@snowcone-app/canvas 0.27.0 → 0.29.0

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 (73) hide show
  1. package/ERROR_CONTRACT.md +13 -0
  2. package/dist/{CanvasRenderer-yszzrDfo.js → CanvasRenderer-_lFoIoz5.js} +916 -848
  3. package/dist/CanvasRenderer-_lFoIoz5.js.map +1 -0
  4. package/dist/{CanvasStateV1-BTbCD_xC.js → CanvasStateV1-BMxr6xb8.js} +7 -4
  5. package/dist/{CanvasStateV1-BTbCD_xC.js.map → CanvasStateV1-BMxr6xb8.js.map} +1 -1
  6. package/dist/ContextualToolbars-0jWvnQgp.js +5833 -0
  7. package/dist/ContextualToolbars-0jWvnQgp.js.map +1 -0
  8. package/dist/{EditorCanvasImpl-Ui8Ceb-h.js → EditorCanvasImpl-BNz8TPFs.js} +8 -8
  9. package/dist/{EditorCanvasImpl-Ui8Ceb-h.js.map → EditorCanvasImpl-BNz8TPFs.js.map} +1 -1
  10. package/dist/{ExportManager-BTcyj4cf.js → ExportManager-B8Td7uR5.js} +1051 -976
  11. package/dist/ExportManager-B8Td7uR5.js.map +1 -0
  12. package/dist/{FontAnalyzer-EF3gLPr8.js → FontAnalyzer-D4Sg-P6_.js} +1410 -1329
  13. package/dist/FontAnalyzer-D4Sg-P6_.js.map +1 -0
  14. package/dist/{ImagePanel-CIk6z41z.js → ImagePanel-CN2Bu3hf.js} +6 -6
  15. package/dist/{ImagePanel-CIk6z41z.js.map → ImagePanel-CN2Bu3hf.js.map} +1 -1
  16. package/dist/{SnowconeCanvas-DuWALOAt.js → SnowconeCanvas-CR_LdRFP.js} +27 -27
  17. package/dist/{SnowconeCanvas-DuWALOAt.js.map → SnowconeCanvas-CR_LdRFP.js.map} +1 -1
  18. package/dist/{UnifiedFontService-CHVYDBDW.js → UnifiedFontService-CgYnYTj7.js} +755 -713
  19. package/dist/UnifiedFontService-CgYnYTj7.js.map +1 -0
  20. package/dist/advanced.mjs +14 -14
  21. package/dist/components/MultiSelectionToolbar.d.ts +18 -0
  22. package/dist/components/toolbars/SecondaryPanels.d.ts +11 -0
  23. package/dist/components/ui/toolbar-button.d.ts +2 -0
  24. package/dist/core/GestureConstraints.d.ts +92 -0
  25. package/dist/core/InteractionStateMachine.d.ts +16 -2
  26. package/dist/core/ResizeHandler.d.ts +4 -1
  27. package/dist/core/ResizePipeline.d.ts +3 -0
  28. package/dist/core/TextElement.d.ts +13 -0
  29. package/dist/core/TextMetrics.d.ts +17 -3
  30. package/dist/core/rich-text-layout.d.ts +2 -0
  31. package/dist/core/text-spacing.d.ts +74 -0
  32. package/dist/{custom-icons-CcLMyybv.js → custom-icons-B5TRC1Ed.js} +2 -2
  33. package/dist/{custom-icons-CcLMyybv.js.map → custom-icons-B5TRC1Ed.js.map} +1 -1
  34. package/dist/{design-builder-cZY958Rw.js → design-builder-COj0zkxu.js} +2 -2
  35. package/dist/{design-builder-cZY958Rw.js.map → design-builder-COj0zkxu.js.map} +1 -1
  36. package/dist/{editorErrors-BhrZ_nwj.js → editorErrors-CCvoKj_P.js} +2 -2
  37. package/dist/editorErrors-CCvoKj_P.js.map +1 -0
  38. package/dist/{embed-CJswRZte.js → embed-BTRtoktw.js} +10 -10
  39. package/dist/{embed-CJswRZte.js.map → embed-BTRtoktw.js.map} +1 -1
  40. package/dist/embed.mjs +6 -6
  41. package/dist/errors/editorError.d.ts +7 -1
  42. package/dist/{guards-DIX8aXWM.js → guards-uQtEQJbs.js} +2 -2
  43. package/dist/{guards-DIX8aXWM.js.map → guards-uQtEQJbs.js.map} +1 -1
  44. package/dist/hooks/index.d.ts +2 -0
  45. package/dist/hooks/useAlignDistribute.d.ts +19 -0
  46. package/dist/hooks/useTextToolbar.d.ts +8 -0
  47. package/dist/index.mjs +8 -8
  48. package/dist/internals.mjs +5 -5
  49. package/dist/rendering/renderer-types.d.ts +4 -0
  50. package/dist/rendering/rich-text-renderer.d.ts +4 -0
  51. package/dist/rendering/text-renderer.d.ts +4 -1
  52. package/dist/state/CanvasStateV1.d.ts +3 -0
  53. package/dist/{template-fields-BXl29sgh.js → template-fields-BLRp84Ny.js} +6 -6
  54. package/dist/{template-fields-BXl29sgh.js.map → template-fields-BLRp84Ny.js.map} +1 -1
  55. package/dist/testing.mjs +4 -4
  56. package/dist/types/index.d.ts +26 -0
  57. package/dist/{usePieceGuideBundle-DE21DQGZ.js → usePieceGuideBundle-CTQszfKA.js} +2 -2
  58. package/dist/{usePieceGuideBundle-DE21DQGZ.js.map → usePieceGuideBundle-CTQszfKA.js.map} +1 -1
  59. package/dist/utils/alignDistribute.d.ts +41 -0
  60. package/dist/utils/featureApplied.d.ts +6 -0
  61. package/dist/{validation-DGXAQmUC.js → validation-eCebhplp.js} +2991 -2956
  62. package/dist/validation-eCebhplp.js.map +1 -0
  63. package/dist/workers/export-worker.bundle.string.d.ts +1 -1
  64. package/example/package.json +1 -1
  65. package/package.json +1 -1
  66. package/dist/CanvasRenderer-yszzrDfo.js.map +0 -1
  67. package/dist/ContextualToolbars-BHjYsril.js +0 -5556
  68. package/dist/ContextualToolbars-BHjYsril.js.map +0 -1
  69. package/dist/ExportManager-BTcyj4cf.js.map +0 -1
  70. package/dist/FontAnalyzer-EF3gLPr8.js.map +0 -1
  71. package/dist/UnifiedFontService-CHVYDBDW.js.map +0 -1
  72. package/dist/editorErrors-BhrZ_nwj.js.map +0 -1
  73. package/dist/validation-DGXAQmUC.js.map +0 -1
@@ -1,7 +1,7 @@
1
- import { X as te, Y as ee, ar as tt, Z as zt, aE as ne, aC as se, av as Vt, aB as oe, au as ht, aF as ie, aG as Ft, aH as ae, aI as re, c as $t, aJ as le, aK as he, aL as ce, aM as de, a4 as jt, a0 as qt, a6 as ft, a1 as Ut, a2 as Ht, a5 as fe, a8 as ge, aN as Ot, aO as ue, aP as pe, aQ as ye, I as be, aR as Se, aS as me, aT as Q } from "./FontAnalyzer-EF3gLPr8.js";
2
- import { T as Bt, a as Te, u as ve, K as we, z as kt, L as Yt, M as Ce, N as Me, O as xe } from "./ExportManager-BTcyj4cf.js";
3
- import { i as Lt, a as Re } from "./guards-DIX8aXWM.js";
4
- const it = {
1
+ import { X as oe, Y as ie, au as nt, Z as Ft, aH as ae, aF as re, ay as Ot, aE as le, ax as gt, aI as he, aJ as Yt, aK as ce, aL as de, c as Zt, aM as fe, aN as ge, aO as ue, aP as pe, a4 as Jt, a0 as Qt, a8 as pt, a1 as te, a2 as Lt, a9 as Gt, a7 as Pt, aa as Xt, a5 as ye, ab as be, aQ as Nt, aR as Se, aS as me, aT as Te, I as we, aU as ve, aV as Me, aW as tt } from "./FontAnalyzer-D4Sg-P6_.js";
2
+ import { T as Wt, a as xe, u as Ce, K as Re, z as At, L as Kt, M as ke, N as Pe, O as Ae } from "./ExportManager-B8Td7uR5.js";
3
+ import { i as Dt, a as Ee } from "./guards-uQtEQJbs.js";
4
+ const ct = {
5
5
  // Canvas-specific
6
6
  canvas: {
7
7
  snapThreshold: 8,
@@ -15,30 +15,30 @@ const it = {
15
15
  spacingLabelFontSize: 11,
16
16
  spacingLabelFontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
17
17
  }
18
- }, ke = 2, Mt = 6, Pe = 16, Ae = 5, Ee = 5, Zt = 0.5;
19
- function Gt(M) {
20
- return ke / M;
18
+ }, He = 2, Rt = 6, Ie = 16, Be = 5, Le = 5, ee = 0.5;
19
+ function $t(v) {
20
+ return He / v;
21
21
  }
22
- function Fe(M) {
23
- return Mt / M;
22
+ function qe(v) {
23
+ return Rt / v;
24
24
  }
25
- function Ie(M) {
26
- return Pe / M;
25
+ function We(v) {
26
+ return Ie / v;
27
27
  }
28
- function Oe(M) {
29
- return [Ae / M, Ee / M];
28
+ function Ue(v) {
29
+ return [Be / v, Le / v];
30
30
  }
31
- function He(M, t, e, o) {
32
- M.save();
33
- const n = Zt / o;
34
- M.translate(t, e), M.scale(n, n), M.strokeStyle = "#000", M.lineWidth = 1.5, M.lineCap = "round", M.lineJoin = "round", M.translate(-12, -12), M.beginPath(), M.moveTo(21, 12), M.arc(12, 12, 9, 0, -Math.PI / 2, !0), M.bezierCurveTo(3.5, 4.5, 4, 6, 3, 8), M.stroke(), M.beginPath(), M.moveTo(3, 3), M.lineTo(3, 8), M.lineTo(8, 8), M.stroke(), M.beginPath(), M.moveTo(3, 12), M.arc(12, 12, 9, Math.PI, Math.PI / 2, !0), M.bezierCurveTo(20.5, 19.5, 20, 18, 21, 16), M.stroke(), M.beginPath(), M.moveTo(16, 16), M.lineTo(21, 16), M.lineTo(21, 21), M.stroke(), M.restore();
31
+ function De(v, t, e, o) {
32
+ v.save();
33
+ const n = ee / o;
34
+ v.translate(t, e), v.scale(n, n), v.strokeStyle = "#000", v.lineWidth = 1.5, v.lineCap = "round", v.lineJoin = "round", v.translate(-12, -12), v.beginPath(), v.moveTo(21, 12), v.arc(12, 12, 9, 0, -Math.PI / 2, !0), v.bezierCurveTo(3.5, 4.5, 4, 6, 3, 8), v.stroke(), v.beginPath(), v.moveTo(3, 3), v.lineTo(3, 8), v.lineTo(8, 8), v.stroke(), v.beginPath(), v.moveTo(3, 12), v.arc(12, 12, 9, Math.PI, Math.PI / 2, !0), v.bezierCurveTo(20.5, 19.5, 20, 18, 21, 16), v.stroke(), v.beginPath(), v.moveTo(16, 16), v.lineTo(21, 16), v.lineTo(21, 21), v.stroke(), v.restore();
35
35
  }
36
- function Ye(M, t, e, o = 1, n = "#3b82f6", s = !1) {
37
- const i = Ie(o);
38
- M.save(), M.fillStyle = "#fff", M.strokeStyle = n, M.lineWidth = s ? Gt(o) * 1.25 : Gt(o), M.beginPath(), M.arc(t, e, i, 0, Math.PI * 2), M.fill(), M.stroke(), He(M, t, e, o), M.restore();
36
+ function Ze(v, t, e, o = 1, n = "#3b82f6", s = !1) {
37
+ const i = We(o);
38
+ v.save(), v.fillStyle = "#fff", v.strokeStyle = n, v.lineWidth = s ? $t(o) * 1.25 : $t(o), v.beginPath(), v.arc(t, e, i, 0, Math.PI * 2), v.fill(), v.stroke(), De(v, t, e, o), v.restore();
39
39
  }
40
- const Xt = Mt * 2;
41
- class Ge {
40
+ const jt = Rt * 2;
41
+ class Je {
42
42
  constructor() {
43
43
  this.resizeHandles = [], this.rotationHandle = null, this.elementRotation = 0, this.rotationAnchor = { x: 0, y: 0 };
44
44
  }
@@ -50,13 +50,13 @@ class Ge {
50
50
  update(t, e = 1) {
51
51
  const n = "isCropping" in t && t.isCropping ? t.getBoundingBox() : t.getVisualBoundingBox(), s = t.getRotationAnchor(), i = t.getEnabledAnchors();
52
52
  this.elementRotation = t.rotation, this.rotationAnchor = s;
53
- const a = it.canvas.selectionPadding, r = {
53
+ const a = ct.canvas.selectionPadding, r = {
54
54
  x: n.x - a,
55
55
  y: n.y - a,
56
56
  width: n.width + a * 2,
57
57
  height: n.height + a * 2
58
- }, l = te(r, t.rotation, s), h = Math.abs(t.rotation % 360) > 0.1;
59
- this.resizeHandles = l.filter((c) => !(!i.includes(c.anchor) || h && c.anchor.includes("middle"))), this.rotationHandle = ee(
58
+ }, l = oe(r, t.rotation, s), h = Math.abs(t.rotation % 360) > 0.1;
59
+ this.resizeHandles = l.filter((c) => !(!i.includes(c.anchor) || h && c.anchor.includes("middle"))), this.rotationHandle = ie(
60
60
  r,
61
61
  t.rotation,
62
62
  s,
@@ -71,8 +71,8 @@ class Ge {
71
71
  this.resizeHandles.forEach((c) => {
72
72
  if (a && r && c.anchor !== r.anchor)
73
73
  return;
74
- const d = !!(i && i.anchor === c.anchor), u = !!(a && r && r.anchor === c.anchor);
75
- this.renderResizeHandle(t, c, d, u, l);
74
+ const d = !!(i && i.anchor === c.anchor), f = !!(a && r && r.anchor === c.anchor);
75
+ this.renderResizeHandle(t, c, d, f, l);
76
76
  }), h && e && this.rotationHandle && !n && !a && this.renderRotationHandle(t, this.rotationHandle, s, l), h && e && this.rotationHandle && n && this.renderRotationTooltip(t, this.rotationHandle, o, l);
77
77
  }
78
78
  /**
@@ -85,10 +85,10 @@ class Ge {
85
85
  if (e.anchor.includes("middle")) {
86
86
  const l = e.anchor === "middle-top" || e.anchor === "middle-bottom";
87
87
  t.translate(i, a), t.rotate(-this.elementRotation * Math.PI / 180), l && t.rotate(Math.PI / 2), t.translate(-i, -a);
88
- const h = Xt * 0.6, c = Xt * 1.4, d = h / 2, u = i - h / 2, p = a - c / 2;
89
- t.fillStyle = "#fff", t.strokeStyle = tt(t.canvas), t.lineWidth = o || n ? 2.5 : 2, t.beginPath(), t.roundRect(u, p, h, c, d), t.fill(), t.stroke();
88
+ const h = jt * 0.6, c = jt * 1.4, d = h / 2, f = i - h / 2, b = a - c / 2;
89
+ t.fillStyle = "#fff", t.strokeStyle = nt(t.canvas), t.lineWidth = o || n ? 2.5 : 2, t.beginPath(), t.roundRect(f, b, h, c, d), t.fill(), t.stroke();
90
90
  } else
91
- t.fillStyle = "#fff", t.strokeStyle = tt(t.canvas), t.lineWidth = o || n ? 2.5 : 2, t.beginPath(), t.arc(i, a, Mt, 0, Math.PI * 2), t.fill(), t.stroke();
91
+ t.fillStyle = "#fff", t.strokeStyle = nt(t.canvas), t.lineWidth = o || n ? 2.5 : 2, t.beginPath(), t.arc(i, a, Rt, 0, Math.PI * 2), t.fill(), t.stroke();
92
92
  t.restore();
93
93
  }
94
94
  /**
@@ -97,9 +97,9 @@ class Ge {
97
97
  */
98
98
  renderRotationHandle(t, e, o = !1, n = 1) {
99
99
  t.save();
100
- const s = e.x * n, i = e.y * n, a = Mt * 2.67;
101
- t.fillStyle = "#fff", t.strokeStyle = tt(t.canvas), t.lineWidth = o ? 2.5 : 2, t.beginPath(), t.arc(s, i, a, 0, Math.PI * 2), t.fill(), t.stroke();
102
- const r = Zt;
100
+ const s = e.x * n, i = e.y * n, a = Rt * 2.67;
101
+ t.fillStyle = "#fff", t.strokeStyle = nt(t.canvas), t.lineWidth = o ? 2.5 : 2, t.beginPath(), t.arc(s, i, a, 0, Math.PI * 2), t.fill(), t.stroke();
102
+ const r = ee;
103
103
  t.translate(s, i), t.scale(r, r), t.strokeStyle = "#000", t.lineWidth = 1.5, t.lineCap = "round", t.lineJoin = "round", t.translate(-12, -12), t.beginPath(), t.moveTo(21, 12), t.arc(12, 12, 9, 0, -Math.PI / 2, !0), t.bezierCurveTo(3.5, 4.5, 4, 6, 3, 8), t.stroke(), t.beginPath(), t.moveTo(3, 3), t.lineTo(3, 8), t.lineTo(8, 8), t.stroke(), t.beginPath(), t.moveTo(3, 12), t.arc(12, 12, 9, Math.PI, Math.PI / 2, !0), t.bezierCurveTo(20.5, 19.5, 20, 18, 21, 16), t.stroke(), t.beginPath(), t.moveTo(16, 16), t.lineTo(21, 16), t.lineTo(21, 21), t.stroke(), t.restore();
104
104
  }
105
105
  /**
@@ -115,9 +115,9 @@ class Ge {
115
115
  * @param zoom - Current zoom level (radius scales inversely with zoom)
116
116
  */
117
117
  hitTestResize(t, e, o = 1) {
118
- const n = se / o;
118
+ const n = re / o;
119
119
  for (const s of this.resizeHandles)
120
- if (zt(t, e, s.x, s.y, n))
120
+ if (Ft(t, e, s.x, s.y, n))
121
121
  return s;
122
122
  return null;
123
123
  }
@@ -127,8 +127,8 @@ class Ge {
127
127
  */
128
128
  hitTestRotation(t, e, o = 1) {
129
129
  if (!this.rotationHandle) return !1;
130
- const n = (Mt * 2.67 + 2) / o;
131
- return zt(t, e, this.rotationHandle.x, this.rotationHandle.y, n);
130
+ const n = (Rt * 2.67 + 2) / o;
131
+ return Ft(t, e, this.rotationHandle.x, this.rotationHandle.y, n);
132
132
  }
133
133
  /**
134
134
  * Get rotation handle position (for React-based rendering)
@@ -143,7 +143,7 @@ class Ge {
143
143
  */
144
144
  getCursor(t, e) {
145
145
  const o = t.anchor.includes("middle") ? "edge" : "corner";
146
- return ne(
146
+ return ae(
147
147
  t.x,
148
148
  t.y,
149
149
  this.rotationAnchor.x,
@@ -154,7 +154,33 @@ class Ge {
154
154
  );
155
155
  }
156
156
  }
157
- class Be {
157
+ const _e = 15;
158
+ function ze(v, t) {
159
+ return Math.abs(v) >= Math.abs(t) ? "x" : "y";
160
+ }
161
+ function Ve(v, t, e) {
162
+ return e != null && e.shift ? ze(v, t) === "x" ? { dx: v, dy: 0, lockedAxis: "y" } : { dx: 0, dy: t, lockedAxis: "x" } : { dx: v, dy: t, lockedAxis: null };
163
+ }
164
+ function Fe(v, t = _e) {
165
+ let o = (Math.round(v / t) * t % 360 + 360) % 360;
166
+ return o > 180 && (o -= 360), o === 0 ? 0 : o;
167
+ }
168
+ function Oe({
169
+ anchor: v,
170
+ startVisualWidth: t,
171
+ startVisualHeight: e,
172
+ newVisualWidth: o,
173
+ newVisualHeight: n
174
+ }) {
175
+ const s = t !== 0 ? t : 1, i = e !== 0 ? e : 1, a = o / s, r = n / i;
176
+ let l;
177
+ return v === "middle-left" || v === "middle-right" ? l = a : v === "middle-top" || v === "middle-bottom" ? l = r : l = Math.abs(a - 1) >= Math.abs(r - 1) ? a : r, {
178
+ scale: l,
179
+ newVisualWidth: t * l,
180
+ newVisualHeight: e * l
181
+ };
182
+ }
183
+ class Ye {
158
184
  /**
159
185
  * Calculate new dimensions and position for a resize operation
160
186
  */
@@ -164,64 +190,79 @@ class Be {
164
190
  dx: o,
165
191
  dy: n,
166
192
  startData: s,
167
- snapSystem: i
193
+ snapSystem: i,
194
+ modifiers: a
168
195
  }) {
169
- var B, L, W, O, D;
170
- const r = new Vt(t).worldDeltaToLocal(o, n), l = r.dx, h = r.dy, c = s.visualWidth ?? s.width ?? 0, d = s.visualHeight ?? s.height ?? 0, u = s.width ?? 0, p = s.height ?? 0;
171
- let b = c, g = d;
172
- e.anchor.includes("right") ? b = c + l : e.anchor.includes("left") && (b = c - l), e.anchor !== "middle-left" && e.anchor !== "middle-right" && (e.anchor.includes("bottom") ? g = d + h : e.anchor.includes("top") && (g = d - h));
173
- let f, y;
174
- if (e.anchor === "middle-left" || e.anchor === "middle-right") {
175
- const F = b - c;
176
- f = u + F, y = p;
196
+ var F, W, q, J, E;
197
+ const l = new Ot(t).worldDeltaToLocal(o, n), h = l.dx, c = l.dy, d = s.visualWidth ?? s.width ?? 0, f = s.visualHeight ?? s.height ?? 0, b = s.width ?? 0, u = s.height ?? 0;
198
+ let p = d, g = f;
199
+ e.anchor.includes("right") ? p = d + h : e.anchor.includes("left") && (p = d - h), e.anchor !== "middle-left" && e.anchor !== "middle-right" && (e.anchor.includes("bottom") ? g = f + c : e.anchor.includes("top") && (g = f - c));
200
+ const y = (a == null ? void 0 : a.shift) === !0;
201
+ let S = null;
202
+ if (y) {
203
+ const z = Oe({
204
+ anchor: e.anchor,
205
+ startVisualWidth: d,
206
+ startVisualHeight: f,
207
+ newVisualWidth: p,
208
+ newVisualHeight: g
209
+ });
210
+ S = z.scale, p = z.newVisualWidth, g = z.newVisualHeight;
211
+ }
212
+ let m, w;
213
+ if (S !== null)
214
+ m = b * S, w = u * S;
215
+ else if (e.anchor === "middle-left" || e.anchor === "middle-right") {
216
+ const z = p - d;
217
+ m = b + z, w = u;
177
218
  } else if (e.anchor === "middle-top" || e.anchor === "middle-bottom") {
178
- const F = g - d;
179
- f = u, y = p + F;
219
+ const z = g - f;
220
+ m = b, w = u + z;
180
221
  } else {
181
- const F = b / c, E = g / d;
182
- f = u * F, y = p * E;
222
+ const z = p / d, N = g / f;
223
+ m = b * z, w = u * N;
183
224
  }
184
- const m = b, T = g;
185
- let v = !1;
225
+ const T = p, C = g;
226
+ let R = !1;
186
227
  if (i && t.transformType === "image") {
187
- const F = e.anchor ?? "", E = F === "top-left" || F === "top-right" || F === "bottom-left" || F === "bottom-right", $ = F.startsWith("crop-");
188
- if (E && !$) {
189
- const j = (B = i.activeSnaps) == null ? void 0 : B.x, J = (L = i.activeSnaps) == null ? void 0 : L.y;
190
- if (!!j || !!J) {
191
- const k = [j, J].find(
192
- (I) => typeof I == "object" && I !== null && "frozenWidth" in I
228
+ const z = e.anchor ?? "", N = z === "top-left" || z === "top-right" || z === "bottom-left" || z === "bottom-right", Q = z.startsWith("crop-");
229
+ if (N && !Q) {
230
+ const B = (F = i.activeSnaps) == null ? void 0 : F.x, k = (W = i.activeSnaps) == null ? void 0 : W.y;
231
+ if (!!B || !!k) {
232
+ const G = [B, k].find(
233
+ (P) => typeof P == "object" && P !== null && "frozenWidth" in P
193
234
  );
194
- if (k) {
195
- const I = t, _ = s.transformData, H = k.frozenWidth ?? ((W = I.transformData) == null ? void 0 : W.width) ?? u, V = I.imageAspectRatio || (_ != null && _.width && (_ != null && _.height) ? _.width / _.height : null);
196
- let Y = k.frozenHeight;
197
- Y == null && (V && V !== 0 ? Y = H / V : (O = I.transformData) != null && O.height ? Y = I.transformData.height : Y = p);
198
- const at = u !== 0 ? H / u : 1, gt = p !== 0 ? Y / p : 1;
199
- b = c * at, g = d * gt, f = H, y = Y, v = !0;
235
+ if (G) {
236
+ const P = t, _ = s.transformData, j = G.frozenWidth ?? ((q = P.transformData) == null ? void 0 : q.width) ?? b, ot = P.imageAspectRatio || (_ != null && _.width && (_ != null && _.height) ? _.width / _.height : null);
237
+ let et = G.frozenHeight;
238
+ et == null && (ot && ot !== 0 ? et = j / ot : (J = P.transformData) != null && J.height ? et = P.transformData.height : et = u);
239
+ const lt = b !== 0 ? j / b : 1, Y = u !== 0 ? et / u : 1;
240
+ p = d * lt, g = f * Y, m = j, w = et, R = !0;
200
241
  }
201
242
  }
202
243
  }
203
244
  }
204
- f = Math.max(50, f), y = Math.max(40, y);
205
- const S = t.clone(), C = S.resize(e.anchor, f, y, s);
206
- if (!e.anchor.includes("middle") && ((D = S.stroke) != null && D.enabled) && s.strokeWidth !== void 0 && s.strokeWidth > 0) {
207
- const F = s.width ?? 1, E = s.height ?? 1, $ = Math.sqrt(f / F * (y / E)), j = Math.max(1, Math.round(s.strokeWidth * $ * 10) / 10);
208
- S.stroke = { ...S.stroke, width: j };
245
+ m = Math.max(50, m), w = Math.max(40, w);
246
+ const x = t.clone(), H = x.resize(e.anchor, m, w, s);
247
+ if (!e.anchor.includes("middle") && ((E = x.stroke) != null && E.enabled) && s.strokeWidth !== void 0 && s.strokeWidth > 0) {
248
+ const z = s.width ?? 1, N = s.height ?? 1, Q = Math.sqrt(m / z * (w / N)), B = Math.max(1, Math.round(s.strokeWidth * Q * 10) / 10);
249
+ x.stroke = { ...x.stroke, width: B };
209
250
  }
210
- const x = v || C === !1, P = e.anchor.includes("top") || e.anchor.includes("bottom"), w = "isCropping" in S && S.isCropping, A = "isGroup" in S && S.isGroup;
211
- if (P && !w && !A) {
212
- const F = t.getRotationAnchor(), E = this._calculateFixedCornerOffset({
251
+ const A = R || H === !1, I = e.anchor.includes("top") || e.anchor.includes("bottom"), L = "isCropping" in x && x.isCropping, D = "isGroup" in x && x.isGroup;
252
+ if (I && !L && !D) {
253
+ const z = t.getRotationAnchor(), N = this._calculateFixedCornerOffset({
213
254
  element: t,
214
- updatedElement: S,
255
+ updatedElement: x,
215
256
  handle: e,
216
- rotationAnchor: F
257
+ rotationAnchor: z
217
258
  });
218
- S.x += E.x, S.y += E.y;
259
+ x.x += N.x, x.y += N.y;
219
260
  }
220
261
  return {
221
- element: S,
222
- isFrozen: x,
262
+ element: x,
263
+ isFrozen: A,
223
264
  // For snap system to detect break-free: dimensions before freeze was applied
224
- unfrozenDimensions: v ? { width: m, height: T } : void 0
265
+ unfrozenDimensions: R ? { width: T, height: C } : void 0
225
266
  };
226
267
  }
227
268
  /**
@@ -235,10 +276,10 @@ class Be {
235
276
  handle: o,
236
277
  rotationAnchor: n
237
278
  }) {
238
- const s = new Vt(t), { cos: i, sin: a } = s.getRenderingCosSin(), r = t.getVisualBoundingBox(), l = e.getVisualBoundingBox(), h = n, c = e.getRotationAnchor(), d = this._getFixedLocalCoords(o.anchor, r.width, r.height), u = d.x, p = d.y, b = r.x - h.x, g = r.y - h.y, f = b + u, y = g + p, m = f * i - y * a, T = f * a + y * i, v = h.x + m, S = h.y + T, C = this._getFixedLocalCoords(o.anchor, l.width, l.height), R = C.x, x = C.y, P = l.x - c.x, w = l.y - c.y, A = P + R, B = w + x, L = A * i - B * a, W = A * a + B * i, O = c.x + L, D = c.y + W;
279
+ const s = new Ot(t), { cos: i, sin: a } = s.getRenderingCosSin(), r = t.getVisualBoundingBox(), l = e.getVisualBoundingBox(), h = n, c = e.getRotationAnchor(), d = this._getFixedLocalCoords(o.anchor, r.width, r.height), f = d.x, b = d.y, u = r.x - h.x, p = r.y - h.y, g = u + f, y = p + b, S = g * i - y * a, m = g * a + y * i, w = h.x + S, T = h.y + m, C = this._getFixedLocalCoords(o.anchor, l.width, l.height), R = C.x, x = C.y, H = l.x - c.x, M = l.y - c.y, A = H + R, I = M + x, L = A * i - I * a, D = A * a + I * i, F = c.x + L, W = c.y + D;
239
280
  return {
240
- x: v - O,
241
- y: S - D
281
+ x: w - F,
282
+ y: T - W
242
283
  };
243
284
  }
244
285
  /**
@@ -276,7 +317,7 @@ class Be {
276
317
  return n;
277
318
  }
278
319
  }
279
- class Le {
320
+ class Ge {
280
321
  constructor() {
281
322
  this.hooks = {
282
323
  beforeResize: [],
@@ -331,9 +372,10 @@ class Le {
331
372
  */
332
373
  executeResize(t) {
333
374
  const e = this.runHooks("beforeResize", t);
334
- let o = Be.calculateResize({
375
+ let o = Ye.calculateResize({
335
376
  ...e,
336
- snapSystem: t.snapSystem
377
+ snapSystem: t.snapSystem,
378
+ modifiers: t.modifiers
337
379
  });
338
380
  return o.handle = t.handle, o.startData = t.startData, o = this.runHooks("afterResize", o), o;
339
381
  }
@@ -346,8 +388,8 @@ class Le {
346
388
  return this.runHooks("afterPositionUpdate", o).position;
347
389
  }
348
390
  }
349
- const Xe = new Le();
350
- class Ne {
391
+ const Qe = new Ge();
392
+ class tn {
351
393
  constructor(t = null) {
352
394
  this.state = "IDLE", this.context = {
353
395
  mode: null,
@@ -431,17 +473,24 @@ class Ne {
431
473
  /**
432
474
  * Update drag operation
433
475
  * Returns updated position { x, y }
434
- */
435
- updateDrag(t, e, o = null) {
476
+ *
477
+ * `modifiers.shift` axis-locks the drag to the dominant axis
478
+ * (re-evaluated each move). Alignment snapping still runs on the
479
+ * free axis; on the locked axis the position is clamped back to the
480
+ * gesture-start value AFTER snapping, so a snap can never move the
481
+ * element off the locked axis. Read modifiers from the CURRENT
482
+ * pointer event — users press/release Shift mid-gesture.
483
+ */
484
+ updateDrag(t, e, o = null, n) {
436
485
  if (this.state !== "DRAGGING")
437
486
  throw new Error("Cannot update drag: not in DRAGGING state");
438
- const n = t - this.context.startX, s = e - this.context.startY, i = this.context.startData;
439
- let a = i.x + n, r = i.y + s;
487
+ const s = t - this.context.startX, i = e - this.context.startY, { dx: a, dy: r, lockedAxis: l } = Ve(s, i, n), h = this.context.startData;
488
+ let c = h.x + a, d = h.y + r;
440
489
  if (this.snapHandler && this.snapHandler.snapPosition && this.context.element) {
441
- const l = this.snapHandler.snapPosition({ x: a, y: r }, this.context.element, o);
442
- a = l.x, r = l.y;
490
+ const f = this.snapHandler.snapPosition({ x: c, y: d }, this.context.element, o);
491
+ c = f.x, d = f.y;
443
492
  }
444
- return { x: a, y: r };
493
+ return l === "x" ? c = h.x : l === "y" && (d = h.y), { x: c, y: d };
445
494
  }
446
495
  /**
447
496
  * Start resize operation
@@ -541,13 +590,19 @@ class Ne {
541
590
  /**
542
591
  * Update rotation operation
543
592
  * Returns updated rotation angle in degrees
593
+ *
594
+ * `modifiers.shift` snaps the result to 15° increments in stored
595
+ * (user-facing, sign-flipped — gotcha #15) degrees. The shift snap
596
+ * REPLACES the snapHandler's rotation snap while held: the 15° grid
597
+ * is a superset of the usual 0/90/180 magnets and must win
598
+ * deterministically. Read modifiers from the CURRENT pointer event.
544
599
  */
545
- updateRotate(t, e, o, n) {
600
+ updateRotate(t, e, o, n, s) {
546
601
  if (this.state !== "ROTATING")
547
602
  throw new Error("Cannot update rotate: not in ROTATING state");
548
- const s = this.context.startData, a = (oe(o, n, t, e) - s.startAngle) * 180 / Math.PI;
549
- let r = s.currentRotation - a;
550
- return r = (r % 360 + 360) % 360, r > 180 && (r -= 360), this.snapHandler && this.snapHandler.snapRotation && this.context.element ? this.snapHandler.snapRotation(r, this.context.element) : r;
603
+ const i = this.context.startData, r = (le(o, n, t, e) - i.startAngle) * 180 / Math.PI;
604
+ let l = i.currentRotation - r;
605
+ return l = (l % 360 + 360) % 360, l > 180 && (l -= 360), s != null && s.shift ? Fe(l) : this.snapHandler && this.snapHandler.snapRotation && this.context.element ? this.snapHandler.snapRotation(l, this.context.element) : l;
551
606
  }
552
607
  /**
553
608
  * Get rotation context
@@ -661,7 +716,7 @@ class Ne {
661
716
  return this.context.mode;
662
717
  }
663
718
  }
664
- class bt {
719
+ class mt {
665
720
  /**
666
721
  * Resolve rotation anchor with clear precedence:
667
722
  * 1. Transform's getRotationAnchor() if overridden
@@ -698,7 +753,7 @@ class bt {
698
753
  rotation: this.resolve(t)
699
754
  };
700
755
  if (t.rotation !== 0) {
701
- const n = o.rotation, s = ht.toRadiansInverse(t.rotation);
756
+ const n = o.rotation, s = gt.toRadiansInverse(t.rotation);
702
757
  Object.keys(o).forEach((i) => {
703
758
  if (i === "rotation") return;
704
759
  const a = o[i], r = a.x - n.x, l = a.y - n.y, h = r * Math.cos(s) - l * Math.sin(s), c = r * Math.sin(s) + l * Math.cos(s);
@@ -769,7 +824,7 @@ class bt {
769
824
  return Math.abs(n.x - o.x) > s || Math.abs(n.y - o.y) > s;
770
825
  }
771
826
  }
772
- class Nt {
827
+ class qt {
773
828
  constructor(t) {
774
829
  this.cellSize = t, this.cells = /* @__PURE__ */ new Map(), this.idIndex = /* @__PURE__ */ new Map();
775
830
  }
@@ -811,12 +866,12 @@ class Nt {
811
866
  const s = [], i = Math.floor((t - o) / this.cellSize), a = Math.floor((t + o) / this.cellSize), r = Math.floor((e - o) / this.cellSize), l = Math.floor((e + o) / this.cellSize);
812
867
  for (let h = i; h <= a; h++)
813
868
  for (let c = r; c <= l; c++) {
814
- const d = `${h},${c}`, u = this.cells.get(d);
815
- if (u)
816
- for (const p of u) {
817
- if (n !== void 0 && p.id === n) continue;
818
- const b = p.x - t, g = p.y - e;
819
- b * b + g * g <= o * o && s.push(p);
869
+ const d = `${h},${c}`, f = this.cells.get(d);
870
+ if (f)
871
+ for (const b of f) {
872
+ if (n !== void 0 && b.id === n) continue;
873
+ const u = b.x - t, p = b.y - e;
874
+ u * u + p * p <= o * o && s.push(b);
820
875
  }
821
876
  }
822
877
  return s;
@@ -865,32 +920,32 @@ class Nt {
865
920
  return `${Math.floor(t / this.cellSize)},${Math.floor(e / this.cellSize)}`;
866
921
  }
867
922
  }
868
- function lt(M) {
869
- const t = M.transformData;
923
+ function ft(v) {
924
+ const t = v.transformData;
870
925
  if (t && "width" in t && typeof t.width == "number")
871
926
  return t.width;
872
927
  }
873
- function St(M) {
874
- const t = M.transformData;
928
+ function Tt(v) {
929
+ const t = v.transformData;
875
930
  if (t && "height" in t && typeof t.height == "number")
876
931
  return t.height;
877
932
  }
878
- function wt(M, t) {
879
- const e = M.transformData;
933
+ function xt(v, t) {
934
+ const e = v.transformData;
880
935
  return e && "width" in e ? (e.width = t, !0) : !1;
881
936
  }
882
- function Pt(M, t) {
883
- const e = M.transformData;
937
+ function Et(v, t) {
938
+ const e = v.transformData;
884
939
  return e && "height" in e ? (e.height = t, !0) : !1;
885
940
  }
886
- class Ke {
941
+ class en {
887
942
  constructor(t = {}) {
888
- this._extraSnapRects = [], this.snapThreshold = t.snapThreshold || it.canvas.snapThreshold, this.enabled = t.enabled !== !1, this.showGuides = t.showGuides !== !1, this.guides = [], this.activeSnaps = {
943
+ this._extraSnapRects = [], this.snapThreshold = t.snapThreshold || ct.canvas.snapThreshold, this.enabled = t.enabled !== !1, this.showGuides = t.showGuides !== !1, this.guides = [], this.activeSnaps = {
889
944
  x: null,
890
945
  // { snapTo: number, anchorKey: string, frozenFontSize: number, frozenWidth: number, frozenPosition: {x, y}, isPositionBasedSnap: boolean }
891
946
  y: null
892
947
  // { snapTo: number, anchorKey: string, frozenFontSize: number, frozenWidth: number, frozenPosition: {x, y}, isPositionBasedSnap: boolean }
893
- }, this.stickyThreshold = t.stickyThreshold || 15, this._spatialGrid = new Nt(Math.max(this.snapThreshold * 2, 16)), this._anchorMetadata = /* @__PURE__ */ new Map();
948
+ }, this.stickyThreshold = t.stickyThreshold || 15, this._spatialGrid = new qt(Math.max(this.snapThreshold * 2, 16)), this._anchorMetadata = /* @__PURE__ */ new Map();
894
949
  }
895
950
  /**
896
951
  * Enable or disable snapping
@@ -902,7 +957,7 @@ class Ke {
902
957
  * Set snap threshold in pixels
903
958
  */
904
959
  setSnapThreshold(t) {
905
- this.snapThreshold = t, this._spatialGrid = new Nt(Math.max(t * 2, 16));
960
+ this.snapThreshold = t, this._spatialGrid = new qt(Math.max(t * 2, 16));
906
961
  }
907
962
  /**
908
963
  * Get current snap guides for rendering
@@ -941,7 +996,7 @@ class Ke {
941
996
  _populateSpatialGrid(t) {
942
997
  this._spatialGrid.clear(), this._anchorMetadata.clear();
943
998
  for (const e of t) {
944
- const o = bt.getSnapAnchors(e);
999
+ const o = mt.getSnapAnchors(e);
945
1000
  for (const [n, s] of Object.entries(o)) {
946
1001
  const i = `${e.id}:${n}`, a = {
947
1002
  x: s.x,
@@ -990,73 +1045,73 @@ class Ke {
990
1045
  return this.clearGuides(), t;
991
1046
  const n = e.clone();
992
1047
  n.x = t.x, n.y = t.y;
993
- const s = bt.getSnapAnchors(n), i = o.filter((y) => y.id !== e.id);
1048
+ const s = mt.getSnapAnchors(n), i = o.filter((y) => y.id !== e.id);
994
1049
  this._populateSpatialGrid(i);
995
1050
  let a = null, r = null, l = 1 / 0, h = 1 / 0;
996
- const c = [], d = [], u = [];
997
- for (const [y, m] of Object.entries(s)) {
998
- const T = this._spatialGrid.queryNearAxis("x", m.x, this.snapThreshold);
999
- for (const S of T) {
1000
- const C = this._anchorMetadata.get(S.id);
1051
+ const c = [], d = [], f = [];
1052
+ for (const [y, S] of Object.entries(s)) {
1053
+ const m = this._spatialGrid.queryNearAxis("x", S.x, this.snapThreshold);
1054
+ for (const T of m) {
1055
+ const C = this._anchorMetadata.get(T.id);
1001
1056
  if (!C) continue;
1002
- const R = C.point, x = C.anchorKey, P = Math.abs(m.x - R.x);
1003
- if (P < this.snapThreshold) {
1004
- const w = {
1057
+ const R = C.point, x = C.anchorKey, H = Math.abs(S.x - R.x);
1058
+ if (H < this.snapThreshold) {
1059
+ const M = {
1005
1060
  snapTo: R.x,
1006
- offset: m.x - t.x,
1061
+ offset: S.x - t.x,
1007
1062
  // How far anchor is from element position
1008
- distance: P,
1063
+ distance: H,
1009
1064
  guide: {
1010
1065
  type: "vertical",
1011
1066
  x: R.x,
1012
- y1: Math.min(m.y, R.y) - 50,
1013
- y2: Math.max(m.y, R.y) + 50,
1067
+ y1: Math.min(S.y, R.y) - 50,
1068
+ y2: Math.max(S.y, R.y) + 50,
1014
1069
  movingKey: y,
1015
1070
  otherKey: x
1016
1071
  }
1017
1072
  };
1018
- c.push(w), P < l && (l = P, a = w);
1073
+ c.push(M), H < l && (l = H, a = M);
1019
1074
  }
1020
1075
  }
1021
- const v = this._spatialGrid.queryNearAxis("y", m.y, this.snapThreshold);
1022
- for (const S of v) {
1023
- const C = this._anchorMetadata.get(S.id);
1076
+ const w = this._spatialGrid.queryNearAxis("y", S.y, this.snapThreshold);
1077
+ for (const T of w) {
1078
+ const C = this._anchorMetadata.get(T.id);
1024
1079
  if (!C) continue;
1025
- const R = C.point, x = C.anchorKey, P = Math.abs(m.y - R.y);
1026
- if (P < this.snapThreshold) {
1027
- const w = {
1080
+ const R = C.point, x = C.anchorKey, H = Math.abs(S.y - R.y);
1081
+ if (H < this.snapThreshold) {
1082
+ const M = {
1028
1083
  snapTo: R.y,
1029
- offset: m.y - t.y,
1030
- distance: P,
1084
+ offset: S.y - t.y,
1085
+ distance: H,
1031
1086
  guide: {
1032
1087
  type: "horizontal",
1033
1088
  y: R.y,
1034
- x1: Math.min(m.x, R.x) - 50,
1035
- x2: Math.max(m.x, R.x) + 50,
1089
+ x1: Math.min(S.x, R.x) - 50,
1090
+ x2: Math.max(S.x, R.x) + 50,
1036
1091
  movingKey: y,
1037
1092
  otherKey: x
1038
1093
  }
1039
1094
  };
1040
- d.push(w), P < h && (h = P, r = w);
1095
+ d.push(M), H < h && (h = H, r = M);
1041
1096
  }
1042
1097
  }
1043
1098
  }
1044
- let p = t.x, b = t.y;
1045
- a && (p = a.snapTo - a.offset), r && (b = r.snapTo - r.offset);
1046
- const g = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
1099
+ let b = t.x, u = t.y;
1100
+ a && (b = a.snapTo - a.offset), r && (u = r.snapTo - r.offset);
1101
+ const p = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map();
1047
1102
  for (const y of c) {
1048
- const m = g.get(y.snapTo);
1049
- (!m || y.distance < m.distance) && g.set(y.snapTo, y);
1103
+ const S = p.get(y.snapTo);
1104
+ (!S || y.distance < S.distance) && p.set(y.snapTo, y);
1050
1105
  }
1051
1106
  for (const y of d) {
1052
- const m = f.get(y.snapTo);
1053
- (!m || y.distance < m.distance) && f.set(y.snapTo, y);
1107
+ const S = g.get(y.snapTo);
1108
+ (!S || y.distance < S.distance) && g.set(y.snapTo, y);
1054
1109
  }
1110
+ for (const y of p.values())
1111
+ f.push(y.guide);
1055
1112
  for (const y of g.values())
1056
- u.push(y.guide);
1057
- for (const y of f.values())
1058
- u.push(y.guide);
1059
- return this.guides = u, { x: p, y: b };
1113
+ f.push(y.guide);
1114
+ return this.guides = f, { x: b, y: u };
1060
1115
  }
1061
1116
  /**
1062
1117
  * Calculate what the frozen font size should be at the snap point
@@ -1067,7 +1122,7 @@ class Ke {
1067
1122
  const i = n != null && n.anchor ? String(n.anchor) : "";
1068
1123
  if (!(n && (i.includes("top") || i.includes("bottom"))))
1069
1124
  return s.fontSize ?? 0;
1070
- const r = lt(t) ?? t.width ?? s.width;
1125
+ const r = ft(t) ?? t.width ?? s.width;
1071
1126
  let l = r;
1072
1127
  i.includes("right") && e !== 0 ? l = r + e : i.includes("left") && e !== 0 && (l = r - e);
1073
1128
  const h = l / s.width;
@@ -1079,7 +1134,7 @@ class Ke {
1079
1134
  * Used for text elements where height is derived, not settable
1080
1135
  */
1081
1136
  _isPositionBasedSnap(t, e) {
1082
- return e === "x" ? !1 : e === "y" ? !(St(t) !== void 0 || t.height !== void 0 && typeof t.height == "number") : !1;
1137
+ return e === "x" ? !1 : e === "y" ? !(Tt(t) !== void 0 || t.height !== void 0 && typeof t.height == "number") : !1;
1083
1138
  }
1084
1139
  /**
1085
1140
  * Determine which snap keys to use based on the resize handle
@@ -1107,9 +1162,9 @@ class Ke {
1107
1162
  for (const h of l) {
1108
1163
  const c = this._anchorMetadata.get(h.id);
1109
1164
  if (!c || !i.has(c.anchorKey)) continue;
1110
- const d = c.point, u = c.anchorKey, p = Math.abs(r.x - d.x);
1111
- p < this.snapThreshold && s.push({
1112
- distance: p,
1165
+ const d = c.point, f = c.anchorKey, b = Math.abs(r.x - d.x);
1166
+ b < this.snapThreshold && s.push({
1167
+ distance: b,
1113
1168
  snapTo: d.x,
1114
1169
  currentValue: r.x,
1115
1170
  guide: {
@@ -1118,7 +1173,7 @@ class Ke {
1118
1173
  y1: Math.min(r.y, d.y) - 50,
1119
1174
  y2: Math.max(r.y, d.y) + 50,
1120
1175
  movingKey: a,
1121
- otherKey: u
1176
+ otherKey: f
1122
1177
  }
1123
1178
  });
1124
1179
  }
@@ -1139,9 +1194,9 @@ class Ke {
1139
1194
  for (const h of l) {
1140
1195
  const c = this._anchorMetadata.get(h.id);
1141
1196
  if (!c || !i.has(c.anchorKey)) continue;
1142
- const d = c.point, u = c.anchorKey, p = Math.abs(r.y - d.y);
1143
- p < this.snapThreshold && s.push({
1144
- distance: p,
1197
+ const d = c.point, f = c.anchorKey, b = Math.abs(r.y - d.y);
1198
+ b < this.snapThreshold && s.push({
1199
+ distance: b,
1145
1200
  snapTo: d.y,
1146
1201
  currentValue: r.y,
1147
1202
  guide: {
@@ -1150,7 +1205,7 @@ class Ke {
1150
1205
  x1: Math.min(r.x, d.x) - 50,
1151
1206
  x2: Math.max(r.x, d.x) + 50,
1152
1207
  movingKey: a,
1153
- otherKey: u
1208
+ otherKey: f
1154
1209
  }
1155
1210
  });
1156
1211
  }
@@ -1190,7 +1245,7 @@ class Ke {
1190
1245
  for (const l of Object.values(o))
1191
1246
  Math.abs(l.x - t.snapTo) < 5 && (a = Math.min(a, l.y), r = Math.max(r, l.y));
1192
1247
  for (const l of n) {
1193
- const h = bt.getSnapAnchors(l);
1248
+ const h = mt.getSnapAnchors(l);
1194
1249
  for (const c of Object.values(h))
1195
1250
  Math.abs(c.x - t.snapTo) < 5 && (a = Math.min(a, c.y), r = Math.max(r, c.y));
1196
1251
  }
@@ -1212,7 +1267,7 @@ class Ke {
1212
1267
  for (const l of Object.values(o))
1213
1268
  Math.abs(l.y - t.snapTo) < 5 && (a = Math.min(a, l.x), r = Math.max(r, l.x));
1214
1269
  for (const l of n) {
1215
- const h = bt.getSnapAnchors(l);
1270
+ const h = mt.getSnapAnchors(l);
1216
1271
  for (const c of Object.values(h))
1217
1272
  Math.abs(c.y - t.snapTo) < 5 && (a = Math.min(a, c.x), r = Math.max(r, c.x));
1218
1273
  }
@@ -1259,7 +1314,7 @@ class Ke {
1259
1314
  * @returns {Object} { frozenWidth, frozenHeight } - Dimensions at snap point
1260
1315
  */
1261
1316
  _calculateFrozenDimensionsAtSnap(t, e, o, n, s) {
1262
- const i = lt(t) ?? t.width ?? 0, a = St(t) ?? t.height ?? 0;
1317
+ const i = ft(t) ?? t.width ?? 0, a = Tt(t) ?? t.height ?? 0;
1263
1318
  let r = i, l = a;
1264
1319
  const h = t.transformType === "image", c = h ? t.imageAspectRatio || (i && a ? i / a : null) : null, d = n.toLowerCase();
1265
1320
  return e === "x" ? d.includes("right") ? (r = i + o, h && c && (l = r / c)) : d.includes("left") && (r = i - o, h && c && (l = r / c)) : e === "y" && (d.includes("bottom") ? (l = a + o, h && c && (r = l * c)) : d.includes("top") && (l = a - o, h && c && (r = l * c))), { frozenWidth: r, frozenHeight: l };
@@ -1274,36 +1329,36 @@ class Ke {
1274
1329
  if (r) {
1275
1330
  const c = e[r.anchorKey];
1276
1331
  if (c) {
1277
- const d = t === "x" ? c.x : c.y, u = Math.abs(d - r.snapTo), p = this._getAdjustedStickyThreshold(t, n);
1278
- if (u < p) {
1332
+ const d = t === "x" ? c.x : c.y, f = Math.abs(d - r.snapTo), b = this._getAdjustedStickyThreshold(t, n);
1333
+ if (f < b) {
1279
1334
  if (l = r.snapTo - d, !(t === "y" && r.isPositionBasedSnap)) {
1280
- const g = this._calculateFrozenFontSizeAtSnap(
1335
+ const p = this._calculateFrozenFontSizeAtSnap(
1281
1336
  n,
1282
1337
  t === "x" ? l : 0,
1283
1338
  t === "y" ? l : 0,
1284
1339
  s,
1285
1340
  i
1286
1341
  );
1287
- g !== r.frozenFontSize && (r.frozenFontSize = g);
1342
+ p !== r.frozenFontSize && (r.frozenFontSize = p);
1288
1343
  }
1289
1344
  h = this._createGuideForSnap(r, r.anchorKey, e, a, t);
1290
1345
  } else {
1291
- const b = r;
1346
+ const u = r;
1292
1347
  if (this.activeSnaps[t] = null, o.length > 0 && o[0].distance < this.snapThreshold) {
1293
1348
  h = o[0], l = h.snapTo - h.currentValue;
1294
- const g = b && b.anchorKey === h.guide.movingKey && Math.abs(b.snapTo - h.snapTo) < 1, f = g ? b.frozenFontSize : this._calculateFrozenFontSizeAtSnap(
1349
+ const p = u && u.anchorKey === h.guide.movingKey && Math.abs(u.snapTo - h.snapTo) < 1, g = p ? u.frozenFontSize : this._calculateFrozenFontSizeAtSnap(
1295
1350
  n,
1296
1351
  t === "x" ? l : 0,
1297
1352
  t === "y" ? l : 0,
1298
1353
  s,
1299
1354
  i
1300
1355
  ), y = this._isPositionBasedSnap(n, t);
1301
- let m;
1302
- g ? m = b.frozenPosition : y ? m = {
1356
+ let S;
1357
+ p ? S = u.frozenPosition : y ? S = {
1303
1358
  x: t === "x" ? n.x + l : n.x,
1304
1359
  y: t === "y" ? n.y + l : n.y
1305
- } : m = { x: n.x, y: n.y };
1306
- const T = this._calculateFrozenDimensionsAtSnap(
1360
+ } : S = { x: n.x, y: n.y };
1361
+ const m = this._calculateFrozenDimensionsAtSnap(
1307
1362
  n,
1308
1363
  t,
1309
1364
  l,
@@ -1313,10 +1368,10 @@ class Ke {
1313
1368
  this.activeSnaps[t] = {
1314
1369
  snapTo: h.snapTo,
1315
1370
  anchorKey: h.guide.movingKey,
1316
- frozenFontSize: f,
1317
- frozenWidth: T.frozenWidth,
1318
- frozenHeight: T.frozenHeight,
1319
- frozenPosition: m,
1371
+ frozenFontSize: g,
1372
+ frozenWidth: m.frozenWidth,
1373
+ frozenHeight: m.frozenHeight,
1374
+ frozenPosition: S,
1320
1375
  isPositionBasedSnap: y
1321
1376
  };
1322
1377
  }
@@ -1325,19 +1380,19 @@ class Ke {
1325
1380
  this.activeSnaps[t] = null;
1326
1381
  } else if (o.length > 0 && o[0].distance < this.snapThreshold) {
1327
1382
  h = o[0], l = h.snapTo - h.currentValue;
1328
- const c = this.activeSnaps[t], d = c && c.anchorKey === h.guide.movingKey && Math.abs(c.snapTo - h.snapTo) < 1, u = d ? c.frozenFontSize : this._calculateFrozenFontSizeAtSnap(
1383
+ const c = this.activeSnaps[t], d = c && c.anchorKey === h.guide.movingKey && Math.abs(c.snapTo - h.snapTo) < 1, f = d ? c.frozenFontSize : this._calculateFrozenFontSizeAtSnap(
1329
1384
  n,
1330
1385
  t === "x" ? l : 0,
1331
1386
  t === "y" ? l : 0,
1332
1387
  s,
1333
1388
  i
1334
- ), p = this._isPositionBasedSnap(n, t);
1335
- let b;
1336
- d ? b = c.frozenPosition : p ? b = {
1389
+ ), b = this._isPositionBasedSnap(n, t);
1390
+ let u;
1391
+ d ? u = c.frozenPosition : b ? u = {
1337
1392
  x: t === "x" ? n.x + l : n.x,
1338
1393
  y: t === "y" ? n.y + l : n.y
1339
- } : b = { x: n.x, y: n.y };
1340
- const g = this._calculateFrozenDimensionsAtSnap(
1394
+ } : u = { x: n.x, y: n.y };
1395
+ const p = this._calculateFrozenDimensionsAtSnap(
1341
1396
  n,
1342
1397
  t,
1343
1398
  l,
@@ -1347,11 +1402,11 @@ class Ke {
1347
1402
  this.activeSnaps[t] = {
1348
1403
  snapTo: h.snapTo,
1349
1404
  anchorKey: h.guide.movingKey,
1350
- frozenFontSize: u,
1351
- frozenWidth: g.frozenWidth,
1352
- frozenHeight: g.frozenHeight,
1353
- frozenPosition: b,
1354
- isPositionBasedSnap: p
1405
+ frozenFontSize: f,
1406
+ frozenWidth: p.frozenWidth,
1407
+ frozenHeight: p.frozenHeight,
1408
+ frozenPosition: u,
1409
+ isPositionBasedSnap: b
1355
1410
  };
1356
1411
  }
1357
1412
  return { snapDelta: l, bestSnap: h };
@@ -1362,11 +1417,11 @@ class Ke {
1362
1417
  _adjustElementForRightResize(t, e, o) {
1363
1418
  const n = t.getVisualBoundingBox(), s = t.transformType === "image";
1364
1419
  if (!s) {
1365
- const i = lt(t);
1366
- i !== void 0 ? wt(t, i + e) : t.width !== void 0 && (t.width += e);
1420
+ const i = ft(t);
1421
+ i !== void 0 ? xt(t, i + e) : t.width !== void 0 && (t.width += e);
1367
1422
  }
1368
1423
  if (o.anchor === "middle-right") {
1369
- const i = ht.toRadiansInverse(t.rotation), a = Math.cos(i), r = Math.sin(i);
1424
+ const i = gt.toRadiansInverse(t.rotation), a = Math.cos(i), r = Math.sin(i);
1370
1425
  t.x += e / 2 * a, t.y += e / 2 * r;
1371
1426
  } else if (!s) {
1372
1427
  const a = t.getVisualBoundingBox().x - n.x;
@@ -1379,11 +1434,11 @@ class Ke {
1379
1434
  _adjustElementForLeftResize(t, e, o) {
1380
1435
  const n = t.getVisualBoundingBox(), s = t.transformType === "image";
1381
1436
  if (!s) {
1382
- const i = lt(t);
1383
- i !== void 0 ? wt(t, i - e) : t.width !== void 0 && (t.width -= e);
1437
+ const i = ft(t);
1438
+ i !== void 0 ? xt(t, i - e) : t.width !== void 0 && (t.width -= e);
1384
1439
  }
1385
1440
  if (o.anchor === "middle-left") {
1386
- const i = ht.toRadiansInverse(t.rotation), a = Math.cos(i), r = Math.sin(i);
1441
+ const i = gt.toRadiansInverse(t.rotation), a = Math.cos(i), r = Math.sin(i);
1387
1442
  t.x += e / 2 * a, t.y += e / 2 * r;
1388
1443
  } else if (t.x += e, !s) {
1389
1444
  const i = t.getVisualBoundingBox(), a = i.x + i.width - (n.x + n.width);
@@ -1396,12 +1451,12 @@ class Ke {
1396
1451
  _adjustElementForBottomResize(t, e, o) {
1397
1452
  const n = t.getVisualBoundingBox(), s = t.transformType === "image";
1398
1453
  if (!s) {
1399
- const r = St(t);
1400
- r !== void 0 ? Pt(t, r + e) : t.height !== void 0 && (t.height += e);
1454
+ const r = Tt(t);
1455
+ r !== void 0 ? Et(t, r + e) : t.height !== void 0 && (t.height += e);
1401
1456
  }
1402
1457
  const i = t.getVisualBoundingBox(), a = Math.abs(i.height - n.height) > 0.01;
1403
1458
  if (o.anchor === "middle-bottom") {
1404
- const r = ht.toRadiansInverse(t.rotation), l = Math.cos(r), h = Math.sin(r);
1459
+ const r = gt.toRadiansInverse(t.rotation), l = Math.cos(r), h = Math.sin(r);
1405
1460
  t.x -= e / 2 * h, t.y += e / 2 * l;
1406
1461
  } else if (!s && a) {
1407
1462
  const r = i.y - n.y;
@@ -1414,12 +1469,12 @@ class Ke {
1414
1469
  _adjustElementForTopResize(t, e, o) {
1415
1470
  const n = t.getVisualBoundingBox(), s = t.transformType === "image";
1416
1471
  if (!s) {
1417
- const r = St(t);
1418
- r !== void 0 ? Pt(t, r - e) : t.height !== void 0 && (t.height -= e);
1472
+ const r = Tt(t);
1473
+ r !== void 0 ? Et(t, r - e) : t.height !== void 0 && (t.height -= e);
1419
1474
  }
1420
1475
  const i = t.getVisualBoundingBox(), a = Math.abs(i.height - n.height) > 0.01;
1421
1476
  if (o.anchor === "middle-top") {
1422
- const r = ht.toRadiansInverse(t.rotation), l = Math.cos(r), h = Math.sin(r);
1477
+ const r = gt.toRadiansInverse(t.rotation), l = Math.cos(r), h = Math.sin(r);
1423
1478
  t.x -= e / 2 * h, t.y += e / 2 * l;
1424
1479
  } else {
1425
1480
  const r = !s && a;
@@ -1438,63 +1493,63 @@ class Ke {
1438
1493
  * @returns {object} Modified resize result with adjusted element
1439
1494
  */
1440
1495
  snapDimensions(t, e, o = null) {
1441
- var S, C, R, x, P;
1496
+ var T, C, R, x, H;
1442
1497
  if (!this.enabled || !e)
1443
1498
  return this.clearGuides(), t;
1444
1499
  const { element: n } = t, s = t.handle;
1445
1500
  let i;
1446
1501
  const a = n.transformType === "image", r = this.activeSnaps.x !== null || this.activeSnaps.y !== null;
1447
1502
  if (a && r && t.isFrozen && t.unfrozenDimensions) {
1448
- const w = n.clone();
1449
- if (w.transformData) {
1450
- const A = n.getVisualBoundingBox(), B = A.width, L = A.height, W = (o == null ? void 0 : o.width) ?? n.width ?? 0, O = (o == null ? void 0 : o.height) ?? n.height ?? 0, D = (o == null ? void 0 : o.visualWidth) ?? B, F = (o == null ? void 0 : o.visualHeight) ?? L, E = t.unfrozenDimensions.width / D, $ = t.unfrozenDimensions.height / F;
1451
- wt(w, W * E), Pt(w, O * $);
1503
+ const M = n.clone();
1504
+ if (M.transformData) {
1505
+ const A = n.getVisualBoundingBox(), I = A.width, L = A.height, D = (o == null ? void 0 : o.width) ?? n.width ?? 0, F = (o == null ? void 0 : o.height) ?? n.height ?? 0, W = (o == null ? void 0 : o.visualWidth) ?? I, q = (o == null ? void 0 : o.visualHeight) ?? L, J = t.unfrozenDimensions.width / W, E = t.unfrozenDimensions.height / q;
1506
+ xt(M, D * J), Et(M, F * E);
1452
1507
  }
1453
- i = bt.getSnapAnchors(w);
1508
+ i = mt.getSnapAnchors(M);
1454
1509
  } else
1455
- i = bt.getSnapAnchors(n);
1456
- const l = e.filter((w) => w.id !== n.id);
1510
+ i = mt.getSnapAnchors(n);
1511
+ const l = e.filter((M) => M.id !== n.id);
1457
1512
  if (l.length === 0)
1458
1513
  return this.clearGuides(), t;
1459
1514
  this._populateSpatialGrid(l);
1460
- const h = this._getSnapKeysForHandle(s), c = this._getTargetSnapKeys(), d = this._findXSnaps(i, l, h, c), u = this._findYSnaps(i, l, h, c);
1461
- this._prioritizeSnaps(d, s, "x"), this._prioritizeSnaps(u, s, "y");
1462
- const p = this._processStickySnap("x", i, d, n, s, o, l), b = this._processStickySnap("y", i, u, n, s, o, l), g = p.snapDelta, f = b.snapDelta, y = p.bestSnap, m = b.bestSnap, T = [];
1463
- y && T.push(y.guide), m && T.push(m.guide), this.guides = T, T.length > 0;
1464
- const v = s && (s.anchor === "top-left" || s.anchor === "top-right" || s.anchor === "bottom-left" || s.anchor === "bottom-right");
1465
- if (a && v && (g !== 0 || f !== 0))
1515
+ const h = this._getSnapKeysForHandle(s), c = this._getTargetSnapKeys(), d = this._findXSnaps(i, l, h, c), f = this._findYSnaps(i, l, h, c);
1516
+ this._prioritizeSnaps(d, s, "x"), this._prioritizeSnaps(f, s, "y");
1517
+ const b = this._processStickySnap("x", i, d, n, s, o, l), u = this._processStickySnap("y", i, f, n, s, o, l), p = b.snapDelta, g = u.snapDelta, y = b.bestSnap, S = u.bestSnap, m = [];
1518
+ y && m.push(y.guide), S && m.push(S.guide), this.guides = m, m.length > 0;
1519
+ const w = s && (s.anchor === "top-left" || s.anchor === "top-right" || s.anchor === "bottom-left" || s.anchor === "bottom-right");
1520
+ if (a && w && (p !== 0 || g !== 0))
1466
1521
  return t;
1467
- if (g !== 0 || f !== 0) {
1468
- const w = n.clone(), A = this.activeSnaps.x || this.activeSnaps.y, B = (A == null ? void 0 : A.frozenFontSize) ?? n.fontSize ?? 0, L = (A == null ? void 0 : A.frozenWidth) ?? lt(n) ?? n.width ?? 0, W = (A == null ? void 0 : A.frozenHeight) ?? St(n) ?? n.height ?? 0, O = (A == null ? void 0 : A.frozenPosition) ?? { x: n.x, y: n.y }, D = w.isCropping && !String(s.anchor).startsWith("crop-");
1469
- if (!D)
1522
+ if (p !== 0 || g !== 0) {
1523
+ const M = n.clone(), A = this.activeSnaps.x || this.activeSnaps.y, I = (A == null ? void 0 : A.frozenFontSize) ?? n.fontSize ?? 0, L = (A == null ? void 0 : A.frozenWidth) ?? ft(n) ?? n.width ?? 0, D = (A == null ? void 0 : A.frozenHeight) ?? Tt(n) ?? n.height ?? 0, F = (A == null ? void 0 : A.frozenPosition) ?? { x: n.x, y: n.y }, W = M.isCropping && !String(s.anchor).startsWith("crop-");
1524
+ if (!W)
1470
1525
  if (s && s.anchor) {
1471
- if (g !== 0) {
1472
- const k = (S = this.activeSnaps.x) == null ? void 0 : S.anchorKey, I = k == null ? void 0 : k.toLowerCase();
1473
- I && I.includes("right") ? this._adjustElementForRightResize(w, g, s) : I && I.includes("left") ? this._adjustElementForLeftResize(w, g, s) : w.x += g;
1526
+ if (p !== 0) {
1527
+ const B = (T = this.activeSnaps.x) == null ? void 0 : T.anchorKey, k = B == null ? void 0 : B.toLowerCase();
1528
+ k && k.includes("right") ? this._adjustElementForRightResize(M, p, s) : k && k.includes("left") ? this._adjustElementForLeftResize(M, p, s) : M.x += p;
1474
1529
  }
1475
- if (f !== 0) {
1476
- const k = (C = this.activeSnaps.y) == null ? void 0 : C.anchorKey, I = k == null ? void 0 : k.toLowerCase();
1477
- I && I.includes("bottom") ? this._adjustElementForBottomResize(w, f, s) : I && I.includes("top") ? this._adjustElementForTopResize(w, f, s) : w.y += f;
1530
+ if (g !== 0) {
1531
+ const B = (C = this.activeSnaps.y) == null ? void 0 : C.anchorKey, k = B == null ? void 0 : B.toLowerCase();
1532
+ k && k.includes("bottom") ? this._adjustElementForBottomResize(M, g, s) : k && k.includes("top") ? this._adjustElementForTopResize(M, g, s) : M.y += g;
1478
1533
  }
1479
1534
  } else
1480
- w.x += g, w.y += f;
1481
- w.fontSize !== void 0 && (w.fontSize = B);
1482
- const F = w.transformType === "image", E = this.activeSnaps.x !== null || this.activeSnaps.y !== null;
1483
- if (F && E) {
1484
- if (lt(w) !== void 0) {
1485
- const k = this.activeSnaps.x || this.activeSnaps.y;
1486
- let I = L, _ = W;
1487
- k && (I = k.frozenWidth ?? I, _ = k.frozenHeight ?? _);
1488
- const H = lt(n), V = St(n), Y = w.imageAspectRatio || (H && V ? H / V : null);
1489
- Y && Y !== 0 && (_ = I / Y), wt(w, I), Pt(w, _), k && (k.frozenWidth = I, k.frozenHeight = _);
1535
+ M.x += p, M.y += g;
1536
+ M.fontSize !== void 0 && (M.fontSize = I);
1537
+ const q = M.transformType === "image", J = this.activeSnaps.x !== null || this.activeSnaps.y !== null;
1538
+ if (q && J) {
1539
+ if (ft(M) !== void 0) {
1540
+ const B = this.activeSnaps.x || this.activeSnaps.y;
1541
+ let k = L, O = D;
1542
+ B && (k = B.frozenWidth ?? k, O = B.frozenHeight ?? O);
1543
+ const G = ft(n), P = Tt(n), _ = M.imageAspectRatio || (G && P ? G / P : null);
1544
+ _ && _ !== 0 && (O = k / _), xt(M, k), Et(M, O), B && (B.frozenWidth = k, B.frozenHeight = O);
1490
1545
  }
1491
1546
  } else
1492
- (((R = this.activeSnaps.y) == null ? void 0 : R.isPositionBasedSnap) || !1) && (lt(w) !== void 0 ? wt(w, L) : w.width !== void 0 && (w.width = L));
1493
- const $ = s && (s.anchor === "middle-left" || s.anchor === "middle-right"), j = s && (s.anchor === "middle-top" || s.anchor === "middle-bottom"), J = ((x = this.activeSnaps.x) == null ? void 0 : x.isPositionBasedSnap) || !1, X = ((P = this.activeSnaps.y) == null ? void 0 : P.isPositionBasedSnap) || !1;
1494
- return (g === 0 || J) && !$ && !j && !D && (w.x = O.x), (f === 0 || X) && !j && !$ && !D && (w.y = O.y), {
1547
+ (((R = this.activeSnaps.y) == null ? void 0 : R.isPositionBasedSnap) || !1) && (ft(M) !== void 0 ? xt(M, L) : M.width !== void 0 && (M.width = L));
1548
+ const E = s && (s.anchor === "middle-left" || s.anchor === "middle-right"), z = s && (s.anchor === "middle-top" || s.anchor === "middle-bottom"), N = ((x = this.activeSnaps.x) == null ? void 0 : x.isPositionBasedSnap) || !1, Q = ((H = this.activeSnaps.y) == null ? void 0 : H.isPositionBasedSnap) || !1;
1549
+ return (p === 0 || N) && !E && !z && !W && (M.x = F.x), (g === 0 || Q) && !z && !E && !W && (M.y = F.y), {
1495
1550
  ...t,
1496
- element: w,
1497
- snapAdjustment: { dx: g, dy: f },
1551
+ element: M,
1552
+ snapAdjustment: { dx: p, dy: g },
1498
1553
  // Flag to indicate we're in sticky snap mode (used to freeze font size)
1499
1554
  isInStickySnap: !0
1500
1555
  };
@@ -1508,12 +1563,12 @@ class Ke {
1508
1563
  if (!this.enabled) return t;
1509
1564
  const n = [0, 45, 90, 135, 180, 225, 270, 315, 360], s = 5;
1510
1565
  for (const i of n)
1511
- if (ie(t, i, s))
1566
+ if (he(t, i, s))
1512
1567
  return i;
1513
1568
  return t;
1514
1569
  }
1515
1570
  }
1516
- class $e {
1571
+ class nn {
1517
1572
  constructor(t = {}) {
1518
1573
  this.lastSnapTarget = null, this.detectionThreshold = t.detectionThreshold || 100, this.minDistance = t.minDistance || 10, this.enabled = t.enabled !== !1, this.showLabels = t.showLabels !== !1, this.indicators = [];
1519
1574
  }
@@ -1548,106 +1603,106 @@ class $e {
1548
1603
  snapToSpacing(t, e, o) {
1549
1604
  if (!this.enabled || !o)
1550
1605
  return t;
1551
- const n = Ft, s = o.filter((g) => g.id !== e.id);
1606
+ const n = Yt, s = o.filter((p) => p.id !== e.id);
1552
1607
  if (s.length === 0)
1553
1608
  return t;
1554
1609
  const i = e.clone();
1555
1610
  i.x = t.x, i.y = t.y;
1556
1611
  const a = i.getVisualBoundingBox(), r = a.x - t.x, l = a.y - t.y;
1557
- let h = t.x, c = t.y, d = !1, u = !1;
1558
- const p = s.filter((g) => {
1559
- const f = g.getVisualBoundingBox();
1560
- return !(a.x + a.width < f.x || a.x > f.x + f.width);
1612
+ let h = t.x, c = t.y, d = !1, f = !1;
1613
+ const b = s.filter((p) => {
1614
+ const g = p.getVisualBoundingBox();
1615
+ return !(a.x + a.width < g.x || a.x > g.x + g.width);
1561
1616
  });
1562
- if (p.sort((g, f) => {
1563
- const y = g.getVisualBoundingBox(), m = f.getVisualBoundingBox();
1564
- return y.y - m.y;
1565
- }), p.length >= 1) {
1566
- let g = null, f = null;
1567
- for (const T of p) {
1568
- const v = T.getVisualBoundingBox();
1569
- v.y + v.height <= a.y ? (!g || v.y > g.getVisualBoundingBox().y) && (g = T) : v.y >= a.y + a.height && (!f || v.y < f.getVisualBoundingBox().y) && (f = T);
1617
+ if (b.sort((p, g) => {
1618
+ const y = p.getVisualBoundingBox(), S = g.getVisualBoundingBox();
1619
+ return y.y - S.y;
1620
+ }), b.length >= 1) {
1621
+ let p = null, g = null;
1622
+ for (const m of b) {
1623
+ const w = m.getVisualBoundingBox();
1624
+ w.y + w.height <= a.y ? (!p || w.y > p.getVisualBoundingBox().y) && (p = m) : w.y >= a.y + a.height && (!g || w.y < g.getVisualBoundingBox().y) && (g = m);
1570
1625
  }
1571
1626
  const y = [];
1572
- for (let T = 0; T < p.length - 1; T++) {
1573
- const v = p[T].getVisualBoundingBox(), C = p[T + 1].getVisualBoundingBox().y - (v.y + v.height);
1627
+ for (let m = 0; m < b.length - 1; m++) {
1628
+ const w = b[m].getVisualBoundingBox(), C = b[m + 1].getVisualBoundingBox().y - (w.y + w.height);
1574
1629
  y.push(C);
1575
1630
  }
1576
- let m = null;
1577
- if (g) {
1578
- const T = g.getVisualBoundingBox(), v = a.y - (T.y + T.height);
1579
- for (const S of y)
1580
- if (Math.abs(v - S) <= n) {
1581
- m = S;
1631
+ let S = null;
1632
+ if (p) {
1633
+ const m = p.getVisualBoundingBox(), w = a.y - (m.y + m.height);
1634
+ for (const T of y)
1635
+ if (Math.abs(w - T) <= n) {
1636
+ S = T;
1582
1637
  break;
1583
1638
  }
1584
1639
  }
1585
- if (!m && f) {
1586
- const v = f.getVisualBoundingBox().y - (a.y + a.height);
1587
- for (const S of y)
1588
- if (Math.abs(v - S) <= n) {
1589
- m = S;
1640
+ if (!S && g) {
1641
+ const w = g.getVisualBoundingBox().y - (a.y + a.height);
1642
+ for (const T of y)
1643
+ if (Math.abs(w - T) <= n) {
1644
+ S = T;
1590
1645
  break;
1591
1646
  }
1592
1647
  }
1593
- if (m !== null && m > 0) {
1594
- if (g) {
1595
- const T = g.getVisualBoundingBox(), v = a.y - (T.y + T.height);
1596
- Math.abs(v - m) <= n && (c = T.y + T.height + m - l, u = !0);
1648
+ if (S !== null && S > 0) {
1649
+ if (p) {
1650
+ const m = p.getVisualBoundingBox(), w = a.y - (m.y + m.height);
1651
+ Math.abs(w - S) <= n && (c = m.y + m.height + S - l, f = !0);
1597
1652
  }
1598
- if (!u && f) {
1599
- const T = f.getVisualBoundingBox(), v = T.y - (a.y + a.height);
1600
- Math.abs(v - m) <= n && (c = T.y - a.height - m - l, u = !0);
1653
+ if (!f && g) {
1654
+ const m = g.getVisualBoundingBox(), w = m.y - (a.y + a.height);
1655
+ Math.abs(w - S) <= n && (c = m.y - a.height - S - l, f = !0);
1601
1656
  }
1602
1657
  }
1603
1658
  }
1604
- const b = s.filter((g) => {
1605
- const f = g.getVisualBoundingBox();
1606
- return !(a.y + a.height < f.y || a.y > f.y + f.height);
1659
+ const u = s.filter((p) => {
1660
+ const g = p.getVisualBoundingBox();
1661
+ return !(a.y + a.height < g.y || a.y > g.y + g.height);
1607
1662
  });
1608
- if (b.sort((g, f) => {
1609
- const y = g.getVisualBoundingBox(), m = f.getVisualBoundingBox();
1610
- return y.x - m.x;
1611
- }), b.length >= 1) {
1612
- let g = null, f = null;
1613
- for (const T of b) {
1614
- const v = T.getVisualBoundingBox();
1615
- v.x + v.width <= a.x ? (!g || v.x > g.getVisualBoundingBox().x) && (g = T) : v.x >= a.x + a.width && (!f || v.x < f.getVisualBoundingBox().x) && (f = T);
1663
+ if (u.sort((p, g) => {
1664
+ const y = p.getVisualBoundingBox(), S = g.getVisualBoundingBox();
1665
+ return y.x - S.x;
1666
+ }), u.length >= 1) {
1667
+ let p = null, g = null;
1668
+ for (const m of u) {
1669
+ const w = m.getVisualBoundingBox();
1670
+ w.x + w.width <= a.x ? (!p || w.x > p.getVisualBoundingBox().x) && (p = m) : w.x >= a.x + a.width && (!g || w.x < g.getVisualBoundingBox().x) && (g = m);
1616
1671
  }
1617
1672
  const y = [];
1618
- for (let T = 0; T < b.length - 1; T++) {
1619
- const v = b[T].getVisualBoundingBox(), C = b[T + 1].getVisualBoundingBox().x - (v.x + v.width);
1673
+ for (let m = 0; m < u.length - 1; m++) {
1674
+ const w = u[m].getVisualBoundingBox(), C = u[m + 1].getVisualBoundingBox().x - (w.x + w.width);
1620
1675
  y.push(C);
1621
1676
  }
1622
- let m = null;
1623
- if (g) {
1624
- const T = g.getVisualBoundingBox(), v = a.x - (T.x + T.width);
1625
- for (const S of y)
1626
- if (Math.abs(v - S) <= n) {
1627
- m = S;
1677
+ let S = null;
1678
+ if (p) {
1679
+ const m = p.getVisualBoundingBox(), w = a.x - (m.x + m.width);
1680
+ for (const T of y)
1681
+ if (Math.abs(w - T) <= n) {
1682
+ S = T;
1628
1683
  break;
1629
1684
  }
1630
1685
  }
1631
- if (!m && f) {
1632
- const v = f.getVisualBoundingBox().x - (a.x + a.width);
1633
- for (const S of y)
1634
- if (Math.abs(v - S) <= n) {
1635
- m = S;
1686
+ if (!S && g) {
1687
+ const w = g.getVisualBoundingBox().x - (a.x + a.width);
1688
+ for (const T of y)
1689
+ if (Math.abs(w - T) <= n) {
1690
+ S = T;
1636
1691
  break;
1637
1692
  }
1638
1693
  }
1639
- if (m !== null && m > 0) {
1640
- if (g) {
1641
- const T = g.getVisualBoundingBox(), v = a.x - (T.x + T.width);
1642
- Math.abs(v - m) <= n && (h = T.x + T.width + m - r, d = !0);
1694
+ if (S !== null && S > 0) {
1695
+ if (p) {
1696
+ const m = p.getVisualBoundingBox(), w = a.x - (m.x + m.width);
1697
+ Math.abs(w - S) <= n && (h = m.x + m.width + S - r, d = !0);
1643
1698
  }
1644
- if (!d && f) {
1645
- const T = f.getVisualBoundingBox(), v = T.x - (a.x + a.width);
1646
- Math.abs(v - m) <= n && (h = T.x - a.width - m - r, d = !0);
1699
+ if (!d && g) {
1700
+ const m = g.getVisualBoundingBox(), w = m.x - (a.x + a.width);
1701
+ Math.abs(w - S) <= n && (h = m.x - a.width - S - r, d = !0);
1647
1702
  }
1648
1703
  }
1649
1704
  }
1650
- return this.lastSnapTarget = d || u ? { x: h, y: c } : null, { x: h, y: c };
1705
+ return this.lastSnapTarget = d || f ? { x: h, y: c } : null, { x: h, y: c };
1651
1706
  }
1652
1707
  /**
1653
1708
  * Detect spacing between a moving element and other elements
@@ -1663,8 +1718,8 @@ class $e {
1663
1718
  return this.clearIndicators(), [];
1664
1719
  const s = t.getVisualBoundingBox(), i = [], a = [], r = [], l = [];
1665
1720
  for (const c of n) {
1666
- const d = c.getVisualBoundingBox(), u = s.x - (d.x + d.width), p = d.x - (s.x + s.width), b = s.y - (d.y + d.height), g = d.y - (s.y + s.height), f = !(s.y + s.height < d.y || s.y > d.y + d.height), y = !(s.x + s.width < d.x || s.x > d.x + d.width);
1667
- u >= this.minDistance && u < this.detectionThreshold && f && i.push({ element: c, distance: u }), p >= this.minDistance && p < this.detectionThreshold && f && a.push({ element: c, distance: p }), b >= this.minDistance && b < this.detectionThreshold && y && r.push({ element: c, distance: b }), g >= this.minDistance && g < this.detectionThreshold && y && l.push({ element: c, distance: g });
1721
+ const d = c.getVisualBoundingBox(), f = s.x - (d.x + d.width), b = d.x - (s.x + s.width), u = s.y - (d.y + d.height), p = d.y - (s.y + s.height), g = !(s.y + s.height < d.y || s.y > d.y + d.height), y = !(s.x + s.width < d.x || s.x > d.x + d.width);
1722
+ f >= this.minDistance && f < this.detectionThreshold && g && i.push({ element: c, distance: f }), b >= this.minDistance && b < this.detectionThreshold && g && a.push({ element: c, distance: b }), u >= this.minDistance && u < this.detectionThreshold && y && r.push({ element: c, distance: u }), p >= this.minDistance && p < this.detectionThreshold && y && l.push({ element: c, distance: p });
1668
1723
  }
1669
1724
  i.sort((c, d) => c.distance - d.distance), a.sort((c, d) => c.distance - d.distance), r.sort((c, d) => c.distance - d.distance), l.sort((c, d) => c.distance - d.distance);
1670
1725
  const h = [];
@@ -1723,28 +1778,28 @@ class $e {
1723
1778
  // bottom
1724
1779
  ) > i)
1725
1780
  continue;
1726
- let d = 0, u = !1, p = 0, b = 0, g = 0;
1781
+ let d = 0, f = !1, b = 0, u = 0, p = 0;
1727
1782
  const y = -30 * (a % 2 === 0 ? 1 : -1);
1728
- h.x >= n.x + n.width ? (d = h.x - (n.x + n.width), d >= this.minDistance && (u = !0, p = n.x + n.width, b = h.x, g = (n.y + n.height / 2 + h.y + h.height / 2) / 2 + y)) : n.x >= h.x + h.width && (d = n.x - (h.x + h.width), d >= this.minDistance && (u = !0, p = h.x + h.width, b = n.x, g = (n.y + n.height / 2 + h.y + h.height / 2) / 2 + y)), u && (o.push({
1783
+ h.x >= n.x + n.width ? (d = h.x - (n.x + n.width), d >= this.minDistance && (f = !0, b = n.x + n.width, u = h.x, p = (n.y + n.height / 2 + h.y + h.height / 2) / 2 + y)) : n.x >= h.x + h.width && (d = n.x - (h.x + h.width), d >= this.minDistance && (f = !0, b = h.x + h.width, u = n.x, p = (n.y + n.height / 2 + h.y + h.height / 2) / 2 + y)), f && (o.push({
1729
1784
  type: "horizontal",
1730
1785
  distance: Math.round(d),
1731
- x1: p,
1732
- x2: b,
1733
- y: g,
1734
- labelX: (p + b) / 2,
1735
- labelY: g,
1786
+ x1: b,
1787
+ x2: u,
1788
+ y: p,
1789
+ labelX: (b + u) / 2,
1790
+ labelY: p,
1736
1791
  isAltHover: !0
1737
1792
  }), a++);
1738
- let m = 0, T = !1, v = 0, S = 0, C = 0;
1793
+ let S = 0, m = !1, w = 0, T = 0, C = 0;
1739
1794
  const x = 30 * (r % 2 === 0 ? 1 : -1);
1740
- h.y >= n.y + n.height ? (m = h.y - (n.y + n.height), m >= this.minDistance && (T = !0, v = (n.x + n.width / 2 + h.x + h.width / 2) / 2 + x, S = n.y + n.height, C = h.y)) : n.y >= h.y + h.height && (m = n.y - (h.y + h.height), m >= this.minDistance && (T = !0, v = (n.x + n.width / 2 + h.x + h.width / 2) / 2 + x, S = h.y + h.height, C = n.y)), T && (o.push({
1795
+ h.y >= n.y + n.height ? (S = h.y - (n.y + n.height), S >= this.minDistance && (m = !0, w = (n.x + n.width / 2 + h.x + h.width / 2) / 2 + x, T = n.y + n.height, C = h.y)) : n.y >= h.y + h.height && (S = n.y - (h.y + h.height), S >= this.minDistance && (m = !0, w = (n.x + n.width / 2 + h.x + h.width / 2) / 2 + x, T = h.y + h.height, C = n.y)), m && (o.push({
1741
1796
  type: "vertical",
1742
- distance: Math.round(m),
1743
- x: v,
1744
- y1: S,
1797
+ distance: Math.round(S),
1798
+ x: w,
1799
+ y1: T,
1745
1800
  y2: C,
1746
- labelX: v,
1747
- labelY: (S + C) / 2,
1801
+ labelX: w,
1802
+ labelY: (T + C) / 2,
1748
1803
  isAltHover: !0
1749
1804
  }), r++);
1750
1805
  }
@@ -1757,84 +1812,84 @@ class $e {
1757
1812
  detectConsistentSpacing(t, e, o, n, s) {
1758
1813
  const i = [], r = o[0], l = r.distance, h = r.element.getVisualBoundingBox(), c = this.checkIfWouldSnap(e, l, n, s);
1759
1814
  if (this.addIndicatorForDirection(i, e, h, l, n, c), n === "left" || n === "right") {
1760
- const d = s.filter((u) => {
1761
- if (u.id === t.id) return !1;
1762
- const p = u.getVisualBoundingBox();
1763
- return !(e.y + e.height < p.y || e.y > p.y + p.height);
1815
+ const d = s.filter((f) => {
1816
+ if (f.id === t.id) return !1;
1817
+ const b = f.getVisualBoundingBox();
1818
+ return !(e.y + e.height < b.y || e.y > b.y + b.height);
1764
1819
  });
1765
- if (d.sort((u, p) => {
1766
- const b = u.getVisualBoundingBox(), g = p.getVisualBoundingBox();
1767
- return b.x - g.x;
1820
+ if (d.sort((f, b) => {
1821
+ const u = f.getVisualBoundingBox(), p = b.getVisualBoundingBox();
1822
+ return u.x - p.x;
1768
1823
  }), n === "left")
1769
- for (let u = 0; u < d.length - 1; u++) {
1770
- const p = d[u], b = d[u + 1], g = p.getVisualBoundingBox(), f = b.getVisualBoundingBox(), y = f.x - (g.x + g.width);
1824
+ for (let f = 0; f < d.length - 1; f++) {
1825
+ const b = d[f], u = d[f + 1], p = b.getVisualBoundingBox(), g = u.getVisualBoundingBox(), y = g.x - (p.x + p.width);
1771
1826
  if (Math.abs(y - l) <= 16 && y >= this.minDistance) {
1772
- const m = Math.max(g.y, f.y), T = Math.min(g.y + g.height, f.y + f.height), v = (m + T) / 2;
1827
+ const S = Math.max(p.y, g.y), m = Math.min(p.y + p.height, g.y + g.height), w = (S + m) / 2;
1773
1828
  i.push({
1774
1829
  type: "horizontal",
1775
1830
  distance: Math.round(y),
1776
- x1: g.x + g.width,
1777
- x2: f.x,
1778
- y: v,
1779
- labelX: (g.x + g.width + f.x) / 2,
1780
- labelY: v
1831
+ x1: p.x + p.width,
1832
+ x2: g.x,
1833
+ y: w,
1834
+ labelX: (p.x + p.width + g.x) / 2,
1835
+ labelY: w
1781
1836
  });
1782
1837
  }
1783
1838
  }
1784
1839
  else
1785
- for (let u = 0; u < d.length - 1; u++) {
1786
- const p = d[u], b = d[u + 1], g = p.getVisualBoundingBox(), f = b.getVisualBoundingBox(), y = f.x - (g.x + g.width);
1840
+ for (let f = 0; f < d.length - 1; f++) {
1841
+ const b = d[f], u = d[f + 1], p = b.getVisualBoundingBox(), g = u.getVisualBoundingBox(), y = g.x - (p.x + p.width);
1787
1842
  if (Math.abs(y - l) <= 16 && y >= this.minDistance) {
1788
- const m = Math.max(g.y, f.y), T = Math.min(g.y + g.height, f.y + f.height), v = (m + T) / 2;
1843
+ const S = Math.max(p.y, g.y), m = Math.min(p.y + p.height, g.y + g.height), w = (S + m) / 2;
1789
1844
  i.push({
1790
1845
  type: "horizontal",
1791
1846
  distance: Math.round(y),
1792
- x1: g.x + g.width,
1793
- x2: f.x,
1794
- y: v,
1795
- labelX: (g.x + g.width + f.x) / 2,
1796
- labelY: v
1847
+ x1: p.x + p.width,
1848
+ x2: g.x,
1849
+ y: w,
1850
+ labelX: (p.x + p.width + g.x) / 2,
1851
+ labelY: w
1797
1852
  });
1798
1853
  }
1799
1854
  }
1800
1855
  } else {
1801
- const d = s.filter((u) => {
1802
- if (u.id === t.id) return !1;
1803
- const p = u.getVisualBoundingBox();
1804
- return !(e.x + e.width < p.x || e.x > p.x + p.width);
1856
+ const d = s.filter((f) => {
1857
+ if (f.id === t.id) return !1;
1858
+ const b = f.getVisualBoundingBox();
1859
+ return !(e.x + e.width < b.x || e.x > b.x + b.width);
1805
1860
  });
1806
- if (d.sort((u, p) => {
1807
- const b = u.getVisualBoundingBox(), g = p.getVisualBoundingBox();
1808
- return b.y - g.y;
1861
+ if (d.sort((f, b) => {
1862
+ const u = f.getVisualBoundingBox(), p = b.getVisualBoundingBox();
1863
+ return u.y - p.y;
1809
1864
  }), n === "top")
1810
- for (let u = 0; u < d.length - 1; u++) {
1811
- const p = d[u], b = d[u + 1], g = p.getVisualBoundingBox(), f = b.getVisualBoundingBox(), y = f.y - (g.y + g.height);
1865
+ for (let f = 0; f < d.length - 1; f++) {
1866
+ const b = d[f], u = d[f + 1], p = b.getVisualBoundingBox(), g = u.getVisualBoundingBox(), y = g.y - (p.y + p.height);
1812
1867
  if (Math.abs(y - l) <= 16 && y >= this.minDistance) {
1813
- const m = Math.max(g.x, f.x), T = Math.min(g.x + g.width, f.x + f.width), v = (m + T) / 2;
1868
+ const S = Math.max(p.x, g.x), m = Math.min(p.x + p.width, g.x + g.width), w = (S + m) / 2;
1814
1869
  i.push({
1815
1870
  type: "vertical",
1816
1871
  distance: Math.round(y),
1817
- x: v,
1818
- y1: g.y + g.height,
1819
- y2: f.y,
1820
- labelX: v,
1821
- labelY: (g.y + g.height + f.y) / 2
1872
+ x: w,
1873
+ y1: p.y + p.height,
1874
+ y2: g.y,
1875
+ labelX: w,
1876
+ labelY: (p.y + p.height + g.y) / 2
1822
1877
  });
1823
1878
  }
1824
1879
  }
1825
1880
  else
1826
- for (let u = 0; u < d.length - 1; u++) {
1827
- const p = d[u], b = d[u + 1], g = p.getVisualBoundingBox(), f = b.getVisualBoundingBox(), y = f.y - (g.y + g.height);
1881
+ for (let f = 0; f < d.length - 1; f++) {
1882
+ const b = d[f], u = d[f + 1], p = b.getVisualBoundingBox(), g = u.getVisualBoundingBox(), y = g.y - (p.y + p.height);
1828
1883
  if (Math.abs(y - l) <= 16 && y >= this.minDistance) {
1829
- const m = Math.max(g.x, f.x), T = Math.min(g.x + g.width, f.x + f.width), v = (m + T) / 2;
1884
+ const S = Math.max(p.x, g.x), m = Math.min(p.x + p.width, g.x + g.width), w = (S + m) / 2;
1830
1885
  i.push({
1831
1886
  type: "vertical",
1832
1887
  distance: Math.round(y),
1833
- x: v,
1834
- y1: g.y + g.height,
1835
- y2: f.y,
1836
- labelX: v,
1837
- labelY: (g.y + g.height + f.y) / 2
1888
+ x: w,
1889
+ y1: p.y + p.height,
1890
+ y2: g.y,
1891
+ labelX: w,
1892
+ labelY: (p.y + p.height + g.y) / 2
1838
1893
  });
1839
1894
  }
1840
1895
  }
@@ -1845,7 +1900,7 @@ class $e {
1845
1900
  * Check if spacing would snap to a pattern
1846
1901
  */
1847
1902
  checkIfWouldSnap(t, e, o, n) {
1848
- const s = Ft;
1903
+ const s = Yt;
1849
1904
  if (o === "top" || o === "bottom") {
1850
1905
  const i = n.filter((a) => {
1851
1906
  const r = a.getVisualBoundingBox();
@@ -1945,7 +2000,7 @@ class $e {
1945
2000
  }
1946
2001
  }
1947
2002
  }
1948
- const Wt = $t("ArtboardRenderer"), We = {
2003
+ const _t = Zt("ArtboardRenderer"), Xe = {
1949
2004
  showLabel: !0,
1950
2005
  showBorder: !0,
1951
2006
  borderColor: "",
@@ -1963,9 +2018,9 @@ const Wt = $t("ArtboardRenderer"), We = {
1963
2018
  borderRadius: 0
1964
2019
  // Default to no border radius (sharp corners)
1965
2020
  };
1966
- class Jt {
2021
+ class ne {
1967
2022
  constructor(t = {}) {
1968
- this.options = { ...We, ...t };
2023
+ this.options = { ...Xe, ...t };
1969
2024
  }
1970
2025
  /**
1971
2026
  * Render an artboard
@@ -1987,10 +2042,10 @@ class Jt {
1987
2042
  * Renders preset color as base layer, then texture on top
1988
2043
  */
1989
2044
  renderTextureBackground(t, e) {
1990
- const o = Bt.getTexture(e.backgroundTexture), n = Bt.getTexturePresetColor(e.backgroundTexture);
2045
+ const o = Wt.getTexture(e.backgroundTexture), n = Wt.getTexturePresetColor(e.backgroundTexture);
1991
2046
  if (t.fillStyle = n, t.fillRect(e.x, e.y, e.width, e.height), !o || !o.complete) {
1992
- Bt.loadTexture(e.backgroundTexture).catch((s) => {
1993
- Wt.error("Failed to load texture:", s);
2047
+ Wt.loadTexture(e.backgroundTexture).catch((s) => {
2048
+ _t.error("Failed to load texture:", s);
1994
2049
  });
1995
2050
  return;
1996
2051
  }
@@ -2011,7 +2066,7 @@ class Jt {
2011
2066
  * Render artboard border (respects clipShape and borderRadius option)
2012
2067
  */
2013
2068
  renderBorder(t, e, o) {
2014
- const { x: n, y: s, width: i, height: a, clipShape: r } = e, l = this.options.borderColor || ae(), h = this.options.selectedBorderColor || tt();
2069
+ const { x: n, y: s, width: i, height: a, clipShape: r } = e, l = this.options.borderColor || ce(), h = this.options.selectedBorderColor || nt();
2015
2070
  if (t.strokeStyle = o ? h : l, t.lineWidth = o ? this.options.selectedBorderWidth : this.options.borderWidth, t.beginPath(), !r || r === "rectangle")
2016
2071
  if (this.options.borderRadius > 0) {
2017
2072
  const c = Math.min(this.options.borderRadius, Math.min(i, a) / 2);
@@ -2019,8 +2074,8 @@ class Jt {
2019
2074
  } else
2020
2075
  t.rect(n, s, i, a);
2021
2076
  else if (r === "circle") {
2022
- const c = n + i / 2, d = s + a / 2, u = Math.min(i, a) / 2;
2023
- t.arc(c, d, u, 0, Math.PI * 2);
2077
+ const c = n + i / 2, d = s + a / 2, f = Math.min(i, a) / 2;
2078
+ t.arc(c, d, f, 0, Math.PI * 2);
2024
2079
  } else if (typeof r == "object" && r.type === "rounded") {
2025
2080
  const c = Math.min(r.radius, Math.min(i, a) / 2);
2026
2081
  this.roundedRect(t, n, s, i, a, c);
@@ -2030,7 +2085,7 @@ class Jt {
2030
2085
  t.save(), t.translate(n, s), t.stroke(c), t.restore();
2031
2086
  return;
2032
2087
  } catch (c) {
2033
- Wt.warn("Invalid SVG path for border, falling back to rectangle:", c), t.rect(n, s, i, a);
2088
+ _t.warn("Invalid SVG path for border, falling back to rectangle:", c), t.rect(n, s, i, a);
2034
2089
  }
2035
2090
  t.stroke();
2036
2091
  }
@@ -2040,7 +2095,7 @@ class Jt {
2040
2095
  renderLabel(t, e, o) {
2041
2096
  const n = this.options.labelFontSize, s = this.options.labelPadding, i = `${e.name} (${Math.round(e.width)} × ${Math.round(e.height)})`, a = e.x, r = e.y - s;
2042
2097
  t.font = `${n}px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`;
2043
- const l = this.options.selectedBorderColor || tt(), h = this.options.labelColor || re();
2098
+ const l = this.options.selectedBorderColor || nt(), h = this.options.labelColor || de();
2044
2099
  t.fillStyle = o ? l : h, t.textAlign = "left", t.textBaseline = "bottom", t.fillText(i, a, r);
2045
2100
  }
2046
2101
  /**
@@ -2084,7 +2139,7 @@ class Jt {
2084
2139
  t.translate(o, n), t.clip(r), t.translate(-o, -n);
2085
2140
  return;
2086
2141
  } catch (r) {
2087
- Wt.warn("Invalid SVG path, falling back to rectangle:", r), t.rect(o, n, s, i);
2142
+ _t.warn("Invalid SVG path, falling back to rectangle:", r), t.rect(o, n, s, i);
2088
2143
  }
2089
2144
  t.clip();
2090
2145
  }
@@ -2143,7 +2198,7 @@ class Jt {
2143
2198
  * Use this when exporting to ensure preview background is never included
2144
2199
  */
2145
2200
  static createForExport(t = {}) {
2146
- return new Jt({
2201
+ return new ne({
2147
2202
  ...t,
2148
2203
  showPreviewBackground: !1
2149
2204
  // CRITICAL: Never show preview in exports
@@ -2156,15 +2211,15 @@ class Jt {
2156
2211
  return !!(this.options.showPreviewBackground && t.previewBackgroundColor && t.previewBackgroundColor !== "transparent");
2157
2212
  }
2158
2213
  }
2159
- class mt {
2214
+ class wt {
2160
2215
  /**
2161
2216
  * Render selection box layer
2162
2217
  */
2163
2218
  static renderSelectionLayer(t, e, o, n = 1) {
2164
2219
  if (!e || e.visible === !1 || o && o.getMode() === "drag" || "isGroup" in e && e.isGroup) return;
2165
2220
  const i = e.getVisualBoundingBox(), a = e.getRotationAnchor();
2166
- t.save(), t.strokeStyle = tt(t.canvas), t.lineWidth = 2, t.translate(a.x * n, a.y * n), t.rotate(ht.toRadians(e.rotation)), t.translate(-a.x * n, -a.y * n);
2167
- const r = it.canvas.selectionPadding;
2221
+ t.save(), t.strokeStyle = nt(t.canvas), t.lineWidth = 2, t.translate(a.x * n, a.y * n), t.rotate(gt.toRadians(e.rotation)), t.translate(-a.x * n, -a.y * n);
2222
+ const r = ct.canvas.selectionPadding;
2168
2223
  t.strokeRect(
2169
2224
  (i.x - r) * n,
2170
2225
  (i.y - r) * n,
@@ -2180,22 +2235,22 @@ class mt {
2180
2235
  if (!e || !(o != null && o.rotationHandle) || (n == null ? void 0 : n.getMode()) !== "resize") return;
2181
2236
  const i = e.getVisualBoundingBox(), a = Math.round(i.width), r = Math.round(i.height), l = `${a} × ${r}`, h = o.rotationHandle, c = h.x * s, d = h.y * s - 20;
2182
2237
  t.save(), t.font = "10px system-ui, -apple-system, sans-serif";
2183
- const p = t.measureText(l).width + 12, b = 18;
2184
- t.shadowColor = le(t.canvas), t.shadowBlur = 4, t.shadowOffsetY = 1, t.fillStyle = he(t.canvas), t.beginPath(), t.roundRect(
2185
- c - p / 2,
2186
- d - b / 2,
2187
- p,
2238
+ const b = t.measureText(l).width + 12, u = 18;
2239
+ t.shadowColor = fe(t.canvas), t.shadowBlur = 4, t.shadowOffsetY = 1, t.fillStyle = ge(t.canvas), t.beginPath(), t.roundRect(
2240
+ c - b / 2,
2241
+ d - u / 2,
2188
2242
  b,
2243
+ u,
2189
2244
  3
2190
2245
  // Smaller border radius
2191
- ), t.fill(), t.shadowColor = "transparent", t.shadowBlur = 0, t.shadowOffsetY = 0, t.fillStyle = ce(t.canvas), t.textAlign = "center", t.textBaseline = "middle", t.fillText(l, c, d + 0.5), t.restore();
2246
+ ), t.fill(), t.shadowColor = "transparent", t.shadowBlur = 0, t.shadowOffsetY = 0, t.fillStyle = ue(t.canvas), t.textAlign = "center", t.textBaseline = "middle", t.fillText(l, c, d + 0.5), t.restore();
2192
2247
  }
2193
2248
  /**
2194
2249
  * Render transform handles layer
2195
2250
  */
2196
2251
  static renderHandlesLayer(t, e, o, n, s, i, a, r = 1, l = !0) {
2197
2252
  if (!e || e.visible === !1 || a.getMode() === "drag") return;
2198
- const c = i.type === "rotation-handle", d = i.type === "resize-handle" ? i.data : null, u = a.getMode() === "resize", p = u ? a.getActiveHandle() : null;
2253
+ const c = i.type === "rotation-handle", d = i.type === "resize-handle" ? i.data : null, f = a.getMode() === "resize", b = f ? a.getActiveHandle() : null;
2199
2254
  o.render(
2200
2255
  t,
2201
2256
  l,
@@ -2203,15 +2258,15 @@ class mt {
2203
2258
  s,
2204
2259
  c,
2205
2260
  d,
2206
- u,
2207
- p,
2261
+ f,
2262
+ b,
2208
2263
  r,
2209
2264
  !0
2210
2265
  // Render rotation handle on canvas (not React)
2211
2266
  );
2212
2267
  }
2213
2268
  }
2214
- class _t {
2269
+ class Vt {
2215
2270
  /**
2216
2271
  * Render hover highlights layer with fade-in animation
2217
2272
  * Outlines the actual element shape instead of a rectangular border
@@ -2226,14 +2281,14 @@ class _t {
2226
2281
  const c = performance.now() - e.startTime;
2227
2282
  h = Math.min(c / r, 1) * l;
2228
2283
  }
2229
- t.strokeStyle = de(t.canvas), t.globalAlpha = h, t.lineWidth = 3, this.renderElementOutline(t, a, s, i), t.restore();
2284
+ t.strokeStyle = pe(t.canvas), t.globalAlpha = h, t.lineWidth = 3, this.renderElementOutline(t, a, s, i), t.restore();
2230
2285
  }
2231
2286
  /**
2232
2287
  * Render outline for a specific element type
2233
2288
  */
2234
2289
  static renderElementOutline(t, e, o = 1, n) {
2235
2290
  const s = e.getRotationAnchor();
2236
- t.translate(s.x * o, s.y * o), t.rotate(ht.toRadians(e.rotation)), t.translate(-s.x * o, -s.y * o), e.transformType === "shape" ? this.renderShapeOutline(t, e, o) : e.transformType === "image" ? this.renderImageOutline(t, e, o) : e.transformType === "group" ? this.renderGroupOutline(t, e, o) : this.renderTextOutline(t, e, o, n);
2291
+ t.translate(s.x * o, s.y * o), t.rotate(gt.toRadians(e.rotation)), t.translate(-s.x * o, -s.y * o), e.transformType === "shape" ? this.renderShapeOutline(t, e, o) : e.transformType === "image" ? this.renderImageOutline(t, e, o) : e.transformType === "group" ? this.renderGroupOutline(t, e, o) : this.renderTextOutline(t, e, o, n);
2237
2292
  }
2238
2293
  /**
2239
2294
  * Render outline for shape elements (star, rectangle, circle, etc.)
@@ -2243,12 +2298,12 @@ class _t {
2243
2298
  const n = e.transformData, s = n.width * o, i = n.height * o, a = 2, l = a + a / 2;
2244
2299
  switch (t.save(), t.translate(e.x * o, e.y * o), t.beginPath(), n.shapeType) {
2245
2300
  case "rectangle": {
2246
- const h = n.borderRadius || 0, c = -(s + l * 2) / 2, d = -(i + l * 2) / 2, u = s + l * 2, p = i + l * 2;
2301
+ const h = n.borderRadius || 0, c = -(s + l * 2) / 2, d = -(i + l * 2) / 2, f = s + l * 2, b = i + l * 2;
2247
2302
  if (h > 0) {
2248
- const b = Math.min(h / 100 * Math.min(u, p), u / 2, p / 2);
2249
- t.roundRect(c, d, u, p, b);
2303
+ const u = Math.min(h / 100 * Math.min(f, b), f / 2, b / 2);
2304
+ t.roundRect(c, d, f, b, u);
2250
2305
  } else
2251
- t.rect(c, d, u, p);
2306
+ t.rect(c, d, f, b);
2252
2307
  break;
2253
2308
  }
2254
2309
  case "circle": {
@@ -2269,24 +2324,24 @@ class _t {
2269
2324
  // bottom-right
2270
2325
  { x: -h, y: c }
2271
2326
  // bottom-left
2272
- ], u = d.map((b, g) => {
2273
- const f = d[(g + 1) % 3], y = f.x - b.x, m = f.y - b.y, T = Math.sqrt(y * y + m * m);
2274
- return { x: m / T, y: -y / T };
2275
- }), p = d.map((b, g) => {
2276
- const f = u[(g + 2) % 3], y = u[g], m = f.x + y.x, T = f.y + y.y, v = Math.sqrt(m * m + T * T), S = (m * f.x + T * f.y) / v, C = l / S;
2327
+ ], f = d.map((u, p) => {
2328
+ const g = d[(p + 1) % 3], y = g.x - u.x, S = g.y - u.y, m = Math.sqrt(y * y + S * S);
2329
+ return { x: S / m, y: -y / m };
2330
+ }), b = d.map((u, p) => {
2331
+ const g = f[(p + 2) % 3], y = f[p], S = g.x + y.x, m = g.y + y.y, w = Math.sqrt(S * S + m * m), T = (S * g.x + m * g.y) / w, C = l / T;
2277
2332
  return {
2278
- x: b.x + m / v * C,
2279
- y: b.y + T / v * C
2333
+ x: u.x + S / w * C,
2334
+ y: u.y + m / w * C
2280
2335
  };
2281
2336
  });
2282
- t.moveTo(p[0].x, p[0].y), t.lineTo(p[1].x, p[1].y), t.lineTo(p[2].x, p[2].y), t.closePath();
2337
+ t.moveTo(b[0].x, b[0].y), t.lineTo(b[1].x, b[1].y), t.lineTo(b[2].x, b[2].y), t.closePath();
2283
2338
  break;
2284
2339
  }
2285
2340
  case "star": {
2286
- const h = n.points ?? 5, c = n.innerRadius ?? 0.4, d = Math.min(s, i) / 2 + l, u = d * c;
2287
- for (let p = 0; p < h * 2; p++) {
2288
- const b = p * Math.PI / h - Math.PI / 2, g = p % 2 === 0 ? d : u, f = g * Math.cos(b), y = g * Math.sin(b);
2289
- p === 0 ? t.moveTo(f, y) : t.lineTo(f, y);
2341
+ const h = n.points ?? 5, c = n.innerRadius ?? 0.4, d = Math.min(s, i) / 2 + l, f = d * c;
2342
+ for (let b = 0; b < h * 2; b++) {
2343
+ const u = b * Math.PI / h - Math.PI / 2, p = b % 2 === 0 ? d : f, g = p * Math.cos(u), y = p * Math.sin(u);
2344
+ b === 0 ? t.moveTo(g, y) : t.lineTo(g, y);
2290
2345
  }
2291
2346
  t.closePath();
2292
2347
  break;
@@ -2294,8 +2349,8 @@ class _t {
2294
2349
  case "polygon": {
2295
2350
  const h = n.sides ?? 5, c = Math.min(s, i) / 2 + l;
2296
2351
  for (let d = 0; d < h; d++) {
2297
- const u = d * 2 * Math.PI / h - Math.PI / 2, p = c * Math.cos(u), b = c * Math.sin(u);
2298
- d === 0 ? t.moveTo(p, b) : t.lineTo(p, b);
2352
+ const f = d * 2 * Math.PI / h - Math.PI / 2, b = c * Math.cos(f), u = c * Math.sin(f);
2353
+ d === 0 ? t.moveTo(b, u) : t.lineTo(b, u);
2299
2354
  }
2300
2355
  t.closePath();
2301
2356
  break;
@@ -2313,15 +2368,15 @@ class _t {
2313
2368
  * Creates a ring effect with a gap between the element and the stroke
2314
2369
  */
2315
2370
  static renderImageOutline(t, e, o) {
2316
- var b;
2317
- const n = e.getVisualBoundingBox(), s = n.width * o, i = n.height * o, a = ((b = e.transformData) == null ? void 0 : b.borderRadius) || 0, r = 2, h = r + r / 2;
2371
+ var u;
2372
+ const n = e.getVisualBoundingBox(), s = n.width * o, i = n.height * o, a = ((u = e.transformData) == null ? void 0 : u.borderRadius) || 0, r = 2, h = r + r / 2;
2318
2373
  t.save(), t.translate(e.x * o, e.y * o);
2319
- const c = -(s + h * 2) / 2, d = -(i + h * 2) / 2, u = s + h * 2, p = i + h * 2;
2374
+ const c = -(s + h * 2) / 2, d = -(i + h * 2) / 2, f = s + h * 2, b = i + h * 2;
2320
2375
  if (t.beginPath(), a > 0) {
2321
- const g = Math.min(a / 100 * Math.min(u, p), u / 2, p / 2);
2322
- t.roundRect(c, d, u, p, g);
2376
+ const p = Math.min(a / 100 * Math.min(f, b), f / 2, b / 2);
2377
+ t.roundRect(c, d, f, b, p);
2323
2378
  } else
2324
- t.rect(c, d, u, p);
2379
+ t.rect(c, d, f, b);
2325
2380
  t.stroke(), t.restore();
2326
2381
  }
2327
2382
  /**
@@ -2354,120 +2409,129 @@ class _t {
2354
2409
  */
2355
2410
  static renderHoverRingEffect(t, e, o) {
2356
2411
  t.save(), t.translate(e.x * o, e.y * o), o !== 1 && t.scale(o, o);
2357
- const n = e.fontSize, s = e.fontFamily, i = e.bold || !1, a = e.italic || !1, r = e.textAlign || "center", l = jt(n, s, i, a), h = n * 1.2, c = 4 / o, d = 4 / o, u = document.createElement("canvas");
2358
- u.width = t.canvas.width, u.height = t.canvas.height;
2359
- const p = u.getContext("2d");
2360
- if (!p) {
2412
+ const n = e.fontSize, s = e.fontFamily, i = e.bold || !1, a = e.italic || !1, r = e.textAlign || "center", l = Jt(n, s, i, a), h = n * (e.lineHeight ?? 1.2), c = e.letterSpacing ?? 0, d = 4 / o, f = 4 / o, b = document.createElement("canvas");
2413
+ b.width = t.canvas.width, b.height = t.canvas.height;
2414
+ const u = b.getContext("2d");
2415
+ if (!u) {
2361
2416
  t.restore();
2362
2417
  return;
2363
2418
  }
2364
- p.setTransform(t.getTransform()), p.textBaseline = "alphabetic", p.lineJoin = "round";
2365
- const b = e.getRichText ? e.getRichText() : null;
2366
- if (b) {
2367
- const g = qt(b), f = [], y = [];
2368
- g.forEach((v) => {
2419
+ u.setTransform(t.getTransform()), u.textBaseline = "alphabetic", u.lineJoin = "round";
2420
+ const p = e.getRichText ? e.getRichText() : null;
2421
+ if (p) {
2422
+ const g = Qt(p), y = [], S = [];
2423
+ g.forEach((T) => {
2369
2424
  if (e.transformType === "custom" && e.transformData) {
2370
- const S = e.transformData.width - ft * 2, C = Ut(v, S, {
2425
+ const C = e.transformData.width - pt * 2, R = te(T, C, {
2371
2426
  fontSize: n,
2372
2427
  fontFamily: s,
2373
2428
  bold: i,
2374
- italic: a
2429
+ italic: a,
2430
+ letterSpacing: e.letterSpacing
2375
2431
  });
2376
- C.forEach((R, x) => {
2377
- f.push(R), y.push({
2378
- isParagraphStart: x === 0,
2379
- isParagraphEnd: x === C.length - 1
2432
+ R.forEach((x, H) => {
2433
+ y.push(x), S.push({
2434
+ isParagraphStart: H === 0,
2435
+ isParagraphEnd: H === R.length - 1
2380
2436
  });
2381
2437
  });
2382
2438
  } else
2383
- f.push(v), y.push({
2439
+ y.push(T), S.push({
2384
2440
  isParagraphStart: !0,
2385
2441
  isParagraphEnd: !0
2386
2442
  });
2387
2443
  });
2388
2444
  let m;
2389
- f.length === 0 ? m = 0 : f.length === 1 ? m = l.height : m = (f.length - 1) * h + l.height;
2390
- const T = -m / 2;
2391
- f.forEach((v, S) => {
2392
- var D, F;
2393
- const C = y[S].isParagraphStart, R = y[S].isParagraphEnd;
2394
- let x = 0;
2395
- const P = v.map((E) => E.text).join(""), w = ((D = P.match(/^ +/)) == null ? void 0 : D[0].length) || 0, A = ((F = P.match(/ +$/)) == null ? void 0 : F[0].length) || 0;
2396
- let B = 0;
2397
- v.forEach((E) => {
2398
- const $ = E.style.fontSize !== void 0 ? E.style.fontSize : n, j = E.style.fontFamily !== void 0 ? E.style.fontFamily : s, J = E.style.bold !== void 0 ? E.style.bold : i, X = E.style.italic !== void 0 ? E.style.italic : a;
2445
+ y.length === 0 ? m = 0 : y.length === 1 ? m = l.height : m = (y.length - 1) * h + l.height;
2446
+ const w = -m / 2;
2447
+ y.forEach((T, C) => {
2448
+ var q, J;
2449
+ const R = S[C].isParagraphStart, x = S[C].isParagraphEnd;
2450
+ let H = 0;
2451
+ const M = T.map((E) => E.text).join(""), A = ((q = M.match(/^ +/)) == null ? void 0 : q[0].length) || 0, I = ((J = M.match(/ +$/)) == null ? void 0 : J[0].length) || 0;
2452
+ let L = 0;
2453
+ T.forEach((E) => {
2454
+ const z = E.style.fontSize !== void 0 ? E.style.fontSize : n, N = E.style.fontFamily !== void 0 ? E.style.fontFamily : s, Q = E.style.bold !== void 0 ? E.style.bold : i, B = E.style.italic !== void 0 ? E.style.italic : a;
2399
2455
  let k = E.text;
2400
- const I = B, _ = B + E.text.length;
2401
- if (!C && w > 0 && I < w) {
2402
- const H = Math.min(w - I, E.text.length);
2403
- k = k.substring(H);
2456
+ const O = L, G = L + E.text.length;
2457
+ if (!R && A > 0 && O < A) {
2458
+ const P = Math.min(A - O, E.text.length);
2459
+ k = k.substring(P);
2404
2460
  }
2405
- if (!R && A > 0) {
2406
- const H = P.length - A;
2407
- if (_ > H) {
2408
- const V = !C && I < w ? Math.min(w - I, E.text.length) : 0, Y = Math.max(0, H - I - V);
2409
- k = k.substring(0, Y);
2461
+ if (!x && I > 0) {
2462
+ const P = M.length - I;
2463
+ if (G > P) {
2464
+ const _ = !R && O < A ? Math.min(A - O, E.text.length) : 0, j = Math.max(0, P - O - _);
2465
+ k = k.substring(0, j);
2410
2466
  }
2411
2467
  }
2412
- k.length > 0 && (t.save(), t.font = Ht($, j, J, X), x += t.measureText(k).width, t.restore()), B += E.text.length;
2468
+ if (k.length > 0) {
2469
+ const P = E.style.letterSpacing !== void 0 ? E.style.letterSpacing : c;
2470
+ t.save(), t.font = Lt(z, N, Q, B), H += Gt(t.measureText(k).width, k, P), t.restore();
2471
+ }
2472
+ L += E.text.length;
2413
2473
  });
2414
- const L = e.transformType === "custom" && e.transformData ? e.transformData.width - ft * 2 : void 0;
2415
- let W;
2416
- r === "center" ? W = -x / 2 : r === "right" ? W = L !== void 0 ? L / 2 - x : -x : W = L !== void 0 ? -L / 2 : 0;
2417
- const O = T + l.ascent + S * h;
2418
- B = 0, v.forEach((E) => {
2419
- const $ = E.style.fontSize !== void 0 ? E.style.fontSize : n, j = E.style.fontFamily !== void 0 ? E.style.fontFamily : s;
2474
+ const D = e.transformType === "custom" && e.transformData ? e.transformData.width - pt * 2 : void 0;
2475
+ let F;
2476
+ r === "center" ? F = -H / 2 : r === "right" ? F = D !== void 0 ? D / 2 - H : -H : F = D !== void 0 ? -D / 2 : 0;
2477
+ const W = w + l.ascent + C * h;
2478
+ L = 0, T.forEach((E) => {
2479
+ const z = E.style.fontSize !== void 0 ? E.style.fontSize : n, N = E.style.fontFamily !== void 0 ? E.style.fontFamily : s;
2420
2480
  E.style.color !== void 0 ? E.style.color : e.color;
2421
- const J = E.style.bold !== void 0 ? E.style.bold : i, X = E.style.italic !== void 0 ? E.style.italic : a;
2481
+ const Q = E.style.bold !== void 0 ? E.style.bold : i, B = E.style.italic !== void 0 ? E.style.italic : a;
2422
2482
  let k = E.text;
2423
- const I = B, _ = B + E.text.length;
2424
- if (!C && w > 0 && I < w) {
2425
- const H = Math.min(w - I, E.text.length);
2426
- k = k.substring(H);
2483
+ const O = L, G = L + E.text.length;
2484
+ if (!R && A > 0 && O < A) {
2485
+ const P = Math.min(A - O, E.text.length);
2486
+ k = k.substring(P);
2427
2487
  }
2428
- if (!R && A > 0) {
2429
- const H = P.length - A;
2430
- if (_ > H) {
2431
- const V = !C && I < w ? Math.min(w - I, E.text.length) : 0, Y = Math.max(0, H - I - V);
2432
- k = k.substring(0, Y);
2488
+ if (!x && I > 0) {
2489
+ const P = M.length - I;
2490
+ if (G > P) {
2491
+ const _ = !R && O < A ? Math.min(A - O, E.text.length) : 0, j = Math.max(0, P - O - _);
2492
+ k = k.substring(0, j);
2433
2493
  }
2434
2494
  }
2435
- B += E.text.length, k.length > 0 && (p.font = Ht($, j, J, X), p.textAlign = "left", p.globalCompositeOperation = "source-over", p.strokeStyle = t.strokeStyle, p.globalAlpha = Math.min(t.globalAlpha * 1.6, 0.8), p.lineWidth = (d + c) * 2, p.strokeText(k, W, O), p.globalCompositeOperation = "destination-out", p.globalAlpha = 1, p.lineWidth = d * 2, p.strokeText(k, W, O), p.fillText(k, W, O), W += p.measureText(k).width);
2495
+ if (L += E.text.length, k.length > 0) {
2496
+ const P = E.style.letterSpacing !== void 0 ? E.style.letterSpacing : c;
2497
+ u.font = Lt(z, N, Q, B), u.textAlign = "left", u.globalCompositeOperation = "source-over", u.strokeStyle = t.strokeStyle, u.globalAlpha = Math.min(t.globalAlpha * 1.6, 0.8), u.lineWidth = (f + d) * 2, Pt(u, k, F, W, P), u.globalCompositeOperation = "destination-out", u.globalAlpha = 1, u.lineWidth = f * 2, Pt(u, k, F, W, P), Xt(u, k, F, W, P), F += Gt(u.measureText(k).width, k, P);
2498
+ }
2436
2499
  });
2437
2500
  });
2438
2501
  } else {
2439
- t.font = Ht(n, s, i, a), p.font = t.font, p.textAlign = r;
2440
- let g, f;
2502
+ t.font = Lt(n, s, i, a), u.font = t.font, u.textAlign = r;
2503
+ let g, y;
2441
2504
  if (e.transformType === "custom" && e.transformData) {
2442
- const C = e.transformData.width - ft * 2, { lines: R } = fe(
2505
+ const R = e.transformData.width - pt * 2, { lines: x } = ye(
2443
2506
  e.text,
2444
- C,
2507
+ R,
2445
2508
  n,
2446
2509
  s,
2447
2510
  i,
2448
2511
  a,
2449
2512
  void 0,
2450
- !0
2513
+ !0,
2514
+ { letterSpacing: c, lineHeight: e.lineHeight }
2451
2515
  );
2452
- g = R;
2516
+ g = x;
2453
2517
  } else {
2454
2518
  g = e.text.split(`
2455
2519
  `);
2456
- const C = e.text.includes(`
2520
+ const R = e.text.includes(`
2457
2521
  `);
2458
- g = Te(g, C);
2522
+ g = xe(g, R);
2459
2523
  }
2460
- g.length === 0 ? f = 0 : g.length === 1 ? f = l.height : f = (g.length - 1) * h + l.height;
2461
- const y = -f / 2, m = e.text.includes(`
2462
- `), T = e.transformType === "custom" && e.transformData ? e.transformData.width : 0, v = -T / 2;
2463
- let S = v + ft;
2464
- r === "center" ? S = v + T / 2 : r === "right" && (S = v + T - ft), g.forEach((C, R) => {
2465
- const x = y + l.ascent + R * h, P = m || R === 0, w = m || R === g.length - 1;
2466
- let A = C;
2467
- P || (A = A.replace(/^ +/, "")), w || (A = A.replace(/ +$/, "")), p.globalCompositeOperation = "source-over", p.strokeStyle = t.strokeStyle, p.globalAlpha = Math.min(t.globalAlpha * 1.6, 0.8), p.lineWidth = (d + c) * 2, p.lineJoin = "round", p.strokeText(A, S, x), p.globalCompositeOperation = "destination-out", p.globalAlpha = 1, p.lineWidth = d * 2, p.strokeText(A, S, x), p.fillText(A, S, x);
2524
+ g.length === 0 ? y = 0 : g.length === 1 ? y = l.height : y = (g.length - 1) * h + l.height;
2525
+ const S = -y / 2, m = e.text.includes(`
2526
+ `), w = e.transformType === "custom" && e.transformData ? e.transformData.width : 0, T = -w / 2;
2527
+ let C = T + pt;
2528
+ r === "center" ? C = T + w / 2 : r === "right" && (C = T + w - pt), g.forEach((R, x) => {
2529
+ const H = S + l.ascent + x * h, M = m || x === 0, A = m || x === g.length - 1;
2530
+ let I = R;
2531
+ M || (I = I.replace(/^ +/, "")), A || (I = I.replace(/ +$/, "")), u.globalCompositeOperation = "source-over", u.strokeStyle = t.strokeStyle, u.globalAlpha = Math.min(t.globalAlpha * 1.6, 0.8), u.lineWidth = (f + d) * 2, u.lineJoin = "round", Pt(u, I, C, H, c), u.globalCompositeOperation = "destination-out", u.globalAlpha = 1, u.lineWidth = f * 2, Pt(u, I, C, H, c), Xt(u, I, C, H, c);
2468
2532
  });
2469
2533
  }
2470
- t.setTransform(1, 0, 0, 1, 0, 0), t.drawImage(u, 0, 0), t.restore();
2534
+ t.setTransform(1, 0, 0, 1, 0, 0), t.drawImage(b, 0, 0), t.restore();
2471
2535
  }
2472
2536
  /**
2473
2537
  * HOVER RING EFFECT for transformed text (circle, wave, arch, lean, ascend, flag)
@@ -2501,13 +2565,13 @@ class _t {
2501
2565
  t.transform(1, 0, Math.tan(y), 1, 0, 0), t.globalCompositeOperation = "source-over", t.strokeStyle = s, t.globalAlpha = 0.8, t.lineWidth = (n + o) * 2, t.lineJoin = "round", t.strokeText(i.text, 0, 0), t.globalCompositeOperation = "destination-out", t.globalAlpha = 1, t.lineWidth = n * 2, t.strokeText(i.text, 0, 0), t.fillText(i.text, 0, 0);
2502
2566
  return;
2503
2567
  }
2504
- const u = i.text.split(""), p = u.map((f) => t.measureText(f).width), b = this.calculateCharPositions(e, u, p), g = (f) => {
2505
- t.translate(f.x, f.y), f.angle && t.rotate(f.angle), f.skewY && t.transform(1, f.skewY, 0, 1, 0, 0);
2568
+ const f = i.text.split(""), b = f.map((g) => t.measureText(g).width), u = this.calculateCharPositions(e, f, b), p = (g) => {
2569
+ t.translate(g.x, g.y), g.angle && t.rotate(g.angle), g.skewY && t.transform(1, g.skewY, 0, 1, 0, 0);
2506
2570
  };
2507
- t.globalCompositeOperation = "source-over", t.strokeStyle = s, t.globalAlpha = 0.8, t.lineWidth = (n + o) * 2, t.lineJoin = "round", b.forEach((f, y) => {
2508
- t.save(), g(f), t.strokeText(u[y], 0, 0), t.restore();
2509
- }), t.globalCompositeOperation = "destination-out", t.globalAlpha = 1, t.lineWidth = n * 2, b.forEach((f, y) => {
2510
- t.save(), g(f), t.strokeText(u[y], 0, 0), t.fillText(u[y], 0, 0), t.restore();
2571
+ t.globalCompositeOperation = "source-over", t.strokeStyle = s, t.globalAlpha = 0.8, t.lineWidth = (n + o) * 2, t.lineJoin = "round", u.forEach((g, y) => {
2572
+ t.save(), p(g), t.strokeText(f[y], 0, 0), t.restore();
2573
+ }), t.globalCompositeOperation = "destination-out", t.globalAlpha = 1, t.lineWidth = n * 2, u.forEach((g, y) => {
2574
+ t.save(), p(g), t.strokeText(f[y], 0, 0), t.fillText(f[y], 0, 0), t.restore();
2511
2575
  });
2512
2576
  }
2513
2577
  /**
@@ -2527,14 +2591,14 @@ class _t {
2527
2591
  if (t.reverse) {
2528
2592
  let a = Math.PI / 2 + s / (2 * i);
2529
2593
  e.forEach((r, l) => {
2530
- const c = o[l] / i, d = Math.cos(a - c / 2) * i, u = Math.sin(a - c / 2) * i, p = a - c / 2 - Math.PI / 2;
2531
- n.push({ x: d, y: u, angle: p }), a -= c;
2594
+ const c = o[l] / i, d = Math.cos(a - c / 2) * i, f = Math.sin(a - c / 2) * i, b = a - c / 2 - Math.PI / 2;
2595
+ n.push({ x: d, y: f, angle: b }), a -= c;
2532
2596
  });
2533
2597
  } else {
2534
2598
  let a = -Math.PI / 2 - s / (2 * i);
2535
2599
  e.forEach((r, l) => {
2536
- const c = o[l] / i, d = Math.cos(a + c / 2) * i, u = Math.sin(a + c / 2) * i, p = a + c / 2 + Math.PI / 2;
2537
- n.push({ x: d, y: u, angle: p }), a += c;
2600
+ const c = o[l] / i, d = Math.cos(a + c / 2) * i, f = Math.sin(a + c / 2) * i, b = a + c / 2 + Math.PI / 2;
2601
+ n.push({ x: d, y: f, angle: b }), a += c;
2538
2602
  });
2539
2603
  }
2540
2604
  return n;
@@ -2546,8 +2610,8 @@ class _t {
2546
2610
  const s = [];
2547
2611
  let a = -o.reduce((r, l) => r + l, 0) / 2;
2548
2612
  return e.forEach((r, l) => {
2549
- const h = o[l], c = a + h / 2, d = c / (n.width / 2), u = n.amplitude * t.fontSize * Math.sin(n.frequency * Math.PI * d), p = n.amplitude * n.frequency * Math.PI * Math.cos(n.frequency * Math.PI * d);
2550
- s.push({ x: c, y: u, angle: 0, skewY: p * ge }), a += h;
2613
+ const h = o[l], c = a + h / 2, d = c / (n.width / 2), f = n.amplitude * t.fontSize * Math.sin(n.frequency * Math.PI * d), b = n.amplitude * n.frequency * Math.PI * Math.cos(n.frequency * Math.PI * d);
2614
+ s.push({ x: c, y: f, angle: 0, skewY: b * be }), a += h;
2551
2615
  }), s;
2552
2616
  }
2553
2617
  /**
@@ -2557,8 +2621,8 @@ class _t {
2557
2621
  const s = [], i = o.reduce((l, h) => l + h, 0), a = n.width / 2;
2558
2622
  let r = -i / 2;
2559
2623
  return e.forEach((l, h) => {
2560
- const c = o[h], d = r + c / 2, u = d / a, p = (Math.pow(u, 2) - 1) * n.archHeight * t.fontSize, b = 2 * u * n.archHeight;
2561
- s.push({ x: d, y: p, angle: 0, skewY: b * 0.3 }), r += c;
2624
+ const c = o[h], d = r + c / 2, f = d / a, b = (Math.pow(f, 2) - 1) * n.archHeight * t.fontSize, u = 2 * f * n.archHeight;
2625
+ s.push({ x: d, y: b, angle: 0, skewY: u * 0.3 }), r += c;
2562
2626
  }), s;
2563
2627
  }
2564
2628
  /**
@@ -2579,8 +2643,8 @@ class _t {
2579
2643
  const s = [], i = o.reduce((h, c) => h + c, 0), a = n.ascendAngle * Math.PI / 180, r = Math.tan(a);
2580
2644
  let l = -i / 2;
2581
2645
  return e.forEach((h, c) => {
2582
- const d = o[c], u = l + d / 2, p = u * r;
2583
- s.push({ x: u, y: p, angle: 0, skewY: r * 1 }), l += d;
2646
+ const d = o[c], f = l + d / 2, b = f * r;
2647
+ s.push({ x: f, y: b, angle: 0, skewY: r * 1 }), l += d;
2584
2648
  }), s;
2585
2649
  }
2586
2650
  /**
@@ -2590,8 +2654,8 @@ class _t {
2590
2654
  const s = [];
2591
2655
  let a = -o.reduce((r, l) => r + l, 0) / 2;
2592
2656
  return e.forEach((r, l) => {
2593
- const h = o[l], c = a + h / 2, d = c / (n.width / 2), u = Math.abs(d), p = n.amplitude * u, b = p * t.fontSize * Math.sin(n.frequency * Math.PI * d), g = p * n.frequency * Math.PI * Math.cos(n.frequency * Math.PI * d), f = n.amplitude * Math.sign(d) * Math.sin(n.frequency * Math.PI * d), y = g + f;
2594
- s.push({ x: c, y: b, angle: 0, skewY: y * 0.3 }), a += h;
2657
+ const h = o[l], c = a + h / 2, d = c / (n.width / 2), f = Math.abs(d), b = n.amplitude * f, u = b * t.fontSize * Math.sin(n.frequency * Math.PI * d), p = b * n.frequency * Math.PI * Math.cos(n.frequency * Math.PI * d), g = n.amplitude * Math.sign(d) * Math.sin(n.frequency * Math.PI * d), y = p + g;
2658
+ s.push({ x: c, y: u, angle: 0, skewY: y * 0.3 }), a += h;
2595
2659
  }), s;
2596
2660
  }
2597
2661
  }
@@ -2600,7 +2664,7 @@ class Ct {
2600
2664
  * Render snap guides layer
2601
2665
  */
2602
2666
  static renderSnapGuidesLayer(t, e = []) {
2603
- e.length !== 0 && (t.save(), t.strokeStyle = tt(t.canvas), t.lineWidth = it.canvas.snapGuideWidth, t.setLineDash(it.canvas.snapGuideDash), e.forEach((o) => {
2667
+ e.length !== 0 && (t.save(), t.strokeStyle = nt(t.canvas), t.lineWidth = ct.canvas.snapGuideWidth, t.setLineDash(ct.canvas.snapGuideDash), e.forEach((o) => {
2604
2668
  t.beginPath(), o.type === "vertical" ? (t.moveTo(o.x ?? 0, o.y1 ?? 0), t.lineTo(o.x ?? 0, o.y2 ?? 0)) : o.type === "horizontal" ? (t.moveTo(o.x1 ?? 0, o.y ?? 0), t.lineTo(o.x2 ?? 0, o.y ?? 0)) : (t.moveTo(o.x1 ?? 0, o.y1 ?? 0), t.lineTo(o.x2 ?? 0, o.y2 ?? 0)), t.stroke();
2605
2669
  }), t.restore());
2606
2670
  }
@@ -2609,8 +2673,8 @@ class Ct {
2609
2673
  */
2610
2674
  static renderSpacingIndicatorsLayer(t, e = []) {
2611
2675
  e.length !== 0 && (t.save(), t.setLineDash([]), e.forEach((o) => {
2612
- const n = Ot(t.canvas);
2613
- if (t.strokeStyle = n, t.fillStyle = n, t.lineWidth = it.canvas.spacingIndicatorWidth, t.beginPath(), o.type === "horizontal") {
2676
+ const n = Nt(t.canvas);
2677
+ if (t.strokeStyle = n, t.fillStyle = n, t.lineWidth = ct.canvas.spacingIndicatorWidth, t.beginPath(), o.type === "horizontal") {
2614
2678
  const s = o.x1 ?? 0, i = o.x2 ?? 0, a = o.y ?? 0;
2615
2679
  t.moveTo(s, a), t.lineTo(i, a), t.stroke();
2616
2680
  const r = 6;
@@ -2632,197 +2696,200 @@ class Ct {
2632
2696
  */
2633
2697
  static renderDistanceLabel(t, e, o, n) {
2634
2698
  const s = `${n}`;
2635
- t.font = `600 ${it.canvas.spacingLabelFontSize}px ${it.canvas.spacingLabelFontFamily}`;
2636
- const a = t.measureText(s).width, r = it.canvas.spacingLabelFontSize, l = 4, h = a + l * 2, c = r + l * 2;
2637
- t.fillStyle = Ot(t.canvas), t.beginPath(), t.roundRect(e - h / 2, o - c / 2, h, c, ue), t.fill(), t.fillStyle = pe, t.textAlign = "center", t.textBaseline = "middle", t.fillText(s, e, o);
2699
+ t.font = `600 ${ct.canvas.spacingLabelFontSize}px ${ct.canvas.spacingLabelFontFamily}`;
2700
+ const a = t.measureText(s).width, r = ct.canvas.spacingLabelFontSize, l = 4, h = a + l * 2, c = r + l * 2;
2701
+ t.fillStyle = Nt(t.canvas), t.beginPath(), t.roundRect(e - h / 2, o - c / 2, h, c, Se), t.fill(), t.fillStyle = me, t.textAlign = "center", t.textBaseline = "middle", t.fillText(s, e, o);
2638
2702
  }
2639
2703
  }
2640
- class Dt {
2704
+ class zt {
2641
2705
  /**
2642
2706
  * Render edit mode features: cursor and text selection highlight
2643
2707
  * This renders on the main canvas at world coordinates (same as the element)
2644
2708
  */
2645
2709
  static renderEditModeLayer(t, e, o, n) {
2646
2710
  if (!e || e.transformType === "image" || e.transformType === "group") return;
2647
- const s = e, { cursorPosition: i, selectionStart: a, selectionEnd: r, editText: l, editRichText: h, cursorOpacity: c, isTouchDevice: d, selectionHandlePositionsRef: u } = o, p = n || 1, b = s.transformType;
2648
- if (b === "circle" || b === "wave" || b === "arch" || b === "lean" || b === "ascend" || b === "flag") {
2649
- this.renderTransformEditModeLayer(t, s, o, p);
2711
+ const s = e, { cursorPosition: i, selectionStart: a, selectionEnd: r, editText: l, editRichText: h, cursorOpacity: c, isTouchDevice: d, selectionHandlePositionsRef: f } = o, b = n || 1, u = s.transformType;
2712
+ if (u === "circle" || u === "wave" || u === "arch" || u === "lean" || u === "ascend" || u === "flag") {
2713
+ this.renderTransformEditModeLayer(t, s, o, b);
2650
2714
  return;
2651
2715
  }
2652
- const g = s.fontSize || 24, f = s.fontFamily || "Arial", y = s.bold || !1, m = s.italic || !1, T = s.underline || !1, v = s.strikethrough || !1, S = s.textAlign || "center";
2716
+ const p = s.fontSize || 24, g = s.fontFamily || "Arial", y = s.bold || !1, S = s.italic || !1, m = s.underline || !1, w = s.strikethrough || !1, T = s.textAlign || "center", C = s.letterSpacing ?? 0;
2653
2717
  t.save(), t.translate(s.x, s.y), t.rotate(-s.rotation * Math.PI / 180);
2654
- const C = jt(g, f, y, m), R = C.height, x = g * 1.2;
2655
- let P, w, A;
2718
+ const R = Jt(p, g, y, S), x = R.height, H = p * (s.lineHeight ?? 1.2);
2719
+ let M, A, I;
2656
2720
  if (h && s.transformType === "custom" && s.transformData.width) {
2657
- const X = s.transformData.width - ft * 2;
2658
- A = X;
2659
- const k = qt(h);
2660
- P = [], w = [], k.forEach((I) => {
2661
- const _ = Ut(I, X, {
2721
+ const B = s.transformData.width - pt * 2;
2722
+ I = B;
2723
+ const k = Qt(h);
2724
+ M = [], A = [], k.forEach((O) => {
2725
+ const G = te(O, B, {
2662
2726
  fontSize: s.fontSize,
2663
2727
  fontFamily: s.fontFamily,
2664
2728
  bold: s.bold,
2665
- italic: s.italic
2729
+ italic: s.italic,
2730
+ letterSpacing: s.letterSpacing
2666
2731
  });
2667
- _.forEach((H, V) => {
2668
- P.push(H), w.push({
2669
- isParagraphStart: V === 0,
2670
- isParagraphEnd: V === _.length - 1
2732
+ G.forEach((P, _) => {
2733
+ M.push(P), A.push({
2734
+ isParagraphStart: _ === 0,
2735
+ isParagraphEnd: _ === G.length - 1
2671
2736
  });
2672
2737
  });
2673
2738
  });
2674
2739
  } else
2675
- P = l.split(`
2740
+ M = l.split(`
2676
2741
  `).map((k) => [
2677
2742
  {
2678
2743
  text: k,
2679
- style: { fontSize: g, fontFamily: f, bold: y, italic: m }
2744
+ style: { fontSize: p, fontFamily: g, bold: y, italic: S }
2680
2745
  }
2681
- ]), w = P.map(() => ({
2746
+ ]), A = M.map(() => ({
2682
2747
  isParagraphStart: !0,
2683
2748
  // Each line is its own paragraph
2684
2749
  isParagraphEnd: !0
2685
2750
  }));
2686
- const B = P.length > 1 ? C.height + (P.length - 1) * x : C.height;
2687
- let L = -B / 2, W = 0, O = L, D = R;
2688
- const F = [];
2751
+ const L = M.length > 1 ? R.height + (M.length - 1) * H : R.height;
2752
+ let D = -L / 2, F = 0, W = D, q = x;
2753
+ const J = [];
2689
2754
  let E = 0;
2690
- P.forEach((X, k) => {
2691
- var V, Y;
2692
- const I = w[k].isParagraphStart, _ = w[k].isParagraphEnd, H = [];
2693
- X.forEach((at) => {
2694
- Array.from(at.text).forEach((ct) => {
2695
- let G = g, ot = f, et = y, U = m;
2755
+ M.forEach((B, k) => {
2756
+ var _, j;
2757
+ const O = A[k].isParagraphStart, G = A[k].isParagraphEnd, P = [];
2758
+ B.forEach((ot) => {
2759
+ Array.from(ot.text).forEach((lt) => {
2760
+ let Y = p, ht = g, it = y, U = S, st = C;
2696
2761
  if (h && E < l.length) {
2697
2762
  const Z = h.getStyleAt(E);
2698
- G = Z.fontSize || g, ot = Z.fontFamily || f, et = Z.bold !== void 0 ? Z.bold : y, U = Z.italic !== void 0 ? Z.italic : m;
2763
+ Y = Z.fontSize || p, ht = Z.fontFamily || g, it = Z.bold !== void 0 ? Z.bold : y, U = Z.italic !== void 0 ? Z.italic : S, st = Z.letterSpacing !== void 0 ? Z.letterSpacing : C;
2699
2764
  }
2700
2765
  t.save();
2701
- const nt = et ? "bold" : "normal", z = U ? "italic" : "normal";
2702
- t.font = `${z} ${nt} ${G}px "${ot}", Arial, sans-serif`;
2703
- const q = t.measureText(ct).width;
2704
- t.restore(), H.push({ char: ct, width: q, fontSize: G, index: E }), E++;
2766
+ const V = it ? "bold" : "normal", $ = U ? "italic" : "normal";
2767
+ t.font = `${$} ${V} ${Y}px "${ht}", Arial, sans-serif`;
2768
+ const at = t.measureText(lt).width + st;
2769
+ t.restore(), P.push({ char: lt, width: at, fontSize: Y, index: E }), E++;
2705
2770
  });
2706
2771
  });
2707
2772
  {
2708
- const at = k === 0, gt = k === P.length - 1, ct = H.map((z) => z.char).join(""), G = ((V = ct.match(/^ +/)) == null ? void 0 : V[0].length) || 0, ot = ((Y = ct.match(/ +$/)) == null ? void 0 : Y[0].length) || 0;
2709
- let et = 0;
2710
- for (let z = 0; z < H.length; z++)
2711
- !at && z < G || !gt && z >= H.length - ot || (et += H[z].width);
2773
+ const ot = k === 0, et = k === M.length - 1, lt = P.map((V) => V.char).join(""), Y = ((_ = lt.match(/^ +/)) == null ? void 0 : _[0].length) || 0, ht = ((j = lt.match(/ +$/)) == null ? void 0 : j[0].length) || 0;
2774
+ let it = 0;
2775
+ for (let V = 0; V < P.length; V++)
2776
+ !ot && V < Y || !et && V >= P.length - ht || (it += P[V].width);
2712
2777
  let U;
2713
- S === "center" ? U = -et / 2 : S === "right" ? U = A !== void 0 ? A / 2 - et : -et : U = A !== void 0 ? -A / 2 : 0;
2714
- let nt = U;
2715
- for (let z = 0; z < H.length; z++) {
2716
- const q = H[z];
2717
- F[q.index] = {
2718
- x: nt,
2719
- y: L,
2720
- width: q.width,
2778
+ T === "center" ? U = -it / 2 : T === "right" ? U = I !== void 0 ? I / 2 - it : -it : U = I !== void 0 ? -I / 2 : 0;
2779
+ let st = U;
2780
+ for (let V = 0; V < P.length; V++) {
2781
+ const $ = P[V];
2782
+ J[$.index] = {
2783
+ x: st,
2784
+ y: D,
2785
+ width: $.width,
2721
2786
  // All characters keep their width for cursor navigation
2722
- height: q.fontSize
2723
- }, nt += q.width;
2787
+ height: $.fontSize
2788
+ }, st += $.width;
2724
2789
  }
2725
- if (H.length > 0) {
2726
- const z = H[0].index, q = H[H.length - 1].index, dt = k < P.length - 1 && q + 1 === E ? q : q + 1;
2727
- if (i >= z && i <= dt)
2728
- if (i === z)
2729
- W = U, O = L, D = R;
2790
+ if (P.length > 0) {
2791
+ const V = P[0].index, $ = P[P.length - 1].index, ut = k < M.length - 1 && $ + 1 === E ? $ : $ + 1;
2792
+ if (i >= V && i <= ut)
2793
+ if (i === V)
2794
+ F = U, W = D, q = x;
2730
2795
  else {
2731
- let pt = 0;
2732
- for (let st = 0; st < H.length && H[st].index < i; st++) {
2733
- const rt = H[st], xt = rt.char === " ";
2734
- let yt = !0;
2735
- if (xt) {
2736
- const Rt = st < G, N = st >= H.length - ot, Tt = !I && G > 0, vt = !_ && ot > 0;
2737
- yt = !(Rt && Tt || N && vt);
2796
+ let yt = 0;
2797
+ for (let rt = 0; rt < P.length && P[rt].index < i; rt++) {
2798
+ const dt = P[rt], bt = dt.char === " ";
2799
+ let St = !0;
2800
+ if (bt) {
2801
+ const kt = rt < Y, X = rt >= P.length - ht, vt = !O && Y > 0, Mt = !G && ht > 0;
2802
+ St = !(kt && vt || X && Mt);
2738
2803
  }
2739
- yt && (pt += rt.width);
2804
+ St && (yt += dt.width);
2740
2805
  }
2741
- W = U + pt, O = L, D = R;
2806
+ F = U + yt, W = D, q = x;
2742
2807
  }
2743
2808
  }
2744
- k < P.length - 1 && (L += x);
2809
+ k < M.length - 1 && (D += H);
2745
2810
  }
2746
2811
  });
2747
- const $ = a !== r;
2748
- let j = null, J = null;
2749
- if ($) {
2750
- const X = Math.min(a, r), k = Math.max(a, r);
2751
- t.save(), t.fillStyle = ye(t.canvas);
2752
- let I = 0, _ = -B / 2;
2753
- if (P.forEach((H, V) => {
2754
- var ot, et;
2755
- const Y = w[V].isParagraphStart, at = w[V].isParagraphEnd, gt = V === 0, ct = V === P.length - 1, G = [];
2756
- if (H.forEach((U) => {
2757
- Array.from(U.text).forEach((nt) => {
2758
- const z = U.style || {}, q = z.fontSize !== void 0 ? z.fontSize : g, Z = z.fontFamily !== void 0 ? z.fontFamily : f, ut = z.bold !== void 0 ? z.bold : y, dt = z.italic !== void 0 ? z.italic : m;
2812
+ const z = a !== r;
2813
+ let N = null, Q = null;
2814
+ if (z) {
2815
+ const B = Math.min(a, r), k = Math.max(a, r);
2816
+ t.save(), t.fillStyle = Te(t.canvas);
2817
+ let O = 0, G = -L / 2;
2818
+ if (M.forEach((P, _) => {
2819
+ var ht, it;
2820
+ const j = A[_].isParagraphStart, ot = A[_].isParagraphEnd, et = _ === 0, lt = _ === M.length - 1, Y = [];
2821
+ if (P.forEach((U) => {
2822
+ Array.from(U.text).forEach((st) => {
2823
+ const V = U.style || {}, $ = V.fontSize !== void 0 ? V.fontSize : p, at = V.fontFamily !== void 0 ? V.fontFamily : g, Z = V.bold !== void 0 ? V.bold : y, ut = V.italic !== void 0 ? V.italic : S, yt = V.letterSpacing !== void 0 ? V.letterSpacing : C;
2759
2824
  t.save();
2760
- const pt = ut ? "bold" : "normal", st = dt ? "italic" : "normal";
2761
- t.font = `${st} ${pt} ${q}px "${Z}", Arial, sans-serif`;
2762
- const rt = t.measureText(nt).width;
2763
- t.restore(), G.push({ char: nt, index: I, width: rt, style: z }), I++;
2825
+ const rt = Z ? "bold" : "normal", dt = ut ? "italic" : "normal";
2826
+ t.font = `${dt} ${rt} ${$}px "${at}", Arial, sans-serif`;
2827
+ const bt = t.measureText(st).width + yt;
2828
+ t.restore(), Y.push({ char: st, index: O, width: bt, style: V }), O++;
2764
2829
  });
2765
- }), G.length > 0) {
2766
- const U = G[0].index, nt = G[G.length - 1].index;
2767
- if (k > U && X <= nt) {
2830
+ }), Y.length > 0) {
2831
+ const U = Y[0].index, st = Y[Y.length - 1].index;
2832
+ if (k > U && B <= st) {
2768
2833
  t.save();
2769
- const z = G.map((N) => N.char).join(""), q = ((ot = z.match(/^ +/)) == null ? void 0 : ot[0].length) || 0, Z = ((et = z.match(/ +$/)) == null ? void 0 : et[0].length) || 0;
2834
+ const V = Y.map((X) => X.char).join(""), $ = ((ht = V.match(/^ +/)) == null ? void 0 : ht[0].length) || 0, at = ((it = V.match(/ +$/)) == null ? void 0 : it[0].length) || 0;
2835
+ let Z = 0;
2836
+ for (let X = 0; X < Y.length; X++)
2837
+ !et && X < $ || !lt && X >= Y.length - at || (Z += Y[X].width);
2770
2838
  let ut = 0;
2771
- for (let N = 0; N < G.length; N++)
2772
- !gt && N < q || !ct && N >= G.length - Z || (ut += G[N].width);
2839
+ T === "center" ? ut = -Z / 2 : T === "right" && (ut = -Z);
2840
+ const yt = Math.max(B, U), rt = Math.min(k, st + 1);
2773
2841
  let dt = 0;
2774
- S === "center" ? dt = -ut / 2 : S === "right" && (dt = -ut);
2775
- const pt = Math.max(X, U), st = Math.min(k, nt + 1);
2776
- let rt = 0;
2777
- for (let N = 0; N < G.length && G[N].index < pt; N++) {
2778
- const Tt = G[N], vt = N < q, At = N >= G.length - Z, Et = !Y && q > 0, It = !at && Z > 0;
2779
- !(vt && Et || At && It) && (rt += Tt.width);
2842
+ for (let X = 0; X < Y.length && Y[X].index < yt; X++) {
2843
+ const vt = Y[X], Mt = X < $, Ht = X >= Y.length - at, It = !j && $ > 0, Bt = !ot && at > 0;
2844
+ !(Mt && It || Ht && Bt) && (dt += vt.width);
2780
2845
  }
2781
- let xt = 0;
2782
- for (let N = 0; N < G.length && G[N].index < st; N++) {
2783
- const Tt = G[N], vt = N < q, At = N >= G.length - Z, Et = !Y && q > 0, It = !at && Z > 0;
2784
- !(vt && Et || At && It) && (xt += Tt.width);
2846
+ let bt = 0;
2847
+ for (let X = 0; X < Y.length && Y[X].index < rt; X++) {
2848
+ const vt = Y[X], Mt = X < $, Ht = X >= Y.length - at, It = !j && $ > 0, Bt = !ot && at > 0;
2849
+ !(Mt && It || Ht && Bt) && (bt += vt.width);
2785
2850
  }
2786
- const yt = dt + rt, Rt = xt - rt;
2787
- t.fillRect(yt, _, Rt, R), j === null && (j = { x: yt, y: _ }), J = { x: yt + Rt, y: _ + R }, t.restore();
2851
+ const St = ut + dt, kt = bt - dt;
2852
+ t.fillRect(St, G, kt, x), N === null && (N = { x: St, y: G }), Q = { x: St + kt, y: G + x }, t.restore();
2788
2853
  }
2789
2854
  }
2790
- V < P.length - 1 && (_ += x);
2855
+ _ < M.length - 1 && (G += H);
2791
2856
  }), t.restore(), h) {
2792
2857
  t.save();
2793
- const H = s.transformType === "custom" ? s.transformData : null, V = H != null && H.width ? H.width - ft * 2 : void 0;
2794
- ve(t, h, {
2795
- fontSize: g,
2796
- fontFamily: f,
2858
+ const P = s.transformType === "custom" ? s.transformData : null, _ = P != null && P.width ? P.width - pt * 2 : void 0;
2859
+ Ce(t, h, {
2860
+ fontSize: p,
2861
+ fontFamily: g,
2797
2862
  color: s.color || "#000000",
2798
2863
  bold: y,
2799
- italic: m,
2800
- underline: T,
2801
- strikethrough: v,
2802
- textAlign: S
2803
- }, V), t.restore();
2864
+ italic: S,
2865
+ underline: m,
2866
+ strikethrough: w,
2867
+ textAlign: T,
2868
+ letterSpacing: s.letterSpacing,
2869
+ lineHeight: s.lineHeight
2870
+ }, _), t.restore();
2804
2871
  }
2805
2872
  }
2806
- if ($ && d && j && J) {
2807
- const X = j, k = J, I = 6 / p, _ = 2 / p;
2873
+ if (z && d && N && Q) {
2874
+ const B = N, k = Q, O = 6 / b, G = 2 / b;
2808
2875
  t.save();
2809
- const H = tt(t.canvas);
2810
- t.fillStyle = H, t.strokeStyle = H, t.lineWidth = _, t.lineCap = "round";
2811
- const V = { x: X.x, y: X.y - I }, Y = { x: k.x, y: k.y + I };
2812
- t.beginPath(), t.moveTo(X.x, X.y), t.lineTo(X.x, X.y + R), t.stroke(), t.beginPath(), t.arc(V.x, V.y, I, 0, Math.PI * 2), t.fill(), t.strokeStyle = "white", t.lineWidth = 2 / p, t.stroke(), t.strokeStyle = H, t.lineWidth = _, t.beginPath(), t.moveTo(k.x, k.y - R), t.lineTo(k.x, k.y), t.stroke(), t.beginPath(), t.arc(Y.x, Y.y, I, 0, Math.PI * 2), t.fill(), t.strokeStyle = "white", t.lineWidth = 2 / p, t.stroke(), t.restore(), u && (u.current = {
2876
+ const P = nt(t.canvas);
2877
+ t.fillStyle = P, t.strokeStyle = P, t.lineWidth = G, t.lineCap = "round";
2878
+ const _ = { x: B.x, y: B.y - O }, j = { x: k.x, y: k.y + O };
2879
+ t.beginPath(), t.moveTo(B.x, B.y), t.lineTo(B.x, B.y + x), t.stroke(), t.beginPath(), t.arc(_.x, _.y, O, 0, Math.PI * 2), t.fill(), t.strokeStyle = "white", t.lineWidth = 2 / b, t.stroke(), t.strokeStyle = P, t.lineWidth = G, t.beginPath(), t.moveTo(k.x, k.y - x), t.lineTo(k.x, k.y), t.stroke(), t.beginPath(), t.arc(j.x, j.y, O, 0, Math.PI * 2), t.fill(), t.strokeStyle = "white", t.lineWidth = 2 / b, t.stroke(), t.restore(), f && (f.current = {
2813
2880
  start: {
2814
- center: V,
2815
- textEdge: X
2881
+ center: _,
2882
+ textEdge: B
2816
2883
  // Original selection edge (top-left of selection on first line)
2817
2884
  },
2818
2885
  end: {
2819
- center: Y,
2886
+ center: j,
2820
2887
  textEdge: k
2821
2888
  // Original selection edge (bottom-right of selection on last line)
2822
2889
  }
2823
2890
  });
2824
- } else u && (u.current = { start: null, end: null });
2825
- !$ && c > 0 && (t.save(), t.globalAlpha = c, t.strokeStyle = tt(t.canvas), t.lineWidth = 3 / p, t.lineCap = "round", t.beginPath(), t.moveTo(W, O), t.lineTo(W, O + D), t.stroke(), t.restore()), t.restore();
2891
+ } else f && (f.current = { start: null, end: null });
2892
+ !z && c > 0 && (t.save(), t.globalAlpha = c, t.strokeStyle = nt(t.canvas), t.lineWidth = 3 / b, t.lineCap = "round", t.beginPath(), t.moveTo(F, W), t.lineTo(F, W + q), t.stroke(), t.restore()), t.restore();
2826
2893
  }
2827
2894
  /**
2828
2895
  * Render edit mode features for transformed text (circle, wave, arch, etc.)
@@ -2833,37 +2900,37 @@ class Dt {
2833
2900
  t.save(), t.translate(e.x, e.y), t.rotate(-e.rotation * Math.PI / 180);
2834
2901
  const c = l ? "bold" : "normal", d = h ? "italic" : "normal";
2835
2902
  t.font = `${d} ${c} ${a}px ${r}`;
2836
- const u = Array.from(e.text), p = u.map((g) => t.measureText(g).width), b = _t.calculateCharPositions(e, u, p);
2837
- if (s >= 0 && s <= u.length && i > 0) {
2838
- let g;
2903
+ const f = Array.from(e.text), b = f.map((p) => t.measureText(p).width), u = Vt.calculateCharPositions(e, f, b);
2904
+ if (s >= 0 && s <= f.length && i > 0) {
2905
+ let p;
2839
2906
  if (s === 0)
2840
- if (b.length > 0) {
2841
- const y = b[0], m = p[0];
2842
- g = {
2843
- x: y.x - Math.cos(y.angle) * (m / 2),
2844
- y: y.y - Math.sin(y.angle) * (m / 2),
2907
+ if (u.length > 0) {
2908
+ const y = u[0], S = b[0];
2909
+ p = {
2910
+ x: y.x - Math.cos(y.angle) * (S / 2),
2911
+ y: y.y - Math.sin(y.angle) * (S / 2),
2845
2912
  angle: y.angle
2846
2913
  };
2847
2914
  } else
2848
- g = { x: 0, y: 0, angle: 0 };
2849
- else if (s >= b.length) {
2850
- const y = b[b.length - 1], m = p[p.length - 1];
2851
- g = {
2852
- x: y.x + Math.cos(y.angle) * (m / 2),
2853
- y: y.y + Math.sin(y.angle) * (m / 2),
2915
+ p = { x: 0, y: 0, angle: 0 };
2916
+ else if (s >= u.length) {
2917
+ const y = u[u.length - 1], S = b[b.length - 1];
2918
+ p = {
2919
+ x: y.x + Math.cos(y.angle) * (S / 2),
2920
+ y: y.y + Math.sin(y.angle) * (S / 2),
2854
2921
  angle: y.angle
2855
2922
  };
2856
2923
  } else {
2857
- const y = b[s], m = p[s];
2858
- g = {
2859
- x: y.x - Math.cos(y.angle) * (m / 2),
2860
- y: y.y - Math.sin(y.angle) * (m / 2),
2924
+ const y = u[s], S = b[s];
2925
+ p = {
2926
+ x: y.x - Math.cos(y.angle) * (S / 2),
2927
+ y: y.y - Math.sin(y.angle) * (S / 2),
2861
2928
  angle: y.angle
2862
2929
  };
2863
2930
  }
2864
- t.save(), t.translate(g.x, g.y), t.rotate(g.angle), t.globalAlpha = i, t.strokeStyle = tt(t.canvas), t.lineWidth = 2 / n;
2865
- const f = a * 1.2;
2866
- t.beginPath(), t.moveTo(0, -f / 2), t.lineTo(0, f / 2), t.stroke(), t.restore();
2931
+ t.save(), t.translate(p.x, p.y), t.rotate(p.angle), t.globalAlpha = i, t.strokeStyle = nt(t.canvas), t.lineWidth = 2 / n;
2932
+ const g = a * 1.2;
2933
+ t.beginPath(), t.moveTo(0, -g / 2), t.lineTo(0, g / 2), t.stroke(), t.restore();
2867
2934
  }
2868
2935
  t.restore();
2869
2936
  }
@@ -2872,28 +2939,28 @@ class Dt {
2872
2939
  * Shows both image resize handles and crop handles
2873
2940
  */
2874
2941
  static renderCropBoxLayer(t, e, o, n = 1) {
2875
- if (!(e instanceof be) || !e.isCropping) return;
2942
+ if (!(e instanceof we) || !e.isCropping) return;
2876
2943
  const s = e, i = s.getCropBoxBounds();
2877
2944
  if (!i) return;
2878
- const a = 4 / n, r = 2 / n, l = Se / n, h = me / n, c = 1 / n;
2879
- t.save(), t.translate(e.x * n, e.y * n), t.rotate(ht.toRadians(e.rotation));
2880
- const d = s.transformData.flipHorizontal ? -1 : 1, u = s.transformData.flipVertical ? -1 : 1;
2881
- t.scale(d * n, u * n);
2882
- const p = s.transformData.width * s.transformData.cropWidth, b = s.transformData.height * s.transformData.cropHeight, g = s.transformData.width / 2 - (s.transformData.cropX * s.transformData.width + p / 2), f = s.transformData.height / 2 - (s.transformData.cropY * s.transformData.height + b / 2), y = s.transformData.width / 2, m = s.transformData.height / 2, T = {
2883
- x: g - y,
2884
- y: f - m,
2945
+ const a = 4 / n, r = 2 / n, l = ve / n, h = Me / n, c = 1 / n;
2946
+ t.save(), t.translate(e.x * n, e.y * n), t.rotate(gt.toRadians(e.rotation));
2947
+ const d = s.transformData.flipHorizontal ? -1 : 1, f = s.transformData.flipVertical ? -1 : 1;
2948
+ t.scale(d * n, f * n);
2949
+ const b = s.transformData.width * s.transformData.cropWidth, u = s.transformData.height * s.transformData.cropHeight, p = s.transformData.width / 2 - (s.transformData.cropX * s.transformData.width + b / 2), g = s.transformData.height / 2 - (s.transformData.cropY * s.transformData.height + u / 2), y = s.transformData.width / 2, S = s.transformData.height / 2, m = {
2950
+ x: p - y,
2951
+ y: g - S,
2885
2952
  width: s.transformData.width,
2886
2953
  height: s.transformData.height
2887
2954
  };
2888
- t.fillStyle = "rgba(0, 0, 0, 0.5)", i.y > T.y && t.fillRect(T.x, T.y, T.width, i.y - T.y);
2889
- const v = i.y + i.height, S = T.y + T.height;
2890
- v < S && t.fillRect(T.x, v, T.width, S - v), i.x > T.x && t.fillRect(T.x, i.y, i.x - T.x, i.height);
2891
- const C = i.x + i.width, R = T.x + T.width;
2892
- C < R && t.fillRect(C, i.y, R - C, i.height), t.strokeStyle = tt(t.canvas), t.lineWidth = r, t.strokeRect(i.x, i.y, i.width, i.height), t.strokeStyle = "rgba(255, 255, 255, 0.5)", t.lineWidth = c;
2955
+ t.fillStyle = "rgba(0, 0, 0, 0.5)", i.y > m.y && t.fillRect(m.x, m.y, m.width, i.y - m.y);
2956
+ const w = i.y + i.height, T = m.y + m.height;
2957
+ w < T && t.fillRect(m.x, w, m.width, T - w), i.x > m.x && t.fillRect(m.x, i.y, i.x - m.x, i.height);
2958
+ const C = i.x + i.width, R = m.x + m.width;
2959
+ C < R && t.fillRect(C, i.y, R - C, i.height), t.strokeStyle = nt(t.canvas), t.lineWidth = r, t.strokeRect(i.x, i.y, i.width, i.height), t.strokeStyle = "rgba(255, 255, 255, 0.5)", t.lineWidth = c;
2893
2960
  const x = i.width / 3;
2894
2961
  t.beginPath(), t.moveTo(i.x + x, i.y), t.lineTo(i.x + x, i.y + i.height), t.moveTo(i.x + 2 * x, i.y), t.lineTo(i.x + 2 * x, i.y + i.height), t.stroke();
2895
- const P = i.height / 3;
2896
- if (t.beginPath(), t.moveTo(i.x, i.y + P), t.lineTo(i.x + i.width, i.y + P), t.moveTo(i.x, i.y + 2 * P), t.lineTo(i.x + i.width, i.y + 2 * P), t.stroke(), [
2962
+ const H = i.height / 3;
2963
+ if (t.beginPath(), t.moveTo(i.x, i.y + H), t.lineTo(i.x + i.width, i.y + H), t.moveTo(i.x, i.y + 2 * H), t.lineTo(i.x + i.width, i.y + 2 * H), t.stroke(), [
2897
2964
  { x: i.x, y: i.y },
2898
2965
  // top-left
2899
2966
  { x: i.x + i.width, y: i.y },
@@ -2902,8 +2969,8 @@ class Dt {
2902
2969
  // bottom-right
2903
2970
  { x: i.x, y: i.y + i.height }
2904
2971
  // bottom-left
2905
- ].forEach((B) => {
2906
- t.beginPath(), t.arc(B.x, B.y, l + 1 / n, 0, Math.PI * 2), t.fillStyle = "#bbb", t.fill(), t.beginPath(), t.arc(B.x, B.y, l, 0, Math.PI * 2), t.fillStyle = "#fff", t.fill();
2972
+ ].forEach((I) => {
2973
+ t.beginPath(), t.arc(I.x, I.y, l + 1 / n, 0, Math.PI * 2), t.fillStyle = "#bbb", t.fill(), t.beginPath(), t.arc(I.x, I.y, l, 0, Math.PI * 2), t.fillStyle = "#fff", t.fill();
2907
2974
  }), [
2908
2975
  { x: i.x + i.width / 2, y: i.y, orientation: "horizontal" },
2909
2976
  // top
@@ -2913,32 +2980,32 @@ class Dt {
2913
2980
  // left
2914
2981
  { x: i.x + i.width, y: i.y + i.height / 2, orientation: "vertical" }
2915
2982
  // right
2916
- ].forEach((B) => {
2917
- let L, W;
2918
- B.orientation === "horizontal" ? (L = h, W = a) : (L = a, W = h);
2919
- const O = B.x - L / 2, D = B.y - W / 2;
2920
- t.fillStyle = "#fff", t.fillRect(O, D, L, W), t.strokeStyle = "#bbb", t.lineWidth = c, t.strokeRect(O, D, L, W);
2983
+ ].forEach((I) => {
2984
+ let L, D;
2985
+ I.orientation === "horizontal" ? (L = h, D = a) : (L = a, D = h);
2986
+ const F = I.x - L / 2, W = I.y - D / 2;
2987
+ t.fillStyle = "#fff", t.fillRect(F, W, L, D), t.strokeStyle = "#bbb", t.lineWidth = c, t.strokeRect(F, W, L, D);
2921
2988
  }), t.restore(), o && o.resizeHandles) {
2922
- const B = o.resizeHandles.filter(
2923
- (D) => D.anchor === "top-left" || D.anchor === "top-right" || D.anchor === "bottom-left" || D.anchor === "bottom-right"
2924
- ), L = s.getCropBoxWorldCorners(), W = 6, O = 20;
2925
- B.forEach((D) => {
2926
- let F = !1;
2989
+ const I = o.resizeHandles.filter(
2990
+ (W) => W.anchor === "top-left" || W.anchor === "top-right" || W.anchor === "bottom-left" || W.anchor === "bottom-right"
2991
+ ), L = s.getCropBoxWorldCorners(), D = 6, F = 20;
2992
+ I.forEach((W) => {
2993
+ let q = !1;
2927
2994
  if (L)
2928
- for (const E of L) {
2929
- const $ = D.x - E.x, j = D.y - E.y;
2930
- if (Math.sqrt($ * $ + j * j) < O) {
2931
- F = !0;
2995
+ for (const J of L) {
2996
+ const E = W.x - J.x, z = W.y - J.y;
2997
+ if (Math.sqrt(E * E + z * z) < F) {
2998
+ q = !0;
2932
2999
  break;
2933
3000
  }
2934
3001
  }
2935
- F || (t.save(), t.globalAlpha = 1, t.beginPath(), t.arc(D.x * n, D.y * n, W, 0, 2 * Math.PI), t.fillStyle = "#fff", t.fill(), t.strokeStyle = tt(t.canvas), t.lineWidth = 2, t.stroke(), t.restore());
3002
+ q || (t.save(), t.globalAlpha = 1, t.beginPath(), t.arc(W.x * n, W.y * n, D, 0, 2 * Math.PI), t.fillStyle = "#fff", t.fill(), t.strokeStyle = nt(t.canvas), t.lineWidth = 2, t.stroke(), t.restore());
2936
3003
  });
2937
3004
  }
2938
3005
  }
2939
3006
  }
2940
- xe();
2941
- const De = $t("CanvasRenderer"), K = class K {
3007
+ Ae();
3008
+ const Ne = Zt("CanvasRenderer"), K = class K {
2942
3009
  /**
2943
3010
  * Get a pooled offscreen canvas for clipping content, only recreating
2944
3011
  * when dimensions change. Eliminates per-frame canvas allocation.
@@ -2962,7 +3029,7 @@ const De = $t("CanvasRenderer"), K = class K {
2962
3029
  e.render(t, o, n);
2963
3030
  } catch (s) {
2964
3031
  const i = s instanceof Error ? s : new Error(String(s));
2965
- De.error(`Failed to render element ${e.id}:`, i), K.onRenderError && K.onRenderError({
3032
+ Ne.error(`Failed to render element ${e.id}:`, i), K.onRenderError && K.onRenderError({
2966
3033
  category: "render",
2967
3034
  message: `Failed to render element: ${i.message}`,
2968
3035
  originalError: i,
@@ -2979,7 +3046,7 @@ const De = $t("CanvasRenderer"), K = class K {
2979
3046
  * Used by knockout rendering system
2980
3047
  */
2981
3048
  static renderElement(t, e, o = !0) {
2982
- o && (t.save(), t.globalAlpha = Q), e.render(t, !1, !1), o && t.restore();
3049
+ o && (t.save(), t.globalAlpha = tt), e.render(t, !1, !1), o && t.restore();
2983
3050
  }
2984
3051
  /**
2985
3052
  * Apply artboard clip path to the context, respecting clipShape.
@@ -3008,12 +3075,12 @@ const De = $t("CanvasRenderer"), K = class K {
3008
3075
  try {
3009
3076
  const l = new Path2D();
3010
3077
  for (const h of a.pieces) {
3011
- const c = new Path2D(h.d), d = h.rotation ?? 0, u = new DOMMatrix();
3012
- if (u.translateSelf(h.x, h.y), d !== 0) {
3013
- const p = (h.baseWidth ?? 0) / 2, b = (h.baseHeight ?? 0) / 2, g = d === 90 || d === 270, f = g ? h.baseHeight ?? 0 : h.baseWidth ?? 0, y = g ? h.baseWidth ?? 0 : h.baseHeight ?? 0;
3014
- u.translateSelf(f / 2, y / 2), u.rotateSelf(d), u.translateSelf(-p, -b);
3078
+ const c = new Path2D(h.d), d = h.rotation ?? 0, f = new DOMMatrix();
3079
+ if (f.translateSelf(h.x, h.y), d !== 0) {
3080
+ const b = (h.baseWidth ?? 0) / 2, u = (h.baseHeight ?? 0) / 2, p = d === 90 || d === 270, g = p ? h.baseHeight ?? 0 : h.baseWidth ?? 0, y = p ? h.baseWidth ?? 0 : h.baseHeight ?? 0;
3081
+ f.translateSelf(g / 2, y / 2), f.rotateSelf(d), f.translateSelf(-b, -u);
3015
3082
  }
3016
- l.addPath(c, u);
3083
+ l.addPath(c, f);
3017
3084
  }
3018
3085
  t.translate(o, n), t.clip(l), t.translate(-o, -n);
3019
3086
  return;
@@ -3028,23 +3095,23 @@ const De = $t("CanvasRenderer"), K = class K {
3028
3095
  */
3029
3096
  static renderElementWithOverflowDimming(t, e, o, n, s, i) {
3030
3097
  const a = t.getTransform(), r = o.borderRadius || 0;
3031
- t.save(), t.globalAlpha = 0.3 * (i ? Q : 1), t.filter = "blur(4px)", t.beginPath();
3032
- const h = t.getTransform().inverse(), c = t.canvas.width, d = t.canvas.height, u = new DOMPoint(0, 0).matrixTransform(h), p = new DOMPoint(c, d).matrixTransform(h), b = Math.max(p.x - u.x, p.y - u.y), g = u.x - b, f = u.y - b, y = p.x + b, m = p.y + b, T = typeof o.clipShape == "object" && o.clipShape !== null && o.clipShape.type === "composite-path" ? o.clipShape : null;
3033
- if (T) {
3034
- const v = new Path2D();
3035
- v.rect(g, f, y - g, m - f);
3036
- for (const S of T.pieces) {
3037
- const C = new Path2D(S.d), R = S.rotation ?? 0, x = new DOMMatrix();
3038
- if (x.translateSelf(o.x + S.x, o.y + S.y), R !== 0) {
3039
- const P = (S.baseWidth ?? 0) / 2, w = (S.baseHeight ?? 0) / 2, A = R === 90 || R === 270, B = A ? S.baseHeight ?? 0 : S.baseWidth ?? 0, L = A ? S.baseWidth ?? 0 : S.baseHeight ?? 0;
3040
- x.translateSelf(B / 2, L / 2), x.rotateSelf(R), x.translateSelf(-P, -w);
3098
+ t.save(), t.globalAlpha = 0.3 * (i ? tt : 1), t.filter = "blur(4px)", t.beginPath();
3099
+ const h = t.getTransform().inverse(), c = t.canvas.width, d = t.canvas.height, f = new DOMPoint(0, 0).matrixTransform(h), b = new DOMPoint(c, d).matrixTransform(h), u = Math.max(b.x - f.x, b.y - f.y), p = f.x - u, g = f.y - u, y = b.x + u, S = b.y + u, m = typeof o.clipShape == "object" && o.clipShape !== null && o.clipShape.type === "composite-path" ? o.clipShape : null;
3100
+ if (m) {
3101
+ const w = new Path2D();
3102
+ w.rect(p, g, y - p, S - g);
3103
+ for (const T of m.pieces) {
3104
+ const C = new Path2D(T.d), R = T.rotation ?? 0, x = new DOMMatrix();
3105
+ if (x.translateSelf(o.x + T.x, o.y + T.y), R !== 0) {
3106
+ const H = (T.baseWidth ?? 0) / 2, M = (T.baseHeight ?? 0) / 2, A = R === 90 || R === 270, I = A ? T.baseHeight ?? 0 : T.baseWidth ?? 0, L = A ? T.baseWidth ?? 0 : T.baseHeight ?? 0;
3107
+ x.translateSelf(I / 2, L / 2), x.rotateSelf(R), x.translateSelf(-H, -M);
3041
3108
  }
3042
- v.addPath(C, x);
3109
+ w.addPath(C, x);
3043
3110
  }
3044
- t.clip(v, "evenodd");
3111
+ t.clip(w, "evenodd");
3045
3112
  } else
3046
- t.rect(g, f, y - g, m - f), r > 0 ? t.roundRect(o.x, o.y, o.width, o.height, r) : t.rect(o.x, o.y, o.width, o.height), t.clip("evenodd");
3047
- e.render(t, !1, !1), t.restore(), t.save(), this.applyArtboardClipPath(t, o), i && (t.globalAlpha = Q), e.render(t, n, s), t.restore(), t.setTransform(a);
3113
+ t.rect(p, g, y - p, S - g), r > 0 ? t.roundRect(o.x, o.y, o.width, o.height, r) : t.rect(o.x, o.y, o.width, o.height), t.clip("evenodd");
3114
+ e.render(t, !1, !1), t.restore(), t.save(), this.applyArtboardClipPath(t, o), i && (t.globalAlpha = tt), e.render(t, n, s), t.restore(), t.setTransform(a);
3048
3115
  }
3049
3116
  /**
3050
3117
  * Render all elements layer
@@ -3057,56 +3124,56 @@ const De = $t("CanvasRenderer"), K = class K {
3057
3124
  */
3058
3125
  static renderElementsLayer(t, e, o, n, s, i, a, r = !0, l = !1, h = !1) {
3059
3126
  const c = s != null && s.getMode() === "drag", d = s == null ? void 0 : s._activeChildContext;
3060
- e !== K._cachedElementsRef && (K._cachedElementConfigs = e.map((f) => f.toJSON()), K._cachedElementMap = new Map(e.map((f) => [f.id, f])), K._cachedElementsRef = e);
3061
- const u = K._cachedElementConfigs, p = K._cachedElementMap, b = K._knockoutRenderedIds;
3062
- b.clear(), e.forEach((f, y) => {
3063
- var m, T, v;
3064
- if (f.blendMode === "knockout" || f.blendMode === "clip") {
3065
- const S = u[y], C = f.blendMode === "knockout" ? "destination-out" : "destination-in", R = ((m = S.knockoutParts) == null ? void 0 : m.scope) || "group", x = u.findIndex((B) => B.id === S.id), P = ((T = S.knockoutParts) == null ? void 0 : T.fill) || ((v = S.knockoutParts) == null ? void 0 : v.stroke), w = R === "artboard" && x !== -1 ? u.slice(0, x) : [];
3066
- P && (R === "artboard" || w.length > 0) && (w.forEach((B) => B.id && b.add(B.id)), we(
3127
+ e !== K._cachedElementsRef && (K._cachedElementConfigs = e.map((g) => g.toJSON()), K._cachedElementMap = new Map(e.map((g) => [g.id, g])), K._cachedElementsRef = e);
3128
+ const f = K._cachedElementConfigs, b = K._cachedElementMap, u = K._knockoutRenderedIds;
3129
+ u.clear(), e.forEach((g, y) => {
3130
+ var S, m, w;
3131
+ if (g.blendMode === "knockout" || g.blendMode === "clip") {
3132
+ const T = f[y], C = g.blendMode === "knockout" ? "destination-out" : "destination-in", R = ((S = T.knockoutParts) == null ? void 0 : S.scope) || "group", x = f.findIndex((I) => I.id === T.id), H = ((m = T.knockoutParts) == null ? void 0 : m.fill) || ((w = T.knockoutParts) == null ? void 0 : w.stroke), M = R === "artboard" && x !== -1 ? f.slice(0, x) : [];
3133
+ H && (R === "artboard" || M.length > 0) && (M.forEach((I) => I.id && u.add(I.id)), Re(
3067
3134
  t,
3068
- S,
3069
- u,
3070
- (B, L) => {
3071
- const W = L.id && p.get(L.id);
3072
- W && this.renderElement(B, W, r);
3135
+ T,
3136
+ f,
3137
+ (I, L) => {
3138
+ const D = L.id && b.get(L.id);
3139
+ D && this.renderElement(I, D, r);
3073
3140
  },
3074
3141
  i,
3075
3142
  a,
3076
3143
  C
3077
- ), b.add(f.id));
3144
+ ), u.add(g.id));
3078
3145
  }
3079
- }), e.some((f) => !b.has(f.id) && f.isClipping) ? this._renderWithClipping(
3146
+ }), e.some((g) => !u.has(g.id) && g.isClipping) ? this._renderWithClipping(
3080
3147
  t,
3081
3148
  e,
3082
- b,
3149
+ u,
3083
3150
  o,
3084
3151
  n,
3085
3152
  c,
3086
3153
  d,
3087
- u,
3154
+ f,
3088
3155
  r
3089
- ) : e.forEach((f) => {
3156
+ ) : e.forEach((g) => {
3090
3157
  var R, x;
3091
- if (b.has(f.id) || f.visible === !1) return;
3092
- const y = f.id === o, m = (n == null ? void 0 : n.type) === "element" && ((R = n == null ? void 0 : n.data) == null ? void 0 : R.id) === f.id, T = c && d && Lt(f) && f.id === o, v = y && !T, S = u[e.indexOf(f)], C = ((x = S == null ? void 0 : S.distressEffect) == null ? void 0 : x.enabled) && S.distressEffect.style === "custom" && S.distressEffect.textureUrl;
3093
- if (S && S.masks && S.masks.length > 0)
3094
- kt(t, S, (P) => {
3095
- const w = (A) => {
3096
- r && (A.save(), A.globalAlpha = Q), this.safeRender(A, f, v, m), r && A.restore();
3158
+ if (u.has(g.id) || g.visible === !1) return;
3159
+ const y = g.id === o, S = (n == null ? void 0 : n.type) === "element" && ((R = n == null ? void 0 : n.data) == null ? void 0 : R.id) === g.id, m = c && d && Dt(g) && g.id === o, w = y && !m, T = f[e.indexOf(g)], C = ((x = T == null ? void 0 : T.distressEffect) == null ? void 0 : x.enabled) && T.distressEffect.style === "custom" && T.distressEffect.textureUrl;
3160
+ if (T && T.masks && T.masks.length > 0)
3161
+ At(t, T, (H) => {
3162
+ const M = (A) => {
3163
+ r && (A.save(), A.globalAlpha = tt), this.safeRender(A, g, w, S), r && A.restore();
3097
3164
  };
3098
3165
  if (C) {
3099
- const A = f.getVisualBoundingBox();
3100
- Yt(P, S.distressEffect, A, w);
3166
+ const A = g.getVisualBoundingBox();
3167
+ Kt(H, T.distressEffect, A, M);
3101
3168
  } else
3102
- w(P);
3169
+ M(H);
3103
3170
  });
3104
3171
  else if (C) {
3105
- const P = f.getVisualBoundingBox();
3106
- Yt(t, S.distressEffect, P, (w) => {
3107
- r && (w.save(), w.globalAlpha = Q), this.safeRender(w, f, v, m), r && w.restore();
3172
+ const H = g.getVisualBoundingBox();
3173
+ Kt(t, T.distressEffect, H, (M) => {
3174
+ r && (M.save(), M.globalAlpha = tt), this.safeRender(M, g, w, S), r && M.restore();
3108
3175
  });
3109
- } else l && !h && a && v ? this.renderElementWithOverflowDimming(t, f, a, v, m, r) : l && a ? (t.save(), this.applyArtboardClipPath(t, a), r && (t.globalAlpha = Q), this.safeRender(t, f, v, m), t.restore()) : (r && (t.save(), t.globalAlpha = Q), this.safeRender(t, f, v, m), r && t.restore());
3176
+ } else l && !h && a && w ? this.renderElementWithOverflowDimming(t, g, a, w, S, r) : l && a ? (t.save(), this.applyArtboardClipPath(t, a), r && (t.globalAlpha = tt), this.safeRender(t, g, w, S), t.restore()) : (r && (t.save(), t.globalAlpha = tt), this.safeRender(t, g, w, S), r && t.restore());
3110
3177
  });
3111
3178
  }
3112
3179
  /**
@@ -3114,51 +3181,51 @@ const De = $t("CanvasRenderer"), K = class K {
3114
3181
  * Elements with isClipping=true clip all elements below them
3115
3182
  */
3116
3183
  static _renderWithClipping(t, e, o, n, s, i, a, r, l = !0) {
3117
- var f;
3118
- const h = t.canvas, c = h.width, d = h.height, u = t.getTransform(), p = [];
3119
- let b = [], g = [];
3184
+ var g;
3185
+ const h = t.canvas, c = h.width, d = h.height, f = t.getTransform(), b = [];
3186
+ let u = [], p = [];
3120
3187
  for (let y = 0; y < e.length; y++) {
3121
- const m = e[y], T = r[y];
3122
- o.has(m.id) || m.visible !== !1 && (m.isClipping ? b.length > 0 ? (p.push({
3123
- content: b,
3124
- mask: m,
3125
- contentConfigs: g,
3126
- maskConfig: T
3127
- }), b = [], g = []) : p.push({
3128
- content: [m],
3129
- contentConfigs: [T]
3130
- }) : (b.push(m), g.push(T)));
3188
+ const S = e[y], m = r[y];
3189
+ o.has(S.id) || S.visible !== !1 && (S.isClipping ? u.length > 0 ? (b.push({
3190
+ content: u,
3191
+ mask: S,
3192
+ contentConfigs: p,
3193
+ maskConfig: m
3194
+ }), u = [], p = []) : b.push({
3195
+ content: [S],
3196
+ contentConfigs: [m]
3197
+ }) : (u.push(S), p.push(m)));
3131
3198
  }
3132
- b.length > 0 && p.push({
3133
- content: b,
3134
- contentConfigs: g
3199
+ u.length > 0 && b.push({
3200
+ content: u,
3201
+ contentConfigs: p
3135
3202
  });
3136
- for (const y of p)
3203
+ for (const y of b)
3137
3204
  if (!y.mask)
3138
- y.content.forEach((m, T) => {
3139
- var P;
3140
- const v = m.id === n, S = (s == null ? void 0 : s.type) === "element" && ((P = s == null ? void 0 : s.data) == null ? void 0 : P.id) === m.id, C = i && a && Lt(m) && m.id === n, R = v && !C, x = y.contentConfigs[T];
3141
- x && x.masks && x.masks.length > 0 ? kt(t, x, (w) => {
3142
- l && (w.save(), w.globalAlpha = Q), m.render(w, R, S), l && w.restore();
3143
- }) : (l && (t.save(), t.globalAlpha = Q), m.render(t, R, S), l && t.restore());
3205
+ y.content.forEach((S, m) => {
3206
+ var H;
3207
+ const w = S.id === n, T = (s == null ? void 0 : s.type) === "element" && ((H = s == null ? void 0 : s.data) == null ? void 0 : H.id) === S.id, C = i && a && Dt(S) && S.id === n, R = w && !C, x = y.contentConfigs[m];
3208
+ x && x.masks && x.masks.length > 0 ? At(t, x, (M) => {
3209
+ l && (M.save(), M.globalAlpha = tt), S.render(M, R, T), l && M.restore();
3210
+ }) : (l && (t.save(), t.globalAlpha = tt), S.render(t, R, T), l && t.restore());
3144
3211
  });
3145
3212
  else {
3146
- const m = this._getContentCanvas(c, d), T = m.getContext("2d");
3147
- if (!T) continue;
3148
- T.setTransform(1, 0, 0, 1, 0, 0), T.clearRect(0, 0, c, d), T.globalCompositeOperation = "source-over", T.setTransform(u), y.content.forEach((x, P) => {
3149
- var O;
3150
- const w = x.id === n, A = (s == null ? void 0 : s.type) === "element" && ((O = s == null ? void 0 : s.data) == null ? void 0 : O.id) === x.id, B = i && a && Lt(x) && x.id === n, L = w && !B, W = y.contentConfigs[P];
3151
- W && W.masks && W.masks.length > 0 ? kt(T, W, (D) => {
3152
- l && (D.save(), D.globalAlpha = Q), x.render(D, L, A), l && D.restore();
3153
- }) : (l && (T.save(), T.globalAlpha = Q), x.render(T, L, A), l && T.restore());
3213
+ const S = this._getContentCanvas(c, d), m = S.getContext("2d");
3214
+ if (!m) continue;
3215
+ m.setTransform(1, 0, 0, 1, 0, 0), m.clearRect(0, 0, c, d), m.globalCompositeOperation = "source-over", m.setTransform(f), y.content.forEach((x, H) => {
3216
+ var F;
3217
+ const M = x.id === n, A = (s == null ? void 0 : s.type) === "element" && ((F = s == null ? void 0 : s.data) == null ? void 0 : F.id) === x.id, I = i && a && Dt(x) && x.id === n, L = M && !I, D = y.contentConfigs[H];
3218
+ D && D.masks && D.masks.length > 0 ? At(m, D, (W) => {
3219
+ l && (W.save(), W.globalAlpha = tt), x.render(W, L, A), l && W.restore();
3220
+ }) : (l && (m.save(), m.globalAlpha = tt), x.render(m, L, A), l && m.restore());
3154
3221
  });
3155
- const v = this._getMaskCanvas(c, d), S = v.getContext("2d");
3156
- if (!S) continue;
3157
- S.setTransform(1, 0, 0, 1, 0, 0), S.clearRect(0, 0, c, d), S.globalCompositeOperation = "source-over", S.setTransform(u);
3158
- const C = y.mask.id === n, R = (s == null ? void 0 : s.type) === "element" && ((f = s == null ? void 0 : s.data) == null ? void 0 : f.id) === y.mask.id;
3159
- y.maskConfig && y.maskConfig.masks && y.maskConfig.masks.length > 0 ? kt(S, y.maskConfig, (x) => {
3160
- l && (x.save(), x.globalAlpha = Q), y.mask.render(x, C, R), l && x.restore();
3161
- }) : (l && (S.save(), S.globalAlpha = Q), y.mask.render(S, C, R), l && S.restore()), T.globalCompositeOperation = "destination-in", T.setTransform(1, 0, 0, 1, 0, 0), T.drawImage(v, 0, 0), t.save(), t.setTransform(1, 0, 0, 1, 0, 0), t.drawImage(m, 0, 0), t.restore();
3222
+ const w = this._getMaskCanvas(c, d), T = w.getContext("2d");
3223
+ if (!T) continue;
3224
+ T.setTransform(1, 0, 0, 1, 0, 0), T.clearRect(0, 0, c, d), T.globalCompositeOperation = "source-over", T.setTransform(f);
3225
+ const C = y.mask.id === n, R = (s == null ? void 0 : s.type) === "element" && ((g = s == null ? void 0 : s.data) == null ? void 0 : g.id) === y.mask.id;
3226
+ y.maskConfig && y.maskConfig.masks && y.maskConfig.masks.length > 0 ? At(T, y.maskConfig, (x) => {
3227
+ l && (x.save(), x.globalAlpha = tt), y.mask.render(x, C, R), l && x.restore();
3228
+ }) : (l && (T.save(), T.globalAlpha = tt), y.mask.render(T, C, R), l && T.restore()), m.globalCompositeOperation = "destination-in", m.setTransform(1, 0, 0, 1, 0, 0), m.drawImage(w, 0, 0), t.save(), t.setTransform(1, 0, 0, 1, 0, 0), t.drawImage(S, 0, 0), t.restore();
3162
3229
  }
3163
3230
  }
3164
3231
  // =========================================================================
@@ -3190,21 +3257,21 @@ const De = $t("CanvasRenderer"), K = class K {
3190
3257
  * @see SelectionRenderer.renderSelectionLayer
3191
3258
  */
3192
3259
  static renderSelectionLayer(t, e, o, n = 1) {
3193
- mt.renderSelectionLayer(t, e, o, n);
3260
+ wt.renderSelectionLayer(t, e, o, n);
3194
3261
  }
3195
3262
  /**
3196
3263
  * Render position and size info below the selected element
3197
3264
  * @see SelectionRenderer.renderPositionSizeInfo
3198
3265
  */
3199
3266
  static renderPositionSizeInfo(t, e, o, n, s = 1) {
3200
- mt.renderPositionSizeInfo(t, e, o, n, s);
3267
+ wt.renderPositionSizeInfo(t, e, o, n, s);
3201
3268
  }
3202
3269
  /**
3203
3270
  * Render transform handles layer
3204
3271
  * @see SelectionRenderer.renderHandlesLayer
3205
3272
  */
3206
3273
  static renderHandlesLayer(t, e, o, n, s, i, a, r = 1, l = !0) {
3207
- mt.renderHandlesLayer(
3274
+ wt.renderHandlesLayer(
3208
3275
  t,
3209
3276
  e,
3210
3277
  o,
@@ -3221,14 +3288,14 @@ const De = $t("CanvasRenderer"), K = class K {
3221
3288
  * @see HoverRenderer.renderHoverLayer
3222
3289
  */
3223
3290
  static renderHoverLayer(t, e, o, n = !1, s = 1, i) {
3224
- _t.renderHoverLayer(t, e, o, n, s, i);
3291
+ Vt.renderHoverLayer(t, e, o, n, s, i);
3225
3292
  }
3226
3293
  /**
3227
3294
  * Render crop box layer (for images in crop mode)
3228
3295
  * @see EditModeRenderer.renderCropBoxLayer
3229
3296
  */
3230
3297
  static renderCropBoxLayer(t, e, o, n = 1) {
3231
- Dt.renderCropBoxLayer(t, e, o, n);
3298
+ zt.renderCropBoxLayer(t, e, o, n);
3232
3299
  }
3233
3300
  // =========================================================================
3234
3301
  // Main Render Orchestration
@@ -3257,13 +3324,13 @@ const De = $t("CanvasRenderer"), K = class K {
3257
3324
  artboardBackgroundColor: h,
3258
3325
  artboard: c,
3259
3326
  isPreview: d = !0,
3260
- zoom: u = 1,
3261
- paddingOffset: p = { x: 0, y: 0 },
3262
- showOverflowDimmed: b = !1,
3263
- suppressOverflowDim: g = !1,
3264
- distressTexture: f,
3327
+ zoom: f = 1,
3328
+ paddingOffset: b = { x: 0, y: 0 },
3329
+ showOverflowDimmed: u = !1,
3330
+ suppressOverflowDim: p = !1,
3331
+ distressTexture: g,
3265
3332
  imageMask: y,
3266
- editModeData: m
3333
+ editModeData: S
3267
3334
  }) {
3268
3335
  if (this.renderElementsLayer(
3269
3336
  t,
@@ -3274,33 +3341,33 @@ const De = $t("CanvasRenderer"), K = class K {
3274
3341
  h,
3275
3342
  c,
3276
3343
  d,
3277
- b,
3278
- g
3279
- ), f != null && f.enabled && c && Ce(t, f, c, h), y != null && y.enabled && c && Me(t, y, c, h), i && m && n && Dt.renderEditModeLayer(t, n, m, u), u !== 1) {
3344
+ u,
3345
+ p
3346
+ ), g != null && g.enabled && c && ke(t, g, c, h), y != null && y.enabled && c && Pe(t, y, c, h), i && S && n && zt.renderEditModeLayer(t, n, S, f), f !== 1) {
3280
3347
  t.save();
3281
- const C = t.getTransform().a / u, R = p.x * u * C, x = p.y * u * C;
3348
+ const C = t.getTransform().a / f, R = b.x * f * C, x = b.y * f * C;
3282
3349
  t.setTransform(C, 0, 0, C, R, x);
3283
3350
  }
3284
- const T = r.map((S) => ({
3285
- ...S,
3286
- x: S.x !== void 0 ? S.x * u : void 0,
3287
- y: S.y !== void 0 ? S.y * u : void 0,
3288
- x1: S.x1 !== void 0 ? S.x1 * u : void 0,
3289
- y1: S.y1 !== void 0 ? S.y1 * u : void 0,
3290
- x2: S.x2 !== void 0 ? S.x2 * u : void 0,
3291
- y2: S.y2 !== void 0 ? S.y2 * u : void 0
3292
- })), v = l.map((S) => ({
3293
- ...S,
3294
- x: S.x !== void 0 ? S.x * u : void 0,
3295
- y: S.y !== void 0 ? S.y * u : void 0,
3296
- x1: S.x1 !== void 0 ? S.x1 * u : void 0,
3297
- y1: S.y1 !== void 0 ? S.y1 * u : void 0,
3298
- x2: S.x2 !== void 0 ? S.x2 * u : void 0,
3299
- y2: S.y2 !== void 0 ? S.y2 * u : void 0,
3300
- labelX: S.labelX * u,
3301
- labelY: S.labelY * u
3351
+ const m = r.map((T) => ({
3352
+ ...T,
3353
+ x: T.x !== void 0 ? T.x * f : void 0,
3354
+ y: T.y !== void 0 ? T.y * f : void 0,
3355
+ x1: T.x1 !== void 0 ? T.x1 * f : void 0,
3356
+ y1: T.y1 !== void 0 ? T.y1 * f : void 0,
3357
+ x2: T.x2 !== void 0 ? T.x2 * f : void 0,
3358
+ y2: T.y2 !== void 0 ? T.y2 * f : void 0
3359
+ })), w = l.map((T) => ({
3360
+ ...T,
3361
+ x: T.x !== void 0 ? T.x * f : void 0,
3362
+ y: T.y !== void 0 ? T.y * f : void 0,
3363
+ x1: T.x1 !== void 0 ? T.x1 * f : void 0,
3364
+ y1: T.y1 !== void 0 ? T.y1 * f : void 0,
3365
+ x2: T.x2 !== void 0 ? T.x2 * f : void 0,
3366
+ y2: T.y2 !== void 0 ? T.y2 * f : void 0,
3367
+ labelX: T.labelX * f,
3368
+ labelY: T.labelY * f
3302
3369
  }));
3303
- Ct.renderSnapGuidesLayer(t, T), Ct.renderSpacingIndicatorsLayer(t, v), u !== 1 && t.restore();
3370
+ Ct.renderSnapGuidesLayer(t, m), Ct.renderSpacingIndicatorsLayer(t, w), f !== 1 && t.restore();
3304
3371
  }
3305
3372
  /**
3306
3373
  * Single-selection interaction chrome: bbox, handles, position/size
@@ -3327,19 +3394,19 @@ const De = $t("CanvasRenderer"), K = class K {
3327
3394
  isEditing: h,
3328
3395
  isAltKeyPressed: c = !1,
3329
3396
  artboardBackgroundColor: d,
3330
- hoverClipArtboard: u,
3331
- showRotationHandle: p = !0,
3332
- zoom: b = 1,
3333
- paddingOffset: g = { x: 0, y: 0 }
3397
+ hoverClipArtboard: f,
3398
+ showRotationHandle: b = !0,
3399
+ zoom: u = 1,
3400
+ paddingOffset: p = { x: 0, y: 0 }
3334
3401
  }) {
3335
- if (b !== 1) {
3402
+ if (u !== 1) {
3336
3403
  t.save();
3337
- const m = t.getTransform().a / b, T = g.x * b * m, v = g.y * b * m;
3338
- t.setTransform(m, 0, 0, m, T, v);
3404
+ const S = t.getTransform().a / u, m = p.x * u * S, w = p.y * u * S;
3405
+ t.setTransform(S, 0, 0, S, m, w);
3339
3406
  }
3340
- if (e && Re(e) && e.isCropping)
3341
- o && Dt.renderCropBoxLayer(t, e, o, b);
3342
- else if (!l && n && mt.renderSelectionLayer(t, e, n, b), o && n && mt.renderPositionSizeInfo(t, e, o, n, b), !l && o && n && mt.renderHandlesLayer(
3407
+ if (e && Ee(e) && e.isCropping)
3408
+ o && zt.renderCropBoxLayer(t, e, o, u);
3409
+ else if (!l && n && wt.renderSelectionLayer(t, e, n, u), o && n && wt.renderPositionSizeInfo(t, e, o, n, u), !l && o && n && wt.renderHandlesLayer(
3343
3410
  t,
3344
3411
  e,
3345
3412
  o,
@@ -3347,33 +3414,34 @@ const De = $t("CanvasRenderer"), K = class K {
3347
3414
  i,
3348
3415
  a,
3349
3416
  n,
3350
- b,
3351
- p
3417
+ u,
3418
+ b
3352
3419
  ), !h) {
3353
- if (u) {
3420
+ if (f) {
3354
3421
  t.save();
3355
- const y = u, m = y.x * b, T = y.y * b, v = y.width * b, S = y.height * b, C = (y.borderRadius ?? 0) * b;
3356
- t.beginPath(), C > 0 ? t.roundRect(m, T, v, S, C) : t.rect(m, T, v, S), t.clip();
3422
+ const y = f, S = y.x * u, m = y.y * u, w = y.width * u, T = y.height * u, C = (y.borderRadius ?? 0) * u;
3423
+ t.beginPath(), C > 0 ? t.roundRect(S, m, w, T, C) : t.rect(S, m, w, T), t.clip();
3357
3424
  }
3358
- _t.renderHoverLayer(t, a, r, c, b, d), u && t.restore();
3425
+ Vt.renderHoverLayer(t, a, r, c, u, d), f && t.restore();
3359
3426
  }
3360
- b !== 1 && t.restore();
3427
+ u !== 1 && t.restore();
3361
3428
  }
3362
3429
  };
3363
3430
  K._contentCanvas = null, K._contentCanvasSize = { width: 0, height: 0 }, K._maskCanvas = null, K._maskCanvasSize = { width: 0, height: 0 }, K._cachedElementsRef = null, K._cachedElementConfigs = null, K._cachedElementMap = null, K._knockoutRenderedIds = /* @__PURE__ */ new Set(), K.onRenderError = null;
3364
- let Kt = K;
3431
+ let Ut = K;
3365
3432
  export {
3366
- Ke as A,
3367
- Kt as C,
3368
- Ne as I,
3369
- Le as R,
3370
- $e as S,
3371
- Ge as T,
3372
- Jt as a,
3373
- Oe as b,
3374
- Fe as c,
3375
- Xe as d,
3376
- Gt as g,
3377
- Ye as r
3433
+ en as A,
3434
+ Ut as C,
3435
+ tn as I,
3436
+ Ge as R,
3437
+ nn as S,
3438
+ Je as T,
3439
+ ne as a,
3440
+ Ue as b,
3441
+ qe as c,
3442
+ Ve as d,
3443
+ Qe as e,
3444
+ $t as g,
3445
+ Ze as r
3378
3446
  };
3379
- //# sourceMappingURL=CanvasRenderer-yszzrDfo.js.map
3447
+ //# sourceMappingURL=CanvasRenderer-_lFoIoz5.js.map