@anu3ev/fabric-image-editor 0.1.82 → 0.1.83

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 +571 -516
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -1,12 +1,12 @@
1
1
  var Ne = Object.defineProperty, Le = Object.defineProperties;
2
2
  var we = Object.getOwnPropertyDescriptors;
3
- var F = Object.getOwnPropertySymbols;
3
+ var G = Object.getOwnPropertySymbols;
4
4
  var Me = Object.prototype.hasOwnProperty, me = Object.prototype.propertyIsEnumerable;
5
- var fe = (c, e, t) => e in c ? Ne(c, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[e] = t, I = (c, e) => {
5
+ var fe = (c, e, t) => e in c ? Ne(c, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[e] = t, v = (c, e) => {
6
6
  for (var t in e || (e = {}))
7
7
  Me.call(e, t) && fe(c, t, e[t]);
8
- if (F)
9
- for (var t of F(e))
8
+ if (G)
9
+ for (var t of G(e))
10
10
  me.call(e, t) && fe(c, t, e[t]);
11
11
  return c;
12
12
  }, be = (c, e) => Le(c, we(e));
@@ -14,28 +14,28 @@ var V = (c, e) => {
14
14
  var t = {};
15
15
  for (var s in c)
16
16
  Me.call(c, s) && e.indexOf(s) < 0 && (t[s] = c[s]);
17
- if (c != null && F)
18
- for (var s of F(c))
17
+ if (c != null && G)
18
+ for (var s of G(c))
19
19
  e.indexOf(s) < 0 && me.call(c, s) && (t[s] = c[s]);
20
20
  return t;
21
21
  };
22
- var j = (c, e, t) => new Promise((s, a) => {
23
- var n = (r) => {
22
+ var p = (c, e, t) => new Promise((s, n) => {
23
+ var a = (r) => {
24
24
  try {
25
25
  i(t.next(r));
26
26
  } catch (d) {
27
- a(d);
27
+ n(d);
28
28
  }
29
29
  }, o = (r) => {
30
30
  try {
31
31
  i(t.throw(r));
32
32
  } catch (d) {
33
- a(d);
33
+ n(d);
34
34
  }
35
- }, i = (r) => r.done ? s(r.value) : Promise.resolve(r.value).then(n, o);
35
+ }, i = (r) => r.done ? s(r.value) : Promise.resolve(r.value).then(a, o);
36
36
  i((t = t.apply(c, e)).next());
37
37
  });
38
- import { ActiveSelection as v, util as W, controlsUtils as Te, InteractiveFabricObject as je, loadSVGFromURL as ke, FabricImage as Z, Point as X, Gradient as pe, Rect as _e, Circle as Be, Triangle as xe, Group as te, Canvas as Re, Pattern as Ue } from "fabric";
38
+ import { ActiveSelection as y, util as F, controlsUtils as Te, InteractiveFabricObject as pe, loadSVGFromURL as ke, FabricImage as Y, Point as $, Gradient as je, Rect as _e, Circle as Be, Triangle as xe, Group as R, Canvas as Re, Pattern as Ue } from "fabric";
39
39
  import { create as ze } from "jsondiffpatch";
40
40
  import He from "diff-match-patch";
41
41
  var Ze = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", A = function() {
@@ -43,7 +43,7 @@ var Ze = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", A =
43
43
  t += Ze[s[e] & 63];
44
44
  return t;
45
45
  };
46
- class P {
46
+ class W {
47
47
  /**
48
48
  * Конструктор принимает редактор и опции.
49
49
  * @param params
@@ -61,7 +61,7 @@ class P {
61
61
  * @param params.options.adaptCanvasToContainerOnResize — адаптировать канвас к размерам контейнера при изменении размеров окна
62
62
  */
63
63
  constructor({ editor: e, options: t = {} }) {
64
- this.isDragging = !1, this.lastMouseX = 0, this.lastMouseY = 0, this.isUndoRedoKeyPressed = !1, this.isSpacePressed = !1, this.savedSelection = [], this.canvasDragging = !1, this.mouseWheelZooming = !1, this.bringToFrontOnSelection = !1, this.resetObjectFitByDoubleClick = !1, this.copyObjectsByHotkey = !1, this.pasteImageFromClipboard = !1, this.undoRedoByHotKeys = !1, this.selectAllByHotkey = !1, this.deleteObjectsByHotkey = !1, this.adaptCanvasToContainerOnResize = !1, this.editor = e, this.canvas = e.canvas, this.options = t, this.handleContainerResizeBound = P.debounce(this.handleContainerResize.bind(this), 500), this.handleCopyEventBound = this.handleCopyEvent.bind(this), this.handlePasteEventBound = this.handlePasteEvent.bind(this), this.handleUndoRedoEventBound = this.handleUndoRedoEvent.bind(this), this.handleUndoRedoKeyUpBound = this.handleUndoRedoKeyUp.bind(this), this.handleSelectAllEventBound = this.handleSelectAllEvent.bind(this), this.handleDeleteObjectsEventBound = this.handleDeleteObjectsEvent.bind(this), this.handleSpaceKeyDownBound = this.handleSpaceKeyDown.bind(this), this.handleSpaceKeyUpBound = this.handleSpaceKeyUp.bind(this), this.handleObjectModifiedHistoryBound = P.debounce(this.handleObjectModifiedHistory.bind(this), 300), this.handleObjectRotatingHistoryBound = P.debounce(this.handleObjectRotatingHistory.bind(this), 300), this.handleObjectAddedHistoryBound = this.handleObjectAddedHistory.bind(this), this.handleObjectRemovedHistoryBound = this.handleObjectRemovedHistory.bind(this), this.handleOverlayUpdateBound = this.handleOverlayUpdate.bind(this), this.handleBackgroundUpdateBound = this.handleBackgroundUpdate.bind(this), this.handleCanvasDragStartBound = this.handleCanvasDragStart.bind(this), this.handleCanvasDraggingBound = this.handleCanvasDragging.bind(this), this.handleCanvasDragEndBound = this.handleCanvasDragEnd.bind(this), this.handleMouseWheelZoomBound = this.handleMouseWheelZoom.bind(this), this.handleBringToFrontBound = this.handleBringToFront.bind(this), this.handleResetObjectFitBound = this.handleResetObjectFit.bind(this), this.handleLockedSelectionBound = this._filterLockedSelection.bind(this), this.init();
64
+ this.isDragging = !1, this.lastMouseX = 0, this.lastMouseY = 0, this.isUndoRedoKeyPressed = !1, this.isSpacePressed = !1, this.savedSelection = [], this.canvasDragging = !1, this.mouseWheelZooming = !1, this.bringToFrontOnSelection = !1, this.resetObjectFitByDoubleClick = !1, this.copyObjectsByHotkey = !1, this.pasteImageFromClipboard = !1, this.undoRedoByHotKeys = !1, this.selectAllByHotkey = !1, this.deleteObjectsByHotkey = !1, this.adaptCanvasToContainerOnResize = !1, this.editor = e, this.canvas = e.canvas, this.options = t, this.handleContainerResizeBound = W.debounce(this.handleContainerResize.bind(this), 500), this.handleCopyEventBound = this.handleCopyEvent.bind(this), this.handlePasteEventBound = this.handlePasteEvent.bind(this), this.handleUndoRedoEventBound = this.handleUndoRedoEvent.bind(this), this.handleUndoRedoKeyUpBound = this.handleUndoRedoKeyUp.bind(this), this.handleSelectAllEventBound = this.handleSelectAllEvent.bind(this), this.handleDeleteObjectsEventBound = this.handleDeleteObjectsEvent.bind(this), this.handleSpaceKeyDownBound = this.handleSpaceKeyDown.bind(this), this.handleSpaceKeyUpBound = this.handleSpaceKeyUp.bind(this), this.handleObjectModifiedHistoryBound = W.debounce(this.handleObjectModifiedHistory.bind(this), 300), this.handleObjectRotatingHistoryBound = W.debounce(this.handleObjectRotatingHistory.bind(this), 300), this.handleObjectAddedHistoryBound = this.handleObjectAddedHistory.bind(this), this.handleObjectRemovedHistoryBound = this.handleObjectRemovedHistory.bind(this), this.handleOverlayUpdateBound = this.handleOverlayUpdate.bind(this), this.handleBackgroundUpdateBound = this.handleBackgroundUpdate.bind(this), this.handleCanvasDragStartBound = this.handleCanvasDragStart.bind(this), this.handleCanvasDraggingBound = this.handleCanvasDragging.bind(this), this.handleCanvasDragEndBound = this.handleCanvasDragEnd.bind(this), this.handleMouseWheelZoomBound = this.handleMouseWheelZoom.bind(this), this.handleBringToFrontBound = this.handleBringToFront.bind(this), this.handleResetObjectFitBound = this.handleResetObjectFit.bind(this), this.handleLockedSelectionBound = this._filterLockedSelection.bind(this), this.init();
65
65
  }
66
66
  /**
67
67
  * Инициализация всех обработчиков согласно опциям.
@@ -71,15 +71,15 @@ class P {
71
71
  adaptCanvasToContainerOnResize: e,
72
72
  canvasDragging: t,
73
73
  mouseWheelZooming: s,
74
- bringToFrontOnSelection: a,
75
- copyObjectsByHotkey: n,
74
+ bringToFrontOnSelection: n,
75
+ copyObjectsByHotkey: a,
76
76
  pasteImageFromClipboard: o,
77
77
  undoRedoByHotKeys: i,
78
78
  selectAllByHotkey: r,
79
79
  deleteObjectsByHotkey: d,
80
80
  resetObjectFitByDoubleClick: h
81
81
  } = this.options;
82
- t && (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), a && (this.canvas.on("selection:created", this.handleBringToFrontBound), this.canvas.on("selection:updated", this.handleBringToFrontBound)), h && this.canvas.on("mouse:dblclick", this.handleResetObjectFitBound), e && window.addEventListener("resize", this.handleContainerResizeBound, { capture: !0 }), n && document.addEventListener("keydown", this.handleCopyEventBound, { capture: !0 }), o && document.addEventListener("paste", this.handlePasteEventBound, { capture: !0 }), i && (document.addEventListener("keydown", this.handleUndoRedoEventBound, { capture: !0 }), document.addEventListener("keyup", this.handleUndoRedoKeyUpBound, { capture: !0 })), r && document.addEventListener("keydown", this.handleSelectAllEventBound, { capture: !0 }), d && 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
+ t && (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)), h && this.canvas.on("mouse:dblclick", this.handleResetObjectFitBound), e && window.addEventListener("resize", this.handleContainerResizeBound, { capture: !0 }), a && document.addEventListener("keydown", this.handleCopyEventBound, { capture: !0 }), o && document.addEventListener("paste", this.handlePasteEventBound, { capture: !0 }), i && (document.addEventListener("keydown", this.handleUndoRedoEventBound, { capture: !0 }), document.addEventListener("keyup", this.handleUndoRedoKeyUpBound, { capture: !0 })), r && document.addEventListener("keydown", this.handleSelectAllEventBound, { capture: !0 }), d && 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 P {
89
89
  */
90
90
  _filterLockedSelection({ selected: e, e: t }) {
91
91
  if (!(e != null && e.length) || !(t instanceof MouseEvent) || e.length === 1) return;
92
- const { lockedObjects: s, unlockedObjects: a } = e.reduce(
92
+ const { lockedObjects: s, unlockedObjects: n } = e.reduce(
93
93
  (o, i) => i.locked ? (o.lockedObjects.push(i), o) : (o.unlockedObjects.push(i), o),
94
94
  { lockedObjects: [], unlockedObjects: [] }
95
95
  );
96
96
  if (s.length === 0) return;
97
- if (a.length > 0) {
98
- if (a.length === 1)
99
- this.canvas.setActiveObject(a[0]);
97
+ if (n.length > 0) {
98
+ if (n.length === 1)
99
+ this.canvas.setActiveObject(n[0]);
100
100
  else {
101
- const o = new v(a, {
101
+ const o = new y(n, {
102
102
  canvas: this.canvas
103
103
  });
104
104
  this.canvas.setActiveObject(o);
@@ -106,14 +106,14 @@ class P {
106
106
  this.canvas.requestRenderAll();
107
107
  return;
108
108
  }
109
- const n = new v(e, {
109
+ const a = new y(e, {
110
110
  canvas: this.canvas
111
111
  });
112
112
  this.editor.objectLockManager.lockObject({
113
- object: n,
113
+ object: a,
114
114
  skipInnerObjects: !0,
115
115
  withoutSave: !0
116
- }), this.canvas.setActiveObject(n), this.canvas.requestRenderAll();
116
+ }), this.canvas.setActiveObject(a), this.canvas.requestRenderAll();
117
117
  }
118
118
  /**
119
119
  * Обработчики для сохранения состояния редактора в истории.
@@ -157,8 +157,8 @@ class P {
157
157
  * @param event.code — код клавиши
158
158
  */
159
159
  handleCopyEvent(e) {
160
- const { ctrlKey: t, metaKey: s, code: a } = e;
161
- this._shouldIgnoreKeyboardEvent(e) || !t && !s || a !== "KeyC" || (e.preventDefault(), this.editor.clipboardManager.copy());
160
+ const { ctrlKey: t, metaKey: s, code: n } = e;
161
+ this._shouldIgnoreKeyboardEvent(e) || !t && !s || n !== "KeyC" || (e.preventDefault(), this.editor.clipboardManager.copy());
162
162
  }
163
163
  /**
164
164
  * Обработчик вставки объекта или изображения из буфера обмена.
@@ -175,9 +175,9 @@ class P {
175
175
  * @param event.code — код клавиши
176
176
  */
177
177
  handleUndoRedoEvent(e) {
178
- return j(this, null, function* () {
179
- const { ctrlKey: t, metaKey: s, code: a, repeat: n } = e;
180
- this._shouldIgnoreKeyboardEvent(e) || !t && !s || n || !/Mac/i.test(navigator.userAgent) && this.isUndoRedoKeyPressed || (a === "KeyZ" ? (e.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.undo()) : a === "KeyY" && (e.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.redo()));
178
+ return p(this, null, function* () {
179
+ const { ctrlKey: t, metaKey: s, code: n, repeat: a } = e;
180
+ this._shouldIgnoreKeyboardEvent(e) || !t && !s || a || !/Mac/i.test(navigator.userAgent) && this.isUndoRedoKeyPressed || (n === "KeyZ" ? (e.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.undo()) : n === "KeyY" && (e.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.redo()));
181
181
  });
182
182
  }
183
183
  /**
@@ -197,8 +197,8 @@ class P {
197
197
  */
198
198
  handleSelectAllEvent(e) {
199
199
  if (this._shouldIgnoreKeyboardEvent(e)) return;
200
- const { ctrlKey: t, metaKey: s, code: a } = e;
201
- !t && !s || a !== "KeyA" || (e.preventDefault(), this.editor.selectionManager.selectAll());
200
+ const { ctrlKey: t, metaKey: s, code: n } = e;
201
+ !t && !s || n !== "KeyA" || (e.preventDefault(), this.editor.selectionManager.selectAll());
202
202
  }
203
203
  /**
204
204
  * Обработчик для удаления объектов (Delete или Backspace).
@@ -216,11 +216,11 @@ class P {
216
216
  */
217
217
  handleSpaceKeyDown(e) {
218
218
  if (e.code !== "Space" || this._shouldIgnoreKeyboardEvent(e)) return;
219
- const { canvas: t, editor: s, isSpacePressed: a, isDragging: n } = this;
220
- if (a || n) return;
219
+ const { canvas: t, editor: s, isSpacePressed: n, isDragging: a } = this;
220
+ if (n || a) return;
221
221
  this.isSpacePressed = !0, e.preventDefault();
222
222
  const o = t.getActiveObject() || null;
223
- o instanceof v ? this.savedSelection = o.getObjects().slice() : o && (this.savedSelection = [o]), t.discardActiveObject(), t.set({
223
+ o instanceof y ? this.savedSelection = o.getObjects().slice() : o && (this.savedSelection = [o]), t.discardActiveObject(), t.set({
224
224
  selection: !1,
225
225
  defaultCursor: "grab"
226
226
  }), t.setCursor("grab"), s.canvasManager.getObjects().forEach((i) => {
@@ -259,8 +259,8 @@ class P {
259
259
  t.setActiveObject(e[0]);
260
260
  return;
261
261
  }
262
- const a = e.filter((o) => s.canvasManager.getObjects().includes(o)), n = new v(a, { canvas: t });
263
- t.setActiveObject(n);
262
+ const n = e.filter((o) => s.canvasManager.getObjects().includes(o)), a = new y(n, { canvas: t });
263
+ t.setActiveObject(a);
264
264
  }
265
265
  // --- Обработчики для событий canvas (Fabric) ---
266
266
  /**
@@ -325,18 +325,18 @@ class P {
325
325
  * @returns true если событие должно быть проигнорировано
326
326
  */
327
327
  _shouldIgnoreKeyboardEvent(e) {
328
- const t = document.activeElement, s = e.target, a = ["input", "textarea", "select"];
328
+ const t = document.activeElement, s = e.target, n = ["input", "textarea", "select"];
329
329
  if (s) {
330
330
  const o = s.tagName.toLowerCase();
331
- if (a.includes(o) || s.contentEditable === "true") return !0;
331
+ if (n.includes(o) || s.contentEditable === "true") return !0;
332
332
  }
333
333
  if (t && t !== s) {
334
334
  const o = t.tagName.toLowerCase();
335
- if (a.includes(o) || t.contentEditable === "true") return !0;
335
+ if (n.includes(o) || t.contentEditable === "true") return !0;
336
336
  }
337
- const n = window.getSelection();
338
- if (n && !n.isCollapsed && n.rangeCount > 0) {
339
- let r = n.getRangeAt(0).commonAncestorContainer;
337
+ const a = window.getSelection();
338
+ if (a && !a.isCollapsed && a.rangeCount > 0) {
339
+ let r = a.getRangeAt(0).commonAncestorContainer;
340
340
  r.nodeType === Node.TEXT_NODE && (r = r.parentElement);
341
341
  const { keyboardIgnoreSelectors: d } = this.options;
342
342
  if (d != null && d.length && r)
@@ -365,9 +365,9 @@ class P {
365
365
  */
366
366
  static debounce(e, t) {
367
367
  let s = null;
368
- return function(...a) {
368
+ return function(...n) {
369
369
  s !== null && clearTimeout(s), s = setTimeout(() => {
370
- e.apply(this, a);
370
+ e.apply(this, n);
371
371
  }, t);
372
372
  };
373
373
  }
@@ -417,12 +417,12 @@ class We {
417
417
  * @returns
418
418
  */
419
419
  _handleMessage({ data: e }) {
420
- const { requestId: t, success: s, data: a, error: n } = e, o = this._callbacks.get(t);
420
+ const { requestId: t, success: s, data: n, error: a } = e, o = this._callbacks.get(t);
421
421
  if (!o) {
422
422
  console.warn(`No callback found for requestId: ${t}`);
423
423
  return;
424
424
  }
425
- s ? o.resolve(a) : o.reject(new Error(n)), this._callbacks.delete(t);
425
+ s ? o.resolve(n) : o.reject(new Error(a)), this._callbacks.delete(t);
426
426
  }
427
427
  /**
428
428
  * Универсальный метод отправки команды в воркер
@@ -432,9 +432,9 @@ class We {
432
432
  * @returns Promise, который будет выполнен, когда воркер вернет ответ
433
433
  */
434
434
  post(e, t, s = []) {
435
- const a = `${e}:${A(8)}`;
436
- return new Promise((n, o) => {
437
- this._callbacks.set(a, { resolve: n, reject: o }), this.worker.postMessage({ action: e, payload: t, requestId: a }, s);
435
+ const n = `${e}:${A(8)}`;
436
+ return new Promise((a, o) => {
437
+ this._callbacks.set(n, { resolve: a, reject: o }), this.worker.postMessage({ action: e, payload: t, requestId: n }, s);
438
438
  });
439
439
  }
440
440
  /**
@@ -444,52 +444,52 @@ class We {
444
444
  this.worker.terminate();
445
445
  }
446
446
  }
447
- const O = 12, Fe = 2, se = 8, ae = 20, Ve = 100, ne = 20, oe = 8, Ge = 100, Q = 32, ie = 1, Xe = "#2B2D33", re = "#3D8BF4", ce = "#FFFFFF";
448
- function G(c, e, t, s, a) {
449
- const n = O, o = Fe;
450
- c.save(), c.translate(e, t), c.rotate(W.degreesToRadians(a.angle)), c.fillStyle = ce, c.strokeStyle = re, c.lineWidth = ie, c.beginPath(), c.roundRect(-n / 2, -n / 2, n, n, o), c.fill(), c.stroke(), c.restore();
447
+ const E = 12, Fe = 2, se = 8, ne = 20, Ge = 100, ae = 20, oe = 8, Ve = 100, Q = 32, ie = 1, Xe = "#2B2D33", re = "#3D8BF4", ce = "#FFFFFF";
448
+ function X(c, e, t, s, n) {
449
+ const a = E, o = Fe;
450
+ c.save(), c.translate(e, t), c.rotate(F.degreesToRadians(n.angle)), c.fillStyle = ce, c.strokeStyle = re, c.lineWidth = ie, c.beginPath(), c.roundRect(-a / 2, -a / 2, a, a, o), c.fill(), c.stroke(), c.restore();
451
451
  }
452
- function ye(c, e, t, s, a) {
453
- const n = se, o = ae, i = Ve;
454
- c.save(), c.translate(e, t), c.rotate(W.degreesToRadians(a.angle)), c.fillStyle = ce, c.strokeStyle = re, c.lineWidth = ie, c.beginPath(), c.roundRect(-n / 2, -o / 2, n, o, i), c.fill(), c.stroke(), c.restore();
452
+ function ye(c, e, t, s, n) {
453
+ const a = se, o = ne, i = Ge;
454
+ c.save(), c.translate(e, t), c.rotate(F.degreesToRadians(n.angle)), c.fillStyle = ce, c.strokeStyle = re, c.lineWidth = ie, c.beginPath(), c.roundRect(-a / 2, -o / 2, a, o, i), c.fill(), c.stroke(), c.restore();
455
455
  }
456
- function Ie(c, e, t, s, a) {
457
- const n = ne, o = oe, i = Ge;
458
- c.save(), c.translate(e, t), c.rotate(W.degreesToRadians(a.angle)), c.fillStyle = ce, c.strokeStyle = re, c.lineWidth = ie, c.beginPath(), c.roundRect(-n / 2, -o / 2, n, o, i), c.fill(), c.stroke(), c.restore();
456
+ function Ie(c, e, t, s, n) {
457
+ const a = ae, o = oe, i = Ve;
458
+ c.save(), c.translate(e, t), c.rotate(F.degreesToRadians(n.angle)), c.fillStyle = ce, c.strokeStyle = re, c.lineWidth = ie, c.beginPath(), c.roundRect(-a / 2, -o / 2, a, o, i), c.fill(), c.stroke(), c.restore();
459
459
  }
460
- const Qe = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", De = new Image();
461
- De.src = Qe;
462
- function $e(c, e, t, s, a) {
460
+ const $e = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", De = new Image();
461
+ De.src = $e;
462
+ function Qe(c, e, t, s, n) {
463
463
  const o = Q / 2;
464
- c.save(), c.translate(e, t), c.rotate(W.degreesToRadians(a.angle)), c.fillStyle = Xe, c.beginPath(), c.arc(0, 0, o, 0, 2 * Math.PI), c.fill(), c.drawImage(De, -o / 2, -o / 2, o, o), c.restore();
464
+ c.save(), c.translate(e, t), c.rotate(F.degreesToRadians(n.angle)), c.fillStyle = Xe, c.beginPath(), c.arc(0, 0, o, 0, 2 * Math.PI), c.fill(), c.drawImage(De, -o / 2, -o / 2, o, o), c.restore();
465
465
  }
466
466
  const Ke = {
467
467
  // Угловые точки
468
468
  tl: {
469
- render: G,
470
- sizeX: O,
471
- sizeY: O,
469
+ render: X,
470
+ sizeX: E,
471
+ sizeY: E,
472
472
  offsetX: 0,
473
473
  offsetY: 0
474
474
  },
475
475
  tr: {
476
- render: G,
477
- sizeX: O,
478
- sizeY: O,
476
+ render: X,
477
+ sizeX: E,
478
+ sizeY: E,
479
479
  offsetX: 0,
480
480
  offsetY: 0
481
481
  },
482
482
  bl: {
483
- render: G,
484
- sizeX: O,
485
- sizeY: O,
483
+ render: X,
484
+ sizeX: E,
485
+ sizeY: E,
486
486
  offsetX: 0,
487
487
  offsetY: 0
488
488
  },
489
489
  br: {
490
- render: G,
491
- sizeX: O,
492
- sizeY: O,
490
+ render: X,
491
+ sizeX: E,
492
+ sizeY: E,
493
493
  offsetX: 0,
494
494
  offsetY: 0
495
495
  },
@@ -497,35 +497,35 @@ const Ke = {
497
497
  ml: {
498
498
  render: ye,
499
499
  sizeX: se,
500
- sizeY: ae,
500
+ sizeY: ne,
501
501
  offsetX: 0,
502
502
  offsetY: 0
503
503
  },
504
504
  mr: {
505
505
  render: ye,
506
506
  sizeX: se,
507
- sizeY: ae,
507
+ sizeY: ne,
508
508
  offsetX: 0,
509
509
  offsetY: 0
510
510
  },
511
511
  // Середина горизонталей
512
512
  mt: {
513
513
  render: Ie,
514
- sizeX: ne,
514
+ sizeX: ae,
515
515
  sizeY: oe,
516
516
  offsetX: 0,
517
517
  offsetY: 0
518
518
  },
519
519
  mb: {
520
520
  render: Ie,
521
- sizeX: ne,
521
+ sizeX: ae,
522
522
  sizeY: oe,
523
523
  offsetX: 0,
524
524
  offsetY: 0
525
525
  },
526
526
  // Специальный «rotate» контрол
527
527
  mtr: {
528
- render: $e,
528
+ render: Qe,
529
529
  sizeX: Q,
530
530
  sizeY: Q,
531
531
  offsetX: 0,
@@ -542,14 +542,14 @@ class Je {
542
542
  sizeY: s.sizeY,
543
543
  offsetX: s.offsetX,
544
544
  offsetY: s.offsetY
545
- }), t === "mtr" && (e[t].cursorStyle = "grab", e[t].mouseDownHandler = (n, o, i, r) => {
545
+ }), t === "mtr" && (e[t].cursorStyle = "grab", e[t].mouseDownHandler = (a, o, i, r) => {
546
546
  var h;
547
547
  (h = o.target.canvas) == null || h.setCursor("grabbing");
548
548
  });
549
- }), je.ownDefaults.controls = e, je.ownDefaults.snapAngle = 1;
549
+ }), pe.ownDefaults.controls = e, pe.ownDefaults.snapAngle = 1;
550
550
  }
551
551
  }
552
- const qe = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNi44NzUgMi41YS42MjUuNjI1IDAgMCAwLS42MjUuNjI0VjYuMjVIMy4xMjVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2MTBjMCAuMzQ1LjI4LjYyNS42MjUuNjI1aDEwYy4zNDUgMCAuNjI1LS4yOC42MjUtLjYyNXYtMy4xMjZoMy4xMjVjLjM0NSAwIC42MjUtLjI4LjYyNS0uNjI1di0xMGEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTEwWm02Ljg3NSAxMGgyLjVWMy43NUg3LjV2Mi41aDUuNjI1Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NS42MjRabS0xMCAzLjc1VjcuNWg4Ljc1djguNzVIMy43NVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", et = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJN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wvc3ZnPg==", P = {
553
553
  style: {
554
554
  position: "absolute",
555
555
  display: "none",
@@ -620,13 +620,13 @@ const qe = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
620
620
  delete: it,
621
621
  lock: et,
622
622
  unlock: tt,
623
- bringToFront: nt,
623
+ bringToFront: at,
624
624
  sendToBack: ot,
625
625
  bringForward: st,
626
- sendBackwards: at
626
+ sendBackwards: nt
627
627
  },
628
628
  handlers: {
629
- copyPaste: (c) => j(null, null, function* () {
629
+ copyPaste: (c) => p(null, null, function* () {
630
630
  c.clipboardManager.copyPaste();
631
631
  }),
632
632
  delete: (c) => {
@@ -659,11 +659,11 @@ class rt {
659
659
  _initToolbar() {
660
660
  if (!this.options.showToolbar) return;
661
661
  const e = this.options.toolbar || {};
662
- this.config = be(I(I({}, Y), e), {
663
- style: I(I({}, Y.style), e.style || {}),
664
- btnStyle: I(I({}, Y.btnStyle), e.btnStyle || {}),
665
- icons: I(I({}, Y.icons), e.icons || {}),
666
- handlers: I(I({}, Y.handlers), e.handlers || {})
662
+ this.config = be(v(v({}, P), e), {
663
+ style: v(v({}, P.style), e.style || {}),
664
+ btnStyle: v(v({}, P.btnStyle), e.btnStyle || {}),
665
+ icons: v(v({}, P.icons), e.icons || {}),
666
+ handlers: v(v({}, P.handlers), e.handlers || {})
667
667
  }), this.currentTarget = null, this.currentLocked = !1, this.isTransforming = !1, this._onMouseDown = this._handleMouseDown.bind(this), this._onObjectMoving = this._startTransform.bind(this), this._onObjectScaling = this._startTransform.bind(this), this._onObjectRotating = this._startTransform.bind(this), this._onMouseUp = this._endTransform.bind(this), this._onObjectModified = this._endTransform.bind(this), this._onSelectionChange = this._updateToolbar.bind(this), this._onSelectionClear = () => {
668
668
  this.el.style.display = "none";
669
669
  }, this._createDOM(), this._bindEvents();
@@ -674,11 +674,11 @@ class rt {
674
674
  _createDOM() {
675
675
  const { style: e } = this.config;
676
676
  this.el = document.createElement("div"), Object.assign(this.el.style, e), this.canvas.wrapperEl.appendChild(this.el), this._onBtnOver = (t) => {
677
- const a = t.target.closest("button");
678
- a && Object.assign(a.style, this.config.btnHover);
677
+ const n = t.target.closest("button");
678
+ n && Object.assign(n.style, this.config.btnHover);
679
679
  }, this._onBtnOut = (t) => {
680
- const a = t.target.closest("button");
681
- a && Object.assign(a.style, this.config.btnStyle);
680
+ const n = t.target.closest("button");
681
+ n && Object.assign(n.style, this.config.btnStyle);
682
682
  }, this.el.addEventListener("mouseover", this._onBtnOver), this.el.addEventListener("mouseout", this._onBtnOut);
683
683
  }
684
684
  /**
@@ -690,10 +690,10 @@ class rt {
690
690
  _renderButtons(e) {
691
691
  this.el.innerHTML = "";
692
692
  for (const t of e) {
693
- const { name: s, handle: a } = t, { icons: n = {}, btnStyle: o, handlers: i = {} } = this.config, r = document.createElement("button");
694
- r.innerHTML = n[a] ? `<img src="${n[a]}" title="${s}" />` : s, Object.assign(r.style, o), r.onclick = () => {
693
+ const { name: s, handle: n } = t, { icons: a = {}, btnStyle: o, handlers: i = {} } = this.config, r = document.createElement("button");
694
+ r.innerHTML = a[n] ? `<img src="${a[n]}" title="${s}" />` : s, Object.assign(r.style, o), r.onclick = () => {
695
695
  var d;
696
- return (d = i[a]) == null ? void 0 : d.call(i, this.editor);
696
+ return (d = i[n]) == null ? void 0 : d.call(i, this.editor);
697
697
  }, r.onmousedown = (d) => {
698
698
  d.stopPropagation(), d.preventDefault();
699
699
  }, r.ondragstart = (d) => d.preventDefault(), this.el.appendChild(r);
@@ -752,9 +752,9 @@ class rt {
752
752
  this.el.style.display = "none";
753
753
  return;
754
754
  }
755
- const { el: t, config: s, canvas: a } = this;
755
+ const { el: t, config: s, canvas: n } = this;
756
756
  e.setCoords();
757
- const n = a.getZoom(), [, , , , o, i] = a.viewportTransform, { x: r } = e.getCenterPoint(), { top: d, height: h } = e.getBoundingRect(), u = r * n + o - t.offsetWidth / 2, g = s.offsetTop || 0, M = (d + h) * n + i + g;
757
+ const a = n.getZoom(), [, , , , o, i] = n.viewportTransform, { x: r } = e.getCenterPoint(), { top: d, height: h } = e.getBoundingRect(), u = r * a + o - t.offsetWidth / 2, g = s.offsetTop || 0, M = (d + h) * a + i + g;
758
758
  Object.assign(t.style, {
759
759
  left: `${u}px`,
760
760
  top: `${M}px`,
@@ -842,9 +842,9 @@ class de {
842
842
  */
843
843
  _positionIndicator(e) {
844
844
  const t = this.canvas.wrapperEl.getBoundingClientRect();
845
- let s = e.clientX - t.left + ve, a = e.clientY - t.top + Ae;
846
- const n = this.el.getBoundingClientRect(), o = n.width, i = n.height;
847
- s + o > t.width && (s = e.clientX - t.left - o - ve), a + i > t.height && (a = e.clientY - t.top - i - Ae), this.el.style.left = `${s}px`, this.el.style.top = `${a}px`;
845
+ let s = e.clientX - t.left + ve, n = e.clientY - t.top + Ae;
846
+ const a = this.el.getBoundingClientRect(), o = a.width, i = a.height;
847
+ s + o > t.width && (s = e.clientX - t.left - o - ve), n + i > t.height && (n = e.clientY - t.top - i - Ae), this.el.style.left = `${s}px`, this.el.style.top = `${n}px`;
848
848
  }
849
849
  /**
850
850
  * Показать индикатор
@@ -875,7 +875,7 @@ class de {
875
875
  this.canvas && (this.canvas.off("object:rotating", this._onObjectRotating), this.canvas.off("mouse:up", this._onMouseUp), this.canvas.off("object:modified", this._onObjectModified), this.canvas.off("selection:cleared", this._onSelectionCleared)), (e = this.el) != null && e.parentNode && this.el.parentNode.removeChild(this.el), this.el = null, this.editor = null, this.canvas = null, this.options = null;
876
876
  }
877
877
  }
878
- class $ {
878
+ class K {
879
879
  constructor({ editor: e }) {
880
880
  this.editor = e, this.canvas = e.canvas, this._historySuspendCount = 0, this.baseState = null, this.patches = [], this.currentIndex = 0, this.maxHistoryLength = e.options.maxHistoryLength, this.totalChangesCount = 0, this.baseStateChangesCount = 0, this._createDiffPatcher();
881
881
  }
@@ -943,10 +943,10 @@ class $ {
943
943
  */
944
944
  getFullState() {
945
945
  const { baseState: e, currentIndex: t, patches: s } = this;
946
- let a = JSON.parse(JSON.stringify(e));
947
- for (let n = 0; n < t; n += 1)
948
- a = this.diffPatcher.patch(a, s[n].diff);
949
- return console.log("getFullState state", a), a;
946
+ let n = JSON.parse(JSON.stringify(e));
947
+ for (let a = 0; a < t; a += 1)
948
+ n = this.diffPatcher.patch(n, s[a].diff);
949
+ return console.log("getFullState state", n), n;
950
950
  }
951
951
  /**
952
952
  * Сохраняем текущее состояние в виде диффа от последнего сохранённого полного состояния.
@@ -1015,19 +1015,19 @@ class $ {
1015
1015
  * @fires editor:history-state-loaded
1016
1016
  */
1017
1017
  loadStateFromFullState(e) {
1018
- return j(this, null, function* () {
1018
+ return p(this, null, function* () {
1019
1019
  if (!e) return;
1020
1020
  console.log("loadStateFromFullState fullState", e);
1021
- const { canvas: t, canvasManager: s, interactionBlocker: a, backgroundManager: n } = this.editor, { width: o, height: i } = t;
1022
- a.overlayMask = null, $._serializeCustomData(e), yield t.loadFromJSON(e, (l, u) => {
1023
- $._deserializeCustomData(l, u);
1021
+ const { canvas: t, canvasManager: s, interactionBlocker: n, backgroundManager: a } = this.editor, { width: o, height: i } = t;
1022
+ n.overlayMask = null, K._serializeCustomData(e), yield t.loadFromJSON(e, (l, u) => {
1023
+ K._deserializeCustomData(l, u);
1024
1024
  });
1025
1025
  const r = t.getObjects().find((l) => l.id === "montage-area");
1026
1026
  r && (this.editor.montageArea = r, (o !== t.getWidth() || i !== t.getHeight()) && s.updateCanvas());
1027
1027
  const d = t.getObjects().find((l) => l.id === "overlay-mask");
1028
- d && (a.overlayMask = d, a.overlayMask.visible = !1);
1028
+ d && (n.overlayMask = d, n.overlayMask.visible = !1);
1029
1029
  const h = t.getObjects().find((l) => l.id === "background");
1030
- h ? (n.backgroundObject = h, n.refresh()) : n.removeBackground({ withoutSave: !0 }), t.renderAll(), t.fire("editor:history-state-loaded", {
1030
+ h ? (a.backgroundObject = h, a.refresh()) : a.removeBackground({ withoutSave: !0 }), t.renderAll(), t.fire("editor:history-state-loaded", {
1031
1031
  fullState: e,
1032
1032
  currentIndex: this.currentIndex,
1033
1033
  totalChangesCount: this.totalChangesCount,
@@ -1042,7 +1042,7 @@ class $ {
1042
1042
  * @fires editor:undo
1043
1043
  */
1044
1044
  undo() {
1045
- return j(this, null, function* () {
1045
+ return p(this, null, function* () {
1046
1046
  if (!this.skipHistory) {
1047
1047
  if (this.currentIndex <= 0) {
1048
1048
  console.log("Нет предыдущих состояний для отмены.");
@@ -1079,7 +1079,7 @@ class $ {
1079
1079
  * @fires editor:redo
1080
1080
  */
1081
1081
  redo() {
1082
- return j(this, null, function* () {
1082
+ return p(this, null, function* () {
1083
1083
  if (!this.skipHistory) {
1084
1084
  if (this.currentIndex >= this.patches.length) {
1085
1085
  console.log("Нет состояний для повтора.");
@@ -1112,7 +1112,7 @@ class $ {
1112
1112
  });
1113
1113
  }
1114
1114
  }
1115
- const lt = 0.1, ht = 2, ut = 0.1, gt = 90, U = 16, z = 16, k = 4096, _ = 4096, Ce = "application/image-editor:";
1115
+ const lt = 0.1, ht = 2, ut = 0.1, gt = 90, z = 16, H = 16, k = 4096, _ = 4096, Ce = "application/image-editor:";
1116
1116
  class N {
1117
1117
  constructor({ editor: e }) {
1118
1118
  this.editor = e, this.options = e.options, this._createdBlobUrls = [], this.acceptContentTypes = this.editor.options.acceptContentTypes, this.acceptFormats = this.getAllowedFormatsFromContentTypes();
@@ -1130,17 +1130,17 @@ class N {
1130
1130
  * @returns возвращает Promise с объектом изображения или null в случае ошибки
1131
1131
  */
1132
1132
  importImage(e) {
1133
- return j(this, null, function* () {
1133
+ return p(this, null, function* () {
1134
1134
  const {
1135
1135
  source: t,
1136
1136
  scale: s = `image-${this.options.scaleType}`,
1137
- withoutSave: a = !1,
1138
- fromClipboard: n = !1,
1137
+ withoutSave: n = !1,
1138
+ fromClipboard: a = !1,
1139
1139
  isBackground: o = !1,
1140
1140
  withoutSelection: i = !1
1141
1141
  } = e;
1142
1142
  if (!t) return null;
1143
- const { canvas: r, montageArea: d, transformManager: h, historyManager: l, errorManager: u } = this.editor, g = yield this.getContentType(t), M = N.getFormatFromContentType(g), { acceptContentTypes: m, acceptFormats: p } = this;
1143
+ const { canvas: r, montageArea: d, transformManager: h, historyManager: l, errorManager: u } = this.editor, g = yield this.getContentType(t), M = N.getFormatFromContentType(g), { acceptContentTypes: m, acceptFormats: j } = this;
1144
1144
  if (!this.isAllowedContentType(g)) {
1145
1145
  const f = `Неверный contentType для изображения: ${g}. Ожидается один из: ${this.acceptContentTypes.join(", ")}.`;
1146
1146
  return u.emitError({
@@ -1153,8 +1153,8 @@ class N {
1153
1153
  format: M,
1154
1154
  contentType: g,
1155
1155
  acceptContentTypes: m,
1156
- acceptFormats: p,
1157
- fromClipboard: n,
1156
+ acceptFormats: j,
1157
+ fromClipboard: a,
1158
1158
  isBackground: o,
1159
1159
  withoutSelection: i
1160
1160
  }
@@ -1179,27 +1179,27 @@ class N {
1179
1179
  format: M,
1180
1180
  contentType: g,
1181
1181
  acceptContentTypes: m,
1182
- acceptFormats: p,
1183
- fromClipboard: n,
1182
+ acceptFormats: j,
1183
+ fromClipboard: a,
1184
1184
  isBackground: o,
1185
1185
  withoutSelection: i
1186
1186
  }
1187
1187
  }), null;
1188
1188
  if (this._createdBlobUrls.push(f), M === "svg") {
1189
1189
  const C = yield ke(f);
1190
- b = W.groupSVGElements(C.objects, C.options);
1190
+ b = F.groupSVGElements(C.objects, C.options);
1191
1191
  } else
1192
- b = yield Z.fromURL(f, { crossOrigin: "anonymous" });
1192
+ b = yield Y.fromURL(f, { crossOrigin: "anonymous" });
1193
1193
  const { width: S, height: T } = b;
1194
- if (b instanceof Z) {
1194
+ if (b instanceof Y) {
1195
1195
  const C = b.getElement();
1196
1196
  let D = "";
1197
1197
  if (C instanceof HTMLImageElement ? D = C.src : C instanceof HTMLCanvasElement && (D = C.toDataURL()), T > _ || S > k) {
1198
1198
  const B = yield this.resizeImageToBoundaries(D, "max"), L = URL.createObjectURL(B);
1199
- this._createdBlobUrls.push(L), b = yield Z.fromURL(L, { crossOrigin: "anonymous" });
1200
- } else if (T < z || S < U) {
1199
+ this._createdBlobUrls.push(L), b = yield Y.fromURL(L, { crossOrigin: "anonymous" });
1200
+ } else if (T < H || S < z) {
1201
1201
  const B = yield this.resizeImageToBoundaries(D, "min"), L = URL.createObjectURL(B);
1202
- this._createdBlobUrls.push(L), b = yield Z.fromURL(L, { crossOrigin: "anonymous" });
1202
+ this._createdBlobUrls.push(L), b = yield Y.fromURL(L, { crossOrigin: "anonymous" });
1203
1203
  }
1204
1204
  }
1205
1205
  if (b.set("id", `${b.type}-${A()}`), b.set("format", M), s === "scale-montage")
@@ -1208,19 +1208,19 @@ class N {
1208
1208
  const { width: C, height: D } = d, B = this.calculateScaleFactor({ imageObject: b, scaleType: s });
1209
1209
  s === "image-contain" && B < 1 ? h.fitObject({ object: b, type: "contain", withoutSave: !0 }) : s === "image-cover" && (S > C || T > D) && h.fitObject({ object: b, type: "cover", withoutSave: !0 });
1210
1210
  }
1211
- r.add(b), r.centerObject(b), i || r.setActiveObject(b), r.renderAll(), l.resumeHistory(), a || l.saveState();
1212
- const H = {
1211
+ r.add(b), r.centerObject(b), i || r.setActiveObject(b), r.renderAll(), l.resumeHistory(), n || l.saveState();
1212
+ const Z = {
1213
1213
  image: b,
1214
1214
  format: M,
1215
1215
  contentType: g,
1216
1216
  scale: s,
1217
- withoutSave: a,
1217
+ withoutSave: n,
1218
1218
  source: t,
1219
- fromClipboard: n,
1219
+ fromClipboard: a,
1220
1220
  isBackground: o,
1221
1221
  withoutSelection: i
1222
1222
  };
1223
- return r.fire("editor:image-imported", H), H;
1223
+ return r.fire("editor:image-imported", Z), Z;
1224
1224
  } catch (f) {
1225
1225
  return u.emitError({
1226
1226
  origin: "ImageManager",
@@ -1232,8 +1232,8 @@ class N {
1232
1232
  format: M,
1233
1233
  contentType: g,
1234
1234
  scale: s,
1235
- withoutSave: a,
1236
- fromClipboard: n,
1235
+ withoutSave: n,
1236
+ fromClipboard: a,
1237
1237
  isBackground: o,
1238
1238
  withoutSelection: i
1239
1239
  }
@@ -1250,24 +1250,24 @@ class N {
1250
1250
  * @returns возвращает Promise с Blob-объектом уменьшенного изображения
1251
1251
  */
1252
1252
  resizeImageToBoundaries(e, t = "max") {
1253
- return j(this, null, function* () {
1253
+ return p(this, null, function* () {
1254
1254
  let s = `Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ${k}x${_}`;
1255
- t === "min" && (s = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${U}x${z}`);
1256
- const a = {
1255
+ t === "min" && (s = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${z}x${H}`);
1256
+ const n = {
1257
1257
  dataURL: e,
1258
1258
  sizeType: t,
1259
1259
  maxWidth: k,
1260
1260
  maxHeight: _,
1261
- minWidth: U,
1262
- minHeight: z
1261
+ minWidth: z,
1262
+ minHeight: H
1263
1263
  };
1264
1264
  return this.editor.errorManager.emitWarning({
1265
1265
  origin: "ImageManager",
1266
1266
  method: "resizeImageToBoundaries",
1267
1267
  code: "IMAGE_RESIZE_WARNING",
1268
1268
  message: s,
1269
- data: a
1270
- }), this.editor.workerManager.post("resizeImage", a);
1269
+ data: n
1270
+ }), this.editor.workerManager.post("resizeImage", n);
1271
1271
  });
1272
1272
  }
1273
1273
  /**
@@ -1282,90 +1282,90 @@ class N {
1282
1282
  * @fires editor:canvas-exported
1283
1283
  */
1284
1284
  exportCanvasAsImageFile() {
1285
- return j(this, arguments, function* (e = {}) {
1285
+ return p(this, arguments, function* (e = {}) {
1286
1286
  const {
1287
1287
  fileName: t = "image.png",
1288
1288
  contentType: s = "image/png",
1289
- exportAsBase64: a = !1,
1290
- exportAsBlob: n = !1
1289
+ exportAsBase64: n = !1,
1290
+ exportAsBlob: a = !1
1291
1291
  } = e, { canvas: o, montageArea: i, workerManager: r, interactionBlocker: d } = this.editor;
1292
1292
  try {
1293
1293
  const h = s === "application/pdf", l = h ? "image/jpg" : s, u = N.getFormatFromContentType(l);
1294
1294
  i.setCoords();
1295
- const { left: g, top: M, width: m, height: p } = i.getBoundingRect(), f = yield o.clone(["id", "format", "locked"]);
1295
+ const { left: g, top: M, width: m, height: j } = i.getBoundingRect(), f = yield o.clone(["id", "format", "locked"]);
1296
1296
  f.enableRetinaScaling = !1, ["image/jpg", "image/jpeg"].includes(l) && (f.backgroundColor = "#ffffff");
1297
- const b = f.getObjects().find((y) => y.id === i.id);
1297
+ const b = f.getObjects().find((I) => I.id === i.id);
1298
1298
  if (b && (b.visible = !1), d != null && d.isBlocked) {
1299
- const y = f.getObjects().find((w) => w.id === d.overlayMask.id);
1300
- y && (y.visible = !1);
1299
+ const I = f.getObjects().find((w) => w.id === d.overlayMask.id);
1300
+ I && (I.visible = !1);
1301
1301
  }
1302
- f.viewportTransform = [1, 0, 0, 1, -g, -M], f.setDimensions({ width: m, height: p }, { backstoreOnly: !0 }), f.renderAll();
1303
- const S = f.getObjects().filter((y) => y.format).every((y) => y.format === "svg");
1302
+ f.viewportTransform = [1, 0, 0, 1, -g, -M], f.setDimensions({ width: m, height: j }, { backstoreOnly: !0 }), f.renderAll();
1303
+ const S = f.getObjects().filter((I) => I.format).every((I) => I.format === "svg");
1304
1304
  if (u === "svg" && S) {
1305
- const y = f.toSVG();
1305
+ const I = f.toSVG();
1306
1306
  f.dispose();
1307
- const E = {
1308
- image: N._exportSVGStringAsFile(y, {
1309
- exportAsBase64: a,
1310
- exportAsBlob: n,
1307
+ const O = {
1308
+ image: N._exportSVGStringAsFile(I, {
1309
+ exportAsBase64: n,
1310
+ exportAsBlob: a,
1311
1311
  fileName: t
1312
1312
  }),
1313
1313
  format: "svg",
1314
1314
  contentType: "image/svg+xml",
1315
1315
  fileName: t.replace(/\.[^/.]+$/, ".svg")
1316
1316
  };
1317
- return o.fire("editor:canvas-exported", E), E;
1317
+ return o.fire("editor:canvas-exported", O), O;
1318
1318
  }
1319
- const T = yield new Promise((y, w) => {
1320
- f.getElement().toBlob((E) => {
1321
- E ? y(E) : w(new Error("Failed to create Blob from canvas"));
1319
+ const T = yield new Promise((I, w) => {
1320
+ f.getElement().toBlob((O) => {
1321
+ O ? I(O) : w(new Error("Failed to create Blob from canvas"));
1322
1322
  });
1323
1323
  });
1324
- if (f.dispose(), n) {
1325
- const y = {
1324
+ if (f.dispose(), a) {
1325
+ const I = {
1326
1326
  image: T,
1327
1327
  format: u,
1328
1328
  contentType: l,
1329
1329
  fileName: t
1330
1330
  };
1331
- return o.fire("editor:canvas-exported", y), y;
1331
+ return o.fire("editor:canvas-exported", I), I;
1332
1332
  }
1333
- const H = yield createImageBitmap(T), C = yield r.post(
1333
+ const Z = yield createImageBitmap(T), C = yield r.post(
1334
1334
  "toDataURL",
1335
- { format: u, quality: 1, bitmap: H },
1336
- [H]
1335
+ { format: u, quality: 1, bitmap: Z },
1336
+ [Z]
1337
1337
  );
1338
1338
  if (h) {
1339
- const w = m * 0.264583, E = p * 0.264583, Ee = (yield this.editor.moduleLoader.loadModule("jspdf")).jsPDF, ee = new Ee({
1340
- orientation: w > E ? "landscape" : "portrait",
1339
+ const w = m * 0.264583, O = j * 0.264583, Oe = (yield this.editor.moduleLoader.loadModule("jspdf")).jsPDF, te = new Oe({
1340
+ orientation: w > O ? "landscape" : "portrait",
1341
1341
  unit: "mm",
1342
- format: [w, E]
1342
+ format: [w, O]
1343
1343
  });
1344
- if (ee.addImage(String(C), "JPG", 0, 0, w, E), a) {
1344
+ if (te.addImage(String(C), "JPG", 0, 0, w, O), n) {
1345
1345
  const ge = {
1346
- image: ee.output("datauristring"),
1346
+ image: te.output("datauristring"),
1347
1347
  format: "pdf",
1348
1348
  contentType: "application/pdf",
1349
1349
  fileName: t
1350
1350
  };
1351
1351
  return o.fire("editor:canvas-exported", ge), ge;
1352
1352
  }
1353
- const Oe = ee.output("blob"), ue = {
1354
- image: new File([Oe], t, { type: "application/pdf" }),
1353
+ const Ee = te.output("blob"), ue = {
1354
+ image: new File([Ee], t, { type: "application/pdf" }),
1355
1355
  format: "pdf",
1356
1356
  contentType: "application/pdf",
1357
1357
  fileName: t
1358
1358
  };
1359
1359
  return o.fire("editor:canvas-exported", ue), ue;
1360
1360
  }
1361
- if (a) {
1362
- const y = {
1361
+ if (n) {
1362
+ const I = {
1363
1363
  image: C,
1364
1364
  format: u,
1365
1365
  contentType: l,
1366
1366
  fileName: t
1367
1367
  };
1368
- return o.fire("editor:canvas-exported", y), y;
1368
+ return o.fire("editor:canvas-exported", I), I;
1369
1369
  }
1370
1370
  const D = u === "svg" && !S ? t.replace(/\.[^/.]+$/, ".png") : t, L = {
1371
1371
  image: new File([T], D, { type: l }),
@@ -1380,7 +1380,7 @@ class N {
1380
1380
  method: "exportCanvasAsImageFile",
1381
1381
  code: "IMAGE_EXPORT_FAILED",
1382
1382
  message: `Ошибка экспорта изображения: ${h.message}`,
1383
- data: { contentType: s, fileName: t, exportAsBase64: a, exportAsBlob: n }
1383
+ data: { contentType: s, fileName: t, exportAsBase64: n, exportAsBlob: a }
1384
1384
  }), null;
1385
1385
  }
1386
1386
  });
@@ -1397,12 +1397,12 @@ class N {
1397
1397
  * @fires editor:object-exported
1398
1398
  */
1399
1399
  exportObjectAsImageFile() {
1400
- return j(this, arguments, function* (e = {}) {
1400
+ return p(this, arguments, function* (e = {}) {
1401
1401
  const {
1402
1402
  object: t,
1403
1403
  fileName: s = "image.png",
1404
- contentType: a = "image/png",
1405
- exportAsBase64: n = !1,
1404
+ contentType: n = "image/png",
1405
+ exportAsBase64: a = !1,
1406
1406
  exportAsBlob: o = !1
1407
1407
  } = e, { canvas: i, workerManager: r } = this.editor, d = t || i.getActiveObject();
1408
1408
  if (!d)
@@ -1411,26 +1411,26 @@ class N {
1411
1411
  method: "exportObjectAsImageFile",
1412
1412
  code: "NO_OBJECT_SELECTED",
1413
1413
  message: "Не выбран объект для экспорта",
1414
- data: { contentType: a, fileName: s, exportAsBase64: n, exportAsBlob: o }
1414
+ data: { contentType: n, fileName: s, exportAsBase64: a, exportAsBlob: o }
1415
1415
  }), null;
1416
1416
  try {
1417
- const h = N.getFormatFromContentType(a);
1417
+ const h = N.getFormatFromContentType(n);
1418
1418
  if (h === "svg") {
1419
- const m = d.toSVG(), p = N._exportSVGStringAsFile(m, {
1420
- exportAsBase64: n,
1419
+ const m = d.toSVG(), j = N._exportSVGStringAsFile(m, {
1420
+ exportAsBase64: a,
1421
1421
  exportAsBlob: o,
1422
1422
  fileName: s
1423
1423
  }), f = {
1424
1424
  object: d,
1425
- image: p,
1425
+ image: j,
1426
1426
  format: h,
1427
1427
  contentType: "image/svg+xml",
1428
1428
  fileName: s.replace(/\.[^/.]+$/, ".svg")
1429
1429
  };
1430
1430
  return i.fire("editor:object-exported", f), f;
1431
1431
  }
1432
- if (n && d instanceof Z) {
1433
- const m = yield createImageBitmap(d.getElement()), p = yield r.post(
1432
+ if (a && d instanceof Y) {
1433
+ const m = yield createImageBitmap(d.getElement()), j = yield r.post(
1434
1434
  "toDataURL",
1435
1435
  {
1436
1436
  format: h,
@@ -1440,18 +1440,18 @@ class N {
1440
1440
  [m]
1441
1441
  ), f = {
1442
1442
  object: d,
1443
- image: p,
1443
+ image: j,
1444
1444
  format: h,
1445
- contentType: a,
1445
+ contentType: n,
1446
1446
  fileName: s
1447
1447
  };
1448
1448
  return i.fire("editor:object-exported", f), f;
1449
1449
  }
1450
1450
  const l = d.toCanvasElement({
1451
1451
  enableRetinaScaling: !1
1452
- }), u = yield new Promise((m, p) => {
1452
+ }), u = yield new Promise((m, j) => {
1453
1453
  l.toBlob((f) => {
1454
- f ? m(f) : p(new Error("Failed to create Blob from canvas"));
1454
+ f ? m(f) : j(new Error("Failed to create Blob from canvas"));
1455
1455
  });
1456
1456
  });
1457
1457
  if (o) {
@@ -1459,16 +1459,16 @@ class N {
1459
1459
  object: d,
1460
1460
  image: u,
1461
1461
  format: h,
1462
- contentType: a,
1462
+ contentType: n,
1463
1463
  fileName: s
1464
1464
  };
1465
1465
  return i.fire("editor:object-exported", m), m;
1466
1466
  }
1467
- const g = new File([u], s, { type: a }), M = {
1467
+ const g = new File([u], s, { type: n }), M = {
1468
1468
  object: d,
1469
1469
  image: g,
1470
1470
  format: h,
1471
- contentType: a,
1471
+ contentType: n,
1472
1472
  fileName: s
1473
1473
  };
1474
1474
  return i.fire("editor:object-exported", M), M;
@@ -1478,7 +1478,7 @@ class N {
1478
1478
  method: "exportObjectAsImageFile",
1479
1479
  code: "IMAGE_EXPORT_FAILED",
1480
1480
  message: `Ошибка экспорта объекта: ${h.message}`,
1481
- data: { contentType: a, fileName: s, exportAsBase64: n, exportAsBlob: o }
1481
+ data: { contentType: n, fileName: s, exportAsBase64: a, exportAsBlob: o }
1482
1482
  }), null;
1483
1483
  }
1484
1484
  });
@@ -1510,7 +1510,7 @@ class N {
1510
1510
  * @public
1511
1511
  */
1512
1512
  getContentType(e) {
1513
- return j(this, null, function* () {
1513
+ return p(this, null, function* () {
1514
1514
  return typeof e == "string" ? this.getContentTypeFromUrl(e) : e.type || "application/octet-stream";
1515
1515
  });
1516
1516
  }
@@ -1521,7 +1521,7 @@ class N {
1521
1521
  * @public
1522
1522
  */
1523
1523
  getContentTypeFromUrl(e) {
1524
- return j(this, null, function* () {
1524
+ return p(this, null, function* () {
1525
1525
  if (e.startsWith("data:")) {
1526
1526
  const t = e.match(/^data:([^;]+)/);
1527
1527
  return t ? t[1] : "application/octet-stream";
@@ -1545,11 +1545,11 @@ class N {
1545
1545
  getContentTypeFromExtension(e) {
1546
1546
  var t;
1547
1547
  try {
1548
- const a = (t = new URL(e).pathname.split(".").pop()) == null ? void 0 : t.toLowerCase(), n = {};
1548
+ const n = (t = new URL(e).pathname.split(".").pop()) == null ? void 0 : t.toLowerCase(), a = {};
1549
1549
  return this.acceptContentTypes.forEach((o) => {
1550
1550
  const i = N.getFormatFromContentType(o);
1551
- i && (n[i] = o);
1552
- }), a && n[a] || "application/octet-stream";
1551
+ i && (a[i] = o);
1552
+ }), n && a[n] || "application/octet-stream";
1553
1553
  } catch (s) {
1554
1554
  return console.warn("Не удалось определить расширение из URL:", e, s), "application/octet-stream";
1555
1555
  }
@@ -1567,8 +1567,8 @@ class N {
1567
1567
  }) {
1568
1568
  const { montageArea: s } = this.editor;
1569
1569
  if (!s || !e) return 1;
1570
- const a = s.width, n = s.height, { width: o, height: i } = e;
1571
- return t === "contain" || t === "image-contain" ? Math.min(a / o, n / i) : t === "cover" || t === "image-cover" ? Math.max(a / o, n / i) : 1;
1570
+ const n = s.width, a = s.height, { width: o, height: i } = e;
1571
+ return t === "contain" || t === "image-contain" ? Math.min(n / o, a / i) : t === "cover" || t === "image-cover" ? Math.max(n / o, a / i) : 1;
1572
1572
  }
1573
1573
  /**
1574
1574
  * Преобразует SVG-строку в Blob, файл, или base64
@@ -1584,9 +1584,9 @@ class N {
1584
1584
  static _exportSVGStringAsFile(e, {
1585
1585
  exportAsBase64: t,
1586
1586
  exportAsBlob: s,
1587
- fileName: a = "image.svg"
1587
+ fileName: n = "image.svg"
1588
1588
  } = {}) {
1589
- return s ? new Blob([e], { type: "image/svg+xml" }) : t ? `data:image/svg+xml;base64,${window.btoa(encodeURIComponent(e))}` : new File([e], a.replace(/\.[^/.]+$/, ".svg"), { type: "image/svg+xml" });
1589
+ return s ? new Blob([e], { type: "image/svg+xml" }) : t ? `data:image/svg+xml;base64,${window.btoa(encodeURIComponent(e))}` : new File([e], n.replace(/\.[^/.]+$/, ".svg"), { type: "image/svg+xml" });
1590
1590
  }
1591
1591
  /**
1592
1592
  * Извлекает чистый формат (subtype) из contentType,
@@ -1600,7 +1600,7 @@ class N {
1600
1600
  return t ? t[1] : "";
1601
1601
  }
1602
1602
  }
1603
- const x = (c, e, t) => Math.max(Math.min(c, t), e), Se = (c, e) => c * e, ft = (c, e) => new X(c / 2, e / 2);
1603
+ const x = (c, e, t) => Math.max(Math.min(c, t), e), Se = (c, e) => c * e, ft = (c, e) => new $(c / 2, e / 2);
1604
1604
  function Mt(c) {
1605
1605
  return ((c == null ? void 0 : c.type) === "image" || (c == null ? void 0 : c.format) === "svg") && typeof (c == null ? void 0 : c.width) == "number" && typeof (c == null ? void 0 : c.height) == "number";
1606
1606
  }
@@ -1628,25 +1628,25 @@ class mt {
1628
1628
  * @param options.adaptCanvasToContainer - Адаптировать канвас к контейнеру
1629
1629
  * @fires editor:resolution-width-changed
1630
1630
  */
1631
- setResolutionWidth(e, { preserveProportional: t, withoutSave: s, adaptCanvasToContainer: a } = {}) {
1631
+ setResolutionWidth(e, { preserveProportional: t, withoutSave: s, adaptCanvasToContainer: n } = {}) {
1632
1632
  var M;
1633
1633
  if (!e) return;
1634
1634
  const {
1635
- canvas: n,
1635
+ canvas: a,
1636
1636
  montageArea: o,
1637
1637
  options: { canvasBackstoreWidth: i }
1638
- } = this.editor, { width: r, height: d } = o, h = x(Number(e), U, k);
1639
- if (!i || i === "auto" || a ? this.adaptCanvasToContainer() : i ? this.setCanvasBackstoreWidth(Number(i)) : this.setCanvasBackstoreWidth(h), o.set({ width: h }), (M = n.clipPath) == null || M.set({ width: h }), t) {
1640
- const m = h / r, p = Se(d, m);
1641
- this.setResolutionHeight(p);
1638
+ } = this.editor, { width: r, height: d } = o, h = x(Number(e), z, k);
1639
+ if (!i || i === "auto" || n ? this.adaptCanvasToContainer() : i ? this.setCanvasBackstoreWidth(Number(i)) : this.setCanvasBackstoreWidth(h), o.set({ width: h }), (M = a.clipPath) == null || M.set({ width: h }), t) {
1640
+ const m = h / r, j = Se(d, m);
1641
+ this.setResolutionHeight(j);
1642
1642
  return;
1643
1643
  }
1644
- const { left: l, top: u } = this.getObjectDefaultCoords(o), g = n.getZoom();
1645
- n.setViewportTransform([g, 0, 0, g, l, u]), this.centerMontageArea(), s || this.editor.historyManager.saveState(), n.fire("editor:resolution-width-changed", {
1644
+ const { left: l, top: u } = this.getObjectDefaultCoords(o), g = a.getZoom();
1645
+ a.setViewportTransform([g, 0, 0, g, l, u]), this.centerMontageArea(), s || this.editor.historyManager.saveState(), a.fire("editor:resolution-width-changed", {
1646
1646
  width: h,
1647
1647
  preserveProportional: t,
1648
1648
  withoutSave: s,
1649
- adaptCanvasToContainer: a
1649
+ adaptCanvasToContainer: n
1650
1650
  });
1651
1651
  }
1652
1652
  /**
@@ -1658,25 +1658,25 @@ class mt {
1658
1658
  * @param options.adaptCanvasToContainer - Адаптировать канвас к контейнеру
1659
1659
  * @fires editor:resolution-height-changed
1660
1660
  */
1661
- setResolutionHeight(e, { preserveProportional: t, withoutSave: s, adaptCanvasToContainer: a } = {}) {
1661
+ setResolutionHeight(e, { preserveProportional: t, withoutSave: s, adaptCanvasToContainer: n } = {}) {
1662
1662
  var M;
1663
1663
  if (!e) return;
1664
1664
  const {
1665
- canvas: n,
1665
+ canvas: a,
1666
1666
  montageArea: o,
1667
1667
  options: { canvasBackstoreHeight: i }
1668
- } = this.editor, { width: r, height: d } = o, h = x(Number(e), z, _);
1669
- if (!i || i === "auto" || a ? this.adaptCanvasToContainer() : i ? this.setCanvasBackstoreHeight(Number(i)) : this.setCanvasBackstoreHeight(h), o.set({ height: h }), (M = n.clipPath) == null || M.set({ height: h }), t) {
1670
- const m = h / d, p = Se(r, m);
1671
- this.setResolutionWidth(p);
1668
+ } = this.editor, { width: r, height: d } = o, h = x(Number(e), H, _);
1669
+ if (!i || i === "auto" || n ? this.adaptCanvasToContainer() : i ? this.setCanvasBackstoreHeight(Number(i)) : this.setCanvasBackstoreHeight(h), o.set({ height: h }), (M = a.clipPath) == null || M.set({ height: h }), t) {
1670
+ const m = h / d, j = Se(r, m);
1671
+ this.setResolutionWidth(j);
1672
1672
  return;
1673
1673
  }
1674
- const { left: l, top: u } = this.getObjectDefaultCoords(o), g = n.getZoom();
1675
- n.setViewportTransform([g, 0, 0, g, l, u]), this.centerMontageArea(), s || this.editor.historyManager.saveState(), n.fire("editor:resolution-height-changed", {
1674
+ const { left: l, top: u } = this.getObjectDefaultCoords(o), g = a.getZoom();
1675
+ a.setViewportTransform([g, 0, 0, g, l, u]), this.centerMontageArea(), s || this.editor.historyManager.saveState(), a.fire("editor:resolution-height-changed", {
1676
1676
  height: h,
1677
1677
  preserveProportional: t,
1678
1678
  withoutSave: s,
1679
- adaptCanvasToContainer: a
1679
+ adaptCanvasToContainer: n
1680
1680
  });
1681
1681
  }
1682
1682
  /**
@@ -1685,16 +1685,16 @@ class mt {
1685
1685
  */
1686
1686
  centerMontageArea() {
1687
1687
  var r;
1688
- const { canvas: e, montageArea: t } = this.editor, s = e.getWidth(), a = e.getHeight(), n = e.getZoom(), o = ft(s, a);
1688
+ const { canvas: e, montageArea: t } = this.editor, s = e.getWidth(), n = e.getHeight(), a = e.getZoom(), o = ft(s, n);
1689
1689
  t.set({
1690
1690
  left: s / 2,
1691
- top: a / 2
1691
+ top: n / 2
1692
1692
  }), (r = e.clipPath) == null || r.set({
1693
1693
  left: s / 2,
1694
- top: a / 2
1694
+ top: n / 2
1695
1695
  }), e.renderAll();
1696
1696
  const i = e.viewportTransform;
1697
- i[4] = s / 2 - o.x * n, i[5] = a / 2 - o.y * n, e.setViewportTransform(i), e.renderAll();
1697
+ i[4] = s / 2 - o.x * a, i[5] = n / 2 - o.y * a, e.setViewportTransform(i), e.renderAll();
1698
1698
  }
1699
1699
  /**
1700
1700
  * Метод для получения координат объекта с учетом текущего зума
@@ -1710,7 +1710,7 @@ class mt {
1710
1710
  code: "NO_ACTIVE_OBJECT",
1711
1711
  message: "Не выбран объект для получения координат"
1712
1712
  }), { left: 0, top: 0 };
1713
- const { width: a, height: n } = s, o = t.getZoom(), i = (a - a * o) / 2, r = (n - n * o) / 2;
1713
+ const { width: n, height: a } = s, o = t.getZoom(), i = (n - n * o) / 2, r = (a - a * o) / 2;
1714
1714
  return { left: i, top: r };
1715
1715
  }
1716
1716
  /**
@@ -1718,7 +1718,7 @@ class mt {
1718
1718
  */
1719
1719
  setCanvasBackstoreWidth(e) {
1720
1720
  if (!e || typeof e != "number") return;
1721
- const t = x(e, U, k);
1721
+ const t = x(e, z, k);
1722
1722
  this.editor.canvas.setDimensions({ width: t }, { backstoreOnly: !0 });
1723
1723
  }
1724
1724
  /**
@@ -1727,7 +1727,7 @@ class mt {
1727
1727
  */
1728
1728
  setCanvasBackstoreHeight(e) {
1729
1729
  if (!e || typeof e != "number") return;
1730
- const t = x(e, z, _);
1730
+ const t = x(e, H, _);
1731
1731
  this.editor.canvas.setDimensions({ height: t }, { backstoreOnly: !0 });
1732
1732
  }
1733
1733
  /**
@@ -1736,8 +1736,8 @@ class mt {
1736
1736
  * с учётом минимальных и максимальных значений.
1737
1737
  */
1738
1738
  adaptCanvasToContainer() {
1739
- const { canvas: e } = this.editor, t = this.getEditorContainer(), s = t.clientWidth, a = t.clientHeight, n = x(s, U, k), o = x(a, z, _);
1740
- e.setDimensions({ width: n, height: o }, { backstoreOnly: !0 });
1739
+ const { canvas: e } = this.editor, t = this.getEditorContainer(), s = t.clientWidth, n = t.clientHeight, a = x(s, z, k), o = x(n, H, _);
1740
+ e.setDimensions({ width: a, height: o }, { backstoreOnly: !0 });
1741
1741
  }
1742
1742
  /**
1743
1743
  * Обновляет размеры канваса без изменения позиций объектов.
@@ -1750,11 +1750,11 @@ class mt {
1750
1750
  montageArea: t,
1751
1751
  montageArea: {
1752
1752
  width: s,
1753
- height: a
1753
+ height: n
1754
1754
  }
1755
- } = this.editor, n = t.left, o = t.top;
1756
- this.setResolutionWidth(s, { adaptCanvasToContainer: !0, withoutSave: !0 }), this.setResolutionHeight(a, { adaptCanvasToContainer: !0, withoutSave: !0 }), this.centerMontageArea();
1757
- const i = t.left - n, r = t.top - o;
1755
+ } = this.editor, a = t.left, o = t.top;
1756
+ this.setResolutionWidth(s, { adaptCanvasToContainer: !0, withoutSave: !0 }), this.setResolutionHeight(n, { adaptCanvasToContainer: !0, withoutSave: !0 }), this.centerMontageArea();
1757
+ const i = t.left - a, r = t.top - o;
1758
1758
  if (i !== 0 || r !== 0) {
1759
1759
  const d = e.getActiveObject(), h = [];
1760
1760
  if ((d == null ? void 0 : d.type) === "activeselection") {
@@ -1770,7 +1770,7 @@ class mt {
1770
1770
  if (h.length === 1)
1771
1771
  e.setActiveObject(h[0]);
1772
1772
  else {
1773
- const l = new v(h, {
1773
+ const l = new y(h, {
1774
1774
  canvas: e
1775
1775
  });
1776
1776
  e.setActiveObject(l);
@@ -1778,7 +1778,7 @@ class mt {
1778
1778
  }
1779
1779
  e.renderAll(), e.fire("editor:canvas-updated", {
1780
1780
  width: s,
1781
- height: a
1781
+ height: n
1782
1782
  });
1783
1783
  }
1784
1784
  /**
@@ -1888,32 +1888,32 @@ class mt {
1888
1888
  */
1889
1889
  setDisplayDimension({ element: e = "canvas", dimension: t, value: s } = {}) {
1890
1890
  if (!s) return;
1891
- const { canvas: a } = this.editor, n = [];
1891
+ const { canvas: n } = this.editor, a = [];
1892
1892
  switch (e) {
1893
1893
  case "canvas":
1894
- n.push(a.lowerCanvasEl, a.upperCanvasEl);
1894
+ a.push(n.lowerCanvasEl, n.upperCanvasEl);
1895
1895
  break;
1896
1896
  case "wrapper":
1897
- n.push(a.wrapperEl);
1897
+ a.push(n.wrapperEl);
1898
1898
  break;
1899
1899
  case "container":
1900
- n.push(this.getEditorContainer());
1900
+ a.push(this.getEditorContainer());
1901
1901
  break;
1902
1902
  default:
1903
- n.push(a.lowerCanvasEl, a.upperCanvasEl);
1903
+ a.push(n.lowerCanvasEl, n.upperCanvasEl);
1904
1904
  }
1905
1905
  const o = t === "width" ? "width" : "height";
1906
1906
  if (typeof s == "string") {
1907
- n.forEach((r) => {
1907
+ a.forEach((r) => {
1908
1908
  r.style[o] = s;
1909
1909
  });
1910
1910
  return;
1911
1911
  }
1912
1912
  if (isNaN(s)) return;
1913
1913
  const i = `${s}px`;
1914
- n.forEach((r) => {
1914
+ a.forEach((r) => {
1915
1915
  r.style[o] = i;
1916
- }), a.fire(`editor:display-${e}-${o}-changed`, {
1916
+ }), n.fire(`editor:display-${e}-${o}-changed`, {
1917
1917
  element: e,
1918
1918
  value: s
1919
1919
  });
@@ -1928,14 +1928,14 @@ class mt {
1928
1928
  */
1929
1929
  scaleMontageAreaToImage({ object: e, preserveAspectRatio: t, withoutSave: s } = {}) {
1930
1930
  const {
1931
- canvas: a,
1932
- montageArea: n,
1931
+ canvas: n,
1932
+ montageArea: a,
1933
1933
  transformManager: o,
1934
1934
  options: {
1935
1935
  montageAreaWidth: i,
1936
1936
  montageAreaHeight: r
1937
1937
  }
1938
- } = this.editor, d = e || a.getActiveObject();
1938
+ } = this.editor, d = e || n.getActiveObject();
1939
1939
  if (!Mt(d)) return;
1940
1940
  const { width: h, height: l } = d;
1941
1941
  let u = Math.min(h, k), g = Math.min(l, _);
@@ -1943,10 +1943,10 @@ class mt {
1943
1943
  const {
1944
1944
  width: M,
1945
1945
  height: m
1946
- } = n, p = h / M, f = l / m, b = Math.max(p, f);
1946
+ } = a, j = h / M, f = l / m, b = Math.max(j, f);
1947
1947
  u = M * b, g = m * b;
1948
1948
  }
1949
- this.setResolutionWidth(u, { withoutSave: !0 }), this.setResolutionHeight(g, { withoutSave: !0 }), this.editor.backgroundManager.backgroundObject && this.editor.backgroundManager.refresh(), (h > i || l > r) && o.calculateAndApplyDefaultZoom(), o.resetObject({ object: d, withoutSave: !0 }), a.centerObject(d), a.renderAll(), s || this.editor.historyManager.saveState(), a.fire("editor:montage-area-scaled-to-image", {
1949
+ this.setResolutionWidth(u, { withoutSave: !0 }), this.setResolutionHeight(g, { withoutSave: !0 }), this.editor.backgroundManager.backgroundObject && this.editor.backgroundManager.refresh(), (h > i || l > r) && o.calculateAndApplyDefaultZoom(), o.resetObject({ object: d, withoutSave: !0 }), n.centerObject(d), n.renderAll(), s || this.editor.historyManager.saveState(), n.fire("editor:montage-area-scaled-to-image", {
1950
1950
  object: d,
1951
1951
  width: u,
1952
1952
  height: g,
@@ -1972,13 +1972,13 @@ class mt {
1972
1972
  const {
1973
1973
  canvas: t,
1974
1974
  transformManager: s,
1975
- historyManager: a,
1975
+ historyManager: n,
1976
1976
  options: {
1977
- montageAreaWidth: n,
1977
+ montageAreaWidth: a,
1978
1978
  montageAreaHeight: o
1979
1979
  }
1980
1980
  } = this.editor;
1981
- s.resetZoom(), this.setResolutionWidth(n, { withoutSave: !0 }), this.setResolutionHeight(o, { withoutSave: !0 }), t.renderAll(), s.resetObjects(), e || a.saveState(), t.fire("editor:default-scale-set");
1981
+ s.resetZoom(), this.setResolutionWidth(a, { withoutSave: !0 }), this.setResolutionHeight(o, { withoutSave: !0 }), t.renderAll(), s.resetObjects(), e || n.saveState(), t.fire("editor:default-scale-set");
1982
1982
  }
1983
1983
  /**
1984
1984
  * Получение всех объектов внутри монтажной области редактора
@@ -1989,10 +1989,10 @@ class mt {
1989
1989
  canvas: e,
1990
1990
  montageArea: t,
1991
1991
  interactionBlocker: { overlayMask: s },
1992
- backgroundManager: { backgroundObject: a }
1992
+ backgroundManager: { backgroundObject: n }
1993
1993
  } = this.editor;
1994
1994
  return e.getObjects().filter(
1995
- (o) => o.id !== t.id && o.id !== (s == null ? void 0 : s.id) && o.id !== (a == null ? void 0 : a.id)
1995
+ (o) => o.id !== t.id && o.id !== (s == null ? void 0 : s.id) && o.id !== (n == null ? void 0 : n.id)
1996
1996
  );
1997
1997
  }
1998
1998
  }
@@ -2008,7 +2008,7 @@ class bt {
2008
2008
  * @param scale - Желаемый масштаб относительно размеров контейнера редактора.
2009
2009
  */
2010
2010
  calculateAndApplyDefaultZoom(e = this.options.defaultScale) {
2011
- const { canvas: t } = this.editor, s = t.editorContainer, a = s.clientWidth, n = s.clientHeight, { width: o, height: i } = this.editor.montageArea, r = a / o * e, d = n / i * e;
2011
+ const { canvas: t } = this.editor, s = t.editorContainer, n = s.clientWidth, a = s.clientHeight, { width: o, height: i } = this.editor.montageArea, r = n / o * e, d = a / i * e;
2012
2012
  this.defaultZoom = Math.min(r, d), this.setZoom();
2013
2013
  }
2014
2014
  /**
@@ -2023,10 +2023,10 @@ class bt {
2023
2023
  zoom(e = ut, t = {}) {
2024
2024
  var u, g;
2025
2025
  if (!e) return;
2026
- const { minZoom: s, maxZoom: a } = this, { canvas: n } = this.editor, o = n.getZoom(), i = n.getCenterPoint(), r = (u = t.pointX) != null ? u : i.x, d = (g = t.pointY) != null ? g : i.y, h = new X(r, d);
2026
+ const { minZoom: s, maxZoom: n } = this, { canvas: a } = this.editor, o = a.getZoom(), i = a.getCenterPoint(), r = (u = t.pointX) != null ? u : i.x, d = (g = t.pointY) != null ? g : i.y, h = new $(r, d);
2027
2027
  let l = Number((o + Number(e)).toFixed(2));
2028
- l > a && (l = a), l < s && (l = s), n.zoomToPoint(h, l), n.fire("editor:zoom-changed", {
2029
- currentZoom: n.getZoom(),
2028
+ l > n && (l = n), l < s && (l = s), a.zoomToPoint(h, l), a.fire("editor:zoom-changed", {
2029
+ currentZoom: a.getZoom(),
2030
2030
  zoom: l,
2031
2031
  point: h
2032
2032
  });
@@ -2037,12 +2037,12 @@ class bt {
2037
2037
  * @fires editor:zoom-changed
2038
2038
  */
2039
2039
  setZoom(e = this.defaultZoom) {
2040
- const { minZoom: t, maxZoom: s } = this, { canvas: a } = this.editor, n = new X(a.getCenterPoint());
2040
+ const { minZoom: t, maxZoom: s } = this, { canvas: n } = this.editor, a = new $(n.getCenterPoint());
2041
2041
  let o = e;
2042
- e > s && (o = s), e < t && (o = t), a.zoomToPoint(n, o), a.fire("editor:zoom-changed", {
2043
- currentZoom: a.getZoom(),
2042
+ e > s && (o = s), e < t && (o = t), n.zoomToPoint(a, o), n.fire("editor:zoom-changed", {
2043
+ currentZoom: n.getZoom(),
2044
2044
  zoom: o,
2045
- point: n
2045
+ point: a
2046
2046
  });
2047
2047
  }
2048
2048
  /**
@@ -2050,7 +2050,7 @@ class bt {
2050
2050
  * @fires editor:zoom-changed
2051
2051
  */
2052
2052
  resetZoom() {
2053
- const { canvas: e } = this.editor, t = new X(e.getCenterPoint());
2053
+ const { canvas: e } = this.editor, t = new $(e.getCenterPoint());
2054
2054
  e.zoomToPoint(t, this.defaultZoom), this.editor.canvas.fire("editor:zoom-changed", {
2055
2055
  currentZoom: e.getZoom(),
2056
2056
  point: t
@@ -2064,11 +2064,11 @@ class bt {
2064
2064
  * @fires editor:object-rotated
2065
2065
  */
2066
2066
  rotate(e = gt, { withoutSave: t } = {}) {
2067
- const { canvas: s, historyManager: a } = this.editor, n = s.getActiveObject();
2068
- if (!n) return;
2069
- const o = n.angle + e;
2070
- n.rotate(o), n.setCoords(), s.renderAll(), t || a.saveState(), s.fire("editor:object-rotated", {
2071
- object: n,
2067
+ const { canvas: s, historyManager: n } = this.editor, a = s.getActiveObject();
2068
+ if (!a) return;
2069
+ const o = a.angle + e;
2070
+ a.rotate(o), a.setCoords(), s.renderAll(), t || n.saveState(), s.fire("editor:object-rotated", {
2071
+ object: a,
2072
2072
  withoutSave: t,
2073
2073
  angle: o
2074
2074
  });
@@ -2080,9 +2080,9 @@ class bt {
2080
2080
  * @fires editor:object-flipped-x
2081
2081
  */
2082
2082
  flipX({ withoutSave: e } = {}) {
2083
- const { canvas: t, historyManager: s } = this.editor, a = t.getActiveObject();
2084
- a && (a.flipX = !a.flipX, t.renderAll(), e || s.saveState(), t.fire("editor:object-flipped-x", {
2085
- object: a,
2083
+ const { canvas: t, historyManager: s } = this.editor, n = t.getActiveObject();
2084
+ n && (n.flipX = !n.flipX, t.renderAll(), e || s.saveState(), t.fire("editor:object-flipped-x", {
2085
+ object: n,
2086
2086
  withoutSave: e
2087
2087
  }));
2088
2088
  }
@@ -2093,9 +2093,9 @@ class bt {
2093
2093
  * @fires editor:object-flipped-y
2094
2094
  */
2095
2095
  flipY({ withoutSave: e } = {}) {
2096
- const { canvas: t, historyManager: s } = this.editor, a = t.getActiveObject();
2097
- a && (a.flipY = !a.flipY, t.renderAll(), e || s.saveState(), t.fire("editor:object-flipped-y", {
2098
- object: a,
2096
+ const { canvas: t, historyManager: s } = this.editor, n = t.getActiveObject();
2097
+ n && (n.flipY = !n.flipY, t.renderAll(), e || s.saveState(), t.fire("editor:object-flipped-y", {
2098
+ object: n,
2099
2099
  withoutSave: e
2100
2100
  }));
2101
2101
  }
@@ -2112,10 +2112,10 @@ class bt {
2112
2112
  opacity: t = 1,
2113
2113
  withoutSave: s
2114
2114
  } = {}) {
2115
- const { canvas: a, historyManager: n } = this.editor, o = e || a.getActiveObject();
2116
- o && (o instanceof v ? o.getObjects().forEach((i) => {
2115
+ const { canvas: n, historyManager: a } = this.editor, o = e || n.getActiveObject();
2116
+ o && (o instanceof y ? o.getObjects().forEach((i) => {
2117
2117
  i.set("opacity", t);
2118
- }) : o.set("opacity", t), a.renderAll(), s || n.saveState(), a.fire("editor:object-opacity-changed", {
2118
+ }) : o.set("opacity", t), n.renderAll(), s || a.saveState(), n.fire("editor:object-opacity-changed", {
2119
2119
  object: o,
2120
2120
  opacity: t,
2121
2121
  withoutSave: s
@@ -2136,24 +2136,24 @@ class bt {
2136
2136
  object: e,
2137
2137
  type: t = this.options.scaleType,
2138
2138
  withoutSave: s,
2139
- fitAsOneObject: a
2139
+ fitAsOneObject: n
2140
2140
  } = {}) {
2141
- const { canvas: n, historyManager: o } = this.editor, i = e || n.getActiveObject();
2141
+ const { canvas: a, historyManager: o } = this.editor, i = e || a.getActiveObject();
2142
2142
  if (i) {
2143
- if (i instanceof v && !a) {
2143
+ if (i instanceof y && !n) {
2144
2144
  const r = i.getObjects();
2145
- n.discardActiveObject(), r.forEach((h) => {
2145
+ a.discardActiveObject(), r.forEach((h) => {
2146
2146
  this._fitSingleObject(h, t);
2147
2147
  });
2148
- const d = new v(r, { canvas: n });
2149
- n.setActiveObject(d);
2148
+ const d = new y(r, { canvas: a });
2149
+ a.setActiveObject(d);
2150
2150
  } else
2151
2151
  this._fitSingleObject(i, t);
2152
- n.renderAll(), s || o.saveState(), n.fire("editor:object-fitted", {
2152
+ a.renderAll(), s || o.saveState(), a.fire("editor:object-fitted", {
2153
2153
  object: i,
2154
2154
  type: t,
2155
2155
  withoutSave: s,
2156
- fitAsOneObject: a
2156
+ fitAsOneObject: n
2157
2157
  });
2158
2158
  }
2159
2159
  }
@@ -2164,9 +2164,9 @@ class bt {
2164
2164
  * @private
2165
2165
  */
2166
2166
  _fitSingleObject(e, t) {
2167
- const { canvas: s, montageArea: a } = this.editor, { width: n, height: o, scaleX: i = 1, scaleY: r = 1, angle: d = 0 } = e, h = n * Math.abs(i), l = o * Math.abs(r), u = d * Math.PI / 180, g = Math.abs(Math.cos(u)), M = Math.abs(Math.sin(u)), m = h * g + l * M, p = h * M + l * g, f = a.width, b = a.height;
2167
+ const { canvas: s, montageArea: n } = this.editor, { width: a, height: o, scaleX: i = 1, scaleY: r = 1, angle: d = 0 } = e, h = a * Math.abs(i), l = o * Math.abs(r), u = d * Math.PI / 180, g = Math.abs(Math.cos(u)), M = Math.abs(Math.sin(u)), m = h * g + l * M, j = h * M + l * g, f = n.width, b = n.height;
2168
2168
  let S;
2169
- t === "contain" ? S = Math.min(f / m, b / p) : S = Math.max(f / m, b / p), e.set({
2169
+ t === "contain" ? S = Math.min(f / m, b / j) : S = Math.max(f / m, b / j), e.set({
2170
2170
  scaleX: i * S,
2171
2171
  scaleY: r * S
2172
2172
  }), s.centerObject(e);
@@ -2189,12 +2189,12 @@ class bt {
2189
2189
  */
2190
2190
  resetObject({ object: e, alwaysFitObject: t = !1, withoutSave: s = !1 } = {}) {
2191
2191
  const {
2192
- canvas: a,
2193
- montageArea: n,
2192
+ canvas: n,
2193
+ montageArea: a,
2194
2194
  imageManager: o,
2195
2195
  historyManager: i,
2196
2196
  options: { scaleType: r }
2197
- } = this.editor, d = e || a.getActiveObject();
2197
+ } = this.editor, d = e || n.getActiveObject();
2198
2198
  if (!d || d.locked) return;
2199
2199
  if (i.suspendHistory(), d.type === "image" || d.format === "svg" || d.set({
2200
2200
  scaleX: 1,
@@ -2205,20 +2205,20 @@ class bt {
2205
2205
  }), t)
2206
2206
  this.fitObject({ object: d, withoutSave: !0, fitAsOneObject: !0 });
2207
2207
  else {
2208
- const { width: l, height: u } = n, { width: g, height: M } = d, m = o.calculateScaleFactor({
2208
+ const { width: l, height: u } = a, { width: g, height: M } = d, m = o.calculateScaleFactor({
2209
2209
  imageObject: d,
2210
2210
  scaleType: r
2211
2211
  });
2212
2212
  r === "contain" && m < 1 || r === "cover" && (g > l || M > u) ? this.fitObject({ object: d, withoutSave: !0, fitAsOneObject: !0 }) : d.set({ scaleX: 1, scaleY: 1 });
2213
2213
  }
2214
- d.set({ flipX: !1, flipY: !1, angle: 0 }), a.centerObject(d), a.renderAll(), i.resumeHistory(), s || i.saveState(), a.fire("editor:object-reset", {
2214
+ d.set({ flipX: !1, flipY: !1, angle: 0 }), n.centerObject(d), n.renderAll(), i.resumeHistory(), s || i.saveState(), n.fire("editor:object-reset", {
2215
2215
  object: d,
2216
2216
  withoutSave: s,
2217
2217
  alwaysFitObject: t
2218
2218
  });
2219
2219
  }
2220
2220
  }
2221
- class jt {
2221
+ class pt {
2222
2222
  constructor({ editor: e }) {
2223
2223
  this.editor = e, this.isBlocked = !1, this.overlayMask = null, this._createOverlay();
2224
2224
  }
@@ -2248,8 +2248,8 @@ class jt {
2248
2248
  const { canvas: e, montageArea: t, historyManager: s } = this.editor;
2249
2249
  if (!t || !this.overlayMask) return;
2250
2250
  s.suspendHistory(), t.setCoords();
2251
- const { left: a, top: n, width: o, height: i } = t.getBoundingRect();
2252
- this.overlayMask.set({ left: a, top: n, width: o, height: i }), e.discardActiveObject(), this.editor.layerManager.bringToFront(this.overlayMask, { withoutSave: !0 }), s.resumeHistory();
2251
+ const { left: n, top: a, width: o, height: i } = t.getBoundingRect();
2252
+ this.overlayMask.set({ left: n, top: a, width: o, height: i }), e.discardActiveObject(), this.editor.layerManager.bringToFront(this.overlayMask, { withoutSave: !0 }), s.resumeHistory();
2253
2253
  }
2254
2254
  /**
2255
2255
  * Выключает редактор:
@@ -2260,8 +2260,8 @@ class jt {
2260
2260
  block() {
2261
2261
  if (this.isBlocked || !this.overlayMask) return;
2262
2262
  const { canvas: e, canvasManager: t, historyManager: s } = this.editor;
2263
- s.suspendHistory(), this.isBlocked = !0, e.discardActiveObject(), e.selection = !1, e.skipTargetFind = !0, t.getObjects().forEach((a) => {
2264
- a.evented = !1, a.selectable = !1;
2263
+ s.suspendHistory(), this.isBlocked = !0, e.discardActiveObject(), e.selection = !1, e.skipTargetFind = !0, t.getObjects().forEach((n) => {
2264
+ n.evented = !1, n.selectable = !1;
2265
2265
  }), e.upperCanvasEl.style.pointerEvents = "none", e.lowerCanvasEl.style.pointerEvents = "none", this.overlayMask.visible = !0, this.refresh(), e.fire("editor:disabled"), s.resumeHistory();
2266
2266
  }
2267
2267
  /**
@@ -2270,12 +2270,12 @@ class jt {
2270
2270
  unblock() {
2271
2271
  if (!this.isBlocked || !this.overlayMask) return;
2272
2272
  const { canvas: e, canvasManager: t, historyManager: s } = this.editor;
2273
- s.suspendHistory(), this.isBlocked = !1, e.selection = !0, e.skipTargetFind = !1, t.getObjects().forEach((a) => {
2274
- a.evented = !0, a.selectable = !0;
2273
+ s.suspendHistory(), this.isBlocked = !1, e.selection = !0, e.skipTargetFind = !1, t.getObjects().forEach((n) => {
2274
+ n.evented = !0, n.selectable = !0;
2275
2275
  }), e.upperCanvasEl.style.pointerEvents = "", e.lowerCanvasEl.style.pointerEvents = "", this.overlayMask.visible = !1, e.requestRenderAll(), e.fire("editor:enabled"), s.resumeHistory();
2276
2276
  }
2277
2277
  }
2278
- class R {
2278
+ class U {
2279
2279
  constructor({ editor: e }) {
2280
2280
  this.editor = e, this.backgroundObject = null;
2281
2281
  }
@@ -2290,12 +2290,12 @@ class R {
2290
2290
  customData: t = {},
2291
2291
  withoutSave: s = !1
2292
2292
  }) {
2293
- var a;
2293
+ var n;
2294
2294
  try {
2295
- const { historyManager: n } = this.editor, { backgroundObject: o } = this;
2296
- if (n.suspendHistory(), o && o.backgroundType === "color") {
2295
+ const { historyManager: a } = this.editor, { backgroundObject: o } = this;
2296
+ if (a.suspendHistory(), o && o.backgroundType === "color") {
2297
2297
  if (o.fill === e) {
2298
- n.resumeHistory();
2298
+ a.resumeHistory();
2299
2299
  return;
2300
2300
  }
2301
2301
  o.set({
@@ -2304,14 +2304,14 @@ class R {
2304
2304
  }), this.editor.canvas.requestRenderAll();
2305
2305
  } else
2306
2306
  this._removeCurrentBackground(), this._createColorBackground(e);
2307
- (a = this.backgroundObject) == null || a.set({ customData: t }), this.editor.canvas.fire("editor:background:changed", { type: "color", color: e }), n.resumeHistory(), s || n.saveState();
2308
- } catch (n) {
2307
+ (n = this.backgroundObject) == null || n.set({ customData: t }), this.editor.canvas.fire("editor:background:changed", { type: "color", color: e }), a.resumeHistory(), s || a.saveState();
2308
+ } catch (a) {
2309
2309
  this.editor.errorManager.emitError({
2310
2310
  code: "BACKGROUND_CREATION_FAILED",
2311
2311
  origin: "BackgroundManager",
2312
2312
  method: "setColorBackground",
2313
2313
  message: "Не удалось установить цветовой фон",
2314
- data: { error: n }
2314
+ data: { error: a }
2315
2315
  });
2316
2316
  }
2317
2317
  }
@@ -2326,13 +2326,13 @@ class R {
2326
2326
  customData: t = {},
2327
2327
  withoutSave: s = !1
2328
2328
  }) {
2329
- var a;
2329
+ var n;
2330
2330
  try {
2331
- const { historyManager: n } = this.editor, { backgroundObject: o } = this;
2332
- if (n.suspendHistory(), o && o.backgroundType === "gradient") {
2333
- const i = R._createFabricGradient(e);
2334
- if (R._isGradientEqual(o.fill, i)) {
2335
- n.resumeHistory();
2331
+ const { historyManager: a } = this.editor, { backgroundObject: o } = this;
2332
+ if (a.suspendHistory(), o && o.backgroundType === "gradient") {
2333
+ const i = U._createFabricGradient(e);
2334
+ if (U._isGradientEqual(o.fill, i)) {
2335
+ a.resumeHistory();
2336
2336
  return;
2337
2337
  }
2338
2338
  o.set({
@@ -2341,17 +2341,17 @@ class R {
2341
2341
  }), this.editor.canvas.requestRenderAll();
2342
2342
  } else
2343
2343
  this._removeCurrentBackground(), this._createGradientBackground(e);
2344
- (a = this.backgroundObject) == null || a.set({ customData: t }), this.editor.canvas.fire("editor:background:changed", {
2344
+ (n = this.backgroundObject) == null || n.set({ customData: t }), this.editor.canvas.fire("editor:background:changed", {
2345
2345
  type: "gradient",
2346
2346
  gradientParams: e
2347
- }), n.resumeHistory(), s || n.saveState();
2348
- } catch (n) {
2347
+ }), a.resumeHistory(), s || a.saveState();
2348
+ } catch (a) {
2349
2349
  this.editor.errorManager.emitError({
2350
2350
  code: "BACKGROUND_CREATION_FAILED",
2351
2351
  origin: "BackgroundManager",
2352
2352
  method: "setGradientBackground",
2353
2353
  message: "Не удалось установить градиентный фон",
2354
- data: { error: n }
2354
+ data: { error: a }
2355
2355
  });
2356
2356
  }
2357
2357
  }
@@ -2363,8 +2363,8 @@ class R {
2363
2363
  angle: e,
2364
2364
  startColor: t,
2365
2365
  endColor: s,
2366
- startPosition: a,
2367
- endPosition: n,
2366
+ startPosition: n,
2367
+ endPosition: a,
2368
2368
  customData: o = {},
2369
2369
  withoutSave: i = !1
2370
2370
  }) {
@@ -2374,8 +2374,8 @@ class R {
2374
2374
  angle: e,
2375
2375
  startColor: t,
2376
2376
  endColor: s,
2377
- startPosition: a,
2378
- endPosition: n
2377
+ startPosition: n,
2378
+ endPosition: a
2379
2379
  },
2380
2380
  customData: o,
2381
2381
  withoutSave: i
@@ -2389,8 +2389,8 @@ class R {
2389
2389
  centerX: e,
2390
2390
  centerY: t,
2391
2391
  radius: s,
2392
- startColor: a,
2393
- endColor: n,
2392
+ startColor: n,
2393
+ endColor: a,
2394
2394
  startPosition: o,
2395
2395
  endPosition: i,
2396
2396
  customData: r = {},
@@ -2402,8 +2402,8 @@ class R {
2402
2402
  centerX: e,
2403
2403
  centerY: t,
2404
2404
  radius: s,
2405
- startColor: a,
2406
- endColor: n,
2405
+ startColor: n,
2406
+ endColor: a,
2407
2407
  startPosition: o,
2408
2408
  endPosition: i
2409
2409
  },
@@ -2417,26 +2417,26 @@ class R {
2417
2417
  * @param options.imageUrl - URL изображения
2418
2418
  * @param options.withoutSave - Если true, не сохранять состояние в историю
2419
2419
  */
2420
- setImageBackground(a) {
2421
- return j(this, arguments, function* ({
2420
+ setImageBackground(n) {
2421
+ return p(this, arguments, function* ({
2422
2422
  imageSource: e,
2423
2423
  customData: t = {},
2424
2424
  withoutSave: s = !1
2425
2425
  }) {
2426
2426
  try {
2427
- const { historyManager: n } = this.editor;
2428
- n.suspendHistory(), yield this._createImageBackground(e, t), this.editor.canvas.fire("editor:background:changed", {
2427
+ const { historyManager: a } = this.editor;
2428
+ a.suspendHistory(), yield this._createImageBackground(e, t), this.editor.canvas.fire("editor:background:changed", {
2429
2429
  type: "image",
2430
2430
  imageSource: e,
2431
2431
  backgroundObject: this.backgroundObject
2432
- }), n.resumeHistory(), s || n.saveState();
2433
- } catch (n) {
2432
+ }), a.resumeHistory(), s || a.saveState();
2433
+ } catch (a) {
2434
2434
  this.editor.errorManager.emitError({
2435
2435
  code: "BACKGROUND_CREATION_FAILED",
2436
2436
  origin: "BackgroundManager",
2437
2437
  method: "setImageBackground",
2438
2438
  message: "Не удалось установить изображение в качестве фона",
2439
- data: { error: n }
2439
+ data: { error: a }
2440
2440
  });
2441
2441
  }
2442
2442
  });
@@ -2468,8 +2468,8 @@ class R {
2468
2468
  const { canvas: e, montageArea: t, historyManager: s } = this.editor;
2469
2469
  if (!t || !this.backgroundObject) return;
2470
2470
  s.suspendHistory(), this.editor.transformManager.fitObject({ object: this.backgroundObject, withoutSave: !0, type: "cover" });
2471
- const a = e.getObjects(), n = a.indexOf(t), o = a.indexOf(this.backgroundObject);
2472
- this.backgroundObject && o !== n + 1 && e.moveObjectTo(this.backgroundObject, n + 1), e.requestRenderAll(), s.resumeHistory();
2471
+ const n = e.getObjects(), a = n.indexOf(t), o = n.indexOf(this.backgroundObject);
2472
+ this.backgroundObject && o !== a + 1 && e.moveObjectTo(this.backgroundObject, a + 1), e.requestRenderAll(), s.resumeHistory();
2473
2473
  }
2474
2474
  /**
2475
2475
  * Создает цветовой фон.
@@ -2503,7 +2503,7 @@ class R {
2503
2503
  backgroundType: "gradient",
2504
2504
  backgroundId: `background-${A()}`
2505
2505
  }, { withoutSelection: !0 }), this.refresh();
2506
- const t = R._createFabricGradient(e);
2506
+ const t = U._createFabricGradient(e);
2507
2507
  this.backgroundObject.set("fill", t), this.editor.canvas.requestRenderAll();
2508
2508
  }
2509
2509
  /**
@@ -2511,15 +2511,15 @@ class R {
2511
2511
  * @param source - источник изображения (URL или File)
2512
2512
  */
2513
2513
  _createImageBackground(e, t) {
2514
- return j(this, null, function* () {
2515
- var a;
2516
- const { image: s } = (a = yield this.editor.imageManager.importImage({
2514
+ return p(this, null, function* () {
2515
+ var n;
2516
+ const { image: s } = (n = yield this.editor.imageManager.importImage({
2517
2517
  source: e,
2518
2518
  withoutSave: !0,
2519
2519
  isBackground: !0,
2520
2520
  withoutSelection: !0,
2521
2521
  scale: "image-cover"
2522
- })) != null ? a : {};
2522
+ })) != null ? n : {};
2523
2523
  if (!s)
2524
2524
  throw new Error("Не удалось загрузить изображение");
2525
2525
  s.set({
@@ -2548,15 +2548,15 @@ class R {
2548
2548
  const {
2549
2549
  startColor: t,
2550
2550
  endColor: s,
2551
- startPosition: a = 0,
2552
- endPosition: n = 100
2551
+ startPosition: n = 0,
2552
+ endPosition: a = 100
2553
2553
  } = e, o = [
2554
- { offset: a / 100, color: t },
2555
- { offset: n / 100, color: s }
2554
+ { offset: n / 100, color: t },
2555
+ { offset: a / 100, color: s }
2556
2556
  ];
2557
2557
  if (e.type === "linear") {
2558
- const l = e.angle * Math.PI / 180, u = R._angleToCoords(l);
2559
- return new pe({
2558
+ const l = e.angle * Math.PI / 180, u = U._angleToCoords(l);
2559
+ return new je({
2560
2560
  type: "linear",
2561
2561
  gradientUnits: "percentage",
2562
2562
  coords: u,
@@ -2575,7 +2575,7 @@ class R {
2575
2575
  r1: 0,
2576
2576
  r2: d / 100
2577
2577
  };
2578
- return new pe({
2578
+ return new je({
2579
2579
  type: "radial",
2580
2580
  gradientUnits: "percentage",
2581
2581
  coords: h,
@@ -2603,14 +2603,14 @@ class R {
2603
2603
  */
2604
2604
  static _isGradientEqual(e, t) {
2605
2605
  if (!e || !t || e.type !== t.type) return !1;
2606
- const s = e.colorStops || [], a = t.colorStops || [];
2607
- return s.length !== a.length || !s.every((o, i) => {
2608
- const r = a[i];
2606
+ const s = e.colorStops || [], n = t.colorStops || [];
2607
+ return s.length !== n.length || !s.every((o, i) => {
2608
+ const r = n[i];
2609
2609
  return o.color === r.color && Math.abs(o.offset - r.offset) < 1e-4;
2610
2610
  }) ? !1 : e.type === "linear" && t.type === "linear" ? Math.abs(e.coords.x1 - t.coords.x1) < 1e-4 && Math.abs(e.coords.y1 - t.coords.y1) < 1e-4 && Math.abs(e.coords.x2 - t.coords.x2) < 1e-4 && Math.abs(e.coords.y2 - t.coords.y2) < 1e-4 : e.type === "radial" && t.type === "radial" ? Math.abs(e.coords.x1 - t.coords.x1) < 1e-4 && Math.abs(e.coords.y1 - t.coords.y1) < 1e-4 && Math.abs(e.coords.x2 - t.coords.x2) < 1e-4 && Math.abs(e.coords.y2 - t.coords.y2) < 1e-4 && Math.abs(e.coords.r1 - t.coords.r1) < 1e-4 && Math.abs(e.coords.r2 - t.coords.r2) < 1e-4 : !1;
2611
2611
  }
2612
2612
  }
2613
- class K {
2613
+ class J {
2614
2614
  constructor({ editor: e }) {
2615
2615
  this.editor = e;
2616
2616
  }
@@ -2622,13 +2622,13 @@ class K {
2622
2622
  * @fires editor:object-bring-to-front
2623
2623
  */
2624
2624
  bringToFront(e, { withoutSave: t } = {}) {
2625
- const { canvas: s, historyManager: a } = this.editor;
2626
- a.suspendHistory();
2627
- const n = e || s.getActiveObject();
2628
- n && (n instanceof v ? n.getObjects().forEach((o) => {
2625
+ const { canvas: s, historyManager: n } = this.editor;
2626
+ n.suspendHistory();
2627
+ const a = e || s.getActiveObject();
2628
+ a && (a instanceof y ? a.getObjects().forEach((o) => {
2629
2629
  s.bringObjectToFront(o);
2630
- }) : s.bringObjectToFront(n), s.renderAll(), a.resumeHistory(), t || a.saveState(), s.fire("editor:object-bring-to-front", {
2631
- object: n,
2630
+ }) : s.bringObjectToFront(a), s.renderAll(), n.resumeHistory(), t || n.saveState(), s.fire("editor:object-bring-to-front", {
2631
+ object: a,
2632
2632
  withoutSave: t
2633
2633
  }));
2634
2634
  }
@@ -2640,11 +2640,11 @@ class K {
2640
2640
  * @fires editor:object-bring-forward
2641
2641
  */
2642
2642
  bringForward(e, { withoutSave: t } = {}) {
2643
- const { canvas: s, historyManager: a } = this.editor;
2644
- a.suspendHistory();
2645
- const n = e || s.getActiveObject();
2646
- n && (n instanceof v ? K._moveSelectionForward(s, n) : s.bringObjectForward(n), s.renderAll(), a.resumeHistory(), t || a.saveState(), s.fire("editor:object-bring-forward", {
2647
- object: n,
2643
+ const { canvas: s, historyManager: n } = this.editor;
2644
+ n.suspendHistory();
2645
+ const a = e || s.getActiveObject();
2646
+ a && (a instanceof y ? J._moveSelectionForward(s, a) : s.bringObjectForward(a), s.renderAll(), n.resumeHistory(), t || n.saveState(), s.fire("editor:object-bring-forward", {
2647
+ object: a,
2648
2648
  withoutSave: t
2649
2649
  }));
2650
2650
  }
@@ -2658,21 +2658,21 @@ class K {
2658
2658
  sendToBack(e, { withoutSave: t } = {}) {
2659
2659
  const {
2660
2660
  canvas: s,
2661
- montageArea: a,
2662
- historyManager: n,
2661
+ montageArea: n,
2662
+ historyManager: a,
2663
2663
  interactionBlocker: { overlayMask: o },
2664
2664
  backgroundManager: { backgroundObject: i }
2665
2665
  } = this.editor;
2666
- n.suspendHistory();
2666
+ a.suspendHistory();
2667
2667
  const r = e || s.getActiveObject();
2668
2668
  if (r) {
2669
- if (r instanceof v) {
2669
+ if (r instanceof y) {
2670
2670
  const d = r.getObjects();
2671
2671
  for (let h = d.length - 1; h >= 0; h -= 1)
2672
2672
  s.sendObjectToBack(d[h]);
2673
2673
  } else
2674
2674
  s.sendObjectToBack(r);
2675
- i && s.sendObjectToBack(i), s.sendObjectToBack(a), o && s.sendObjectToBack(o), s.renderAll(), n.resumeHistory(), t || n.saveState(), s.fire("editor:object-send-to-back", {
2675
+ i && s.sendObjectToBack(i), s.sendObjectToBack(n), o && s.sendObjectToBack(o), s.renderAll(), a.resumeHistory(), t || a.saveState(), s.fire("editor:object-send-to-back", {
2676
2676
  object: r,
2677
2677
  withoutSave: t
2678
2678
  });
@@ -2687,14 +2687,14 @@ class K {
2687
2687
  sendBackwards(e, { withoutSave: t } = {}) {
2688
2688
  const {
2689
2689
  canvas: s,
2690
- montageArea: a,
2691
- historyManager: n,
2690
+ montageArea: n,
2691
+ historyManager: a,
2692
2692
  interactionBlocker: { overlayMask: o },
2693
2693
  backgroundManager: { backgroundObject: i }
2694
2694
  } = this.editor;
2695
- n.suspendHistory();
2695
+ a.suspendHistory();
2696
2696
  const r = e || s.getActiveObject();
2697
- r && (r instanceof v ? K._moveSelectionBackwards(s, r) : s.sendObjectBackwards(r), i && s.sendObjectToBack(i), s.sendObjectToBack(a), o && s.sendObjectToBack(o), s.renderAll(), n.resumeHistory(), t || n.saveState(), s.fire("editor:object-send-backwards", {
2697
+ r && (r instanceof y ? J._moveSelectionBackwards(s, r) : s.sendObjectBackwards(r), i && s.sendObjectToBack(i), s.sendObjectToBack(n), o && s.sendObjectToBack(o), s.renderAll(), a.resumeHistory(), t || a.saveState(), s.fire("editor:object-send-backwards", {
2698
2698
  object: r,
2699
2699
  withoutSave: t
2700
2700
  }));
@@ -2706,15 +2706,15 @@ class K {
2706
2706
  * @param activeSelection - активное выделение
2707
2707
  */
2708
2708
  static _moveSelectionForward(e, t) {
2709
- const s = e.getObjects(), a = t.getObjects();
2710
- if (!a.some((i) => {
2709
+ const s = e.getObjects(), n = t.getObjects();
2710
+ if (!n.some((i) => {
2711
2711
  const r = s.indexOf(i);
2712
2712
  for (let d = r + 1; d < s.length; d += 1)
2713
- if (!a.includes(s[d]))
2713
+ if (!n.includes(s[d]))
2714
2714
  return !0;
2715
2715
  return !1;
2716
2716
  })) return;
2717
- a.map((i) => ({ obj: i, index: s.indexOf(i) })).sort((i, r) => r.index - i.index).forEach((i) => {
2717
+ n.map((i) => ({ obj: i, index: s.indexOf(i) })).sort((i, r) => r.index - i.index).forEach((i) => {
2718
2718
  e.bringObjectForward(i.obj);
2719
2719
  });
2720
2720
  }
@@ -2725,20 +2725,20 @@ class K {
2725
2725
  * @param activeSelection - активное выделение
2726
2726
  */
2727
2727
  static _moveSelectionBackwards(e, t) {
2728
- const s = e.getObjects(), a = t.getObjects();
2729
- if (!a.some((i) => {
2728
+ const s = e.getObjects(), n = t.getObjects();
2729
+ if (!n.some((i) => {
2730
2730
  const r = s.indexOf(i);
2731
2731
  for (let d = r - 1; d >= 0; d -= 1)
2732
- if (!a.includes(s[d]))
2732
+ if (!n.includes(s[d]))
2733
2733
  return !0;
2734
2734
  return !1;
2735
2735
  })) return;
2736
- a.map((i) => ({ obj: i, index: s.indexOf(i) })).sort((i, r) => i.index - r.index).forEach((i) => {
2736
+ n.map((i) => ({ obj: i, index: s.indexOf(i) })).sort((i, r) => i.index - r.index).forEach((i) => {
2737
2737
  e.sendObjectBackwards(i.obj);
2738
2738
  });
2739
2739
  }
2740
2740
  }
2741
- class pt {
2741
+ class jt {
2742
2742
  /**
2743
2743
  * Менеджер фигур для редактора.
2744
2744
  * @param options - Опции и настройки менеджера фигур.
@@ -2767,8 +2767,8 @@ class pt {
2767
2767
  id: e = `rect-${A()}`,
2768
2768
  left: t,
2769
2769
  top: s,
2770
- width: a = 100,
2771
- height: n = 100,
2770
+ width: n = 100,
2771
+ height: a = 100,
2772
2772
  fill: o = "blue"
2773
2773
  } = l, i = V(l, [
2774
2774
  "id",
@@ -2778,12 +2778,12 @@ class pt {
2778
2778
  "height",
2779
2779
  "fill"
2780
2780
  ]);
2781
- const { canvas: u } = this.editor, g = new _e(I({
2781
+ const { canvas: u } = this.editor, g = new _e(v({
2782
2782
  id: e,
2783
2783
  left: t,
2784
2784
  top: s,
2785
- width: a,
2786
- height: n,
2785
+ width: n,
2786
+ height: a,
2787
2787
  fill: o
2788
2788
  }, i));
2789
2789
  return !t && !s && u.centerObject(g), d || (u.add(g), r || u.setActiveObject(g), u.renderAll()), g;
@@ -2809,8 +2809,8 @@ class pt {
2809
2809
  id: e = `circle-${A()}`,
2810
2810
  left: t,
2811
2811
  top: s,
2812
- radius: a = 50,
2813
- fill: n = "green"
2812
+ radius: n = 50,
2813
+ fill: a = "green"
2814
2814
  } = h, o = V(h, [
2815
2815
  "id",
2816
2816
  "left",
@@ -2818,12 +2818,12 @@ class pt {
2818
2818
  "radius",
2819
2819
  "fill"
2820
2820
  ]);
2821
- const { canvas: l } = this.editor, u = new Be(I({
2821
+ const { canvas: l } = this.editor, u = new Be(v({
2822
2822
  id: e,
2823
2823
  left: t,
2824
2824
  top: s,
2825
- fill: n,
2826
- radius: a
2825
+ fill: a,
2826
+ radius: n
2827
2827
  }, o));
2828
2828
  return !t && !s && l.centerObject(u), r || (l.add(u), i || l.setActiveObject(u), l.renderAll()), u;
2829
2829
  }
@@ -2849,8 +2849,8 @@ class pt {
2849
2849
  id: e = `triangle-${A()}`,
2850
2850
  left: t,
2851
2851
  top: s,
2852
- width: a = 100,
2853
- height: n = 100,
2852
+ width: n = 100,
2853
+ height: a = 100,
2854
2854
  fill: o = "yellow"
2855
2855
  } = l, i = V(l, [
2856
2856
  "id",
@@ -2860,13 +2860,13 @@ class pt {
2860
2860
  "height",
2861
2861
  "fill"
2862
2862
  ]);
2863
- const { canvas: u } = this.editor, g = new xe(I({
2863
+ const { canvas: u } = this.editor, g = new xe(v({
2864
2864
  id: e,
2865
2865
  left: t,
2866
2866
  top: s,
2867
2867
  fill: o,
2868
- width: a,
2869
- height: n
2868
+ width: n,
2869
+ height: a
2870
2870
  }, i));
2871
2871
  return !t && !s && u.centerObject(g), d || (u.add(g), r || u.setActiveObject(g), u.renderAll()), g;
2872
2872
  }
@@ -2899,18 +2899,18 @@ class yt {
2899
2899
  * Асинхронное клонирование для внутреннего буфера
2900
2900
  */
2901
2901
  _cloneToInternalClipboard(e) {
2902
- return j(this, null, function* () {
2902
+ return p(this, null, function* () {
2903
2903
  const { canvas: t, errorManager: s } = this.editor;
2904
2904
  try {
2905
- const a = yield e.clone(["format"]);
2906
- this.clipboard = a, t.fire("editor:object-copied", { object: a });
2907
- } catch (a) {
2905
+ const n = yield e.clone(["format"]);
2906
+ this.clipboard = n, t.fire("editor:object-copied", { object: n });
2907
+ } catch (n) {
2908
2908
  s.emitError({
2909
2909
  origin: "ClipboardManager",
2910
2910
  method: "_cloneToInternalClipboard",
2911
2911
  code: "CLONE_FAILED",
2912
2912
  message: "Ошибка клонирования объекта для внутреннего буфера",
2913
- data: a
2913
+ data: n
2914
2914
  });
2915
2915
  }
2916
2916
  });
@@ -2919,7 +2919,7 @@ class yt {
2919
2919
  * Копирование в системный буфер обмена
2920
2920
  */
2921
2921
  _copyToSystemClipboard(e) {
2922
- return j(this, null, function* () {
2922
+ return p(this, null, function* () {
2923
2923
  const { errorManager: t } = this.editor;
2924
2924
  if (typeof ClipboardItem == "undefined" || !navigator.clipboard)
2925
2925
  return t.emitWarning({
@@ -2929,8 +2929,8 @@ class yt {
2929
2929
  message: "navigator.clipboard не поддерживается в этом браузере или отсутствует HTTPS-соединение."
2930
2930
  }), !1;
2931
2931
  try {
2932
- const s = e.toObject(["format"]), a = JSON.stringify(s);
2933
- return e.type === "image" ? this._copyImageToClipboard(e, a) : this._copyTextToClipboard(a);
2932
+ const s = e.toObject(["format"]), n = JSON.stringify(s);
2933
+ return e.type === "image" ? this._copyImageToClipboard(e, n) : this._copyTextToClipboard(n);
2934
2934
  } catch (s) {
2935
2935
  return t.emitError({
2936
2936
  origin: "ClipboardManager",
@@ -2946,12 +2946,12 @@ class yt {
2946
2946
  * Копирование изображения в буфер обмена
2947
2947
  */
2948
2948
  _copyImageToClipboard(e, t) {
2949
- return j(this, null, function* () {
2949
+ return p(this, null, function* () {
2950
2950
  try {
2951
- const a = e.toCanvasElement({ enableRetinaScaling: !1 }).toDataURL(), n = a.slice(5).split(";")[0], o = a.split(",")[1], i = atob(o), r = new Uint8Array(i.length);
2951
+ const n = e.toCanvasElement({ enableRetinaScaling: !1 }).toDataURL(), a = n.slice(5).split(";")[0], o = n.split(",")[1], i = atob(o), r = new Uint8Array(i.length);
2952
2952
  for (let l = 0; l < i.length; l += 1)
2953
2953
  r[l] = i.charCodeAt(l);
2954
- const d = new Blob([r.buffer], { type: n }), h = new ClipboardItem({ [n]: d });
2954
+ const d = new Blob([r.buffer], { type: a }), h = new ClipboardItem({ [a]: d });
2955
2955
  return yield navigator.clipboard.write([h]), console.info("Image copied to clipboard successfully"), !0;
2956
2956
  } catch (s) {
2957
2957
  return this.editor.errorManager.emitWarning({
@@ -2968,7 +2968,7 @@ class yt {
2968
2968
  * Копирование текста в буфер обмена
2969
2969
  */
2970
2970
  _copyTextToClipboard(e) {
2971
- return j(this, null, function* () {
2971
+ return p(this, null, function* () {
2972
2972
  try {
2973
2973
  const t = `${Ce}${e}`;
2974
2974
  return yield navigator.clipboard.writeText(t), console.info("Text copied to clipboard successfully"), !0;
@@ -2990,9 +2990,9 @@ class yt {
2990
2990
  */
2991
2991
  _addClonedObjectToCanvas(e) {
2992
2992
  const { canvas: t, historyManager: s } = this.editor;
2993
- if (t.discardActiveObject(), e instanceof v) {
2994
- s.suspendHistory(), e.canvas = t, e.forEachObject((a) => {
2995
- t.add(a);
2993
+ if (t.discardActiveObject(), e instanceof y) {
2994
+ s.suspendHistory(), e.canvas = t, e.forEachObject((n) => {
2995
+ t.add(n);
2996
2996
  }), t.setActiveObject(e), t.requestRenderAll(), s.resumeHistory(), s.saveState();
2997
2997
  return;
2998
2998
  }
@@ -3003,7 +3003,7 @@ class yt {
3003
3003
  * @param source - источник изображения (data URL или URL)
3004
3004
  */
3005
3005
  _handleImageImport(e) {
3006
- return j(this, null, function* () {
3006
+ return p(this, null, function* () {
3007
3007
  var s;
3008
3008
  const { image: t } = (s = yield this.editor.imageManager.importImage({
3009
3009
  source: e,
@@ -3019,25 +3019,30 @@ class yt {
3019
3019
  * @fires editor:object-pasted
3020
3020
  */
3021
3021
  copyPaste(e) {
3022
- return j(this, null, function* () {
3022
+ return p(this, null, function* () {
3023
3023
  const { canvas: t } = this.editor, s = e || t.getActiveObject();
3024
3024
  if (!s || s.locked) return !1;
3025
3025
  try {
3026
- const a = yield s.clone(["format"]);
3027
- return a.set({
3028
- id: `${a.type}-${A()}`,
3029
- left: a.left + 10,
3030
- top: a.top + 10,
3026
+ const n = yield s.clone(["format"]);
3027
+ return n instanceof y && n.forEachObject((a) => {
3028
+ a.set({
3029
+ id: `${a.type}-${A()}`,
3030
+ evented: !0
3031
+ });
3032
+ }), n.set({
3033
+ id: `${n.type}-${A()}`,
3034
+ left: n.left + 10,
3035
+ top: n.top + 10,
3031
3036
  evented: !0
3032
- }), this._addClonedObjectToCanvas(a), t.fire("editor:object-duplicated", { object: a }), !0;
3033
- } catch (a) {
3034
- const { errorManager: n } = this.editor;
3035
- return n.emitError({
3037
+ }), this._addClonedObjectToCanvas(n), t.fire("editor:object-duplicated", { object: n }), !0;
3038
+ } catch (n) {
3039
+ const { errorManager: a } = this.editor;
3040
+ return a.emitError({
3036
3041
  origin: "ClipboardManager",
3037
3042
  method: "copyPaste",
3038
3043
  code: "COPY_PASTE_FAILED",
3039
3044
  message: "Ошибка создания копии объекта",
3040
- data: a
3045
+ data: n
3041
3046
  }), !1;
3042
3047
  }
3043
3048
  });
@@ -3049,7 +3054,7 @@ class yt {
3049
3054
  * @param event.clipboardData.items — элементы буфера обмена
3050
3055
  */
3051
3056
  handlePasteEvent(t) {
3052
- return j(this, arguments, function* ({ clipboardData: e }) {
3057
+ return p(this, arguments, function* ({ clipboardData: e }) {
3053
3058
  var r;
3054
3059
  if (!((r = e == null ? void 0 : e.items) != null && r.length)) {
3055
3060
  this.paste();
@@ -3060,8 +3065,8 @@ class yt {
3060
3065
  this.paste();
3061
3066
  return;
3062
3067
  }
3063
- const { items: a } = e, n = a[a.length - 1], o = n.getAsFile();
3064
- if (n.type !== "text/html" && o) {
3068
+ const { items: n } = e, a = n[n.length - 1], o = a.getAsFile();
3069
+ if (a.type !== "text/html" && o) {
3065
3070
  const d = new FileReader();
3066
3071
  d.onload = (h) => {
3067
3072
  h.target && this._handleImageImport(h.target.result).catch((l) => {
@@ -3100,12 +3105,17 @@ class yt {
3100
3105
  * @fires editor:object-pasted
3101
3106
  */
3102
3107
  paste() {
3103
- return j(this, null, function* () {
3108
+ return p(this, null, function* () {
3104
3109
  const { canvas: e } = this.editor;
3105
3110
  if (!this.clipboard) return !1;
3106
3111
  try {
3107
3112
  const t = yield this.clipboard.clone(["format"]);
3108
- return e.discardActiveObject(), t.set({
3113
+ return e.discardActiveObject(), t instanceof y && t.forEachObject((s) => {
3114
+ s.set({
3115
+ id: `${s.type}-${A()}`,
3116
+ evented: !0
3117
+ });
3118
+ }), t.set({
3109
3119
  id: `${t.type}-${A()}`,
3110
3120
  left: t.left + 10,
3111
3121
  top: t.top + 10,
@@ -3124,7 +3134,7 @@ class yt {
3124
3134
  });
3125
3135
  }
3126
3136
  }
3127
- class J {
3137
+ class q {
3128
3138
  constructor({ editor: e }) {
3129
3139
  this.editor = e;
3130
3140
  }
@@ -3137,7 +3147,7 @@ class J {
3137
3147
  * @fires editor:object-locked
3138
3148
  */
3139
3149
  lockObject({ object: e, skipInnerObjects: t, withoutSave: s } = {}) {
3140
- const { canvas: a, historyManager: n } = this.editor, o = e || a.getActiveObject();
3150
+ const { canvas: n, historyManager: a } = this.editor, o = e || n.getActiveObject();
3141
3151
  if (!o || o.locked) return;
3142
3152
  const i = {
3143
3153
  lockMovementX: !0,
@@ -3149,9 +3159,9 @@ class J {
3149
3159
  lockSkewingY: !0,
3150
3160
  locked: !0
3151
3161
  };
3152
- o.set(i), !t && J._isGroupOrSelection(o) && o.getObjects().forEach((d) => {
3162
+ o.set(i), !t && q._isGroupOrSelection(o) && o.getObjects().forEach((d) => {
3153
3163
  d.set(i);
3154
- }), a.renderAll(), s || n.saveState(), a.fire("editor:object-locked", {
3164
+ }), n.renderAll(), s || a.saveState(), n.fire("editor:object-locked", {
3155
3165
  object: o,
3156
3166
  skipInnerObjects: t,
3157
3167
  withoutSave: s
@@ -3165,8 +3175,8 @@ class J {
3165
3175
  * @fires editor:object-unlocked
3166
3176
  */
3167
3177
  unlockObject({ object: e, withoutSave: t } = {}) {
3168
- const { canvas: s, historyManager: a } = this.editor, n = e || s.getActiveObject();
3169
- if (!n) return;
3178
+ const { canvas: s, historyManager: n } = this.editor, a = e || s.getActiveObject();
3179
+ if (!a) return;
3170
3180
  const o = {
3171
3181
  lockMovementX: !1,
3172
3182
  lockMovementY: !1,
@@ -3177,15 +3187,15 @@ class J {
3177
3187
  lockSkewingY: !1,
3178
3188
  locked: !1
3179
3189
  };
3180
- n.set(o), J._isGroupOrSelection(n) && n.getObjects().forEach((i) => {
3190
+ a.set(o), q._isGroupOrSelection(a) && a.getObjects().forEach((i) => {
3181
3191
  i.set(o);
3182
- }), s.renderAll(), t || a.saveState(), s.fire("editor:object-unlocked", {
3183
- object: n,
3192
+ }), s.renderAll(), t || n.saveState(), s.fire("editor:object-unlocked", {
3193
+ object: a,
3184
3194
  withoutSave: t
3185
3195
  });
3186
3196
  }
3187
3197
  static _isGroupOrSelection(e) {
3188
- return e instanceof v || e instanceof te;
3198
+ return e instanceof y || e instanceof R;
3189
3199
  }
3190
3200
  }
3191
3201
  class It {
@@ -3193,55 +3203,100 @@ class It {
3193
3203
  this.editor = e;
3194
3204
  }
3195
3205
  /**
3196
- * Группировка объектов
3197
- * @param options
3198
- * @param options.withoutSave - Не сохранять состояние
3199
- * @param options.object - массив объектов для группировки
3200
- * @fires editor:objects-grouped
3206
+ * Получить объекты для группировки
3207
+ * @private
3201
3208
  */
3209
+ _getObjectsToGroup(e) {
3210
+ if (Array.isArray(e))
3211
+ return e.length > 0 ? e : null;
3212
+ const t = e || this.editor.canvas.getActiveObject();
3213
+ return !t || !(t instanceof y) ? null : t.getObjects();
3214
+ }
3215
+ /**
3216
+ * Получить группы для разгруппировки
3217
+ * @private
3218
+ */
3219
+ _getGroupsToUngroup(e) {
3220
+ if (Array.isArray(e)) {
3221
+ const s = e.filter((n) => n instanceof R);
3222
+ return s.length > 0 ? s : null;
3223
+ }
3224
+ if (e instanceof y) {
3225
+ const s = e.getObjects().filter((n) => n instanceof R);
3226
+ return s.length > 0 ? s : null;
3227
+ }
3228
+ const t = e || this.editor.canvas.getActiveObject();
3229
+ if (!t) return null;
3230
+ if (t instanceof y) {
3231
+ const s = t.getObjects().filter((n) => n instanceof R);
3232
+ return s.length > 0 ? s : null;
3233
+ }
3234
+ return t instanceof R ? [t] : null;
3235
+ }
3236
+ /**
3237
+ * Группировка объектов
3238
+ * @param options
3239
+ * @param options.target - объект ActiveSelection или массив объектов для группировки
3240
+ * @param options.withoutSave - Не сохранять состояние
3241
+ * @fires editor:objects-grouped
3242
+ */
3202
3243
  group({
3203
- object: e,
3204
- withoutSave: t
3244
+ target: e,
3245
+ withoutSave: t = !1
3205
3246
  } = {}) {
3206
- const { canvas: s, historyManager: a } = this.editor;
3207
- a.suspendHistory();
3208
- const n = e || s.getActiveObject();
3209
- if (!n || !(n instanceof v)) return;
3210
- const o = n.getObjects(), i = new te(o);
3211
- o.forEach((r) => s.remove(r)), i.set("id", `${i.type}-${A()}`), s.add(i), s.setActiveObject(i), s.renderAll(), a.resumeHistory(), t || a.saveState(), s.fire("editor:objects-grouped", {
3212
- object: n,
3213
- group: i,
3214
- withoutSave: t
3215
- });
3247
+ const { canvas: s, historyManager: n } = this.editor, a = this._getObjectsToGroup(e);
3248
+ if (!a) return null;
3249
+ try {
3250
+ n.suspendHistory();
3251
+ const o = new R(a, {
3252
+ id: `group-${A()}`
3253
+ });
3254
+ a.forEach((r) => s.remove(r)), s.add(o), s.setActiveObject(o), s.requestRenderAll();
3255
+ const i = {
3256
+ group: o,
3257
+ withoutSave: t
3258
+ };
3259
+ return s.fire("editor:objects-grouped", i), i;
3260
+ } finally {
3261
+ n.resumeHistory(), t || n.saveState();
3262
+ }
3216
3263
  }
3217
3264
  /**
3218
- * Разгруппировка объектов
3219
- * @param options
3220
- * @param options.object - объект для разгруппировки
3221
- * @param options.withoutSave - Не сохранять состояние
3222
- * @returns данные о разгруппировке или null, если объект не является группой
3223
- * @fires editor:objects-ungrouped
3224
- */
3265
+ * Разгруппировка объектов
3266
+ * @param options
3267
+ * @param options.target - объект Group, массив групп или ActiveSelection с группами для разгруппировки
3268
+ * @param options.withoutSave - Не сохранять состояние
3269
+ * @returns данные о разгруппировке или null, если нет групп для разгруппировки
3270
+ * @fires editor:objects-ungrouped
3271
+ */
3225
3272
  ungroup({
3226
- object: e,
3227
- withoutSave: t
3273
+ target: e,
3274
+ withoutSave: t = !1
3228
3275
  } = {}) {
3229
- const { canvas: s, historyManager: a } = this.editor, n = e || s.getActiveObject();
3230
- if (!(n instanceof te)) return null;
3231
- a.suspendHistory();
3232
- const o = n.removeAll();
3233
- s.remove(n), o.forEach((d) => s.add(d));
3234
- const i = new v(o, {
3235
- canvas: s
3236
- });
3237
- s.setActiveObject(i), s.renderAll(), a.resumeHistory(), t || a.saveState();
3238
- const r = {
3239
- object: n,
3240
- selection: i,
3241
- ungroupedObjects: o,
3242
- withoutSave: t
3243
- };
3244
- return s.fire("editor:objects-ungrouped", r), r;
3276
+ const { canvas: s, historyManager: n } = this.editor, a = this._getGroupsToUngroup(e);
3277
+ if (!a) return null;
3278
+ try {
3279
+ n.suspendHistory();
3280
+ const o = [];
3281
+ a.forEach((d) => {
3282
+ const h = d.removeAll();
3283
+ s.remove(d), h.forEach((l) => {
3284
+ s.add(l), o.push(l);
3285
+ });
3286
+ });
3287
+ const i = new y(o, {
3288
+ canvas: s
3289
+ });
3290
+ s.setActiveObject(i), s.requestRenderAll();
3291
+ const r = {
3292
+ selection: i,
3293
+ ungroupedObjects: o,
3294
+ withoutSave: t
3295
+ };
3296
+ return s.fire("editor:objects-ungrouped", r), r;
3297
+ } finally {
3298
+ n.resumeHistory(), t || n.saveState();
3299
+ }
3245
3300
  }
3246
3301
  }
3247
3302
  class vt {
@@ -3255,8 +3310,8 @@ class vt {
3255
3310
  selectAll() {
3256
3311
  const { canvas: e, canvasManager: t, objectLockManager: s } = this.editor;
3257
3312
  e.discardActiveObject();
3258
- const a = t.getObjects(), n = a.some((i) => i.locked), o = a.length > 1 ? new v(t.getObjects(), { canvas: e }) : a[0];
3259
- n && s.lockObject({ object: o, skipInnerObjects: !0, withoutSave: !0 }), e.setActiveObject(o), e.requestRenderAll(), e.fire("editor:all-objects-selected", { selected: o });
3313
+ const n = t.getObjects(), a = n.some((i) => i.locked), o = n.length > 1 ? new y(t.getObjects(), { canvas: e }) : n[0];
3314
+ a && s.lockObject({ object: o, skipInnerObjects: !0, withoutSave: !0 }), e.setActiveObject(o), e.requestRenderAll(), e.fire("editor:all-objects-selected", { selected: o });
3260
3315
  }
3261
3316
  }
3262
3317
  class le {
@@ -3277,11 +3332,11 @@ class le {
3277
3332
  * @returns массив всех удаленных объектов (включая саму группу)
3278
3333
  */
3279
3334
  _handleGroupDeletion(e) {
3280
- var a;
3281
- const { groupingManager: t } = this.editor, { ungroupedObjects: s = [] } = (a = t.ungroup({
3335
+ var n;
3336
+ const { groupingManager: t } = this.editor, { ungroupedObjects: s = [] } = (n = t.ungroup({
3282
3337
  object: e,
3283
3338
  withoutSave: !0
3284
- })) != null ? a : {};
3339
+ })) != null ? n : {};
3285
3340
  return this.deleteSelectedObjects({
3286
3341
  objects: s,
3287
3342
  withoutSave: !0,
@@ -3301,9 +3356,9 @@ class le {
3301
3356
  withoutSave: t = !1,
3302
3357
  _isRecursiveCall: s = !1
3303
3358
  } = {}) {
3304
- const { canvas: a, historyManager: n } = this.editor, i = (e || a.getActiveObjects()).filter((h) => !h.locked);
3359
+ const { canvas: n, historyManager: a } = this.editor, i = (e || n.getActiveObjects()).filter((h) => !h.locked);
3305
3360
  if (!(i != null && i.length)) return null;
3306
- s || n.suspendHistory();
3361
+ s || a.suspendHistory();
3307
3362
  const r = [];
3308
3363
  if (i.forEach((h) => {
3309
3364
  if (le._isUngroupableGroup(h)) {
@@ -3311,14 +3366,14 @@ class le {
3311
3366
  r.push(...l);
3312
3367
  return;
3313
3368
  }
3314
- a.remove(h), r.push(h);
3369
+ n.remove(h), r.push(h);
3315
3370
  }), s) return null;
3316
- a.discardActiveObject(), a.renderAll(), n.resumeHistory(), t || n.saveState();
3371
+ n.discardActiveObject(), n.renderAll(), a.resumeHistory(), t || a.saveState();
3317
3372
  const d = {
3318
3373
  objects: r,
3319
3374
  withoutSave: t
3320
3375
  };
3321
- return a.fire("editor:objects-deleted", d), d;
3376
+ return n.fire("editor:objects-deleted", d), d;
3322
3377
  }
3323
3378
  }
3324
3379
  const At = {
@@ -3420,7 +3475,7 @@ const At = {
3420
3475
  INVALID_GRADIENT_FORMAT: "INVALID_GRADIENT_FORMAT"
3421
3476
  }
3422
3477
  };
3423
- class q {
3478
+ class ee {
3424
3479
  constructor({ editor: e }) {
3425
3480
  this._buffer = [], this.editor = e;
3426
3481
  }
@@ -3446,22 +3501,22 @@ class q {
3446
3501
  * @param options.message — текст ошибки (опционально, если не передан, то используется код ошибки)
3447
3502
  * @fires editor:error
3448
3503
  */
3449
- emitError({ origin: e = "ImageEditor", method: t = "Unknown Method", code: s, data: a, message: n }) {
3450
- if (!q.isValidErrorCode(s)) {
3504
+ emitError({ origin: e = "ImageEditor", method: t = "Unknown Method", code: s, data: n, message: a }) {
3505
+ if (!ee.isValidErrorCode(s)) {
3451
3506
  console.warn("Неизвестный код ошибки: ", { code: s, origin: e, method: t });
3452
3507
  return;
3453
3508
  }
3454
3509
  if (!s) return;
3455
- const o = n || s;
3456
- console.error(`${e}. ${t}. ${s}. ${o}`, a);
3510
+ const o = a || s;
3511
+ console.error(`${e}. ${t}. ${s}. ${o}`, n);
3457
3512
  const i = {
3458
3513
  code: s,
3459
3514
  origin: e,
3460
3515
  method: t,
3461
3516
  message: o,
3462
- data: a
3517
+ data: n
3463
3518
  };
3464
- this._buffer.push(I({
3519
+ this._buffer.push(v({
3465
3520
  type: "editor:error"
3466
3521
  }, i)), this.editor.canvas.fire("editor:error", i);
3467
3522
  }
@@ -3475,21 +3530,21 @@ class q {
3475
3530
  * @param options.message — текст предупреждения (опционально, если не передан, то используется код предупреждения)
3476
3531
  * @fires editor:warning
3477
3532
  */
3478
- emitWarning({ origin: e = "ImageEditor", method: t = "Unknown Method", code: s, message: a, data: n }) {
3479
- if (!q.isValidErrorCode(s)) {
3533
+ emitWarning({ origin: e = "ImageEditor", method: t = "Unknown Method", code: s, message: n, data: a }) {
3534
+ if (!ee.isValidErrorCode(s)) {
3480
3535
  console.warn("Неизвестный код предупреждения: ", { code: s, origin: e, method: t });
3481
3536
  return;
3482
3537
  }
3483
- const o = a || s;
3484
- console.warn(`${e}. ${t}. ${s}. ${o}`, n);
3538
+ const o = n || s;
3539
+ console.warn(`${e}. ${t}. ${s}. ${o}`, a);
3485
3540
  const i = {
3486
3541
  code: s,
3487
3542
  origin: e,
3488
3543
  method: t,
3489
3544
  message: o,
3490
- data: n
3545
+ data: a
3491
3546
  };
3492
- this._buffer.push(I({
3547
+ this._buffer.push(v({
3493
3548
  type: "editor:warning"
3494
3549
  }, i)), this.editor.canvas.fire("editor:warning", i);
3495
3550
  }
@@ -3517,13 +3572,13 @@ class he {
3517
3572
  * @fires editor:ready
3518
3573
  */
3519
3574
  init() {
3520
- return j(this, null, function* () {
3575
+ return p(this, null, function* () {
3521
3576
  const {
3522
3577
  editorContainerWidth: e,
3523
3578
  editorContainerHeight: t,
3524
3579
  canvasWrapperWidth: s,
3525
- canvasWrapperHeight: a,
3526
- canvasCSSWidth: n,
3580
+ canvasWrapperHeight: n,
3581
+ canvasCSSWidth: a,
3527
3582
  canvasCSSHeight: o,
3528
3583
  initialImage: i,
3529
3584
  initialStateJSON: r,
@@ -3531,7 +3586,7 @@ class he {
3531
3586
  showRotationAngle: h,
3532
3587
  _onReadyCallback: l
3533
3588
  } = this.options;
3534
- if (Je.apply(), this.canvas = new Re(this.containerId, this.options), this.moduleLoader = new Ye(), this.workerManager = new We(), this.errorManager = new q({ editor: this }), this.historyManager = new $({ editor: this }), this.toolbar = new rt({ editor: this }), this.transformManager = new bt({ editor: this }), this.canvasManager = new mt({ editor: this }), this.imageManager = new N({ editor: this }), this.layerManager = new K({ editor: this }), this.shapeManager = new pt({ editor: this }), this.interactionBlocker = new jt({ editor: this }), this.backgroundManager = new R({ editor: this }), this.clipboardManager = new yt({ editor: this }), this.objectLockManager = new J({ editor: this }), this.groupingManager = new It({ editor: this }), this.selectionManager = new vt({ editor: this }), this.deletionManager = new le({ editor: this }), h && (this.angleIndicator = new de({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.listeners = new P({ editor: this, options: this.options }), this.canvasManager.setEditorContainerWidth(e), this.canvasManager.setEditorContainerHeight(t), this.canvasManager.setCanvasWrapperWidth(s), this.canvasManager.setCanvasWrapperHeight(a), this.canvasManager.setCanvasCSSWidth(n), this.canvasManager.setCanvasCSSHeight(o), this.canvasManager.updateCanvas(), this.transformManager.calculateAndApplyDefaultZoom(), i != null && i.source) {
3589
+ if (Je.apply(), this.canvas = new Re(this.containerId, this.options), this.moduleLoader = new Ye(), this.workerManager = new We(), this.errorManager = new ee({ editor: this }), this.historyManager = new K({ editor: this }), this.toolbar = new rt({ editor: this }), this.transformManager = new bt({ editor: this }), this.canvasManager = new mt({ editor: this }), this.imageManager = new N({ editor: this }), this.layerManager = new J({ editor: this }), this.shapeManager = new jt({ editor: this }), this.interactionBlocker = new pt({ editor: this }), this.backgroundManager = new U({ editor: this }), this.clipboardManager = new yt({ editor: this }), this.objectLockManager = new q({ editor: this }), this.groupingManager = new It({ editor: this }), this.selectionManager = new vt({ editor: this }), this.deletionManager = new le({ editor: this }), h && (this.angleIndicator = new de({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.listeners = new W({ editor: this, options: this.options }), this.canvasManager.setEditorContainerWidth(e), this.canvasManager.setEditorContainerHeight(t), this.canvasManager.setCanvasWrapperWidth(s), this.canvasManager.setCanvasWrapperHeight(n), this.canvasManager.setCanvasCSSWidth(a), this.canvasManager.setCanvasCSSHeight(o), this.canvasManager.updateCanvas(), this.transformManager.calculateAndApplyDefaultZoom(), i != null && i.source) {
3535
3590
  const {
3536
3591
  source: u,
3537
3592
  scale: g = `image-${d}`,
@@ -3701,13 +3756,13 @@ const Ct = {
3701
3756
  keyboardIgnoreSelectors: []
3702
3757
  };
3703
3758
  function wt(c, e = {}) {
3704
- const t = I(I({}, Ct), e), s = document.getElementById(c);
3759
+ const t = v(v({}, Ct), e), s = document.getElementById(c);
3705
3760
  if (!s)
3706
3761
  return Promise.reject(new Error(`Контейнер с ID "${c}" не найден.`));
3707
- const a = document.createElement("canvas");
3708
- return a.id = `${c}-canvas`, s.appendChild(a), t.editorContainer = s, new Promise((n) => {
3709
- t._onReadyCallback = n;
3710
- const o = new he(a.id, t);
3762
+ const n = document.createElement("canvas");
3763
+ return n.id = `${c}-canvas`, s.appendChild(n), t.editorContainer = s, new Promise((a) => {
3764
+ t._onReadyCallback = a;
3765
+ const o = new he(n.id, t);
3711
3766
  window[c] = o;
3712
3767
  });
3713
3768
  }