@anu3ev/fabric-image-editor 0.5.32 → 0.5.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -451,7 +451,7 @@ class Fn {
451
451
  }
452
452
  function Wn(h) {
453
453
  return new Worker(
454
- "" + new URL("assets/worker-CN39s7P7.js", import.meta.url).href,
454
+ "" + new URL("assets/worker-2TM2HcqM.js", import.meta.url).href,
455
455
  {
456
456
  name: h == null ? void 0 : h.name
457
457
  }
@@ -1239,6 +1239,7 @@ const Le = [
1239
1239
  "customData",
1240
1240
  "backgroundType",
1241
1241
  "format",
1242
+ "contentType",
1242
1243
  "width",
1243
1244
  "height",
1244
1245
  "locked",
@@ -1869,12 +1870,12 @@ class pt {
1869
1870
  if (!e) return null;
1870
1871
  const { canvas: l, montageArea: d, transformManager: u, historyManager: f, errorManager: g } = this.editor, m = yield this.getContentType(e), p = pt.getFormatFromContentType(m), { acceptContentTypes: y, acceptFormats: v } = this;
1871
1872
  if (!this.isAllowedContentType(m)) {
1872
- const C = `Неверный contentType для изображения: ${m}. Ожидается один из: ${this.acceptContentTypes.join(", ")}.`;
1873
+ const j = `Неверный contentType для изображения: ${m}. Ожидается один из: ${this.acceptContentTypes.join(", ")}.`;
1873
1874
  return g.emitError({
1874
1875
  origin: "ImageManager",
1875
1876
  method: "importImage",
1876
1877
  code: "INVALID_CONTENT_TYPE",
1877
- message: C,
1878
+ message: j,
1878
1879
  data: {
1879
1880
  source: e,
1880
1881
  format: p,
@@ -1891,12 +1892,12 @@ class pt {
1891
1892
  }
1892
1893
  f.suspendHistory();
1893
1894
  try {
1894
- let C, b;
1895
+ let j, b;
1895
1896
  if (e instanceof File)
1896
- C = URL.createObjectURL(e);
1897
+ j = URL.createObjectURL(e);
1897
1898
  else if (typeof e == "string") {
1898
- const I = yield (yield fetch(e, { mode: "cors" })).blob();
1899
- C = URL.createObjectURL(I);
1899
+ const C = yield (yield fetch(e, { mode: "cors" })).blob();
1900
+ j = URL.createObjectURL(C);
1900
1901
  } else
1901
1902
  return g.emitError({
1902
1903
  origin: "ImageManager",
@@ -1916,36 +1917,38 @@ class pt {
1916
1917
  customData: c
1917
1918
  }
1918
1919
  }), f.resumeHistory(), null;
1919
- if (this._createdBlobUrls.push(C), p === "svg") {
1920
- const w = yield En(C);
1920
+ if (this._createdBlobUrls.push(j), p === "svg") {
1921
+ const w = yield En(j);
1921
1922
  b = vt.groupSVGElements(w.objects, w.options);
1922
1923
  } else
1923
- b = yield Kt.fromURL(C, { crossOrigin: "anonymous" });
1924
- const { width: T, height: M } = b;
1924
+ b = yield Kt.fromURL(j, { crossOrigin: "anonymous" });
1925
+ const { width: T, height: S } = b;
1925
1926
  if (b instanceof Kt) {
1926
1927
  const w = b.getElement();
1927
- let I = "";
1928
- if (w instanceof HTMLImageElement ? I = w.src : w instanceof HTMLCanvasElement && (I = w.toDataURL()), M > Pt || T > zt) {
1929
- const S = yield this.resizeImageToBoundaries({
1930
- dataURL: I,
1931
- sizeType: "max"
1932
- }), j = URL.createObjectURL(S);
1933
- this._createdBlobUrls.push(j), b = yield Kt.fromURL(j, { crossOrigin: "anonymous" });
1934
- } else if (M < $t || T < Qt) {
1935
- const S = yield this.resizeImageToBoundaries({
1936
- dataURL: I,
1937
- sizeType: "min"
1938
- }), j = URL.createObjectURL(S);
1939
- this._createdBlobUrls.push(j), b = yield Kt.fromURL(j, { crossOrigin: "anonymous" });
1928
+ let C = "";
1929
+ if (w instanceof HTMLImageElement ? C = w.src : w instanceof HTMLCanvasElement && (C = w.toDataURL()), S > Pt || T > zt) {
1930
+ const A = yield this.resizeImageToBoundaries({
1931
+ dataURL: C,
1932
+ sizeType: "max",
1933
+ contentType: m
1934
+ }), I = URL.createObjectURL(A);
1935
+ this._createdBlobUrls.push(I), b = yield Kt.fromURL(I, { crossOrigin: "anonymous" });
1936
+ } else if (S < $t || T < Qt) {
1937
+ const A = yield this.resizeImageToBoundaries({
1938
+ dataURL: C,
1939
+ sizeType: "min",
1940
+ contentType: m
1941
+ }), I = URL.createObjectURL(A);
1942
+ this._createdBlobUrls.push(I), b = yield Kt.fromURL(I, { crossOrigin: "anonymous" });
1940
1943
  }
1941
1944
  }
1942
- if (b.set("id", `${b.type}-${et()}`), b.set("format", p), b.set("customData", c || null), n === "scale-montage")
1945
+ if (b.set("id", `${b.type}-${et()}`), b.set("format", p), b.set("contentType", m), b.set("customData", c || null), n === "scale-montage")
1943
1946
  this.editor.canvasManager.scaleMontageAreaToImage({ object: b, withoutSave: !0 });
1944
1947
  else {
1945
- const { width: w, height: I } = d, S = this.calculateScaleFactor({ imageObject: b, scaleType: n });
1946
- n === "image-contain" && S < 1 ? u.fitObject({ object: b, type: "contain", withoutSave: !0 }) : n === "image-cover" && (T > w || M > I) && u.fitObject({ object: b, type: "cover", withoutSave: !0 });
1948
+ const { width: w, height: C } = d, A = this.calculateScaleFactor({ imageObject: b, scaleType: n });
1949
+ n === "image-contain" && A < 1 ? u.fitObject({ object: b, type: "contain", withoutSave: !0 }) : n === "image-cover" && (T > w || S > C) && u.fitObject({ object: b, type: "cover", withoutSave: !0 });
1947
1950
  }
1948
- const A = {
1951
+ const M = {
1949
1952
  image: b,
1950
1953
  format: p,
1951
1954
  contentType: m,
@@ -1958,13 +1961,13 @@ class pt {
1958
1961
  withoutAdding: r,
1959
1962
  customData: c
1960
1963
  };
1961
- return r ? (f.resumeHistory(), l.fire("editor:image-imported", A), A) : (l.add(b), l.centerObject(b), a || l.setActiveObject(b), l.renderAll(), f.resumeHistory(), s || f.saveState(), l.fire("editor:image-imported", A), A);
1962
- } catch (C) {
1964
+ return r ? (f.resumeHistory(), l.fire("editor:image-imported", M), M) : (l.add(b), l.centerObject(b), a || l.setActiveObject(b), l.renderAll(), f.resumeHistory(), s || f.saveState(), l.fire("editor:image-imported", M), M);
1965
+ } catch (j) {
1963
1966
  return g.emitError({
1964
1967
  origin: "ImageManager",
1965
1968
  method: "importImage",
1966
1969
  code: "IMPORT_FAILED",
1967
- message: `Ошибка импорта изображения: ${C.message}`,
1970
+ message: `Ошибка импорта изображения: ${j.message}`,
1968
1971
  data: {
1969
1972
  source: e,
1970
1973
  format: p,
@@ -1994,6 +1997,8 @@ class pt {
1994
1997
  * @param options.minHeight - минимальная высота (по умолчанию CANVAS_MIN_HEIGHT)
1995
1998
  * @param options.asBase64 - вернуть base64 вместо Blob
1996
1999
  * @param options.emitMessage - выводить предупреждение в случае ресайза
2000
+ * @param options.contentType - тип контента
2001
+ * @param options.quality - качество изображения от 0 до 1 (для JPEG/WebP)
1997
2002
  * @returns возвращает Promise с Blob или base64 в зависимости от опций
1998
2003
  */
1999
2004
  resizeImageToBoundaries(t) {
@@ -2001,40 +2006,44 @@ class pt {
2001
2006
  const {
2002
2007
  dataURL: e,
2003
2008
  sizeType: n = "max",
2004
- maxWidth: s = zt,
2005
- maxHeight: o = Pt,
2006
- minWidth: i = Qt,
2007
- minHeight: a = $t,
2008
- asBase64: r = !1,
2009
- emitMessage: c = !0
2010
- } = t, { errorManager: l, workerManager: d } = this.editor, u = {
2009
+ contentType: s = "image/png",
2010
+ quality: o = 1,
2011
+ maxWidth: i = zt,
2012
+ maxHeight: a = Pt,
2013
+ minWidth: r = Qt,
2014
+ minHeight: c = $t,
2015
+ asBase64: l = !1,
2016
+ emitMessage: d = !0
2017
+ } = t, { errorManager: u, workerManager: f } = this.editor, g = {
2011
2018
  dataURL: e,
2012
2019
  sizeType: n,
2013
- maxWidth: s,
2014
- maxHeight: o,
2015
- minWidth: i,
2016
- minHeight: a
2020
+ contentType: s,
2021
+ quality: o,
2022
+ maxWidth: i,
2023
+ maxHeight: a,
2024
+ minWidth: r,
2025
+ minHeight: c
2017
2026
  };
2018
- if (c) {
2019
- let g = `Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ${s}x${o}`;
2020
- n === "min" && (g = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${i}x${a}`), l.emitWarning({
2027
+ if (d) {
2028
+ let p = `Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ${i}x${a}`;
2029
+ n === "min" && (p = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${r}x${c}`), u.emitWarning({
2021
2030
  origin: "ImageManager",
2022
2031
  method: "resizeImageToBoundaries",
2023
2032
  code: "IMAGE_RESIZE_WARNING",
2024
- message: g,
2025
- data: u
2033
+ message: p,
2034
+ data: g
2026
2035
  });
2027
2036
  }
2028
- const f = yield d.post("resizeImage", u);
2029
- if (r) {
2030
- const g = yield this.getContentTypeFromUrl(e), p = pt.getFormatFromContentType(g) || "png", y = yield createImageBitmap(f);
2031
- return yield d.post(
2037
+ const m = yield f.post("resizeImage", g);
2038
+ if (l) {
2039
+ const p = yield createImageBitmap(m);
2040
+ return yield f.post(
2032
2041
  "toDataURL",
2033
- { format: p, quality: 1, bitmap: y },
2034
- [y]
2042
+ { contentType: s, quality: o, bitmap: p },
2043
+ [p]
2035
2044
  );
2036
2045
  }
2037
- return f;
2046
+ return m;
2038
2047
  });
2039
2048
  }
2040
2049
  /**
@@ -2061,18 +2070,18 @@ class pt {
2061
2070
  a.setCoords();
2062
2071
  const { left: f, top: g, width: m, height: p } = a.getBoundingRect(), y = yield i.clone(["id", "format", "locked"]);
2063
2072
  y.enableRetinaScaling = !1, ["image/jpg", "image/jpeg"].includes(d) && (y.backgroundColor = "#ffffff");
2064
- const v = y.getObjects().find((S) => S.id === a.id);
2073
+ const v = y.getObjects().find((A) => A.id === a.id);
2065
2074
  if (v && (v.visible = !1), c != null && c.isBlocked) {
2066
- const S = y.getObjects().find((j) => j.id === c.overlayMask.id);
2067
- S && (S.visible = !1);
2075
+ const A = y.getObjects().find((I) => I.id === c.overlayMask.id);
2076
+ A && (A.visible = !1);
2068
2077
  }
2069
2078
  y.viewportTransform = [1, 0, 0, 1, -f, -g], y.setDimensions({ width: m, height: p }, { backstoreOnly: !0 }), y.renderAll();
2070
- const C = y.getObjects().filter((S) => S.format).every((S) => S.format === "svg");
2071
- if (u === "svg" && C) {
2072
- const S = y.toSVG();
2079
+ const j = y.getObjects().filter((A) => A.format).every((A) => A.format === "svg");
2080
+ if (u === "svg" && j) {
2081
+ const A = y.toSVG();
2073
2082
  y.dispose();
2074
2083
  const O = {
2075
- image: pt._exportSVGStringAsFile(S, {
2084
+ image: pt._exportSVGStringAsFile(A, {
2076
2085
  exportAsBase64: s,
2077
2086
  exportAsBlob: o,
2078
2087
  fileName: e
@@ -2083,32 +2092,40 @@ class pt {
2083
2092
  };
2084
2093
  return i.fire("editor:canvas-exported", O), O;
2085
2094
  }
2086
- const b = yield new Promise((S, j) => {
2087
- y.getElement().toBlob((O) => {
2088
- O ? S(O) : j(new Error("Failed to create Blob from canvas"));
2089
- });
2095
+ const b = yield new Promise((A, I) => {
2096
+ y.getElement().toBlob(
2097
+ (O) => {
2098
+ O ? A(O) : I(new Error("Failed to create Blob from canvas"));
2099
+ },
2100
+ d,
2101
+ 1
2102
+ );
2090
2103
  });
2091
2104
  if (y.dispose(), o) {
2092
- const S = {
2105
+ const A = {
2093
2106
  image: b,
2094
2107
  format: u,
2095
2108
  contentType: d,
2096
2109
  fileName: e
2097
2110
  };
2098
- return i.fire("editor:canvas-exported", S), S;
2111
+ return i.fire("editor:canvas-exported", A), A;
2099
2112
  }
2100
- const T = yield createImageBitmap(b), M = yield r.post(
2113
+ const T = yield createImageBitmap(b), S = yield r.post(
2101
2114
  "toDataURL",
2102
- { format: u, quality: 1, bitmap: T },
2115
+ {
2116
+ contentType: d,
2117
+ quality: 1,
2118
+ bitmap: T
2119
+ },
2103
2120
  [T]
2104
2121
  );
2105
2122
  if (l) {
2106
- const j = m * 0.264583, O = p * 0.264583, k = (yield this.editor.moduleLoader.loadModule("jspdf")).jsPDF, D = new k({
2107
- orientation: j > O ? "landscape" : "portrait",
2123
+ const I = m * 0.264583, O = p * 0.264583, k = (yield this.editor.moduleLoader.loadModule("jspdf")).jsPDF, D = new k({
2124
+ orientation: I > O ? "landscape" : "portrait",
2108
2125
  unit: "mm",
2109
- format: [j, O]
2126
+ format: [I, O]
2110
2127
  });
2111
- if (D.addImage(String(M), "JPG", 0, 0, j, O), s) {
2128
+ if (D.addImage(String(S), "JPG", 0, 0, I, O), s) {
2112
2129
  const B = {
2113
2130
  image: D.output("datauristring"),
2114
2131
  format: "pdf",
@@ -2126,21 +2143,21 @@ class pt {
2126
2143
  return i.fire("editor:canvas-exported", L), L;
2127
2144
  }
2128
2145
  if (s) {
2129
- const S = {
2130
- image: M,
2146
+ const A = {
2147
+ image: S,
2131
2148
  format: u,
2132
2149
  contentType: d,
2133
2150
  fileName: e
2134
2151
  };
2135
- return i.fire("editor:canvas-exported", S), S;
2152
+ return i.fire("editor:canvas-exported", A), A;
2136
2153
  }
2137
- const A = u === "svg" && !C ? e.replace(/\.[^/.]+$/, ".png") : e, I = {
2138
- image: new File([b], A, { type: d }),
2154
+ const M = u === "svg" && !j ? e.replace(/\.[^/.]+$/, ".png") : e, C = {
2155
+ image: new File([b], M, { type: d }),
2139
2156
  format: u,
2140
2157
  contentType: d,
2141
- fileName: A
2158
+ fileName: M
2142
2159
  };
2143
- return i.fire("editor:canvas-exported", I), I;
2160
+ return i.fire("editor:canvas-exported", C), C;
2144
2161
  } catch (l) {
2145
2162
  return this.editor.errorManager.emitError({
2146
2163
  origin: "ImageManager",
@@ -2165,87 +2182,93 @@ class pt {
2165
2182
  */
2166
2183
  exportObjectAsImageFile() {
2167
2184
  return G(this, arguments, function* (t = {}) {
2185
+ var v;
2168
2186
  const {
2169
2187
  object: e,
2170
- fileName: n = "image.png",
2171
- contentType: s = "image/png",
2188
+ fileName: n,
2189
+ contentType: s,
2172
2190
  exportAsBase64: o = !1,
2173
2191
  exportAsBlob: i = !1
2174
- } = t, { canvas: a, workerManager: r } = this.editor, c = e || a.getActiveObject();
2192
+ } = t, { canvas: a, workerManager: r } = this.editor, c = e || a.getActiveObject(), l = s != null ? s : "image/png", d = pt.getFormatFromContentType(l) || "png", u = n != null ? n : `image.${d}`;
2175
2193
  if (!c)
2176
2194
  return this.editor.errorManager.emitError({
2177
2195
  origin: "ImageManager",
2178
2196
  method: "exportObjectAsImageFile",
2179
2197
  code: "NO_OBJECT_SELECTED",
2180
2198
  message: "Не выбран объект для экспорта",
2181
- data: { contentType: s, fileName: n, exportAsBase64: o, exportAsBlob: i }
2199
+ data: { contentType: l, fileName: u, exportAsBase64: o, exportAsBlob: i }
2182
2200
  }), null;
2201
+ const { contentType: f, format: g = "" } = c, m = (v = s != null ? s : f) != null ? v : "image/png", p = pt.getFormatFromContentType(m) || g || "png", y = n != null ? n : `image.${p}`;
2183
2202
  try {
2184
- const l = pt.getFormatFromContentType(s);
2185
- if (l === "svg") {
2186
- const m = c.toSVG(), p = pt._exportSVGStringAsFile(m, {
2203
+ if (p === "svg") {
2204
+ const M = c.toSVG(), w = pt._exportSVGStringAsFile(M, {
2187
2205
  exportAsBase64: o,
2188
2206
  exportAsBlob: i,
2189
- fileName: n
2190
- }), y = {
2207
+ fileName: y
2208
+ }), C = {
2191
2209
  object: c,
2192
- image: p,
2193
- format: l,
2210
+ image: w,
2211
+ format: p,
2194
2212
  contentType: "image/svg+xml",
2195
- fileName: n.replace(/\.[^/.]+$/, ".svg")
2213
+ fileName: y.replace(/\.[^/.]+$/, ".svg")
2196
2214
  };
2197
- return a.fire("editor:object-exported", y), y;
2215
+ return a.fire("editor:object-exported", C), C;
2198
2216
  }
2199
2217
  if (o && c instanceof Kt) {
2200
- const m = yield createImageBitmap(c.getElement()), p = yield r.post(
2218
+ const M = yield createImageBitmap(c.getElement()), w = yield r.post(
2201
2219
  "toDataURL",
2202
2220
  {
2203
- format: l,
2221
+ contentType: m,
2204
2222
  quality: 1,
2205
- bitmap: m
2223
+ bitmap: M
2206
2224
  },
2207
- [m]
2208
- ), y = {
2225
+ [M]
2226
+ ), C = {
2209
2227
  object: c,
2210
- image: p,
2211
- format: l,
2212
- contentType: s,
2213
- fileName: n
2228
+ image: w,
2229
+ format: p,
2230
+ contentType: m,
2231
+ fileName: y
2214
2232
  };
2215
- return a.fire("editor:object-exported", y), y;
2233
+ return a.fire("editor:object-exported", C), C;
2216
2234
  }
2217
- const d = c.toCanvasElement({
2235
+ const j = c.toCanvasElement({
2218
2236
  enableRetinaScaling: !1
2219
- }), u = yield new Promise((m, p) => {
2220
- d.toBlob((y) => {
2221
- y ? m(y) : p(new Error("Failed to create Blob from canvas"));
2237
+ }), b = yield new Promise((M, w) => {
2238
+ j.toBlob((C) => {
2239
+ C ? M(C) : w(new Error("Failed to create Blob from canvas"));
2222
2240
  });
2223
2241
  });
2224
2242
  if (i) {
2225
- const m = {
2243
+ const M = {
2226
2244
  object: c,
2227
- image: u,
2228
- format: l,
2229
- contentType: s,
2230
- fileName: n
2245
+ image: b,
2246
+ format: p,
2247
+ contentType: m,
2248
+ fileName: y
2231
2249
  };
2232
- return a.fire("editor:object-exported", m), m;
2250
+ return a.fire("editor:object-exported", M), M;
2233
2251
  }
2234
- const f = new File([u], n, { type: s }), g = {
2252
+ const T = new File([b], y, { type: m }), S = {
2235
2253
  object: c,
2236
- image: f,
2237
- format: l,
2238
- contentType: s,
2239
- fileName: n
2254
+ image: T,
2255
+ format: p,
2256
+ contentType: m,
2257
+ fileName: y
2240
2258
  };
2241
- return a.fire("editor:object-exported", g), g;
2242
- } catch (l) {
2259
+ return a.fire("editor:object-exported", S), S;
2260
+ } catch (j) {
2243
2261
  return this.editor.errorManager.emitError({
2244
2262
  origin: "ImageManager",
2245
2263
  method: "exportObjectAsImageFile",
2246
2264
  code: "IMAGE_EXPORT_FAILED",
2247
- message: `Ошибка экспорта объекта: ${l.message}`,
2248
- data: { contentType: s, fileName: n, exportAsBase64: o, exportAsBlob: i }
2265
+ message: `Ошибка экспорта объекта: ${j.message}`,
2266
+ data: {
2267
+ contentType: m,
2268
+ fileName: y,
2269
+ exportAsBase64: o,
2270
+ exportAsBlob: i
2271
+ }
2249
2272
  }), null;
2250
2273
  }
2251
2274
  });
@@ -2892,10 +2915,10 @@ class gs {
2892
2915
  */
2893
2916
  _fitSingleObject(t, e) {
2894
2917
  const { canvas: n, montageArea: s } = this.editor, { width: o, height: i, scaleX: a = 1, scaleY: r = 1, angle: c = 0 } = t, l = o * Math.abs(a), d = i * Math.abs(r), u = c * Math.PI / 180, f = Math.abs(Math.cos(u)), g = Math.abs(Math.sin(u)), m = l * f + d * g, p = l * g + d * f, y = s.width, v = s.height;
2895
- let C;
2896
- e === "contain" ? C = Math.min(y / m, v / p) : C = Math.max(y / m, v / p), t.set({
2897
- scaleX: a * C,
2898
- scaleY: r * C
2918
+ let j;
2919
+ e === "contain" ? j = Math.min(y / m, v / p) : j = Math.max(y / m, v / p), t.set({
2920
+ scaleX: a * j,
2921
+ scaleY: r * j
2899
2922
  }), n.centerObject(t);
2900
2923
  }
2901
2924
  /**
@@ -3015,8 +3038,8 @@ class ps {
3015
3038
  _calculateEmptySpaceRatio(t) {
3016
3039
  const { canvas: e, montageArea: n } = this.editor, s = e.viewportTransform, o = e.getWidth(), i = e.getHeight(), a = n.left - n.width / 2, r = n.left + n.width / 2, c = n.top - n.height / 2, l = n.top + n.height / 2, d = -s[4] / t, u = (-s[4] + o) / t, f = -s[5] / t, g = (-s[5] + i) / t, m = d < a, p = u > r, y = f < c, v = g > l;
3017
3040
  if (!(m || p || y || v)) return 0;
3018
- const b = Math.max(0, a - d), T = Math.max(0, u - r), M = Math.max(0, c - f), A = Math.max(0, g - l), w = Math.max(b, T), I = Math.max(M, A), S = w / o, j = I / i;
3019
- return Math.max(S, j);
3041
+ const b = Math.max(0, a - d), T = Math.max(0, u - r), S = Math.max(0, c - f), M = Math.max(0, g - l), w = Math.max(b, T), C = Math.max(S, M), A = w / o, I = C / i;
3042
+ return Math.max(A, I);
3020
3043
  }
3021
3044
  /**
3022
3045
  * Вычисляет плавный шаг перемещения viewport к центру с ускорением
@@ -3032,7 +3055,7 @@ class ps {
3032
3055
  const { canvas: i, montageArea: a } = this.editor, r = i.viewportTransform, c = i.getWidth(), l = i.getHeight(), d = t.x - r[4], u = t.y - r[5], f = Math.abs(s), g = e - n;
3033
3056
  if (Math.abs(g) / f <= 0.1)
3034
3057
  return { x: d, y: u };
3035
- const p = c / 2, y = l / 2, v = a.left, C = a.top, b = p - v * n, T = y - C * n, M = (b - r[4]) / (e - n), A = (T - r[5]) / (e - n), w = M * f, I = A * f, S = w * o, j = I * o, O = Math.abs(S) > Math.abs(d) ? d : S, k = Math.abs(j) > Math.abs(u) ? u : j;
3058
+ const p = c / 2, y = l / 2, v = a.left, j = a.top, b = p - v * n, T = y - j * n, S = (b - r[4]) / (e - n), M = (T - r[5]) / (e - n), w = S * f, C = M * f, A = w * o, I = C * o, O = Math.abs(A) > Math.abs(d) ? d : A, k = Math.abs(I) > Math.abs(u) ? u : I;
3036
3059
  return { x: O, y: k };
3037
3060
  }
3038
3061
  /**
@@ -4748,41 +4771,41 @@ const ws = ({ textbox: h }) => {
4748
4771
  l += v;
4749
4772
  continue;
4750
4773
  }
4751
- const C = c[p], b = v / o, T = this._getLineLeftOffset(p);
4752
- let M = 0, A = 0, w = this.getValueOfPropertyAt(p, 0, e), I = this._getDecorationColorAt(p, 0), S = this.getValueOfPropertyAt(p, 0, "textDecorationThickness"), j = w, O = I, k = S;
4774
+ const j = c[p], b = v / o, T = this._getLineLeftOffset(p);
4775
+ let S = 0, M = 0, w = this.getValueOfPropertyAt(p, 0, e), C = this._getDecorationColorAt(p, 0), A = this.getValueOfPropertyAt(p, 0, "textDecorationThickness"), I = w, O = C, k = A;
4753
4776
  const D = l + b * (1 - r);
4754
4777
  let W = this.getHeightOfChar(p, 0), E = this.getValueOfPropertyAt(p, 0, "deltaY");
4755
- for (let B = 0, P = C.length; B < P; B += 1) {
4778
+ for (let B = 0, P = j.length; B < P; B += 1) {
4756
4779
  const x = this.__charBounds[p][B];
4757
- j = this.getValueOfPropertyAt(p, B, e), O = this._getDecorationColorAt(p, B), k = this.getValueOfPropertyAt(p, B, "textDecorationThickness");
4780
+ I = this.getValueOfPropertyAt(p, B, e), O = this._getDecorationColorAt(p, B), k = this.getValueOfPropertyAt(p, B, "textDecorationThickness");
4758
4781
  const _ = this.getHeightOfChar(p, B), R = this.getValueOfPropertyAt(p, B, "deltaY");
4759
- if (u && j && O) {
4782
+ if (u && I && O) {
4760
4783
  const N = s * k / 1e3;
4761
- t.save(), t.fillStyle = I, t.translate(x.renderLeft, x.renderTop), t.rotate(x.angle), t.fillRect(
4784
+ t.save(), t.fillStyle = C, t.translate(x.renderLeft, x.renderTop), t.rotate(x.angle), t.fillRect(
4762
4785
  -x.kernedWidth / 2,
4763
4786
  g * _ + R - m * N,
4764
4787
  x.kernedWidth,
4765
4788
  N
4766
4789
  ), t.restore();
4767
- } else if ((j !== w || O !== I || _ !== W || k !== S || R !== E) && A > 0) {
4768
- const N = s * S / 1e3;
4769
- let K = d + T + M;
4770
- n === "rtl" && (K = a - K - A), w && I && S && (t.fillStyle = I, t.fillRect(
4790
+ } else if ((I !== w || O !== C || _ !== W || k !== A || R !== E) && M > 0) {
4791
+ const N = s * A / 1e3;
4792
+ let K = d + T + S;
4793
+ n === "rtl" && (K = a - K - M), w && C && A && (t.fillStyle = C, t.fillRect(
4771
4794
  K,
4772
4795
  D + g * W + E - m * N,
4773
- A,
4796
+ M,
4774
4797
  N
4775
- )), M = x.left, A = x.width, w = j, S = k, I = O, W = _, E = R;
4798
+ )), S = x.left, M = x.width, w = I, A = k, C = O, W = _, E = R;
4776
4799
  } else
4777
- A += x.kernedWidth;
4800
+ M += x.kernedWidth;
4778
4801
  }
4779
- let L = d + T + M;
4780
- n === "rtl" && (L = a - L - A), t.fillStyle = O;
4802
+ let L = d + T + S;
4803
+ n === "rtl" && (L = a - L - M), t.fillStyle = O;
4781
4804
  const z = s * k / 1e3;
4782
- j && O && k && t.fillRect(
4805
+ I && O && k && t.fillRect(
4783
4806
  L,
4784
4807
  D + g * W + E - m * z,
4785
- A - f,
4808
+ M - f,
4786
4809
  z
4787
4810
  ), l += v;
4788
4811
  }
@@ -5214,10 +5237,10 @@ class rt {
5214
5237
  s.set({ width: m });
5215
5238
  const { width: p = 0 } = s, y = g - p;
5216
5239
  if (y !== 0 && o && o.corner === "ml") {
5217
- const C = ((l = s.angle) != null ? l : 0) * Math.PI / 180, b = Math.cos(C), T = Math.sin(C), M = (d = s.scaleX) != null ? d : 1, A = y * M;
5240
+ const j = ((l = s.angle) != null ? l : 0) * Math.PI / 180, b = Math.cos(j), T = Math.sin(j), S = (d = s.scaleX) != null ? d : 1, M = y * S;
5218
5241
  s.set({
5219
- left: ((u = s.left) != null ? u : 0) + A * b,
5220
- top: ((f = s.top) != null ? f : 0) + A * T
5242
+ left: ((u = s.left) != null ? u : 0) + M * b,
5243
+ top: ((f = s.top) != null ? f : 0) + M * T
5221
5244
  });
5222
5245
  }
5223
5246
  }
@@ -5240,9 +5263,9 @@ class rt {
5240
5263
  baseRadii: d,
5241
5264
  baseStyles: u,
5242
5265
  baseLineFontDefaults: f
5243
- } = i, g = typeof ((ne = o.original) == null ? void 0 : ne.width) == "number" ? o.original.width : void 0, m = typeof ((ve = o.original) == null ? void 0 : ve.left) == "number" ? o.original.left : void 0, p = g != null ? g : a, y = m != null ? m : r, v = (se = o.corner) != null ? se : "", C = (ie = o.action) != null ? ie : "", b = ["ml", "mr"].includes(v) || C === "scaleX", T = ["mt", "mb"].includes(v) || C === "scaleY", M = ["tl", "tr", "bl", "br"].includes(v) || C === "scale", A = M || T;
5244
- if (!b && !T && !M) return;
5245
- const w = Math.abs((Rt = (oe = s.scaleX) != null ? oe : o.scaleX) != null ? Rt : 1) || 1, I = Math.abs((ae = (be = s.scaleY) != null ? be : o.scaleY) != null ? ae : 1) || 1, S = Math.max(1, p * w), j = Math.max(1, Math.round(S)), O = Math.max(1, c * I), {
5266
+ } = i, g = typeof ((ne = o.original) == null ? void 0 : ne.width) == "number" ? o.original.width : void 0, m = typeof ((ve = o.original) == null ? void 0 : ve.left) == "number" ? o.original.left : void 0, p = g != null ? g : a, y = m != null ? m : r, v = (se = o.corner) != null ? se : "", j = (ie = o.action) != null ? ie : "", b = ["ml", "mr"].includes(v) || j === "scaleX", T = ["mt", "mb"].includes(v) || j === "scaleY", S = ["tl", "tr", "bl", "br"].includes(v) || j === "scale", M = S || T;
5267
+ if (!b && !T && !S) return;
5268
+ const w = Math.abs((Rt = (oe = s.scaleX) != null ? oe : o.scaleX) != null ? Rt : 1) || 1, C = Math.abs((ae = (be = s.scaleY) != null ? be : o.scaleY) != null ? ae : 1) || 1, A = Math.max(1, p * w), I = Math.max(1, Math.round(A)), O = Math.max(1, c * C), {
5246
5269
  paddingTop: k = 0,
5247
5270
  paddingRight: D = 0,
5248
5271
  paddingBottom: W = 0,
@@ -5254,19 +5277,19 @@ class rt {
5254
5277
  fontSize: x,
5255
5278
  width: _,
5256
5279
  originX: R = "left"
5257
- } = s, N = M || T, K = M || T, H = N ? {
5258
- top: Math.max(0, l.top * I),
5259
- right: Math.max(0, l.right * I),
5260
- bottom: Math.max(0, l.bottom * I),
5261
- left: Math.max(0, l.left * I)
5280
+ } = s, N = S || T, K = S || T, H = N ? {
5281
+ top: Math.max(0, l.top * C),
5282
+ right: Math.max(0, l.right * C),
5283
+ bottom: Math.max(0, l.bottom * C),
5284
+ left: Math.max(0, l.left * C)
5262
5285
  } : l, q = K ? {
5263
- topLeft: Math.max(0, d.topLeft * I),
5264
- topRight: Math.max(0, d.topRight * I),
5265
- bottomRight: Math.max(0, d.bottomRight * I),
5266
- bottomLeft: Math.max(0, d.bottomLeft * I)
5286
+ topLeft: Math.max(0, d.topLeft * C),
5287
+ topRight: Math.max(0, d.topRight * C),
5288
+ bottomRight: Math.max(0, d.bottomRight * C),
5289
+ bottomLeft: Math.max(0, d.bottomLeft * C)
5267
5290
  } : d, tt = Object.keys(u).length > 0;
5268
5291
  let at;
5269
- if (A && tt) {
5292
+ if (M && tt) {
5270
5293
  const kt = {};
5271
5294
  Object.entries(u).forEach(([re, Q]) => {
5272
5295
  if (!Q) return;
@@ -5274,23 +5297,23 @@ class rt {
5274
5297
  Object.entries(Q).forEach(([Me, Bt]) => {
5275
5298
  if (!Bt) return;
5276
5299
  const He = F({}, Bt);
5277
- typeof Bt.fontSize == "number" && (He.fontSize = Math.max(1, Bt.fontSize * I)), st[Me] = He;
5300
+ typeof Bt.fontSize == "number" && (He.fontSize = Math.max(1, Bt.fontSize * C)), st[Me] = He;
5278
5301
  }), Object.keys(st).length && (kt[re] = st);
5279
5302
  }), Object.keys(kt).length && (at = kt);
5280
5303
  }
5281
5304
  let ft;
5282
- A && (ft = hn({
5305
+ M && (ft = hn({
5283
5306
  lineFontDefaults: f,
5284
- scale: I
5307
+ scale: C
5285
5308
  }));
5286
- const wt = (Zt = (Ht = o.originX) != null ? Ht : R) != null ? Zt : "left", dt = y + p, ht = y + p / 2, It = _ != null ? _ : p, At = j !== It, Lt = Math.abs(O - (x != null ? x : c)) > it, _t = Math.abs(H.top - k) > it || Math.abs(H.right - D) > it || Math.abs(H.bottom - W) > it || Math.abs(H.left - E) > it, xt = Math.abs(q.topLeft - L) > it || Math.abs(q.topRight - z) > it || Math.abs(q.bottomRight - B) > it || Math.abs(q.bottomLeft - P) > it;
5309
+ const wt = (Zt = (Ht = o.originX) != null ? Ht : R) != null ? Zt : "left", dt = y + p, ht = y + p / 2, It = _ != null ? _ : p, At = I !== It, Lt = Math.abs(O - (x != null ? x : c)) > it, _t = Math.abs(H.top - k) > it || Math.abs(H.right - D) > it || Math.abs(H.bottom - W) > it || Math.abs(H.left - E) > it, xt = Math.abs(q.topLeft - L) > it || Math.abs(q.topRight - z) > it || Math.abs(q.bottomRight - B) > it || Math.abs(q.bottomLeft - P) > it;
5287
5310
  if (!At && !Lt && !_t && !xt) {
5288
5311
  s.set({ scaleX: 1, scaleY: 1 }), o.scaleX = 1, o.scaleY = 1;
5289
5312
  return;
5290
5313
  }
5291
5314
  at && (s.styles = at), ft && (s.lineFontDefaults = ft), s.set({
5292
- width: j,
5293
- fontSize: A ? O : c,
5315
+ width: I,
5316
+ fontSize: M ? O : c,
5294
5317
  paddingTop: H.top,
5295
5318
  paddingRight: H.right,
5296
5319
  paddingBottom: H.bottom,
@@ -5304,9 +5327,9 @@ class rt {
5304
5327
  });
5305
5328
  const Yt = Et({ textbox: s });
5306
5329
  Yt && (s.dirty = !0);
5307
- const gt = (Gt = s.width) != null ? Gt : j, ee = gt !== It;
5330
+ const gt = (Gt = s.width) != null ? Gt : I, ee = gt !== It;
5308
5331
  let Tt = y;
5309
- ee && (b || M) && (wt === "right" ? Tt = dt - gt : wt === "center" && (Tt = ht - gt / 2)), s.set({ left: Tt }), i.baseLeft = Tt, o.scaleX = 1, o.scaleY = 1;
5332
+ ee && (b || S) && (wt === "right" ? Tt = dt - gt : wt === "center" && (Tt = ht - gt / 2)), s.set({ left: Tt }), i.baseLeft = Tt, o.scaleX = 1, o.scaleY = 1;
5310
5333
  const { original: bt } = o;
5311
5334
  bt && (bt.scaleX = 1, bt.scaleY = 1, bt.width = gt, bt.height = s.height, bt.left = Tt), s.setCoords(), this.canvas.requestRenderAll(), i.baseWidth = gt, i.baseFontSize = (Vt = s.fontSize) != null ? Vt : O, i.baseStyles = JSON.parse(JSON.stringify((Xt = s.styles) != null ? Xt : {})), i.baseLineFontDefaults = dn({
5312
5335
  lineFontDefaults: s.lineFontDefaults
@@ -5322,17 +5345,17 @@ class rt {
5322
5345
  bottomLeft: q.bottomLeft
5323
5346
  }, i.hasWidthChange = ee || Lt || _t || xt || Yt;
5324
5347
  }, this._handleObjectModified = (n) => {
5325
- var v, C, b;
5348
+ var v, j, b;
5326
5349
  const { target: s } = n;
5327
5350
  if (s instanceof X) {
5328
5351
  const T = s.getObjects();
5329
- if (!T.some((S) => rt._isTextbox(S))) return;
5330
- const { scaleX: A = 1, scaleY: w = 1 } = s;
5331
- if (Math.abs(A - 1) < it && Math.abs(w - 1) < it) return;
5332
- this.canvas.discardActiveObject(), T.forEach((S) => {
5333
- var j, O, k, D;
5334
- if (rt._isTextbox(S)) {
5335
- const W = (j = S.scaleX) != null ? j : 1, E = (O = S.scaleY) != null ? O : 1, L = ((k = S.fontSize) != null ? k : 16) * E, z = ((D = S.width) != null ? D : 0) * W, B = E, {
5352
+ if (!T.some((A) => rt._isTextbox(A))) return;
5353
+ const { scaleX: M = 1, scaleY: w = 1 } = s;
5354
+ if (Math.abs(M - 1) < it && Math.abs(w - 1) < it) return;
5355
+ this.canvas.discardActiveObject(), T.forEach((A) => {
5356
+ var I, O, k, D;
5357
+ if (rt._isTextbox(A)) {
5358
+ const W = (I = A.scaleX) != null ? I : 1, E = (O = A.scaleY) != null ? O : 1, L = ((k = A.fontSize) != null ? k : 16) * E, z = ((D = A.width) != null ? D : 0) * W, B = E, {
5336
5359
  paddingTop: P = 0,
5337
5360
  paddingRight: x = 0,
5338
5361
  paddingBottom: _ = 0,
@@ -5342,7 +5365,7 @@ class rt {
5342
5365
  radiusBottomRight: H = 0,
5343
5366
  radiusBottomLeft: q = 0,
5344
5367
  styles: tt
5345
- } = S, at = {
5368
+ } = A, at = {
5346
5369
  paddingTop: Math.max(0, P * B),
5347
5370
  paddingRight: Math.max(0, x * B),
5348
5371
  paddingBottom: Math.max(0, _ * B),
@@ -5360,7 +5383,7 @@ class rt {
5360
5383
  });
5361
5384
  }));
5362
5385
  const dt = hn({
5363
- lineFontDefaults: S.lineFontDefaults,
5386
+ lineFontDefaults: A.lineFontDefaults,
5364
5387
  scale: B
5365
5388
  }), ht = Ot(F(F({
5366
5389
  fontSize: L,
@@ -5370,21 +5393,21 @@ class rt {
5370
5393
  }, at), ft), {
5371
5394
  styles: wt
5372
5395
  });
5373
- dt && (ht.lineFontDefaults = dt), S.set(ht), Et({ textbox: S });
5396
+ dt && (ht.lineFontDefaults = dt), A.set(ht), Et({ textbox: A });
5374
5397
  }
5375
- S.setCoords();
5398
+ A.setCoords();
5376
5399
  });
5377
- const I = new X(T, {
5400
+ const C = new X(T, {
5378
5401
  canvas: this.canvas
5379
5402
  });
5380
- this.canvas.setActiveObject(I), this.canvas.requestRenderAll();
5403
+ this.canvas.setActiveObject(C), this.canvas.requestRenderAll();
5381
5404
  return;
5382
5405
  }
5383
5406
  if (!rt._isTextbox(s)) return;
5384
5407
  s.isScaling = !1;
5385
5408
  const o = this.scalingState.get(s);
5386
5409
  if (this.scalingState.delete(s), !(o != null && o.hasWidthChange)) return;
5387
- const i = (v = s.width) != null ? v : s.calcTextWidth(), a = (b = (C = s.fontSize) != null ? C : o == null ? void 0 : o.baseFontSize) != null ? b : 16, r = !!(o.baseStyles && Object.keys(o.baseStyles).length), {
5410
+ const i = (v = s.width) != null ? v : s.calcTextWidth(), a = (b = (j = s.fontSize) != null ? j : o == null ? void 0 : o.baseFontSize) != null ? b : 16, r = !!(o.baseStyles && Object.keys(o.baseStyles).length), {
5388
5411
  paddingTop: c = 0,
5389
5412
  paddingRight: l = 0,
5390
5413
  paddingBottom: d = 0,
@@ -5415,7 +5438,7 @@ class rt {
5415
5438
  * @param options — настройки текста
5416
5439
  * @param flags — флаги поведения
5417
5440
  */
5418
- addText(D = {}, { withoutSelection: j = !1, withoutSave: O = !1, withoutAdding: k = !1 } = {}) {
5441
+ addText(D = {}, { withoutSelection: I = !1, withoutSave: O = !1, withoutAdding: k = !1 } = {}) {
5419
5442
  var W = D, {
5420
5443
  id: t = `text-${et()}`,
5421
5444
  text: e = "Новый текст",
@@ -5435,14 +5458,14 @@ class rt {
5435
5458
  backgroundColor: p,
5436
5459
  backgroundOpacity: y = 1,
5437
5460
  paddingTop: v = 0,
5438
- paddingRight: C = 0,
5461
+ paddingRight: j = 0,
5439
5462
  paddingBottom: b = 0,
5440
5463
  paddingLeft: T = 0,
5441
- radiusTopLeft: M = 0,
5442
- radiusTopRight: A = 0,
5464
+ radiusTopLeft: S = 0,
5465
+ radiusTopRight: M = 0,
5443
5466
  radiusBottomRight: w = 0,
5444
- radiusBottomLeft: I = 0
5445
- } = W, S = jt(W, [
5467
+ radiusBottomLeft: C = 0
5468
+ } = W, A = jt(W, [
5446
5469
  "id",
5447
5470
  "text",
5448
5471
  "autoExpand",
@@ -5493,19 +5516,19 @@ class rt {
5493
5516
  backgroundColor: p,
5494
5517
  backgroundOpacity: y,
5495
5518
  paddingTop: v,
5496
- paddingRight: C,
5519
+ paddingRight: j,
5497
5520
  paddingBottom: b,
5498
5521
  paddingLeft: T,
5499
- radiusTopLeft: M,
5500
- radiusTopRight: A,
5522
+ radiusTopLeft: S,
5523
+ radiusTopRight: M,
5501
5524
  radiusBottomRight: w,
5502
- radiusBottomLeft: I
5503
- }, S), _ = new ye(e, x), R = n !== !1;
5525
+ radiusBottomLeft: C
5526
+ }, A), _ = new ye(e, x), R = n !== !1;
5504
5527
  if (_.autoExpand = R, _.textCaseRaw = (K = _.text) != null ? K : "", c) {
5505
5528
  const H = we({ value: _.textCaseRaw });
5506
5529
  H !== _.text && _.set({ text: H });
5507
5530
  }
5508
- return Et({ textbox: _ }) && (_.dirty = !0), S.left === void 0 && S.top === void 0 && L.centerObject(_), k || L.add(_), j || L.setActiveObject(_), L.requestRenderAll(), E.resumeHistory(), O || E.saveState(), L.fire("editor:text-added", {
5531
+ return Et({ textbox: _ }) && (_.dirty = !0), A.left === void 0 && A.top === void 0 && L.centerObject(_), k || L.add(_), I || L.setActiveObject(_), L.requestRenderAll(), E.resumeHistory(), O || E.saveState(), L.fire("editor:text-added", {
5509
5532
  textbox: _,
5510
5533
  options: Ot(F({}, x), {
5511
5534
  text: e,
@@ -5518,7 +5541,7 @@ class rt {
5518
5541
  strokeWidth: B
5519
5542
  }),
5520
5543
  flags: {
5521
- withoutSelection: !!j,
5544
+ withoutSelection: !!I,
5522
5545
  withoutSave: !!O,
5523
5546
  withoutAdding: !!k
5524
5547
  }
@@ -5555,15 +5578,15 @@ class rt {
5555
5578
  fontFamily: p,
5556
5579
  fontSize: y,
5557
5580
  bold: v,
5558
- italic: C,
5581
+ italic: j,
5559
5582
  underline: b,
5560
5583
  uppercase: T,
5561
- strikethrough: M,
5562
- align: A,
5584
+ strikethrough: S,
5585
+ align: M,
5563
5586
  color: w,
5564
- strokeColor: I,
5565
- strokeWidth: S,
5566
- opacity: j,
5587
+ strokeColor: C,
5588
+ strokeWidth: A,
5589
+ opacity: I,
5567
5590
  backgroundColor: O,
5568
5591
  backgroundOpacity: k,
5569
5592
  paddingTop: D,
@@ -5609,20 +5632,20 @@ class rt {
5609
5632
  const Q = v ? "bold" : "normal";
5610
5633
  N && (H.fontWeight = Q), dt && (R.fontWeight = Q, ht && (tt.fontWeight = Q));
5611
5634
  }
5612
- if (C !== void 0) {
5613
- const Q = C ? "italic" : "normal";
5635
+ if (j !== void 0) {
5636
+ const Q = j ? "italic" : "normal";
5614
5637
  N && (H.fontStyle = Q), dt && (R.fontStyle = Q, ht && (tt.fontStyle = Q));
5615
5638
  }
5616
- if (b !== void 0 && (N && (H.underline = b), dt && (R.underline = b, ht && (tt.underline = b))), M !== void 0 && (N && (H.linethrough = M), dt && (R.linethrough = M, ht && (tt.linethrough = M))), A !== void 0 && (R.textAlign = A), w !== void 0 && (N && (H.fill = w), dt && (R.fill = w, ht && (tt.fill = w))), I !== void 0 || S !== void 0) {
5617
- const Q = N ? cn({ textbox: i, range: N, property: "strokeWidth" }) : void 0, st = N ? cn({ textbox: i, range: N, property: "stroke" }) : void 0, Me = (Vt = (Gt = S != null ? S : Q) != null ? Gt : i.strokeWidth) != null ? Vt : 0;
5639
+ if (b !== void 0 && (N && (H.underline = b), dt && (R.underline = b, ht && (tt.underline = b))), S !== void 0 && (N && (H.linethrough = S), dt && (R.linethrough = S, ht && (tt.linethrough = S))), M !== void 0 && (R.textAlign = M), w !== void 0 && (N && (H.fill = w), dt && (R.fill = w, ht && (tt.fill = w))), C !== void 0 || A !== void 0) {
5640
+ const Q = N ? cn({ textbox: i, range: N, property: "strokeWidth" }) : void 0, st = N ? cn({ textbox: i, range: N, property: "stroke" }) : void 0, Me = (Vt = (Gt = A != null ? A : Q) != null ? Gt : i.strokeWidth) != null ? Vt : 0;
5618
5641
  ft = xe({ width: Me });
5619
- const Bt = (kt = (Xt = I != null ? I : st) != null ? Xt : i.stroke) != null ? kt : void 0;
5642
+ const Bt = (kt = (Xt = C != null ? C : st) != null ? Xt : i.stroke) != null ? kt : void 0;
5620
5643
  at = _e({
5621
5644
  strokeColor: Bt,
5622
5645
  width: ft
5623
5646
  }), N && (H.stroke = at, H.strokeWidth = ft), dt && (R.stroke = at, R.strokeWidth = ft, ht && (tt.stroke = at, tt.strokeWidth = ft));
5624
5647
  }
5625
- j !== void 0 && (R.opacity = j), O !== void 0 && (R.backgroundColor = O), k !== void 0 && (R.backgroundOpacity = k), D !== void 0 && (R.paddingTop = D), W !== void 0 && (R.paddingRight = W), E !== void 0 && (R.paddingBottom = E), L !== void 0 && (R.paddingLeft = L), z !== void 0 && (R.radiusTopLeft = z), B !== void 0 && (R.radiusTopRight = B), P !== void 0 && (R.radiusBottomRight = P), x !== void 0 && (R.radiusBottomLeft = x);
5648
+ I !== void 0 && (R.opacity = I), O !== void 0 && (R.backgroundColor = O), k !== void 0 && (R.backgroundOpacity = k), D !== void 0 && (R.paddingTop = D), W !== void 0 && (R.paddingRight = W), E !== void 0 && (R.paddingBottom = E), L !== void 0 && (R.paddingLeft = L), z !== void 0 && (R.radiusTopLeft = z), B !== void 0 && (R.radiusTopRight = B), P !== void 0 && (R.radiusBottomRight = P), x !== void 0 && (R.radiusBottomLeft = x);
5626
5649
  const It = (re = i.textCaseRaw) != null ? re : a, At = !!i.uppercase, Lt = g !== void 0, _t = Lt ? g != null ? g : "" : It, xt = T != null ? T : At, Yt = xt !== At;
5627
5650
  if (Lt || Yt) {
5628
5651
  const Q = xt ? we({ value: _t }) : _t;
@@ -5655,12 +5678,12 @@ class rt {
5655
5678
  updates: st
5656
5679
  });
5657
5680
  }
5658
- if (N && (w !== void 0 || I !== void 0 || S !== void 0)) {
5681
+ if (N && (w !== void 0 || C !== void 0 || A !== void 0)) {
5659
5682
  const Q = Ls({
5660
5683
  textbox: i,
5661
5684
  range: N
5662
5685
  }), st = {};
5663
- w !== void 0 && (st.fill = w), (I !== void 0 || S !== void 0) && (at === null && (st.stroke = null), at != null && (st.stroke = at)), ln({
5686
+ w !== void 0 && (st.fill = w), (C !== void 0 || A !== void 0) && (at === null && (st.stroke = null), at != null && (st.stroke = at)), ln({
5664
5687
  textbox: i,
5665
5688
  lineIndices: Q,
5666
5689
  updates: st
@@ -5758,8 +5781,8 @@ class rt {
5758
5781
  } = t, d = e, u = (k = t.__lineDefaultsPrevText) != null ? k : d, f = u.split(`
5759
5782
  `), g = d.split(`
5760
5783
  `), m = f.length, y = g.length - m;
5761
- let v = n, C = !1, b = !1;
5762
- const T = typeof a == "string" ? a : void 0, M = typeof r == "string" ? r : void 0;
5784
+ let v = n, j = !1, b = !1;
5785
+ const T = typeof a == "string" ? a : void 0, S = typeof r == "string" ? r : void 0;
5763
5786
  if (y !== 0 && n && Object.keys(n).length) {
5764
5787
  const E = _s({
5765
5788
  previous: u,
@@ -5785,7 +5808,7 @@ class rt {
5785
5808
  const N = _ >= B ? _ + y : _;
5786
5809
  P[N] = F({}, R);
5787
5810
  }
5788
- v = P, C = !0, b = !0;
5811
+ v = P, j = !0, b = !0;
5789
5812
  }
5790
5813
  if (y < 0) {
5791
5814
  const z = Math.abs(y);
@@ -5800,36 +5823,36 @@ class rt {
5800
5823
  const K = n[N];
5801
5824
  K && (N < B && (_[N] = F({}, K)), N > x && (_[N + y] = F({}, K)));
5802
5825
  }
5803
- v = _, C = !0, b = !0;
5826
+ v = _, j = !0, b = !0;
5804
5827
  }
5805
5828
  }
5806
- let A = null;
5829
+ let M = null;
5807
5830
  if (l && typeof c == "number") {
5808
5831
  const E = t.get2DCursorLocation(c), { lineIndex: L } = E;
5809
- Number.isFinite(L) && (A = L);
5832
+ Number.isFinite(L) && (M = L);
5810
5833
  }
5811
- let w = s, I = !1, S = !1, j, O = null;
5834
+ let w = s, C = !1, A = !1, I, O = null;
5812
5835
  for (let E = 0; E < g.length; E += 1) {
5813
5836
  const L = (W = g[E]) != null ? W : "", z = v ? v[E] : void 0;
5814
- if (z && (j = z), L.length !== 0) {
5837
+ if (z && (I = z), L.length !== 0) {
5815
5838
  if (z) {
5816
5839
  const N = Is({
5817
5840
  lineText: L,
5818
5841
  lineStyles: w ? w[E] : void 0,
5819
5842
  lineDefaults: z
5820
5843
  });
5821
- N.changed && (w || (w = {}, S = !0), S || (w = F({}, w), S = !0), N.lineStyles && (w[E] = N.lineStyles), !N.lineStyles && w[E] && delete w[E], I = !0);
5844
+ N.changed && (w || (w = {}, A = !0), A || (w = F({}, w), A = !0), N.lineStyles && (w[E] = N.lineStyles), !N.lineStyles && w[E] && delete w[E], C = !0);
5822
5845
  }
5823
5846
  continue;
5824
5847
  }
5825
- const P = z != null ? z : j, x = {};
5826
- (P == null ? void 0 : P.fontFamily) !== void 0 ? x.fontFamily = P.fontFamily : o !== void 0 && (x.fontFamily = o), (P == null ? void 0 : P.fontSize) !== void 0 ? x.fontSize = P.fontSize : i !== void 0 && (x.fontSize = i), (P == null ? void 0 : P.fill) !== void 0 ? x.fill = P.fill : T !== void 0 && (x.fill = T), (P == null ? void 0 : P.stroke) !== void 0 ? x.stroke = P.stroke : M !== void 0 && (x.stroke = M), !z && Object.keys(x).length && (v || (v = {}, b = !0), b || (v = F({}, v), b = !0), v[E] = x, C = !0, j = x), z && (j = z), A !== null && A === E && (O = x);
5848
+ const P = z != null ? z : I, x = {};
5849
+ (P == null ? void 0 : P.fontFamily) !== void 0 ? x.fontFamily = P.fontFamily : o !== void 0 && (x.fontFamily = o), (P == null ? void 0 : P.fontSize) !== void 0 ? x.fontSize = P.fontSize : i !== void 0 && (x.fontSize = i), (P == null ? void 0 : P.fill) !== void 0 ? x.fill = P.fill : T !== void 0 && (x.fill = T), (P == null ? void 0 : P.stroke) !== void 0 ? x.stroke = P.stroke : S !== void 0 && (x.stroke = S), !z && Object.keys(x).length && (v || (v = {}, b = !0), b || (v = F({}, v), b = !0), v[E] = x, j = !0, I = x), z && (I = z), M !== null && M === E && (O = x);
5827
5850
  const _ = {};
5828
5851
  x.fontFamily !== void 0 && (_.fontFamily = x.fontFamily), x.fontSize !== void 0 && (_.fontSize = x.fontSize), x.fill !== void 0 && (_.fill = x.fill), x.stroke !== void 0 && (_.stroke = x.stroke);
5829
5852
  const R = Object.keys(_).length > 0;
5830
- (R || w && w[E]) && (w || (w = {}, S = !0), S || (w = F({}, w), S = !0), R && (w[E] = { 0: _ }), !R && w[E] && delete w[E], I = !0);
5853
+ (R || w && w[E]) && (w || (w = {}, A = !0), A || (w = F({}, w), A = !0), R && (w[E] = { 0: _ }), !R && w[E] && delete w[E], C = !0);
5831
5854
  }
5832
- if (C && v && (t.lineFontDefaults = v), I && (t.styles = w, t.dirty = !0), O && typeof c == "number") {
5855
+ if (j && v && (t.lineFontDefaults = v), C && (t.styles = w, t.dirty = !0), O && typeof c == "number") {
5833
5856
  const E = {};
5834
5857
  if (O.fontFamily !== void 0 && (E.fontFamily = O.fontFamily), O.fontSize !== void 0 && (E.fontSize = O.fontSize), O.fill !== void 0 && (E.fill = O.fill), O.stroke !== void 0 && (E.stroke = O.stroke), Object.keys(E).length) {
5835
5858
  this.lineDefaultsSyncing.add(t);
@@ -5847,15 +5870,15 @@ class rt {
5847
5870
  * но не шире монтажной области, и удерживает объект в её пределах.
5848
5871
  */
5849
5872
  _autoExpandTextboxWidth(t, { anchor: e } = {}) {
5850
- var A, w, I, S, j, O, k, D, W, E, L, z, B;
5873
+ var M, w, C, A, I, O, k, D, W, E, L, z, B;
5851
5874
  const { montageArea: n } = this.editor;
5852
5875
  if (!n) return !1;
5853
5876
  const s = typeof t.text == "string" ? t.text : "";
5854
5877
  if (!s.length) return !1;
5855
5878
  n.setCoords();
5856
- const o = n.getBoundingRect(!1, !0), i = (A = o.width) != null ? A : 0;
5879
+ const o = n.getBoundingRect(!1, !0), i = (M = o.width) != null ? M : 0;
5857
5880
  if (!Number.isFinite(i) || i <= 0) return !1;
5858
- const a = e != null ? e : (w = this.editingAnchorState) == null ? void 0 : w.get(t), r = (S = (I = a == null ? void 0 : a.originY) != null ? I : t.originY) != null ? S : "top", c = Math.abs((j = t.scaleX) != null ? j : 1) || 1, l = (O = t.paddingLeft) != null ? O : 0, d = (k = t.paddingRight) != null ? k : 0, u = (D = t.strokeWidth) != null ? D : 0, f = Math.max(
5881
+ const a = e != null ? e : (w = this.editingAnchorState) == null ? void 0 : w.get(t), r = (A = (C = a == null ? void 0 : a.originY) != null ? C : t.originY) != null ? A : "top", c = Math.abs((I = t.scaleX) != null ? I : 1) || 1, l = (O = t.paddingLeft) != null ? O : 0, d = (k = t.paddingRight) != null ? k : 0, u = (D = t.strokeWidth) != null ? D : 0, f = Math.max(
5859
5882
  1,
5860
5883
  i / c - l - d - u
5861
5884
  );
@@ -5866,18 +5889,18 @@ class rt {
5866
5889
  Math.abs(((W = t.width) != null ? W : 0) - f) > it && (t.set({ width: f }), m = !0), t.initDimensions();
5867
5890
  const { textLines: p } = t, y = Array.isArray(p) && p.length > g, v = Math.ceil(
5868
5891
  ks({ textbox: t, text: s })
5869
- ), C = Math.min((E = t.minWidth) != null ? E : 1, f);
5892
+ ), j = Math.min((E = t.minWidth) != null ? E : 1, f);
5870
5893
  let b = Math.min(
5871
5894
  f,
5872
- Math.max(v, C)
5895
+ Math.max(v, j)
5873
5896
  );
5874
5897
  y && (b = f), Math.abs(((L = t.width) != null ? L : 0) - b) > it && (t.set({ width: b }), t.initDimensions(), m = !0), Et({ textbox: t }) && (m = !0), a && (t.setPositionByOrigin(new lt(a.x, a.y), "center", r), m = !0);
5875
- const M = Bs({
5898
+ const S = Bs({
5876
5899
  textbox: t,
5877
5900
  montageLeft: (z = o.left) != null ? z : 0,
5878
5901
  montageRight: ((B = o.left) != null ? B : 0) + i
5879
5902
  });
5880
- return m || M;
5903
+ return m || S;
5881
5904
  }
5882
5905
  /**
5883
5906
  * Возвращает хранилище якорей редактирования, создавая его при необходимости.
@@ -5954,15 +5977,15 @@ class rt {
5954
5977
  stroke: p,
5955
5978
  strokeWidth: y,
5956
5979
  opacity: v,
5957
- backgroundColor: C,
5980
+ backgroundColor: j,
5958
5981
  backgroundOpacity: b,
5959
5982
  paddingTop: T,
5960
- paddingRight: M,
5961
- paddingBottom: A,
5983
+ paddingRight: S,
5984
+ paddingBottom: M,
5962
5985
  paddingLeft: w,
5963
- radiusTopLeft: I,
5964
- radiusTopRight: S,
5965
- radiusBottomRight: j,
5986
+ radiusTopLeft: C,
5987
+ radiusTopRight: A,
5988
+ radiusBottomRight: I,
5966
5989
  radiusBottomLeft: O,
5967
5990
  left: k,
5968
5991
  top: D,
@@ -5992,15 +6015,15 @@ class rt {
5992
6015
  stroke: p,
5993
6016
  strokeWidth: y,
5994
6017
  opacity: v,
5995
- backgroundColor: C,
6018
+ backgroundColor: j,
5996
6019
  backgroundOpacity: b,
5997
6020
  paddingTop: T,
5998
- paddingRight: M,
5999
- paddingBottom: A,
6021
+ paddingRight: S,
6022
+ paddingBottom: M,
6000
6023
  paddingLeft: w,
6001
- radiusTopLeft: I,
6002
- radiusTopRight: S,
6003
- radiusBottomRight: j,
6024
+ radiusTopLeft: C,
6025
+ radiusTopRight: A,
6026
+ radiusBottomRight: I,
6004
6027
  radiusBottomLeft: O,
6005
6028
  left: k,
6006
6029
  top: D,
@@ -6193,7 +6216,7 @@ class Z {
6193
6216
  baseWidth: p,
6194
6217
  baseHeight: y,
6195
6218
  montageArea: i != null ? i : null
6196
- })), C = Ot(F({}, n), {
6219
+ })), j = Ot(F({}, n), {
6197
6220
  baseWidth: p,
6198
6221
  baseHeight: y,
6199
6222
  positionsNormalized: !0,
@@ -6201,7 +6224,7 @@ class Z {
6201
6224
  });
6202
6225
  return {
6203
6226
  id: t != null ? t : `template-${et()}`,
6204
- meta: C,
6227
+ meta: j,
6205
6228
  objects: v
6206
6229
  };
6207
6230
  }
@@ -6248,17 +6271,17 @@ class Z {
6248
6271
  code: Dt.TEMPLATE_MANAGER.INVALID_TEMPLATE,
6249
6272
  message: "Не удалось создать объекты шаблона"
6250
6273
  }), null;
6251
- const { backgroundObject: C, contentObjects: b } = Z._extractBackgroundObject(v);
6252
- C && (y = yield Z._applyBackgroundFromObject({
6253
- backgroundObject: C,
6274
+ const { backgroundObject: j, contentObjects: b } = Z._extractBackgroundObject(v);
6275
+ j && (y = yield Z._applyBackgroundFromObject({
6276
+ backgroundObject: j,
6254
6277
  backgroundManager: a,
6255
6278
  errorManager: i
6256
6279
  }));
6257
- const T = b.map((M) => (this._adaptTextboxWidth({
6258
- object: M,
6280
+ const T = b.map((S) => (this._adaptTextboxWidth({
6281
+ object: S,
6259
6282
  baseWidth: f.baseWidth
6260
6283
  }), Z._transformObject({
6261
- object: M,
6284
+ object: S,
6262
6285
  scale: g,
6263
6286
  bounds: d,
6264
6287
  targetSize: u,
@@ -6266,10 +6289,10 @@ class Z {
6266
6289
  baseHeight: f.baseHeight,
6267
6290
  montageArea: s,
6268
6291
  useRelativePositions: m
6269
- }), M.set({
6270
- id: `${M.type}-${et()}`,
6292
+ }), S.set({
6293
+ id: `${S.type}-${et()}`,
6271
6294
  evented: !0
6272
- }), n.add(M), M));
6295
+ }), n.add(S), S));
6273
6296
  return !T.length && !y ? null : (p = T.length > 0 || y, T.length && Z._activateObjects({ canvas: n, objects: T }), n.requestRenderAll(), n.fire("editor:template-applied", {
6274
6297
  template: t,
6275
6298
  objects: T,
@@ -6355,21 +6378,21 @@ class Z {
6355
6378
  naturalHeight: 0,
6356
6379
  width: 0,
6357
6380
  height: 0
6358
- }, m = nt({ value: d || f || c.width, fallback: 0 }), p = nt({ value: u || g || c.height, fallback: 0 }), y = nt({ value: s, fallback: m }), v = nt({ value: o, fallback: p }), C = nt({ value: i, fallback: c.scaleX || 1 }), b = nt({ value: a, fallback: c.scaleY || 1 }), T = y * C, M = v * b, A = m > 0, w = p > 0, I = T > 0, S = M > 0, j = Z._resolveImageFit({ customData: r }), O = {};
6359
- if (A && (O.width = m), w && (O.height = p), !A || !w) {
6381
+ }, m = nt({ value: d || f || c.width, fallback: 0 }), p = nt({ value: u || g || c.height, fallback: 0 }), y = nt({ value: s, fallback: m }), v = nt({ value: o, fallback: p }), j = nt({ value: i, fallback: c.scaleX || 1 }), b = nt({ value: a, fallback: c.scaleY || 1 }), T = y * j, S = v * b, M = m > 0, w = p > 0, C = T > 0, A = S > 0, I = Z._resolveImageFit({ customData: r }), O = {};
6382
+ if (M && (O.width = m), w && (O.height = p), !M || !w) {
6360
6383
  c.set(O);
6361
6384
  return;
6362
6385
  }
6363
- if (j === "stretch") {
6364
- const D = I ? T / m : null, W = S ? M / p : null;
6386
+ if (I === "stretch") {
6387
+ const D = C ? T / m : null, W = A ? S / p : null;
6365
6388
  D && D > 0 && (O.scaleX = D), W && W > 0 && (O.scaleY = W), c.set(O);
6366
6389
  return;
6367
6390
  }
6368
- if (!I || !S) {
6391
+ if (!C || !A) {
6369
6392
  c.set(O);
6370
6393
  return;
6371
6394
  }
6372
- const k = Math.min(T / m, M / p);
6395
+ const k = Math.min(T / m, S / p);
6373
6396
  Number.isFinite(k) && k > 0 && (O.scaleX = k, O.scaleY = k), c.set(O);
6374
6397
  }
6375
6398
  /**
@@ -6478,10 +6501,10 @@ class Z {
6478
6501
  bounds: p,
6479
6502
  targetSize: s,
6480
6503
  montageArea: a
6481
- }), v = g * e, C = m * e;
6504
+ }), v = g * e, j = m * e;
6482
6505
  t.set({
6483
6506
  scaleX: v,
6484
- scaleY: C
6507
+ scaleY: j
6485
6508
  }), t.setPositionByOrigin(y, "center", "center"), t.setCoords(), delete c[Jt], delete c[Ae], delete c[fe], delete c[je];
6486
6509
  }
6487
6510
  /**
@@ -6581,16 +6604,16 @@ class Z {
6581
6604
  } = t, r = nt({ value: e, fallback: 0 }), c = t, l = nt({ value: c.paddingLeft, fallback: 0 }), d = nt({ value: c.paddingRight, fallback: 0 }), u = nt({ value: i, fallback: 1 }), f = nt({ value: a, fallback: 0 }) * u, g = nt({ value: o, fallback: 0 }), m = g * u, p = l * u, y = d * u, v = m + p + y + f;
6582
6605
  if (!s || !g || !r) return;
6583
6606
  t.setCoords();
6584
- const C = t, b = C[Jt], T = typeof b == "number" ? b : null, M = Z._resolveAnchor(C, fe), A = v / r, w = T !== null ? T - A / 2 : null, I = T !== null ? T + A / 2 : null, S = t.getCenterPoint();
6607
+ const j = t, b = j[Jt], T = typeof b == "number" ? b : null, S = Z._resolveAnchor(j, fe), M = v / r, w = T !== null ? T - M / 2 : null, C = T !== null ? T + M / 2 : null, A = t.getCenterPoint();
6585
6608
  t.set("width", s), t.initDimensions();
6586
- const j = Z._getLongestLineWidth({
6609
+ const I = Z._getLongestLineWidth({
6587
6610
  textbox: t,
6588
6611
  text: n
6589
- }), O = j > g ? j + 1 : g;
6590
- t.set("width", O), t.initDimensions(), t.setPositionByOrigin(S, "center", "center"), t.setCoords();
6612
+ }), O = I > g ? I + 1 : g;
6613
+ t.set("width", O), t.initDimensions(), t.setPositionByOrigin(A, "center", "center"), t.setCoords();
6591
6614
  const D = (O * u + p + y + f) / r;
6592
6615
  let W = T;
6593
- M === "start" && w !== null ? W = Math.max(0, w) + D / 2 : M === "end" && I !== null && (W = Math.min(1, I) - D / 2), typeof W == "number" && (C[Jt] = W);
6616
+ S === "start" && w !== null ? W = Math.max(0, w) + D / 2 : S === "end" && C !== null && (W = Math.min(1, C) - D / 2), typeof W == "number" && (j[Jt] = W);
6594
6617
  }
6595
6618
  /**
6596
6619
  * Возвращает ширину самой длинной строки текстового объекта.
@@ -6641,7 +6664,7 @@ class Z {
6641
6664
  x: (b.x - a) / u,
6642
6665
  y: (b.y - r) / f
6643
6666
  };
6644
- })(), p = (d.left - a) / u, y = (d.top - r) / f, v = p + d.width / u, C = y + d.height / f;
6667
+ })(), p = (d.left - a) / u, y = (d.top - r) / f, v = p + d.width / u, j = y + d.height / f;
6645
6668
  return i[Jt] = m.x, i[Ae] = m.y, i[fe] = Z._detectAnchor({
6646
6669
  center: m.x,
6647
6670
  start: p,
@@ -6649,7 +6672,7 @@ class Z {
6649
6672
  }), i[je] = Z._detectAnchor({
6650
6673
  center: m.y,
6651
6674
  start: y,
6652
- end: C
6675
+ end: j
6653
6676
  }), i.left = p, i.top = y, i;
6654
6677
  }
6655
6678
  /**
@@ -6860,26 +6883,26 @@ const Ce = 5, Mn = "#3D8BF4", Re = 1, ot = 2, Ue = ({
6860
6883
  left: a,
6861
6884
  right: r
6862
6885
  } = h, c = [];
6863
- for (const M of t) {
6864
- const { left: A, right: w } = M;
6865
- Math.min(w, r) - Math.max(A, a) > 0 && c.push(M);
6886
+ for (const S of t) {
6887
+ const { left: M, right: w } = S;
6888
+ Math.min(w, r) - Math.max(M, a) > 0 && c.push(S);
6866
6889
  }
6867
6890
  if (!c.length)
6868
6891
  return { delta: 0, guide: null };
6869
6892
  const l = [];
6870
- for (const M of c)
6871
- l.push({ bounds: M, isActive: !1 });
6893
+ for (const S of c)
6894
+ l.push({ bounds: S, isActive: !1 });
6872
6895
  l.push({ bounds: h, isActive: !0 }), Sn({ items: l, axis: "top" });
6873
6896
  const d = wn({ items: l });
6874
6897
  if (d === -1)
6875
6898
  return { delta: 0, guide: null };
6876
6899
  const u = [], f = i - o, g = l[d - 1], m = l[d + 1];
6877
6900
  if (g && m) {
6878
- const { bounds: M } = g, { bounds: A } = m, { bottom: w } = M, { top: I } = A, j = I - w - f;
6879
- if (j >= 0) {
6880
- const O = j / 2;
6901
+ const { bounds: S } = g, { bounds: M } = m, { bottom: w } = S, { top: C } = M, I = C - w - f;
6902
+ if (I >= 0) {
6903
+ const O = I / 2;
6881
6904
  if (yt({ value: O, step: ot })) {
6882
- const D = Ue({ value: O, step: ot }), W = o - w, E = I - i, L = Math.abs(W - D), z = Math.abs(E - D), B = Math.max(L, z);
6905
+ const D = Ue({ value: O, step: ot }), W = o - w, E = C - i, L = Math.abs(W - D), z = Math.abs(E - D), B = Math.max(L, z);
6883
6906
  if (B <= e) {
6884
6907
  const P = D - W;
6885
6908
  if (yt({ value: P, step: ot })) {
@@ -6899,56 +6922,56 @@ const Ce = 5, Mn = "#3D8BF4", Re = 1, ot = 2, Ue = ({
6899
6922
  }
6900
6923
  }
6901
6924
  const p = An({ items: l, axis: "vertical" });
6902
- let y = null, v = null, C = null, b = null;
6925
+ let y = null, v = null, j = null, b = null;
6903
6926
  if (g) {
6904
- C = g.bounds;
6905
- const { bottom: M } = C, A = o - M;
6906
- A >= 0 && (y = A);
6927
+ j = g.bounds;
6928
+ const { bottom: S } = j, M = o - S;
6929
+ M >= 0 && (y = M);
6907
6930
  }
6908
6931
  if (m) {
6909
6932
  b = m.bounds;
6910
- const { top: M } = b, A = M - i;
6911
- A >= 0 && (v = A);
6933
+ const { top: S } = b, M = S - i;
6934
+ M >= 0 && (v = M);
6912
6935
  }
6913
- for (const M of p) {
6936
+ for (const S of p) {
6914
6937
  const {
6915
- beforeIndex: A,
6938
+ beforeIndex: M,
6916
6939
  afterIndex: w,
6917
- start: I,
6918
- end: S,
6919
- distance: j
6920
- } = M;
6921
- if (!(A === d || w === d || !yt({ value: j, step: ot }))) {
6922
- if (y !== null && C) {
6923
- const k = Math.abs(y - j);
6940
+ start: C,
6941
+ end: A,
6942
+ distance: I
6943
+ } = S;
6944
+ if (!(M === d || w === d || !yt({ value: I, step: ot }))) {
6945
+ if (y !== null && j) {
6946
+ const k = Math.abs(y - I);
6924
6947
  if (k <= e) {
6925
- const D = j - y;
6948
+ const D = I - y;
6926
6949
  if (!yt({ value: D, step: ot })) continue;
6927
- const E = o + D, { bottom: L } = C, z = {
6950
+ const E = o + D, { bottom: L } = j, z = {
6928
6951
  type: "vertical",
6929
6952
  axis: s,
6930
- refStart: I,
6931
- refEnd: S,
6953
+ refStart: C,
6954
+ refEnd: A,
6932
6955
  activeStart: L,
6933
6956
  activeEnd: E,
6934
- distance: j
6957
+ distance: I
6935
6958
  };
6936
6959
  u.push({ delta: D, guide: z, diff: k });
6937
6960
  }
6938
6961
  }
6939
6962
  if (v !== null && b) {
6940
- const k = Math.abs(v - j);
6963
+ const k = Math.abs(v - I);
6941
6964
  if (k <= e) {
6942
- const D = v - j;
6965
+ const D = v - I;
6943
6966
  if (!yt({ value: D, step: ot })) continue;
6944
6967
  const E = i + D, { top: L } = b, z = {
6945
6968
  type: "vertical",
6946
6969
  axis: s,
6947
- refStart: I,
6948
- refEnd: S,
6970
+ refStart: C,
6971
+ refEnd: A,
6949
6972
  activeStart: E,
6950
6973
  activeEnd: L,
6951
- distance: j
6974
+ distance: I
6952
6975
  };
6953
6976
  u.push({ delta: D, guide: z, diff: k });
6954
6977
  }
@@ -6958,9 +6981,9 @@ const Ce = 5, Mn = "#3D8BF4", Re = 1, ot = 2, Ue = ({
6958
6981
  if (!u.length)
6959
6982
  return { delta: 0, guide: null };
6960
6983
  let T = u[0];
6961
- for (let M = 1; M < u.length; M += 1) {
6962
- const A = u[M];
6963
- A.diff < T.diff && (T = A);
6984
+ for (let S = 1; S < u.length; S += 1) {
6985
+ const M = u[S];
6986
+ M.diff < T.diff && (T = M);
6964
6987
  }
6965
6988
  return {
6966
6989
  delta: T.delta,
@@ -6979,26 +7002,26 @@ const Ce = 5, Mn = "#3D8BF4", Re = 1, ot = 2, Ue = ({
6979
7002
  top: a,
6980
7003
  bottom: r
6981
7004
  } = h, c = [];
6982
- for (const M of t) {
6983
- const { top: A, bottom: w } = M;
6984
- Math.min(w, r) - Math.max(A, a) > 0 && c.push(M);
7005
+ for (const S of t) {
7006
+ const { top: M, bottom: w } = S;
7007
+ Math.min(w, r) - Math.max(M, a) > 0 && c.push(S);
6985
7008
  }
6986
7009
  if (!c.length)
6987
7010
  return { delta: 0, guide: null };
6988
7011
  const l = [];
6989
- for (const M of c)
6990
- l.push({ bounds: M, isActive: !1 });
7012
+ for (const S of c)
7013
+ l.push({ bounds: S, isActive: !1 });
6991
7014
  l.push({ bounds: h, isActive: !0 }), Sn({ items: l, axis: "left" });
6992
7015
  const d = wn({ items: l });
6993
7016
  if (d === -1)
6994
7017
  return { delta: 0, guide: null };
6995
7018
  const u = [], f = i - o, g = l[d - 1], m = l[d + 1];
6996
7019
  if (g && m) {
6997
- const { bounds: M } = g, { bounds: A } = m, { right: w } = M, { left: I } = A, j = I - w - f;
6998
- if (j >= 0) {
6999
- const O = j / 2;
7020
+ const { bounds: S } = g, { bounds: M } = m, { right: w } = S, { left: C } = M, I = C - w - f;
7021
+ if (I >= 0) {
7022
+ const O = I / 2;
7000
7023
  if (yt({ value: O, step: ot })) {
7001
- const D = Ue({ value: O, step: ot }), W = o - w, E = I - i, L = Math.abs(W - D), z = Math.abs(E - D), B = Math.max(L, z);
7024
+ const D = Ue({ value: O, step: ot }), W = o - w, E = C - i, L = Math.abs(W - D), z = Math.abs(E - D), B = Math.max(L, z);
7002
7025
  if (B <= e) {
7003
7026
  const P = D - W;
7004
7027
  if (yt({ value: P, step: ot })) {
@@ -7018,56 +7041,56 @@ const Ce = 5, Mn = "#3D8BF4", Re = 1, ot = 2, Ue = ({
7018
7041
  }
7019
7042
  }
7020
7043
  const p = An({ items: l, axis: "horizontal" });
7021
- let y = null, v = null, C = null, b = null;
7044
+ let y = null, v = null, j = null, b = null;
7022
7045
  if (g) {
7023
- C = g.bounds;
7024
- const { right: M } = C, A = o - M;
7025
- A >= 0 && (y = A);
7046
+ j = g.bounds;
7047
+ const { right: S } = j, M = o - S;
7048
+ M >= 0 && (y = M);
7026
7049
  }
7027
7050
  if (m) {
7028
7051
  b = m.bounds;
7029
- const { left: M } = b, A = M - i;
7030
- A >= 0 && (v = A);
7052
+ const { left: S } = b, M = S - i;
7053
+ M >= 0 && (v = M);
7031
7054
  }
7032
- for (const M of p) {
7055
+ for (const S of p) {
7033
7056
  const {
7034
- beforeIndex: A,
7057
+ beforeIndex: M,
7035
7058
  afterIndex: w,
7036
- start: I,
7037
- end: S,
7038
- distance: j
7039
- } = M;
7040
- if (!(A === d || w === d || !yt({ value: j, step: ot }))) {
7041
- if (y !== null && C) {
7042
- const k = Math.abs(y - j);
7059
+ start: C,
7060
+ end: A,
7061
+ distance: I
7062
+ } = S;
7063
+ if (!(M === d || w === d || !yt({ value: I, step: ot }))) {
7064
+ if (y !== null && j) {
7065
+ const k = Math.abs(y - I);
7043
7066
  if (k <= e) {
7044
- const D = j - y;
7067
+ const D = I - y;
7045
7068
  if (!yt({ value: D, step: ot })) continue;
7046
- const E = o + D, { right: L } = C, z = {
7069
+ const E = o + D, { right: L } = j, z = {
7047
7070
  type: "horizontal",
7048
7071
  axis: s,
7049
- refStart: I,
7050
- refEnd: S,
7072
+ refStart: C,
7073
+ refEnd: A,
7051
7074
  activeStart: L,
7052
7075
  activeEnd: E,
7053
- distance: j
7076
+ distance: I
7054
7077
  };
7055
7078
  u.push({ delta: D, guide: z, diff: k });
7056
7079
  }
7057
7080
  }
7058
7081
  if (v !== null && b) {
7059
- const k = Math.abs(v - j);
7082
+ const k = Math.abs(v - I);
7060
7083
  if (k <= e) {
7061
- const D = v - j;
7084
+ const D = v - I;
7062
7085
  if (!yt({ value: D, step: ot })) continue;
7063
7086
  const E = i + D, { left: L } = b, z = {
7064
7087
  type: "horizontal",
7065
7088
  axis: s,
7066
- refStart: I,
7067
- refEnd: S,
7089
+ refStart: C,
7090
+ refEnd: A,
7068
7091
  activeStart: E,
7069
7092
  activeEnd: L,
7070
- distance: j
7093
+ distance: I
7071
7094
  };
7072
7095
  u.push({ delta: D, guide: z, diff: k });
7073
7096
  }
@@ -7077,9 +7100,9 @@ const Ce = 5, Mn = "#3D8BF4", Re = 1, ot = 2, Ue = ({
7077
7100
  if (!u.length)
7078
7101
  return { delta: 0, guide: null };
7079
7102
  let T = u[0];
7080
- for (let M = 1; M < u.length; M += 1) {
7081
- const A = u[M];
7082
- A.diff < T.diff && (T = A);
7103
+ for (let S = 1; S < u.length; S += 1) {
7104
+ const M = u[S];
7105
+ M.diff < T.diff && (T = M);
7083
7106
  }
7084
7107
  return {
7085
7108
  delta: T.delta,
@@ -7134,14 +7157,14 @@ const Ce = 5, Mn = "#3D8BF4", Re = 1, ot = 2, Ue = ({
7134
7157
  offsetAlongAxis: f = 0,
7135
7158
  offsetPerpendicular: g = 0
7136
7159
  }) => {
7137
- const m = i || 1, p = 12 / m, y = d / m, v = u / m, C = (n + s) / 2 + f, b = t === "vertical" ? e + g : C, T = t === "vertical" ? C : e + g;
7160
+ const m = i || 1, p = 12 / m, y = d / m, v = u / m, j = (n + s) / 2 + f, b = t === "vertical" ? e + g : j, T = t === "vertical" ? j : e + g;
7138
7161
  h.save(), h.setLineDash([]), h.fillStyle = a, h.strokeStyle = a, h.lineWidth = l / m, h.font = `${p}px ${c}`, h.textAlign = "center", h.textBaseline = "middle";
7139
- const A = h.measureText(o).width + y * 2, w = p + y * 2, I = b - A / 2, S = T - w / 2;
7162
+ const M = h.measureText(o).width + y * 2, w = p + y * 2, C = b - M / 2, A = T - w / 2;
7140
7163
  h.beginPath(), Gs({
7141
7164
  context: h,
7142
- x: I,
7143
- y: S,
7144
- width: A,
7165
+ x: C,
7166
+ y: A,
7167
+ width: M,
7145
7168
  height: w,
7146
7169
  radius: v
7147
7170
  }), h.fill(), h.fillStyle = r, h.fillText(o, b, T), h.restore();
@@ -7383,26 +7406,26 @@ class $ {
7383
7406
  originY: y
7384
7407
  } = s, {
7385
7408
  originX: v = "left",
7386
- originY: C = "top",
7409
+ originY: j = "top",
7387
7410
  scaleX: b = 1,
7388
7411
  scaleY: T = 1
7389
- } = e, M = p != null ? p : v, A = y != null ? y : C, w = $._collectVerticalSnapCandidates({
7412
+ } = e, S = p != null ? p : v, M = y != null ? y : j, w = $._collectVerticalSnapCandidates({
7390
7413
  bounds: u,
7391
- originX: M,
7414
+ originX: S,
7392
7415
  shouldSnapX: i
7393
- }), I = $._collectHorizontalSnapCandidates({
7416
+ }), C = $._collectHorizontalSnapCandidates({
7394
7417
  bounds: u,
7395
- originY: A,
7418
+ originY: M,
7396
7419
  shouldSnapY: a
7397
- }), S = $._findAxisSnapCandidate({
7420
+ }), A = $._findAxisSnapCandidate({
7398
7421
  anchors: l,
7399
7422
  candidates: w,
7400
7423
  threshold: m
7401
- }), j = $._findAxisSnapCandidate({
7424
+ }), I = $._findAxisSnapCandidate({
7402
7425
  anchors: d,
7403
- candidates: I,
7426
+ candidates: C,
7404
7427
  threshold: m
7405
- }), { guidePosition: O } = S, { guidePosition: k } = j, D = O !== null, W = k !== null;
7428
+ }), { guidePosition: O } = A, { guidePosition: k } = I, D = O !== null, W = k !== null;
7406
7429
  if (!D && !W) {
7407
7430
  this._clearGuides();
7408
7431
  return;
@@ -7412,10 +7435,10 @@ class $ {
7412
7435
  if (r) {
7413
7436
  const P = $._resolveUniformScale({
7414
7437
  bounds: u,
7415
- originX: M,
7416
- originY: A,
7417
- verticalSnap: S,
7418
- horizontalSnap: j
7438
+ originX: S,
7439
+ originY: M,
7440
+ verticalSnap: A,
7441
+ horizontalSnap: I
7419
7442
  });
7420
7443
  if (P) {
7421
7444
  const { scaleFactor: x, guide: _ } = P;
@@ -7427,8 +7450,8 @@ class $ {
7427
7450
  if (D) {
7428
7451
  const K = $._resolveDesiredWidth({
7429
7452
  bounds: u,
7430
- originX: M,
7431
- snap: S
7453
+ originX: S,
7454
+ snap: A
7432
7455
  });
7433
7456
  if (K !== null) {
7434
7457
  const H = $._resolveScaleForWidth({
@@ -7450,8 +7473,8 @@ class $ {
7450
7473
  if (W) {
7451
7474
  const K = $._resolveDesiredHeight({
7452
7475
  bounds: u,
7453
- originY: A,
7454
- snap: j
7476
+ originY: M,
7477
+ snap: I
7455
7478
  });
7456
7479
  if (K !== null) {
7457
7480
  const H = $._resolveScaleForHeight({
@@ -7477,8 +7500,8 @@ class $ {
7477
7500
  return;
7478
7501
  }
7479
7502
  if (B) {
7480
- const P = e.getRelativeCenterPoint(), x = e.translateToOriginPoint(P, M, A), _ = {};
7481
- L !== null && (_.scaleX = L, s.scaleX = L), z !== null && (_.scaleY = z, s.scaleY = z), Object.keys(_).length && (e.set(_), e.setPositionByOrigin(x, M, A), e.setCoords());
7503
+ const P = e.getRelativeCenterPoint(), x = e.translateToOriginPoint(P, S, M), _ = {};
7504
+ L !== null && (_.scaleX = L, s.scaleX = L), z !== null && (_.scaleY = z, s.scaleY = z), Object.keys(_).length && (e.set(_), e.setPositionByOrigin(x, S, M), e.setCoords());
7482
7505
  }
7483
7506
  this._applyGuides({
7484
7507
  guides: E,
@@ -7520,7 +7543,7 @@ class $ {
7520
7543
  const { canvas: d } = this, u = d.getZoom() || 1, f = Ce / u, { originX: g, originY: m } = e, {
7521
7544
  originX: p = "left",
7522
7545
  originY: y = "top"
7523
- } = t, v = g != null ? g : p, C = m != null ? m : y, b = $._collectVerticalSnapCandidates({
7546
+ } = t, v = g != null ? g : p, j = m != null ? m : y, b = $._collectVerticalSnapCandidates({
7524
7547
  bounds: l,
7525
7548
  originX: v,
7526
7549
  shouldSnapX: !0
@@ -7528,38 +7551,38 @@ class $ {
7528
7551
  anchors: r,
7529
7552
  candidates: b,
7530
7553
  threshold: f
7531
- }), { guidePosition: M } = T;
7532
- if (M === null) {
7554
+ }), { guidePosition: S } = T;
7555
+ if (S === null) {
7533
7556
  this._clearGuides();
7534
7557
  return;
7535
7558
  }
7536
- const A = $._resolveDesiredWidth({
7559
+ const M = $._resolveDesiredWidth({
7537
7560
  bounds: l,
7538
7561
  originX: v,
7539
7562
  snap: T
7540
7563
  });
7541
- if (A === null) {
7564
+ if (M === null) {
7542
7565
  this._clearGuides();
7543
7566
  return;
7544
7567
  }
7545
7568
  const w = $._resolveTextWidthForBounds({
7546
7569
  target: t,
7547
- boundsWidth: A
7570
+ boundsWidth: M
7548
7571
  });
7549
7572
  if (w === null) {
7550
7573
  this._clearGuides();
7551
7574
  return;
7552
7575
  }
7553
- const { width: I = 0 } = t;
7554
- if (w !== I) {
7555
- const S = t.getRelativeCenterPoint(), j = t.translateToOriginPoint(S, v, C);
7556
- t.set({ width: w }), t.setPositionByOrigin(j, v, C), t.setCoords();
7576
+ const { width: C = 0 } = t;
7577
+ if (w !== C) {
7578
+ const A = t.getRelativeCenterPoint(), I = t.translateToOriginPoint(A, v, j);
7579
+ t.set({ width: w }), t.setPositionByOrigin(I, v, j), t.setCoords();
7557
7580
  }
7558
7581
  this._applyGuides({
7559
7582
  guides: [
7560
7583
  {
7561
7584
  type: "vertical",
7562
- position: M
7585
+ position: S
7563
7586
  }
7564
7587
  ],
7565
7588
  spacingGuides: []
@@ -7731,31 +7754,31 @@ class $ {
7731
7754
  } = o;
7732
7755
  let p = null, y = null;
7733
7756
  if (u !== null && l > 0) {
7734
- const C = $._resolveDesiredWidth({
7757
+ const j = $._resolveDesiredWidth({
7735
7758
  bounds: t,
7736
7759
  originX: e,
7737
7760
  snap: s
7738
7761
  });
7739
- if (C !== null) {
7740
- const b = C / l;
7762
+ if (j !== null) {
7763
+ const b = j / l;
7741
7764
  Number.isFinite(b) && b > 0 && (p = b);
7742
7765
  }
7743
7766
  }
7744
7767
  if (g !== null && d > 0) {
7745
- const C = $._resolveDesiredHeight({
7768
+ const j = $._resolveDesiredHeight({
7746
7769
  bounds: t,
7747
7770
  originY: n,
7748
7771
  snap: o
7749
7772
  });
7750
- if (C !== null) {
7751
- const b = C / d;
7773
+ if (j !== null) {
7774
+ const b = j / d;
7752
7775
  Number.isFinite(b) && b > 0 && (y = b);
7753
7776
  }
7754
7777
  }
7755
7778
  let v = null;
7756
7779
  if (p !== null && y === null && (v = "x"), y !== null && p === null && (v = "y"), p !== null && y !== null) {
7757
- const C = Math.abs(f), b = Math.abs(m);
7758
- C <= b && (v = "x"), C > b && (v = "y");
7780
+ const j = Math.abs(f), b = Math.abs(m);
7781
+ j <= b && (v = "x"), j > b && (v = "y");
7759
7782
  }
7760
7783
  return v === "x" && p !== null && u !== null ? {
7761
7784
  scaleFactor: p,
@@ -8119,42 +8142,42 @@ class Wt {
8119
8142
  } = e, m = Math.max(a, u), p = Math.min(r, f), v = p >= m ? (m + p) / 2 : (c + g) / 2;
8120
8143
  if (l >= i) {
8121
8144
  if (n) return s;
8122
- const j = l - i;
8123
- return j > 0 && s.push({
8145
+ const I = l - i;
8146
+ return I > 0 && s.push({
8124
8147
  type: "horizontal",
8125
8148
  axis: v,
8126
8149
  start: i,
8127
8150
  end: l,
8128
- distance: j
8151
+ distance: I
8129
8152
  }), s;
8130
8153
  }
8131
8154
  if (d <= o) {
8132
8155
  if (n) return s;
8133
- const j = o - d;
8134
- return j > 0 && s.push({
8156
+ const I = o - d;
8157
+ return I > 0 && s.push({
8135
8158
  type: "horizontal",
8136
8159
  axis: v,
8137
8160
  start: d,
8138
8161
  end: o,
8139
- distance: j
8162
+ distance: I
8140
8163
  }), s;
8141
8164
  }
8142
8165
  if (!n) return s;
8143
- const C = o < l, b = i > d, T = Math.min(o, l), M = Math.max(o, l), A = M - T;
8144
- A > 0 && !C && s.push({
8166
+ const j = o < l, b = i > d, T = Math.min(o, l), S = Math.max(o, l), M = S - T;
8167
+ M > 0 && !j && s.push({
8145
8168
  type: "horizontal",
8146
8169
  axis: v,
8147
8170
  start: T,
8148
- end: M,
8149
- distance: A
8171
+ end: S,
8172
+ distance: M
8150
8173
  });
8151
- const w = Math.min(i, d), I = Math.max(i, d), S = I - w;
8152
- return S > 0 && !b && s.push({
8174
+ const w = Math.min(i, d), C = Math.max(i, d), A = C - w;
8175
+ return A > 0 && !b && s.push({
8153
8176
  type: "horizontal",
8154
8177
  axis: v,
8155
8178
  start: w,
8156
- end: I,
8157
- distance: S
8179
+ end: C,
8180
+ distance: A
8158
8181
  }), s;
8159
8182
  }
8160
8183
  /**
@@ -8180,42 +8203,42 @@ class Wt {
8180
8203
  } = e, m = Math.max(a, u), p = Math.min(r, f), v = p >= m ? (m + p) / 2 : (c + g) / 2;
8181
8204
  if (l >= i) {
8182
8205
  if (n) return s;
8183
- const j = l - i;
8184
- return j > 0 && s.push({
8206
+ const I = l - i;
8207
+ return I > 0 && s.push({
8185
8208
  type: "vertical",
8186
8209
  axis: v,
8187
8210
  start: i,
8188
8211
  end: l,
8189
- distance: j
8212
+ distance: I
8190
8213
  }), s;
8191
8214
  }
8192
8215
  if (d <= o) {
8193
8216
  if (n) return s;
8194
- const j = o - d;
8195
- return j > 0 && s.push({
8217
+ const I = o - d;
8218
+ return I > 0 && s.push({
8196
8219
  type: "vertical",
8197
8220
  axis: v,
8198
8221
  start: d,
8199
8222
  end: o,
8200
- distance: j
8223
+ distance: I
8201
8224
  }), s;
8202
8225
  }
8203
8226
  if (!n) return s;
8204
- const C = o < l, b = i > d, T = Math.min(o, l), M = Math.max(o, l), A = M - T;
8205
- A > 0 && !C && s.push({
8227
+ const j = o < l, b = i > d, T = Math.min(o, l), S = Math.max(o, l), M = S - T;
8228
+ M > 0 && !j && s.push({
8206
8229
  type: "vertical",
8207
8230
  axis: v,
8208
8231
  start: T,
8209
- end: M,
8210
- distance: A
8232
+ end: S,
8233
+ distance: M
8211
8234
  });
8212
- const w = Math.min(i, d), I = Math.max(i, d), S = I - w;
8213
- return S > 0 && !b && s.push({
8235
+ const w = Math.min(i, d), C = Math.max(i, d), A = C - w;
8236
+ return A > 0 && !b && s.push({
8214
8237
  type: "vertical",
8215
8238
  axis: v,
8216
8239
  start: w,
8217
- end: I,
8218
- distance: S
8240
+ end: C,
8241
+ distance: A
8219
8242
  }), s;
8220
8243
  }
8221
8244
  /**