@anu3ev/fabric-image-editor 0.5.13 → 0.5.17

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 +832 -814
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -19,23 +19,23 @@ var vt = (h, t) => {
19
19
  t.indexOf(s) < 0 && _e.call(h, s) && (e[s] = h[s]);
20
20
  return e;
21
21
  };
22
- var k = (h, t, e) => new Promise((s, o) => {
23
- var n = (r) => {
22
+ var k = (h, t, e) => new Promise((s, n) => {
23
+ var o = (r) => {
24
24
  try {
25
25
  a(e.next(r));
26
26
  } catch (c) {
27
- o(c);
27
+ n(c);
28
28
  }
29
29
  }, i = (r) => {
30
30
  try {
31
31
  a(e.throw(r));
32
32
  } catch (c) {
33
- o(c);
33
+ n(c);
34
34
  }
35
- }, a = (r) => r.done ? s(r.value) : Promise.resolve(r.value).then(n, i);
35
+ }, a = (r) => r.done ? s(r.value) : Promise.resolve(r.value).then(o, i);
36
36
  a((e = e.apply(h, t)).next());
37
37
  });
38
- import { ActiveSelection as U, Textbox as nt, util as dt, controlsUtils as xe, InteractiveFabricObject as Ne, Point as et, FitContentLayout as Be, loadSVGFromURL as hs, FabricImage as zt, Gradient as ke, Rect as us, Circle as gs, Triangle as fs, Group as Et, Color as ps, classRegistry as ze, loadSVGFromString as ms, Canvas as ys, Pattern as vs } from "fabric";
38
+ import { ActiveSelection as U, Textbox as ot, util as dt, controlsUtils as xe, InteractiveFabricObject as Ne, Point as et, FitContentLayout as Be, loadSVGFromURL as hs, FabricImage as zt, Gradient as ke, Rect as us, Circle as gs, Triangle as fs, Group as Et, Color as ps, classRegistry as ze, loadSVGFromString as ms, Canvas as ys, Pattern as vs } from "fabric";
39
39
  import { create as bs } from "jsondiffpatch";
40
40
  import Ms from "diff-match-patch";
41
41
  var ws = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", V = function() {
@@ -71,15 +71,15 @@ class Ft {
71
71
  adaptCanvasToContainerOnResize: t,
72
72
  canvasDragging: e,
73
73
  mouseWheelZooming: s,
74
- bringToFrontOnSelection: o,
75
- copyObjectsByHotkey: n,
74
+ bringToFrontOnSelection: n,
75
+ copyObjectsByHotkey: o,
76
76
  pasteImageFromClipboard: i,
77
77
  undoRedoByHotKeys: a,
78
78
  selectAllByHotkey: r,
79
79
  deleteObjectsByHotkey: c,
80
80
  resetObjectFitByDoubleClick: d
81
81
  } = this.options;
82
- e && (this.canvas.on("mouse:down", this.handleCanvasDragStartBound), this.canvas.on("mouse:move", this.handleCanvasDraggingBound), this.canvas.on("mouse:up", this.handleCanvasDragEndBound), document.addEventListener("keydown", this.handleSpaceKeyDownBound, { capture: !0 }), document.addEventListener("keyup", this.handleSpaceKeyUpBound, { capture: !0 })), s && this.canvas.on("mouse:wheel", this.handleMouseWheelZoomBound), o && (this.canvas.on("selection:created", this.handleBringToFrontBound), this.canvas.on("selection:updated", this.handleBringToFrontBound)), d && this.canvas.on("mouse:dblclick", this.handleResetObjectFitBound), t && window.addEventListener("resize", this.handleContainerResizeBound, { capture: !0 }), n && document.addEventListener("keydown", this.handleCopyEventBound, { capture: !0 }), i && document.addEventListener("paste", this.handlePasteEventBound, { capture: !0 }), a && (document.addEventListener("keydown", this.handleUndoRedoEventBound, { capture: !0 }), document.addEventListener("keyup", this.handleUndoRedoKeyUpBound, { capture: !0 })), r && document.addEventListener("keydown", this.handleSelectAllEventBound, { capture: !0 }), c && document.addEventListener("keydown", this.handleDeleteObjectsEventBound, { capture: !0 }), this.canvas.on("object:modified", this.handleObjectModifiedHistoryBound), this.canvas.on("object:rotating", this.handleObjectRotatingHistoryBound), this.canvas.on("object:added", this.handleObjectAddedHistoryBound), this.canvas.on("object:removed", this.handleObjectRemovedHistoryBound), this.canvas.on("object:added", this.handleOverlayUpdateBound), this.canvas.on("selection:created", this.handleOverlayUpdateBound), this.canvas.on("selection:created", this.handleLockedSelectionBound), this.canvas.on("selection:updated", this.handleLockedSelectionBound), this.canvas.on("object:added", this.handleBackgroundUpdateBound), this.canvas.on("selection:created", this.handleBackgroundUpdateBound);
82
+ e && (this.canvas.on("mouse:down", this.handleCanvasDragStartBound), this.canvas.on("mouse:move", this.handleCanvasDraggingBound), this.canvas.on("mouse:up", this.handleCanvasDragEndBound), document.addEventListener("keydown", this.handleSpaceKeyDownBound, { capture: !0 }), document.addEventListener("keyup", this.handleSpaceKeyUpBound, { capture: !0 })), s && this.canvas.on("mouse:wheel", this.handleMouseWheelZoomBound), n && (this.canvas.on("selection:created", this.handleBringToFrontBound), this.canvas.on("selection:updated", this.handleBringToFrontBound)), d && this.canvas.on("mouse:dblclick", this.handleResetObjectFitBound), t && window.addEventListener("resize", this.handleContainerResizeBound, { capture: !0 }), o && document.addEventListener("keydown", this.handleCopyEventBound, { capture: !0 }), i && document.addEventListener("paste", this.handlePasteEventBound, { capture: !0 }), a && (document.addEventListener("keydown", this.handleUndoRedoEventBound, { capture: !0 }), document.addEventListener("keyup", this.handleUndoRedoKeyUpBound, { capture: !0 })), r && document.addEventListener("keydown", this.handleSelectAllEventBound, { capture: !0 }), c && document.addEventListener("keydown", this.handleDeleteObjectsEventBound, { capture: !0 }), this.canvas.on("object:modified", this.handleObjectModifiedHistoryBound), this.canvas.on("object:rotating", this.handleObjectRotatingHistoryBound), this.canvas.on("object:added", this.handleObjectAddedHistoryBound), this.canvas.on("object:removed", this.handleObjectRemovedHistoryBound), this.canvas.on("object:added", this.handleOverlayUpdateBound), this.canvas.on("selection:created", this.handleOverlayUpdateBound), this.canvas.on("selection:created", this.handleLockedSelectionBound), this.canvas.on("selection:updated", this.handleLockedSelectionBound), this.canvas.on("object:added", this.handleBackgroundUpdateBound), this.canvas.on("selection:created", this.handleBackgroundUpdateBound);
83
83
  }
84
84
  /**
85
85
  * При массовом выделении объектов удаляем из него залоченные.
@@ -89,16 +89,16 @@ class Ft {
89
89
  */
90
90
  _filterLockedSelection({ selected: t, e }) {
91
91
  if (!(t != null && t.length) || !(e instanceof MouseEvent) || t.length === 1) return;
92
- const { lockedObjects: s, unlockedObjects: o } = t.reduce(
92
+ const { lockedObjects: s, unlockedObjects: n } = t.reduce(
93
93
  (i, a) => a.locked ? (i.lockedObjects.push(a), i) : (i.unlockedObjects.push(a), i),
94
94
  { lockedObjects: [], unlockedObjects: [] }
95
95
  );
96
96
  if (s.length === 0) return;
97
- if (o.length > 0) {
98
- if (o.length === 1)
99
- this.canvas.setActiveObject(o[0]);
97
+ if (n.length > 0) {
98
+ if (n.length === 1)
99
+ this.canvas.setActiveObject(n[0]);
100
100
  else {
101
- const i = new U(o, {
101
+ const i = new U(n, {
102
102
  canvas: this.canvas
103
103
  });
104
104
  this.canvas.setActiveObject(i);
@@ -106,14 +106,14 @@ class Ft {
106
106
  this.canvas.requestRenderAll();
107
107
  return;
108
108
  }
109
- const n = new U(t, {
109
+ const o = new U(t, {
110
110
  canvas: this.canvas
111
111
  });
112
112
  this.editor.objectLockManager.lockObject({
113
- object: n,
113
+ object: o,
114
114
  skipInnerObjects: !0,
115
115
  withoutSave: !0
116
- }), this.canvas.setActiveObject(n), this.canvas.requestRenderAll();
116
+ }), this.canvas.setActiveObject(o), this.canvas.requestRenderAll();
117
117
  }
118
118
  /**
119
119
  * Обработчики для сохранения состояния редактора в истории.
@@ -157,8 +157,8 @@ class Ft {
157
157
  * @param event.code — код клавиши
158
158
  */
159
159
  handleCopyEvent(t) {
160
- const { ctrlKey: e, metaKey: s, code: o } = t;
161
- this._shouldIgnoreKeyboardEvent(t) || !e && !s || o !== "KeyC" || (t.preventDefault(), this.editor.clipboardManager.copy());
160
+ const { ctrlKey: e, metaKey: s, code: n } = t;
161
+ this._shouldIgnoreKeyboardEvent(t) || !e && !s || n !== "KeyC" || (t.preventDefault(), this.editor.clipboardManager.copy());
162
162
  }
163
163
  /**
164
164
  * Обработчик вставки объекта или изображения из буфера обмена.
@@ -176,8 +176,8 @@ class Ft {
176
176
  */
177
177
  handleUndoRedoEvent(t) {
178
178
  return k(this, null, function* () {
179
- const { ctrlKey: e, metaKey: s, code: o, repeat: n } = t;
180
- this._shouldIgnoreKeyboardEvent(t) || !e && !s || n || !/Mac/i.test(navigator.userAgent) && this.isUndoRedoKeyPressed || (o === "KeyZ" ? (t.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.undo()) : o === "KeyY" && (t.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.redo()));
179
+ const { ctrlKey: e, metaKey: s, code: n, repeat: o } = t;
180
+ this._shouldIgnoreKeyboardEvent(t) || !e && !s || o || !/Mac/i.test(navigator.userAgent) && this.isUndoRedoKeyPressed || (n === "KeyZ" ? (t.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.undo()) : n === "KeyY" && (t.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.redo()));
181
181
  });
182
182
  }
183
183
  /**
@@ -197,8 +197,8 @@ class Ft {
197
197
  */
198
198
  handleSelectAllEvent(t) {
199
199
  if (this._shouldIgnoreKeyboardEvent(t)) return;
200
- const { ctrlKey: e, metaKey: s, code: o } = t;
201
- !e && !s || o !== "KeyA" || (t.preventDefault(), this.editor.selectionManager.selectAll());
200
+ const { ctrlKey: e, metaKey: s, code: n } = t;
201
+ !e && !s || n !== "KeyA" || (t.preventDefault(), this.editor.selectionManager.selectAll());
202
202
  }
203
203
  /**
204
204
  * Обработчик для удаления объектов (Delete или Backspace).
@@ -216,8 +216,8 @@ class Ft {
216
216
  */
217
217
  handleSpaceKeyDown(t) {
218
218
  if (t.code !== "Space" || this._shouldIgnoreKeyboardEvent(t)) return;
219
- const { canvas: e, editor: s, isSpacePressed: o, isDragging: n } = this;
220
- if (o || n) return;
219
+ const { canvas: e, editor: s, isSpacePressed: n, isDragging: o } = this;
220
+ if (n || o) return;
221
221
  this.isSpacePressed = !0, t.preventDefault();
222
222
  const i = e.getActiveObject() || null;
223
223
  i instanceof U ? this.savedSelection = i.getObjects().slice() : i && (this.savedSelection = [i]), e.discardActiveObject(), e.set({
@@ -259,8 +259,8 @@ class Ft {
259
259
  e.setActiveObject(t[0]);
260
260
  return;
261
261
  }
262
- const o = t.filter((i) => s.canvasManager.getObjects().includes(i)), n = new U(o, { canvas: e });
263
- e.setActiveObject(n);
262
+ const n = t.filter((i) => s.canvasManager.getObjects().includes(i)), o = new U(n, { canvas: e });
263
+ e.setActiveObject(o);
264
264
  }
265
265
  // --- Обработчики для событий canvas (Fabric) ---
266
266
  /**
@@ -282,8 +282,8 @@ class Ft {
282
282
  const { panConstraintManager: e, montageArea: s } = this.editor;
283
283
  if (!e.isPanAllowed())
284
284
  return;
285
- const o = this.canvas.viewportTransform, n = o[4] + (t.clientX - this.lastMouseX), i = o[5] + (t.clientY - this.lastMouseY), a = e.constrainPan(n, i);
286
- o[4] = a.x, o[5] = a.y, s.setCoords(), this.canvas.requestRenderAll(), this.lastMouseX = t.clientX, this.lastMouseY = t.clientY;
285
+ const n = this.canvas.viewportTransform, o = n[4] + (t.clientX - this.lastMouseX), i = n[5] + (t.clientY - this.lastMouseY), a = e.constrainPan(o, i);
286
+ n[4] = a.x, n[5] = a.y, s.setCoords(), this.canvas.requestRenderAll(), this.lastMouseX = t.clientX, this.lastMouseY = t.clientY;
287
287
  }
288
288
  /**
289
289
  * Завершение перетаскивания канваса (mouse:up).
@@ -301,8 +301,8 @@ class Ft {
301
301
  * @returns Шаг изменения зума
302
302
  */
303
303
  _calculateAdaptiveZoomStep(t) {
304
- const e = this.canvas.getZoom(), s = 0.05, n = t / 100;
305
- return -(e * s * n);
304
+ const e = this.canvas.getZoom(), s = 0.05, o = t / 100;
305
+ return -(e * s * o);
306
306
  }
307
307
  /**
308
308
  * Обработчик зума колесиком мыши. Работает при зажатом Ctrl или Cmd.
@@ -330,7 +330,7 @@ class Ft {
330
330
  */
331
331
  handleResetObjectFit(t) {
332
332
  const e = t == null ? void 0 : t.target;
333
- !e || e instanceof nt || this.editor.transformManager.resetObject({ object: e });
333
+ !e || e instanceof ot || this.editor.transformManager.resetObject({ object: e });
334
334
  }
335
335
  /**
336
336
  * Проверяет, должно ли событие клавиатуры быть проигнорировано
@@ -339,23 +339,23 @@ class Ft {
339
339
  * @returns true если событие должно быть проигнорировано
340
340
  */
341
341
  _shouldIgnoreKeyboardEvent(t) {
342
- const e = document.activeElement, s = t.target, o = ["input", "textarea", "select"];
342
+ const e = document.activeElement, s = t.target, n = ["input", "textarea", "select"];
343
343
  if (s) {
344
344
  const i = s.tagName.toLowerCase();
345
- if (t.type === "paste" && o.includes(i)) {
345
+ if (t.type === "paste" && n.includes(i)) {
346
346
  const a = e == null ? void 0 : e.tagName.toLowerCase();
347
- return !!(a && o.includes(a));
347
+ return !!(a && n.includes(a));
348
348
  }
349
- if (o.includes(i) || s.contentEditable === "true")
349
+ if (n.includes(i) || s.contentEditable === "true")
350
350
  return !0;
351
351
  }
352
352
  if (e && e !== s) {
353
353
  const i = e.tagName.toLowerCase();
354
- if (o.includes(i) || e.contentEditable === "true") return !0;
354
+ if (n.includes(i) || e.contentEditable === "true") return !0;
355
355
  }
356
- const n = window.getSelection();
357
- if (n && !n.isCollapsed && n.rangeCount > 0) {
358
- let r = n.getRangeAt(0).commonAncestorContainer;
356
+ const o = window.getSelection();
357
+ if (o && !o.isCollapsed && o.rangeCount > 0) {
358
+ let r = o.getRangeAt(0).commonAncestorContainer;
359
359
  r.nodeType === Node.TEXT_NODE && (r = r.parentElement);
360
360
  const { keyboardIgnoreSelectors: c } = this.options;
361
361
  if (c != null && c.length && r)
@@ -384,9 +384,9 @@ class Ft {
384
384
  */
385
385
  static debounce(t, e) {
386
386
  let s = null;
387
- return function(...o) {
387
+ return function(...n) {
388
388
  s !== null && clearTimeout(s), s = setTimeout(() => {
389
- t.apply(this, o);
389
+ t.apply(this, n);
390
390
  }, e);
391
391
  };
392
392
  }
@@ -436,12 +436,12 @@ class js {
436
436
  * @returns
437
437
  */
438
438
  _handleMessage({ data: t }) {
439
- const { requestId: e, success: s, data: o, error: n } = t, i = this._callbacks.get(e);
439
+ const { requestId: e, success: s, data: n, error: o } = t, i = this._callbacks.get(e);
440
440
  if (!i) {
441
441
  console.warn(`No callback found for requestId: ${e}`);
442
442
  return;
443
443
  }
444
- s ? i.resolve(o) : i.reject(new Error(n)), this._callbacks.delete(e);
444
+ s ? i.resolve(n) : i.reject(new Error(o)), this._callbacks.delete(e);
445
445
  }
446
446
  /**
447
447
  * Универсальный метод отправки команды в воркер
@@ -451,9 +451,9 @@ class js {
451
451
  * @returns Promise, который будет выполнен, когда воркер вернет ответ
452
452
  */
453
453
  post(t, e, s = []) {
454
- const o = `${t}:${V(8)}`;
455
- return new Promise((n, i) => {
456
- this._callbacks.set(o, { resolve: n, reject: i }), this.worker.postMessage({ action: t, payload: e, requestId: o }, s);
454
+ const n = `${t}:${V(8)}`;
455
+ return new Promise((o, i) => {
456
+ this._callbacks.set(n, { resolve: o, reject: i }), this.worker.postMessage({ action: t, payload: e, requestId: n }, s);
457
457
  });
458
458
  }
459
459
  /**
@@ -464,23 +464,23 @@ class js {
464
464
  }
465
465
  }
466
466
  const rt = 12, Is = 2, de = 8, le = 20, Cs = 100, he = 20, ue = 8, Ts = 100, $t = 32, me = 1, Es = "#2B2D33", ye = "#3D8BF4", ve = "#FFFFFF";
467
- function Xt(h, t, e, s, o) {
468
- const n = rt, i = Is;
469
- h.save(), h.translate(t, e), h.rotate(dt.degreesToRadians(o.angle)), h.fillStyle = ve, h.strokeStyle = ye, h.lineWidth = me, h.beginPath(), h.roundRect(-n / 2, -n / 2, n, n, i), h.fill(), h.stroke(), h.restore();
467
+ function Xt(h, t, e, s, n) {
468
+ const o = rt, i = Is;
469
+ h.save(), h.translate(t, e), h.rotate(dt.degreesToRadians(n.angle)), h.fillStyle = ve, h.strokeStyle = ye, h.lineWidth = me, h.beginPath(), h.roundRect(-o / 2, -o / 2, o, o, i), h.fill(), h.stroke(), h.restore();
470
470
  }
471
- function Ue(h, t, e, s, o) {
472
- const n = de, i = le, a = Cs;
473
- h.save(), h.translate(t, e), h.rotate(dt.degreesToRadians(o.angle)), h.fillStyle = ve, h.strokeStyle = ye, h.lineWidth = me, h.beginPath(), h.roundRect(-n / 2, -i / 2, n, i, a), h.fill(), h.stroke(), h.restore();
471
+ function Ue(h, t, e, s, n) {
472
+ const o = de, i = le, a = Cs;
473
+ h.save(), h.translate(t, e), h.rotate(dt.degreesToRadians(n.angle)), h.fillStyle = ve, h.strokeStyle = ye, h.lineWidth = me, h.beginPath(), h.roundRect(-o / 2, -i / 2, o, i, a), h.fill(), h.stroke(), h.restore();
474
474
  }
475
- function Pe(h, t, e, s, o) {
476
- const n = he, i = ue, a = Ts;
477
- h.save(), h.translate(t, e), h.rotate(dt.degreesToRadians(o.angle)), h.fillStyle = ve, h.strokeStyle = ye, h.lineWidth = me, h.beginPath(), h.roundRect(-n / 2, -i / 2, n, i, a), h.fill(), h.stroke(), h.restore();
475
+ function Pe(h, t, e, s, n) {
476
+ const o = he, i = ue, a = Ts;
477
+ h.save(), h.translate(t, e), h.rotate(dt.degreesToRadians(n.angle)), h.fillStyle = ve, h.strokeStyle = ye, h.lineWidth = me, h.beginPath(), h.roundRect(-o / 2, -i / 2, o, i, a), h.fill(), h.stroke(), h.restore();
478
478
  }
479
479
  const Os = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", ts = new Image();
480
480
  ts.src = Os;
481
- function Ls(h, t, e, s, o) {
481
+ function Ls(h, t, e, s, n) {
482
482
  const i = $t / 2;
483
- h.save(), h.translate(t, e), h.rotate(dt.degreesToRadians(o.angle)), h.fillStyle = Es, h.beginPath(), h.arc(0, 0, i, 0, 2 * Math.PI), h.fill(), h.drawImage(ts, -i / 2, -i / 2, i, i), h.restore();
483
+ h.save(), h.translate(t, e), h.rotate(dt.degreesToRadians(n.angle)), h.fillStyle = Es, h.beginPath(), h.arc(0, 0, i, 0, 2 * Math.PI), h.fill(), h.drawImage(ts, -i / 2, -i / 2, i, i), h.restore();
484
484
  }
485
485
  const Ds = {
486
486
  // Угловые точки
@@ -558,9 +558,9 @@ class $ {
558
558
  static wrapWidthControl(t) {
559
559
  if (!(t != null && t.actionHandler)) return;
560
560
  const e = t.actionHandler;
561
- t.actionHandler = (s, o, n, i) => {
562
- const a = o == null ? void 0 : o.target;
563
- return !a || a.locked || a.lockScalingX ? !1 : e(s, o, n, i);
561
+ t.actionHandler = (s, n, o, i) => {
562
+ const a = n == null ? void 0 : n.target;
563
+ return !a || a.locked || a.lockScalingX ? !1 : e(s, n, o, i);
564
564
  };
565
565
  }
566
566
  /**
@@ -568,8 +568,8 @@ class $ {
568
568
  */
569
569
  static applyControlOverrides(t) {
570
570
  Object.entries(Ds).forEach(([e, s]) => {
571
- const o = t[e];
572
- o && (Object.assign(o, s), e === "mtr" && (o.cursorStyle = "grab", o.mouseDownHandler = (n, i, a, r) => {
571
+ const n = t[e];
572
+ n && (Object.assign(n, s), e === "mtr" && (n.cursorStyle = "grab", n.mouseDownHandler = (o, i, a, r) => {
573
573
  var d;
574
574
  const c = i == null ? void 0 : i.target;
575
575
  (d = c == null ? void 0 : c.canvas) == null || d.setCursor("grabbing");
@@ -583,14 +583,14 @@ class $ {
583
583
  const t = xe.createObjectDefaultControls();
584
584
  $.applyControlOverrides(t), Ne.ownDefaults.controls = t;
585
585
  const e = xe.createTextboxDefaultControls();
586
- $.applyControlOverrides(e), e.mt && (e.mt.visible = !1), e.mb && (e.mb.visible = !1), $.wrapWidthControl(e.ml), $.wrapWidthControl(e.mr), nt.ownDefaults.controls = e, $.patchActiveSelectionBounds(), Ne.ownDefaults.snapAngle = 1;
586
+ $.applyControlOverrides(e), e.mt && (e.mt.visible = !1), e.mb && (e.mb.visible = !1), $.wrapWidthControl(e.ml), $.wrapWidthControl(e.mr), ot.ownDefaults.controls = e, $.patchActiveSelectionBounds(), Ne.ownDefaults.snapAngle = 1;
587
587
  }
588
588
  /**
589
589
  * Обновляет алгоритм расчёта границ ActiveSelection, чтобы учитывать фон и отступы текстовых объектов.
590
590
  */
591
591
  static patchActiveSelectionBounds() {
592
592
  const t = U.prototype, e = t._calcBoundsFromObjects;
593
- t._calcBoundsFromObjects = function(...n) {
593
+ t._calcBoundsFromObjects = function(...o) {
594
594
  var g, f;
595
595
  const i = (f = (g = this.getObjects) == null ? void 0 : g.call(this)) != null ? f : [];
596
596
  $.applyTextSelectionScalingLock({
@@ -601,7 +601,7 @@ class $ {
601
601
  objects: i
602
602
  });
603
603
  if (!a)
604
- return e ? e.apply(this, n) : void 0;
604
+ return e ? e.apply(this, o) : void 0;
605
605
  const { left: r, top: c, width: d, height: l } = a;
606
606
  this.set({
607
607
  flipX: !1,
@@ -613,9 +613,9 @@ class $ {
613
613
  return this.setPositionByOrigin(u, "center", "center"), a;
614
614
  };
615
615
  const s = t._onAfterObjectsChange;
616
- t._onAfterObjectsChange = function(n, i) {
616
+ t._onAfterObjectsChange = function(o, i) {
617
617
  var p, m;
618
- const a = s ? s.call(this, n, i) : void 0, r = (m = (p = this.getObjects) == null ? void 0 : p.call(this)) != null ? m : [];
618
+ const a = s ? s.call(this, o, i) : void 0, r = (m = (p = this.getObjects) == null ? void 0 : p.call(this)) != null ? m : [];
619
619
  $.applyTextSelectionScalingLock({
620
620
  selection: this,
621
621
  objects: r
@@ -630,20 +630,20 @@ class $ {
630
630
  height: g
631
631
  }), this.setPositionByOrigin(f, "center", "center"), this.setCoords(), a;
632
632
  };
633
- const o = Be.prototype.calcBoundingBox;
634
- Be.prototype.calcBoundingBox = function(n, i) {
633
+ const n = Be.prototype.calcBoundingBox;
634
+ Be.prototype.calcBoundingBox = function(o, i) {
635
635
  const { target: a, type: r, overrides: c } = i;
636
636
  if (r === "imperative" && c)
637
637
  return c;
638
638
  if (!(a instanceof U))
639
- return o.call(this, n, i);
639
+ return n.call(this, o, i);
640
640
  $.applyTextSelectionScalingLock({
641
641
  selection: a,
642
- objects: n
642
+ objects: o
643
643
  });
644
- const d = $.calculateActiveSelectionBounds({ objects: n });
644
+ const d = $.calculateActiveSelectionBounds({ objects: o });
645
645
  if (!d)
646
- return o.call(this, n, i);
646
+ return n.call(this, o, i);
647
647
  const { left: l, top: u, width: g, height: f } = d, p = new et(g, f), m = new et(l + g / 2, u + f / 2);
648
648
  return r === "initialization" ? {
649
649
  center: m,
@@ -662,12 +662,12 @@ class $ {
662
662
  objects: t
663
663
  }) {
664
664
  if (!t.length) return null;
665
- const e = t.map((a) => a.getBoundingRect()), s = Math.min(...e.map(({ left: a }) => a)), o = Math.min(...e.map(({ top: a }) => a)), n = Math.max(...e.map(({ left: a, width: r }) => a + r));
665
+ const e = t.map((a) => a.getBoundingRect()), s = Math.min(...e.map(({ left: a }) => a)), n = Math.min(...e.map(({ top: a }) => a)), o = Math.max(...e.map(({ left: a, width: r }) => a + r));
666
666
  return {
667
- height: Math.max(...e.map(({ top: a, height: r }) => a + r)) - o,
667
+ height: Math.max(...e.map(({ top: a, height: r }) => a + r)) - n,
668
668
  left: s,
669
- top: o,
670
- width: n - s
669
+ top: n,
670
+ width: o - s
671
671
  };
672
672
  }
673
673
  /**
@@ -677,7 +677,7 @@ class $ {
677
677
  selection: t,
678
678
  objects: e
679
679
  }) {
680
- const s = e.some((o) => o instanceof nt);
680
+ const s = e.some((n) => n instanceof ot);
681
681
  t.setControlsVisibility({
682
682
  mt: !s,
683
683
  mb: !s,
@@ -695,33 +695,33 @@ const z = class z {
695
695
  }
696
696
  loadFonts() {
697
697
  return k(this, null, function* () {
698
- var o;
699
- const t = (o = this.fonts) != null ? o : [];
698
+ var n;
699
+ const t = (n = this.fonts) != null ? n : [];
700
700
  if (!t.length) return;
701
701
  const e = typeof document != "undefined" ? document : void 0;
702
702
  if (!e) return;
703
- const s = t.map((n) => z.loadFont(n, e));
703
+ const s = t.map((o) => z.loadFont(o, e));
704
704
  yield Promise.allSettled(s);
705
705
  });
706
706
  }
707
707
  static loadFont(t, e) {
708
708
  return k(this, null, function* () {
709
709
  var c, d;
710
- const s = typeof FontFace != "undefined", o = (c = t.family) == null ? void 0 : c.trim(), n = (d = t.source) == null ? void 0 : d.trim();
711
- if (!o || !n) return;
712
- const i = z.normalizeFontSource(n), a = z.getDescriptorSnapshot(t.descriptors), r = z.getFontRegistrationKey(o, i, a);
710
+ const s = typeof FontFace != "undefined", n = (c = t.family) == null ? void 0 : c.trim(), o = (d = t.source) == null ? void 0 : d.trim();
711
+ if (!n || !o) return;
712
+ const i = z.normalizeFontSource(o), a = z.getDescriptorSnapshot(t.descriptors), r = z.getFontRegistrationKey(n, i, a);
713
713
  if (!z.registeredFontKeys.has(r)) {
714
- if (z.isFontFaceAlreadyApplied(e, o, a)) {
714
+ if (z.isFontFaceAlreadyApplied(e, n, a)) {
715
715
  z.registeredFontKeys.add(r);
716
716
  return;
717
717
  }
718
718
  if (s && e.fonts && typeof e.fonts.add == "function")
719
719
  try {
720
- const u = yield new FontFace(o, i, t.descriptors).load();
720
+ const u = yield new FontFace(n, i, t.descriptors).load();
721
721
  e.fonts.add(u), z.registeredFontKeys.add(r);
722
722
  return;
723
723
  } catch (l) {
724
- console.warn(`Не удалось загрузить шрифт "${o}" через FontFace API`, l);
724
+ console.warn(`Не удалось загрузить шрифт "${n}" через FontFace API`, l);
725
725
  }
726
726
  z.injectFontFace({
727
727
  font: t,
@@ -736,14 +736,14 @@ const z = class z {
736
736
  font: t,
737
737
  source: e,
738
738
  doc: s,
739
- registrationKey: o
739
+ registrationKey: n
740
740
  }) {
741
741
  var d;
742
- const { descriptors: n } = t, i = (d = t.family) == null ? void 0 : d.trim();
742
+ const { descriptors: o } = t, i = (d = t.family) == null ? void 0 : d.trim();
743
743
  if (!i) return;
744
744
  const a = s.createElement("style");
745
- a.setAttribute("data-editor-font", i), a.setAttribute("data-editor-font-key", o);
746
- const r = z.descriptorsToCss(n), c = [
745
+ a.setAttribute("data-editor-font", i), a.setAttribute("data-editor-font-key", n);
746
+ const r = z.descriptorsToCss(o), c = [
747
747
  "@font-face {",
748
748
  ` font-family: ${z.formatFontFamilyForCss(i)};`,
749
749
  ` src: ${e};`,
@@ -751,7 +751,7 @@ const z = class z {
751
751
  "}"
752
752
  ];
753
753
  a.textContent = c.join(`
754
- `), s.head.appendChild(a), z.registeredFontKeys.add(o);
754
+ `), s.head.appendChild(a), z.registeredFontKeys.add(n);
755
755
  }
756
756
  static normalizeFontSource(t) {
757
757
  const e = t.trim();
@@ -762,8 +762,8 @@ const z = class z {
762
762
  }
763
763
  static normalizeDescriptorValue(t, e) {
764
764
  if (typeof t == "string") {
765
- const o = t.trim();
766
- return o.length > 0 ? o : e;
765
+ const n = t.trim();
766
+ return n.length > 0 ? n : e;
767
767
  }
768
768
  if (t == null)
769
769
  return e;
@@ -802,13 +802,13 @@ const z = class z {
802
802
  ].join("::");
803
803
  }
804
804
  static isFontFaceAlreadyApplied(t, e, s) {
805
- const o = t.fonts;
806
- if (!o || typeof o.forEach != "function") return !1;
807
- const n = z.normalizeFamilyName(e);
805
+ const n = t.fonts;
806
+ if (!n || typeof n.forEach != "function") return !1;
807
+ const o = z.normalizeFamilyName(e);
808
808
  let i = !1;
809
809
  try {
810
- o.forEach((a) => {
811
- if (i || z.normalizeFamilyName(a.family) !== n) return;
810
+ n.forEach((a) => {
811
+ if (i || z.normalizeFamilyName(a.family) !== o) return;
812
812
  const c = z.getDescriptorSnapshot({
813
813
  style: a.style,
814
814
  weight: a.weight,
@@ -839,9 +839,9 @@ const z = class z {
839
839
  descentOverride: "descent-override",
840
840
  lineGapOverride: "line-gap-override"
841
841
  };
842
- return Object.entries(t).filter(([, s]) => s != null && `${s}`.length > 0).map(([s, o]) => {
842
+ return Object.entries(t).filter(([, s]) => s != null && `${s}`.length > 0).map(([s, n]) => {
843
843
  var i;
844
- return `${(i = e[s]) != null ? i : s}: ${o};`;
844
+ return `${(i = e[s]) != null ? i : s}: ${n};`;
845
845
  });
846
846
  }
847
847
  };
@@ -980,11 +980,11 @@ class Ps {
980
980
  _createDOM() {
981
981
  const { style: t } = this.config;
982
982
  this.el = document.createElement("div"), Object.assign(this.el.style, t), this.canvas.wrapperEl.appendChild(this.el), this._onBtnOver = (e) => {
983
- const o = e.target.closest("button");
984
- o && Object.assign(o.style, this.config.btnHover);
983
+ const n = e.target.closest("button");
984
+ n && Object.assign(n.style, this.config.btnHover);
985
985
  }, this._onBtnOut = (e) => {
986
- const o = e.target.closest("button");
987
- o && Object.assign(o.style, this.config.btnStyle);
986
+ const n = e.target.closest("button");
987
+ n && Object.assign(n.style, this.config.btnStyle);
988
988
  }, this.el.addEventListener("mouseover", this._onBtnOver), this.el.addEventListener("mouseout", this._onBtnOut);
989
989
  }
990
990
  /**
@@ -996,10 +996,10 @@ class Ps {
996
996
  _renderButtons(t) {
997
997
  this.el.innerHTML = "";
998
998
  for (const e of t) {
999
- const { name: s, handle: o } = e, { icons: n = {}, btnStyle: i, handlers: a = {} } = this.config, r = document.createElement("button");
1000
- r.innerHTML = n[o] ? `<img src="${n[o]}" title="${s}" />` : s, Object.assign(r.style, i), r.onclick = () => {
999
+ const { name: s, handle: n } = e, { icons: o = {}, btnStyle: i, handlers: a = {} } = this.config, r = document.createElement("button");
1000
+ r.innerHTML = o[n] ? `<img src="${o[n]}" title="${s}" />` : s, Object.assign(r.style, i), r.onclick = () => {
1001
1001
  var c;
1002
- return (c = a[o]) == null ? void 0 : c.call(a, this.editor);
1002
+ return (c = a[n]) == null ? void 0 : c.call(a, this.editor);
1003
1003
  }, r.onmousedown = (c) => {
1004
1004
  c.stopPropagation(), c.preventDefault();
1005
1005
  }, r.ondragstart = (c) => c.preventDefault(), this.el.appendChild(r);
@@ -1070,9 +1070,9 @@ class Ps {
1070
1070
  this.el.style.display = "none";
1071
1071
  return;
1072
1072
  }
1073
- const { el: e, config: s, canvas: o } = this;
1073
+ const { el: e, config: s, canvas: n } = this;
1074
1074
  t.setCoords();
1075
- const n = o.getZoom(), [, , , , i, a] = o.viewportTransform, { x: r } = t.getCenterPoint(), { top: c, height: d } = t.getBoundingRect(), u = r * n + i - e.offsetWidth / 2, g = s.offsetTop || 0, f = (c + d) * n + a + g;
1075
+ const o = n.getZoom(), [, , , , i, a] = n.viewportTransform, { x: r } = t.getCenterPoint(), { top: c, height: d } = t.getBoundingRect(), u = r * o + i - e.offsetWidth / 2, g = s.offsetTop || 0, f = (c + d) * o + a + g;
1076
1076
  Object.assign(e.style, {
1077
1077
  left: `${u}px`,
1078
1078
  top: `${f}px`,
@@ -1160,9 +1160,9 @@ class be {
1160
1160
  */
1161
1161
  _positionIndicator(t) {
1162
1162
  const e = this.canvas.wrapperEl.getBoundingClientRect();
1163
- let s = t.clientX - e.left + Fe, o = t.clientY - e.top + We;
1164
- const n = this.el.getBoundingClientRect(), i = n.width, a = n.height;
1165
- s + i > e.width && (s = t.clientX - e.left - i - Fe), o + a > e.height && (o = t.clientY - e.top - a - We), this.el.style.left = `${s}px`, this.el.style.top = `${o}px`;
1163
+ let s = t.clientX - e.left + Fe, n = t.clientY - e.top + We;
1164
+ const o = this.el.getBoundingClientRect(), i = o.width, a = o.height;
1165
+ s + i > e.width && (s = t.clientX - e.left - i - Fe), n + a > e.height && (n = t.clientY - e.top - a - We), this.el.style.left = `${s}px`, this.el.style.top = `${n}px`;
1166
1166
  }
1167
1167
  /**
1168
1168
  * Показать индикатор
@@ -1242,7 +1242,7 @@ class Ys {
1242
1242
  _createDiffPatcher() {
1243
1243
  this.diffPatcher = bs({
1244
1244
  objectHash(t) {
1245
- const e = t, s = t, o = s.styles ? JSON.stringify(s.styles) : "", n = e.customData ? JSON.stringify(e.customData) : "";
1245
+ const e = t, s = t, n = s.styles ? JSON.stringify(s.styles) : "", o = e.customData ? JSON.stringify(e.customData) : "";
1246
1246
  return [
1247
1247
  e.id,
1248
1248
  e.backgroundId,
@@ -1258,7 +1258,7 @@ class Ys {
1258
1258
  e.scaleY,
1259
1259
  e.angle,
1260
1260
  e.opacity,
1261
- n,
1261
+ o,
1262
1262
  s.text,
1263
1263
  s.textCaseRaw,
1264
1264
  s.uppercase,
@@ -1272,7 +1272,7 @@ class Ys {
1272
1272
  s.fill,
1273
1273
  s.stroke,
1274
1274
  s.strokeWidth,
1275
- o,
1275
+ n,
1276
1276
  s.paddingTop,
1277
1277
  s.paddingRight,
1278
1278
  s.paddingBottom,
@@ -1320,10 +1320,10 @@ class Ys {
1320
1320
  */
1321
1321
  getFullState() {
1322
1322
  const { baseState: t, currentIndex: e, patches: s } = this;
1323
- let o = JSON.parse(JSON.stringify(t));
1324
- for (let n = 0; n < e; n += 1)
1325
- o = this.diffPatcher.patch(o, s[n].diff);
1326
- return console.log("getFullState state", o), o;
1323
+ let n = JSON.parse(JSON.stringify(t));
1324
+ for (let o = 0; o < e; o += 1)
1325
+ n = this.diffPatcher.patch(n, s[o].diff);
1326
+ return console.log("getFullState state", n), n;
1327
1327
  }
1328
1328
  /**
1329
1329
  * Сохраняем текущее состояние в виде диффа от последнего сохранённого полного состояния.
@@ -1359,14 +1359,14 @@ class Ys {
1359
1359
  return k(this, null, function* () {
1360
1360
  if (!t) return;
1361
1361
  console.log("loadStateFromFullState fullState", t);
1362
- const { canvas: e, canvasManager: s, interactionBlocker: o, backgroundManager: n } = this.editor, { width: i, height: a } = e;
1363
- o.overlayMask = null, yield e.loadFromJSON(t);
1362
+ const { canvas: e, canvasManager: s, interactionBlocker: n, backgroundManager: o } = this.editor, { width: i, height: a } = e;
1363
+ n.overlayMask = null, yield e.loadFromJSON(t);
1364
1364
  const r = e.getObjects().find((l) => l.id === "montage-area");
1365
1365
  r && (this.editor.montageArea = r, (i !== e.getWidth() || a !== e.getHeight()) && s.updateCanvas());
1366
1366
  const c = e.getObjects().find((l) => l.id === "overlay-mask");
1367
- c && (o.overlayMask = c, o.overlayMask.visible = !1);
1367
+ c && (n.overlayMask = c, n.overlayMask.visible = !1);
1368
1368
  const d = e.getObjects().find((l) => l.id === "background");
1369
- d ? (n.backgroundObject = d, n.refresh()) : n.removeBackground({ withoutSave: !0 }), e.renderAll(), e.fire("editor:history-state-loaded", {
1369
+ d ? (o.backgroundObject = d, o.refresh()) : o.removeBackground({ withoutSave: !0 }), e.renderAll(), e.fire("editor:history-state-loaded", {
1370
1370
  fullState: t,
1371
1371
  currentIndex: this.currentIndex,
1372
1372
  totalChangesCount: this.totalChangesCount,
@@ -1451,9 +1451,9 @@ class Ys {
1451
1451
  });
1452
1452
  }
1453
1453
  _withTemporaryUnlock(t) {
1454
- var o, n, i;
1454
+ var n, o, i;
1455
1455
  const e = [];
1456
- ((i = (n = (o = this.canvas).getObjects) == null ? void 0 : n.call(o)) != null ? i : []).forEach((a) => {
1456
+ ((i = (o = (n = this.canvas).getObjects) == null ? void 0 : o.call(n)) != null ? i : []).forEach((a) => {
1457
1457
  const r = typeof a.type == "string" ? a.type.toLowerCase() : "";
1458
1458
  if (!(r === "textbox" || r === "i-text" || typeof a.isEditing == "boolean") || a.locked) return;
1459
1459
  const d = !!a.lockMovementX, l = !!a.lockMovementY;
@@ -1509,8 +1509,8 @@ class ct {
1509
1509
  const {
1510
1510
  source: e,
1511
1511
  scale: s = `image-${this.options.scaleType}`,
1512
- withoutSave: o = !1,
1513
- fromClipboard: n = !1,
1512
+ withoutSave: n = !1,
1513
+ fromClipboard: o = !1,
1514
1514
  isBackground: i = !1,
1515
1515
  withoutSelection: a = !1,
1516
1516
  withoutAdding: r = !1
@@ -1530,7 +1530,7 @@ class ct {
1530
1530
  contentType: f,
1531
1531
  acceptContentTypes: m,
1532
1532
  acceptFormats: v,
1533
- fromClipboard: n,
1533
+ fromClipboard: o,
1534
1534
  isBackground: i,
1535
1535
  withoutSelection: a,
1536
1536
  withoutAdding: r
@@ -1557,7 +1557,7 @@ class ct {
1557
1557
  contentType: f,
1558
1558
  acceptContentTypes: m,
1559
1559
  acceptFormats: v,
1560
- fromClipboard: n,
1560
+ fromClipboard: o,
1561
1561
  isBackground: i,
1562
1562
  withoutSelection: a,
1563
1563
  withoutAdding: r
@@ -1591,14 +1591,14 @@ class ct {
1591
1591
  format: p,
1592
1592
  contentType: f,
1593
1593
  scale: s,
1594
- withoutSave: o,
1594
+ withoutSave: n,
1595
1595
  source: e,
1596
- fromClipboard: n,
1596
+ fromClipboard: o,
1597
1597
  isBackground: i,
1598
1598
  withoutSelection: a,
1599
1599
  withoutAdding: r
1600
1600
  };
1601
- return r ? (u.resumeHistory(), c.fire("editor:image-imported", I), I) : (c.add(S), c.centerObject(S), a || c.setActiveObject(S), c.renderAll(), u.resumeHistory(), o || u.saveState(), c.fire("editor:image-imported", I), I);
1601
+ return r ? (u.resumeHistory(), c.fire("editor:image-imported", I), I) : (c.add(S), c.centerObject(S), a || c.setActiveObject(S), c.renderAll(), u.resumeHistory(), n || u.saveState(), c.fire("editor:image-imported", I), I);
1602
1602
  } catch (M) {
1603
1603
  return g.emitError({
1604
1604
  origin: "ImageManager",
@@ -1610,8 +1610,8 @@ class ct {
1610
1610
  format: p,
1611
1611
  contentType: f,
1612
1612
  scale: s,
1613
- withoutSave: o,
1614
- fromClipboard: n,
1613
+ withoutSave: n,
1614
+ fromClipboard: o,
1615
1615
  isBackground: i,
1616
1616
  withoutSelection: a,
1617
1617
  withoutAdding: r
@@ -1632,7 +1632,7 @@ class ct {
1632
1632
  return k(this, null, function* () {
1633
1633
  let s = `Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ${Mt}x${wt}`;
1634
1634
  e === "min" && (s = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${Rt}x${_t}`);
1635
- const o = {
1635
+ const n = {
1636
1636
  dataURL: t,
1637
1637
  sizeType: e,
1638
1638
  maxWidth: Mt,
@@ -1645,8 +1645,8 @@ class ct {
1645
1645
  method: "resizeImageToBoundaries",
1646
1646
  code: "IMAGE_RESIZE_WARNING",
1647
1647
  message: s,
1648
- data: o
1649
- }), this.editor.workerManager.post("resizeImage", o);
1648
+ data: n
1649
+ }), this.editor.workerManager.post("resizeImage", n);
1650
1650
  });
1651
1651
  }
1652
1652
  /**
@@ -1665,8 +1665,8 @@ class ct {
1665
1665
  const {
1666
1666
  fileName: e = "image.png",
1667
1667
  contentType: s = "image/png",
1668
- exportAsBase64: o = !1,
1669
- exportAsBlob: n = !1
1668
+ exportAsBase64: n = !1,
1669
+ exportAsBlob: o = !1
1670
1670
  } = t, { canvas: i, montageArea: a, workerManager: r, interactionBlocker: c } = this.editor;
1671
1671
  try {
1672
1672
  const d = s === "application/pdf", l = d ? "image/jpg" : s, u = ct.getFormatFromContentType(l);
@@ -1685,8 +1685,8 @@ class ct {
1685
1685
  v.dispose();
1686
1686
  const E = {
1687
1687
  image: ct._exportSVGStringAsFile(w, {
1688
- exportAsBase64: o,
1689
- exportAsBlob: n,
1688
+ exportAsBase64: n,
1689
+ exportAsBlob: o,
1690
1690
  fileName: e
1691
1691
  }),
1692
1692
  format: "svg",
@@ -1700,7 +1700,7 @@ class ct {
1700
1700
  E ? w(E) : T(new Error("Failed to create Blob from canvas"));
1701
1701
  });
1702
1702
  });
1703
- if (v.dispose(), n) {
1703
+ if (v.dispose(), o) {
1704
1704
  const w = {
1705
1705
  image: y,
1706
1706
  format: u,
@@ -1720,7 +1720,7 @@ class ct {
1720
1720
  unit: "mm",
1721
1721
  format: [T, E]
1722
1722
  });
1723
- if (x.addImage(String(I), "JPG", 0, 0, T, E), o) {
1723
+ if (x.addImage(String(I), "JPG", 0, 0, T, E), n) {
1724
1724
  const W = {
1725
1725
  image: x.output("datauristring"),
1726
1726
  format: "pdf",
@@ -1737,7 +1737,7 @@ class ct {
1737
1737
  };
1738
1738
  return i.fire("editor:canvas-exported", D), D;
1739
1739
  }
1740
- if (o) {
1740
+ if (n) {
1741
1741
  const w = {
1742
1742
  image: I,
1743
1743
  format: u,
@@ -1759,7 +1759,7 @@ class ct {
1759
1759
  method: "exportCanvasAsImageFile",
1760
1760
  code: "IMAGE_EXPORT_FAILED",
1761
1761
  message: `Ошибка экспорта изображения: ${d.message}`,
1762
- data: { contentType: s, fileName: e, exportAsBase64: o, exportAsBlob: n }
1762
+ data: { contentType: s, fileName: e, exportAsBase64: n, exportAsBlob: o }
1763
1763
  }), null;
1764
1764
  }
1765
1765
  });
@@ -1780,8 +1780,8 @@ class ct {
1780
1780
  const {
1781
1781
  object: e,
1782
1782
  fileName: s = "image.png",
1783
- contentType: o = "image/png",
1784
- exportAsBase64: n = !1,
1783
+ contentType: n = "image/png",
1784
+ exportAsBase64: o = !1,
1785
1785
  exportAsBlob: i = !1
1786
1786
  } = t, { canvas: a, workerManager: r } = this.editor, c = e || a.getActiveObject();
1787
1787
  if (!c)
@@ -1790,13 +1790,13 @@ class ct {
1790
1790
  method: "exportObjectAsImageFile",
1791
1791
  code: "NO_OBJECT_SELECTED",
1792
1792
  message: "Не выбран объект для экспорта",
1793
- data: { contentType: o, fileName: s, exportAsBase64: n, exportAsBlob: i }
1793
+ data: { contentType: n, fileName: s, exportAsBase64: o, exportAsBlob: i }
1794
1794
  }), null;
1795
1795
  try {
1796
- const d = ct.getFormatFromContentType(o);
1796
+ const d = ct.getFormatFromContentType(n);
1797
1797
  if (d === "svg") {
1798
1798
  const p = c.toSVG(), m = ct._exportSVGStringAsFile(p, {
1799
- exportAsBase64: n,
1799
+ exportAsBase64: o,
1800
1800
  exportAsBlob: i,
1801
1801
  fileName: s
1802
1802
  }), v = {
@@ -1808,7 +1808,7 @@ class ct {
1808
1808
  };
1809
1809
  return a.fire("editor:object-exported", v), v;
1810
1810
  }
1811
- if (n && c instanceof zt) {
1811
+ if (o && c instanceof zt) {
1812
1812
  const p = yield createImageBitmap(c.getElement()), m = yield r.post(
1813
1813
  "toDataURL",
1814
1814
  {
@@ -1821,7 +1821,7 @@ class ct {
1821
1821
  object: c,
1822
1822
  image: m,
1823
1823
  format: d,
1824
- contentType: o,
1824
+ contentType: n,
1825
1825
  fileName: s
1826
1826
  };
1827
1827
  return a.fire("editor:object-exported", v), v;
@@ -1838,16 +1838,16 @@ class ct {
1838
1838
  object: c,
1839
1839
  image: u,
1840
1840
  format: d,
1841
- contentType: o,
1841
+ contentType: n,
1842
1842
  fileName: s
1843
1843
  };
1844
1844
  return a.fire("editor:object-exported", p), p;
1845
1845
  }
1846
- const g = new File([u], s, { type: o }), f = {
1846
+ const g = new File([u], s, { type: n }), f = {
1847
1847
  object: c,
1848
1848
  image: g,
1849
1849
  format: d,
1850
- contentType: o,
1850
+ contentType: n,
1851
1851
  fileName: s
1852
1852
  };
1853
1853
  return a.fire("editor:object-exported", f), f;
@@ -1857,7 +1857,7 @@ class ct {
1857
1857
  method: "exportObjectAsImageFile",
1858
1858
  code: "IMAGE_EXPORT_FAILED",
1859
1859
  message: `Ошибка экспорта объекта: ${d.message}`,
1860
- data: { contentType: o, fileName: s, exportAsBase64: n, exportAsBlob: i }
1860
+ data: { contentType: n, fileName: s, exportAsBase64: o, exportAsBlob: i }
1861
1861
  }), null;
1862
1862
  }
1863
1863
  });
@@ -1924,11 +1924,11 @@ class ct {
1924
1924
  getContentTypeFromExtension(t) {
1925
1925
  var e;
1926
1926
  try {
1927
- const o = (e = new URL(t).pathname.split(".").pop()) == null ? void 0 : e.toLowerCase(), n = {};
1927
+ const n = (e = new URL(t).pathname.split(".").pop()) == null ? void 0 : e.toLowerCase(), o = {};
1928
1928
  return this.acceptContentTypes.forEach((i) => {
1929
1929
  const a = ct.getFormatFromContentType(i);
1930
- a && (n[a] = i);
1931
- }), o && n[o] || "application/octet-stream";
1930
+ a && (o[a] = i);
1931
+ }), n && o[n] || "application/octet-stream";
1932
1932
  } catch (s) {
1933
1933
  return console.warn("Не удалось определить расширение из URL:", t, s), "application/octet-stream";
1934
1934
  }
@@ -1946,8 +1946,8 @@ class ct {
1946
1946
  }) {
1947
1947
  const { montageArea: s } = this.editor;
1948
1948
  if (!s || !t) return 1;
1949
- const o = s.width, n = s.height, { width: i, height: a } = t;
1950
- return e === "contain" || e === "image-contain" ? Math.min(o / i, n / a) : e === "cover" || e === "image-cover" ? Math.max(o / i, n / a) : 1;
1949
+ const n = s.width, o = s.height, { width: i, height: a } = t;
1950
+ return e === "contain" || e === "image-contain" ? Math.min(n / i, o / a) : e === "cover" || e === "image-cover" ? Math.max(n / i, o / a) : 1;
1951
1951
  }
1952
1952
  /**
1953
1953
  * Преобразует SVG-строку в Blob, файл, или base64
@@ -1963,9 +1963,9 @@ class ct {
1963
1963
  static _exportSVGStringAsFile(t, {
1964
1964
  exportAsBase64: e,
1965
1965
  exportAsBlob: s,
1966
- fileName: o = "image.svg"
1966
+ fileName: n = "image.svg"
1967
1967
  } = {}) {
1968
- return s ? new Blob([t], { type: "image/svg+xml" }) : e ? `data:image/svg+xml;base64,${window.btoa(encodeURIComponent(t))}` : new File([t], o.replace(/\.[^/.]+$/, ".svg"), { type: "image/svg+xml" });
1968
+ return s ? new Blob([t], { type: "image/svg+xml" }) : e ? `data:image/svg+xml;base64,${window.btoa(encodeURIComponent(t))}` : new File([t], n.replace(/\.[^/.]+$/, ".svg"), { type: "image/svg+xml" });
1969
1969
  }
1970
1970
  /**
1971
1971
  * Извлекает чистый формат (subtype) из contentType,
@@ -2007,25 +2007,25 @@ class Qs {
2007
2007
  * @param options.adaptCanvasToContainer - Адаптировать канвас к контейнеру
2008
2008
  * @fires editor:resolution-width-changed
2009
2009
  */
2010
- setResolutionWidth(t, { preserveProportional: e, withoutSave: s, adaptCanvasToContainer: o } = {}) {
2010
+ setResolutionWidth(t, { preserveProportional: e, withoutSave: s, adaptCanvasToContainer: n } = {}) {
2011
2011
  var f;
2012
2012
  if (!t) return;
2013
2013
  const {
2014
- canvas: n,
2014
+ canvas: o,
2015
2015
  montageArea: i,
2016
2016
  options: { canvasBackstoreWidth: a }
2017
2017
  } = this.editor, { width: r, height: c } = i, d = Tt(Number(t), Rt, Mt);
2018
- if (!a || a === "auto" || o ? this.adaptCanvasToContainer() : a ? this.setCanvasBackstoreWidth(Number(a)) : this.setCanvasBackstoreWidth(d), i.set({ width: d }), (f = n.clipPath) == null || f.set({ width: d }), e) {
2018
+ if (!a || a === "auto" || n ? this.adaptCanvasToContainer() : a ? this.setCanvasBackstoreWidth(Number(a)) : this.setCanvasBackstoreWidth(d), i.set({ width: d }), (f = o.clipPath) == null || f.set({ width: d }), e) {
2019
2019
  const p = d / r, m = Ze(c, p);
2020
2020
  this.setResolutionHeight(m);
2021
2021
  return;
2022
2022
  }
2023
- const { left: l, top: u } = this.getObjectDefaultCoords(i), g = n.getZoom();
2024
- n.setViewportTransform([g, 0, 0, g, l, u]), this.centerMontageArea(), s || this.editor.historyManager.saveState(), n.fire("editor:resolution-width-changed", {
2023
+ const { left: l, top: u } = this.getObjectDefaultCoords(i), g = o.getZoom();
2024
+ o.setViewportTransform([g, 0, 0, g, l, u]), this.centerMontageArea(), s || this.editor.historyManager.saveState(), o.fire("editor:resolution-width-changed", {
2025
2025
  width: d,
2026
2026
  preserveProportional: e,
2027
2027
  withoutSave: s,
2028
- adaptCanvasToContainer: o
2028
+ adaptCanvasToContainer: n
2029
2029
  }), this.editor.panConstraintManager.updateBounds();
2030
2030
  }
2031
2031
  /**
@@ -2037,25 +2037,25 @@ class Qs {
2037
2037
  * @param options.adaptCanvasToContainer - Адаптировать канвас к контейнеру
2038
2038
  * @fires editor:resolution-height-changed
2039
2039
  */
2040
- setResolutionHeight(t, { preserveProportional: e, withoutSave: s, adaptCanvasToContainer: o } = {}) {
2040
+ setResolutionHeight(t, { preserveProportional: e, withoutSave: s, adaptCanvasToContainer: n } = {}) {
2041
2041
  var f;
2042
2042
  if (!t) return;
2043
2043
  const {
2044
- canvas: n,
2044
+ canvas: o,
2045
2045
  montageArea: i,
2046
2046
  options: { canvasBackstoreHeight: a }
2047
2047
  } = this.editor, { width: r, height: c } = i, d = Tt(Number(t), _t, wt);
2048
- if (!a || a === "auto" || o ? this.adaptCanvasToContainer() : a ? this.setCanvasBackstoreHeight(Number(a)) : this.setCanvasBackstoreHeight(d), i.set({ height: d }), (f = n.clipPath) == null || f.set({ height: d }), e) {
2048
+ if (!a || a === "auto" || n ? this.adaptCanvasToContainer() : a ? this.setCanvasBackstoreHeight(Number(a)) : this.setCanvasBackstoreHeight(d), i.set({ height: d }), (f = o.clipPath) == null || f.set({ height: d }), e) {
2049
2049
  const p = d / c, m = Ze(r, p);
2050
2050
  this.setResolutionWidth(m);
2051
2051
  return;
2052
2052
  }
2053
- const { left: l, top: u } = this.getObjectDefaultCoords(i), g = n.getZoom();
2054
- n.setViewportTransform([g, 0, 0, g, l, u]), this.centerMontageArea(), s || this.editor.historyManager.saveState(), n.fire("editor:resolution-height-changed", {
2053
+ const { left: l, top: u } = this.getObjectDefaultCoords(i), g = o.getZoom();
2054
+ o.setViewportTransform([g, 0, 0, g, l, u]), this.centerMontageArea(), s || this.editor.historyManager.saveState(), o.fire("editor:resolution-height-changed", {
2055
2055
  height: d,
2056
2056
  preserveProportional: e,
2057
2057
  withoutSave: s,
2058
- adaptCanvasToContainer: o
2058
+ adaptCanvasToContainer: n
2059
2059
  }), this.editor.panConstraintManager.updateBounds();
2060
2060
  }
2061
2061
  /**
@@ -2064,16 +2064,16 @@ class Qs {
2064
2064
  */
2065
2065
  centerMontageArea() {
2066
2066
  var r;
2067
- const { canvas: t, montageArea: e } = this.editor, s = t.getWidth(), o = t.getHeight(), n = t.getZoom(), i = Xs(s, o);
2067
+ const { canvas: t, montageArea: e } = this.editor, s = t.getWidth(), n = t.getHeight(), o = t.getZoom(), i = Xs(s, n);
2068
2068
  e.set({
2069
2069
  left: s / 2,
2070
- top: o / 2
2070
+ top: n / 2
2071
2071
  }), (r = t.clipPath) == null || r.set({
2072
2072
  left: s / 2,
2073
- top: o / 2
2073
+ top: n / 2
2074
2074
  }), t.renderAll();
2075
2075
  const a = t.viewportTransform;
2076
- a[4] = s / 2 - i.x * n, a[5] = o / 2 - i.y * n, t.setViewportTransform(a), t.renderAll();
2076
+ a[4] = s / 2 - i.x * o, a[5] = n / 2 - i.y * o, t.setViewportTransform(a), t.renderAll();
2077
2077
  }
2078
2078
  /**
2079
2079
  * Метод для получения координат объекта с учетом текущего зума
@@ -2089,7 +2089,7 @@ class Qs {
2089
2089
  code: "NO_ACTIVE_OBJECT",
2090
2090
  message: "Не выбран объект для получения координат"
2091
2091
  }), { left: 0, top: 0 };
2092
- const { width: o, height: n } = s, i = e.getZoom(), a = (o - o * i) / 2, r = (n - n * i) / 2;
2092
+ const { width: n, height: o } = s, i = e.getZoom(), a = (n - n * i) / 2, r = (o - o * i) / 2;
2093
2093
  return { left: a, top: r };
2094
2094
  }
2095
2095
  /**
@@ -2115,8 +2115,8 @@ class Qs {
2115
2115
  * с учётом минимальных и максимальных значений.
2116
2116
  */
2117
2117
  adaptCanvasToContainer() {
2118
- const { canvas: t } = this.editor, e = this.getEditorContainer(), s = e.clientWidth, o = e.clientHeight, n = Tt(s, Rt, Mt), i = Tt(o, _t, wt);
2119
- t.setDimensions({ width: n, height: i }, { backstoreOnly: !0 });
2118
+ const { canvas: t } = this.editor, e = this.getEditorContainer(), s = e.clientWidth, n = e.clientHeight, o = Tt(s, Rt, Mt), i = Tt(n, _t, wt);
2119
+ t.setDimensions({ width: o, height: i }, { backstoreOnly: !0 });
2120
2120
  }
2121
2121
  /**
2122
2122
  * Обновляет размеры канваса без изменения позиций объектов.
@@ -2129,11 +2129,11 @@ class Qs {
2129
2129
  montageArea: e,
2130
2130
  montageArea: {
2131
2131
  width: s,
2132
- height: o
2132
+ height: n
2133
2133
  }
2134
- } = this.editor, n = e.left, i = e.top;
2135
- this.setResolutionWidth(s, { adaptCanvasToContainer: !0, withoutSave: !0 }), this.setResolutionHeight(o, { adaptCanvasToContainer: !0, withoutSave: !0 }), this.centerMontageArea();
2136
- const a = e.left - n, r = e.top - i;
2134
+ } = this.editor, o = e.left, i = e.top;
2135
+ this.setResolutionWidth(s, { adaptCanvasToContainer: !0, withoutSave: !0 }), this.setResolutionHeight(n, { adaptCanvasToContainer: !0, withoutSave: !0 }), this.centerMontageArea();
2136
+ const a = e.left - o, r = e.top - i;
2137
2137
  if (a !== 0 || r !== 0) {
2138
2138
  const c = t.getActiveObject(), d = [];
2139
2139
  if ((c == null ? void 0 : c.type) === "activeselection") {
@@ -2157,7 +2157,7 @@ class Qs {
2157
2157
  }
2158
2158
  t.renderAll(), t.fire("editor:canvas-updated", {
2159
2159
  width: s,
2160
- height: o
2160
+ height: n
2161
2161
  }), this.editor.panConstraintManager.updateBounds();
2162
2162
  }
2163
2163
  /**
@@ -2267,32 +2267,32 @@ class Qs {
2267
2267
  */
2268
2268
  setDisplayDimension({ element: t = "canvas", dimension: e, value: s } = {}) {
2269
2269
  if (!s) return;
2270
- const { canvas: o } = this.editor, n = [];
2270
+ const { canvas: n } = this.editor, o = [];
2271
2271
  switch (t) {
2272
2272
  case "canvas":
2273
- n.push(o.lowerCanvasEl, o.upperCanvasEl);
2273
+ o.push(n.lowerCanvasEl, n.upperCanvasEl);
2274
2274
  break;
2275
2275
  case "wrapper":
2276
- n.push(o.wrapperEl);
2276
+ o.push(n.wrapperEl);
2277
2277
  break;
2278
2278
  case "container":
2279
- n.push(this.getEditorContainer());
2279
+ o.push(this.getEditorContainer());
2280
2280
  break;
2281
2281
  default:
2282
- n.push(o.lowerCanvasEl, o.upperCanvasEl);
2282
+ o.push(n.lowerCanvasEl, n.upperCanvasEl);
2283
2283
  }
2284
2284
  const i = e === "width" ? "width" : "height";
2285
2285
  if (typeof s == "string") {
2286
- n.forEach((r) => {
2286
+ o.forEach((r) => {
2287
2287
  r.style[i] = s;
2288
2288
  });
2289
2289
  return;
2290
2290
  }
2291
2291
  if (isNaN(s)) return;
2292
2292
  const a = `${s}px`;
2293
- n.forEach((r) => {
2293
+ o.forEach((r) => {
2294
2294
  r.style[i] = a;
2295
- }), o.fire(`editor:display-${t}-${i}-changed`, {
2295
+ }), n.fire(`editor:display-${t}-${i}-changed`, {
2296
2296
  element: t,
2297
2297
  value: s
2298
2298
  });
@@ -2307,14 +2307,14 @@ class Qs {
2307
2307
  */
2308
2308
  scaleMontageAreaToImage({ object: t, preserveAspectRatio: e, withoutSave: s } = {}) {
2309
2309
  const {
2310
- canvas: o,
2311
- montageArea: n,
2310
+ canvas: n,
2311
+ montageArea: o,
2312
2312
  transformManager: i,
2313
2313
  options: {
2314
2314
  montageAreaWidth: a,
2315
2315
  montageAreaHeight: r
2316
2316
  }
2317
- } = this.editor, c = t || o.getActiveObject();
2317
+ } = this.editor, c = t || n.getActiveObject();
2318
2318
  if (!Ks(c)) return;
2319
2319
  const { width: d, height: l } = c;
2320
2320
  let u = Math.min(d, Mt), g = Math.min(l, wt);
@@ -2322,10 +2322,10 @@ class Qs {
2322
2322
  const {
2323
2323
  width: f,
2324
2324
  height: p
2325
- } = n, m = d / f, v = l / p, M = Math.max(m, v);
2325
+ } = o, m = d / f, v = l / p, M = Math.max(m, v);
2326
2326
  u = f * M, g = p * M;
2327
2327
  }
2328
- 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", {
2328
+ 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 }), n.centerObject(c), n.renderAll(), s || this.editor.historyManager.saveState(), n.fire("editor:montage-area-scaled-to-image", {
2329
2329
  object: c,
2330
2330
  width: u,
2331
2331
  height: g,
@@ -2351,13 +2351,13 @@ class Qs {
2351
2351
  const {
2352
2352
  canvas: e,
2353
2353
  transformManager: s,
2354
- historyManager: o,
2354
+ historyManager: n,
2355
2355
  options: {
2356
- montageAreaWidth: n,
2356
+ montageAreaWidth: o,
2357
2357
  montageAreaHeight: i
2358
2358
  }
2359
2359
  } = this.editor;
2360
- this.editor.zoomManager.resetZoom(), this.setResolutionWidth(n, { withoutSave: !0 }), this.setResolutionHeight(i, { withoutSave: !0 }), e.renderAll(), s.resetObjects(), t || o.saveState(), e.fire("editor:default-scale-set");
2360
+ this.editor.zoomManager.resetZoom(), this.setResolutionWidth(o, { withoutSave: !0 }), this.setResolutionHeight(i, { withoutSave: !0 }), e.renderAll(), s.resetObjects(), t || n.saveState(), e.fire("editor:default-scale-set");
2361
2361
  }
2362
2362
  /**
2363
2363
  * Получение всех объектов внутри монтажной области редактора
@@ -2368,10 +2368,10 @@ class Qs {
2368
2368
  canvas: t,
2369
2369
  montageArea: e,
2370
2370
  interactionBlocker: { overlayMask: s },
2371
- backgroundManager: { backgroundObject: o }
2371
+ backgroundManager: { backgroundObject: n }
2372
2372
  } = this.editor;
2373
2373
  return t.getObjects().filter(
2374
- (i) => i.id !== e.id && i.id !== (s == null ? void 0 : s.id) && i.id !== (o == null ? void 0 : o.id)
2374
+ (i) => i.id !== e.id && i.id !== (s == null ? void 0 : s.id) && i.id !== (n == null ? void 0 : n.id)
2375
2375
  );
2376
2376
  }
2377
2377
  }
@@ -2387,11 +2387,11 @@ class qs {
2387
2387
  * @fires editor:object-rotated
2388
2388
  */
2389
2389
  rotate(t = Gs, { withoutSave: e } = {}) {
2390
- const { canvas: s, historyManager: o } = this.editor, n = s.getActiveObject();
2391
- if (!n) return;
2392
- const i = n.angle + t;
2393
- n.rotate(i), n.setCoords(), s.renderAll(), e || o.saveState(), s.fire("editor:object-rotated", {
2394
- object: n,
2390
+ const { canvas: s, historyManager: n } = this.editor, o = s.getActiveObject();
2391
+ if (!o) return;
2392
+ const i = o.angle + t;
2393
+ o.rotate(i), o.setCoords(), s.renderAll(), e || n.saveState(), s.fire("editor:object-rotated", {
2394
+ object: o,
2395
2395
  withoutSave: e,
2396
2396
  angle: i
2397
2397
  });
@@ -2403,9 +2403,9 @@ class qs {
2403
2403
  * @fires editor:object-flipped-x
2404
2404
  */
2405
2405
  flipX({ withoutSave: t } = {}) {
2406
- const { canvas: e, historyManager: s } = this.editor, o = e.getActiveObject();
2407
- o && (o.flipX = !o.flipX, e.renderAll(), t || s.saveState(), e.fire("editor:object-flipped-x", {
2408
- object: o,
2406
+ const { canvas: e, historyManager: s } = this.editor, n = e.getActiveObject();
2407
+ n && (n.flipX = !n.flipX, e.renderAll(), t || s.saveState(), e.fire("editor:object-flipped-x", {
2408
+ object: n,
2409
2409
  withoutSave: t
2410
2410
  }));
2411
2411
  }
@@ -2416,9 +2416,9 @@ class qs {
2416
2416
  * @fires editor:object-flipped-y
2417
2417
  */
2418
2418
  flipY({ withoutSave: t } = {}) {
2419
- const { canvas: e, historyManager: s } = this.editor, o = e.getActiveObject();
2420
- o && (o.flipY = !o.flipY, e.renderAll(), t || s.saveState(), e.fire("editor:object-flipped-y", {
2421
- object: o,
2419
+ const { canvas: e, historyManager: s } = this.editor, n = e.getActiveObject();
2420
+ n && (n.flipY = !n.flipY, e.renderAll(), t || s.saveState(), e.fire("editor:object-flipped-y", {
2421
+ object: n,
2422
2422
  withoutSave: t
2423
2423
  }));
2424
2424
  }
@@ -2435,10 +2435,10 @@ class qs {
2435
2435
  opacity: e = 1,
2436
2436
  withoutSave: s
2437
2437
  } = {}) {
2438
- const { canvas: o, historyManager: n } = this.editor, i = t || o.getActiveObject();
2438
+ const { canvas: n, historyManager: o } = this.editor, i = t || n.getActiveObject();
2439
2439
  i && (i instanceof U ? i.getObjects().forEach((a) => {
2440
2440
  a.set("opacity", e);
2441
- }) : i.set("opacity", e), o.renderAll(), s || n.saveState(), o.fire("editor:object-opacity-changed", {
2441
+ }) : i.set("opacity", e), n.renderAll(), s || o.saveState(), n.fire("editor:object-opacity-changed", {
2442
2442
  object: i,
2443
2443
  opacity: e,
2444
2444
  withoutSave: s
@@ -2459,24 +2459,24 @@ class qs {
2459
2459
  object: t,
2460
2460
  type: e = this.options.scaleType,
2461
2461
  withoutSave: s,
2462
- fitAsOneObject: o
2462
+ fitAsOneObject: n
2463
2463
  } = {}) {
2464
- const { canvas: n, historyManager: i } = this.editor, a = t || n.getActiveObject();
2464
+ const { canvas: o, historyManager: i } = this.editor, a = t || o.getActiveObject();
2465
2465
  if (a) {
2466
- if (a instanceof U && !o) {
2466
+ if (a instanceof U && !n) {
2467
2467
  const r = a.getObjects();
2468
- n.discardActiveObject(), r.forEach((d) => {
2468
+ o.discardActiveObject(), r.forEach((d) => {
2469
2469
  this._fitSingleObject(d, e);
2470
2470
  });
2471
- const c = new U(r, { canvas: n });
2472
- n.setActiveObject(c);
2471
+ const c = new U(r, { canvas: o });
2472
+ o.setActiveObject(c);
2473
2473
  } else
2474
2474
  this._fitSingleObject(a, e);
2475
- n.renderAll(), s || i.saveState(), n.fire("editor:object-fitted", {
2475
+ o.renderAll(), s || i.saveState(), o.fire("editor:object-fitted", {
2476
2476
  object: a,
2477
2477
  type: e,
2478
2478
  withoutSave: s,
2479
- fitAsOneObject: o
2479
+ fitAsOneObject: n
2480
2480
  });
2481
2481
  }
2482
2482
  }
@@ -2487,7 +2487,7 @@ class qs {
2487
2487
  * @private
2488
2488
  */
2489
2489
  _fitSingleObject(t, e) {
2490
- 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, M = o.height;
2490
+ const { canvas: s, montageArea: n } = this.editor, { width: o, height: i, scaleX: a = 1, scaleY: r = 1, angle: c = 0 } = t, d = o * 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 = n.width, M = n.height;
2491
2491
  let S;
2492
2492
  e === "contain" ? S = Math.min(v / p, M / m) : S = Math.max(v / p, M / m), t.set({
2493
2493
  scaleX: a * S,
@@ -2512,12 +2512,12 @@ class qs {
2512
2512
  */
2513
2513
  resetObject({ object: t, alwaysFitObject: e = !1, withoutSave: s = !1 } = {}) {
2514
2514
  const {
2515
- canvas: o,
2516
- montageArea: n,
2515
+ canvas: n,
2516
+ montageArea: o,
2517
2517
  imageManager: i,
2518
2518
  historyManager: a,
2519
2519
  options: { scaleType: r }
2520
- } = this.editor, c = t || o.getActiveObject();
2520
+ } = this.editor, c = t || n.getActiveObject();
2521
2521
  if (!c || c.locked) return;
2522
2522
  if (a.suspendHistory(), c.type === "image" || c.format === "svg" || c.set({
2523
2523
  scaleX: 1,
@@ -2528,13 +2528,13 @@ class qs {
2528
2528
  }), e)
2529
2529
  this.fitObject({ object: c, withoutSave: !0, fitAsOneObject: !0 });
2530
2530
  else {
2531
- const { width: l, height: u } = n, { width: g, height: f } = c, p = i.calculateScaleFactor({
2531
+ const { width: l, height: u } = o, { width: g, height: f } = c, p = i.calculateScaleFactor({
2532
2532
  imageObject: c,
2533
2533
  scaleType: r
2534
2534
  });
2535
2535
  r === "contain" && p < 1 || r === "cover" && (g > l || f > u) ? this.fitObject({ object: c, withoutSave: !0, fitAsOneObject: !0 }) : c.set({ scaleX: 1, scaleY: 1 });
2536
2536
  }
2537
- c.set({ flipX: !1, flipY: !1, angle: 0 }), o.centerObject(c), o.renderAll(), a.resumeHistory(), s || a.saveState(), o.fire("editor:object-reset", {
2537
+ c.set({ flipX: !1, flipY: !1, angle: 0 }), n.centerObject(c), n.renderAll(), a.resumeHistory(), s || a.saveState(), n.fire("editor:object-reset", {
2538
2538
  object: c,
2539
2539
  withoutSave: s,
2540
2540
  alwaysFitObject: e
@@ -2565,7 +2565,7 @@ class Js {
2565
2565
  * @private
2566
2566
  */
2567
2567
  _getClampedPointerCoordinates(t) {
2568
- 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));
2568
+ const { canvas: e, montageArea: s } = this.editor, n = e.getPointer(t, !0), o = 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 + o[4], u = r * i + o[4], g = c * i + o[5], f = d * i + o[5], p = Math.max(l, Math.min(u, n.x)), m = Math.max(g, Math.min(f, n.y));
2569
2569
  return {
2570
2570
  x: p,
2571
2571
  y: m
@@ -2577,8 +2577,8 @@ class Js {
2577
2577
  * @private
2578
2578
  */
2579
2579
  _calculateFitZoom() {
2580
- const { canvas: t, montageArea: e } = this.editor, s = t.getWidth(), o = t.getHeight(), n = s / e.width, i = o / e.height;
2581
- return Math.max(n, i);
2580
+ const { canvas: t, montageArea: e } = this.editor, s = t.getWidth(), n = t.getHeight(), o = s / e.width, i = n / e.height;
2581
+ return Math.max(o, i);
2582
2582
  }
2583
2583
  /**
2584
2584
  * Вычисляет целевую позицию viewport для центрирования монтажной области
@@ -2587,7 +2587,7 @@ class Js {
2587
2587
  * @private
2588
2588
  */
2589
2589
  _calculateTargetViewportPosition(t) {
2590
- const { canvas: e, montageArea: s } = this.editor, o = e.getWidth(), n = e.getHeight(), i = o / 2, a = n / 2, r = s.left, c = s.top;
2590
+ const { canvas: e, montageArea: s } = this.editor, n = e.getWidth(), o = e.getHeight(), i = n / 2, a = o / 2, r = s.left, c = s.top;
2591
2591
  return {
2592
2592
  x: i - r * t,
2593
2593
  y: a - c * t
@@ -2600,9 +2600,9 @@ class Js {
2600
2600
  * @private
2601
2601
  */
2602
2602
  _calculateEmptySpaceRatio(t) {
2603
- 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, M = f > d;
2603
+ const { canvas: e, montageArea: s } = this.editor, n = e.viewportTransform, o = 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 = -n[4] / t, u = (-n[4] + o) / t, g = -n[5] / t, f = (-n[5] + i) / t, p = l < a, m = u > r, v = g < c, M = f > d;
2604
2604
  if (!(p || m || v || M)) return 0;
2605
- const y = Math.max(0, a - l), b = Math.max(0, u - r), I = Math.max(0, c - g), j = Math.max(0, f - d), A = Math.max(y, b), C = Math.max(I, j), w = A / n, T = C / i;
2605
+ const y = Math.max(0, a - l), b = Math.max(0, u - r), I = Math.max(0, c - g), j = Math.max(0, f - d), A = Math.max(y, b), C = Math.max(I, j), w = A / o, T = C / i;
2606
2606
  return Math.max(w, T);
2607
2607
  }
2608
2608
  /**
@@ -2615,11 +2615,11 @@ class Js {
2615
2615
  * @returns Вычисленный шаг перемещения viewport
2616
2616
  * @private
2617
2617
  */
2618
- _calculateSmoothCenteringStep(t, e, s, o, n) {
2619
- 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;
2618
+ _calculateSmoothCenteringStep(t, e, s, n, o) {
2619
+ 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(n), f = e - s;
2620
2620
  if (Math.abs(f) / g <= 0.1)
2621
2621
  return { x: l, y: u };
2622
- const m = c / 2, v = d / 2, M = a.left, S = a.top, y = m - M * s, b = v - S * s, I = (y - r[4]) / (e - s), j = (b - r[5]) / (e - s), A = I * g, C = j * g, w = A * n, T = C * n, E = Math.abs(w) > Math.abs(l) ? l : w, P = Math.abs(T) > Math.abs(u) ? u : T;
2622
+ const m = c / 2, v = d / 2, M = a.left, S = a.top, y = m - M * s, b = v - S * s, I = (y - r[4]) / (e - s), j = (b - r[5]) / (e - s), A = I * g, C = j * g, w = A * o, T = C * o, E = Math.abs(w) > Math.abs(l) ? l : w, P = Math.abs(T) > Math.abs(u) ? u : T;
2623
2623
  return { x: E, y: P };
2624
2624
  }
2625
2625
  /**
@@ -2633,17 +2633,17 @@ class Js {
2633
2633
  * @private
2634
2634
  */
2635
2635
  _applyViewportCentering(t, e = !1, s = Ye) {
2636
- const { canvas: o } = this.editor, n = this._getScaledMontageDimensions(t), i = o.getWidth(), a = o.getHeight(), r = n.width > i || n.height > a, c = this._calculateFitZoom(), d = t - c;
2636
+ const { canvas: n } = this.editor, o = this._getScaledMontageDimensions(t), i = n.getWidth(), a = n.getHeight(), r = o.width > i || o.height > a, c = this._calculateFitZoom(), d = t - c;
2637
2637
  if (!(!r || d) && !e)
2638
2638
  return !1;
2639
- const u = o.viewportTransform, g = this._calculateTargetViewportPosition(t);
2639
+ const u = n.viewportTransform, g = this._calculateTargetViewportPosition(t);
2640
2640
  if (!r)
2641
- return u[4] = g.x, u[5] = g.y, o.setViewportTransform(u), !0;
2641
+ return u[4] = g.x, u[5] = g.y, n.setViewportTransform(u), !0;
2642
2642
  if (e && !r) {
2643
2643
  const f = this._calculateEmptySpaceRatio(t);
2644
2644
  if (f > 0) {
2645
2645
  const p = this._calculateSmoothCenteringStep(g, t, c, s, f);
2646
- return u[4] += p.x, u[5] += p.y, o.setViewportTransform(u), !0;
2646
+ return u[4] += p.x, u[5] += p.y, n.setViewportTransform(u), !0;
2647
2647
  }
2648
2648
  }
2649
2649
  return !1;
@@ -2656,7 +2656,7 @@ class Js {
2656
2656
  * @param scale - Желаемый масштаб относительно размеров контейнера редактора.
2657
2657
  */
2658
2658
  calculateAndApplyDefaultZoom(t = this.options.defaultScale) {
2659
- const { canvas: e } = this.editor, s = e.editorContainer, o = s.clientWidth || e.getWidth(), n = s.clientHeight || e.getHeight(), { width: i, height: a } = this.editor.montageArea, r = o / i * t, c = n / a * t;
2659
+ const { canvas: e } = this.editor, s = e.editorContainer, n = s.clientWidth || e.getWidth(), o = s.clientHeight || e.getHeight(), { width: i, height: a } = this.editor.montageArea, r = n / i * t, c = o / a * t;
2660
2660
  this.defaultZoom = Math.min(r, c), this.setZoom(), this.editor.panConstraintManager.updateBounds();
2661
2661
  }
2662
2662
  /**
@@ -2670,12 +2670,12 @@ class Js {
2670
2670
  * @fires editor:zoom-changed
2671
2671
  */
2672
2672
  handleMouseWheelZoom(t, e) {
2673
- const { canvas: s, montageArea: o } = this.editor, n = s.getZoom(), i = t < 0, a = this._getScaledMontageDimensions(n), r = s.getWidth(), c = s.getHeight(), d = a.width > r || a.height > c;
2673
+ const { canvas: s, montageArea: n } = this.editor, o = s.getZoom(), i = t < 0, a = this._getScaledMontageDimensions(o), r = s.getWidth(), c = s.getHeight(), d = a.width > r || a.height > c;
2674
2674
  if (i) {
2675
2675
  if (!d)
2676
2676
  this.zoom(t, {
2677
- pointX: o.left,
2678
- pointY: o.top
2677
+ pointX: n.left,
2678
+ pointY: n.top
2679
2679
  });
2680
2680
  else {
2681
2681
  const u = this._getClampedPointerCoordinates(e);
@@ -2688,8 +2688,8 @@ class Js {
2688
2688
  }
2689
2689
  if (t < 0 || !d) {
2690
2690
  this.zoom(t, {
2691
- pointX: o.left,
2692
- pointY: o.top
2691
+ pointX: n.left,
2692
+ pointY: n.top
2693
2693
  });
2694
2694
  return;
2695
2695
  }
@@ -2710,11 +2710,11 @@ class Js {
2710
2710
  zoom(t = Ye, e = {}) {
2711
2711
  var g, f;
2712
2712
  if (!t) return;
2713
- 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 et(c, d);
2713
+ const { minZoom: s, maxZoom: n } = this, { canvas: o } = this.editor, i = t < 0, a = o.getZoom(), r = o.getCenterPoint(), c = (g = e.pointX) != null ? g : r.x, d = (f = e.pointY) != null ? f : r.y, l = new et(c, d);
2714
2714
  this.editor.montageArea.setCoords(), this.editor.canvas.requestRenderAll();
2715
2715
  let u = Number((a + Number(t)).toFixed(3));
2716
- 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", {
2717
- currentZoom: n.getZoom(),
2716
+ u > n && (u = n), u < s && (u = s), o.zoomToPoint(l, u), this.editor.panConstraintManager.updateBounds(), this._applyViewportCentering(u, i, t), o.fire("editor:zoom-changed", {
2717
+ currentZoom: o.getZoom(),
2718
2718
  zoom: u,
2719
2719
  point: l
2720
2720
  });
@@ -2725,12 +2725,12 @@ class Js {
2725
2725
  * @fires editor:zoom-changed
2726
2726
  */
2727
2727
  setZoom(t = this.defaultZoom) {
2728
- const { minZoom: e, maxZoom: s } = this, { canvas: o } = this.editor, n = new et(o.getCenterPoint());
2728
+ const { minZoom: e, maxZoom: s } = this, { canvas: n } = this.editor, o = new et(n.getCenterPoint());
2729
2729
  let i = t;
2730
- t > s && (i = s), t < e && (i = e), o.zoomToPoint(n, i), o.fire("editor:zoom-changed", {
2731
- currentZoom: o.getZoom(),
2730
+ t > s && (i = s), t < e && (i = e), n.zoomToPoint(o, i), n.fire("editor:zoom-changed", {
2731
+ currentZoom: n.getZoom(),
2732
2732
  zoom: i,
2733
- point: n
2733
+ point: o
2734
2734
  }), this.editor.panConstraintManager.updateBounds();
2735
2735
  }
2736
2736
  /**
@@ -2775,8 +2775,8 @@ class $s {
2775
2775
  const { canvas: t, montageArea: e, historyManager: s } = this.editor;
2776
2776
  if (!e || !this.overlayMask) return;
2777
2777
  s.suspendHistory(), e.setCoords();
2778
- const { left: o, top: n, width: i, height: a } = e.getBoundingRect();
2779
- this.overlayMask.set({ left: o, top: n, width: i, height: a }), t.discardActiveObject(), this.editor.layerManager.bringToFront(this.overlayMask, { withoutSave: !0 }), s.resumeHistory();
2778
+ const { left: n, top: o, width: i, height: a } = e.getBoundingRect();
2779
+ this.overlayMask.set({ left: n, top: o, width: i, height: a }), t.discardActiveObject(), this.editor.layerManager.bringToFront(this.overlayMask, { withoutSave: !0 }), s.resumeHistory();
2780
2780
  }
2781
2781
  /**
2782
2782
  * Выключает редактор:
@@ -2787,8 +2787,8 @@ class $s {
2787
2787
  block() {
2788
2788
  if (this.isBlocked || !this.overlayMask) return;
2789
2789
  const { canvas: t, canvasManager: e, historyManager: s } = this.editor;
2790
- s.suspendHistory(), this.isBlocked = !0, t.discardActiveObject(), t.selection = !1, t.skipTargetFind = !0, e.getObjects().forEach((o) => {
2791
- o.evented = !1, o.selectable = !1;
2790
+ s.suspendHistory(), this.isBlocked = !0, t.discardActiveObject(), t.selection = !1, t.skipTargetFind = !0, e.getObjects().forEach((n) => {
2791
+ n.evented = !1, n.selectable = !1;
2792
2792
  }), t.upperCanvasEl.style.pointerEvents = "none", t.lowerCanvasEl.style.pointerEvents = "none", this.overlayMask.visible = !0, this.refresh(), t.fire("editor:disabled"), s.resumeHistory();
2793
2793
  }
2794
2794
  /**
@@ -2797,8 +2797,8 @@ class $s {
2797
2797
  unblock() {
2798
2798
  if (!this.isBlocked || !this.overlayMask) return;
2799
2799
  const { canvas: t, canvasManager: e, historyManager: s } = this.editor;
2800
- s.suspendHistory(), this.isBlocked = !1, t.selection = !0, t.skipTargetFind = !1, e.getObjects().forEach((o) => {
2801
- o.evented = !0, o.selectable = !0;
2800
+ s.suspendHistory(), this.isBlocked = !1, t.selection = !0, t.skipTargetFind = !1, e.getObjects().forEach((n) => {
2801
+ n.evented = !0, n.selectable = !0;
2802
2802
  }), t.upperCanvasEl.style.pointerEvents = "", t.lowerCanvasEl.style.pointerEvents = "", this.overlayMask.visible = !1, t.requestRenderAll(), t.fire("editor:enabled"), s.resumeHistory();
2803
2803
  }
2804
2804
  }
@@ -2815,30 +2815,37 @@ class Ot {
2815
2815
  setColorBackground({
2816
2816
  color: t,
2817
2817
  customData: e = {},
2818
- withoutSave: s = !1
2818
+ fromTemplate: s = !1,
2819
+ withoutSave: n = !1
2819
2820
  }) {
2820
2821
  var o;
2821
2822
  try {
2822
- const { historyManager: n } = this.editor, { backgroundObject: i } = this;
2823
- if (n.suspendHistory(), i && i.backgroundType === "color") {
2824
- if (i.fill === t) {
2825
- n.resumeHistory();
2823
+ const { historyManager: i } = this.editor, { backgroundObject: a } = this;
2824
+ if (i.suspendHistory(), a && a.backgroundType === "color") {
2825
+ if (a.fill === t) {
2826
+ i.resumeHistory();
2826
2827
  return;
2827
2828
  }
2828
- i.set({
2829
+ a.set({
2829
2830
  fill: t,
2830
2831
  backgroundId: `background-${V()}`
2831
2832
  }), this.editor.canvas.requestRenderAll();
2832
2833
  } else
2833
2834
  this._removeCurrentBackground(), this._createColorBackground(t);
2834
- (o = this.backgroundObject) == null || o.set({ customData: e }), this.editor.canvas.fire("editor:background:changed", { type: "color", color: t }), n.resumeHistory(), s || n.saveState();
2835
- } catch (n) {
2835
+ (o = this.backgroundObject) == null || o.set({ customData: e }), this.editor.canvas.fire("editor:background:changed", {
2836
+ type: "color",
2837
+ color: t,
2838
+ customData: e,
2839
+ fromTemplate: s,
2840
+ withoutSave: n
2841
+ }), i.resumeHistory(), n || i.saveState();
2842
+ } catch (i) {
2836
2843
  this.editor.errorManager.emitError({
2837
2844
  code: "BACKGROUND_CREATION_FAILED",
2838
2845
  origin: "BackgroundManager",
2839
2846
  method: "setColorBackground",
2840
2847
  message: "Не удалось установить цветовой фон",
2841
- data: { error: n }
2848
+ data: { error: i, color: t, customData: e, fromTemplate: s, withoutSave: n }
2842
2849
  });
2843
2850
  }
2844
2851
  }
@@ -2851,34 +2858,38 @@ class Ot {
2851
2858
  setGradientBackground({
2852
2859
  gradient: t,
2853
2860
  customData: e = {},
2854
- withoutSave: s = !1
2861
+ fromTemplate: s = !1,
2862
+ withoutSave: n = !1
2855
2863
  }) {
2856
2864
  var o;
2857
2865
  try {
2858
- const { historyManager: n } = this.editor, { backgroundObject: i } = this;
2859
- if (n.suspendHistory(), i && i.backgroundType === "gradient") {
2860
- const a = Ot._createFabricGradient(t);
2861
- if (Ot._isGradientEqual(i.fill, a)) {
2862
- n.resumeHistory();
2866
+ const { historyManager: i } = this.editor, { backgroundObject: a } = this;
2867
+ if (i.suspendHistory(), a && a.backgroundType === "gradient") {
2868
+ const r = Ot._createFabricGradient(t);
2869
+ if (Ot._isGradientEqual(a.fill, r)) {
2870
+ i.resumeHistory();
2863
2871
  return;
2864
2872
  }
2865
- i.set({
2866
- fill: a,
2873
+ a.set({
2874
+ fill: r,
2867
2875
  backgroundId: `background-${V()}`
2868
2876
  }), this.editor.canvas.requestRenderAll();
2869
2877
  } else
2870
2878
  this._removeCurrentBackground(), this._createGradientBackground(t);
2871
2879
  (o = this.backgroundObject) == null || o.set({ customData: e }), this.editor.canvas.fire("editor:background:changed", {
2872
2880
  type: "gradient",
2881
+ customData: e,
2882
+ fromTemplate: s,
2883
+ withoutSave: n,
2873
2884
  gradientParams: t
2874
- }), n.resumeHistory(), s || n.saveState();
2875
- } catch (n) {
2885
+ }), i.resumeHistory(), n || i.saveState();
2886
+ } catch (i) {
2876
2887
  this.editor.errorManager.emitError({
2877
2888
  code: "BACKGROUND_CREATION_FAILED",
2878
2889
  origin: "BackgroundManager",
2879
2890
  method: "setGradientBackground",
2880
2891
  message: "Не удалось установить градиентный фон",
2881
- data: { error: n }
2892
+ data: { error: i, gradient: t, customData: e, fromTemplate: s, withoutSave: n }
2882
2893
  });
2883
2894
  }
2884
2895
  }
@@ -2890,8 +2901,8 @@ class Ot {
2890
2901
  angle: t,
2891
2902
  startColor: e,
2892
2903
  endColor: s,
2893
- startPosition: o,
2894
- endPosition: n,
2904
+ startPosition: n,
2905
+ endPosition: o,
2895
2906
  colorStops: i,
2896
2907
  customData: a = {},
2897
2908
  withoutSave: r = !1
@@ -2902,8 +2913,8 @@ class Ot {
2902
2913
  angle: t,
2903
2914
  startColor: e,
2904
2915
  endColor: s,
2905
- startPosition: o,
2906
- endPosition: n,
2916
+ startPosition: n,
2917
+ endPosition: o,
2907
2918
  colorStops: i
2908
2919
  },
2909
2920
  customData: a,
@@ -2918,8 +2929,8 @@ class Ot {
2918
2929
  centerX: t,
2919
2930
  centerY: e,
2920
2931
  radius: s,
2921
- startColor: o,
2922
- endColor: n,
2932
+ startColor: n,
2933
+ endColor: o,
2923
2934
  startPosition: i,
2924
2935
  endPosition: a,
2925
2936
  colorStops: r,
@@ -2932,8 +2943,8 @@ class Ot {
2932
2943
  centerX: t,
2933
2944
  centerY: e,
2934
2945
  radius: s,
2935
- startColor: o,
2936
- endColor: n,
2946
+ startColor: n,
2947
+ endColor: o,
2937
2948
  startPosition: i,
2938
2949
  endPosition: a,
2939
2950
  colorStops: r
@@ -2952,22 +2963,26 @@ class Ot {
2952
2963
  return k(this, arguments, function* ({
2953
2964
  imageSource: t,
2954
2965
  customData: e = {},
2955
- withoutSave: s = !1
2966
+ fromTemplate: s = !1,
2967
+ withoutSave: n = !1
2956
2968
  }) {
2957
2969
  try {
2958
- const { historyManager: n } = this.editor;
2959
- n.suspendHistory(), yield this._createImageBackground(t, e), this.editor.canvas.fire("editor:background:changed", {
2970
+ const { historyManager: i } = this.editor;
2971
+ i.suspendHistory(), yield this._createImageBackground(t, e), this.editor.canvas.fire("editor:background:changed", {
2960
2972
  type: "image",
2961
2973
  imageSource: t,
2974
+ customData: e,
2975
+ fromTemplate: s,
2976
+ withoutSave: n,
2962
2977
  backgroundObject: this.backgroundObject
2963
- }), n.resumeHistory(), s || n.saveState();
2964
- } catch (n) {
2978
+ }), i.resumeHistory(), n || i.saveState();
2979
+ } catch (i) {
2965
2980
  this.editor.errorManager.emitError({
2966
2981
  code: "BACKGROUND_CREATION_FAILED",
2967
2982
  origin: "BackgroundManager",
2968
2983
  method: "setImageBackground",
2969
2984
  message: "Не удалось установить изображение в качестве фона",
2970
- data: { error: n }
2985
+ data: { error: i, imageSource: t, customData: e, fromTemplate: s, withoutSave: n }
2971
2986
  });
2972
2987
  }
2973
2988
  });
@@ -2981,14 +2996,14 @@ class Ot {
2981
2996
  try {
2982
2997
  const { historyManager: e } = this.editor;
2983
2998
  if (!this.backgroundObject) return;
2984
- e.suspendHistory(), this._removeCurrentBackground(), this.editor.canvas.fire("editor:background:removed"), e.resumeHistory(), t || e.saveState();
2999
+ e.suspendHistory(), this._removeCurrentBackground(), this.editor.canvas.fire("editor:background:removed", { withoutSave: t }), e.resumeHistory(), t || e.saveState();
2985
3000
  } catch (e) {
2986
3001
  this.editor.errorManager.emitError({
2987
3002
  code: "BACKGROUND_REMOVAL_FAILED",
2988
3003
  origin: "BackgroundManager",
2989
3004
  method: "removeBackground",
2990
3005
  message: "Не удалось удалить фон",
2991
- data: { error: e }
3006
+ data: { error: e, withoutSave: t }
2992
3007
  });
2993
3008
  }
2994
3009
  }
@@ -2999,8 +3014,8 @@ class Ot {
2999
3014
  const { canvas: t, montageArea: e, historyManager: s } = this.editor;
3000
3015
  if (!e || !this.backgroundObject) return;
3001
3016
  s.suspendHistory(), this.editor.transformManager.fitObject({ object: this.backgroundObject, withoutSave: !0, type: "cover" });
3002
- const o = t.getObjects(), n = o.indexOf(e), i = o.indexOf(this.backgroundObject);
3003
- this.backgroundObject && i !== n + 1 && t.moveObjectTo(this.backgroundObject, n + 1), t.requestRenderAll(), s.resumeHistory();
3017
+ const n = t.getObjects(), o = n.indexOf(e), i = n.indexOf(this.backgroundObject);
3018
+ this.backgroundObject && i !== o + 1 && t.moveObjectTo(this.backgroundObject, o + 1), t.requestRenderAll(), s.resumeHistory();
3004
3019
  }
3005
3020
  /**
3006
3021
  * Создает цветовой фон.
@@ -3043,14 +3058,14 @@ class Ot {
3043
3058
  */
3044
3059
  _createImageBackground(t, e) {
3045
3060
  return k(this, null, function* () {
3046
- var o;
3047
- const { image: s } = (o = yield this.editor.imageManager.importImage({
3061
+ var n;
3062
+ const { image: s } = (n = yield this.editor.imageManager.importImage({
3048
3063
  source: t,
3049
3064
  withoutSave: !0,
3050
3065
  isBackground: !0,
3051
3066
  withoutSelection: !0,
3052
3067
  scale: "image-cover"
3053
- })) != null ? o : {};
3068
+ })) != null ? n : {};
3054
3069
  if (!s)
3055
3070
  throw new Error("Не удалось загрузить изображение");
3056
3071
  s.set({
@@ -3079,8 +3094,8 @@ class Ot {
3079
3094
  const {
3080
3095
  startColor: e,
3081
3096
  endColor: s,
3082
- startPosition: o = 0,
3083
- endPosition: n = 100,
3097
+ startPosition: n = 0,
3098
+ endPosition: o = 100,
3084
3099
  colorStops: i
3085
3100
  } = t;
3086
3101
  let a;
@@ -3088,8 +3103,8 @@ class Ot {
3088
3103
  offset: u.offset / 100,
3089
3104
  color: u.color
3090
3105
  })) : e && s ? a = [
3091
- { offset: o / 100, color: e },
3092
- { offset: n / 100, color: s }
3106
+ { offset: n / 100, color: e },
3107
+ { offset: o / 100, color: s }
3093
3108
  ] : a = [
3094
3109
  { offset: 0, color: "#000000" },
3095
3110
  { offset: 1, color: "#ffffff" }
@@ -3142,9 +3157,9 @@ class Ot {
3142
3157
  */
3143
3158
  static _isGradientEqual(t, e) {
3144
3159
  if (!t || !e || t.type !== e.type) return !1;
3145
- const s = t.colorStops || [], o = e.colorStops || [];
3146
- return s.length !== o.length || !s.every((i, a) => {
3147
- const r = o[a];
3160
+ const s = t.colorStops || [], n = e.colorStops || [];
3161
+ return s.length !== n.length || !s.every((i, a) => {
3162
+ const r = n[a];
3148
3163
  return i.color === r.color && Math.abs(i.offset - r.offset) < 1e-4;
3149
3164
  }) ? !1 : t.type === "linear" && e.type === "linear" ? Math.abs(t.coords.x1 - e.coords.x1) < 1e-4 && Math.abs(t.coords.y1 - e.coords.y1) < 1e-4 && Math.abs(t.coords.x2 - e.coords.x2) < 1e-4 && Math.abs(t.coords.y2 - e.coords.y2) < 1e-4 : t.type === "radial" && e.type === "radial" ? Math.abs(t.coords.x1 - e.coords.x1) < 1e-4 && Math.abs(t.coords.y1 - e.coords.y1) < 1e-4 && Math.abs(t.coords.x2 - e.coords.x2) < 1e-4 && Math.abs(t.coords.y2 - e.coords.y2) < 1e-4 && Math.abs(t.coords.r1 - e.coords.r1) < 1e-4 && Math.abs(t.coords.r2 - e.coords.r2) < 1e-4 : !1;
3150
3165
  }
@@ -3161,13 +3176,13 @@ class te {
3161
3176
  * @fires editor:object-bring-to-front
3162
3177
  */
3163
3178
  bringToFront(t, { withoutSave: e } = {}) {
3164
- const { canvas: s, historyManager: o } = this.editor;
3165
- o.suspendHistory();
3166
- const n = t || s.getActiveObject();
3167
- n && (n instanceof U ? n.getObjects().forEach((i) => {
3179
+ const { canvas: s, historyManager: n } = this.editor;
3180
+ n.suspendHistory();
3181
+ const o = t || s.getActiveObject();
3182
+ o && (o instanceof U ? o.getObjects().forEach((i) => {
3168
3183
  s.bringObjectToFront(i);
3169
- }) : s.bringObjectToFront(n), s.renderAll(), o.resumeHistory(), e || o.saveState(), s.fire("editor:object-bring-to-front", {
3170
- object: n,
3184
+ }) : s.bringObjectToFront(o), s.renderAll(), n.resumeHistory(), e || n.saveState(), s.fire("editor:object-bring-to-front", {
3185
+ object: o,
3171
3186
  withoutSave: e
3172
3187
  }));
3173
3188
  }
@@ -3179,11 +3194,11 @@ class te {
3179
3194
  * @fires editor:object-bring-forward
3180
3195
  */
3181
3196
  bringForward(t, { withoutSave: e } = {}) {
3182
- const { canvas: s, historyManager: o } = this.editor;
3183
- o.suspendHistory();
3184
- const n = t || s.getActiveObject();
3185
- n && (n instanceof U ? te._moveSelectionForward(s, n) : s.bringObjectForward(n), s.renderAll(), o.resumeHistory(), e || o.saveState(), s.fire("editor:object-bring-forward", {
3186
- object: n,
3197
+ const { canvas: s, historyManager: n } = this.editor;
3198
+ n.suspendHistory();
3199
+ const o = t || s.getActiveObject();
3200
+ o && (o instanceof U ? te._moveSelectionForward(s, o) : s.bringObjectForward(o), s.renderAll(), n.resumeHistory(), e || n.saveState(), s.fire("editor:object-bring-forward", {
3201
+ object: o,
3187
3202
  withoutSave: e
3188
3203
  }));
3189
3204
  }
@@ -3197,12 +3212,12 @@ class te {
3197
3212
  sendToBack(t, { withoutSave: e } = {}) {
3198
3213
  const {
3199
3214
  canvas: s,
3200
- montageArea: o,
3201
- historyManager: n,
3215
+ montageArea: n,
3216
+ historyManager: o,
3202
3217
  interactionBlocker: { overlayMask: i },
3203
3218
  backgroundManager: { backgroundObject: a }
3204
3219
  } = this.editor;
3205
- n.suspendHistory();
3220
+ o.suspendHistory();
3206
3221
  const r = t || s.getActiveObject();
3207
3222
  if (r) {
3208
3223
  if (r instanceof U) {
@@ -3211,7 +3226,7 @@ class te {
3211
3226
  s.sendObjectToBack(c[d]);
3212
3227
  } else
3213
3228
  s.sendObjectToBack(r);
3214
- a && s.sendObjectToBack(a), s.sendObjectToBack(o), i && s.sendObjectToBack(i), s.renderAll(), n.resumeHistory(), e || n.saveState(), s.fire("editor:object-send-to-back", {
3229
+ a && s.sendObjectToBack(a), s.sendObjectToBack(n), i && s.sendObjectToBack(i), s.renderAll(), o.resumeHistory(), e || o.saveState(), s.fire("editor:object-send-to-back", {
3215
3230
  object: r,
3216
3231
  withoutSave: e
3217
3232
  });
@@ -3226,14 +3241,14 @@ class te {
3226
3241
  sendBackwards(t, { withoutSave: e } = {}) {
3227
3242
  const {
3228
3243
  canvas: s,
3229
- montageArea: o,
3230
- historyManager: n,
3244
+ montageArea: n,
3245
+ historyManager: o,
3231
3246
  interactionBlocker: { overlayMask: i },
3232
3247
  backgroundManager: { backgroundObject: a }
3233
3248
  } = this.editor;
3234
- n.suspendHistory();
3249
+ o.suspendHistory();
3235
3250
  const r = t || s.getActiveObject();
3236
- r && (r instanceof U ? te._moveSelectionBackwards(s, r) : s.sendObjectBackwards(r), a && s.sendObjectToBack(a), s.sendObjectToBack(o), i && s.sendObjectToBack(i), s.renderAll(), n.resumeHistory(), e || n.saveState(), s.fire("editor:object-send-backwards", {
3251
+ r && (r instanceof U ? te._moveSelectionBackwards(s, r) : s.sendObjectBackwards(r), a && s.sendObjectToBack(a), s.sendObjectToBack(n), i && s.sendObjectToBack(i), s.renderAll(), o.resumeHistory(), e || o.saveState(), s.fire("editor:object-send-backwards", {
3237
3252
  object: r,
3238
3253
  withoutSave: e
3239
3254
  }));
@@ -3245,15 +3260,15 @@ class te {
3245
3260
  * @param activeSelection - активное выделение
3246
3261
  */
3247
3262
  static _moveSelectionForward(t, e) {
3248
- const s = t.getObjects(), o = e.getObjects();
3249
- if (!o.some((a) => {
3263
+ const s = t.getObjects(), n = e.getObjects();
3264
+ if (!n.some((a) => {
3250
3265
  const r = s.indexOf(a);
3251
3266
  for (let c = r + 1; c < s.length; c += 1)
3252
- if (!o.includes(s[c]))
3267
+ if (!n.includes(s[c]))
3253
3268
  return !0;
3254
3269
  return !1;
3255
3270
  })) return;
3256
- o.map((a) => ({ obj: a, index: s.indexOf(a) })).sort((a, r) => r.index - a.index).forEach((a) => {
3271
+ n.map((a) => ({ obj: a, index: s.indexOf(a) })).sort((a, r) => r.index - a.index).forEach((a) => {
3257
3272
  t.bringObjectForward(a.obj);
3258
3273
  });
3259
3274
  }
@@ -3264,20 +3279,20 @@ class te {
3264
3279
  * @param activeSelection - активное выделение
3265
3280
  */
3266
3281
  static _moveSelectionBackwards(t, e) {
3267
- const s = t.getObjects(), o = e.getObjects();
3268
- if (!o.some((a) => {
3282
+ const s = t.getObjects(), n = e.getObjects();
3283
+ if (!n.some((a) => {
3269
3284
  const r = s.indexOf(a);
3270
3285
  for (let c = r - 1; c >= 0; c -= 1)
3271
- if (!o.includes(s[c]))
3286
+ if (!n.includes(s[c]))
3272
3287
  return !0;
3273
3288
  return !1;
3274
3289
  })) return;
3275
- o.map((a) => ({ obj: a, index: s.indexOf(a) })).sort((a, r) => a.index - r.index).forEach((a) => {
3290
+ n.map((a) => ({ obj: a, index: s.indexOf(a) })).sort((a, r) => a.index - r.index).forEach((a) => {
3276
3291
  t.sendObjectBackwards(a.obj);
3277
3292
  });
3278
3293
  }
3279
3294
  }
3280
- class to {
3295
+ class tn {
3281
3296
  /**
3282
3297
  * Менеджер фигур для редактора.
3283
3298
  * @param options - Опции и настройки менеджера фигур.
@@ -3306,8 +3321,8 @@ class to {
3306
3321
  id: t = `rect-${V()}`,
3307
3322
  left: e,
3308
3323
  top: s,
3309
- width: o = 100,
3310
- height: n = 100,
3324
+ width: n = 100,
3325
+ height: o = 100,
3311
3326
  fill: i = "blue"
3312
3327
  } = l, a = vt(l, [
3313
3328
  "id",
@@ -3321,8 +3336,8 @@ class to {
3321
3336
  id: t,
3322
3337
  left: e,
3323
3338
  top: s,
3324
- width: o,
3325
- height: n,
3339
+ width: n,
3340
+ height: o,
3326
3341
  fill: i
3327
3342
  }, a));
3328
3343
  return !e && !s && u.centerObject(g), c || (u.add(g), r || u.setActiveObject(g), u.renderAll()), g;
@@ -3348,8 +3363,8 @@ class to {
3348
3363
  id: t = `circle-${V()}`,
3349
3364
  left: e,
3350
3365
  top: s,
3351
- radius: o = 50,
3352
- fill: n = "green"
3366
+ radius: n = 50,
3367
+ fill: o = "green"
3353
3368
  } = d, i = vt(d, [
3354
3369
  "id",
3355
3370
  "left",
@@ -3361,8 +3376,8 @@ class to {
3361
3376
  id: t,
3362
3377
  left: e,
3363
3378
  top: s,
3364
- fill: n,
3365
- radius: o
3379
+ fill: o,
3380
+ radius: n
3366
3381
  }, i));
3367
3382
  return !e && !s && l.centerObject(u), r || (l.add(u), a || l.setActiveObject(u), l.renderAll()), u;
3368
3383
  }
@@ -3388,8 +3403,8 @@ class to {
3388
3403
  id: t = `triangle-${V()}`,
3389
3404
  left: e,
3390
3405
  top: s,
3391
- width: o = 100,
3392
- height: n = 100,
3406
+ width: n = 100,
3407
+ height: o = 100,
3393
3408
  fill: i = "yellow"
3394
3409
  } = l, a = vt(l, [
3395
3410
  "id",
@@ -3404,13 +3419,13 @@ class to {
3404
3419
  left: e,
3405
3420
  top: s,
3406
3421
  fill: i,
3407
- width: o,
3408
- height: n
3422
+ width: n,
3423
+ height: o
3409
3424
  }, a));
3410
3425
  return !e && !s && u.centerObject(g), c || (u.add(g), r || u.setActiveObject(g), u.renderAll()), g;
3411
3426
  }
3412
3427
  }
3413
- class eo {
3428
+ class en {
3414
3429
  /**
3415
3430
  * @param options
3416
3431
  * @param options.editor - экземпляр редактора с доступом к canvas
@@ -3441,15 +3456,15 @@ class eo {
3441
3456
  return k(this, null, function* () {
3442
3457
  const { canvas: e, errorManager: s } = this.editor;
3443
3458
  try {
3444
- const o = yield t.clone(Kt);
3445
- this.clipboard = o, e.fire("editor:object-copied", { object: o });
3446
- } catch (o) {
3459
+ const n = yield t.clone(Kt);
3460
+ this.clipboard = n, e.fire("editor:object-copied", { object: n });
3461
+ } catch (n) {
3447
3462
  s.emitError({
3448
3463
  origin: "ClipboardManager",
3449
3464
  method: "_cloneToInternalClipboard",
3450
3465
  code: "CLONE_FAILED",
3451
3466
  message: "Ошибка клонирования объекта для внутреннего буфера",
3452
- data: o
3467
+ data: n
3453
3468
  });
3454
3469
  }
3455
3470
  });
@@ -3468,8 +3483,8 @@ class eo {
3468
3483
  message: "navigator.clipboard не поддерживается в этом браузере или отсутствует HTTPS-соединение."
3469
3484
  }), !1;
3470
3485
  try {
3471
- const s = t.toObject(Kt), o = JSON.stringify(s);
3472
- return t.type === "image" ? this._copyImageToClipboard(t, o) : this._copyTextToClipboard(o);
3486
+ const s = t.toObject(Kt), n = JSON.stringify(s);
3487
+ return t.type === "image" ? this._copyImageToClipboard(t, n) : this._copyTextToClipboard(n);
3473
3488
  } catch (s) {
3474
3489
  return e.emitError({
3475
3490
  origin: "ClipboardManager",
@@ -3487,10 +3502,10 @@ class eo {
3487
3502
  _copyImageToClipboard(t, e) {
3488
3503
  return k(this, null, function* () {
3489
3504
  try {
3490
- 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);
3505
+ const n = t.toCanvasElement({ enableRetinaScaling: !1 }).toDataURL(), o = n.slice(5).split(";")[0], i = n.split(",")[1], a = atob(i), r = new Uint8Array(a.length);
3491
3506
  for (let l = 0; l < a.length; l += 1)
3492
3507
  r[l] = a.charCodeAt(l);
3493
- const c = new Blob([r.buffer], { type: n }), d = new ClipboardItem({ [n]: c });
3508
+ const c = new Blob([r.buffer], { type: o }), d = new ClipboardItem({ [o]: c });
3494
3509
  return yield navigator.clipboard.write([d]), console.info("Image copied to clipboard successfully"), !0;
3495
3510
  } catch (s) {
3496
3511
  return this.editor.errorManager.emitWarning({
@@ -3530,8 +3545,8 @@ class eo {
3530
3545
  _addClonedObjectToCanvas(t) {
3531
3546
  const { canvas: e, historyManager: s } = this.editor;
3532
3547
  if (e.discardActiveObject(), t instanceof U) {
3533
- s.suspendHistory(), t.canvas = e, t.forEachObject((o) => {
3534
- e.add(o);
3548
+ s.suspendHistory(), t.canvas = e, t.forEachObject((n) => {
3549
+ e.add(n);
3535
3550
  }), e.setActiveObject(t), e.requestRenderAll(), s.resumeHistory(), s.saveState();
3536
3551
  return;
3537
3552
  }
@@ -3562,26 +3577,26 @@ class eo {
3562
3577
  const { canvas: e } = this.editor, s = t || e.getActiveObject();
3563
3578
  if (!s || s.locked) return !1;
3564
3579
  try {
3565
- const o = yield s.clone(Kt);
3566
- return o instanceof U && o.forEachObject((n) => {
3567
- n.set({
3568
- id: `${n.type}-${V()}`,
3580
+ const n = yield s.clone(Kt);
3581
+ return n instanceof U && n.forEachObject((o) => {
3582
+ o.set({
3583
+ id: `${o.type}-${V()}`,
3569
3584
  evented: !0
3570
3585
  });
3571
- }), o.set({
3572
- id: `${o.type}-${V()}`,
3573
- left: o.left + 10,
3574
- top: o.top + 10,
3586
+ }), n.set({
3587
+ id: `${n.type}-${V()}`,
3588
+ left: n.left + 10,
3589
+ top: n.top + 10,
3575
3590
  evented: !0
3576
- }), this._addClonedObjectToCanvas(o), e.fire("editor:object-duplicated", { object: o }), !0;
3577
- } catch (o) {
3578
- const { errorManager: n } = this.editor;
3579
- return n.emitError({
3591
+ }), this._addClonedObjectToCanvas(n), e.fire("editor:object-duplicated", { object: n }), !0;
3592
+ } catch (n) {
3593
+ const { errorManager: o } = this.editor;
3594
+ return o.emitError({
3580
3595
  origin: "ClipboardManager",
3581
3596
  method: "copyPaste",
3582
3597
  code: "COPY_PASTE_FAILED",
3583
3598
  message: "Ошибка создания копии объекта",
3584
- data: o
3599
+ data: n
3585
3600
  }), !1;
3586
3601
  }
3587
3602
  });
@@ -3604,8 +3619,8 @@ class eo {
3604
3619
  this.paste();
3605
3620
  return;
3606
3621
  }
3607
- const { items: o } = t, n = o[o.length - 1], i = n.getAsFile();
3608
- if (n.type !== "text/html" && i) {
3622
+ const { items: n } = t, o = n[n.length - 1], i = o.getAsFile();
3623
+ if (o.type !== "text/html" && i) {
3609
3624
  const c = new FileReader();
3610
3625
  c.onload = (d) => {
3611
3626
  d.target && this._handleImageImport(d.target.result).catch((l) => {
@@ -3686,7 +3701,7 @@ class ee {
3686
3701
  * @fires editor:object-locked
3687
3702
  */
3688
3703
  lockObject({ object: t, skipInnerObjects: e, withoutSave: s } = {}) {
3689
- const { canvas: o, historyManager: n } = this.editor, i = t || o.getActiveObject();
3704
+ const { canvas: n, historyManager: o } = this.editor, i = t || n.getActiveObject();
3690
3705
  if (!i || i.locked) return;
3691
3706
  const a = {
3692
3707
  lockMovementX: !0,
@@ -3701,7 +3716,7 @@ class ee {
3701
3716
  };
3702
3717
  i.set(a), !e && ee._isGroupOrSelection(i) && i.getObjects().forEach((c) => {
3703
3718
  c.set(a);
3704
- }), o.renderAll(), s || n.saveState(), o.fire("editor:object-locked", {
3719
+ }), n.renderAll(), s || o.saveState(), n.fire("editor:object-locked", {
3705
3720
  object: i,
3706
3721
  skipInnerObjects: e,
3707
3722
  withoutSave: s
@@ -3715,8 +3730,8 @@ class ee {
3715
3730
  * @fires editor:object-unlocked
3716
3731
  */
3717
3732
  unlockObject({ object: t, withoutSave: e } = {}) {
3718
- const { canvas: s, historyManager: o } = this.editor, n = t || s.getActiveObject();
3719
- if (!n) return;
3733
+ const { canvas: s, historyManager: n } = this.editor, o = t || s.getActiveObject();
3734
+ if (!o) return;
3720
3735
  const i = {
3721
3736
  lockMovementX: !1,
3722
3737
  lockMovementY: !1,
@@ -3728,10 +3743,10 @@ class ee {
3728
3743
  editable: !0,
3729
3744
  locked: !1
3730
3745
  };
3731
- n.set(i), ee._isGroupOrSelection(n) && n.getObjects().forEach((a) => {
3746
+ o.set(i), ee._isGroupOrSelection(o) && o.getObjects().forEach((a) => {
3732
3747
  a.set(i);
3733
- }), s.renderAll(), e || o.saveState(), s.fire("editor:object-unlocked", {
3734
- object: n,
3748
+ }), s.renderAll(), e || n.saveState(), s.fire("editor:object-unlocked", {
3749
+ object: o,
3735
3750
  withoutSave: e
3736
3751
  });
3737
3752
  }
@@ -3739,7 +3754,7 @@ class ee {
3739
3754
  return t instanceof U || t instanceof Et;
3740
3755
  }
3741
3756
  }
3742
- class so {
3757
+ class sn {
3743
3758
  constructor({ editor: t }) {
3744
3759
  this.editor = t;
3745
3760
  }
@@ -3759,17 +3774,17 @@ class so {
3759
3774
  */
3760
3775
  _getGroupsToUngroup(t) {
3761
3776
  if (Array.isArray(t)) {
3762
- const s = t.filter((o) => o instanceof Et);
3777
+ const s = t.filter((n) => n instanceof Et);
3763
3778
  return s.length > 0 ? s : null;
3764
3779
  }
3765
3780
  if (t instanceof U) {
3766
- const s = t.getObjects().filter((o) => o instanceof Et);
3781
+ const s = t.getObjects().filter((n) => n instanceof Et);
3767
3782
  return s.length > 0 ? s : null;
3768
3783
  }
3769
3784
  const e = t || this.editor.canvas.getActiveObject();
3770
3785
  if (!e) return null;
3771
3786
  if (e instanceof U) {
3772
- const s = e.getObjects().filter((o) => o instanceof Et);
3787
+ const s = e.getObjects().filter((n) => n instanceof Et);
3773
3788
  return s.length > 0 ? s : null;
3774
3789
  }
3775
3790
  return e instanceof Et ? [e] : null;
@@ -3785,21 +3800,21 @@ class so {
3785
3800
  target: t,
3786
3801
  withoutSave: e = !1
3787
3802
  } = {}) {
3788
- const { canvas: s, historyManager: o } = this.editor, n = this._getObjectsToGroup(t);
3789
- if (!n) return null;
3803
+ const { canvas: s, historyManager: n } = this.editor, o = this._getObjectsToGroup(t);
3804
+ if (!o) return null;
3790
3805
  try {
3791
- o.suspendHistory();
3792
- const i = new Et(n, {
3806
+ n.suspendHistory();
3807
+ const i = new Et(o, {
3793
3808
  id: `group-${V()}`
3794
3809
  });
3795
- n.forEach((r) => s.remove(r)), s.add(i), s.setActiveObject(i), s.requestRenderAll();
3810
+ o.forEach((r) => s.remove(r)), s.add(i), s.setActiveObject(i), s.requestRenderAll();
3796
3811
  const a = {
3797
3812
  group: i,
3798
3813
  withoutSave: e
3799
3814
  };
3800
3815
  return s.fire("editor:objects-grouped", a), a;
3801
3816
  } finally {
3802
- o.resumeHistory(), e || o.saveState();
3817
+ n.resumeHistory(), e || n.saveState();
3803
3818
  }
3804
3819
  }
3805
3820
  /**
@@ -3814,12 +3829,12 @@ class so {
3814
3829
  target: t,
3815
3830
  withoutSave: e = !1
3816
3831
  } = {}) {
3817
- const { canvas: s, historyManager: o } = this.editor, n = this._getGroupsToUngroup(t);
3818
- if (!n) return null;
3832
+ const { canvas: s, historyManager: n } = this.editor, o = this._getGroupsToUngroup(t);
3833
+ if (!o) return null;
3819
3834
  try {
3820
- o.suspendHistory();
3835
+ n.suspendHistory();
3821
3836
  const i = [];
3822
- n.forEach((c) => {
3837
+ o.forEach((c) => {
3823
3838
  const d = c.removeAll();
3824
3839
  s.remove(c), d.forEach((l) => {
3825
3840
  s.add(l), i.push(l);
@@ -3836,11 +3851,11 @@ class so {
3836
3851
  };
3837
3852
  return s.fire("editor:objects-ungrouped", r), r;
3838
3853
  } finally {
3839
- o.resumeHistory(), e || o.saveState();
3854
+ n.resumeHistory(), e || n.saveState();
3840
3855
  }
3841
3856
  }
3842
3857
  }
3843
- class oo {
3858
+ class nn {
3844
3859
  constructor({ editor: t }) {
3845
3860
  this.editor = t;
3846
3861
  }
@@ -3851,8 +3866,8 @@ class oo {
3851
3866
  selectAll() {
3852
3867
  const { canvas: t, canvasManager: e, objectLockManager: s } = this.editor;
3853
3868
  t.discardActiveObject();
3854
- const o = e.getObjects(), n = o.some((a) => a.locked), i = o.length > 1 ? new U(e.getObjects(), { canvas: t }) : o[0];
3855
- n && s.lockObject({ object: i, skipInnerObjects: !0, withoutSave: !0 }), t.setActiveObject(i), t.requestRenderAll(), t.fire("editor:all-objects-selected", { selected: i });
3869
+ const n = e.getObjects(), o = n.some((a) => a.locked), i = n.length > 1 ? new U(e.getObjects(), { canvas: t }) : n[0];
3870
+ o && s.lockObject({ object: i, skipInnerObjects: !0, withoutSave: !0 }), t.setActiveObject(i), t.requestRenderAll(), t.fire("editor:all-objects-selected", { selected: i });
3856
3871
  }
3857
3872
  }
3858
3873
  class Me {
@@ -3873,11 +3888,11 @@ class Me {
3873
3888
  * @returns массив всех удаленных объектов (включая саму группу)
3874
3889
  */
3875
3890
  _handleGroupDeletion(t) {
3876
- var o;
3877
- const { groupingManager: e } = this.editor, { ungroupedObjects: s = [] } = (o = e.ungroup({
3891
+ var n;
3892
+ const { groupingManager: e } = this.editor, { ungroupedObjects: s = [] } = (n = e.ungroup({
3878
3893
  object: t,
3879
3894
  withoutSave: !0
3880
- })) != null ? o : {};
3895
+ })) != null ? n : {};
3881
3896
  return this.deleteSelectedObjects({
3882
3897
  objects: s,
3883
3898
  withoutSave: !0,
@@ -3897,9 +3912,9 @@ class Me {
3897
3912
  withoutSave: e = !1,
3898
3913
  _isRecursiveCall: s = !1
3899
3914
  } = {}) {
3900
- const { canvas: o, historyManager: n } = this.editor, a = (t || o.getActiveObjects()).filter((d) => !d.locked);
3915
+ const { canvas: n, historyManager: o } = this.editor, a = (t || n.getActiveObjects()).filter((d) => !d.locked);
3901
3916
  if (!(a != null && a.length)) return null;
3902
- s || n.suspendHistory();
3917
+ s || o.suspendHistory();
3903
3918
  const r = [];
3904
3919
  if (a.forEach((d) => {
3905
3920
  if (Me._isUngroupableGroup(d)) {
@@ -3907,14 +3922,14 @@ class Me {
3907
3922
  r.push(...l);
3908
3923
  return;
3909
3924
  }
3910
- o.remove(d), r.push(d);
3925
+ n.remove(d), r.push(d);
3911
3926
  }), s) return null;
3912
- o.discardActiveObject(), o.renderAll(), n.resumeHistory(), e || n.saveState();
3927
+ n.discardActiveObject(), n.renderAll(), o.resumeHistory(), e || o.saveState();
3913
3928
  const c = {
3914
3929
  objects: r,
3915
3930
  withoutSave: e
3916
3931
  };
3917
- return o.fire("editor:objects-deleted", c), c;
3932
+ return n.fire("editor:objects-deleted", c), c;
3918
3933
  }
3919
3934
  }
3920
3935
  const bt = {
@@ -4048,20 +4063,20 @@ class Wt {
4048
4063
  * @param options.message — текст ошибки (опционально, если не передан, то используется код ошибки)
4049
4064
  * @fires editor:error
4050
4065
  */
4051
- emitError({ origin: t = "ImageEditor", method: e = "Unknown Method", code: s, data: o, message: n }) {
4066
+ emitError({ origin: t = "ImageEditor", method: e = "Unknown Method", code: s, data: n, message: o }) {
4052
4067
  if (!Wt.isValidErrorCode(s)) {
4053
4068
  console.warn("Неизвестный код ошибки: ", { code: s, origin: t, method: e });
4054
4069
  return;
4055
4070
  }
4056
4071
  if (!s) return;
4057
- const i = n || s;
4058
- console.error(`${t}. ${e}. ${s}. ${i}`, o);
4072
+ const i = o || s;
4073
+ console.error(`${t}. ${e}. ${s}. ${i}`, n);
4059
4074
  const a = {
4060
4075
  code: s,
4061
4076
  origin: t,
4062
4077
  method: e,
4063
4078
  message: i,
4064
- data: o
4079
+ data: n
4065
4080
  };
4066
4081
  this._buffer.push(B({
4067
4082
  type: "editor:error"
@@ -4077,19 +4092,19 @@ class Wt {
4077
4092
  * @param options.message — текст предупреждения (опционально, если не передан, то используется код предупреждения)
4078
4093
  * @fires editor:warning
4079
4094
  */
4080
- emitWarning({ origin: t = "ImageEditor", method: e = "Unknown Method", code: s, message: o, data: n }) {
4095
+ emitWarning({ origin: t = "ImageEditor", method: e = "Unknown Method", code: s, message: n, data: o }) {
4081
4096
  if (!Wt.isValidErrorCode(s)) {
4082
4097
  console.warn("Неизвестный код предупреждения: ", { code: s, origin: t, method: e });
4083
4098
  return;
4084
4099
  }
4085
- const i = o || s;
4086
- console.warn(`${t}. ${e}. ${s}. ${i}`, n);
4100
+ const i = n || s;
4101
+ console.warn(`${t}. ${e}. ${s}. ${i}`, o);
4087
4102
  const a = {
4088
4103
  code: s,
4089
4104
  origin: t,
4090
4105
  method: e,
4091
4106
  message: i,
4092
- data: n
4107
+ data: o
4093
4108
  };
4094
4109
  this._buffer.push(B({
4095
4110
  type: "editor:warning"
@@ -4104,7 +4119,7 @@ class Wt {
4104
4119
  return t ? Object.values(bt).some((e) => Object.values(e).includes(t)) : !1;
4105
4120
  }
4106
4121
  }
4107
- class no {
4122
+ class on {
4108
4123
  constructor({ editor: t }) {
4109
4124
  this.currentBounds = null, this.editor = t;
4110
4125
  }
@@ -4117,8 +4132,8 @@ class no {
4117
4132
  * @returns Объект с границами перетаскивания
4118
4133
  */
4119
4134
  calculatePanBounds() {
4120
- const { canvas: t, montageArea: e, zoomManager: s } = this.editor, { defaultZoom: o } = s, n = t.getZoom();
4121
- if (n <= o)
4135
+ const { canvas: t, montageArea: e, zoomManager: s } = this.editor, { defaultZoom: n } = s, o = t.getZoom();
4136
+ if (o <= n)
4122
4137
  return {
4123
4138
  minX: 0,
4124
4139
  maxX: 0,
@@ -4126,7 +4141,7 @@ class no {
4126
4141
  maxY: 0,
4127
4142
  canPan: !1
4128
4143
  };
4129
- const i = e.width * n, a = e.height * n, r = i / 2, c = a / 2;
4144
+ const i = e.width * o, a = e.height * o, r = i / 2, c = a / 2;
4130
4145
  return {
4131
4146
  minX: -r,
4132
4147
  maxX: r,
@@ -4154,13 +4169,13 @@ class no {
4154
4169
  constrainPan(t, e) {
4155
4170
  if (!this.currentBounds || !this.currentBounds.canPan)
4156
4171
  return { x: 0, y: 0 };
4157
- 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(
4172
+ const { canvas: s, montageArea: n } = this.editor, o = s.getZoom(), i = n.left, a = n.top, r = s.getWidth() / 2, c = s.getHeight() / 2, d = i * o + t - r, l = a * o + e - c, u = Math.max(
4158
4173
  this.currentBounds.minX,
4159
4174
  Math.min(this.currentBounds.maxX, d)
4160
4175
  ), g = Math.max(
4161
4176
  this.currentBounds.minY,
4162
4177
  Math.min(this.currentBounds.maxY, l)
4163
- ), f = u + r - i * n, p = g + c - a * n;
4178
+ ), f = u + r - i * o, p = g + c - a * o;
4164
4179
  return {
4165
4180
  x: f,
4166
4181
  y: p
@@ -4178,7 +4193,7 @@ class no {
4178
4193
  * @returns Объект с координатами смещения
4179
4194
  */
4180
4195
  getCurrentOffset() {
4181
- const { canvas: t, montageArea: e } = this.editor, s = t.getZoom(), o = t.viewportTransform, n = e.left, i = e.top, a = t.getWidth() / 2, r = t.getHeight() / 2, c = n * s + o[4] - a, d = i * s + o[5] - r;
4196
+ const { canvas: t, montageArea: e } = this.editor, s = t.getZoom(), n = t.viewportTransform, o = e.left, i = e.top, a = t.getWidth() / 2, r = t.getHeight() / 2, c = o * s + n[4] - a, d = i * s + n[5] - r;
4182
4197
  return { x: c, y: d };
4183
4198
  }
4184
4199
  /**
@@ -4193,10 +4208,10 @@ const at = ({
4193
4208
  value: h,
4194
4209
  min: t,
4195
4210
  max: e
4196
- }) => Math.min(Math.max(h, t), e), Dt = class Dt extends nt {
4211
+ }) => Math.min(Math.max(h, t), e), Dt = class Dt extends ot {
4197
4212
  constructor(t, e = {}) {
4198
- var s, o, n, i, a, r, c, d, l;
4199
- 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();
4213
+ var s, n, o, i, a, r, c, d, l;
4214
+ super(t, e), this.backgroundOpacity = (s = e.backgroundOpacity) != null ? s : 1, this.paddingTop = (n = e.paddingTop) != null ? n : 0, this.paddingRight = (o = e.paddingRight) != null ? o : 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();
4200
4215
  }
4201
4216
  /**
4202
4217
  * Пересчитывает размеры текста и округляет их до целых значений.
@@ -4241,10 +4256,10 @@ const at = ({
4241
4256
  });
4242
4257
  }
4243
4258
  _renderBackground(t) {
4244
- var s, o;
4259
+ var s, n;
4245
4260
  const e = this._getEffectiveBackgroundFill();
4246
4261
  if (e && e) {
4247
- 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;
4262
+ const o = this._getPadding(), i = (s = this.width) != null ? s : 0, a = (n = this.height) != null ? n : 0, r = i + o.left + o.right, c = a + o.top + o.bottom, d = this._getCornerRadii({ width: r, height: c }), l = this._getLeftOffset() - o.left, u = this._getTopOffset() - o.top;
4248
4263
  t.save(), Dt._renderRoundedRect({
4249
4264
  ctx: t,
4250
4265
  height: c,
@@ -4256,8 +4271,8 @@ const at = ({
4256
4271
  }
4257
4272
  }
4258
4273
  _getBackgroundDimensions() {
4259
- var o, n, i, a;
4260
- const t = (n = (o = this.width) != null ? o : this.calcTextWidth()) != null ? n : 0, e = (a = (i = this.height) != null ? i : this.calcTextHeight()) != null ? a : 0, s = this._getPadding();
4274
+ var n, o, i, a;
4275
+ const t = (o = (n = this.width) != null ? n : this.calcTextWidth()) != null ? o : 0, e = (a = (i = this.height) != null ? i : this.calcTextHeight()) != null ? a : 0, s = this._getPadding();
4261
4276
  return {
4262
4277
  height: e + s.top + s.bottom,
4263
4278
  width: t + s.left + s.right
@@ -4265,38 +4280,38 @@ const at = ({
4265
4280
  }
4266
4281
  _getCornerRadii({ width: t, height: e }) {
4267
4282
  var i, a, r, c;
4268
- const s = t / 2, o = e / 2, n = Math.min(s, o);
4283
+ const s = t / 2, n = e / 2, o = Math.min(s, n);
4269
4284
  return {
4270
- bottomLeft: at({ value: (i = this.radiusBottomLeft) != null ? i : 0, min: 0, max: n }),
4271
- bottomRight: at({ value: (a = this.radiusBottomRight) != null ? a : 0, min: 0, max: n }),
4272
- topLeft: at({ value: (r = this.radiusTopLeft) != null ? r : 0, min: 0, max: n }),
4273
- topRight: at({ value: (c = this.radiusTopRight) != null ? c : 0, min: 0, max: n })
4285
+ bottomLeft: at({ value: (i = this.radiusBottomLeft) != null ? i : 0, min: 0, max: o }),
4286
+ bottomRight: at({ value: (a = this.radiusBottomRight) != null ? a : 0, min: 0, max: o }),
4287
+ topLeft: at({ value: (r = this.radiusTopLeft) != null ? r : 0, min: 0, max: o }),
4288
+ topRight: at({ value: (c = this.radiusTopRight) != null ? c : 0, min: 0, max: o })
4274
4289
  };
4275
4290
  }
4276
4291
  _getPadding() {
4277
- var t, e, s, o;
4292
+ var t, e, s, n;
4278
4293
  return {
4279
4294
  bottom: (t = this.paddingBottom) != null ? t : 0,
4280
4295
  left: (e = this.paddingLeft) != null ? e : 0,
4281
4296
  right: (s = this.paddingRight) != null ? s : 0,
4282
- top: (o = this.paddingTop) != null ? o : 0
4297
+ top: (n = this.paddingTop) != null ? n : 0
4283
4298
  };
4284
4299
  }
4285
4300
  _getEffectiveBackgroundFill() {
4286
- var o;
4301
+ var n;
4287
4302
  const t = this.backgroundColor;
4288
4303
  if (!t) return null;
4289
- const e = at({ value: (o = this.backgroundOpacity) != null ? o : 1, min: 0, max: 1 });
4304
+ const e = at({ value: (n = this.backgroundOpacity) != null ? n : 1, min: 0, max: 1 });
4290
4305
  let s;
4291
4306
  try {
4292
4307
  s = new ps(t);
4293
- } catch (n) {
4308
+ } catch (o) {
4294
4309
  return Wt.emitError({
4295
4310
  origin: "BackgroundTextbox",
4296
4311
  method: "_getEffectiveBackgroundFill",
4297
4312
  code: "INVALID_COLOR_VALUE",
4298
4313
  message: `Некорректное значение цвета фона: ${t}`,
4299
- data: { color: t, error: n }
4314
+ data: { color: t, error: o }
4300
4315
  }), null;
4301
4316
  }
4302
4317
  return s.setAlpha(e), s.toRgba();
@@ -4305,17 +4320,17 @@ const at = ({
4305
4320
  ctx: t,
4306
4321
  height: e,
4307
4322
  left: s,
4308
- radii: o,
4309
- top: n,
4323
+ radii: n,
4324
+ top: o,
4310
4325
  width: i
4311
4326
  }) {
4312
- const a = s + i, r = n + e, {
4327
+ const a = s + i, r = o + e, {
4313
4328
  topLeft: c,
4314
4329
  topRight: d,
4315
4330
  bottomRight: l,
4316
4331
  bottomLeft: u
4317
- } = 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 });
4318
- 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();
4332
+ } = n, 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 });
4333
+ t.beginPath(), t.moveTo(s + g, o), t.lineTo(a - f, o), t.quadraticCurveTo(a, o, a, o + 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, o + g), t.quadraticCurveTo(s, o, s + g, o), t.closePath();
4319
4334
  }
4320
4335
  /**
4321
4336
  * Округляет текущие значения ширины и высоты до ближайших целых.
@@ -4324,12 +4339,12 @@ const at = ({
4324
4339
  const {
4325
4340
  width: t = 0,
4326
4341
  height: e = 0
4327
- } = this, s = Math.round(t), o = Math.round(e);
4328
- s !== t && (this.width = Math.max(0, s)), o !== e && (this.height = Math.max(0, o));
4342
+ } = this, s = Math.round(t), n = Math.round(e);
4343
+ s !== t && (this.width = Math.max(0, s)), n !== e && (this.height = Math.max(0, n));
4329
4344
  }
4330
4345
  };
4331
4346
  Dt.type = "background-textbox", Dt.cacheProperties = [
4332
- ...Array.isArray(nt.cacheProperties) ? nt.cacheProperties : [],
4347
+ ...Array.isArray(ot.cacheProperties) ? ot.cacheProperties : [],
4333
4348
  "backgroundColor",
4334
4349
  "backgroundOpacity",
4335
4350
  "paddingTop",
@@ -4341,7 +4356,7 @@ Dt.type = "background-textbox", Dt.cacheProperties = [
4341
4356
  "radiusBottomRight",
4342
4357
  "radiusBottomLeft"
4343
4358
  ], Dt.stateProperties = [
4344
- ...Array.isArray(nt.stateProperties) ? nt.stateProperties : [],
4359
+ ...Array.isArray(ot.stateProperties) ? ot.stateProperties : [],
4345
4360
  "backgroundColor",
4346
4361
  "backgroundOpacity",
4347
4362
  "paddingTop",
@@ -4354,25 +4369,25 @@ Dt.type = "background-textbox", Dt.cacheProperties = [
4354
4369
  "radiusBottomLeft"
4355
4370
  ];
4356
4371
  let se = Dt;
4357
- const io = () => {
4372
+ const an = () => {
4358
4373
  var h;
4359
4374
  (h = ze) != null && h.setClass && ze.setClass(se, "background-textbox");
4360
- }, ao = ({ textbox: h }) => {
4361
- var s, o;
4375
+ }, rn = ({ textbox: h }) => {
4376
+ var s, n;
4362
4377
  if (!h.isEditing) return null;
4363
- const t = (s = h.selectionStart) != null ? s : 0, e = (o = h.selectionEnd) != null ? o : t;
4378
+ const t = (s = h.selectionStart) != null ? s : 0, e = (n = h.selectionEnd) != null ? n : t;
4364
4379
  return t === e ? null : {
4365
4380
  start: Math.min(t, e),
4366
4381
  end: Math.max(t, e)
4367
4382
  };
4368
- }, ro = ({ textbox: h }) => {
4383
+ }, cn = ({ textbox: h }) => {
4369
4384
  var e, s;
4370
4385
  const t = (s = (e = h.text) == null ? void 0 : e.length) != null ? s : 0;
4371
4386
  return t <= 0 ? null : { start: 0, end: t };
4372
- }, co = ({ textbox: h, range: t }) => {
4373
- var s, o;
4387
+ }, dn = ({ textbox: h, range: t }) => {
4388
+ var s, n;
4374
4389
  if (!t) return !1;
4375
- const e = (o = (s = h.text) == null ? void 0 : s.length) != null ? o : 0;
4390
+ const e = (n = (s = h.text) == null ? void 0 : s.length) != null ? n : 0;
4376
4391
  return e <= 0 ? !1 : t.start <= 0 && t.end >= e;
4377
4392
  }, ie = ({
4378
4393
  textbox: h,
@@ -4380,14 +4395,14 @@ const io = () => {
4380
4395
  range: e
4381
4396
  }) => {
4382
4397
  if (!t || !Object.keys(t).length) return !1;
4383
- const { start: s, end: o } = e;
4384
- return o <= s ? !1 : (h.setSelectionStyles(t, s, o), !0);
4398
+ const { start: s, end: n } = e;
4399
+ return n <= s ? !1 : (h.setSelectionStyles(t, s, n), !0);
4385
4400
  }, Ge = ({
4386
4401
  textbox: h,
4387
4402
  range: t,
4388
4403
  property: e
4389
4404
  }) => {
4390
- var o;
4405
+ var n;
4391
4406
  if (!t) return;
4392
4407
  const s = h.getSelectionStyles(
4393
4408
  t.start,
@@ -4395,8 +4410,8 @@ const io = () => {
4395
4410
  !0
4396
4411
  );
4397
4412
  if (s.length)
4398
- return (o = s[0]) == null ? void 0 : o[e];
4399
- }, Ve = ({ strokeColor: h, width: t }) => t <= 0 ? null : h != null ? h : "#000000", Xe = ({ width: h = 0 }) => h ? Math.max(0, h) : 0, ae = ({ value: h }) => typeof h == "string" ? h.toLocaleUpperCase() : "", ot = 0.01;
4413
+ return (n = s[0]) == null ? void 0 : n[e];
4414
+ }, Ve = ({ strokeColor: h, width: t }) => t <= 0 ? null : h != null ? h : "#000000", Xe = ({ width: h = 0 }) => h ? Math.max(0, h) : 0, ae = ({ value: h }) => typeof h == "string" ? h.toLocaleUpperCase() : "", nt = 0.01;
4400
4415
  class F {
4401
4416
  constructor({ editor: t }) {
4402
4417
  var e;
@@ -4404,15 +4419,15 @@ class F {
4404
4419
  this.isTextEditingActive = !0;
4405
4420
  }, this._handleTextEditingExited = (s) => {
4406
4421
  var r, c;
4407
- const { target: o } = s;
4408
- if (!F._isTextbox(o)) return;
4409
- const n = (r = o.text) != null ? r : "";
4410
- if (!!o.uppercase) {
4411
- const d = (c = o.textCaseRaw) != null ? c : n.toLocaleLowerCase();
4412
- o.textCaseRaw = d;
4422
+ const { target: n } = s;
4423
+ if (!F._isTextbox(n)) return;
4424
+ const o = (r = n.text) != null ? r : "";
4425
+ if (!!n.uppercase) {
4426
+ const d = (c = n.textCaseRaw) != null ? c : o.toLocaleLowerCase();
4427
+ n.textCaseRaw = d;
4413
4428
  } else
4414
- o.textCaseRaw = n;
4415
- F._roundTextboxDimensions({ textbox: o }) && (o.setCoords(), o.dirty = !0, this.canvas.requestRenderAll()), o.locked || o.set({
4429
+ n.textCaseRaw = o;
4430
+ F._roundTextboxDimensions({ textbox: n }) && (n.setCoords(), n.dirty = !0, this.canvas.requestRenderAll()), n.locked || n.set({
4416
4431
  lockMovementX: !1,
4417
4432
  lockMovementY: !1
4418
4433
  }), setTimeout(() => {
@@ -4420,19 +4435,19 @@ class F {
4420
4435
  }, Vs);
4421
4436
  }, this._handleObjectScaling = (s) => {
4422
4437
  var X, It, Ht, mt, Zt, Ct, Se, Ae, je, Ie, Ce, Te, Ee;
4423
- const { target: o, transform: n } = s;
4424
- if (o instanceof U || !F._isTextbox(o) || !n) return;
4425
- o.isScaling = !0;
4426
- const i = this._ensureScalingState(o), {
4438
+ const { target: n, transform: o } = s;
4439
+ if (n instanceof U || !F._isTextbox(n) || !o) return;
4440
+ n.isScaling = !0;
4441
+ const i = this._ensureScalingState(n), {
4427
4442
  baseWidth: a,
4428
4443
  baseLeft: r,
4429
4444
  baseFontSize: c,
4430
4445
  basePadding: d,
4431
4446
  baseRadii: l,
4432
4447
  baseStyles: u
4433
- } = 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 = (Ht = n.corner) != null ? Ht : "", M = (mt = n.action) != null ? mt : "", S = ["ml", "mr"].includes(v) || M === "scaleX", y = ["mt", "mb"].includes(v) || M === "scaleY", b = ["tl", "tr", "bl", "br"].includes(v) || M === "scale", I = b || y;
4448
+ } = i, g = typeof ((X = o.original) == null ? void 0 : X.width) == "number" ? o.original.width : void 0, f = typeof ((It = o.original) == null ? void 0 : It.left) == "number" ? o.original.left : void 0, p = g != null ? g : a, m = f != null ? f : r, v = (Ht = o.corner) != null ? Ht : "", M = (mt = o.action) != null ? mt : "", S = ["ml", "mr"].includes(v) || M === "scaleX", y = ["mt", "mb"].includes(v) || M === "scaleY", b = ["tl", "tr", "bl", "br"].includes(v) || M === "scale", I = b || y;
4434
4449
  if (!S && !y && !b) return;
4435
- const j = Math.abs((Ct = (Zt = o.scaleX) != null ? Zt : n.scaleX) != null ? Ct : 1) || 1, A = Math.abs((Ae = (Se = o.scaleY) != null ? Se : n.scaleY) != null ? Ae : 1) || 1, C = Math.max(1, p * j), w = Math.max(1, Math.round(C)), T = Math.max(1, c * A), {
4450
+ const j = Math.abs((Ct = (Zt = n.scaleX) != null ? Zt : o.scaleX) != null ? Ct : 1) || 1, A = Math.abs((Ae = (Se = n.scaleY) != null ? Se : o.scaleY) != null ? Ae : 1) || 1, C = Math.max(1, p * j), w = Math.max(1, Math.round(C)), T = Math.max(1, c * A), {
4436
4451
  paddingTop: E = 0,
4437
4452
  paddingRight: P = 0,
4438
4453
  paddingBottom: x = 0,
@@ -4444,7 +4459,7 @@ class F {
4444
4459
  fontSize: G,
4445
4460
  width: Y,
4446
4461
  originX: K = "left"
4447
- } = o, tt = b || y, J = b || y, H = tt ? {
4462
+ } = n, tt = b || y, J = b || y, H = tt ? {
4448
4463
  top: Math.max(0, d.top * A),
4449
4464
  right: Math.max(0, d.right * A),
4450
4465
  bottom: Math.max(0, d.bottom * A),
@@ -4457,23 +4472,23 @@ class F {
4457
4472
  } : l, St = Object.keys(u).length > 0;
4458
4473
  let st;
4459
4474
  if (I && St) {
4460
- const oe = {};
4475
+ const ne = {};
4461
4476
  Object.entries(u).forEach(([as, Oe]) => {
4462
4477
  if (!Oe) return;
4463
- const ne = {};
4478
+ const oe = {};
4464
4479
  Object.entries(Oe).forEach(([rs, Gt]) => {
4465
4480
  if (!Gt) return;
4466
4481
  const Le = B({}, Gt);
4467
- typeof Gt.fontSize == "number" && (Le.fontSize = Math.max(1, Gt.fontSize * A)), ne[rs] = Le;
4468
- }), Object.keys(ne).length && (oe[as] = ne);
4469
- }), Object.keys(oe).length && (st = oe);
4482
+ typeof Gt.fontSize == "number" && (Le.fontSize = Math.max(1, Gt.fontSize * A)), oe[rs] = Le;
4483
+ }), Object.keys(oe).length && (ne[as] = oe);
4484
+ }), Object.keys(ne).length && (st = ne);
4470
4485
  }
4471
- const lt = (Ie = (je = n.originX) != null ? je : K) != null ? Ie : "left", pt = m + p, At = m + p / 2, ht = Y != null ? Y : p, jt = w !== ht, Yt = Math.abs(T - (G != null ? G : c)) > ot, xt = Math.abs(H.top - E) > ot || Math.abs(H.right - P) > ot || Math.abs(H.bottom - x) > ot || Math.abs(H.left - N) > ot, Nt = Math.abs(q.topLeft - Z) > ot || Math.abs(q.topRight - D) > ot || Math.abs(q.bottomRight - _) > ot || Math.abs(q.bottomLeft - W) > ot;
4486
+ const lt = (Ie = (je = o.originX) != null ? je : K) != null ? Ie : "left", pt = m + p, At = m + p / 2, ht = Y != null ? Y : p, jt = w !== ht, Yt = Math.abs(T - (G != null ? G : c)) > nt, xt = Math.abs(H.top - E) > nt || Math.abs(H.right - P) > nt || Math.abs(H.bottom - x) > nt || Math.abs(H.left - N) > nt, Nt = Math.abs(q.topLeft - Z) > nt || Math.abs(q.topRight - D) > nt || Math.abs(q.bottomRight - _) > nt || Math.abs(q.bottomLeft - W) > nt;
4472
4487
  if (!jt && !Yt && !xt && !Nt) {
4473
- o.set({ scaleX: 1, scaleY: 1 }), n.scaleX = 1, n.scaleY = 1;
4488
+ n.set({ scaleX: 1, scaleY: 1 }), o.scaleX = 1, o.scaleY = 1;
4474
4489
  return;
4475
4490
  }
4476
- st && (o.styles = st), o.set({
4491
+ st && (n.styles = st), n.set({
4477
4492
  width: w,
4478
4493
  fontSize: I ? T : c,
4479
4494
  paddingTop: H.top,
@@ -4487,13 +4502,13 @@ class F {
4487
4502
  scaleX: 1,
4488
4503
  scaleY: 1
4489
4504
  });
4490
- const Bt = F._roundTextboxDimensions({ textbox: o });
4491
- Bt && (o.dirty = !0);
4492
- const ut = (Ce = o.width) != null ? Ce : w, kt = ut !== ht;
4505
+ const Bt = F._roundTextboxDimensions({ textbox: n });
4506
+ Bt && (n.dirty = !0);
4507
+ const ut = (Ce = n.width) != null ? Ce : w, kt = ut !== ht;
4493
4508
  let gt = m;
4494
- kt && (S || b) && (lt === "right" ? gt = pt - ut : lt === "center" && (gt = At - ut / 2)), o.set({ left: gt }), i.baseLeft = gt, n.scaleX = 1, n.scaleY = 1;
4495
- const { original: it } = n;
4496
- 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 = (Te = o.fontSize) != null ? Te : T, i.baseStyles = JSON.parse(JSON.stringify((Ee = o.styles) != null ? Ee : {})), i.basePadding = {
4509
+ kt && (S || b) && (lt === "right" ? gt = pt - ut : lt === "center" && (gt = At - ut / 2)), n.set({ left: gt }), i.baseLeft = gt, o.scaleX = 1, o.scaleY = 1;
4510
+ const { original: it } = o;
4511
+ it && (it.scaleX = 1, it.scaleY = 1, it.width = ut, it.height = n.height, it.left = gt), n.setCoords(), this.canvas.requestRenderAll(), i.baseWidth = ut, i.baseFontSize = (Te = n.fontSize) != null ? Te : T, i.baseStyles = JSON.parse(JSON.stringify((Ee = n.styles) != null ? Ee : {})), i.basePadding = {
4497
4512
  top: H.top,
4498
4513
  right: H.right,
4499
4514
  bottom: H.bottom,
@@ -4506,12 +4521,12 @@ class F {
4506
4521
  }, i.hasWidthChange = kt || Yt || xt || Nt || Bt;
4507
4522
  }, this._handleObjectModified = (s) => {
4508
4523
  var M, S, y;
4509
- const { target: o } = s;
4510
- if (o instanceof U) {
4511
- const b = o.getObjects();
4524
+ const { target: n } = s;
4525
+ if (n instanceof U) {
4526
+ const b = n.getObjects();
4512
4527
  if (!b.some((w) => F._isTextbox(w))) return;
4513
- const { scaleX: j = 1, scaleY: A = 1 } = o;
4514
- if (Math.abs(j - 1) < ot && Math.abs(A - 1) < ot) return;
4528
+ const { scaleX: j = 1, scaleY: A = 1 } = n;
4529
+ if (Math.abs(j - 1) < nt && Math.abs(A - 1) < nt) return;
4515
4530
  this.canvas.discardActiveObject(), b.forEach((w) => {
4516
4531
  var T, E, P, x;
4517
4532
  if (F._isTextbox(w)) {
@@ -4558,11 +4573,11 @@ class F {
4558
4573
  this.canvas.setActiveObject(C), this.canvas.requestRenderAll();
4559
4574
  return;
4560
4575
  }
4561
- if (!F._isTextbox(o)) return;
4562
- o.isScaling = !1;
4563
- const n = this.scalingState.get(o);
4564
- if (this.scalingState.delete(o), !(n != null && n.hasWidthChange)) return;
4565
- const i = (M = o.width) != null ? M : o.calcTextWidth(), a = (y = (S = o.fontSize) != null ? S : n == null ? void 0 : n.baseFontSize) != null ? y : 16, r = !!(n.baseStyles && Object.keys(n.baseStyles).length), {
4576
+ if (!F._isTextbox(n)) return;
4577
+ n.isScaling = !1;
4578
+ const o = this.scalingState.get(n);
4579
+ if (this.scalingState.delete(n), !(o != null && o.hasWidthChange)) return;
4580
+ const i = (M = n.width) != null ? M : n.calcTextWidth(), a = (y = (S = n.fontSize) != null ? S : o == null ? void 0 : o.baseFontSize) != null ? y : 16, r = !!(o.baseStyles && Object.keys(o.baseStyles).length), {
4566
4581
  paddingTop: c = 0,
4567
4582
  paddingRight: d = 0,
4568
4583
  paddingBottom: l = 0,
@@ -4571,7 +4586,7 @@ class F {
4571
4586
  radiusTopRight: f = 0,
4572
4587
  radiusBottomRight: p = 0,
4573
4588
  radiusBottomLeft: m = 0
4574
- } = o, v = {
4589
+ } = n, v = {
4575
4590
  width: i,
4576
4591
  paddingTop: c,
4577
4592
  paddingRight: d,
@@ -4583,10 +4598,10 @@ class F {
4583
4598
  radiusBottomLeft: m
4584
4599
  };
4585
4600
  r || (v.fontSize = a), this.updateText({
4586
- target: o,
4601
+ target: n,
4587
4602
  style: v
4588
- }), o.set({ scaleX: 1, scaleY: 1 }), o.setCoords();
4589
- }, this.editor = t, this.canvas = t.canvas, this.fonts = (e = t.options.fonts) != null ? e : [], this.scalingState = /* @__PURE__ */ new WeakMap(), this.isTextEditingActive = !1, this._bindEvents(), io();
4603
+ }), n.set({ scaleX: 1, scaleY: 1 }), n.setCoords();
4604
+ }, this.editor = t, this.canvas = t.canvas, this.fonts = (e = t.options.fonts) != null ? e : [], this.scalingState = /* @__PURE__ */ new WeakMap(), this.isTextEditingActive = !1, this._bindEvents(), an();
4590
4605
  }
4591
4606
  /**
4592
4607
  * Добавляет новый текстовый объект на канвас.
@@ -4598,8 +4613,8 @@ class F {
4598
4613
  id: t = `text-${V()}`,
4599
4614
  text: e = "Новый текст",
4600
4615
  fontFamily: s,
4601
- fontSize: o = 48,
4602
- bold: n = !1,
4616
+ fontSize: n = 48,
4617
+ bold: o = !1,
4603
4618
  italic: i = !1,
4604
4619
  underline: a = !1,
4605
4620
  uppercase: r = !1,
@@ -4654,8 +4669,8 @@ class F {
4654
4669
  }), G = B({
4655
4670
  id: t,
4656
4671
  fontFamily: D,
4657
- fontSize: o,
4658
- fontWeight: n ? "bold" : "normal",
4672
+ fontSize: n,
4673
+ fontWeight: o ? "bold" : "normal",
4659
4674
  fontStyle: i ? "italic" : "normal",
4660
4675
  underline: a,
4661
4676
  uppercase: r,
@@ -4685,7 +4700,7 @@ class F {
4685
4700
  textbox: Y,
4686
4701
  options: yt(B({}, G), {
4687
4702
  text: e,
4688
- bold: n,
4703
+ bold: o,
4689
4704
  italic: i,
4690
4705
  strikethrough: c,
4691
4706
  align: d,
@@ -4708,13 +4723,13 @@ class F {
4708
4723
  * @param options.withoutSave — не сохранять состояние в историю
4709
4724
  * @param options.skipRender — не вызывать перерисовку канваса
4710
4725
  */
4711
- updateText({ target: t, style: e = {}, withoutSave: s, skipRender: o } = {}) {
4726
+ updateText({ target: t, style: e = {}, withoutSave: s, skipRender: n } = {}) {
4712
4727
  var Nt, Bt, ut, kt, gt, it;
4713
- const n = this._resolveTextObject(t);
4714
- if (!n) return null;
4728
+ const o = this._resolveTextObject(t);
4729
+ if (!o) return null;
4715
4730
  const { historyManager: i } = this.editor, { canvas: a } = this;
4716
4731
  i.suspendHistory();
4717
- const r = F._getSnapshot(n), xt = e, {
4732
+ const r = F._getSnapshot(o), xt = e, {
4718
4733
  text: c,
4719
4734
  fontFamily: d,
4720
4735
  fontSize: l,
@@ -4762,7 +4777,7 @@ class F {
4762
4777
  "radiusTopRight",
4763
4778
  "radiusBottomRight",
4764
4779
  "radiusBottomLeft"
4765
- ]), D = B({}, Z), _ = ao({ textbox: n }), W = _ ? F._expandRangeToFullLines({ textbox: n, range: _ }) : null, G = {}, Y = {}, K = {}, tt = co({ textbox: n, range: _ }), J = !_ || tt, H = !_;
4780
+ ]), D = B({}, Z), _ = rn({ textbox: o }), W = _ ? F._expandRangeToFullLines({ textbox: o, range: _ }) : null, G = {}, Y = {}, K = {}, tt = dn({ textbox: o, range: _ }), J = !_ || tt, H = !_;
4766
4781
  if (d !== void 0 && (W && (Y.fontFamily = d), J && (D.fontFamily = d, H && (K.fontFamily = d))), l !== void 0 && (W && (Y.fontSize = l), J && (D.fontSize = l, H && (K.fontSize = l))), u !== void 0) {
4767
4782
  const X = u ? "bold" : "normal";
4768
4783
  _ && (G.fontWeight = X), J && (D.fontWeight = X, H && (K.fontWeight = X));
@@ -4772,43 +4787,43 @@ class F {
4772
4787
  _ && (G.fontStyle = X), J && (D.fontStyle = X, H && (K.fontStyle = X));
4773
4788
  }
4774
4789
  if (f !== void 0 && (_ && (G.underline = f), J && (D.underline = f, H && (K.underline = f))), m !== void 0 && (_ && (G.linethrough = m), J && (D.linethrough = m, H && (K.linethrough = m))), v !== void 0 && (D.textAlign = v), M !== void 0 && (_ && (G.fill = M), J && (D.fill = M, H && (K.fill = M))), S !== void 0 || y !== void 0) {
4775
- const X = _ ? Ge({ textbox: n, range: _, property: "strokeWidth" }) : void 0, It = _ ? Ge({ textbox: n, range: _, property: "stroke" }) : void 0, Ht = (Bt = (Nt = y != null ? y : X) != null ? Nt : n.strokeWidth) != null ? Bt : 0, mt = Xe({ width: Ht }), Zt = (kt = (ut = S != null ? S : It) != null ? ut : n.stroke) != null ? kt : void 0, Ct = Ve({
4790
+ const X = _ ? Ge({ textbox: o, range: _, property: "strokeWidth" }) : void 0, It = _ ? Ge({ textbox: o, range: _, property: "stroke" }) : void 0, Ht = (Bt = (Nt = y != null ? y : X) != null ? Nt : o.strokeWidth) != null ? Bt : 0, mt = Xe({ width: Ht }), Zt = (kt = (ut = S != null ? S : It) != null ? ut : o.stroke) != null ? kt : void 0, Ct = Ve({
4776
4791
  strokeColor: Zt,
4777
4792
  width: mt
4778
4793
  });
4779
4794
  _ && (G.stroke = Ct, G.strokeWidth = mt), J && (D.stroke = Ct, D.strokeWidth = mt, H && (K.stroke = Ct, K.strokeWidth = mt));
4780
4795
  }
4781
4796
  b !== void 0 && (D.opacity = b), I !== void 0 && (D.backgroundColor = I), j !== void 0 && (D.backgroundOpacity = j), A !== void 0 && (D.paddingTop = A), C !== void 0 && (D.paddingRight = C), w !== void 0 && (D.paddingBottom = w), T !== void 0 && (D.paddingLeft = T), E !== void 0 && (D.radiusTopLeft = E), P !== void 0 && (D.radiusTopRight = P), x !== void 0 && (D.radiusBottomRight = x), N !== void 0 && (D.radiusBottomLeft = N);
4782
- const q = (it = n.textCaseRaw) != null ? it : (gt = n.text) != null ? gt : "", St = !!n.uppercase, st = c !== void 0, lt = st ? c != null ? c : "" : q, pt = p != null ? p : St;
4797
+ const q = (it = o.textCaseRaw) != null ? it : (gt = o.text) != null ? gt : "", St = !!o.uppercase, st = c !== void 0, lt = st ? c != null ? c : "" : q, pt = p != null ? p : St;
4783
4798
  if (st || pt !== St) {
4784
4799
  const X = pt ? ae({ value: lt }) : lt;
4785
- D.text = X, n.textCaseRaw = lt;
4786
- } else n.textCaseRaw === void 0 && (n.textCaseRaw = q);
4787
- n.uppercase = pt, n.set(D);
4800
+ D.text = X, o.textCaseRaw = lt;
4801
+ } else o.textCaseRaw === void 0 && (o.textCaseRaw = q);
4802
+ o.uppercase = pt, o.set(D);
4788
4803
  let ht = !1;
4789
4804
  if (_) {
4790
- const X = ie({ textbox: n, styles: G, range: _ }), It = W ? ie({ textbox: n, styles: Y, range: W }) : !1;
4805
+ const X = ie({ textbox: o, styles: G, range: _ }), It = W ? ie({ textbox: o, styles: Y, range: W }) : !1;
4791
4806
  ht = X || It;
4792
4807
  } else if (Object.keys(K).length) {
4793
- const X = ro({ textbox: n });
4794
- X && (ht = ie({ textbox: n, styles: K, range: X }));
4808
+ const X = cn({ textbox: o });
4809
+ X && (ht = ie({ textbox: o, styles: K, range: X }));
4795
4810
  }
4796
- ht && (n.dirty = !0), (I !== void 0 || j !== void 0 || A !== void 0 || C !== void 0 || w !== void 0 || T !== void 0 || E !== void 0 || P !== void 0 || x !== void 0 || N !== void 0) && (n.dirty = !0), F._roundTextboxDimensions({ textbox: n }) && (n.dirty = !0), n.setCoords(), o || a.requestRenderAll(), i.resumeHistory(), s || i.saveState();
4797
- const Yt = F._getSnapshot(n);
4811
+ ht && (o.dirty = !0), (I !== void 0 || j !== void 0 || A !== void 0 || C !== void 0 || w !== void 0 || T !== void 0 || E !== void 0 || P !== void 0 || x !== void 0 || N !== void 0) && (o.dirty = !0), F._roundTextboxDimensions({ textbox: o }) && (o.dirty = !0), o.setCoords(), n || a.requestRenderAll(), i.resumeHistory(), s || i.saveState();
4812
+ const Yt = F._getSnapshot(o);
4798
4813
  return a.fire("editor:text-updated", {
4799
- textbox: n,
4814
+ textbox: o,
4800
4815
  target: t,
4801
4816
  style: e,
4802
4817
  options: {
4803
4818
  withoutSave: !!s,
4804
- skipRender: !!o
4819
+ skipRender: !!n
4805
4820
  },
4806
4821
  updates: D,
4807
4822
  before: r,
4808
4823
  after: Yt,
4809
4824
  selectionRange: _ != null ? _ : void 0,
4810
4825
  selectionStyles: _ && Object.keys(G).length ? G : void 0
4811
- }), n;
4826
+ }), o;
4812
4827
  }
4813
4828
  /**
4814
4829
  * Уничтожает менеджер и снимает слушатели.
@@ -4821,14 +4836,14 @@ class F {
4821
4836
  * Возвращает активный текст или ищет по id.
4822
4837
  */
4823
4838
  _resolveTextObject(t) {
4824
- if (t instanceof nt) return t;
4839
+ if (t instanceof ot) return t;
4825
4840
  const { canvas: e } = this;
4826
4841
  if (!t) {
4827
4842
  const s = e.getActiveObject();
4828
4843
  return F._isTextbox(s) ? s : null;
4829
4844
  }
4830
4845
  if (typeof t == "string") {
4831
- const s = e.getObjects().find((o) => F._isTextbox(o) && o.id === t);
4846
+ const s = e.getObjects().find((n) => F._isTextbox(n) && n.id === t);
4832
4847
  return s != null ? s : null;
4833
4848
  }
4834
4849
  return null;
@@ -4837,7 +4852,7 @@ class F {
4837
4852
  * Проверяет, является ли объект текстовым блоком редактора.
4838
4853
  */
4839
4854
  static _isTextbox(t) {
4840
- return !!t && t instanceof nt;
4855
+ return !!t && t instanceof ot;
4841
4856
  }
4842
4857
  /**
4843
4858
  * Вешает обработчики событий Fabric для работы с текстом.
@@ -4852,8 +4867,8 @@ class F {
4852
4867
  static _handleTextChanged(t) {
4853
4868
  const { target: e } = t;
4854
4869
  if (!F._isTextbox(e)) return;
4855
- const { text: s = "", uppercase: o } = e, n = !!o, i = s.toLocaleLowerCase();
4856
- if (n) {
4870
+ const { text: s = "", uppercase: n } = e, o = !!n, i = s.toLocaleLowerCase();
4871
+ if (o) {
4857
4872
  const r = ae({ value: i });
4858
4873
  r !== s && e.set({ text: r }), e.textCaseRaw = i;
4859
4874
  } else
@@ -4871,9 +4886,9 @@ class F {
4871
4886
  const { target: e, transform: s } = t;
4872
4887
  if (!F._isTextbox(e)) return;
4873
4888
  const {
4874
- paddingLeft: o = 0,
4875
- paddingRight: n = 0
4876
- } = e, i = o + n;
4889
+ paddingLeft: n = 0,
4890
+ paddingRight: o = 0
4891
+ } = e, i = n + o;
4877
4892
  if (i === 0) return;
4878
4893
  const a = (l = e.width) != null ? l : 0, r = Math.max(0, a - i);
4879
4894
  if (a === r) return;
@@ -4891,15 +4906,15 @@ class F {
4891
4906
  * Возвращает диапазоны символов для каждой строки текста без учёта символов переноса.
4892
4907
  */
4893
4908
  static _getLineRanges({ textbox: t }) {
4894
- var n;
4895
- const e = (n = t.text) != null ? n : "";
4909
+ var o;
4910
+ const e = (o = t.text) != null ? o : "";
4896
4911
  if (!e.length) return [];
4897
4912
  const s = e.split(`
4898
4913
  `);
4899
- let o = 0;
4914
+ let n = 0;
4900
4915
  return s.map((i) => {
4901
- const a = o, r = o + i.length;
4902
- return o = r + 1, { start: a, end: r };
4916
+ const a = n, r = n + i.length;
4917
+ return n = r + 1, { start: a, end: r };
4903
4918
  });
4904
4919
  }
4905
4920
  /**
@@ -4911,19 +4926,19 @@ class F {
4911
4926
  }) {
4912
4927
  const s = F._getLineRanges({ textbox: t });
4913
4928
  if (!s.length) return e;
4914
- let { start: o } = e, { end: n } = e;
4929
+ let { start: n } = e, { end: o } = e;
4915
4930
  return s.forEach(({ start: i, end: a }) => {
4916
- e.end > i && e.start < a && (o = Math.min(o, i), n = Math.max(n, a));
4917
- }), { start: o, end: n };
4931
+ e.end > i && e.start < a && (n = Math.min(n, i), o = Math.max(o, a));
4932
+ }), { start: n, end: o };
4918
4933
  }
4919
4934
  /**
4920
4935
  * Создаёт или возвращает сохранённое состояние для текущего цикла масштабирования текста.
4921
4936
  */
4922
4937
  _ensureScalingState(t) {
4923
- var s, o, n;
4938
+ var s, n, o;
4924
4939
  let e = this.scalingState.get(t);
4925
4940
  if (!e) {
4926
- 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, {
4941
+ const i = (s = t.width) != null ? s : t.calcTextWidth(), a = (n = t.left) != null ? n : 0, r = (o = t.fontSize) != null ? o : 16, { styles: c = {} } = t, {
4927
4942
  paddingTop: d = 0,
4928
4943
  paddingRight: l = 0,
4929
4944
  paddingBottom: u = 0,
@@ -4971,7 +4986,7 @@ class F {
4971
4986
  static _roundTextboxDimensions({
4972
4987
  textbox: t
4973
4988
  }) {
4974
- 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 = F._resolveDimension({
4989
+ const { width: e, height: s, calcTextWidth: n, calcTextHeight: o } = t, i = typeof n == "function" ? n.call(t) : void 0, a = typeof o == "function" ? o.call(t) : void 0, r = F._resolveDimension({
4975
4990
  rawValue: e,
4976
4991
  calculatedValue: i
4977
4992
  }), c = F._resolveDimension({
@@ -4993,8 +5008,8 @@ class F {
4993
5008
  });
4994
5009
  }, {
4995
5010
  id: s,
4996
- text: o,
4997
- textCaseRaw: n,
5011
+ text: n,
5012
+ textCaseRaw: o,
4998
5013
  uppercase: i,
4999
5014
  fontFamily: a,
5000
5015
  fontSize: r,
@@ -5032,8 +5047,8 @@ class F {
5032
5047
  return e({
5033
5048
  snapshot: W,
5034
5049
  entries: {
5035
- text: o,
5036
- textCaseRaw: n,
5050
+ text: n,
5051
+ textCaseRaw: o,
5037
5052
  fontFamily: a,
5038
5053
  fontSize: r,
5039
5054
  fontWeight: c,
@@ -5082,23 +5097,23 @@ const Q = ({
5082
5097
  }) => {
5083
5098
  const s = Q({ value: h });
5084
5099
  return e ? s : s / (t || 1);
5085
- }, lo = ({
5100
+ }, ln = ({
5086
5101
  object: h,
5087
5102
  baseWidth: t,
5088
5103
  baseHeight: e,
5089
5104
  useRelativePositions: s,
5090
- centerKeys: o
5105
+ centerKeys: n
5091
5106
  }) => {
5092
- const n = h;
5093
- if (typeof n[o.x] == "number" && typeof n[o.y] == "number")
5107
+ const o = h;
5108
+ if (typeof o[n.x] == "number" && typeof o[n.y] == "number")
5094
5109
  return {
5095
5110
  x: Qt({
5096
- value: n[o.x],
5111
+ value: o[n.x],
5097
5112
  dimension: t,
5098
5113
  useRelativePositions: s
5099
5114
  }),
5100
5115
  y: Qt({
5101
- value: n[o.y],
5116
+ value: o[n.y],
5102
5117
  dimension: e,
5103
5118
  useRelativePositions: s
5104
5119
  })
@@ -5116,28 +5131,28 @@ const Q = ({
5116
5131
  x: l + g / 2,
5117
5132
  y: u + f / 2
5118
5133
  };
5119
- }, ho = ({
5134
+ }, hn = ({
5120
5135
  normalizedX: h,
5121
5136
  normalizedY: t,
5122
5137
  bounds: e,
5123
5138
  targetSize: s,
5124
- montageArea: o
5139
+ montageArea: n
5125
5140
  }) => {
5126
- const { left: n, top: i, width: a, height: r } = e;
5127
- if (!o) {
5128
- const { width: l, height: u } = s, g = n + h * (l || a), f = i + t * (u || r);
5141
+ const { left: o, top: i, width: a, height: r } = e;
5142
+ if (!n) {
5143
+ const { width: l, height: u } = s, g = o + h * (l || a), f = i + t * (u || r);
5129
5144
  return new et(g, f);
5130
5145
  }
5131
- const c = n + h * a, d = i + t * r;
5146
+ const c = o + h * a, d = i + t * r;
5132
5147
  return new et(c, d);
5133
- }, uo = ({
5148
+ }, un = ({
5134
5149
  object: h,
5135
5150
  montageArea: t,
5136
5151
  bounds: e
5137
5152
  }) => {
5138
5153
  if (!t || !e) return null;
5139
5154
  try {
5140
- 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;
5155
+ const s = h.getCenterPoint(), { left: n, top: o, width: i, height: a } = e, r = s.x - n, c = s.y - o, d = r / i, l = c / a;
5141
5156
  return {
5142
5157
  x: d,
5143
5158
  y: l
@@ -5154,9 +5169,9 @@ const Q = ({
5154
5169
  const t = h.getBoundingRect(!1, !0), {
5155
5170
  left: e = 0,
5156
5171
  top: s = 0,
5157
- width: o = 0,
5158
- height: n = 0
5159
- } = t, i = e + o, a = s + n, r = e + o / 2, c = s + n / 2;
5172
+ width: n = 0,
5173
+ height: o = 0
5174
+ } = t, i = e + n, a = s + o, r = e + n / 2, c = s + o / 2;
5160
5175
  return {
5161
5176
  left: e,
5162
5177
  right: i,
@@ -5168,14 +5183,14 @@ const Q = ({
5168
5183
  } catch (t) {
5169
5184
  return null;
5170
5185
  }
5171
- }, go = ({
5186
+ }, gn = ({
5172
5187
  x1: h,
5173
5188
  y1: t,
5174
5189
  x2: e,
5175
5190
  y2: s
5176
- }) => (Math.atan2(s - t, e - h) * 180 / Math.PI + 360) % 360, fo = (h) => {
5191
+ }) => (Math.atan2(s - t, e - h) * 180 / Math.PI + 360) % 360, fn = (h) => {
5177
5192
  if (!h || typeof h != "object") return null;
5178
- 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) => ({
5193
+ const { type: t, coords: e, colorStops: s } = h, n = Array.isArray(s) ? s : [], o = n[0], i = n[n.length - 1], a = typeof (o == null ? void 0 : o.color) == "string" ? o.color : void 0, r = typeof (i == null ? void 0 : i.color) == "string" ? i.color : a, c = typeof (o == null ? void 0 : o.offset) == "number" ? o.offset * 100 : void 0, d = typeof (i == null ? void 0 : i.offset) == "number" ? i.offset * 100 : void 0, l = n.map((u) => ({
5179
5194
  color: typeof u.color == "string" ? u.color : "#000000",
5180
5195
  offset: typeof u.offset == "number" ? u.offset * 100 : 0
5181
5196
  }));
@@ -5185,7 +5200,7 @@ const Q = ({
5185
5200
  if (typeof u == "number" && typeof g == "number" && typeof f == "number" && typeof p == "number")
5186
5201
  return {
5187
5202
  type: "linear",
5188
- angle: go({ x1: u, y1: g, x2: f, y2: p }),
5203
+ angle: gn({ x1: u, y1: g, x2: f, y2: p }),
5189
5204
  startColor: a,
5190
5205
  endColor: r,
5191
5206
  startPosition: c,
@@ -5222,14 +5237,14 @@ class R {
5222
5237
  templateId: t,
5223
5238
  previewId: e,
5224
5239
  meta: s = {},
5225
- withBackground: o = !1
5240
+ withBackground: n = !1
5226
5241
  } = {}) {
5227
5242
  const {
5228
- canvas: n,
5243
+ canvas: o,
5229
5244
  montageArea: i,
5230
5245
  errorManager: a,
5231
5246
  backgroundManager: r
5232
- } = this.editor, c = n.getActiveObject(), d = R._collectObjects(c), { backgroundObject: l } = r != null ? r : {}, u = o && l ? [l] : [], g = [...d, ...u];
5247
+ } = this.editor, c = o.getActiveObject(), d = R._collectObjects(c), { backgroundObject: l } = r != null ? r : {}, u = n && l ? [l] : [], g = [...d, ...u];
5233
5248
  if (!g.length)
5234
5249
  return a.emitWarning({
5235
5250
  origin: "TemplateManager",
@@ -5267,8 +5282,8 @@ class R {
5267
5282
  data: e
5268
5283
  }) {
5269
5284
  const {
5270
- canvas: o,
5271
- montageArea: n,
5285
+ canvas: n,
5286
+ montageArea: o,
5272
5287
  historyManager: i,
5273
5288
  errorManager: a,
5274
5289
  backgroundManager: r
@@ -5280,7 +5295,7 @@ class R {
5280
5295
  code: bt.TEMPLATE_MANAGER.INVALID_TEMPLATE,
5281
5296
  message: "Шаблон не содержит объектов"
5282
5297
  }), null;
5283
- const u = R._getBounds(n);
5298
+ const u = R._getBounds(o);
5284
5299
  if (!u)
5285
5300
  return a.emitWarning({
5286
5301
  origin: "TemplateManager",
@@ -5288,7 +5303,7 @@ class R {
5288
5303
  code: bt.TEMPLATE_MANAGER.INVALID_TARGET,
5289
5304
  message: "Не удалось определить границы монтажной области"
5290
5305
  }), null;
5291
- const g = R._getMontageSize({ montageArea: n, bounds: u }), f = R._normalizeMeta({ meta: d, fallback: g }), p = R._calculateScale({ meta: f, target: g }), m = !!f.positionsNormalized;
5306
+ const g = R._getMontageSize({ montageArea: o, bounds: u }), f = R._normalizeMeta({ meta: d, fallback: g }), p = R._calculateScale({ meta: f, target: g }), m = !!f.positionsNormalized;
5292
5307
  let v = !1, M = !1;
5293
5308
  i.suspendHistory();
5294
5309
  try {
@@ -5316,13 +5331,13 @@ class R {
5316
5331
  targetSize: g,
5317
5332
  baseWidth: f.baseWidth,
5318
5333
  baseHeight: f.baseHeight,
5319
- montageArea: n,
5334
+ montageArea: o,
5320
5335
  useRelativePositions: m
5321
5336
  }), j.set({
5322
5337
  id: `${j.type}-${V()}`,
5323
5338
  evented: !0
5324
- }), o.add(j), j));
5325
- return !I.length && !M ? null : (v = I.length > 0 || M, I.length && R._activateObjects({ canvas: o, objects: I }), o.requestRenderAll(), o.fire("editor:template-applied", {
5339
+ }), n.add(j), j));
5340
+ return !I.length && !M ? null : (v = I.length > 0 || M, I.length && R._activateObjects({ canvas: n, objects: I }), n.requestRenderAll(), n.fire("editor:template-applied", {
5326
5341
  template: t,
5327
5342
  objects: I,
5328
5343
  bounds: u
@@ -5378,8 +5393,8 @@ class R {
5378
5393
  if (i)
5379
5394
  return R._restoreImageScale({ revived: i, serialized: s }), i;
5380
5395
  }
5381
- const o = yield dt.enlivenObjects([s]), n = o == null ? void 0 : o[0];
5382
- return n ? (R._restoreImageScale({ revived: n, serialized: s }), n) : null;
5396
+ const n = yield dt.enlivenObjects([s]), o = n == null ? void 0 : n[0];
5397
+ return o ? (R._restoreImageScale({ revived: o, serialized: s }), o) : null;
5383
5398
  })))).filter((s) => !!s);
5384
5399
  });
5385
5400
  }
@@ -5392,8 +5407,8 @@ class R {
5392
5407
  }) {
5393
5408
  if ((typeof t.type == "string" ? t.type.toLowerCase() : "") !== "image") return;
5394
5409
  const {
5395
- width: o,
5396
- height: n,
5410
+ width: n,
5411
+ height: o,
5397
5412
  scaleX: i,
5398
5413
  scaleY: a,
5399
5414
  customData: r
@@ -5407,7 +5422,7 @@ class R {
5407
5422
  naturalHeight: 0,
5408
5423
  width: 0,
5409
5424
  height: 0
5410
- }, p = Q({ value: l || g || c.width, fallback: 0 }), m = Q({ value: u || f || c.height, fallback: 0 }), v = Q({ value: o, fallback: p }), M = Q({ value: n, fallback: m }), S = Q({ value: i, fallback: c.scaleX || 1 }), y = Q({ value: a, fallback: c.scaleY || 1 }), b = v * S, I = M * y, j = p > 0, A = m > 0, C = b > 0, w = I > 0, T = R._resolveImageFit({ customData: r }), E = {};
5425
+ }, p = Q({ value: l || g || c.width, fallback: 0 }), m = Q({ value: u || f || c.height, fallback: 0 }), v = Q({ value: n, fallback: p }), M = Q({ value: o, fallback: m }), S = Q({ value: i, fallback: c.scaleX || 1 }), y = Q({ value: a, fallback: c.scaleY || 1 }), b = v * S, I = M * y, j = p > 0, A = m > 0, C = b > 0, w = I > 0, T = R._resolveImageFit({ customData: r }), E = {};
5411
5426
  if (j && (E.width = p), A && (E.height = m), !j || !A) {
5412
5427
  c.set(E);
5413
5428
  return;
@@ -5448,10 +5463,10 @@ class R {
5448
5463
  const e = typeof t.svgMarkup == "string" ? t.svgMarkup : null;
5449
5464
  if (!e) return null;
5450
5465
  try {
5451
- const s = yield ms(e), o = dt.groupSVGElements(s.objects, s.options), n = yield dt.enlivenObjectEnlivables(
5466
+ const s = yield ms(e), n = dt.groupSVGElements(s.objects, s.options), o = yield dt.enlivenObjectEnlivables(
5452
5467
  R._prepareSerializableProps(t)
5453
5468
  );
5454
- return o.set(n), o.setCoords(), o;
5469
+ return n.set(o), n.setCoords(), n;
5455
5470
  } catch (s) {
5456
5471
  return null;
5457
5472
  }
@@ -5480,7 +5495,7 @@ class R {
5480
5495
  const s = e.call(t);
5481
5496
  if (!s) return null;
5482
5497
  if (/<svg[\s>]/i.test(s)) return s;
5483
- const { width: n, height: i } = t.getBoundingRect(!1, !0), a = n || t.width || 0, r = i || t.height || 0;
5498
+ const { width: o, height: i } = t.getBoundingRect(!1, !0), a = o || t.width || 0, r = i || t.height || 0;
5484
5499
  return `
5485
5500
  <svg
5486
5501
  xmlns="http://www.w3.org/2000/svg"
@@ -5501,15 +5516,15 @@ class R {
5501
5516
  object: t,
5502
5517
  scale: e,
5503
5518
  bounds: s,
5504
- targetSize: o,
5505
- baseWidth: n,
5519
+ targetSize: n,
5520
+ baseWidth: o,
5506
5521
  baseHeight: i,
5507
5522
  montageArea: a,
5508
5523
  useRelativePositions: r
5509
5524
  }) {
5510
- const c = t, { x: d, y: l } = lo({
5525
+ const c = t, { x: d, y: l } = ln({
5511
5526
  object: t,
5512
- baseWidth: n,
5527
+ baseWidth: o,
5513
5528
  baseHeight: i,
5514
5529
  useRelativePositions: r,
5515
5530
  centerKeys: {
@@ -5518,17 +5533,17 @@ class R {
5518
5533
  }
5519
5534
  }), { scaleX: u, scaleY: g } = t, f = Q({ value: u, fallback: 1 }), p = Q({ value: g, fallback: 1 }), m = R._getPositioningBounds({
5520
5535
  bounds: s,
5521
- baseWidth: n,
5536
+ baseWidth: o,
5522
5537
  baseHeight: i,
5523
5538
  scale: e,
5524
5539
  useRelativePositions: r,
5525
5540
  anchorX: R._resolveAnchor(c, qt),
5526
5541
  anchorY: R._resolveAnchor(c, ce)
5527
- }), v = ho({
5542
+ }), v = hn({
5528
5543
  normalizedX: d,
5529
5544
  normalizedY: l,
5530
5545
  bounds: m,
5531
- targetSize: o,
5546
+ targetSize: n,
5532
5547
  montageArea: a
5533
5548
  }), M = f * e, S = p * e;
5534
5549
  t.set({
@@ -5544,13 +5559,13 @@ class R {
5544
5559
  bounds: t,
5545
5560
  baseWidth: e,
5546
5561
  baseHeight: s,
5547
- scale: o,
5548
- useRelativePositions: n,
5562
+ scale: n,
5563
+ useRelativePositions: o,
5549
5564
  anchorX: i,
5550
5565
  anchorY: a
5551
5566
  }) {
5552
- if (!n) return t;
5553
- 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);
5567
+ if (!o) return t;
5568
+ const r = (e || t.width) * n, c = (s || t.height) * n, d = t.width - r, l = t.height - c, u = t.left + R._calculateAnchorOffset(i, d), g = t.top + R._calculateAnchorOffset(a, l);
5554
5569
  return {
5555
5570
  left: u,
5556
5571
  top: g,
@@ -5566,11 +5581,11 @@ class R {
5566
5581
  return s === "center" || s === "end" || s === "start" ? s : "start";
5567
5582
  }
5568
5583
  static _detectAnchor({ start: t, end: e }) {
5569
- const s = t <= 0.05, o = e >= 0.95, n = t < 0, i = e > 1, a = e - t, r = Math.max(0, t), c = Math.max(0, 1 - e), d = Math.abs(r - c) <= 0.02;
5570
- if (s && o || n && i)
5584
+ const s = t <= 0.05, n = e >= 0.95, o = t < 0, i = e > 1, a = e - t, r = Math.max(0, t), c = Math.max(0, 1 - e), d = Math.abs(r - c) <= 0.02;
5585
+ if (s && n || o && i)
5571
5586
  return d || a >= 0.9 ? "center" : r <= c ? "start" : "end";
5572
- if (s || n) return "start";
5573
- if (o || i) return "end";
5587
+ if (s || o) return "start";
5588
+ if (n || i) return "end";
5574
5589
  const l = r - c;
5575
5590
  return Math.abs(l) <= 0.1 ? "center" : l < 0 ? "start" : "end";
5576
5591
  }
@@ -5581,9 +5596,9 @@ class R {
5581
5596
  meta: t,
5582
5597
  fallback: e
5583
5598
  }) {
5584
- const { width: s, height: o } = e, r = t || {}, { baseWidth: n = s, baseHeight: i = o } = r, a = vt(r, ["baseWidth", "baseHeight"]);
5599
+ const { width: s, height: n } = e, r = t || {}, { baseWidth: o = s, baseHeight: i = n } = r, a = vt(r, ["baseWidth", "baseHeight"]);
5585
5600
  return B({
5586
- baseWidth: n,
5601
+ baseWidth: o,
5587
5602
  baseHeight: i
5588
5603
  }, a);
5589
5604
  }
@@ -5594,7 +5609,7 @@ class R {
5594
5609
  meta: t,
5595
5610
  target: e
5596
5611
  }) {
5597
- const { width: s, height: o } = e, { baseWidth: n, baseHeight: i } = t, a = s / (n || s || 1), r = o / (i || o || 1);
5612
+ const { width: s, height: n } = e, { baseWidth: o, baseHeight: i } = t, a = s / (o || s || 1), r = n / (i || n || 1);
5598
5613
  return Math.min(a, r);
5599
5614
  }
5600
5615
  /**
@@ -5620,21 +5635,21 @@ class R {
5620
5635
  baseWidth: e
5621
5636
  }) {
5622
5637
  var Z, D;
5623
- if (!(t instanceof nt)) return;
5638
+ if (!(t instanceof ot)) return;
5624
5639
  const s = typeof t.text == "string" ? t.text : "";
5625
5640
  if (!s) return;
5626
- const o = Q({
5641
+ const n = Q({
5627
5642
  value: (D = (Z = this.editor) == null ? void 0 : Z.montageArea) == null ? void 0 : D.width,
5628
5643
  fallback: 0
5629
5644
  }), {
5630
- width: n = 0,
5645
+ width: o = 0,
5631
5646
  scaleX: i = 1,
5632
5647
  strokeWidth: a = 0
5633
- } = t, r = Q({ value: e, fallback: 0 }), c = t, d = Q({ value: c.paddingLeft, fallback: 0 }), l = Q({ value: c.paddingRight, fallback: 0 }), u = Q({ value: i, fallback: 1 }), g = Q({ value: a, fallback: 0 }) * u, f = Q({ value: n, fallback: 0 }), p = f * u, m = d * u, v = l * u, M = p + m + v + g;
5634
- if (!o || !f || !r) return;
5648
+ } = t, r = Q({ value: e, fallback: 0 }), c = t, d = Q({ value: c.paddingLeft, fallback: 0 }), l = Q({ value: c.paddingRight, fallback: 0 }), u = Q({ value: i, fallback: 1 }), g = Q({ value: a, fallback: 0 }) * u, f = Q({ value: o, fallback: 0 }), p = f * u, m = d * u, v = l * u, M = p + m + v + g;
5649
+ if (!n || !f || !r) return;
5635
5650
  t.setCoords();
5636
5651
  const S = t, y = S[Pt], b = typeof y == "number" ? y : null, I = R._resolveAnchor(S, qt), j = M / r, A = b !== null ? b - j / 2 : null, C = b !== null ? b + j / 2 : null, w = t.getCenterPoint();
5637
- t.set("width", o), t.initDimensions();
5652
+ t.set("width", n), t.initDimensions();
5638
5653
  const T = R._getLongestLineWidth({
5639
5654
  textbox: t,
5640
5655
  text: s
@@ -5653,14 +5668,14 @@ class R {
5653
5668
  }) {
5654
5669
  const {
5655
5670
  textLines: s
5656
- } = t, o = Array.isArray(s) && s.length > 0 ? s.length : Math.max(e.split(`
5671
+ } = t, n = Array.isArray(s) && s.length > 0 ? s.length : Math.max(e.split(`
5657
5672
  `).length, 1);
5658
- let n = 0;
5659
- for (let i = 0; i < o; i += 1) {
5673
+ let o = 0;
5674
+ for (let i = 0; i < n; i += 1) {
5660
5675
  const a = t.getLineWidth(i);
5661
- a > n && (n = a);
5676
+ a > o && (o = a);
5662
5677
  }
5663
- return n;
5678
+ return o;
5664
5679
  }
5665
5680
  /**
5666
5681
  * Сериализует объект относительно монтажной области.
@@ -5669,8 +5684,8 @@ class R {
5669
5684
  object: t,
5670
5685
  bounds: e,
5671
5686
  baseWidth: s,
5672
- baseHeight: o,
5673
- montageArea: n
5687
+ baseHeight: n,
5688
+ montageArea: o
5674
5689
  }) {
5675
5690
  const i = t.toDatalessObject([...es]);
5676
5691
  if (R._isSvgObject(t)) {
@@ -5683,9 +5698,9 @@ class R {
5683
5698
  top: r,
5684
5699
  width: c,
5685
5700
  height: d
5686
- } = e, l = t.getBoundingRect(!1, !0), u = s || c || 1, g = o || d || 1, f = uo({
5701
+ } = e, l = t.getBoundingRect(!1, !0), u = s || c || 1, g = n || d || 1, f = un({
5687
5702
  object: t,
5688
- montageArea: n,
5703
+ montageArea: o,
5689
5704
  bounds: e
5690
5705
  }), p = f != null ? f : (() => {
5691
5706
  const y = t.getCenterPoint();
@@ -5708,35 +5723,37 @@ class R {
5708
5723
  * Делит список объектов на фон и контент по id === 'background'.
5709
5724
  */
5710
5725
  static _extractBackgroundObject(t) {
5711
- const e = t.findIndex((n) => n.id === "background");
5726
+ const e = t.findIndex((o) => o.id === "background");
5712
5727
  if (e === -1)
5713
5728
  return { backgroundObject: null, contentObjects: t };
5714
- const s = t[e], o = t.filter((n, i) => i !== e);
5715
- return { backgroundObject: s, contentObjects: o };
5729
+ const s = t[e], n = t.filter((o, i) => i !== e);
5730
+ return { backgroundObject: s, contentObjects: n };
5716
5731
  }
5717
5732
  /**
5718
5733
  * Применяет фоновый объект шаблона к текущему холсту через BackgroundManager.
5719
5734
  */
5720
- static _applyBackgroundFromObject(o) {
5735
+ static _applyBackgroundFromObject(n) {
5721
5736
  return k(this, arguments, function* ({
5722
5737
  backgroundObject: t,
5723
5738
  backgroundManager: e,
5724
5739
  errorManager: s
5725
5740
  }) {
5726
5741
  try {
5727
- const { fill: n, customData: i } = t, { backgroundType: a } = t, r = R._cloneCustomData(i);
5728
- if (a === "color" && typeof n == "string")
5742
+ const { fill: o, customData: i } = t, { backgroundType: a } = t, r = R._cloneCustomData(i);
5743
+ if (a === "color" && typeof o == "string")
5729
5744
  return e.setColorBackground({
5730
- color: n,
5745
+ color: o,
5731
5746
  customData: r,
5747
+ fromTemplate: !0,
5732
5748
  withoutSave: !0
5733
5749
  }), !0;
5734
5750
  if (a === "gradient") {
5735
- const c = fo(n);
5751
+ const c = fn(o);
5736
5752
  if (c)
5737
5753
  return e.setGradientBackground({
5738
5754
  gradient: c,
5739
5755
  customData: r,
5756
+ fromTemplate: !0,
5740
5757
  withoutSave: !0
5741
5758
  }), !0;
5742
5759
  }
@@ -5746,16 +5763,17 @@ class R {
5746
5763
  return yield e.setImageBackground({
5747
5764
  imageSource: c,
5748
5765
  customData: r,
5766
+ fromTemplate: !0,
5749
5767
  withoutSave: !0
5750
5768
  }), !0;
5751
5769
  }
5752
- } catch (n) {
5770
+ } catch (o) {
5753
5771
  s.emitWarning({
5754
5772
  origin: "TemplateManager",
5755
5773
  method: "applyTemplate",
5756
5774
  code: bt.TEMPLATE_MANAGER.APPLY_FAILED,
5757
5775
  message: "Не удалось применить фон из шаблона",
5758
- data: n
5776
+ data: o
5759
5777
  });
5760
5778
  }
5761
5779
  return !1;
@@ -5768,14 +5786,14 @@ class R {
5768
5786
  montageArea: t,
5769
5787
  bounds: e
5770
5788
  }) {
5771
- var n, i;
5772
- const s = (e == null ? void 0 : e.width) || 0, o = (e == null ? void 0 : e.height) || 0;
5789
+ var o, i;
5790
+ const s = (e == null ? void 0 : e.width) || 0, n = (e == null ? void 0 : e.height) || 0;
5773
5791
  return t ? {
5774
- width: ((n = t.getScaledWidth) == null ? void 0 : n.call(t)) || t.width || s,
5775
- height: ((i = t.getScaledHeight) == null ? void 0 : i.call(t)) || t.height || o
5792
+ width: ((o = t.getScaledWidth) == null ? void 0 : o.call(t)) || t.width || s,
5793
+ height: ((i = t.getScaledHeight) == null ? void 0 : i.call(t)) || t.height || n
5776
5794
  } : {
5777
5795
  width: s,
5778
- height: o
5796
+ height: n
5779
5797
  };
5780
5798
  }
5781
5799
  /**
@@ -5791,13 +5809,13 @@ class R {
5791
5809
  static _getImageSource(t) {
5792
5810
  const e = t;
5793
5811
  if ("getSrc" in t && typeof e.getSrc == "function") {
5794
- const o = e.getSrc();
5795
- if (o) return o;
5812
+ const n = e.getSrc();
5813
+ if (n) return n;
5796
5814
  }
5797
5815
  if ("getElement" in t && typeof e.getElement == "function") {
5798
- const o = e.getElement();
5799
- if (o instanceof HTMLImageElement)
5800
- return o.currentSrc || o.src || null;
5816
+ const n = e.getElement();
5817
+ if (n instanceof HTMLImageElement)
5818
+ return n.currentSrc || n.src || null;
5801
5819
  }
5802
5820
  const s = t;
5803
5821
  return typeof s.src == "string" ? s.src : null;
@@ -5812,29 +5830,29 @@ class R {
5812
5830
  return dt.enlivenObjectEnlivables(t);
5813
5831
  }
5814
5832
  }
5815
- const po = 5, ss = "#3D8BF4", fe = 1, Jt = 1, Ke = ({
5833
+ const pn = 5, ss = "#3D8BF4", fe = 1, Jt = 1, Ke = ({
5816
5834
  anchors: h,
5817
5835
  positions: t,
5818
5836
  threshold: e
5819
5837
  }) => {
5820
- let s = 0, o = e + 1, n = null;
5838
+ let s = 0, n = e + 1, o = null;
5821
5839
  for (const i of t)
5822
5840
  for (const a of h) {
5823
5841
  const r = Math.abs(a - i);
5824
- r > e || r >= o || (s = a - i, o = r, n = a);
5842
+ r > e || r >= n || (s = a - i, n = r, o = a);
5825
5843
  }
5826
5844
  return {
5827
5845
  delta: s,
5828
- guidePosition: n
5846
+ guidePosition: o
5829
5847
  };
5830
- }, mo = ({
5848
+ }, mn = ({
5831
5849
  activeBounds: h,
5832
5850
  threshold: t,
5833
5851
  anchors: e
5834
5852
  }) => {
5835
- const { left: s, right: o, centerX: n, top: i, bottom: a, centerY: r } = h, c = Ke({
5853
+ const { left: s, right: n, centerX: o, top: i, bottom: a, centerY: r } = h, c = Ke({
5836
5854
  anchors: e.vertical,
5837
- positions: [s, n, o],
5855
+ positions: [s, o, n],
5838
5856
  threshold: t
5839
5857
  }), d = Ke({
5840
5858
  anchors: e.horizontal,
@@ -5852,27 +5870,27 @@ const po = 5, ss = "#3D8BF4", fe = 1, Jt = 1, Ke = ({
5852
5870
  deltaY: d.delta,
5853
5871
  guides: l
5854
5872
  };
5855
- }, os = ({
5873
+ }, ns = ({
5856
5874
  activeBounds: h,
5857
5875
  aligned: t,
5858
5876
  threshold: e,
5859
5877
  patterns: s,
5860
- type: o
5878
+ type: n
5861
5879
  }) => {
5862
5880
  if (!t.length || !s.length) return [];
5863
5881
  const {
5864
- top: n,
5882
+ top: o,
5865
5883
  bottom: i,
5866
5884
  left: a,
5867
5885
  right: r
5868
5886
  } = h, c = [];
5869
5887
  for (const d of s)
5870
5888
  for (const l of t)
5871
- if (o === "vertical") {
5872
- const u = n - l.bottom, g = Math.abs(u - d.distance);
5889
+ if (n === "vertical") {
5890
+ const u = o - l.bottom, g = Math.abs(u - d.distance);
5873
5891
  if (g <= e) {
5874
5892
  const m = d.distance - u, v = {
5875
- type: o,
5893
+ type: n,
5876
5894
  axis: d.axis,
5877
5895
  refStart: d.start,
5878
5896
  refEnd: d.end,
@@ -5885,7 +5903,7 @@ const po = 5, ss = "#3D8BF4", fe = 1, Jt = 1, Ke = ({
5885
5903
  const f = l.top - i, p = Math.abs(f - d.distance);
5886
5904
  if (p <= e) {
5887
5905
  const m = d.distance - f, v = {
5888
- type: o,
5906
+ type: n,
5889
5907
  axis: d.axis,
5890
5908
  refStart: d.start,
5891
5909
  refEnd: d.end,
@@ -5899,7 +5917,7 @@ const po = 5, ss = "#3D8BF4", fe = 1, Jt = 1, Ke = ({
5899
5917
  const u = a - l.right, g = Math.abs(u - d.distance);
5900
5918
  if (g <= e) {
5901
5919
  const m = d.distance - u, v = {
5902
- type: o,
5920
+ type: n,
5903
5921
  axis: d.axis,
5904
5922
  refStart: d.start,
5905
5923
  refEnd: d.end,
@@ -5912,7 +5930,7 @@ const po = 5, ss = "#3D8BF4", fe = 1, Jt = 1, Ke = ({
5912
5930
  const f = l.left - r, p = Math.abs(f - d.distance);
5913
5931
  if (p <= e) {
5914
5932
  const m = d.distance - f, v = {
5915
- type: o,
5933
+ type: n,
5916
5934
  axis: d.axis,
5917
5935
  refStart: d.start,
5918
5936
  refEnd: d.end,
@@ -5924,15 +5942,15 @@ const po = 5, ss = "#3D8BF4", fe = 1, Jt = 1, Ke = ({
5924
5942
  }
5925
5943
  }
5926
5944
  return c;
5927
- }, yo = ({
5945
+ }, yn = ({
5928
5946
  activeBounds: h,
5929
5947
  candidates: t,
5930
5948
  threshold: e,
5931
5949
  patterns: s
5932
5950
  }) => {
5933
5951
  const {
5934
- centerX: o,
5935
- top: n,
5952
+ centerX: n,
5953
+ top: o,
5936
5954
  bottom: i,
5937
5955
  left: a,
5938
5956
  right: r
@@ -5947,13 +5965,13 @@ const po = 5, ss = "#3D8BF4", fe = 1, Jt = 1, Ke = ({
5947
5965
  const l = d.findIndex((y) => y.isActive);
5948
5966
  if (l === -1)
5949
5967
  return { delta: 0, guide: null };
5950
- const u = d[l - 1], g = d[l - 2], f = d[l + 1], p = d[l + 2], m = [], v = i - n;
5968
+ const u = d[l - 1], g = d[l - 2], f = d[l + 1], p = d[l + 2], m = [], v = i - o;
5951
5969
  if (u && g) {
5952
- const { bounds: y } = u, { bounds: b } = g, I = y.top - b.bottom, j = n - y.bottom, A = Math.abs(j - I);
5970
+ const { bounds: y } = u, { bounds: b } = g, I = y.top - b.bottom, j = o - y.bottom, A = Math.abs(j - I);
5953
5971
  if (A <= e) {
5954
- const C = I - j, w = n + C, T = {
5972
+ const C = I - j, w = o + C, T = {
5955
5973
  type: "vertical",
5956
- axis: o,
5974
+ axis: n,
5957
5975
  refStart: b.bottom,
5958
5976
  refEnd: y.top,
5959
5977
  activeStart: y.bottom,
@@ -5968,7 +5986,7 @@ const po = 5, ss = "#3D8BF4", fe = 1, Jt = 1, Ke = ({
5968
5986
  if (A <= e) {
5969
5987
  const C = j - I, w = i + C, T = {
5970
5988
  type: "vertical",
5971
- axis: o,
5989
+ axis: n,
5972
5990
  refStart: y.bottom,
5973
5991
  refEnd: b.top,
5974
5992
  activeStart: w,
@@ -5981,11 +5999,11 @@ const po = 5, ss = "#3D8BF4", fe = 1, Jt = 1, Ke = ({
5981
5999
  if (u && f) {
5982
6000
  const { bounds: y } = u, { bounds: b } = f, j = b.top - y.bottom - v;
5983
6001
  if (j >= 0) {
5984
- const A = j / 2, C = n - y.bottom, w = b.top - i, T = Math.abs(C - A), E = Math.abs(w - A), P = Math.max(T, E);
6002
+ const A = j / 2, C = o - y.bottom, w = b.top - i, T = Math.abs(C - A), E = Math.abs(w - A), P = Math.max(T, E);
5985
6003
  if (P <= e) {
5986
6004
  const x = A - C, N = i + x, Z = {
5987
6005
  type: "vertical",
5988
- axis: o,
6006
+ axis: n,
5989
6007
  refStart: y.bottom,
5990
6008
  refEnd: y.bottom + A,
5991
6009
  activeStart: N,
@@ -5996,7 +6014,7 @@ const po = 5, ss = "#3D8BF4", fe = 1, Jt = 1, Ke = ({
5996
6014
  }
5997
6015
  }
5998
6016
  }
5999
- const M = os({
6017
+ const M = ns({
6000
6018
  activeBounds: h,
6001
6019
  aligned: c,
6002
6020
  threshold: e,
@@ -6010,15 +6028,15 @@ const po = 5, ss = "#3D8BF4", fe = 1, Jt = 1, Ke = ({
6010
6028
  delta: S.delta,
6011
6029
  guide: S.guide
6012
6030
  };
6013
- }, vo = ({
6031
+ }, vn = ({
6014
6032
  activeBounds: h,
6015
6033
  candidates: t,
6016
6034
  threshold: e,
6017
6035
  patterns: s
6018
6036
  }) => {
6019
6037
  const {
6020
- centerY: o,
6021
- left: n,
6038
+ centerY: n,
6039
+ left: o,
6022
6040
  right: i,
6023
6041
  top: a,
6024
6042
  bottom: r
@@ -6033,13 +6051,13 @@ const po = 5, ss = "#3D8BF4", fe = 1, Jt = 1, Ke = ({
6033
6051
  const l = d.findIndex((y) => y.isActive);
6034
6052
  if (l === -1)
6035
6053
  return { delta: 0, guide: null };
6036
- const u = d[l - 1], g = d[l - 2], f = d[l + 1], p = d[l + 2], m = [], v = i - n;
6054
+ const u = d[l - 1], g = d[l - 2], f = d[l + 1], p = d[l + 2], m = [], v = i - o;
6037
6055
  if (u && g) {
6038
- const { bounds: y } = u, { bounds: b } = g, I = y.left - b.right, j = n - y.right, A = Math.abs(j - I);
6056
+ const { bounds: y } = u, { bounds: b } = g, I = y.left - b.right, j = o - y.right, A = Math.abs(j - I);
6039
6057
  if (A <= e) {
6040
- const C = I - j, w = n + C, T = {
6058
+ const C = I - j, w = o + C, T = {
6041
6059
  type: "horizontal",
6042
- axis: o,
6060
+ axis: n,
6043
6061
  refStart: b.right,
6044
6062
  refEnd: y.left,
6045
6063
  activeStart: y.right,
@@ -6054,7 +6072,7 @@ const po = 5, ss = "#3D8BF4", fe = 1, Jt = 1, Ke = ({
6054
6072
  if (A <= e) {
6055
6073
  const C = j - I, w = i + C, T = {
6056
6074
  type: "horizontal",
6057
- axis: o,
6075
+ axis: n,
6058
6076
  refStart: y.right,
6059
6077
  refEnd: b.left,
6060
6078
  activeStart: w,
@@ -6067,11 +6085,11 @@ const po = 5, ss = "#3D8BF4", fe = 1, Jt = 1, Ke = ({
6067
6085
  if (u && f) {
6068
6086
  const { bounds: y } = u, { bounds: b } = f, j = b.left - y.right - v;
6069
6087
  if (j >= 0) {
6070
- const A = j / 2, C = n - y.right, w = b.left - i, T = Math.abs(C - A), E = Math.abs(w - A), P = Math.max(T, E);
6088
+ const A = j / 2, C = o - y.right, w = b.left - i, T = Math.abs(C - A), E = Math.abs(w - A), P = Math.max(T, E);
6071
6089
  if (P <= e) {
6072
6090
  const x = A - C, N = i + x, Z = {
6073
6091
  type: "horizontal",
6074
- axis: o,
6092
+ axis: n,
6075
6093
  refStart: y.right,
6076
6094
  refEnd: y.right + A,
6077
6095
  activeStart: N,
@@ -6082,7 +6100,7 @@ const po = 5, ss = "#3D8BF4", fe = 1, Jt = 1, Ke = ({
6082
6100
  }
6083
6101
  }
6084
6102
  }
6085
- const M = os({
6103
+ const M = ns({
6086
6104
  activeBounds: h,
6087
6105
  aligned: c,
6088
6106
  threshold: e,
@@ -6096,45 +6114,45 @@ const po = 5, ss = "#3D8BF4", fe = 1, Jt = 1, Ke = ({
6096
6114
  delta: S.delta,
6097
6115
  guide: S.guide
6098
6116
  };
6099
- }, bo = ({
6117
+ }, bn = ({
6100
6118
  activeBounds: h,
6101
6119
  candidates: t,
6102
6120
  threshold: e,
6103
6121
  spacingPatterns: s
6104
6122
  }) => {
6105
- const o = yo({
6123
+ const n = yn({
6106
6124
  activeBounds: h,
6107
6125
  candidates: t,
6108
6126
  threshold: e,
6109
6127
  patterns: s.vertical
6110
- }), n = vo({
6128
+ }), o = vn({
6111
6129
  activeBounds: h,
6112
6130
  candidates: t,
6113
6131
  threshold: e,
6114
6132
  patterns: s.horizontal
6115
6133
  }), i = [];
6116
- return o.guide && i.push(o.guide), n.guide && i.push(n.guide), {
6117
- deltaX: n.delta,
6118
- deltaY: o.delta,
6134
+ return n.guide && i.push(n.guide), o.guide && i.push(o.guide), {
6135
+ deltaX: o.delta,
6136
+ deltaY: n.delta,
6119
6137
  guides: i
6120
6138
  };
6121
- }, Mo = ({
6139
+ }, Mn = ({
6122
6140
  context: h,
6123
6141
  x: t,
6124
6142
  y: e,
6125
6143
  width: s,
6126
- height: o,
6127
- radius: n
6144
+ height: n,
6145
+ radius: o
6128
6146
  }) => {
6129
- const i = Math.min(n, s / 2, o / 2);
6130
- 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();
6147
+ const i = Math.min(o, s / 2, n / 2);
6148
+ 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 + n - i), h.quadraticCurveTo(t + s, e + n, t + s - i, e + n), h.lineTo(t + i, e + n), h.quadraticCurveTo(t, e + n, t, e + n - i), h.lineTo(t, e + i), h.quadraticCurveTo(t, e, t + i, e), h.closePath();
6131
6149
  }, pe = ({
6132
6150
  context: h,
6133
6151
  type: t,
6134
6152
  axis: e,
6135
6153
  start: s,
6136
- end: o,
6137
- text: n,
6154
+ end: n,
6155
+ text: o,
6138
6156
  zoom: i,
6139
6157
  color: a,
6140
6158
  textColor: r = "#ffffff",
@@ -6145,38 +6163,38 @@ const po = 5, ss = "#3D8BF4", fe = 1, Jt = 1, Ke = ({
6145
6163
  offsetAlongAxis: g = 0,
6146
6164
  offsetPerpendicular: f = 0
6147
6165
  }) => {
6148
- const p = i || 1, m = 12 / p, v = l / p, M = u / p, S = (s + o) / 2 + g, y = t === "vertical" ? e + f : S, b = t === "vertical" ? S : e + f;
6166
+ const p = i || 1, m = 12 / p, v = l / p, M = u / p, S = (s + n) / 2 + g, y = t === "vertical" ? e + f : S, b = t === "vertical" ? S : e + f;
6149
6167
  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";
6150
- const j = h.measureText(n).width + v * 2, A = m + v * 2, C = y - j / 2, w = b - A / 2;
6151
- h.beginPath(), Mo({
6168
+ const j = h.measureText(o).width + v * 2, A = m + v * 2, C = y - j / 2, w = b - A / 2;
6169
+ h.beginPath(), Mn({
6152
6170
  context: h,
6153
6171
  x: C,
6154
6172
  y: w,
6155
6173
  width: j,
6156
6174
  height: A,
6157
6175
  radius: M
6158
- }), h.fill(), h.fillStyle = r, h.fillText(n, y, b), h.restore();
6159
- }, wo = ({
6176
+ }), h.fill(), h.fillStyle = r, h.fillText(o, y, b), h.restore();
6177
+ }, wn = ({
6160
6178
  context: h,
6161
6179
  guide: t,
6162
6180
  zoom: e
6163
6181
  }) => {
6164
6182
  const {
6165
6183
  type: s,
6166
- axis: o,
6167
- refStart: n,
6184
+ axis: n,
6185
+ refStart: o,
6168
6186
  refEnd: i,
6169
6187
  activeStart: a,
6170
6188
  activeEnd: r,
6171
6189
  distance: c
6172
6190
  } = t, d = Math.round(c).toString();
6173
- 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();
6191
+ h.beginPath(), s === "vertical" ? (h.moveTo(n, o), h.lineTo(n, i), h.moveTo(n, a), h.lineTo(n, r)) : (h.moveTo(o, n), h.lineTo(i, n), h.moveTo(a, n), h.lineTo(r, n)), h.stroke();
6174
6192
  const l = ss;
6175
6193
  pe({
6176
6194
  context: h,
6177
6195
  type: s,
6178
- axis: o,
6179
- start: n,
6196
+ axis: n,
6197
+ start: o,
6180
6198
  end: i,
6181
6199
  text: d,
6182
6200
  zoom: e,
@@ -6185,7 +6203,7 @@ const po = 5, ss = "#3D8BF4", fe = 1, Jt = 1, Ke = ({
6185
6203
  }), pe({
6186
6204
  context: h,
6187
6205
  type: s,
6188
- axis: o,
6206
+ axis: n,
6189
6207
  start: a,
6190
6208
  end: r,
6191
6209
  text: d,
@@ -6200,31 +6218,31 @@ const po = 5, ss = "#3D8BF4", fe = 1, Jt = 1, Ke = ({
6200
6218
  const {
6201
6219
  left: e,
6202
6220
  right: s,
6203
- centerX: o,
6204
- top: n,
6221
+ centerX: n,
6222
+ top: o,
6205
6223
  bottom: i,
6206
6224
  centerY: a
6207
6225
  } = t;
6208
- h.vertical.push(e, o, s), h.horizontal.push(n, a, i);
6226
+ h.vertical.push(e, n, s), h.horizontal.push(o, a, i);
6209
6227
  }, qe = ({
6210
6228
  bounds: h,
6211
6229
  type: t,
6212
6230
  primaryStart: e,
6213
6231
  primaryEnd: s
6214
6232
  }) => {
6215
- const o = [], n = e === "top" ? "left" : "top", i = s === "bottom" ? "right" : "bottom", a = [...h].sort((r, c) => r[e] - c[e]);
6233
+ const n = [], o = e === "top" ? "left" : "top", i = s === "bottom" ? "right" : "bottom", a = [...h].sort((r, c) => r[e] - c[e]);
6216
6234
  for (let r = 0; r < a.length; r += 1) {
6217
6235
  const c = a[r];
6218
6236
  let d = null, l = Number.POSITIVE_INFINITY;
6219
6237
  for (let p = r + 1; p < a.length; p += 1) {
6220
6238
  const m = a[p];
6221
- if (Math.min(c[i], m[i]) - Math.max(c[n], m[n]) < 0) continue;
6239
+ if (Math.min(c[i], m[i]) - Math.max(c[o], m[o]) < 0) continue;
6222
6240
  const M = m[e] - c[s];
6223
6241
  M < 0 || M < l && (l = M, d = m);
6224
6242
  }
6225
6243
  if (!d || l === Number.POSITIVE_INFINITY) continue;
6226
- const u = Math.max(c[n], d[n]), g = Math.min(c[i], d[i]), f = (u + g) / 2;
6227
- o.push({
6244
+ const u = Math.max(c[o], d[o]), g = Math.min(c[i], d[i]), f = (u + g) / 2;
6245
+ n.push({
6228
6246
  type: t,
6229
6247
  axis: f,
6230
6248
  start: c[s],
@@ -6232,8 +6250,8 @@ const po = 5, ss = "#3D8BF4", fe = 1, Jt = 1, Ke = ({
6232
6250
  distance: d[e] - c[s]
6233
6251
  });
6234
6252
  }
6235
- return o;
6236
- }, So = ({
6253
+ return n;
6254
+ }, Sn = ({
6237
6255
  bounds: h
6238
6256
  }) => {
6239
6257
  const t = qe({
@@ -6248,7 +6266,7 @@ const po = 5, ss = "#3D8BF4", fe = 1, Jt = 1, Ke = ({
6248
6266
  primaryEnd: "right"
6249
6267
  });
6250
6268
  return { vertical: t, horizontal: e };
6251
- }, Ao = ["montage-area", "background", "interaction-blocker"], ns = ({
6269
+ }, An = ["montage-area", "background", "interaction-blocker"], os = ({
6252
6270
  activeObject: h
6253
6271
  }) => {
6254
6272
  const t = /* @__PURE__ */ new Set();
@@ -6256,15 +6274,15 @@ const po = 5, ss = "#3D8BF4", fe = 1, Jt = 1, Ke = ({
6256
6274
  }, is = ({
6257
6275
  object: h,
6258
6276
  excluded: t,
6259
- ignoredIds: e = Ao
6277
+ ignoredIds: e = An
6260
6278
  }) => {
6261
6279
  if (t.has(h)) return !0;
6262
6280
  const { visible: s = !0 } = h;
6263
6281
  if (!s) return !0;
6264
- const { id: o } = h;
6265
- return !!(o && e.includes(o));
6282
+ const { id: n } = h;
6283
+ return !!(n && e.includes(n));
6266
6284
  };
6267
- class jo {
6285
+ class jn {
6268
6286
  /**
6269
6287
  * Создаёт менеджер прилипания и инициализирует слушатели событий.
6270
6288
  */
@@ -6322,13 +6340,13 @@ class jo {
6322
6340
  return;
6323
6341
  }
6324
6342
  !this.anchors.vertical.length && !this.anchors.horizontal.length && this._cacheAnchors({ activeObject: e });
6325
- let n = ft({ object: e });
6326
- if (!n) {
6343
+ let o = ft({ object: e });
6344
+ if (!o) {
6327
6345
  this._clearGuides();
6328
6346
  return;
6329
6347
  }
6330
- const { canvas: i } = this, a = i.getZoom() || 1, r = po / a, c = mo({
6331
- activeBounds: n,
6348
+ const { canvas: i } = this, a = i.getZoom() || 1, r = pn / a, c = mn({
6349
+ activeBounds: o,
6332
6350
  threshold: r,
6333
6351
  anchors: this.anchors
6334
6352
  }), { deltaX: d, deltaY: l, guides: u } = c;
@@ -6337,10 +6355,10 @@ class jo {
6337
6355
  e.set({
6338
6356
  left: v + d,
6339
6357
  top: M + l
6340
- }), e.setCoords(), n = (p = ft({ object: e })) != null ? p : n;
6358
+ }), e.setCoords(), o = (p = ft({ object: e })) != null ? p : o;
6341
6359
  }
6342
- const g = this.cachedTargetBounds.length ? this.cachedTargetBounds : this._collectTargets({ activeObject: e }).map((v) => ft({ object: v })).filter((v) => !!v), f = bo({
6343
- activeBounds: n,
6360
+ const g = this.cachedTargetBounds.length ? this.cachedTargetBounds : this._collectTargets({ activeObject: e }).map((v) => ft({ object: v })).filter((v) => !!v), f = bn({
6361
+ activeBounds: o,
6344
6362
  candidates: g,
6345
6363
  threshold: r,
6346
6364
  spacingPatterns: this.spacingPatterns
@@ -6350,7 +6368,7 @@ class jo {
6350
6368
  e.set({
6351
6369
  left: v + f.deltaX,
6352
6370
  top: M + f.deltaY
6353
- }), e.setCoords(), n = (m = ft({ object: e })) != null ? m : n;
6371
+ }), e.setCoords(), o = (m = ft({ object: e })) != null ? m : o;
6354
6372
  }
6355
6373
  this._applyGuides({
6356
6374
  guides: u,
@@ -6377,12 +6395,12 @@ class jo {
6377
6395
  if (!this.activeGuides.length && !this.activeSpacingGuides.length) return;
6378
6396
  const { canvas: t, guideBounds: e } = this, s = t.getSelectionContext();
6379
6397
  if (!s) return;
6380
- const o = e != null ? e : this._calculateViewportBounds(), { left: n, right: i, top: a, bottom: r } = o, { viewportTransform: c } = t, d = t.getZoom() || 1;
6398
+ const n = e != null ? e : this._calculateViewportBounds(), { left: o, right: i, top: a, bottom: r } = n, { viewportTransform: c } = t, d = t.getZoom() || 1;
6381
6399
  s.save(), Array.isArray(c) && s.transform(...c), s.lineWidth = fe / d, s.strokeStyle = ss, s.setLineDash([4, 4]);
6382
6400
  for (const l of this.activeGuides)
6383
- 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();
6401
+ s.beginPath(), l.type === "vertical" ? (s.moveTo(l.position, a), s.lineTo(l.position, r)) : (s.moveTo(o, l.position), s.lineTo(i, l.position)), s.stroke();
6384
6402
  for (const l of this.activeSpacingGuides)
6385
- wo({
6403
+ wn({
6386
6404
  context: s,
6387
6405
  guide: l,
6388
6406
  zoom: d
@@ -6418,22 +6436,22 @@ class jo {
6418
6436
  * Применяет шаг перемещения, округляя координаты объекта к сетке MOVE_SNAP_STEP.
6419
6437
  */
6420
6438
  _applyMovementStep({ target: t }) {
6421
- const { left: e = 0, top: s = 0 } = t, o = Math.round(e / Jt) * Jt, n = Math.round(s / Jt) * Jt;
6422
- o === e && n === s || (t.set({
6423
- left: o,
6424
- top: n
6439
+ const { left: e = 0, top: s = 0 } = t, n = Math.round(e / Jt) * Jt, o = Math.round(s / Jt) * Jt;
6440
+ n === e && o === s || (t.set({
6441
+ left: n,
6442
+ top: o
6425
6443
  }), t.setCoords());
6426
6444
  }
6427
6445
  /**
6428
6446
  * Сохраняет линии для прилипания от всех доступных объектов и монтажной области.
6429
6447
  */
6430
6448
  _cacheAnchors({ activeObject: t }) {
6431
- const e = this._collectTargets({ activeObject: t }), s = { vertical: [], horizontal: [] }, o = [];
6449
+ const e = this._collectTargets({ activeObject: t }), s = { vertical: [], horizontal: [] }, n = [];
6432
6450
  for (const a of e) {
6433
6451
  const r = ft({ object: a });
6434
- r && (Qe({ anchors: s, bounds: r }), o.push(r));
6452
+ r && (Qe({ anchors: s, bounds: r }), n.push(r));
6435
6453
  }
6436
- const { montageArea: n } = this.editor, i = ft({ object: n });
6454
+ const { montageArea: o } = this.editor, i = ft({ object: o });
6437
6455
  if (i) {
6438
6456
  Qe({ anchors: s, bounds: i });
6439
6457
  const { left: a, right: r, top: c, bottom: d } = i;
@@ -6445,29 +6463,29 @@ class jo {
6445
6463
  };
6446
6464
  } else
6447
6465
  this.guideBounds = this._calculateViewportBounds();
6448
- this.anchors = s, this.spacingPatterns = So({ bounds: o }), this.cachedTargetBounds = o;
6466
+ this.anchors = s, this.spacingPatterns = Sn({ bounds: n }), this.cachedTargetBounds = n;
6449
6467
  }
6450
6468
  /**
6451
6469
  * Собирает объекты, подходящие для прилипания, исключая активный объект и запрещённые id.
6452
6470
  */
6453
6471
  _collectTargets({ activeObject: t }) {
6454
- const e = ns({ activeObject: t }), s = [];
6455
- return this.canvas.forEachObject((o) => {
6456
- is({ object: o, excluded: e }) || s.push(o);
6472
+ const e = os({ activeObject: t }), s = [];
6473
+ return this.canvas.forEachObject((n) => {
6474
+ is({ object: n, excluded: e }) || s.push(n);
6457
6475
  }), s;
6458
6476
  }
6459
6477
  /**
6460
6478
  * Возвращает границы для рисования направляющих.
6461
6479
  */
6462
6480
  _calculateViewportBounds() {
6463
- const { canvas: t } = this, { viewportTransform: e } = t, s = t.getWidth(), o = t.getHeight(), [
6464
- n = 1,
6481
+ const { canvas: t } = this, { viewportTransform: e } = t, s = t.getWidth(), n = t.getHeight(), [
6482
+ o = 1,
6465
6483
  ,
6466
6484
  ,
6467
6485
  i = 1,
6468
6486
  a = 0,
6469
6487
  r = 0
6470
- ] = e != null ? e : [], c = (0 - a) / n, d = (0 - r) / i, l = (s - a) / n, u = (o - r) / i;
6488
+ ] = e != null ? e : [], c = (0 - a) / o, d = (0 - r) / i, l = (s - a) / o, u = (n - r) / i;
6471
6489
  return {
6472
6490
  left: c,
6473
6491
  right: l,
@@ -6539,8 +6557,8 @@ class Lt {
6539
6557
  this._clearGuides();
6540
6558
  return;
6541
6559
  }
6542
- const { canvas: o } = this;
6543
- if (!o.getActiveObjects().length) {
6560
+ const { canvas: n } = this;
6561
+ if (!n.getActiveObjects().length) {
6544
6562
  this._clearGuides();
6545
6563
  return;
6546
6564
  }
@@ -6577,30 +6595,30 @@ class Lt {
6577
6595
  this._clearGuides();
6578
6596
  return;
6579
6597
  }
6580
- const { canvas: e, editor: s } = this, o = e.getActiveObject();
6581
- if (!o) {
6598
+ const { canvas: e, editor: s } = this, n = e.getActiveObject();
6599
+ if (!n) {
6582
6600
  this._clearGuides();
6583
6601
  return;
6584
6602
  }
6585
- const n = ft({ object: o });
6586
- if (!n) {
6603
+ const o = ft({ object: n });
6604
+ if (!o) {
6587
6605
  this._clearGuides();
6588
6606
  return;
6589
6607
  }
6590
6608
  const i = Lt._resolveTarget({
6591
6609
  event: t,
6592
- activeObject: o
6610
+ activeObject: n
6593
6611
  }), { montageArea: a } = s, r = i != null ? i : a, c = r === a, d = ft({ object: r });
6594
6612
  if (!d) {
6595
6613
  this._clearGuides();
6596
6614
  return;
6597
6615
  }
6598
- if (c && (n.right <= d.left || n.left >= d.right || n.bottom <= d.top || n.top >= d.bottom)) {
6616
+ if (c && (o.right <= d.left || o.left >= d.right || o.bottom <= d.top || o.top >= d.bottom)) {
6599
6617
  this._clearGuides();
6600
6618
  return;
6601
6619
  }
6602
6620
  const u = Lt._buildGuides({
6603
- activeBounds: n,
6621
+ activeBounds: o,
6604
6622
  targetBounds: d,
6605
6623
  targetIsMontageArea: c
6606
6624
  });
@@ -6617,8 +6635,8 @@ class Lt {
6617
6635
  event: t,
6618
6636
  activeObject: e
6619
6637
  }) {
6620
- const { target: s } = t, o = ns({ activeObject: e });
6621
- return s && !is({ object: s, excluded: o }) ? s : null;
6638
+ const { target: s } = t, n = os({ activeObject: e });
6639
+ return s && !is({ object: s, excluded: n }) ? s : null;
6622
6640
  }
6623
6641
  /**
6624
6642
  * Собирает вертикальные и горизонтальные направляющие расстояний.
@@ -6628,16 +6646,16 @@ class Lt {
6628
6646
  targetBounds: e,
6629
6647
  targetIsMontageArea: s
6630
6648
  }) {
6631
- const o = Lt._buildHorizontalGuides({
6649
+ const n = Lt._buildHorizontalGuides({
6632
6650
  activeBounds: t,
6633
6651
  targetBounds: e,
6634
6652
  targetIsMontageArea: s
6635
- }), n = Lt._buildVerticalGuides({
6653
+ }), o = Lt._buildVerticalGuides({
6636
6654
  activeBounds: t,
6637
6655
  targetBounds: e,
6638
6656
  targetIsMontageArea: s
6639
6657
  });
6640
- return [...o, ...n];
6658
+ return [...n, ...o];
6641
6659
  }
6642
6660
  /**
6643
6661
  * Строит горизонтальные направляющие (расстояние по оси X).
@@ -6647,8 +6665,8 @@ class Lt {
6647
6665
  targetBounds: e,
6648
6666
  targetIsMontageArea: s
6649
6667
  }) {
6650
- const o = [], {
6651
- left: n = 0,
6668
+ const n = [], {
6669
+ left: o = 0,
6652
6670
  right: i = 0,
6653
6671
  top: a = 0,
6654
6672
  bottom: r = 0,
@@ -6661,30 +6679,30 @@ class Lt {
6661
6679
  centerY: f = 0
6662
6680
  } = e, p = Math.max(a, u), m = Math.min(r, g), M = m >= p ? (p + m) / 2 : (c + f) / 2;
6663
6681
  if (d >= i) {
6664
- if (s) return o;
6682
+ if (s) return n;
6665
6683
  const T = d - i;
6666
- return T > 0 && o.push({
6684
+ return T > 0 && n.push({
6667
6685
  type: "horizontal",
6668
6686
  axis: M,
6669
6687
  start: i,
6670
6688
  end: d,
6671
6689
  distance: T
6672
- }), o;
6690
+ }), n;
6673
6691
  }
6674
- if (l <= n) {
6675
- if (s) return o;
6676
- const T = n - l;
6677
- return T > 0 && o.push({
6692
+ if (l <= o) {
6693
+ if (s) return n;
6694
+ const T = o - l;
6695
+ return T > 0 && n.push({
6678
6696
  type: "horizontal",
6679
6697
  axis: M,
6680
6698
  start: l,
6681
- end: n,
6699
+ end: o,
6682
6700
  distance: T
6683
- }), o;
6701
+ }), n;
6684
6702
  }
6685
- if (!s) return o;
6686
- const S = n < d, y = i > l, b = Math.min(n, d), I = Math.max(n, d), j = I - b;
6687
- j > 0 && !S && o.push({
6703
+ if (!s) return n;
6704
+ const S = o < d, y = i > l, b = Math.min(o, d), I = Math.max(o, d), j = I - b;
6705
+ j > 0 && !S && n.push({
6688
6706
  type: "horizontal",
6689
6707
  axis: M,
6690
6708
  start: b,
@@ -6692,13 +6710,13 @@ class Lt {
6692
6710
  distance: j
6693
6711
  });
6694
6712
  const A = Math.min(i, l), C = Math.max(i, l), w = C - A;
6695
- return w > 0 && !y && o.push({
6713
+ return w > 0 && !y && n.push({
6696
6714
  type: "horizontal",
6697
6715
  axis: M,
6698
6716
  start: A,
6699
6717
  end: C,
6700
6718
  distance: w
6701
- }), o;
6719
+ }), n;
6702
6720
  }
6703
6721
  /**
6704
6722
  * Строит вертикальные направляющие (расстояние по оси Y).
@@ -6708,8 +6726,8 @@ class Lt {
6708
6726
  targetBounds: e,
6709
6727
  targetIsMontageArea: s
6710
6728
  }) {
6711
- const o = [], {
6712
- top: n = 0,
6729
+ const n = [], {
6730
+ top: o = 0,
6713
6731
  bottom: i = 0,
6714
6732
  left: a = 0,
6715
6733
  right: r = 0,
@@ -6722,30 +6740,30 @@ class Lt {
6722
6740
  centerX: f = 0
6723
6741
  } = e, p = Math.max(a, u), m = Math.min(r, g), M = m >= p ? (p + m) / 2 : (c + f) / 2;
6724
6742
  if (d >= i) {
6725
- if (s) return o;
6743
+ if (s) return n;
6726
6744
  const T = d - i;
6727
- return T > 0 && o.push({
6745
+ return T > 0 && n.push({
6728
6746
  type: "vertical",
6729
6747
  axis: M,
6730
6748
  start: i,
6731
6749
  end: d,
6732
6750
  distance: T
6733
- }), o;
6751
+ }), n;
6734
6752
  }
6735
- if (l <= n) {
6736
- if (s) return o;
6737
- const T = n - l;
6738
- return T > 0 && o.push({
6753
+ if (l <= o) {
6754
+ if (s) return n;
6755
+ const T = o - l;
6756
+ return T > 0 && n.push({
6739
6757
  type: "vertical",
6740
6758
  axis: M,
6741
6759
  start: l,
6742
- end: n,
6760
+ end: o,
6743
6761
  distance: T
6744
- }), o;
6762
+ }), n;
6745
6763
  }
6746
- if (!s) return o;
6747
- const S = n < d, y = i > l, b = Math.min(n, d), I = Math.max(n, d), j = I - b;
6748
- j > 0 && !S && o.push({
6764
+ if (!s) return n;
6765
+ const S = o < d, y = i > l, b = Math.min(o, d), I = Math.max(o, d), j = I - b;
6766
+ j > 0 && !S && n.push({
6749
6767
  type: "vertical",
6750
6768
  axis: M,
6751
6769
  start: b,
@@ -6753,13 +6771,13 @@ class Lt {
6753
6771
  distance: j
6754
6772
  });
6755
6773
  const A = Math.min(i, l), C = Math.max(i, l), w = C - A;
6756
- return w > 0 && !y && o.push({
6774
+ return w > 0 && !y && n.push({
6757
6775
  type: "vertical",
6758
6776
  axis: M,
6759
6777
  start: A,
6760
6778
  end: C,
6761
6779
  distance: w
6762
- }), o;
6780
+ }), n;
6763
6781
  }
6764
6782
  /**
6765
6783
  * Сбрасывает активные направляющие и инициирует перерисовку.
@@ -6785,8 +6803,8 @@ class Lt {
6785
6803
  if (!this.activeGuides.length) return;
6786
6804
  const { canvas: t } = this, e = t.getSelectionContext();
6787
6805
  if (!e) return;
6788
- 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;
6789
- e.save(), Array.isArray(s) && e.transform(...s), e.lineWidth = $e / o, e.strokeStyle = Je, e.setLineDash([]);
6806
+ const { viewportTransform: s } = t, n = t.getZoom() || 1, o = this.activeGuides.some((c) => c.type === "vertical"), i = this.activeGuides.some((c) => c.type === "horizontal"), a = o && i && !this.isTargetMontageArea, r = a ? 12 / n : 0;
6807
+ e.save(), Array.isArray(s) && e.transform(...s), e.lineWidth = $e / n, e.strokeStyle = Je, e.setLineDash([]);
6790
6808
  for (const c of this.activeGuides) {
6791
6809
  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, M = 0;
6792
6810
  e.beginPath(), d === "vertical" ? (e.moveTo(l, u), e.lineTo(l, g)) : (e.moveTo(u, l), e.lineTo(g, l)), e.stroke(), pe({
@@ -6796,7 +6814,7 @@ class Lt {
6796
6814
  start: u,
6797
6815
  end: g,
6798
6816
  text: Math.round(f).toString(),
6799
- zoom: o,
6817
+ zoom: n,
6800
6818
  color: Je,
6801
6819
  lineWidth: $e,
6802
6820
  offsetAlongAxis: v,
@@ -6845,8 +6863,8 @@ class we {
6845
6863
  editorContainerWidth: t,
6846
6864
  editorContainerHeight: e,
6847
6865
  canvasWrapperWidth: s,
6848
- canvasWrapperHeight: o,
6849
- canvasCSSWidth: n,
6866
+ canvasWrapperHeight: n,
6867
+ canvasCSSWidth: o,
6850
6868
  canvasCSSHeight: i,
6851
6869
  initialImage: a,
6852
6870
  initialStateJSON: r,
@@ -6854,7 +6872,7 @@ class we {
6854
6872
  showRotationAngle: d,
6855
6873
  _onReadyCallback: l
6856
6874
  } = this.options;
6857
- if ($.apply(), this.canvas = new ys(this.containerId, this.options), this.moduleLoader = new Ss(), this.workerManager = new js(), this.errorManager = new Wt({ editor: this }), this.historyManager = new Ys({ editor: this }), this.toolbar = new Ps({ 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 te({ 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 ee({ editor: this }), this.groupingManager = new so({ editor: this }), this.selectionManager = new oo({ editor: this }), this.deletionManager = new Me({ editor: this }), this.panConstraintManager = new no({ editor: this }), this.snappingManager = new jo({ editor: this }), this.measurementManager = new Lt({ editor: this }), this.fontManager = new ge((u = this.options.fonts) != null ? u : []), this.textManager = new F({ editor: this }), this.templateManager = new R({ editor: this }), d && (this.angleIndicator = new be({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.listeners = new Ft({ 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) {
6875
+ if ($.apply(), this.canvas = new ys(this.containerId, this.options), this.moduleLoader = new Ss(), this.workerManager = new js(), this.errorManager = new Wt({ editor: this }), this.historyManager = new Ys({ editor: this }), this.toolbar = new Ps({ 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 te({ editor: this }), this.shapeManager = new tn({ editor: this }), this.interactionBlocker = new $s({ editor: this }), this.backgroundManager = new Ot({ editor: this }), this.clipboardManager = new en({ editor: this }), this.objectLockManager = new ee({ editor: this }), this.groupingManager = new sn({ editor: this }), this.selectionManager = new nn({ editor: this }), this.deletionManager = new Me({ editor: this }), this.panConstraintManager = new on({ editor: this }), this.snappingManager = new jn({ editor: this }), this.measurementManager = new Lt({ editor: this }), this.fontManager = new ge((u = this.options.fonts) != null ? u : []), this.textManager = new F({ editor: this }), this.templateManager = new R({ editor: this }), d && (this.angleIndicator = new be({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.listeners = new Ft({ editor: this, options: this.options }), this.canvasManager.setEditorContainerWidth(t), this.canvasManager.setEditorContainerHeight(e), this.canvasManager.setCanvasWrapperWidth(s), this.canvasManager.setCanvasWrapperHeight(n), this.canvasManager.setCanvasCSSWidth(o), this.canvasManager.setCanvasCSSHeight(i), this.canvasManager.updateCanvas(), this.zoomManager.calculateAndApplyDefaultZoom(), yield this.fontManager.loadFonts(), a != null && a.source) {
6858
6876
  const {
6859
6877
  source: g,
6860
6878
  scale: f = `image-${c}`,
@@ -6916,8 +6934,8 @@ class we {
6916
6934
  * Метод для удаления редактора и всех слушателей.
6917
6935
  */
6918
6936
  destroy() {
6919
- var t, e, s, o;
6920
- this.listeners.destroy(), (t = this.snappingManager) == null || t.destroy(), (e = this.measurementManager) == null || e.destroy(), this.toolbar.destroy(), (s = this.angleIndicator) == null || s.destroy(), (o = this.textManager) == null || o.destroy(), this.canvas.dispose(), this.workerManager.worker.terminate(), this.imageManager.revokeBlobUrls(), this.errorManager.cleanBuffer();
6937
+ var t, e, s, n;
6938
+ this.listeners.destroy(), (t = this.snappingManager) == null || t.destroy(), (e = this.measurementManager) == null || e.destroy(), this.toolbar.destroy(), (s = this.angleIndicator) == null || s.destroy(), (n = this.textManager) == null || n.destroy(), this.canvas.dispose(), this.workerManager.worker.terminate(), this.imageManager.revokeBlobUrls(), this.errorManager.cleanBuffer();
6921
6939
  }
6922
6940
  /**
6923
6941
  * Создает паттерн мозаики.
@@ -6972,7 +6990,7 @@ const O = [
6972
6990
  "U+A640-A69F",
6973
6991
  "U+FE2E-FE2F",
6974
6992
  "U+2116"
6975
- ].join(", "), Io = [
6993
+ ].join(", "), In = [
6976
6994
  {
6977
6995
  family: "Arial",
6978
6996
  source: 'local("Arial"), local("Liberation Sans"), local("DejaVu Sans")',
@@ -7762,7 +7780,7 @@ const O = [
7762
7780
  unicodeRange: O
7763
7781
  }
7764
7782
  }
7765
- ], Co = {
7783
+ ], Cn = {
7766
7784
  /**
7767
7785
  * Опции редактора
7768
7786
  */
@@ -7854,20 +7872,20 @@ const O = [
7854
7872
  /**
7855
7873
  * Список шрифтов, которые будут доступны в редакторе по умолчанию.
7856
7874
  */
7857
- fonts: Io
7875
+ fonts: In
7858
7876
  };
7859
- function Do(h, t = {}) {
7860
- const e = B(B({}, Co), t), s = document.getElementById(h);
7877
+ function Dn(h, t = {}) {
7878
+ const e = B(B({}, Cn), t), s = document.getElementById(h);
7861
7879
  if (!s)
7862
7880
  return Promise.reject(new Error(`Контейнер с ID "${h}" не найден.`));
7863
- const o = document.createElement("canvas");
7864
- return o.id = `${h}-canvas`, s.appendChild(o), e.editorContainer = s, new Promise((n) => {
7865
- e._onReadyCallback = n;
7866
- const i = new we(o.id, e);
7881
+ const n = document.createElement("canvas");
7882
+ return n.id = `${h}-canvas`, s.appendChild(n), e.editorContainer = s, new Promise((o) => {
7883
+ e._onReadyCallback = o;
7884
+ const i = new we(n.id, e);
7867
7885
  window[h] = i;
7868
7886
  });
7869
7887
  }
7870
7888
  export {
7871
- Do as default
7889
+ Dn as default
7872
7890
  };
7873
7891
  //# sourceMappingURL=main.js.map