@anu3ev/fabric-image-editor 0.1.68 → 0.1.70

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 +681 -546
  2. package/package.json +2 -1
package/dist/main.js CHANGED
@@ -1,16 +1,16 @@
1
- var pe = Object.defineProperty, ye = Object.defineProperties;
2
- var Ie = Object.getOwnPropertyDescriptors;
1
+ var ye = Object.defineProperty, Ie = Object.defineProperties;
2
+ var ve = Object.getOwnPropertyDescriptors;
3
3
  var Y = Object.getOwnPropertySymbols;
4
4
  var le = Object.prototype.hasOwnProperty, he = Object.prototype.propertyIsEnumerable;
5
- var de = (r, e, t) => e in r ? pe(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, p = (r, e) => {
5
+ var de = (r, e, t) => e in r ? ye(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, p = (r, e) => {
6
6
  for (var t in e || (e = {}))
7
7
  le.call(e, t) && de(r, t, e[t]);
8
8
  if (Y)
9
9
  for (var t of Y(e))
10
10
  he.call(e, t) && de(r, t, e[t]);
11
11
  return r;
12
- }, ge = (r, e) => ye(r, Ie(e));
13
- var _ = (r, e) => {
12
+ }, ge = (r, e) => Ie(r, ve(e));
13
+ var P = (r, e) => {
14
14
  var t = {};
15
15
  for (var s in r)
16
16
  le.call(r, s) && e.indexOf(s) < 0 && (t[s] = r[s]);
@@ -19,28 +19,28 @@ var _ = (r, e) => {
19
19
  e.indexOf(s) < 0 && he.call(r, s) && (t[s] = r[s]);
20
20
  return t;
21
21
  };
22
- var v = (r, e, t) => new Promise((s, n) => {
23
- var i = (d) => {
22
+ var j = (r, e, t) => new Promise((s, n) => {
23
+ var a = (d) => {
24
24
  try {
25
25
  o(t.next(d));
26
26
  } catch (c) {
27
27
  n(c);
28
28
  }
29
- }, a = (d) => {
29
+ }, i = (d) => {
30
30
  try {
31
31
  o(t.throw(d));
32
32
  } catch (c) {
33
33
  n(c);
34
34
  }
35
- }, o = (d) => d.done ? s(d.value) : Promise.resolve(d.value).then(i, a);
35
+ }, o = (d) => d.done ? s(d.value) : Promise.resolve(d.value).then(a, i);
36
36
  o((t = t.apply(r, e)).next());
37
37
  });
38
- import { ActiveSelection as y, util as H, controlsUtils as ve, InteractiveFabricObject as Ae, loadSVGFromURL as Se, FabricImage as R, Point as P, Rect as Ce, Circle as Ne, Triangle as De, Group as J, Canvas as Le, Pattern as we } from "fabric";
39
- import { create as Ee } from "jsondiffpatch";
40
- import Oe from "diff-match-patch";
41
- var Te = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", L = function() {
38
+ import { ActiveSelection as y, util as H, controlsUtils as Ae, InteractiveFabricObject as Se, loadSVGFromURL as Ce, FabricImage as U, Point as F, Rect as De, Circle as Le, Triangle as Ne, Group as J, Canvas as Ee, Pattern as we } from "fabric";
39
+ import { create as Oe } from "jsondiffpatch";
40
+ import Te from "diff-match-patch";
41
+ var ke = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", D = function() {
42
42
  for (var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 21, t = "", s = crypto.getRandomValues(new Uint8Array(e |= 0)); e--; )
43
- t += Te[s[e] & 63];
43
+ t += ke[s[e] & 63];
44
44
  return t;
45
45
  };
46
46
  class z {
@@ -72,14 +72,14 @@ class z {
72
72
  canvasDragging: t,
73
73
  mouseWheelZooming: s,
74
74
  bringToFrontOnSelection: n,
75
- copyObjectsByHotkey: i,
76
- pasteImageFromClipboard: a,
75
+ copyObjectsByHotkey: a,
76
+ pasteImageFromClipboard: i,
77
77
  undoRedoByHotKeys: o,
78
78
  selectAllByHotkey: d,
79
79
  deleteObjectsByHotkey: c,
80
- resetObjectFitByDoubleClick: l
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), n && (this.canvas.on("selection:created", this.handleBringToFrontBound), this.canvas.on("selection:updated", this.handleBringToFrontBound)), l && this.canvas.on("mouse:dblclick", this.handleResetObjectFitBound), e && window.addEventListener("resize", this.handleContainerResizeBound, { capture: !0 }), i && document.addEventListener("keydown", this.handleCopyEventBound, { capture: !0 }), a && document.addEventListener("paste", this.handlePasteEventBound, { capture: !0 }), o && (document.addEventListener("keydown", this.handleUndoRedoEventBound, { capture: !0 }), document.addEventListener("keyup", this.handleUndoRedoKeyUpBound, { capture: !0 })), d && document.addEventListener("keydown", this.handleSelectAllEventBound, { capture: !0 }), c && document.addEventListener("keydown", this.handleDeleteObjectsEventBound, { capture: !0 }), this.canvas.on("object:modified", this.handleObjectModifiedHistoryBound), this.canvas.on("object:rotating", this.handleObjectRotatingHistoryBound), this.canvas.on("object:added", this.handleObjectAddedHistoryBound), this.canvas.on("object:removed", this.handleObjectRemovedHistoryBound), this.canvas.on("object:added", this.handleOverlayUpdateBound), this.canvas.on("selection:created", this.handleOverlayUpdateBound), this.canvas.on("selection:created", this.handleLockedSelectionBound), this.canvas.on("selection:updated", this.handleLockedSelectionBound);
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 }), i && document.addEventListener("paste", this.handlePasteEventBound, { capture: !0 }), o && (document.addEventListener("keydown", this.handleUndoRedoEventBound, { capture: !0 }), document.addEventListener("keyup", this.handleUndoRedoKeyUpBound, { capture: !0 })), d && document.addEventListener("keydown", this.handleSelectAllEventBound, { capture: !0 }), c && document.addEventListener("keydown", this.handleDeleteObjectsEventBound, { capture: !0 }), this.canvas.on("object:modified", this.handleObjectModifiedHistoryBound), this.canvas.on("object:rotating", this.handleObjectRotatingHistoryBound), this.canvas.on("object:added", this.handleObjectAddedHistoryBound), this.canvas.on("object:removed", this.handleObjectRemovedHistoryBound), this.canvas.on("object:added", this.handleOverlayUpdateBound), this.canvas.on("selection:created", this.handleOverlayUpdateBound), this.canvas.on("selection:created", this.handleLockedSelectionBound), this.canvas.on("selection:updated", this.handleLockedSelectionBound);
83
83
  }
84
84
  /**
85
85
  * При массовом выделении объектов удаляем из него залоченные.
@@ -90,7 +90,7 @@ class z {
90
90
  _filterLockedSelection({ selected: e, e: t }) {
91
91
  if (!(e != null && e.length) || !(t instanceof MouseEvent) || e.length === 1) return;
92
92
  const { lockedObjects: s, unlockedObjects: n } = e.reduce(
93
- (a, o) => o.locked ? (a.lockedObjects.push(o), a) : (a.unlockedObjects.push(o), a),
93
+ (i, o) => o.locked ? (i.lockedObjects.push(o), i) : (i.unlockedObjects.push(o), i),
94
94
  { lockedObjects: [], unlockedObjects: [] }
95
95
  );
96
96
  if (s.length === 0) return;
@@ -98,22 +98,22 @@ class z {
98
98
  if (n.length === 1)
99
99
  this.canvas.setActiveObject(n[0]);
100
100
  else {
101
- const a = new y(n, {
101
+ const i = new y(n, {
102
102
  canvas: this.canvas
103
103
  });
104
- this.canvas.setActiveObject(a);
104
+ this.canvas.setActiveObject(i);
105
105
  }
106
106
  this.canvas.requestRenderAll();
107
107
  return;
108
108
  }
109
- const i = new y(e, {
109
+ const a = new y(e, {
110
110
  canvas: this.canvas
111
111
  });
112
112
  this.editor.objectLockManager.lockObject({
113
- object: i,
113
+ object: a,
114
114
  skipInnerObjects: !0,
115
115
  withoutSave: !0
116
- }), this.canvas.setActiveObject(i), this.canvas.requestRenderAll();
116
+ }), this.canvas.setActiveObject(a), this.canvas.requestRenderAll();
117
117
  }
118
118
  /**
119
119
  * Обработчики для сохранения состояния редактора в истории.
@@ -172,9 +172,9 @@ class z {
172
172
  * @param event.code — код клавиши
173
173
  */
174
174
  handleUndoRedoEvent(e) {
175
- return v(this, null, function* () {
176
- const { ctrlKey: t, metaKey: s, code: n, repeat: i } = e;
177
- this._shouldIgnoreKeyboardEvent(e) || !t && !s || i || !/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()));
175
+ return j(this, null, function* () {
176
+ const { ctrlKey: t, metaKey: s, code: n, repeat: a } = e;
177
+ 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()));
178
178
  });
179
179
  }
180
180
  /**
@@ -213,11 +213,11 @@ class z {
213
213
  */
214
214
  handleSpaceKeyDown(e) {
215
215
  if (e.code !== "Space" || this._shouldIgnoreKeyboardEvent(e)) return;
216
- const { canvas: t, editor: s, isSpacePressed: n, isDragging: i } = this;
217
- if (n || i) return;
216
+ const { canvas: t, editor: s, isSpacePressed: n, isDragging: a } = this;
217
+ if (n || a) return;
218
218
  this.isSpacePressed = !0, e.preventDefault();
219
- const a = t.getActiveObject() || null;
220
- a instanceof y ? this.savedSelection = a.getObjects().slice() : a && (this.savedSelection = [a]), t.discardActiveObject(), t.set({
219
+ const i = t.getActiveObject() || null;
220
+ i instanceof y ? this.savedSelection = i.getObjects().slice() : i && (this.savedSelection = [i]), t.discardActiveObject(), t.set({
221
221
  selection: !1,
222
222
  defaultCursor: "grab"
223
223
  }), t.setCursor("grab"), s.canvasManager.getObjects().forEach((o) => {
@@ -256,8 +256,8 @@ class z {
256
256
  t.setActiveObject(e[0]);
257
257
  return;
258
258
  }
259
- const n = e.filter((a) => s.canvasManager.getObjects().includes(a)), i = new y(n, { canvas: t });
260
- t.setActiveObject(i);
259
+ const n = e.filter((i) => s.canvasManager.getObjects().includes(i)), a = new y(n, { canvas: t });
260
+ t.setActiveObject(a);
261
261
  }
262
262
  // --- Обработчики для событий canvas (Fabric) ---
263
263
  /**
@@ -326,18 +326,18 @@ class z {
326
326
  if (!t) return !1;
327
327
  const s = ["input", "textarea", "select"], n = t.tagName.toLowerCase();
328
328
  if (s.includes(n) || t.contentEditable === "true") return !0;
329
- const { keyboardIgnoreSelectors: i } = this.options;
330
- if (i != null && i.length)
331
- for (const a of i)
329
+ const { keyboardIgnoreSelectors: a } = this.options;
330
+ if (a != null && a.length)
331
+ for (const i of a)
332
332
  try {
333
- if (t.matches && t.matches(a) || t.closest && t.closest(a))
333
+ if (t.matches && t.matches(i) || t.closest && t.closest(i))
334
334
  return !0;
335
335
  } catch (o) {
336
336
  this.editor.errorManager.emitWarning({
337
337
  origin: "Listeners",
338
338
  method: "_shouldIgnoreKeyboardEvent",
339
339
  code: "INVALID_SELECTOR",
340
- message: `Invalid keyboard ignore selector: "${a}". Error: ${o.message}`,
340
+ message: `Invalid keyboard ignore selector: "${i}". Error: ${o.message}`,
341
341
  data: o
342
342
  });
343
343
  }
@@ -364,7 +364,7 @@ class z {
364
364
  };
365
365
  }
366
366
  }
367
- class ke {
367
+ class xe {
368
368
  /**
369
369
  * Класс для динамической загрузки внешних модулей.
370
370
  */
@@ -382,7 +382,7 @@ class ke {
382
382
  return this.loaders[e] ? (this.cache.has(e) || this.cache.set(e, this.loaders[e]()), this.cache.get(e)) : Promise.reject(new Error(`Unknown module "${e}"`));
383
383
  }
384
384
  }
385
- function xe(r) {
385
+ function Be(r) {
386
386
  return new Worker(
387
387
  "" + new URL("assets/worker-CN39s7P7.js", import.meta.url).href,
388
388
  {
@@ -390,13 +390,13 @@ function xe(r) {
390
390
  }
391
391
  );
392
392
  }
393
- class Be {
393
+ class _e {
394
394
  /**
395
395
  * @param scriptUrl — URL скрипта воркера.
396
396
  * По-умолчанию использует DefaultWorker из соседнего файла
397
397
  */
398
398
  constructor(e) {
399
- e ? this.worker = new Worker(e, { type: "module" }) : this.worker = new xe(), this._callbacks = /* @__PURE__ */ new Map(), this.worker.onmessage = this._handleMessage.bind(this);
399
+ e ? this.worker = new Worker(e, { type: "module" }) : this.worker = new Be(), this._callbacks = /* @__PURE__ */ new Map(), this.worker.onmessage = this._handleMessage.bind(this);
400
400
  }
401
401
  /**
402
402
  * Обработчик сообщений от воркера
@@ -409,12 +409,12 @@ class Be {
409
409
  * @returns
410
410
  */
411
411
  _handleMessage({ data: e }) {
412
- const { requestId: t, success: s, data: n, error: i } = e, a = this._callbacks.get(t);
413
- if (!a) {
412
+ const { requestId: t, success: s, data: n, error: a } = e, i = this._callbacks.get(t);
413
+ if (!i) {
414
414
  console.warn(`No callback found for requestId: ${t}`);
415
415
  return;
416
416
  }
417
- s ? a.resolve(n) : a.reject(new Error(i)), this._callbacks.delete(t);
417
+ s ? i.resolve(n) : i.reject(new Error(a)), this._callbacks.delete(t);
418
418
  }
419
419
  /**
420
420
  * Универсальный метод отправки команды в воркер
@@ -424,9 +424,9 @@ class Be {
424
424
  * @returns Promise, который будет выполнен, когда воркер вернет ответ
425
425
  */
426
426
  post(e, t, s = []) {
427
- const n = `${e}:${L(8)}`;
428
- return new Promise((i, a) => {
429
- this._callbacks.set(n, { resolve: i, reject: a }), this.worker.postMessage({ action: e, payload: t, requestId: n }, s);
427
+ const n = `${e}:${D(8)}`;
428
+ return new Promise((a, i) => {
429
+ this._callbacks.set(n, { resolve: a, reject: i }), this.worker.postMessage({ action: e, payload: t, requestId: n }, s);
430
430
  });
431
431
  }
432
432
  /**
@@ -436,26 +436,26 @@ class Be {
436
436
  this.worker.terminate();
437
437
  }
438
438
  }
439
- const N = 12, Ue = 2, K = 8, q = 20, Re = 100, ee = 20, te = 8, Ze = 100, F = 32, se = 1, ze = "#2B2D33", ne = "#3D8BF4", ie = "#FFFFFF";
439
+ const N = 12, Re = 2, K = 8, q = 20, Ue = 100, ee = 20, te = 8, Ze = 100, V = 32, se = 1, ze = "#2B2D33", ne = "#3D8BF4", ae = "#FFFFFF";
440
440
  function W(r, e, t, s, n) {
441
- const i = N, a = Ue;
442
- r.save(), r.translate(e, t), r.rotate(H.degreesToRadians(n.angle)), r.fillStyle = ie, r.strokeStyle = ne, r.lineWidth = se, r.beginPath(), r.roundRect(-i / 2, -i / 2, i, i, a), r.fill(), r.stroke(), r.restore();
441
+ const a = N, i = Re;
442
+ r.save(), r.translate(e, t), r.rotate(H.degreesToRadians(n.angle)), r.fillStyle = ae, r.strokeStyle = ne, r.lineWidth = se, r.beginPath(), r.roundRect(-a / 2, -a / 2, a, a, i), r.fill(), r.stroke(), r.restore();
443
443
  }
444
444
  function ue(r, e, t, s, n) {
445
- const i = K, a = q, o = Re;
446
- r.save(), r.translate(e, t), r.rotate(H.degreesToRadians(n.angle)), r.fillStyle = ie, r.strokeStyle = ne, r.lineWidth = se, r.beginPath(), r.roundRect(-i / 2, -a / 2, i, a, o), r.fill(), r.stroke(), r.restore();
445
+ const a = K, i = q, o = Ue;
446
+ r.save(), r.translate(e, t), r.rotate(H.degreesToRadians(n.angle)), r.fillStyle = ae, r.strokeStyle = ne, r.lineWidth = se, r.beginPath(), r.roundRect(-a / 2, -i / 2, a, i, o), r.fill(), r.stroke(), r.restore();
447
447
  }
448
448
  function Me(r, e, t, s, n) {
449
- const i = ee, a = te, o = Ze;
450
- r.save(), r.translate(e, t), r.rotate(H.degreesToRadians(n.angle)), r.fillStyle = ie, r.strokeStyle = ne, r.lineWidth = se, r.beginPath(), r.roundRect(-i / 2, -a / 2, i, a, o), r.fill(), r.stroke(), r.restore();
449
+ const a = ee, i = te, o = Ze;
450
+ r.save(), r.translate(e, t), r.rotate(H.degreesToRadians(n.angle)), r.fillStyle = ae, r.strokeStyle = ne, r.lineWidth = se, r.beginPath(), r.roundRect(-a / 2, -i / 2, a, i, o), r.fill(), r.stroke(), r.restore();
451
451
  }
452
- const He = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", fe = new Image();
453
- fe.src = He;
452
+ const He = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", je = new Image();
453
+ je.src = He;
454
454
  function Ye(r, e, t, s, n) {
455
- const a = F / 2;
456
- r.save(), r.translate(e, t), r.rotate(H.degreesToRadians(n.angle)), r.fillStyle = ze, r.beginPath(), r.arc(0, 0, a, 0, 2 * Math.PI), r.fill(), r.drawImage(fe, -a / 2, -a / 2, a, a), r.restore();
455
+ const i = V / 2;
456
+ r.save(), r.translate(e, t), r.rotate(H.degreesToRadians(n.angle)), r.fillStyle = ze, r.beginPath(), r.arc(0, 0, i, 0, 2 * Math.PI), r.fill(), r.drawImage(je, -i / 2, -i / 2, i, i), r.restore();
457
457
  }
458
- const _e = {
458
+ const Pe = {
459
459
  // Угловые точки
460
460
  tl: {
461
461
  render: W,
@@ -518,30 +518,30 @@ const _e = {
518
518
  // Специальный «rotate» контрол
519
519
  mtr: {
520
520
  render: Ye,
521
- sizeX: F,
522
- sizeY: F,
521
+ sizeX: V,
522
+ sizeY: V,
523
523
  offsetX: 0,
524
- offsetY: -F
524
+ offsetY: -V
525
525
  }
526
526
  };
527
527
  class We {
528
528
  static apply() {
529
- const e = ve.createObjectDefaultControls();
530
- Object.entries(_e).forEach(([t, s]) => {
529
+ const e = Ae.createObjectDefaultControls();
530
+ Object.entries(Pe).forEach(([t, s]) => {
531
531
  Object.assign(e[t], {
532
532
  render: s.render,
533
533
  sizeX: s.sizeX,
534
534
  sizeY: s.sizeY,
535
535
  offsetX: s.offsetX,
536
536
  offsetY: s.offsetY
537
- }), t === "mtr" && (e[t].cursorStyle = "grab", e[t].mouseDownHandler = (i, a, o, d) => {
538
- var l;
539
- (l = a.target.canvas) == null || l.setCursor("grabbing");
537
+ }), t === "mtr" && (e[t].cursorStyle = "grab", e[t].mouseDownHandler = (a, i, o, d) => {
538
+ var h;
539
+ (h = i.target.canvas) == null || h.setCursor("grabbing");
540
540
  });
541
- }), Ae.ownDefaults.controls = e;
541
+ }), Se.ownDefaults.controls = e;
542
542
  }
543
543
  }
544
- const Pe = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNi44NzUgMi41YS42MjUuNjI1IDAgMCAwLS42MjUuNjI0VjYuMjVIMy4xMjVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2MTBjMCAuMzQ1LjI4LjYyNS42MjUuNjI1aDEwYy4zNDUgMCAuNjI1LS4yOC42MjUtLjYyNXYtMy4xMjZoMy4xMjVjLjM0NSAwIC42MjUtLjI4LjYyNS0uNjI1di0xMGEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTEwWm02Ljg3NSAxMGgyLjVWMy43NUg3LjV2Mi41aDUuNjI1Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NS42MjRabS0xMCAzLjc1VjcuNWg4Ljc1djguNzVIMy43NVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", Fe = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMi41IDcuNWMwLS42OS41Ni0xLjI1IDEuMjUtMS4yNWgxMi41Yy42OSAwIDEuMjUuNTYgMS4y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-608,20 +608,18 @@ const Pe = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
608
608
  ],
609
609
  offsetTop: 50,
610
610
  icons: {
611
- copyPaste: Pe,
612
- delete: Je,
613
- lock: Fe,
614
- unlock: Ve,
615
- bringToFront: Qe,
616
- sendToBack: $e,
617
- bringForward: Ge,
618
- sendBackwards: Xe
611
+ copyPaste: Fe,
612
+ delete: Ke,
613
+ lock: Ve,
614
+ unlock: Ge,
615
+ bringToFront: $e,
616
+ sendToBack: Je,
617
+ bringForward: Xe,
618
+ sendBackwards: Qe
619
619
  },
620
620
  handlers: {
621
- copyPaste: (r) => v(null, null, function* () {
622
- yield r.clipboardManager.copy(), yield r.clipboardManager.paste(), r.clipboardManager.clipboard && r.canvas.fire("editor:object-duplicated", {
623
- object: r.clipboardManager.clipboard
624
- });
621
+ copyPaste: (r) => j(null, null, function* () {
622
+ r.clipboardManager.copyPaste();
625
623
  }),
626
624
  delete: (r) => {
627
625
  r.deletionManager.deleteSelectedObjects();
@@ -646,7 +644,7 @@ const Pe = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
646
644
  }
647
645
  }
648
646
  };
649
- class Ke {
647
+ class qe {
650
648
  constructor({ editor: e }) {
651
649
  this.currentTarget = null, this.currentLocked = !1, this.isTransforming = !1, this.editor = e, this.canvas = e.canvas, this.options = e.options, this._initToolbar();
652
650
  }
@@ -684,8 +682,8 @@ class Ke {
684
682
  _renderButtons(e) {
685
683
  this.el.innerHTML = "";
686
684
  for (const t of e) {
687
- const { name: s, handle: n } = t, { icons: i = {}, btnStyle: a, handlers: o = {} } = this.config, d = document.createElement("button");
688
- d.innerHTML = i[n] ? `<img src="${i[n]}" title="${s}" />` : s, Object.assign(d.style, a), d.onclick = () => {
685
+ const { name: s, handle: n } = t, { icons: a = {}, btnStyle: i, handlers: o = {} } = this.config, d = document.createElement("button");
686
+ d.innerHTML = a[n] ? `<img src="${a[n]}" title="${s}" />` : s, Object.assign(d.style, i), d.onclick = () => {
689
687
  var c;
690
688
  return (c = o[n]) == null ? void 0 : c.call(o, this.editor);
691
689
  }, d.onmousedown = (c) => {
@@ -748,10 +746,10 @@ class Ke {
748
746
  }
749
747
  const { el: t, config: s, canvas: n } = this;
750
748
  e.setCoords();
751
- const i = n.getZoom(), [, , , , a, o] = n.viewportTransform, { x: d } = e.getCenterPoint(), { top: c, height: l } = e.getBoundingRect(), g = d * i + a - t.offsetWidth / 2, u = s.offsetTop || 0, m = (c + l) * i + o + u;
749
+ const a = n.getZoom(), [, , , , i, o] = n.viewportTransform, { x: d } = e.getCenterPoint(), { top: c, height: h } = e.getBoundingRect(), g = d * a + i - t.offsetWidth / 2, M = s.offsetTop || 0, f = (c + h) * a + o + M;
752
750
  Object.assign(t.style, {
753
751
  left: `${g}px`,
754
- top: `${m}px`,
752
+ top: `${f}px`,
755
753
  display: "flex"
756
754
  });
757
755
  }
@@ -762,7 +760,7 @@ class Ke {
762
760
  this.el.removeEventListener("mouseover", this._onBtnOver), this.el.removeEventListener("mouseout", this._onBtnOut), this.canvas.off("mouse:down", this._onMouseDown), this.canvas.off("object:moving", this._onObjectMoving), this.canvas.off("object:scaling", this._onObjectScaling), this.canvas.off("object:rotating", this._onObjectRotating), this.canvas.off("mouse:up", this._onMouseUp), this.canvas.off("object:modified", this._onObjectModified), this.canvas.off("selection:created", this._onSelectionChange), this.canvas.off("selection:updated", this._onSelectionChange), this.canvas.off("after:render", this._onSelectionChange), this.canvas.off("selection:cleared", this._onSelectionClear), this.el.remove();
763
761
  }
764
762
  }
765
- class qe {
763
+ class et {
766
764
  constructor({ editor: e }) {
767
765
  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();
768
766
  }
@@ -774,7 +772,7 @@ class qe {
774
772
  return this.patches[this.currentIndex - 1] || null;
775
773
  }
776
774
  _createDiffPatcher() {
777
- this.diffPatcher = Ee({
775
+ this.diffPatcher = Oe({
778
776
  objectHash(e) {
779
777
  const t = e;
780
778
  return [
@@ -798,7 +796,7 @@ class qe {
798
796
  includeValueOnMove: !1
799
797
  },
800
798
  textDiff: {
801
- diffMatchPatch: Oe,
799
+ diffMatchPatch: Te,
802
800
  minLength: 60
803
801
  }
804
802
  });
@@ -829,8 +827,8 @@ class qe {
829
827
  getFullState() {
830
828
  const { baseState: e, currentIndex: t, patches: s } = this;
831
829
  let n = JSON.parse(JSON.stringify(e));
832
- for (let i = 0; i < t; i += 1)
833
- n = this.diffPatcher.patch(n, s[i].diff);
830
+ for (let a = 0; a < t; a += 1)
831
+ n = this.diffPatcher.patch(n, s[a].diff);
834
832
  return console.log("getFullState state", n), n;
835
833
  }
836
834
  /**
@@ -864,7 +862,7 @@ class qe {
864
862
  console.log("Нет изменений для сохранения.");
865
863
  return;
866
864
  }
867
- console.log("baseState", this.baseState), this.currentIndex < this.patches.length && this.patches.splice(this.currentIndex), console.log("diff", s), this.totalChangesCount += 1, this.patches.push({ id: L(), diff: s }), this.currentIndex += 1, this.patches.length > this.maxHistoryLength && (this.baseState = this.diffPatcher.patch(this.baseState, this.patches[0].diff), this.patches.shift(), this.currentIndex -= 1, this.baseStateChangesCount += 1), console.log("Состояние сохранено. Текущий индекс истории:", this.currentIndex);
865
+ console.log("baseState", this.baseState), this.currentIndex < this.patches.length && this.patches.splice(this.currentIndex), console.log("diff", s), this.totalChangesCount += 1, this.patches.push({ id: D(), diff: s }), this.currentIndex += 1, this.patches.length > this.maxHistoryLength && (this.baseState = this.diffPatcher.patch(this.baseState, this.patches[0].diff), this.patches.shift(), this.currentIndex -= 1, this.baseStateChangesCount += 1), console.log("Состояние сохранено. Текущий индекс истории:", this.currentIndex);
868
866
  }
869
867
  /**
870
868
  * Функция загрузки состояния в канвас.
@@ -872,13 +870,13 @@ class qe {
872
870
  * @fires editor:history-state-loaded
873
871
  */
874
872
  loadStateFromFullState(e) {
875
- return v(this, null, function* () {
873
+ return j(this, null, function* () {
876
874
  if (!e) return;
877
875
  console.log("loadStateFromFullState fullState", e);
878
- const { canvas: t, canvasManager: s, interactionBlocker: n } = this.editor, { width: i, height: a } = t;
876
+ const { canvas: t, canvasManager: s, interactionBlocker: n } = this.editor, { width: a, height: i } = t;
879
877
  yield t.loadFromJSON(e);
880
878
  const o = t.getObjects().find((c) => c.id === "montage-area");
881
- o && (this.editor.montageArea = o, (i !== t.getWidth() || a !== t.getHeight()) && s.updateCanvas());
879
+ o && (this.editor.montageArea = o, (a !== t.getWidth() || i !== t.getHeight()) && s.updateCanvas());
882
880
  const d = t.getObjects().find((c) => c.id === "overlay-mask");
883
881
  d && (n.overlayMask = d, n.overlayMask.visible = !1), t.renderAll(), t.fire("editor:history-state-loaded", {
884
882
  fullState: e,
@@ -895,7 +893,7 @@ class qe {
895
893
  * @fires editor:undo
896
894
  */
897
895
  undo() {
898
- return v(this, null, function* () {
896
+ return j(this, null, function* () {
899
897
  if (!this.skipHistory) {
900
898
  if (this.currentIndex <= 0) {
901
899
  console.log("Нет предыдущих состояний для отмены.");
@@ -932,7 +930,7 @@ class qe {
932
930
  * @fires editor:redo
933
931
  */
934
932
  redo() {
935
- return v(this, null, function* () {
933
+ return j(this, null, function* () {
936
934
  if (!this.skipHistory) {
937
935
  if (this.currentIndex >= this.patches.length) {
938
936
  console.log("Нет состояний для повтора.");
@@ -965,8 +963,8 @@ class qe {
965
963
  });
966
964
  }
967
965
  }
968
- const et = 0.1, tt = 2, st = 0.1, nt = 90, B = 16, U = 16, O = 4096, T = 4096, $ = "application/image-editor:";
969
- class D {
966
+ const tt = 0.1, st = 2, nt = 0.1, at = 90, _ = 16, R = 16, O = 4096, T = 4096, me = "application/image-editor:";
967
+ class E {
970
968
  constructor({ editor: e }) {
971
969
  this.editor = e, this.options = e.options, this._createdBlobUrls = [], this.acceptContentTypes = this.editor.options.acceptContentTypes, this.acceptFormats = this.getAllowedFormatsFromContentTypes();
972
970
  }
@@ -983,81 +981,83 @@ class D {
983
981
  * @returns возвращает Promise с объектом изображения или null в случае ошибки
984
982
  */
985
983
  importImage(e) {
986
- return v(this, null, function* () {
984
+ return j(this, null, function* () {
987
985
  const {
988
986
  source: t,
989
987
  scale: s = `image-${this.options.scaleType}`,
990
- withoutSave: n = !1
988
+ withoutSave: n = !1,
989
+ fromClipboard: a = !1
991
990
  } = e;
992
991
  if (!t) return null;
993
- const { canvas: i, montageArea: a, transformManager: o, historyManager: d, errorManager: c } = this.editor, l = yield this.getContentType(t), h = D.getFormatFromContentType(l), { acceptContentTypes: g, acceptFormats: u } = this;
992
+ const { canvas: i, montageArea: o, transformManager: d, historyManager: c, errorManager: h } = this.editor, l = yield this.getContentType(t), g = E.getFormatFromContentType(l), { acceptContentTypes: M, acceptFormats: f } = this;
994
993
  if (!this.isAllowedContentType(l)) {
995
994
  const m = `Неверный contentType для изображения: ${l}. Ожидается один из: ${this.acceptContentTypes.join(", ")}.`;
996
- return c.emitError({
995
+ return h.emitError({
997
996
  origin: "ImageManager",
998
997
  method: "importImage",
999
998
  code: "INVALID_CONTENT_TYPE",
1000
999
  message: m,
1001
- data: { source: t, format: h, contentType: l, acceptContentTypes: g, acceptFormats: u }
1000
+ data: { source: t, format: g, contentType: l, acceptContentTypes: M, acceptFormats: f, fromClipboard: a }
1002
1001
  }), null;
1003
1002
  }
1004
- d.suspendHistory();
1003
+ c.suspendHistory();
1005
1004
  try {
1006
- let m, M;
1005
+ let m, u;
1007
1006
  if (t instanceof File)
1008
1007
  m = URL.createObjectURL(t);
1009
1008
  else if (typeof t == "string") {
1010
- const S = yield (yield fetch(t, { mode: "cors" })).blob();
1011
- m = URL.createObjectURL(S);
1009
+ const C = yield (yield fetch(t, { mode: "cors" })).blob();
1010
+ m = URL.createObjectURL(C);
1012
1011
  } else
1013
- return c.emitError({
1012
+ return h.emitError({
1014
1013
  origin: "ImageManager",
1015
1014
  method: "importImage",
1016
1015
  code: "INVALID_SOURCE_TYPE",
1017
1016
  message: "Неверный тип источника изображения. Ожидается URL или объект File.",
1018
- data: { source: t, format: h, contentType: l, acceptContentTypes: g, acceptFormats: u }
1017
+ data: { source: t, format: g, contentType: l, acceptContentTypes: M, acceptFormats: f, fromClipboard: a }
1019
1018
  }), null;
1020
- if (this._createdBlobUrls.push(m), h === "svg") {
1021
- const b = yield Se(m);
1022
- M = H.groupSVGElements(b.objects, b.options);
1019
+ if (this._createdBlobUrls.push(m), g === "svg") {
1020
+ const v = yield Ce(m);
1021
+ u = H.groupSVGElements(v.objects, v.options);
1023
1022
  } else
1024
- M = yield R.fromURL(m, { crossOrigin: "anonymous" });
1025
- const { width: f, height: j } = M;
1026
- if (M instanceof R) {
1027
- const b = M.getElement();
1028
- let S = "";
1029
- if (b instanceof HTMLImageElement ? S = b.src : b instanceof HTMLCanvasElement && (S = b.toDataURL()), j > T || f > O) {
1030
- const w = yield this.resizeImageToBoundaries(S, "max"), E = URL.createObjectURL(w);
1031
- this._createdBlobUrls.push(E), M = yield R.fromURL(E, { crossOrigin: "anonymous" });
1032
- } else if (j < U || f < B) {
1033
- const w = yield this.resizeImageToBoundaries(S, "min"), E = URL.createObjectURL(w);
1034
- this._createdBlobUrls.push(E), M = yield R.fromURL(E, { crossOrigin: "anonymous" });
1023
+ u = yield U.fromURL(m, { crossOrigin: "anonymous" });
1024
+ const { width: b, height: A } = u;
1025
+ if (u instanceof U) {
1026
+ const v = u.getElement();
1027
+ let C = "";
1028
+ if (v instanceof HTMLImageElement ? C = v.src : v instanceof HTMLCanvasElement && (C = v.toDataURL()), A > T || b > O) {
1029
+ const w = yield this.resizeImageToBoundaries(C, "max"), k = URL.createObjectURL(w);
1030
+ this._createdBlobUrls.push(k), u = yield U.fromURL(k, { crossOrigin: "anonymous" });
1031
+ } else if (A < R || b < _) {
1032
+ const w = yield this.resizeImageToBoundaries(C, "min"), k = URL.createObjectURL(w);
1033
+ this._createdBlobUrls.push(k), u = yield U.fromURL(k, { crossOrigin: "anonymous" });
1035
1034
  }
1036
1035
  }
1037
- if (M.set("id", `${M.type}-${L()}`), M.set("format", h), s === "scale-montage")
1038
- this.editor.canvasManager.scaleMontageAreaToImage({ object: M, withoutSave: !0 });
1036
+ if (u.set("id", `${u.type}-${D()}`), u.set("format", g), s === "scale-montage")
1037
+ this.editor.canvasManager.scaleMontageAreaToImage({ object: u, withoutSave: !0 });
1039
1038
  else {
1040
- const { width: b, height: S } = a, w = this.calculateScaleFactor({ imageObject: M, scaleType: s });
1041
- s === "image-contain" && w < 1 ? o.fitObject({ object: M, type: "contain", withoutSave: !0 }) : s === "image-cover" && (f > b || j > S) && o.fitObject({ object: M, type: "cover", withoutSave: !0 });
1039
+ const { width: v, height: C } = o, w = this.calculateScaleFactor({ imageObject: u, scaleType: s });
1040
+ s === "image-contain" && w < 1 ? d.fitObject({ object: u, type: "contain", withoutSave: !0 }) : s === "image-cover" && (b > v || A > C) && d.fitObject({ object: u, type: "cover", withoutSave: !0 });
1042
1041
  }
1043
- i.add(M), i.centerObject(M), i.setActiveObject(M), i.renderAll(), d.resumeHistory(), n || d.saveState();
1044
- const A = {
1045
- image: M,
1046
- format: h,
1042
+ i.add(u), i.centerObject(u), i.setActiveObject(u), i.renderAll(), c.resumeHistory(), n || c.saveState();
1043
+ const S = {
1044
+ image: u,
1045
+ format: g,
1047
1046
  contentType: l,
1048
1047
  scale: s,
1049
1048
  withoutSave: n,
1050
- source: t
1049
+ source: t,
1050
+ fromClipboard: a
1051
1051
  };
1052
- return i.fire("editor:image-imported", A), A;
1052
+ return i.fire("editor:image-imported", S), S;
1053
1053
  } catch (m) {
1054
- return c.emitError({
1054
+ return h.emitError({
1055
1055
  origin: "ImageManager",
1056
1056
  method: "importImage",
1057
1057
  code: "IMPORT_FAILED",
1058
1058
  message: `Ошибка импорта изображения: ${m.message}`,
1059
- data: { source: t, format: h, contentType: l, scale: s, withoutSave: n }
1060
- }), d.resumeHistory(), null;
1059
+ data: { source: t, format: g, contentType: l, scale: s, withoutSave: n, fromClipboard: a }
1060
+ }), c.resumeHistory(), null;
1061
1061
  }
1062
1062
  });
1063
1063
  }
@@ -1070,16 +1070,16 @@ class D {
1070
1070
  * @returns возвращает Promise с Blob-объектом уменьшенного изображения
1071
1071
  */
1072
1072
  resizeImageToBoundaries(e, t = "max") {
1073
- return v(this, null, function* () {
1073
+ return j(this, null, function* () {
1074
1074
  let s = `Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ${O}x${T}`;
1075
- t === "min" && (s = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${B}x${U}`);
1075
+ t === "min" && (s = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${_}x${R}`);
1076
1076
  const n = {
1077
1077
  dataURL: e,
1078
1078
  sizeType: t,
1079
1079
  maxWidth: O,
1080
1080
  maxHeight: T,
1081
- minWidth: B,
1082
- minHeight: U
1081
+ minWidth: _,
1082
+ minHeight: R
1083
1083
  };
1084
1084
  return this.editor.errorManager.emitWarning({
1085
1085
  origin: "ImageManager",
@@ -1102,101 +1102,101 @@ class D {
1102
1102
  * @fires editor:canvas-exported
1103
1103
  */
1104
1104
  exportCanvasAsImageFile() {
1105
- return v(this, arguments, function* (e = {}) {
1105
+ return j(this, arguments, function* (e = {}) {
1106
1106
  const {
1107
1107
  fileName: t = "image.png",
1108
1108
  contentType: s = "image/png",
1109
1109
  exportAsBase64: n = !1,
1110
- exportAsBlob: i = !1
1111
- } = e, { canvas: a, montageArea: o, workerManager: d } = this.editor;
1110
+ exportAsBlob: a = !1
1111
+ } = e, { canvas: i, montageArea: o, workerManager: d } = this.editor;
1112
1112
  try {
1113
- const c = s === "application/pdf", l = c ? "image/jpg" : s, h = D.getFormatFromContentType(l);
1113
+ const c = s === "application/pdf", h = c ? "image/jpg" : s, l = E.getFormatFromContentType(h);
1114
1114
  o.setCoords();
1115
- const { left: g, top: u, width: m, height: M } = o.getBoundingRect(), f = yield a.clone(["id", "format", "locked"]);
1116
- f.enableRetinaScaling = !1, ["image/jpg", "image/jpeg"].includes(l) && (f.backgroundColor = "#ffffff");
1117
- const j = f.getObjects().find((I) => I.id === o.id);
1118
- j && (j.visible = !1), f.viewportTransform = [1, 0, 0, 1, -g, -u], f.setDimensions({ width: m, height: M }, { backstoreOnly: !0 }), f.renderAll();
1119
- const A = f.getObjects().filter((I) => I.format).every((I) => I.format === "svg");
1120
- if (h === "svg" && A) {
1121
- const I = f.toSVG();
1122
- f.dispose();
1123
- const C = {
1124
- image: D._exportSVGStringAsFile(I, {
1115
+ const { left: g, top: M, width: f, height: m } = o.getBoundingRect(), u = yield i.clone(["id", "format", "locked"]);
1116
+ u.enableRetinaScaling = !1, ["image/jpg", "image/jpeg"].includes(h) && (u.backgroundColor = "#ffffff");
1117
+ const b = u.getObjects().find((I) => I.id === o.id);
1118
+ b && (b.visible = !1), u.viewportTransform = [1, 0, 0, 1, -g, -M], u.setDimensions({ width: f, height: m }, { backstoreOnly: !0 }), u.renderAll();
1119
+ const A = u.getObjects().filter((I) => I.format).every((I) => I.format === "svg");
1120
+ if (l === "svg" && A) {
1121
+ const I = u.toSVG();
1122
+ u.dispose();
1123
+ const L = {
1124
+ image: E._exportSVGStringAsFile(I, {
1125
1125
  exportAsBase64: n,
1126
- exportAsBlob: i,
1126
+ exportAsBlob: a,
1127
1127
  fileName: t
1128
1128
  }),
1129
1129
  format: "svg",
1130
1130
  contentType: "image/svg+xml",
1131
1131
  fileName: t.replace(/\.[^/.]+$/, ".svg")
1132
1132
  };
1133
- return a.fire("editor:canvas-exported", C), C;
1133
+ return i.fire("editor:canvas-exported", L), L;
1134
1134
  }
1135
- const b = yield new Promise((I, k) => {
1136
- f.getElement().toBlob((C) => {
1137
- C ? I(C) : k(new Error("Failed to create Blob from canvas"));
1135
+ const S = yield new Promise((I, x) => {
1136
+ u.getElement().toBlob((L) => {
1137
+ L ? I(L) : x(new Error("Failed to create Blob from canvas"));
1138
1138
  });
1139
1139
  });
1140
- if (f.dispose(), i) {
1140
+ if (u.dispose(), a) {
1141
1141
  const I = {
1142
- image: b,
1143
- format: h,
1144
- contentType: l,
1142
+ image: S,
1143
+ format: l,
1144
+ contentType: h,
1145
1145
  fileName: t
1146
1146
  };
1147
- return a.fire("editor:canvas-exported", I), I;
1147
+ return i.fire("editor:canvas-exported", I), I;
1148
1148
  }
1149
- const S = yield createImageBitmap(b), w = yield d.post(
1149
+ const v = yield createImageBitmap(S), C = yield d.post(
1150
1150
  "toDataURL",
1151
- { format: h, quality: 1, bitmap: S },
1152
- [S]
1151
+ { format: l, quality: 1, bitmap: v },
1152
+ [v]
1153
1153
  );
1154
1154
  if (c) {
1155
- const k = m * 0.264583, C = M * 0.264583, je = (yield this.editor.moduleLoader.loadModule("jspdf")).jsPDF, Q = new je({
1156
- orientation: k > C ? "landscape" : "portrait",
1155
+ const x = f * 0.264583, L = m * 0.264583, be = (yield this.editor.moduleLoader.loadModule("jspdf")).jsPDF, $ = new be({
1156
+ orientation: x > L ? "landscape" : "portrait",
1157
1157
  unit: "mm",
1158
- format: [k, C]
1158
+ format: [x, L]
1159
1159
  });
1160
- if (Q.addImage(String(w), "JPG", 0, 0, k, C), n) {
1160
+ if ($.addImage(String(C), "JPG", 0, 0, x, L), n) {
1161
1161
  const ce = {
1162
- image: Q.output("datauristring"),
1162
+ image: $.output("datauristring"),
1163
1163
  format: "pdf",
1164
1164
  contentType: "application/pdf",
1165
1165
  fileName: t
1166
1166
  };
1167
- return a.fire("editor:canvas-exported", ce), ce;
1167
+ return i.fire("editor:canvas-exported", ce), ce;
1168
1168
  }
1169
- const be = Q.output("blob"), re = {
1170
- image: new File([be], t, { type: "application/pdf" }),
1169
+ const pe = $.output("blob"), re = {
1170
+ image: new File([pe], t, { type: "application/pdf" }),
1171
1171
  format: "pdf",
1172
1172
  contentType: "application/pdf",
1173
1173
  fileName: t
1174
1174
  };
1175
- return a.fire("editor:canvas-exported", re), re;
1175
+ return i.fire("editor:canvas-exported", re), re;
1176
1176
  }
1177
1177
  if (n) {
1178
1178
  const I = {
1179
- image: w,
1180
- format: h,
1181
- contentType: l,
1179
+ image: C,
1180
+ format: l,
1181
+ contentType: h,
1182
1182
  fileName: t
1183
1183
  };
1184
- return a.fire("editor:canvas-exported", I), I;
1184
+ return i.fire("editor:canvas-exported", I), I;
1185
1185
  }
1186
- const E = h === "svg" && !A ? t.replace(/\.[^/.]+$/, ".png") : t, oe = {
1187
- image: new File([b], E, { type: l }),
1188
- format: h,
1189
- contentType: l,
1190
- fileName: E
1186
+ const w = l === "svg" && !A ? t.replace(/\.[^/.]+$/, ".png") : t, oe = {
1187
+ image: new File([S], w, { type: h }),
1188
+ format: l,
1189
+ contentType: h,
1190
+ fileName: w
1191
1191
  };
1192
- return a.fire("editor:canvas-exported", oe), oe;
1192
+ return i.fire("editor:canvas-exported", oe), oe;
1193
1193
  } catch (c) {
1194
1194
  return this.editor.errorManager.emitError({
1195
1195
  origin: "ImageManager",
1196
1196
  method: "exportCanvasAsImageFile",
1197
1197
  code: "IMAGE_EXPORT_FAILED",
1198
1198
  message: `Ошибка экспорта изображения: ${c.message}`,
1199
- data: { contentType: s, fileName: t, exportAsBase64: n, exportAsBlob: i }
1199
+ data: { contentType: s, fileName: t, exportAsBase64: n, exportAsBlob: a }
1200
1200
  }), null;
1201
1201
  }
1202
1202
  });
@@ -1213,13 +1213,13 @@ class D {
1213
1213
  * @fires editor:object-exported
1214
1214
  */
1215
1215
  exportObjectAsImageFile() {
1216
- return v(this, arguments, function* (e = {}) {
1216
+ return j(this, arguments, function* (e = {}) {
1217
1217
  const {
1218
1218
  object: t,
1219
1219
  fileName: s = "image.png",
1220
1220
  contentType: n = "image/png",
1221
- exportAsBase64: i = !1,
1222
- exportAsBlob: a = !1
1221
+ exportAsBase64: a = !1,
1222
+ exportAsBlob: i = !1
1223
1223
  } = e, { canvas: o, workerManager: d } = this.editor, c = t || o.getActiveObject();
1224
1224
  if (!c)
1225
1225
  return this.editor.errorManager.emitError({
@@ -1227,74 +1227,74 @@ class D {
1227
1227
  method: "exportObjectAsImageFile",
1228
1228
  code: "NO_OBJECT_SELECTED",
1229
1229
  message: "Не выбран объект для экспорта",
1230
- data: { contentType: n, fileName: s, exportAsBase64: i, exportAsBlob: a }
1230
+ data: { contentType: n, fileName: s, exportAsBase64: a, exportAsBlob: i }
1231
1231
  }), null;
1232
1232
  try {
1233
- const l = D.getFormatFromContentType(n);
1234
- if (l === "svg") {
1235
- const M = c.toSVG(), f = D._exportSVGStringAsFile(M, {
1236
- exportAsBase64: i,
1237
- exportAsBlob: a,
1233
+ const h = E.getFormatFromContentType(n);
1234
+ if (h === "svg") {
1235
+ const m = c.toSVG(), u = E._exportSVGStringAsFile(m, {
1236
+ exportAsBase64: a,
1237
+ exportAsBlob: i,
1238
1238
  fileName: s
1239
- }), j = {
1239
+ }), b = {
1240
1240
  object: c,
1241
- image: f,
1242
- format: l,
1241
+ image: u,
1242
+ format: h,
1243
1243
  contentType: "image/svg+xml",
1244
1244
  fileName: s.replace(/\.[^/.]+$/, ".svg")
1245
1245
  };
1246
- return o.fire("editor:object-exported", j), j;
1246
+ return o.fire("editor:object-exported", b), b;
1247
1247
  }
1248
- if (i && c instanceof R) {
1249
- const M = yield createImageBitmap(c.getElement()), f = yield d.post(
1248
+ if (a && c instanceof U) {
1249
+ const m = yield createImageBitmap(c.getElement()), u = yield d.post(
1250
1250
  "toDataURL",
1251
1251
  {
1252
- format: l,
1252
+ format: h,
1253
1253
  quality: 1,
1254
- bitmap: M
1254
+ bitmap: m
1255
1255
  },
1256
- [M]
1257
- ), j = {
1256
+ [m]
1257
+ ), b = {
1258
1258
  object: c,
1259
- image: f,
1260
- format: l,
1259
+ image: u,
1260
+ format: h,
1261
1261
  contentType: n,
1262
1262
  fileName: s
1263
1263
  };
1264
- return o.fire("editor:object-exported", j), j;
1264
+ return o.fire("editor:object-exported", b), b;
1265
1265
  }
1266
- const h = c.toCanvasElement({
1266
+ const l = c.toCanvasElement({
1267
1267
  enableRetinaScaling: !1
1268
- }), g = yield new Promise((M, f) => {
1269
- h.toBlob((j) => {
1270
- j ? M(j) : f(new Error("Failed to create Blob from canvas"));
1268
+ }), g = yield new Promise((m, u) => {
1269
+ l.toBlob((b) => {
1270
+ b ? m(b) : u(new Error("Failed to create Blob from canvas"));
1271
1271
  });
1272
1272
  });
1273
- if (a) {
1274
- const M = {
1273
+ if (i) {
1274
+ const m = {
1275
1275
  object: c,
1276
1276
  image: g,
1277
- format: l,
1277
+ format: h,
1278
1278
  contentType: n,
1279
1279
  fileName: s
1280
1280
  };
1281
- return o.fire("editor:object-exported", M), M;
1281
+ return o.fire("editor:object-exported", m), m;
1282
1282
  }
1283
- const u = new File([g], s, { type: n }), m = {
1283
+ const M = new File([g], s, { type: n }), f = {
1284
1284
  object: c,
1285
- image: u,
1286
- format: l,
1285
+ image: M,
1286
+ format: h,
1287
1287
  contentType: n,
1288
1288
  fileName: s
1289
1289
  };
1290
- return o.fire("editor:object-exported", m), m;
1291
- } catch (l) {
1290
+ return o.fire("editor:object-exported", f), f;
1291
+ } catch (h) {
1292
1292
  return this.editor.errorManager.emitError({
1293
1293
  origin: "ImageManager",
1294
1294
  method: "exportObjectAsImageFile",
1295
1295
  code: "IMAGE_EXPORT_FAILED",
1296
- message: `Ошибка экспорта объекта: ${l.message}`,
1297
- data: { contentType: n, fileName: s, exportAsBase64: i, exportAsBlob: a }
1296
+ message: `Ошибка экспорта объекта: ${h.message}`,
1297
+ data: { contentType: n, fileName: s, exportAsBase64: a, exportAsBlob: i }
1298
1298
  }), null;
1299
1299
  }
1300
1300
  });
@@ -1310,7 +1310,7 @@ class D {
1310
1310
  * @returns массив допустимых форматов изображений
1311
1311
  */
1312
1312
  getAllowedFormatsFromContentTypes() {
1313
- return this.acceptContentTypes.map((e) => D.getFormatFromContentType(e)).filter((e) => e);
1313
+ return this.acceptContentTypes.map((e) => E.getFormatFromContentType(e)).filter((e) => e);
1314
1314
  }
1315
1315
  /**
1316
1316
  * Проверяет, является ли contentType допустимым типом изображения.
@@ -1326,7 +1326,7 @@ class D {
1326
1326
  * @public
1327
1327
  */
1328
1328
  getContentType(e) {
1329
- return v(this, null, function* () {
1329
+ return j(this, null, function* () {
1330
1330
  return typeof e == "string" ? this.getContentTypeFromUrl(e) : e.type || "application/octet-stream";
1331
1331
  });
1332
1332
  }
@@ -1337,7 +1337,7 @@ class D {
1337
1337
  * @public
1338
1338
  */
1339
1339
  getContentTypeFromUrl(e) {
1340
- return v(this, null, function* () {
1340
+ return j(this, null, function* () {
1341
1341
  if (e.startsWith("data:")) {
1342
1342
  const t = e.match(/^data:([^;]+)/);
1343
1343
  return t ? t[1] : "application/octet-stream";
@@ -1361,11 +1361,11 @@ class D {
1361
1361
  getContentTypeFromExtension(e) {
1362
1362
  var t;
1363
1363
  try {
1364
- const n = (t = new URL(e).pathname.split(".").pop()) == null ? void 0 : t.toLowerCase(), i = {};
1365
- return this.acceptContentTypes.forEach((a) => {
1366
- const o = D.getFormatFromContentType(a);
1367
- o && (i[o] = a);
1368
- }), n && i[n] || "application/octet-stream";
1364
+ const n = (t = new URL(e).pathname.split(".").pop()) == null ? void 0 : t.toLowerCase(), a = {};
1365
+ return this.acceptContentTypes.forEach((i) => {
1366
+ const o = E.getFormatFromContentType(i);
1367
+ o && (a[o] = i);
1368
+ }), n && a[n] || "application/octet-stream";
1369
1369
  } catch (s) {
1370
1370
  return console.warn("Не удалось определить расширение из URL:", e, s), "application/octet-stream";
1371
1371
  }
@@ -1383,8 +1383,8 @@ class D {
1383
1383
  }) {
1384
1384
  const { montageArea: s } = this.editor;
1385
1385
  if (!s || !e) return 1;
1386
- const n = s.width, i = s.height, { width: a, height: o } = e;
1387
- return t === "contain" || t === "image-contain" ? Math.min(n / a, i / o) : t === "cover" || t === "image-cover" ? Math.max(n / a, i / o) : 1;
1386
+ const n = s.width, a = s.height, { width: i, height: o } = e;
1387
+ return t === "contain" || t === "image-contain" ? Math.min(n / i, a / o) : t === "cover" || t === "image-cover" ? Math.max(n / i, a / o) : 1;
1388
1388
  }
1389
1389
  /**
1390
1390
  * Преобразует SVG-строку в Blob, файл, или base64
@@ -1416,11 +1416,11 @@ class D {
1416
1416
  return t ? t[1] : "";
1417
1417
  }
1418
1418
  }
1419
- const x = (r, e, t) => Math.max(Math.min(r, t), e), me = (r, e) => r * e, it = (r, e) => new P(r / 2, e / 2);
1420
- function at(r) {
1419
+ const B = (r, e, t) => Math.max(Math.min(r, t), e), fe = (r, e) => r * e, it = (r, e) => new F(r / 2, e / 2);
1420
+ function ot(r) {
1421
1421
  return ((r == null ? void 0 : r.type) === "image" || (r == null ? void 0 : r.format) === "svg") && typeof (r == null ? void 0 : r.width) == "number" && typeof (r == null ? void 0 : r.height) == "number";
1422
1422
  }
1423
- class ot {
1423
+ class rt {
1424
1424
  /**
1425
1425
  * @param options
1426
1426
  * @param options.editor – экземпляр редактора
@@ -1445,21 +1445,21 @@ class ot {
1445
1445
  * @fires editor:resolution-width-changed
1446
1446
  */
1447
1447
  setResolutionWidth(e, { preserveProportional: t, withoutSave: s, adaptCanvasToContainer: n } = {}) {
1448
- var m;
1448
+ var f;
1449
1449
  if (!e) return;
1450
1450
  const {
1451
- canvas: i,
1452
- montageArea: a,
1451
+ canvas: a,
1452
+ montageArea: i,
1453
1453
  options: { canvasBackstoreWidth: o }
1454
- } = this.editor, { width: d, height: c } = a, l = x(Number(e), B, O);
1455
- if (!o || o === "auto" || n ? this.adaptCanvasToContainer() : o ? this.setCanvasBackstoreWidth(Number(o)) : this.setCanvasBackstoreWidth(l), a.set({ width: l }), (m = i.clipPath) == null || m.set({ width: l }), t) {
1456
- const M = l / d, f = me(c, M);
1457
- this.setResolutionHeight(f);
1454
+ } = this.editor, { width: d, height: c } = i, h = B(Number(e), _, O);
1455
+ if (!o || o === "auto" || n ? this.adaptCanvasToContainer() : o ? this.setCanvasBackstoreWidth(Number(o)) : this.setCanvasBackstoreWidth(h), i.set({ width: h }), (f = a.clipPath) == null || f.set({ width: h }), t) {
1456
+ const m = h / d, u = fe(c, m);
1457
+ this.setResolutionHeight(u);
1458
1458
  return;
1459
1459
  }
1460
- const { left: h, top: g } = this.getObjectDefaultCoords(a), u = i.getZoom();
1461
- i.setViewportTransform([u, 0, 0, u, h, g]), this.centerMontageArea(), s || this.editor.historyManager.saveState(), i.fire("editor:resolution-width-changed", {
1462
- width: l,
1460
+ const { left: l, top: g } = this.getObjectDefaultCoords(i), M = a.getZoom();
1461
+ a.setViewportTransform([M, 0, 0, M, l, g]), this.centerMontageArea(), s || this.editor.historyManager.saveState(), a.fire("editor:resolution-width-changed", {
1462
+ width: h,
1463
1463
  preserveProportional: t,
1464
1464
  withoutSave: s,
1465
1465
  adaptCanvasToContainer: n
@@ -1475,21 +1475,21 @@ class ot {
1475
1475
  * @fires editor:resolution-height-changed
1476
1476
  */
1477
1477
  setResolutionHeight(e, { preserveProportional: t, withoutSave: s, adaptCanvasToContainer: n } = {}) {
1478
- var m;
1478
+ var f;
1479
1479
  if (!e) return;
1480
1480
  const {
1481
- canvas: i,
1482
- montageArea: a,
1481
+ canvas: a,
1482
+ montageArea: i,
1483
1483
  options: { canvasBackstoreHeight: o }
1484
- } = this.editor, { width: d, height: c } = a, l = x(Number(e), U, T);
1485
- if (!o || o === "auto" || n ? this.adaptCanvasToContainer() : o ? this.setCanvasBackstoreHeight(Number(o)) : this.setCanvasBackstoreHeight(l), a.set({ height: l }), (m = i.clipPath) == null || m.set({ height: l }), t) {
1486
- const M = l / c, f = me(d, M);
1487
- this.setResolutionWidth(f);
1484
+ } = this.editor, { width: d, height: c } = i, h = B(Number(e), R, T);
1485
+ if (!o || o === "auto" || n ? this.adaptCanvasToContainer() : o ? this.setCanvasBackstoreHeight(Number(o)) : this.setCanvasBackstoreHeight(h), i.set({ height: h }), (f = a.clipPath) == null || f.set({ height: h }), t) {
1486
+ const m = h / c, u = fe(d, m);
1487
+ this.setResolutionWidth(u);
1488
1488
  return;
1489
1489
  }
1490
- const { left: h, top: g } = this.getObjectDefaultCoords(a), u = i.getZoom();
1491
- i.setViewportTransform([u, 0, 0, u, h, g]), this.centerMontageArea(), s || this.editor.historyManager.saveState(), i.fire("editor:resolution-height-changed", {
1492
- height: l,
1490
+ const { left: l, top: g } = this.getObjectDefaultCoords(i), M = a.getZoom();
1491
+ a.setViewportTransform([M, 0, 0, M, l, g]), this.centerMontageArea(), s || this.editor.historyManager.saveState(), a.fire("editor:resolution-height-changed", {
1492
+ height: h,
1493
1493
  preserveProportional: t,
1494
1494
  withoutSave: s,
1495
1495
  adaptCanvasToContainer: n
@@ -1501,7 +1501,7 @@ class ot {
1501
1501
  */
1502
1502
  centerMontageArea() {
1503
1503
  var d;
1504
- const { canvas: e, montageArea: t } = this.editor, s = e.getWidth(), n = e.getHeight(), i = e.getZoom(), a = it(s, n);
1504
+ const { canvas: e, montageArea: t } = this.editor, s = e.getWidth(), n = e.getHeight(), a = e.getZoom(), i = it(s, n);
1505
1505
  t.set({
1506
1506
  left: s / 2,
1507
1507
  top: n / 2
@@ -1510,7 +1510,7 @@ class ot {
1510
1510
  top: n / 2
1511
1511
  }), e.renderAll();
1512
1512
  const o = e.viewportTransform;
1513
- o[4] = s / 2 - a.x * i, o[5] = n / 2 - a.y * i, e.setViewportTransform(o), e.renderAll();
1513
+ o[4] = s / 2 - i.x * a, o[5] = n / 2 - i.y * a, e.setViewportTransform(o), e.renderAll();
1514
1514
  }
1515
1515
  /**
1516
1516
  * Метод для получения координат объекта с учетом текущего зума
@@ -1526,7 +1526,7 @@ class ot {
1526
1526
  code: "NO_ACTIVE_OBJECT",
1527
1527
  message: "Не выбран объект для получения координат"
1528
1528
  }), { left: 0, top: 0 };
1529
- const { width: n, height: i } = s, a = t.getZoom(), o = (n - n * a) / 2, d = (i - i * a) / 2;
1529
+ const { width: n, height: a } = s, i = t.getZoom(), o = (n - n * i) / 2, d = (a - a * i) / 2;
1530
1530
  return { left: o, top: d };
1531
1531
  }
1532
1532
  /**
@@ -1534,7 +1534,7 @@ class ot {
1534
1534
  */
1535
1535
  setCanvasBackstoreWidth(e) {
1536
1536
  if (!e || typeof e != "number") return;
1537
- const t = x(e, B, O);
1537
+ const t = B(e, _, O);
1538
1538
  this.editor.canvas.setDimensions({ width: t }, { backstoreOnly: !0 });
1539
1539
  }
1540
1540
  /**
@@ -1543,7 +1543,7 @@ class ot {
1543
1543
  */
1544
1544
  setCanvasBackstoreHeight(e) {
1545
1545
  if (!e || typeof e != "number") return;
1546
- const t = x(e, U, T);
1546
+ const t = B(e, R, T);
1547
1547
  this.editor.canvas.setDimensions({ height: t }, { backstoreOnly: !0 });
1548
1548
  }
1549
1549
  /**
@@ -1552,8 +1552,8 @@ class ot {
1552
1552
  * с учётом минимальных и максимальных значений.
1553
1553
  */
1554
1554
  adaptCanvasToContainer() {
1555
- const { canvas: e } = this.editor, t = this.getEditorContainer(), s = t.clientWidth, n = t.clientHeight, i = x(s, B, O), a = x(n, U, T);
1556
- e.setDimensions({ width: i, height: a }, { backstoreOnly: !0 });
1555
+ const { canvas: e } = this.editor, t = this.getEditorContainer(), s = t.clientWidth, n = t.clientHeight, a = B(s, _, O), i = B(n, R, T);
1556
+ e.setDimensions({ width: a, height: i }, { backstoreOnly: !0 });
1557
1557
  }
1558
1558
  /**
1559
1559
  * Обновляет размеры канваса без изменения позиций объектов.
@@ -1568,28 +1568,28 @@ class ot {
1568
1568
  width: s,
1569
1569
  height: n
1570
1570
  }
1571
- } = this.editor, i = t.left, a = t.top;
1571
+ } = this.editor, a = t.left, i = t.top;
1572
1572
  this.setResolutionWidth(s, { adaptCanvasToContainer: !0, withoutSave: !0 }), this.setResolutionHeight(n, { adaptCanvasToContainer: !0, withoutSave: !0 }), this.centerMontageArea();
1573
- const o = t.left - i, d = t.top - a;
1573
+ const o = t.left - a, d = t.top - i;
1574
1574
  if (o !== 0 || d !== 0) {
1575
- const c = e.getActiveObject(), l = [];
1575
+ const c = e.getActiveObject(), h = [];
1576
1576
  if ((c == null ? void 0 : c.type) === "activeselection") {
1577
- const h = c;
1578
- l.push(...h.getObjects()), e.discardActiveObject();
1577
+ const l = c;
1578
+ h.push(...l.getObjects()), e.discardActiveObject();
1579
1579
  }
1580
- if (e.getObjects().forEach((h) => {
1581
- h.id === "montage-area" || h.id === "overlay-mask" || (h.set({
1582
- left: h.left + o,
1583
- top: h.top + d
1584
- }), h.setCoords());
1585
- }), l.length > 0)
1586
- if (l.length === 1)
1587
- e.setActiveObject(l[0]);
1580
+ if (e.getObjects().forEach((l) => {
1581
+ l.id === "montage-area" || l.id === "overlay-mask" || (l.set({
1582
+ left: l.left + o,
1583
+ top: l.top + d
1584
+ }), l.setCoords());
1585
+ }), h.length > 0)
1586
+ if (h.length === 1)
1587
+ e.setActiveObject(h[0]);
1588
1588
  else {
1589
- const h = new y(l, {
1589
+ const l = new y(h, {
1590
1590
  canvas: e
1591
1591
  });
1592
- e.setActiveObject(h);
1592
+ e.setActiveObject(l);
1593
1593
  }
1594
1594
  }
1595
1595
  e.renderAll(), e.fire("editor:canvas-updated", {
@@ -1704,32 +1704,32 @@ class ot {
1704
1704
  */
1705
1705
  setDisplayDimension({ element: e = "canvas", dimension: t, value: s } = {}) {
1706
1706
  if (!s) return;
1707
- const { canvas: n } = this.editor, i = [];
1707
+ const { canvas: n } = this.editor, a = [];
1708
1708
  switch (e) {
1709
1709
  case "canvas":
1710
- i.push(n.lowerCanvasEl, n.upperCanvasEl);
1710
+ a.push(n.lowerCanvasEl, n.upperCanvasEl);
1711
1711
  break;
1712
1712
  case "wrapper":
1713
- i.push(n.wrapperEl);
1713
+ a.push(n.wrapperEl);
1714
1714
  break;
1715
1715
  case "container":
1716
- i.push(this.getEditorContainer());
1716
+ a.push(this.getEditorContainer());
1717
1717
  break;
1718
1718
  default:
1719
- i.push(n.lowerCanvasEl, n.upperCanvasEl);
1719
+ a.push(n.lowerCanvasEl, n.upperCanvasEl);
1720
1720
  }
1721
- const a = t === "width" ? "width" : "height";
1721
+ const i = t === "width" ? "width" : "height";
1722
1722
  if (typeof s == "string") {
1723
- i.forEach((d) => {
1724
- d.style[a] = s;
1723
+ a.forEach((d) => {
1724
+ d.style[i] = s;
1725
1725
  });
1726
1726
  return;
1727
1727
  }
1728
1728
  if (isNaN(s)) return;
1729
1729
  const o = `${s}px`;
1730
- i.forEach((d) => {
1731
- d.style[a] = o;
1732
- }), n.fire(`editor:display-${e}-${a}-changed`, {
1730
+ a.forEach((d) => {
1731
+ d.style[i] = o;
1732
+ }), n.fire(`editor:display-${e}-${i}-changed`, {
1733
1733
  element: e,
1734
1734
  value: s
1735
1735
  });
@@ -1745,27 +1745,27 @@ class ot {
1745
1745
  scaleMontageAreaToImage({ object: e, preserveAspectRatio: t, withoutSave: s } = {}) {
1746
1746
  const {
1747
1747
  canvas: n,
1748
- montageArea: i,
1749
- transformManager: a,
1748
+ montageArea: a,
1749
+ transformManager: i,
1750
1750
  options: {
1751
1751
  montageAreaWidth: o,
1752
1752
  montageAreaHeight: d
1753
1753
  }
1754
1754
  } = this.editor, c = e || n.getActiveObject();
1755
- if (!at(c)) return;
1756
- const { width: l, height: h } = c;
1757
- let g = Math.min(l, O), u = Math.min(h, T);
1755
+ if (!ot(c)) return;
1756
+ const { width: h, height: l } = c;
1757
+ let g = Math.min(h, O), M = Math.min(l, T);
1758
1758
  if (t) {
1759
1759
  const {
1760
- width: m,
1761
- height: M
1762
- } = i, f = l / m, j = h / M, A = Math.max(f, j);
1763
- g = m * A, u = M * A;
1760
+ width: f,
1761
+ height: m
1762
+ } = a, u = h / f, b = l / m, A = Math.max(u, b);
1763
+ g = f * A, M = m * A;
1764
1764
  }
1765
- this.setResolutionWidth(g, { withoutSave: !0 }), this.setResolutionHeight(u, { withoutSave: !0 }), (l > o || h > d) && a.calculateAndApplyDefaultZoom(), a.resetObject(c, { withoutSave: !0 }), n.centerObject(c), n.renderAll(), s || this.editor.historyManager.saveState(), n.fire("editor:montage-area-scaled-to-image", {
1765
+ this.setResolutionWidth(g, { withoutSave: !0 }), this.setResolutionHeight(M, { withoutSave: !0 }), (h > o || l > d) && i.calculateAndApplyDefaultZoom(), i.resetObject(c, { withoutSave: !0 }), n.centerObject(c), n.renderAll(), s || this.editor.historyManager.saveState(), n.fire("editor:montage-area-scaled-to-image", {
1766
1766
  object: c,
1767
1767
  width: g,
1768
- height: u,
1768
+ height: M,
1769
1769
  preserveAspectRatio: t,
1770
1770
  withoutSave: s
1771
1771
  });
@@ -1790,11 +1790,11 @@ class ot {
1790
1790
  transformManager: s,
1791
1791
  historyManager: n,
1792
1792
  options: {
1793
- montageAreaWidth: i,
1794
- montageAreaHeight: a
1793
+ montageAreaWidth: a,
1794
+ montageAreaHeight: i
1795
1795
  }
1796
1796
  } = this.editor;
1797
- s.resetZoom(), this.setResolutionWidth(i, { withoutSave: !0 }), this.setResolutionHeight(a, { withoutSave: !0 }), t.renderAll(), s.resetObjects(), e || n.saveState(), t.fire("editor:default-scale-set");
1797
+ s.resetZoom(), this.setResolutionWidth(a, { withoutSave: !0 }), this.setResolutionHeight(i, { withoutSave: !0 }), t.renderAll(), s.resetObjects(), e || n.saveState(), t.fire("editor:default-scale-set");
1798
1798
  }
1799
1799
  /**
1800
1800
  * Получение всех объектов внутри монтажной области редактора
@@ -1802,12 +1802,12 @@ class ot {
1802
1802
  */
1803
1803
  getObjects() {
1804
1804
  const { canvas: e, montageArea: t, interactionBlocker: { overlayMask: s } } = this.editor;
1805
- return e.getObjects().filter((i) => i.id !== t.id && i.id !== (s == null ? void 0 : s.id));
1805
+ return e.getObjects().filter((a) => a.id !== t.id && a.id !== (s == null ? void 0 : s.id));
1806
1806
  }
1807
1807
  }
1808
- class rt {
1808
+ class ct {
1809
1809
  constructor({ editor: e }) {
1810
- this.editor = e, this.options = e.options, this.minZoom = this.options.minZoom || et, this.maxZoom = this.options.maxZoom || tt, this.defaultZoom = this.options.defaultScale, this.maxZoomFactor = this.options.maxZoomFactor;
1810
+ this.editor = e, this.options = e.options, this.minZoom = this.options.minZoom || tt, this.maxZoom = this.options.maxZoom || st, this.defaultZoom = this.options.defaultScale, this.maxZoomFactor = this.options.maxZoomFactor;
1811
1811
  }
1812
1812
  /**
1813
1813
  * Метод рассчитывает и применяет зум по умолчанию для монтажной области редактора.
@@ -1817,7 +1817,7 @@ class rt {
1817
1817
  * @param scale - Желаемый масштаб относительно размеров контейнера редактора.
1818
1818
  */
1819
1819
  calculateAndApplyDefaultZoom(e = this.options.defaultScale) {
1820
- const { canvas: t } = this.editor, s = t.editorContainer, n = s.clientWidth, i = s.clientHeight, { width: a, height: o } = this.editor.montageArea, d = n / a * e, c = i / o * e;
1820
+ const { canvas: t } = this.editor, s = t.editorContainer, n = s.clientWidth, a = s.clientHeight, { width: i, height: o } = this.editor.montageArea, d = n / i * e, c = a / o * e;
1821
1821
  this.defaultZoom = Math.min(d, c), this.setZoom();
1822
1822
  }
1823
1823
  /**
@@ -1829,15 +1829,15 @@ class rt {
1829
1829
  * @fires editor:zoom-changed
1830
1830
  * Если передавать координаты курсора, то нужно быть аккуратнее, так как юзер может выйти за пределы рабочей области
1831
1831
  */
1832
- zoom(e = st, t = {}) {
1833
- var g, u;
1832
+ zoom(e = nt, t = {}) {
1833
+ var g, M;
1834
1834
  if (!e) return;
1835
- const { minZoom: s, maxZoom: n } = this, { canvas: i } = this.editor, a = i.getZoom(), o = i.getCenterPoint(), d = (g = t.pointX) != null ? g : o.x, c = (u = t.pointY) != null ? u : o.y, l = new P(d, c);
1836
- let h = Number((a + Number(e)).toFixed(2));
1837
- h > n && (h = n), h < s && (h = s), i.zoomToPoint(l, h), i.fire("editor:zoom-changed", {
1838
- currentZoom: i.getZoom(),
1839
- zoom: h,
1840
- point: l
1835
+ const { minZoom: s, maxZoom: n } = this, { canvas: a } = this.editor, i = a.getZoom(), o = a.getCenterPoint(), d = (g = t.pointX) != null ? g : o.x, c = (M = t.pointY) != null ? M : o.y, h = new F(d, c);
1836
+ let l = Number((i + Number(e)).toFixed(2));
1837
+ l > n && (l = n), l < s && (l = s), a.zoomToPoint(h, l), a.fire("editor:zoom-changed", {
1838
+ currentZoom: a.getZoom(),
1839
+ zoom: l,
1840
+ point: h
1841
1841
  });
1842
1842
  }
1843
1843
  /**
@@ -1846,12 +1846,12 @@ class rt {
1846
1846
  * @fires editor:zoom-changed
1847
1847
  */
1848
1848
  setZoom(e = this.defaultZoom) {
1849
- const { minZoom: t, maxZoom: s } = this, { canvas: n } = this.editor, i = new P(n.getCenterPoint());
1850
- let a = e;
1851
- e > s && (a = s), e < t && (a = t), n.zoomToPoint(i, a), n.fire("editor:zoom-changed", {
1849
+ const { minZoom: t, maxZoom: s } = this, { canvas: n } = this.editor, a = new F(n.getCenterPoint());
1850
+ let i = e;
1851
+ e > s && (i = s), e < t && (i = t), n.zoomToPoint(a, i), n.fire("editor:zoom-changed", {
1852
1852
  currentZoom: n.getZoom(),
1853
- zoom: a,
1854
- point: i
1853
+ zoom: i,
1854
+ point: a
1855
1855
  });
1856
1856
  }
1857
1857
  /**
@@ -1859,7 +1859,7 @@ class rt {
1859
1859
  * @fires editor:zoom-changed
1860
1860
  */
1861
1861
  resetZoom() {
1862
- const { canvas: e } = this.editor, t = new P(e.getCenterPoint());
1862
+ const { canvas: e } = this.editor, t = new F(e.getCenterPoint());
1863
1863
  e.zoomToPoint(t, this.defaultZoom), this.editor.canvas.fire("editor:zoom-changed", {
1864
1864
  currentZoom: e.getZoom(),
1865
1865
  point: t
@@ -1872,14 +1872,14 @@ class rt {
1872
1872
  * @param options.withoutSave - Не сохранять состояние
1873
1873
  * @fires editor:object-rotated
1874
1874
  */
1875
- rotate(e = nt, { withoutSave: t } = {}) {
1876
- const { canvas: s, historyManager: n } = this.editor, i = s.getActiveObject();
1877
- if (!i) return;
1878
- const a = i.angle + e;
1879
- i.rotate(a), i.setCoords(), s.renderAll(), t || n.saveState(), s.fire("editor:object-rotated", {
1880
- object: i,
1875
+ rotate(e = at, { withoutSave: t } = {}) {
1876
+ const { canvas: s, historyManager: n } = this.editor, a = s.getActiveObject();
1877
+ if (!a) return;
1878
+ const i = a.angle + e;
1879
+ a.rotate(i), a.setCoords(), s.renderAll(), t || n.saveState(), s.fire("editor:object-rotated", {
1880
+ object: a,
1881
1881
  withoutSave: t,
1882
- angle: a
1882
+ angle: i
1883
1883
  });
1884
1884
  }
1885
1885
  /**
@@ -1921,11 +1921,11 @@ class rt {
1921
1921
  opacity: t = 1,
1922
1922
  withoutSave: s
1923
1923
  } = {}) {
1924
- const { canvas: n, historyManager: i } = this.editor, a = e || n.getActiveObject();
1925
- a && (a instanceof y ? a.getObjects().forEach((o) => {
1924
+ const { canvas: n, historyManager: a } = this.editor, i = e || n.getActiveObject();
1925
+ i && (i instanceof y ? i.getObjects().forEach((o) => {
1926
1926
  o.set("opacity", t);
1927
- }) : a.set("opacity", t), n.renderAll(), s || i.saveState(), n.fire("editor:object-opacity-changed", {
1928
- object: a,
1927
+ }) : i.set("opacity", t), n.renderAll(), s || a.saveState(), n.fire("editor:object-opacity-changed", {
1928
+ object: i,
1929
1929
  opacity: t,
1930
1930
  withoutSave: s
1931
1931
  }));
@@ -1947,18 +1947,18 @@ class rt {
1947
1947
  withoutSave: s,
1948
1948
  fitAsOneObject: n
1949
1949
  } = {}) {
1950
- const { canvas: i, historyManager: a } = this.editor, o = e || i.getActiveObject();
1950
+ const { canvas: a, historyManager: i } = this.editor, o = e || a.getActiveObject();
1951
1951
  if (o) {
1952
1952
  if (o instanceof y && !n) {
1953
1953
  const d = o.getObjects();
1954
- i.discardActiveObject(), d.forEach((l) => {
1955
- this._fitSingleObject(l, t);
1954
+ a.discardActiveObject(), d.forEach((h) => {
1955
+ this._fitSingleObject(h, t);
1956
1956
  });
1957
- const c = new y(d, { canvas: i });
1958
- i.setActiveObject(c);
1957
+ const c = new y(d, { canvas: a });
1958
+ a.setActiveObject(c);
1959
1959
  } else
1960
1960
  this._fitSingleObject(o, t);
1961
- i.renderAll(), s || a.saveState(), i.fire("editor:object-fitted", {
1961
+ a.renderAll(), s || i.saveState(), a.fire("editor:object-fitted", {
1962
1962
  object: o,
1963
1963
  type: t,
1964
1964
  withoutSave: s,
@@ -1973,11 +1973,11 @@ class rt {
1973
1973
  * @private
1974
1974
  */
1975
1975
  _fitSingleObject(e, t) {
1976
- const { canvas: s, montageArea: n } = this.editor, { width: i, height: a, scaleX: o = 1, scaleY: d = 1, angle: c = 0 } = e, l = i * Math.abs(o), h = a * Math.abs(d), g = c * Math.PI / 180, u = Math.abs(Math.cos(g)), m = Math.abs(Math.sin(g)), M = l * u + h * m, f = l * m + h * u, j = n.width, A = n.height;
1977
- let b;
1978
- t === "contain" ? b = Math.min(j / M, A / f) : b = Math.max(j / M, A / f), e.set({
1979
- scaleX: o * b,
1980
- scaleY: d * b
1976
+ const { canvas: s, montageArea: n } = this.editor, { width: a, height: i, scaleX: o = 1, scaleY: d = 1, angle: c = 0 } = e, h = a * Math.abs(o), l = i * Math.abs(d), g = c * Math.PI / 180, M = Math.abs(Math.cos(g)), f = Math.abs(Math.sin(g)), m = h * M + l * f, u = h * f + l * M, b = n.width, A = n.height;
1977
+ let S;
1978
+ t === "contain" ? S = Math.min(b / m, A / u) : S = Math.max(b / m, A / u), e.set({
1979
+ scaleX: o * S,
1980
+ scaleY: d * S
1981
1981
  }), s.centerObject(e);
1982
1982
  }
1983
1983
  /**
@@ -1999,8 +1999,8 @@ class rt {
1999
1999
  resetObject(e, { alwaysFitObject: t = !1, withoutSave: s = !1 } = {}) {
2000
2000
  const {
2001
2001
  canvas: n,
2002
- montageArea: i,
2003
- imageManager: a,
2002
+ montageArea: a,
2003
+ imageManager: i,
2004
2004
  historyManager: o,
2005
2005
  options: { scaleType: d }
2006
2006
  } = this.editor, c = e || n.getActiveObject();
@@ -2014,11 +2014,11 @@ class rt {
2014
2014
  }), t)
2015
2015
  this.fitObject({ object: c, withoutSave: !0, fitAsOneObject: !0 });
2016
2016
  else {
2017
- const { width: h, height: g } = i, { width: u, height: m } = c, M = a.calculateScaleFactor({
2017
+ const { width: l, height: g } = a, { width: M, height: f } = c, m = i.calculateScaleFactor({
2018
2018
  imageObject: c,
2019
2019
  scaleType: d
2020
2020
  });
2021
- d === "contain" && M < 1 || d === "cover" && (u > h || m > g) ? this.fitObject({ object: c, withoutSave: !0, fitAsOneObject: !0 }) : c.set({ scaleX: 1, scaleY: 1 });
2021
+ d === "contain" && m < 1 || d === "cover" && (M > l || f > g) ? this.fitObject({ object: c, withoutSave: !0, fitAsOneObject: !0 }) : c.set({ scaleX: 1, scaleY: 1 });
2022
2022
  }
2023
2023
  c.set({ flipX: !1, flipY: !1, angle: 0 }), n.centerObject(c), n.renderAll(), o.resumeHistory(), s || o.saveState(), n.fire("editor:object-reset", {
2024
2024
  object: c,
@@ -2027,7 +2027,7 @@ class rt {
2027
2027
  });
2028
2028
  }
2029
2029
  }
2030
- class ct {
2030
+ class dt {
2031
2031
  constructor({ editor: e }) {
2032
2032
  this.editor = e, this.isBlocked = !1, this.overlayMask = null, this._createOverlay();
2033
2033
  }
@@ -2057,8 +2057,8 @@ class ct {
2057
2057
  const { canvas: e, montageArea: t, historyManager: s } = this.editor;
2058
2058
  if (!t || !this.overlayMask) return;
2059
2059
  s.suspendHistory(), t.setCoords();
2060
- const { left: n, top: i, width: a, height: o } = t.getBoundingRect();
2061
- this.overlayMask.set({ left: n, top: i, width: a, height: o }), e.discardActiveObject(), this.editor.layerManager.bringToFront(this.overlayMask, { withoutSave: !0 }), s.resumeHistory();
2060
+ const { left: n, top: a, width: i, height: o } = t.getBoundingRect();
2061
+ this.overlayMask.set({ left: n, top: a, width: i, height: o }), e.discardActiveObject(), this.editor.layerManager.bringToFront(this.overlayMask, { withoutSave: !0 }), s.resumeHistory();
2062
2062
  }
2063
2063
  /**
2064
2064
  * Выключает редактор:
@@ -2084,7 +2084,7 @@ class ct {
2084
2084
  }), e.upperCanvasEl.style.pointerEvents = "", e.lowerCanvasEl.style.pointerEvents = "", this.overlayMask.visible = !1, e.requestRenderAll(), e.fire("editor:enabled"), s.resumeHistory();
2085
2085
  }
2086
2086
  }
2087
- class V {
2087
+ class G {
2088
2088
  constructor({ editor: e }) {
2089
2089
  this.editor = e;
2090
2090
  }
@@ -2098,11 +2098,11 @@ class V {
2098
2098
  bringToFront(e, { withoutSave: t } = {}) {
2099
2099
  const { canvas: s, historyManager: n } = this.editor;
2100
2100
  n.suspendHistory();
2101
- const i = e || s.getActiveObject();
2102
- i && (i instanceof y ? i.getObjects().forEach((a) => {
2103
- s.bringObjectToFront(a);
2104
- }) : s.bringObjectToFront(i), s.renderAll(), n.resumeHistory(), t || n.saveState(), s.fire("editor:object-bring-to-front", {
2105
- object: i,
2101
+ const a = e || s.getActiveObject();
2102
+ a && (a instanceof y ? a.getObjects().forEach((i) => {
2103
+ s.bringObjectToFront(i);
2104
+ }) : s.bringObjectToFront(a), s.renderAll(), n.resumeHistory(), t || n.saveState(), s.fire("editor:object-bring-to-front", {
2105
+ object: a,
2106
2106
  withoutSave: t
2107
2107
  }));
2108
2108
  }
@@ -2116,9 +2116,9 @@ class V {
2116
2116
  bringForward(e, { withoutSave: t } = {}) {
2117
2117
  const { canvas: s, historyManager: n } = this.editor;
2118
2118
  n.suspendHistory();
2119
- const i = e || s.getActiveObject();
2120
- i && (i instanceof y ? V._moveSelectionForward(s, i) : s.bringObjectForward(i), s.renderAll(), n.resumeHistory(), t || n.saveState(), s.fire("editor:object-bring-forward", {
2121
- object: i,
2119
+ const a = e || s.getActiveObject();
2120
+ a && (a instanceof y ? G._moveSelectionForward(s, a) : s.bringObjectForward(a), s.renderAll(), n.resumeHistory(), t || n.saveState(), s.fire("editor:object-bring-forward", {
2121
+ object: a,
2122
2122
  withoutSave: t
2123
2123
  }));
2124
2124
  }
@@ -2133,10 +2133,10 @@ class V {
2133
2133
  const {
2134
2134
  canvas: s,
2135
2135
  montageArea: n,
2136
- historyManager: i,
2137
- interactionBlocker: { overlayMask: a }
2136
+ historyManager: a,
2137
+ interactionBlocker: { overlayMask: i }
2138
2138
  } = this.editor;
2139
- i.suspendHistory();
2139
+ a.suspendHistory();
2140
2140
  const o = e || s.getActiveObject();
2141
2141
  if (o) {
2142
2142
  if (o instanceof y) {
@@ -2145,7 +2145,7 @@ class V {
2145
2145
  s.sendObjectToBack(d[c]);
2146
2146
  } else
2147
2147
  s.sendObjectToBack(o);
2148
- s.sendObjectToBack(n), a && s.sendObjectToBack(a), s.renderAll(), i.resumeHistory(), t || i.saveState(), s.fire("editor:object-send-to-back", {
2148
+ s.sendObjectToBack(n), i && s.sendObjectToBack(i), s.renderAll(), a.resumeHistory(), t || a.saveState(), s.fire("editor:object-send-to-back", {
2149
2149
  object: o,
2150
2150
  withoutSave: t
2151
2151
  });
@@ -2161,12 +2161,12 @@ class V {
2161
2161
  const {
2162
2162
  canvas: s,
2163
2163
  montageArea: n,
2164
- historyManager: i,
2165
- interactionBlocker: { overlayMask: a }
2164
+ historyManager: a,
2165
+ interactionBlocker: { overlayMask: i }
2166
2166
  } = this.editor;
2167
- i.suspendHistory();
2167
+ a.suspendHistory();
2168
2168
  const o = e || s.getActiveObject();
2169
- o && (o instanceof y ? V._moveSelectionBackwards(s, o) : s.sendObjectBackwards(o), s.sendObjectToBack(n), a && s.sendObjectToBack(a), s.renderAll(), i.resumeHistory(), t || i.saveState(), s.fire("editor:object-send-backwards", {
2169
+ o && (o instanceof y ? G._moveSelectionBackwards(s, o) : s.sendObjectBackwards(o), s.sendObjectToBack(n), i && s.sendObjectToBack(i), s.renderAll(), a.resumeHistory(), t || a.saveState(), s.fire("editor:object-send-backwards", {
2170
2170
  object: o,
2171
2171
  withoutSave: t
2172
2172
  }));
@@ -2210,7 +2210,7 @@ class V {
2210
2210
  });
2211
2211
  }
2212
2212
  }
2213
- class dt {
2213
+ class lt {
2214
2214
  /**
2215
2215
  * Менеджер фигур для редактора.
2216
2216
  * @param options - Опции и настройки менеджера фигур.
@@ -2234,15 +2234,15 @@ class dt {
2234
2234
  * @param flags.withoutSelection - Не выделять объект
2235
2235
  * @param flags.withoutAdding - Не добавлять объект в canvas
2236
2236
  */
2237
- addRectangle(l = {}, { withoutSelection: d, withoutAdding: c } = {}) {
2238
- var h = l, {
2239
- id: e = `rect-${L()}`,
2237
+ addRectangle(h = {}, { withoutSelection: d, withoutAdding: c } = {}) {
2238
+ var l = h, {
2239
+ id: e = `rect-${D()}`,
2240
2240
  left: t,
2241
2241
  top: s,
2242
2242
  width: n = 100,
2243
- height: i = 100,
2244
- fill: a = "blue"
2245
- } = h, o = _(h, [
2243
+ height: a = 100,
2244
+ fill: i = "blue"
2245
+ } = l, o = P(l, [
2246
2246
  "id",
2247
2247
  "left",
2248
2248
  "top",
@@ -2250,15 +2250,15 @@ class dt {
2250
2250
  "height",
2251
2251
  "fill"
2252
2252
  ]);
2253
- const { canvas: g } = this.editor, u = new Ce(p({
2253
+ const { canvas: g } = this.editor, M = new De(p({
2254
2254
  id: e,
2255
2255
  left: t,
2256
2256
  top: s,
2257
2257
  width: n,
2258
- height: i,
2259
- fill: a
2258
+ height: a,
2259
+ fill: i
2260
2260
  }, o));
2261
- return !t && !s && g.centerObject(u), c || (g.add(u), d || g.setActiveObject(u), g.renderAll()), u;
2261
+ return !t && !s && g.centerObject(M), c || (g.add(M), d || g.setActiveObject(M), g.renderAll()), M;
2262
2262
  }
2263
2263
  /**
2264
2264
  * Добавление круга
@@ -2277,27 +2277,27 @@ class dt {
2277
2277
  * @param flags.withoutAdding - Не добавлять объект в canvas
2278
2278
  */
2279
2279
  addCircle(c = {}, { withoutSelection: o, withoutAdding: d } = {}) {
2280
- var l = c, {
2281
- id: e = `circle-${L()}`,
2280
+ var h = c, {
2281
+ id: e = `circle-${D()}`,
2282
2282
  left: t,
2283
2283
  top: s,
2284
2284
  radius: n = 50,
2285
- fill: i = "green"
2286
- } = l, a = _(l, [
2285
+ fill: a = "green"
2286
+ } = h, i = P(h, [
2287
2287
  "id",
2288
2288
  "left",
2289
2289
  "top",
2290
2290
  "radius",
2291
2291
  "fill"
2292
2292
  ]);
2293
- const { canvas: h } = this.editor, g = new Ne(p({
2293
+ const { canvas: l } = this.editor, g = new Le(p({
2294
2294
  id: e,
2295
2295
  left: t,
2296
2296
  top: s,
2297
- fill: i,
2297
+ fill: a,
2298
2298
  radius: n
2299
- }, a));
2300
- return !t && !s && h.centerObject(g), d || (h.add(g), o || h.setActiveObject(g), h.renderAll()), g;
2299
+ }, i));
2300
+ return !t && !s && l.centerObject(g), d || (l.add(g), o || l.setActiveObject(g), l.renderAll()), g;
2301
2301
  }
2302
2302
  /**
2303
2303
  * Добавление треугольника
@@ -2316,15 +2316,15 @@ class dt {
2316
2316
  * @param flags.withoutSelection - Не выделять объект
2317
2317
  * @param flags.withoutAdding - Не добавлять объект в canvas
2318
2318
  */
2319
- addTriangle(l = {}, { withoutSelection: d, withoutAdding: c } = {}) {
2320
- var h = l, {
2321
- id: e = `triangle-${L()}`,
2319
+ addTriangle(h = {}, { withoutSelection: d, withoutAdding: c } = {}) {
2320
+ var l = h, {
2321
+ id: e = `triangle-${D()}`,
2322
2322
  left: t,
2323
2323
  top: s,
2324
2324
  width: n = 100,
2325
- height: i = 100,
2326
- fill: a = "yellow"
2327
- } = h, o = _(h, [
2325
+ height: a = 100,
2326
+ fill: i = "yellow"
2327
+ } = l, o = P(l, [
2328
2328
  "id",
2329
2329
  "left",
2330
2330
  "top",
@@ -2332,18 +2332,18 @@ class dt {
2332
2332
  "height",
2333
2333
  "fill"
2334
2334
  ]);
2335
- const { canvas: g } = this.editor, u = new De(p({
2335
+ const { canvas: g } = this.editor, M = new Ne(p({
2336
2336
  id: e,
2337
2337
  left: t,
2338
2338
  top: s,
2339
- fill: a,
2339
+ fill: i,
2340
2340
  width: n,
2341
- height: i
2341
+ height: a
2342
2342
  }, o));
2343
- return !t && !s && g.centerObject(u), c || (g.add(u), d || g.setActiveObject(u), g.renderAll()), u;
2343
+ return !t && !s && g.centerObject(M), c || (g.add(M), d || g.setActiveObject(M), g.renderAll()), M;
2344
2344
  }
2345
2345
  }
2346
- class lt {
2346
+ class ht {
2347
2347
  /**
2348
2348
  * @param options
2349
2349
  * @param options.editor - экземпляр редактора с доступом к canvas
@@ -2352,72 +2352,166 @@ class lt {
2352
2352
  this.editor = e, this.clipboard = null;
2353
2353
  }
2354
2354
  /**
2355
- * Копирование объекта
2355
+ * Синхронное копирование объекта в системный буфер обмена
2356
2356
  * @fires editor:object-copied
2357
2357
  */
2358
2358
  copy() {
2359
- return v(this, null, function* () {
2360
- const { canvas: e, errorManager: t } = this.editor, s = e.getActiveObject();
2361
- if (!s || s.locked) return;
2359
+ const { canvas: e } = this.editor, t = e.getActiveObject();
2360
+ !t || t.locked || (this._cloneToInternalClipboard(t), this._copyToSystemClipboard(t).catch((s) => {
2361
+ this.editor.errorManager.emitWarning({
2362
+ origin: "ClipboardManager",
2363
+ method: "copy",
2364
+ code: "COPY_FAILED",
2365
+ message: "Ошибка копирования объекта в системный буфер обмена",
2366
+ data: s
2367
+ });
2368
+ }));
2369
+ }
2370
+ /**
2371
+ * Асинхронное клонирование для внутреннего буфера
2372
+ */
2373
+ _cloneToInternalClipboard(e) {
2374
+ return j(this, null, function* () {
2375
+ const { canvas: t, errorManager: s } = this.editor;
2362
2376
  try {
2363
- const g = yield s.clone(["format"]);
2364
- this.clipboard = g, e.fire("editor:object-copied", { object: g });
2365
- } catch (g) {
2366
- t.emitError({
2377
+ const n = yield e.clone(["format"]);
2378
+ this.clipboard = n, t.fire("editor:object-copied", { object: n });
2379
+ } catch (n) {
2380
+ s.emitError({
2367
2381
  origin: "ClipboardManager",
2368
- method: "copy",
2382
+ method: "_cloneToInternalClipboard",
2369
2383
  code: "CLONE_FAILED",
2370
- message: "Ошибка клонирования объекта",
2371
- data: g
2384
+ message: "Ошибка клонирования объекта для внутреннего буфера",
2385
+ data: n
2372
2386
  });
2373
- return;
2374
2387
  }
2375
- if (typeof ClipboardItem == "undefined" || !navigator.clipboard) {
2376
- t.emitWarning({
2388
+ });
2389
+ }
2390
+ /**
2391
+ * Копирование в системный буфер обмена
2392
+ */
2393
+ _copyToSystemClipboard(e) {
2394
+ return j(this, null, function* () {
2395
+ const { errorManager: t } = this.editor;
2396
+ if (typeof ClipboardItem == "undefined" || !navigator.clipboard)
2397
+ return t.emitWarning({
2377
2398
  origin: "ClipboardManager",
2378
- method: "copy",
2399
+ method: "_copyToSystemClipboard",
2379
2400
  code: "CLIPBOARD_NOT_SUPPORTED",
2380
- // eslint-disable-next-line max-len
2381
- message: "ClipboardManager. navigator.clipboard не поддерживается в этом браузере или отсутствует соединение по HTTPS-протоколу."
2382
- });
2383
- return;
2401
+ message: "navigator.clipboard не поддерживается в этом браузере или отсутствует HTTPS-соединение."
2402
+ }), !1;
2403
+ try {
2404
+ const s = e.toObject(["format"]), n = JSON.stringify(s);
2405
+ return e.type === "image" ? this._copyImageToClipboard(e, n) : this._copyTextToClipboard(n);
2406
+ } catch (s) {
2407
+ return t.emitError({
2408
+ origin: "ClipboardManager",
2409
+ method: "_copyToSystemClipboard",
2410
+ code: "COPY_FAILED",
2411
+ message: "Ошибка копирования объекта",
2412
+ data: s
2413
+ }), !1;
2384
2414
  }
2385
- if (s.type !== "image") {
2386
- const g = `${$}${JSON.stringify(s.toObject(["format"]))}`;
2387
- navigator.clipboard.writeText(g).catch((u) => {
2388
- t.emitWarning({
2389
- origin: "ClipboardManager",
2390
- method: "copy",
2391
- code: "CLIPBOARD_WRITE_TEXT_FAILED",
2392
- message: `Ошибка записи текстового объекта в буфер обмена: ${u.message}`,
2393
- data: u
2394
- });
2395
- });
2396
- return;
2415
+ });
2416
+ }
2417
+ /**
2418
+ * Копирование изображения в буфер обмена
2419
+ */
2420
+ _copyImageToClipboard(e, t) {
2421
+ return j(this, null, function* () {
2422
+ try {
2423
+ const n = e.toCanvasElement({ enableRetinaScaling: !1 }).toDataURL(), a = n.slice(5).split(";")[0], i = n.split(",")[1], o = atob(i), d = new Uint8Array(o.length);
2424
+ for (let l = 0; l < o.length; l += 1)
2425
+ d[l] = o.charCodeAt(l);
2426
+ const c = new Blob([d.buffer], { type: a }), h = new ClipboardItem({ [a]: c });
2427
+ return yield navigator.clipboard.write([h]), console.info("Image copied to clipboard successfully"), !0;
2428
+ } catch (s) {
2429
+ return this.editor.errorManager.emitWarning({
2430
+ origin: "ClipboardManager",
2431
+ method: "_copyImageToClipboard",
2432
+ code: "CLIPBOARD_WRITE_IMAGE_FAILED",
2433
+ message: `Ошибка записи изображения в буфер обмена, выполняется fallback к текстовому копированию: ${s}`,
2434
+ data: s
2435
+ }), this._copyTextToClipboard(t);
2436
+ }
2437
+ });
2438
+ }
2439
+ /**
2440
+ * Копирование текста в буфер обмена
2441
+ */
2442
+ _copyTextToClipboard(e) {
2443
+ return j(this, null, function* () {
2444
+ try {
2445
+ const t = `${me}${e}`;
2446
+ return yield navigator.clipboard.writeText(t), console.info("Text copied to clipboard successfully"), !0;
2447
+ } catch (t) {
2448
+ const { errorManager: s } = this.editor;
2449
+ return s.emitWarning({
2450
+ origin: "ClipboardManager",
2451
+ method: "_copyTextToClipboard",
2452
+ code: "CLIPBOARD_WRITE_TEXT_FAILED",
2453
+ message: `Ошибка записи текста в буфер обмена: ${t}`,
2454
+ data: t
2455
+ }), !1;
2456
+ }
2457
+ });
2458
+ }
2459
+ /**
2460
+ * Добавляет клонированный объект на canvas с учетом типа объекта
2461
+ * @param clonedObject - клонированный объект для добавления
2462
+ */
2463
+ _addClonedObjectToCanvas(e) {
2464
+ const { canvas: t, historyManager: s } = this.editor;
2465
+ if (t.discardActiveObject(), e instanceof y) {
2466
+ s.suspendHistory(), e.canvas = t, e.forEachObject((n) => {
2467
+ t.add(n);
2468
+ }), t.setActiveObject(e), t.requestRenderAll(), s.resumeHistory(), s.saveState();
2469
+ return;
2470
+ }
2471
+ t.add(e), t.setActiveObject(e), t.requestRenderAll();
2472
+ }
2473
+ /**
2474
+ * Обработка импорта изображения из буфера обмена
2475
+ * @param source - источник изображения (data URL или URL)
2476
+ */
2477
+ _handleImageImport(e) {
2478
+ return j(this, null, function* () {
2479
+ var s;
2480
+ const { image: t } = (s = yield this.editor.imageManager.importImage({
2481
+ source: e,
2482
+ fromClipboard: !0
2483
+ })) != null ? s : {};
2484
+ t && this.editor.canvas.fire("editor:object-pasted", { object: t });
2485
+ });
2486
+ }
2487
+ /**
2488
+ * Создать копию объекта - копирует и сразу вставляет
2489
+ * @param objectToCopy - объект для копирования (если не указан, используется активный объект)
2490
+ * @fires editor:object-copied
2491
+ * @fires editor:object-pasted
2492
+ */
2493
+ copyPaste(e) {
2494
+ return j(this, null, function* () {
2495
+ const { canvas: t } = this.editor, s = e || t.getActiveObject();
2496
+ if (!s || s.locked) return !1;
2497
+ try {
2498
+ const n = yield s.clone(["format"]);
2499
+ return n.set({
2500
+ id: `${n.type}-${D()}`,
2501
+ left: n.left + 10,
2502
+ top: n.top + 10,
2503
+ evented: !0
2504
+ }), this._addClonedObjectToCanvas(n), t.fire("editor:object-duplicated", { object: n }), !0;
2505
+ } catch (n) {
2506
+ const { errorManager: a } = this.editor;
2507
+ return a.emitError({
2508
+ origin: "ClipboardManager",
2509
+ method: "copyPaste",
2510
+ code: "COPY_PASTE_FAILED",
2511
+ message: "Ошибка создания копии объекта",
2512
+ data: n
2513
+ }), !1;
2397
2514
  }
2398
- const i = s.toCanvasElement({
2399
- enableRetinaScaling: !1
2400
- }).toDataURL(), a = i.slice(5).split(";")[0], o = i.split(",")[1], d = atob(o), c = new Uint8Array(d.length);
2401
- for (let g = 0; g < d.length; g += 1)
2402
- c[g] = d.charCodeAt(g);
2403
- const l = new Blob([c.buffer], { type: a }), h = new ClipboardItem({ [a]: l });
2404
- navigator.clipboard.write([h]).catch((g) => {
2405
- if (g.name === "NotAllowedError") {
2406
- console.info("Clipboard access denied, object copied to internal clipboard only");
2407
- return;
2408
- }
2409
- const u = `${$}${JSON.stringify(s.toObject(["format"]))}`;
2410
- navigator.clipboard.writeText(u).catch((m) => {
2411
- t.emitWarning({
2412
- origin: "ClipboardManager",
2413
- method: "copy",
2414
- code: "CLIPBOARD_WRITE_IMAGE_FAILED",
2415
- // eslint-disable-next-line max-len
2416
- message: `Ошибка записи изображения в буфер обмена: ${g.message}. Fallback также не удался: ${m.message}`,
2417
- data: { originalError: g, fallbackError: m }
2418
- });
2419
- });
2420
- });
2421
2515
  });
2422
2516
  }
2423
2517
  /**
@@ -2427,30 +2521,46 @@ class lt {
2427
2521
  * @param event.clipboardData.items — элементы буфера обмена
2428
2522
  */
2429
2523
  handlePasteEvent(t) {
2430
- return v(this, arguments, function* ({ clipboardData: e }) {
2431
- var c;
2432
- if (!((c = e == null ? void 0 : e.items) != null && c.length)) {
2524
+ return j(this, arguments, function* ({ clipboardData: e }) {
2525
+ var d;
2526
+ if (!((d = e == null ? void 0 : e.items) != null && d.length)) {
2433
2527
  this.paste();
2434
2528
  return;
2435
2529
  }
2436
2530
  const s = e.getData("text/plain");
2437
- if (s && s.startsWith($)) {
2531
+ if (s && s.startsWith(me)) {
2438
2532
  this.paste();
2439
2533
  return;
2440
2534
  }
2441
- const { imageManager: n } = this.editor, { items: i } = e, a = i[i.length - 1], o = a.getAsFile();
2442
- if (a.type !== "text/html" && o) {
2443
- const l = new FileReader();
2444
- l.onload = (h) => {
2445
- h.target && this.editor.imageManager.importImage({ source: h.target.result });
2446
- }, l.readAsDataURL(o);
2535
+ const { items: n } = e, a = n[n.length - 1], i = a.getAsFile();
2536
+ if (a.type !== "text/html" && i) {
2537
+ const c = new FileReader();
2538
+ c.onload = (h) => {
2539
+ h.target && this._handleImageImport(h.target.result).catch((l) => {
2540
+ this.editor.errorManager.emitError({
2541
+ origin: "ClipboardManager",
2542
+ method: "handlePasteEvent",
2543
+ code: "PASTE_IMAGE_FAILED",
2544
+ message: "Ошибка вставки изображения из буфера обмена",
2545
+ data: l
2546
+ });
2547
+ });
2548
+ }, c.readAsDataURL(i);
2447
2549
  return;
2448
2550
  }
2449
- const d = e.getData("text/html");
2450
- if (d) {
2451
- const g = new DOMParser().parseFromString(d, "text/html").querySelector("img");
2452
- if (g != null && g.src) {
2453
- n.importImage({ source: g.src });
2551
+ const o = e.getData("text/html");
2552
+ if (o) {
2553
+ const l = new DOMParser().parseFromString(o, "text/html").querySelector("img");
2554
+ if (l != null && l.src) {
2555
+ this._handleImageImport(l.src).catch((g) => {
2556
+ this.editor.errorManager.emitError({
2557
+ origin: "ClipboardManager",
2558
+ method: "handlePasteEvent",
2559
+ code: "PASTE_HTML_IMAGE_FAILED",
2560
+ message: "Ошибка вставки изображения из HTML",
2561
+ data: g
2562
+ });
2563
+ });
2454
2564
  return;
2455
2565
  }
2456
2566
  }
@@ -2458,26 +2568,35 @@ class lt {
2458
2568
  });
2459
2569
  }
2460
2570
  /**
2461
- * Вставка объекта
2571
+ * Вставка объекта из внутреннего буфера
2462
2572
  * @fires editor:object-pasted
2463
2573
  */
2464
2574
  paste() {
2465
- return v(this, null, function* () {
2575
+ return j(this, null, function* () {
2466
2576
  const { canvas: e } = this.editor;
2467
- if (!this.clipboard) return;
2468
- const t = yield this.clipboard.clone(["format"]);
2469
- e.discardActiveObject(), t.set({
2470
- id: `${t.type}-${L()}`,
2471
- left: t.left + 10,
2472
- top: t.top + 10,
2473
- evented: !0
2474
- }), t instanceof y ? (t.canvas = e, t.forEachObject((s) => {
2475
- e.add(s);
2476
- })) : e.add(t), e.setActiveObject(t), e.requestRenderAll(), e.fire("editor:object-pasted", { object: t });
2577
+ if (!this.clipboard) return !1;
2578
+ try {
2579
+ const t = yield this.clipboard.clone(["format"]);
2580
+ return e.discardActiveObject(), t.set({
2581
+ id: `${t.type}-${D()}`,
2582
+ left: t.left + 10,
2583
+ top: t.top + 10,
2584
+ evented: !0
2585
+ }), this._addClonedObjectToCanvas(t), e.fire("editor:object-pasted", { object: t }), !0;
2586
+ } catch (t) {
2587
+ const { errorManager: s } = this.editor;
2588
+ return s.emitError({
2589
+ origin: "ClipboardManager",
2590
+ method: "paste",
2591
+ code: "PASTE_FAILED",
2592
+ message: "Ошибка вставки объекта",
2593
+ data: t
2594
+ }), !1;
2595
+ }
2477
2596
  });
2478
2597
  }
2479
2598
  }
2480
- class G {
2599
+ class X {
2481
2600
  constructor({ editor: e }) {
2482
2601
  this.editor = e;
2483
2602
  }
@@ -2490,8 +2609,8 @@ class G {
2490
2609
  * @fires editor:object-locked
2491
2610
  */
2492
2611
  lockObject({ object: e, skipInnerObjects: t, withoutSave: s } = {}) {
2493
- const { canvas: n, historyManager: i } = this.editor, a = e || n.getActiveObject();
2494
- if (!a || a.locked) return;
2612
+ const { canvas: n, historyManager: a } = this.editor, i = e || n.getActiveObject();
2613
+ if (!i || i.locked) return;
2495
2614
  const o = {
2496
2615
  lockMovementX: !0,
2497
2616
  lockMovementY: !0,
@@ -2502,10 +2621,10 @@ class G {
2502
2621
  lockSkewingY: !0,
2503
2622
  locked: !0
2504
2623
  };
2505
- a.set(o), !t && G._isGroupOrSelection(a) && a.getObjects().forEach((c) => {
2624
+ i.set(o), !t && X._isGroupOrSelection(i) && i.getObjects().forEach((c) => {
2506
2625
  c.set(o);
2507
- }), n.renderAll(), s || i.saveState(), n.fire("editor:object-locked", {
2508
- object: a,
2626
+ }), n.renderAll(), s || a.saveState(), n.fire("editor:object-locked", {
2627
+ object: i,
2509
2628
  skipInnerObjects: t,
2510
2629
  withoutSave: s
2511
2630
  });
@@ -2518,9 +2637,9 @@ class G {
2518
2637
  * @fires editor:object-unlocked
2519
2638
  */
2520
2639
  unlockObject({ object: e, withoutSave: t } = {}) {
2521
- const { canvas: s, historyManager: n } = this.editor, i = e || s.getActiveObject();
2522
- if (!i) return;
2523
- const a = {
2640
+ const { canvas: s, historyManager: n } = this.editor, a = e || s.getActiveObject();
2641
+ if (!a) return;
2642
+ const i = {
2524
2643
  lockMovementX: !1,
2525
2644
  lockMovementY: !1,
2526
2645
  lockRotation: !1,
@@ -2530,10 +2649,10 @@ class G {
2530
2649
  lockSkewingY: !1,
2531
2650
  locked: !1
2532
2651
  };
2533
- i.set(a), G._isGroupOrSelection(i) && i.getObjects().forEach((o) => {
2534
- o.set(a);
2652
+ a.set(i), X._isGroupOrSelection(a) && a.getObjects().forEach((o) => {
2653
+ o.set(i);
2535
2654
  }), s.renderAll(), t || n.saveState(), s.fire("editor:object-unlocked", {
2536
- object: i,
2655
+ object: a,
2537
2656
  withoutSave: t
2538
2657
  });
2539
2658
  }
@@ -2541,7 +2660,7 @@ class G {
2541
2660
  return e instanceof y || e instanceof J;
2542
2661
  }
2543
2662
  }
2544
- class ht {
2663
+ class gt {
2545
2664
  constructor({ editor: e }) {
2546
2665
  this.editor = e;
2547
2666
  }
@@ -2558,11 +2677,11 @@ class ht {
2558
2677
  } = {}) {
2559
2678
  const { canvas: s, historyManager: n } = this.editor;
2560
2679
  n.suspendHistory();
2561
- const i = e || s.getActiveObject();
2562
- if (!i || !(i instanceof y)) return;
2563
- const a = i.getObjects(), o = new J(a);
2564
- a.forEach((d) => s.remove(d)), o.set("id", `${o.type}-${L()}`), s.add(o), s.setActiveObject(o), s.renderAll(), n.resumeHistory(), t || n.saveState(), s.fire("editor:objects-grouped", {
2565
- object: i,
2680
+ const a = e || s.getActiveObject();
2681
+ if (!a || !(a instanceof y)) return;
2682
+ const i = a.getObjects(), o = new J(i);
2683
+ i.forEach((d) => s.remove(d)), o.set("id", `${o.type}-${D()}`), s.add(o), s.setActiveObject(o), s.renderAll(), n.resumeHistory(), t || n.saveState(), s.fire("editor:objects-grouped", {
2684
+ object: a,
2566
2685
  group: o,
2567
2686
  withoutSave: t
2568
2687
  });
@@ -2580,21 +2699,21 @@ class ht {
2580
2699
  } = {}) {
2581
2700
  const { canvas: s, historyManager: n } = this.editor;
2582
2701
  n.suspendHistory();
2583
- const i = e || s.getActiveObject();
2584
- if (!(i instanceof J)) return;
2585
- const a = i.removeAll();
2586
- s.remove(i), a.forEach((d) => s.add(d));
2587
- const o = new y(a, {
2702
+ const a = e || s.getActiveObject();
2703
+ if (!(a instanceof J)) return;
2704
+ const i = a.removeAll();
2705
+ s.remove(a), i.forEach((d) => s.add(d));
2706
+ const o = new y(i, {
2588
2707
  canvas: s
2589
2708
  });
2590
2709
  s.setActiveObject(o), s.renderAll(), n.resumeHistory(), t || n.saveState(), s.fire("editor:objects-ungrouped", {
2591
- object: i,
2710
+ object: a,
2592
2711
  selection: o,
2593
2712
  withoutSave: t
2594
2713
  });
2595
2714
  }
2596
2715
  }
2597
- class gt {
2716
+ class ut {
2598
2717
  constructor({ editor: e }) {
2599
2718
  this.editor = e;
2600
2719
  }
@@ -2605,11 +2724,11 @@ class gt {
2605
2724
  selectAll() {
2606
2725
  const { canvas: e, canvasManager: t, objectLockManager: s } = this.editor;
2607
2726
  e.discardActiveObject();
2608
- const n = t.getObjects(), i = n.some((o) => o.locked), a = n.length > 1 ? new y(t.getObjects(), { canvas: e }) : n[0];
2609
- i && s.lockObject({ object: a, skipInnerObjects: !0, withoutSave: !0 }), e.setActiveObject(a), e.requestRenderAll(), e.fire("editor:all-objects-selected", { selected: a });
2727
+ const n = t.getObjects(), a = n.some((o) => o.locked), i = n.length > 1 ? new y(t.getObjects(), { canvas: e }) : n[0];
2728
+ a && s.lockObject({ object: i, skipInnerObjects: !0, withoutSave: !0 }), e.setActiveObject(i), e.requestRenderAll(), e.fire("editor:all-objects-selected", { selected: i });
2610
2729
  }
2611
2730
  }
2612
- class ut {
2731
+ class Mt {
2613
2732
  constructor({ editor: e }) {
2614
2733
  this.editor = e;
2615
2734
  }
@@ -2624,20 +2743,20 @@ class ut {
2624
2743
  objects: e,
2625
2744
  withoutSave: t
2626
2745
  } = {}) {
2627
- const { canvas: s, historyManager: n, groupingManager: i } = this.editor, a = (e || s.getActiveObjects()).filter((o) => !o.locked);
2628
- a != null && a.length && (n.suspendHistory(), a.forEach((o) => {
2746
+ const { canvas: s, historyManager: n, groupingManager: a } = this.editor, i = (e || s.getActiveObjects()).filter((o) => !o.locked);
2747
+ i != null && i.length && (n.suspendHistory(), i.forEach((o) => {
2629
2748
  if (o.type === "group" && o.format !== "svg") {
2630
- i.ungroup({ object: o, withoutSave: t }), this.deleteSelectedObjects();
2749
+ a.ungroup({ object: o, withoutSave: t }), this.deleteSelectedObjects();
2631
2750
  return;
2632
2751
  }
2633
2752
  s.remove(o);
2634
2753
  }), s.discardActiveObject(), s.renderAll(), n.resumeHistory(), t || n.saveState(), s.fire("editor:objects-deleted", {
2635
- objects: a,
2754
+ objects: i,
2636
2755
  withoutSave: t
2637
2756
  }));
2638
2757
  }
2639
2758
  }
2640
- const Mt = {
2759
+ const mt = {
2641
2760
  IMAGE_MANAGER: {
2642
2761
  /**
2643
2762
  * Некорректный Content-Type изображения
@@ -2683,7 +2802,23 @@ const Mt = {
2683
2802
  /**
2684
2803
  * Ошибка клонирования объекта.
2685
2804
  */
2686
- CLONE_FAILED: "CLONE_FAILED"
2805
+ CLONE_FAILED: "CLONE_FAILED",
2806
+ /**
2807
+ * Ошибка копирования объекта.
2808
+ */
2809
+ COPY_FAILED: "COPY_FAILED",
2810
+ /**
2811
+ * Ошибка вставки изображения из буфера обмена.
2812
+ */
2813
+ PASTE_IMAGE_FAILED: "PASTE_IMAGE_FAILED",
2814
+ /**
2815
+ * Ошибка вставки HTML-изображения из буфера обмена.
2816
+ */
2817
+ PASTE_HTML_IMAGE_FAILED: "PASTE_HTML_IMAGE_FAILED",
2818
+ /**
2819
+ * Ошибка вставки объекта из буфера обмена.
2820
+ */
2821
+ PASTE_FAILED: "PASTE_FAILED"
2687
2822
  },
2688
2823
  /**
2689
2824
  * Коды ошибок и предупреждений для CanvasManager.
@@ -2699,7 +2834,7 @@ const Mt = {
2699
2834
  REDO_ERROR: "REDO_ERROR"
2700
2835
  }
2701
2836
  };
2702
- class X {
2837
+ class Q {
2703
2838
  constructor({ editor: e }) {
2704
2839
  this._buffer = [], this.editor = e;
2705
2840
  }
@@ -2725,19 +2860,19 @@ class X {
2725
2860
  * @param options.message — текст ошибки (опционально, если не передан, то используется код ошибки)
2726
2861
  * @fires editor:error
2727
2862
  */
2728
- emitError({ origin: e = "ImageEditor", method: t = "Unknown Method", code: s, data: n, message: i }) {
2729
- if (!X.isValidErrorCode(s)) {
2863
+ emitError({ origin: e = "ImageEditor", method: t = "Unknown Method", code: s, data: n, message: a }) {
2864
+ if (!Q.isValidErrorCode(s)) {
2730
2865
  console.warn("Неизвестный код ошибки: ", { code: s, origin: e, method: t });
2731
2866
  return;
2732
2867
  }
2733
2868
  if (!s) return;
2734
- const a = i || s;
2735
- console.error(`${e}. ${t}. ${s}. ${a}`, n);
2869
+ const i = a || s;
2870
+ console.error(`${e}. ${t}. ${s}. ${i}`, n);
2736
2871
  const o = {
2737
2872
  code: s,
2738
2873
  origin: e,
2739
2874
  method: t,
2740
- message: a,
2875
+ message: i,
2741
2876
  data: n
2742
2877
  };
2743
2878
  this._buffer.push(p({
@@ -2754,19 +2889,19 @@ class X {
2754
2889
  * @param options.message — текст предупреждения (опционально, если не передан, то используется код предупреждения)
2755
2890
  * @fires editor:warning
2756
2891
  */
2757
- emitWarning({ origin: e = "ImageEditor", method: t = "Unknown Method", code: s, message: n, data: i }) {
2758
- if (!X.isValidErrorCode(s)) {
2892
+ emitWarning({ origin: e = "ImageEditor", method: t = "Unknown Method", code: s, message: n, data: a }) {
2893
+ if (!Q.isValidErrorCode(s)) {
2759
2894
  console.warn("Неизвестный код предупреждения: ", { code: s, origin: e, method: t });
2760
2895
  return;
2761
2896
  }
2762
- const a = n || s;
2763
- console.warn(`${e}. ${t}. ${s}. ${a}`, i);
2897
+ const i = n || s;
2898
+ console.warn(`${e}. ${t}. ${s}. ${i}`, a);
2764
2899
  const o = {
2765
2900
  code: s,
2766
2901
  origin: e,
2767
2902
  method: t,
2768
- message: a,
2769
- data: i
2903
+ message: i,
2904
+ data: a
2770
2905
  };
2771
2906
  this._buffer.push(p({
2772
2907
  type: "editor:warning"
@@ -2778,17 +2913,17 @@ class X {
2778
2913
  * @returns true, если код допустим, иначе false
2779
2914
  */
2780
2915
  static isValidErrorCode(e) {
2781
- return e ? Object.values(Mt).some((t) => Object.values(t).includes(e)) : !1;
2916
+ return e ? Object.values(mt).some((t) => Object.values(t).includes(e)) : !1;
2782
2917
  }
2783
2918
  }
2784
- class ae {
2919
+ class ie {
2785
2920
  /**
2786
2921
  * Конструктор класса ImageEditor.
2787
2922
  * @param canvasId - идентификатор канваса, в котором будет создан редактор
2788
2923
  * @param options - опции и настройки редактора
2789
2924
  */
2790
2925
  constructor(e, t) {
2791
- this.options = t, this.containerId = e, this.editorId = `${e}-${L()}`, this.clipboard = null, this.init();
2926
+ this.options = t, this.containerId = e, this.editorId = `${e}-${D()}`, this.clipboard = null, this.init();
2792
2927
  }
2793
2928
  /**
2794
2929
  * Инициализация редактора.
@@ -2796,29 +2931,29 @@ class ae {
2796
2931
  * @fires editor:ready
2797
2932
  */
2798
2933
  init() {
2799
- return v(this, null, function* () {
2934
+ return j(this, null, function* () {
2800
2935
  const {
2801
2936
  editorContainerWidth: e,
2802
2937
  editorContainerHeight: t,
2803
2938
  canvasWrapperWidth: s,
2804
2939
  canvasWrapperHeight: n,
2805
- canvasCSSWidth: i,
2806
- canvasCSSHeight: a,
2940
+ canvasCSSWidth: a,
2941
+ canvasCSSHeight: i,
2807
2942
  initialImage: o,
2808
2943
  initialStateJSON: d,
2809
2944
  scaleType: c,
2810
- _onReadyCallback: l
2945
+ _onReadyCallback: h
2811
2946
  } = this.options;
2812
- if (We.apply(), this.canvas = new Le(this.containerId, this.options), this.moduleLoader = new ke(), this.workerManager = new Be(), this.errorManager = new X({ editor: this }), this.historyManager = new qe({ editor: this }), this.toolbar = new Ke({ editor: this }), this.transformManager = new rt({ editor: this }), this.canvasManager = new ot({ editor: this }), this.imageManager = new D({ editor: this }), this.layerManager = new V({ editor: this }), this.shapeManager = new dt({ editor: this }), this.interactionBlocker = new ct({ editor: this }), this.clipboardManager = new lt({ editor: this }), this.objectLockManager = new G({ editor: this }), this.groupingManager = new ht({ editor: this }), this.selectionManager = new gt({ editor: this }), this.deletionManager = new ut({ editor: this }), this._createMontageArea(), this._createClippingArea(), this.listeners = new z({ editor: this, options: this.options }), this.canvasManager.setEditorContainerWidth(e), this.canvasManager.setEditorContainerHeight(t), this.canvasManager.setCanvasWrapperWidth(s), this.canvasManager.setCanvasWrapperHeight(n), this.canvasManager.setCanvasCSSWidth(i), this.canvasManager.setCanvasCSSHeight(a), o != null && o.source) {
2947
+ if (We.apply(), this.canvas = new Ee(this.containerId, this.options), this.moduleLoader = new xe(), this.workerManager = new _e(), this.errorManager = new Q({ editor: this }), this.historyManager = new et({ editor: this }), this.toolbar = new qe({ editor: this }), this.transformManager = new ct({ editor: this }), this.canvasManager = new rt({ editor: this }), this.imageManager = new E({ editor: this }), this.layerManager = new G({ editor: this }), this.shapeManager = new lt({ editor: this }), this.interactionBlocker = new dt({ editor: this }), this.clipboardManager = new ht({ editor: this }), this.objectLockManager = new X({ editor: this }), this.groupingManager = new gt({ editor: this }), this.selectionManager = new ut({ editor: this }), this.deletionManager = new Mt({ editor: this }), this._createMontageArea(), this._createClippingArea(), this.listeners = new z({ 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(i), o != null && o.source) {
2813
2948
  const {
2814
- source: h,
2949
+ source: l,
2815
2950
  scale: g = `image-${c}`,
2816
- withoutSave: u = !0
2951
+ withoutSave: M = !0
2817
2952
  } = o;
2818
- yield this.imageManager.importImage({ source: h, scale: g, withoutSave: u });
2953
+ yield this.imageManager.importImage({ source: l, scale: g, withoutSave: M });
2819
2954
  } else
2820
2955
  this.canvasManager.setDefaultScale({ withoutSave: !0 });
2821
- d && this.historyManager.loadStateFromFullState(d), this.historyManager.saveState(), console.log("editor:ready"), this.canvas.fire("editor:ready", this), typeof l == "function" && l(this);
2956
+ d && this.historyManager.loadStateFromFullState(d), this.historyManager.saveState(), console.log("editor:ready"), this.canvas.fire("editor:ready", this), typeof h == "function" && h(this);
2822
2957
  });
2823
2958
  }
2824
2959
  /**
@@ -2832,7 +2967,7 @@ class ae {
2832
2967
  this.montageArea = this.shapeManager.addRectangle({
2833
2968
  width: e,
2834
2969
  height: t,
2835
- fill: ae._createMosaicPattern(),
2970
+ fill: ie._createMosaicPattern(),
2836
2971
  stroke: null,
2837
2972
  strokeWidth: 0,
2838
2973
  selectable: !1,
@@ -2888,7 +3023,7 @@ class ae {
2888
3023
  });
2889
3024
  }
2890
3025
  }
2891
- const mt = {
3026
+ const ft = {
2892
3027
  /**
2893
3028
  * Опции редактора
2894
3029
  */
@@ -2979,14 +3114,14 @@ const mt = {
2979
3114
  keyboardIgnoreSelectors: []
2980
3115
  };
2981
3116
  function At(r, e = {}) {
2982
- const t = p(p({}, mt), e), s = document.getElementById(r);
3117
+ const t = p(p({}, ft), e), s = document.getElementById(r);
2983
3118
  if (!s)
2984
3119
  return Promise.reject(new Error(`Контейнер с ID "${r}" не найден.`));
2985
3120
  const n = document.createElement("canvas");
2986
- return n.id = `${r}-canvas`, s.appendChild(n), t.editorContainer = s, new Promise((i) => {
2987
- t._onReadyCallback = i;
2988
- const a = new ae(n.id, t);
2989
- window[r] = a;
3121
+ return n.id = `${r}-canvas`, s.appendChild(n), t.editorContainer = s, new Promise((a) => {
3122
+ t._onReadyCallback = a;
3123
+ const i = new ie(n.id, t);
3124
+ window[r] = i;
2990
3125
  });
2991
3126
  }
2992
3127
  export {