@snowcone-app/canvas 0.1.10 → 0.1.13

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 (48) hide show
  1. package/dist/{CanvasStateV1-BmE5V6me.cjs → CanvasStateV1-C4hC1MCe.cjs} +5 -5
  2. package/dist/{CanvasStateV1-BmE5V6me.cjs.map → CanvasStateV1-C4hC1MCe.cjs.map} +1 -1
  3. package/dist/{CanvasStateV1-CD3Q94F4.js → CanvasStateV1-CJU_xYW5.js} +3 -3
  4. package/dist/{CanvasStateV1-CD3Q94F4.js.map → CanvasStateV1-CJU_xYW5.js.map} +1 -1
  5. package/dist/{HybridHistoryManager-BV6XV0nD.js → HybridHistoryManager-jBBnVim8.js} +54 -54
  6. package/dist/{HybridHistoryManager-BV6XV0nD.js.map → HybridHistoryManager-jBBnVim8.js.map} +1 -1
  7. package/dist/{ElementFactory-Ckv6sSev.js → ImportManager-Oqu2yB54.js} +595 -378
  8. package/dist/ImportManager-Oqu2yB54.js.map +1 -0
  9. package/dist/{ElementFactory-DEjwp-Wg.cjs → ImportManager-W1eWhfyM.cjs} +5 -5
  10. package/dist/ImportManager-W1eWhfyM.cjs.map +1 -0
  11. package/dist/ThemeContext-BMNQKl1c.cjs +2 -0
  12. package/dist/{ThemeContext-4mJ_y0Me.cjs.map → ThemeContext-BMNQKl1c.cjs.map} +1 -1
  13. package/dist/ThemeContext-wj-wSO7J.js +1158 -0
  14. package/dist/{ThemeContext-H0Z-MqqR.js.map → ThemeContext-wj-wSO7J.js.map} +1 -1
  15. package/dist/advanced.js +5 -32
  16. package/dist/advanced.js.map +1 -1
  17. package/dist/advanced.mjs +588 -15069
  18. package/dist/advanced.mjs.map +1 -1
  19. package/dist/components/embed/KitLayout.d.ts +22 -0
  20. package/dist/components/embed/UndoRedoControls.d.ts +3 -0
  21. package/dist/compose-Dqh2f8tS.js +22222 -0
  22. package/dist/compose-Dqh2f8tS.js.map +1 -0
  23. package/dist/compose-HDJp4Z_d.cjs +60 -0
  24. package/dist/compose-HDJp4Z_d.cjs.map +1 -0
  25. package/dist/index.js +1 -1
  26. package/dist/index.js.map +1 -1
  27. package/dist/index.mjs +600 -516
  28. package/dist/index.mjs.map +1 -1
  29. package/dist/internals.js +1 -1
  30. package/dist/internals.js.map +1 -1
  31. package/dist/internals.mjs +101 -102
  32. package/dist/internals.mjs.map +1 -1
  33. package/dist/style.css.d.ts +4 -0
  34. package/dist/testing.js +1 -1
  35. package/dist/testing.mjs +11 -11
  36. package/package.json +8 -4
  37. package/dist/ElementFactory-Ckv6sSev.js.map +0 -1
  38. package/dist/ElementFactory-DEjwp-Wg.cjs.map +0 -1
  39. package/dist/ImportManager-64OYjELO.js +0 -222
  40. package/dist/ImportManager-64OYjELO.js.map +0 -1
  41. package/dist/ImportManager-wSzrR-5a.cjs +0 -2
  42. package/dist/ImportManager-wSzrR-5a.cjs.map +0 -1
  43. package/dist/ThemeContext-4mJ_y0Me.cjs +0 -2
  44. package/dist/ThemeContext-H0Z-MqqR.js +0 -1077
  45. package/dist/compose-DHBRwi_A.cjs +0 -33
  46. package/dist/compose-DHBRwi_A.cjs.map +0 -1
  47. package/dist/compose-DIPiisIw.js +0 -7690
  48. package/dist/compose-DIPiisIw.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { Y as en, aq as ut, ar as ht, ax as Se, a9 as pt, a7 as gt, a0 as Ce, a6 as bt, $ as pn, aL as mt, aM as ke, c as xn, aN as yt, aO as xt, G as Ve, I as Un, P as je, S as Xe, T as $t, aH as vt, aG as wt, ab as St, aP as ne, aQ as Ct, aR as kt, aS as Tt, aT as _t, aU as qe, aI as Ye, U as Xn, aJ as Ke, aV as ie, aW as Et, am as At, aX as Pt, aY as Te, aZ as It, a_ as Dt, a$ as Rt, aE as Ft, b0 as Mt, b1 as Ot, b2 as nn, ah as Bt, al as Lt, ae as Nt, ac as Ut, aj as zt, af as Wt, aa as Ht } from "./HybridHistoryManager-BV6XV0nD.js";
1
+ import { K as en, aq as bt, ar as mt, ax as ke, $ as yt, Z as xt, O as Te, Y as $t, N as pn, aL as vt, aM as _e, c as mn, aN as wt, aO as St, G as Ke, I as Un, P as Je, S as Ze, T as Ct, aH as kt, aG as Tt, ab as _t, aP as ee, aQ as Et, aR as At, aS as Pt, aT as It, aU as Qe, aI as nt, H as Xn, aJ as et, aV as oe, aW as Dt, am as Rt, aX as Ft, aY as Ee, aZ as Mt, a_ as Ot, a$ as Bt, aE as Lt, b0 as Nt, b1 as Ut, b2 as nn, ah as zt, al as Wt, ae as Ht, ac as Gt, aj as Vt, af as jt, a0 as Xt, A as Ae } from "./HybridHistoryManager-jBBnVim8.js";
2
2
  const sn = {
3
3
  // Canvas-specific
4
4
  canvas: {
@@ -16,30 +16,30 @@ const sn = {
16
16
  spacingLabelFontSize: 11,
17
17
  spacingLabelFontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
18
18
  }
19
- }, Gt = 2, Bn = 6, Vt = 16, jt = 5, Xt = 5, Je = 0.5;
20
- function _e(i) {
21
- return Gt / i;
19
+ }, qt = 2, Bn = 6, Yt = 16, Kt = 5, Jt = 5, tt = 0.5;
20
+ function Pe(i) {
21
+ return qt / i;
22
22
  }
23
- function Ja(i) {
23
+ function er(i) {
24
24
  return Bn / i;
25
25
  }
26
- function qt(i) {
27
- return Vt / i;
26
+ function Zt(i) {
27
+ return Yt / i;
28
28
  }
29
- function Za(i) {
30
- return [jt / i, Xt / i];
29
+ function tr(i) {
30
+ return [Kt / i, Jt / i];
31
31
  }
32
- function Yt(i, n, e, t) {
32
+ function Qt(i, n, e, t) {
33
33
  i.save();
34
- const a = Je / t;
34
+ const a = tt / t;
35
35
  i.translate(n, e), i.scale(a, a), i.strokeStyle = "#000", i.lineWidth = 1.5, i.lineCap = "round", i.lineJoin = "round", i.translate(-12, -12), i.beginPath(), i.moveTo(21, 12), i.arc(12, 12, 9, 0, -Math.PI / 2, !0), i.bezierCurveTo(3.5, 4.5, 4, 6, 3, 8), i.stroke(), i.beginPath(), i.moveTo(3, 3), i.lineTo(3, 8), i.lineTo(8, 8), i.stroke(), i.beginPath(), i.moveTo(3, 12), i.arc(12, 12, 9, Math.PI, Math.PI / 2, !0), i.bezierCurveTo(20.5, 19.5, 20, 18, 21, 16), i.stroke(), i.beginPath(), i.moveTo(16, 16), i.lineTo(21, 16), i.lineTo(21, 21), i.stroke(), i.restore();
36
36
  }
37
- function Qa(i, n, e, t = 1, a = "#3b82f6", r = !1) {
38
- const s = qt(t);
39
- i.save(), i.fillStyle = "#fff", i.strokeStyle = a, i.lineWidth = r ? _e(t) * 1.25 : _e(t), i.beginPath(), i.arc(n, e, s, 0, Math.PI * 2), i.fill(), i.stroke(), Yt(i, n, e, t), i.restore();
37
+ function ar(i, n, e, t = 1, a = "#3b82f6", r = !1) {
38
+ const s = Zt(t);
39
+ i.save(), i.fillStyle = "#fff", i.strokeStyle = a, i.lineWidth = r ? Pe(t) * 1.25 : Pe(t), i.beginPath(), i.arc(n, e, s, 0, Math.PI * 2), i.fill(), i.stroke(), Qt(i, n, e, t), i.restore();
40
40
  }
41
- const Ee = Bn * 2;
42
- class nr {
41
+ const Ie = Bn * 2;
42
+ class rr {
43
43
  constructor() {
44
44
  this.resizeHandles = [], this.rotationHandle = null, this.elementRotation = 0, this.rotationAnchor = { x: 0, y: 0 };
45
45
  }
@@ -56,8 +56,8 @@ class nr {
56
56
  y: a.y - o,
57
57
  width: a.width + o * 2,
58
58
  height: a.height + o * 2
59
- }, c = ut(l, n.rotation, r), d = Math.abs(n.rotation % 360) > 0.1;
60
- this.resizeHandles = c.filter((f) => !(!s.includes(f.anchor) || d && f.anchor.includes("middle"))), this.rotationHandle = ht(
59
+ }, c = bt(l, n.rotation, r), d = Math.abs(n.rotation % 360) > 0.1;
60
+ this.resizeHandles = c.filter((f) => !(!s.includes(f.anchor) || d && f.anchor.includes("middle"))), this.rotationHandle = mt(
61
61
  l,
62
62
  n.rotation,
63
63
  r,
@@ -86,7 +86,7 @@ class nr {
86
86
  if (e.anchor.includes("middle")) {
87
87
  const c = e.anchor === "middle-top" || e.anchor === "middle-bottom";
88
88
  n.translate(s, o), n.rotate(-this.elementRotation * Math.PI / 180), c && n.rotate(Math.PI / 2), n.translate(-s, -o);
89
- const d = Ee * 0.6, f = Ee * 1.4, h = d / 2, u = s - d / 2, g = o - f / 2;
89
+ const d = Ie * 0.6, f = Ie * 1.4, h = d / 2, u = s - d / 2, g = o - f / 2;
90
90
  n.fillStyle = "#fff", n.strokeStyle = en(n.canvas), n.lineWidth = t || a ? 2.5 : 2, n.beginPath(), n.roundRect(u, g, d, f, h), n.fill(), n.stroke();
91
91
  } else
92
92
  n.fillStyle = "#fff", n.strokeStyle = en(n.canvas), n.lineWidth = t || a ? 2.5 : 2, n.beginPath(), n.arc(s, o, Bn, 0, Math.PI * 2), n.fill(), n.stroke();
@@ -100,7 +100,7 @@ class nr {
100
100
  n.save();
101
101
  const r = e.x * a, s = e.y * a, o = Bn * 2.67;
102
102
  n.fillStyle = "#fff", n.strokeStyle = en(n.canvas), n.lineWidth = t ? 2.5 : 2, n.beginPath(), n.arc(r, s, o, 0, Math.PI * 2), n.fill(), n.stroke();
103
- const l = Je;
103
+ const l = tt;
104
104
  n.translate(r, s), n.scale(l, l), n.strokeStyle = "#000", n.lineWidth = 1.5, n.lineCap = "round", n.lineJoin = "round", n.translate(-12, -12), n.beginPath(), n.moveTo(21, 12), n.arc(12, 12, 9, 0, -Math.PI / 2, !0), n.bezierCurveTo(3.5, 4.5, 4, 6, 3, 8), n.stroke(), n.beginPath(), n.moveTo(3, 3), n.lineTo(3, 8), n.lineTo(8, 8), n.stroke(), n.beginPath(), n.moveTo(3, 12), n.arc(12, 12, 9, Math.PI, Math.PI / 2, !0), n.bezierCurveTo(20.5, 19.5, 20, 18, 21, 16), n.stroke(), n.beginPath(), n.moveTo(16, 16), n.lineTo(21, 16), n.lineTo(21, 21), n.stroke(), n.restore();
105
105
  }
106
106
  /**
@@ -116,9 +116,9 @@ class nr {
116
116
  * @param zoom - Current zoom level (radius scales inversely with zoom)
117
117
  */
118
118
  hitTestResize(n, e, t = 1) {
119
- const a = gt / t;
119
+ const a = xt / t;
120
120
  for (const r of this.resizeHandles)
121
- if (Se(n, e, r.x, r.y, a))
121
+ if (ke(n, e, r.x, r.y, a))
122
122
  return r;
123
123
  return null;
124
124
  }
@@ -129,7 +129,7 @@ class nr {
129
129
  hitTestRotation(n, e, t = 1) {
130
130
  if (!this.rotationHandle) return !1;
131
131
  const a = (Bn * 2.67 + 2) / t;
132
- return Se(n, e, this.rotationHandle.x, this.rotationHandle.y, a);
132
+ return ke(n, e, this.rotationHandle.x, this.rotationHandle.y, a);
133
133
  }
134
134
  /**
135
135
  * Get rotation handle position (for React-based rendering)
@@ -144,7 +144,7 @@ class nr {
144
144
  */
145
145
  getCursor(n, e) {
146
146
  const t = n.anchor.includes("middle") ? "edge" : "corner";
147
- return pt(
147
+ return yt(
148
148
  n.x,
149
149
  n.y,
150
150
  this.rotationAnchor.x,
@@ -155,7 +155,7 @@ class nr {
155
155
  );
156
156
  }
157
157
  }
158
- class Kt {
158
+ class na {
159
159
  /**
160
160
  * Calculate new dimensions and position for a resize operation
161
161
  */
@@ -168,7 +168,7 @@ class Kt {
168
168
  snapSystem: s
169
169
  }) {
170
170
  var I, A, R, z, O;
171
- const l = new Ce(n).worldDeltaToLocal(t, a), c = l.dx, d = l.dy, f = r.visualWidth ?? r.width ?? 0, h = r.visualHeight ?? r.height ?? 0, u = r.width ?? 0, g = r.height ?? 0;
171
+ const l = new Te(n).worldDeltaToLocal(t, a), c = l.dx, d = l.dy, f = r.visualWidth ?? r.width ?? 0, h = r.visualHeight ?? r.height ?? 0, u = r.width ?? 0, g = r.height ?? 0;
172
172
  let m = f, p = h;
173
173
  e.anchor.includes("right") ? m = f + c : e.anchor.includes("left") && (m = f - c), e.anchor !== "middle-left" && e.anchor !== "middle-right" && (e.anchor.includes("bottom") ? p = h + d : e.anchor.includes("top") && (p = h - d));
174
174
  let y, b;
@@ -236,7 +236,7 @@ class Kt {
236
236
  handle: t,
237
237
  rotationAnchor: a
238
238
  }) {
239
- const r = new Ce(n), { cos: s, sin: o } = r.getRenderingCosSin(), l = n.getVisualBoundingBox(), c = e.getVisualBoundingBox(), d = a, f = e.getRotationAnchor(), h = this._getFixedLocalCoords(t.anchor, l.width, l.height), u = h.x, g = h.y, m = l.x - d.x, p = l.y - d.y, y = m + u, b = p + g, $ = y * s - b * o, x = y * o + b * s, w = d.x + $, v = d.y + x, S = this._getFixedLocalCoords(t.anchor, c.width, c.height), T = S.x, k = S.y, _ = c.x - f.x, C = c.y - f.y, E = _ + T, I = C + k, A = E * s - I * o, R = E * o + I * s, z = f.x + A, O = f.y + R;
239
+ const r = new Te(n), { cos: s, sin: o } = r.getRenderingCosSin(), l = n.getVisualBoundingBox(), c = e.getVisualBoundingBox(), d = a, f = e.getRotationAnchor(), h = this._getFixedLocalCoords(t.anchor, l.width, l.height), u = h.x, g = h.y, m = l.x - d.x, p = l.y - d.y, y = m + u, b = p + g, $ = y * s - b * o, x = y * o + b * s, w = d.x + $, v = d.y + x, S = this._getFixedLocalCoords(t.anchor, c.width, c.height), T = S.x, k = S.y, _ = c.x - f.x, C = c.y - f.y, E = _ + T, I = C + k, A = E * s - I * o, R = E * o + I * s, z = f.x + A, O = f.y + R;
240
240
  return {
241
241
  x: w - z,
242
242
  y: v - O
@@ -277,7 +277,7 @@ class Kt {
277
277
  return a;
278
278
  }
279
279
  }
280
- class Jt {
280
+ class ea {
281
281
  constructor() {
282
282
  this.hooks = {
283
283
  beforeResize: [],
@@ -332,7 +332,7 @@ class Jt {
332
332
  */
333
333
  executeResize(n) {
334
334
  const e = this.runHooks("beforeResize", n);
335
- let t = Kt.calculateResize({
335
+ let t = na.calculateResize({
336
336
  ...e,
337
337
  snapSystem: n.snapSystem
338
338
  });
@@ -347,8 +347,8 @@ class Jt {
347
347
  return this.runHooks("afterPositionUpdate", t).position;
348
348
  }
349
349
  }
350
- const er = new Jt();
351
- class tr {
350
+ const sr = new ea();
351
+ class ir {
352
352
  constructor(n = null) {
353
353
  this.state = "IDLE", this.context = {
354
354
  mode: null,
@@ -546,7 +546,7 @@ class tr {
546
546
  updateRotate(n, e, t, a) {
547
547
  if (this.state !== "ROTATING")
548
548
  throw new Error("Cannot update rotate: not in ROTATING state");
549
- const r = this.context.startData, o = (bt(t, a, n, e) - r.startAngle) * 180 / Math.PI;
549
+ const r = this.context.startData, o = ($t(t, a, n, e) - r.startAngle) * 180 / Math.PI;
550
550
  let l = r.currentRotation - o;
551
551
  return l = (l % 360 + 360) % 360, l > 180 && (l -= 360), this.snapHandler && this.snapHandler.snapRotation && this.context.element ? this.snapHandler.snapRotation(l, this.context.element) : l;
552
552
  }
@@ -770,7 +770,7 @@ class Cn {
770
770
  return Math.abs(a.x - t.x) > r || Math.abs(a.y - t.y) > r;
771
771
  }
772
772
  }
773
- class Ae {
773
+ class De {
774
774
  constructor(n) {
775
775
  this.cellSize = n, this.cells = /* @__PURE__ */ new Map(), this.idIndex = /* @__PURE__ */ new Map();
776
776
  }
@@ -884,14 +884,14 @@ function Vn(i, n) {
884
884
  const e = i.transformData;
885
885
  return e && "height" in e ? (e.height = n, !0) : !1;
886
886
  }
887
- class ar {
887
+ class or {
888
888
  constructor(n = {}) {
889
889
  this._extraSnapRects = [], this.snapThreshold = n.snapThreshold || sn.canvas.snapThreshold, this.enabled = n.enabled !== !1, this.showGuides = n.showGuides !== !1, this.guides = [], this.activeSnaps = {
890
890
  x: null,
891
891
  // { snapTo: number, anchorKey: string, frozenFontSize: number, frozenWidth: number, frozenPosition: {x, y}, isPositionBasedSnap: boolean }
892
892
  y: null
893
893
  // { snapTo: number, anchorKey: string, frozenFontSize: number, frozenWidth: number, frozenPosition: {x, y}, isPositionBasedSnap: boolean }
894
- }, this.stickyThreshold = n.stickyThreshold || 15, this._spatialGrid = new Ae(Math.max(this.snapThreshold * 2, 16)), this._anchorMetadata = /* @__PURE__ */ new Map();
894
+ }, this.stickyThreshold = n.stickyThreshold || 15, this._spatialGrid = new De(Math.max(this.snapThreshold * 2, 16)), this._anchorMetadata = /* @__PURE__ */ new Map();
895
895
  }
896
896
  /**
897
897
  * Enable or disable snapping
@@ -903,7 +903,7 @@ class ar {
903
903
  * Set snap threshold in pixels
904
904
  */
905
905
  setSnapThreshold(n) {
906
- this.snapThreshold = n, this._spatialGrid = new Ae(Math.max(n * 2, 16));
906
+ this.snapThreshold = n, this._spatialGrid = new De(Math.max(n * 2, 16));
907
907
  }
908
908
  /**
909
909
  * Get current snap guides for rendering
@@ -1509,12 +1509,12 @@ class ar {
1509
1509
  if (!this.enabled) return n;
1510
1510
  const a = [0, 45, 90, 135, 180, 225, 270, 315, 360], r = 5;
1511
1511
  for (const s of a)
1512
- if (mt(n, s, r))
1512
+ if (vt(n, s, r))
1513
1513
  return s;
1514
1514
  return n;
1515
1515
  }
1516
1516
  }
1517
- class rr {
1517
+ class lr {
1518
1518
  constructor(n = {}) {
1519
1519
  this.lastSnapTarget = null, this.detectionThreshold = n.detectionThreshold || 100, this.minDistance = n.minDistance || 10, this.enabled = n.enabled !== !1, this.showLabels = n.showLabels !== !1, this.indicators = [];
1520
1520
  }
@@ -1549,7 +1549,7 @@ class rr {
1549
1549
  snapToSpacing(n, e, t) {
1550
1550
  if (!this.enabled || !t)
1551
1551
  return n;
1552
- const a = ke, r = t.filter((p) => p.id !== e.id);
1552
+ const a = _e, r = t.filter((p) => p.id !== e.id);
1553
1553
  if (r.length === 0)
1554
1554
  return n;
1555
1555
  const s = e.clone();
@@ -1846,7 +1846,7 @@ class rr {
1846
1846
  * Check if spacing would snap to a pattern
1847
1847
  */
1848
1848
  checkIfWouldSnap(n, e, t, a) {
1849
- const r = ke;
1849
+ const r = _e;
1850
1850
  if (t === "top" || t === "bottom") {
1851
1851
  const s = a.filter((o) => {
1852
1852
  const l = o.getVisualBoundingBox();
@@ -1946,7 +1946,7 @@ class rr {
1946
1946
  }
1947
1947
  }
1948
1948
  }
1949
- const Zt = xn("TextureManager"), Ln = class Ln {
1949
+ const ta = mn("TextureManager"), Ln = class Ln {
1950
1950
  /**
1951
1951
  * Load a texture by ID or URL
1952
1952
  */
@@ -1960,7 +1960,7 @@ const Zt = xn("TextureManager"), Ln = class Ln {
1960
1960
  s.crossOrigin = "anonymous", s.onload = () => {
1961
1961
  this.cache.set(n, s), this.cache.set(e, s), this.loading.delete(n), this.loading.delete(e), a(s);
1962
1962
  }, s.onerror = () => {
1963
- Zt.error("Failed to load texture:", e), this.loading.delete(n), this.loading.delete(e), r(new Error(`Failed to load texture: ${e}`));
1963
+ ta.error("Failed to load texture:", e), this.loading.delete(n), this.loading.delete(e), r(new Error(`Failed to load texture: ${e}`));
1964
1964
  }, s.src = e;
1965
1965
  });
1966
1966
  return this.loading.set(n, t), e !== n && this.loading.set(e, t), t;
@@ -2037,7 +2037,7 @@ Ln.cache = /* @__PURE__ */ new Map(), Ln.loading = /* @__PURE__ */ new Map(), Ln
2037
2037
  }
2038
2038
  ];
2039
2039
  let cn = Ln;
2040
- const oe = xn("ArtboardRenderer"), Qt = {
2040
+ const le = mn("ArtboardRenderer"), aa = {
2041
2041
  showLabel: !0,
2042
2042
  showBorder: !0,
2043
2043
  borderColor: "",
@@ -2055,9 +2055,9 @@ const oe = xn("ArtboardRenderer"), Qt = {
2055
2055
  borderRadius: 0
2056
2056
  // Default to no border radius (sharp corners)
2057
2057
  };
2058
- class Ze {
2058
+ class at {
2059
2059
  constructor(n = {}) {
2060
- this.options = { ...Qt, ...n };
2060
+ this.options = { ...aa, ...n };
2061
2061
  }
2062
2062
  /**
2063
2063
  * Render an artboard
@@ -2082,7 +2082,7 @@ class Ze {
2082
2082
  const t = cn.getTexture(e.backgroundTexture), a = cn.getTexturePresetColor(e.backgroundTexture);
2083
2083
  if (n.fillStyle = a, n.fillRect(e.x, e.y, e.width, e.height), !t || !t.complete) {
2084
2084
  cn.loadTexture(e.backgroundTexture).catch((r) => {
2085
- oe.error("Failed to load texture:", r);
2085
+ le.error("Failed to load texture:", r);
2086
2086
  });
2087
2087
  return;
2088
2088
  }
@@ -2103,7 +2103,7 @@ class Ze {
2103
2103
  * Render artboard border (respects clipShape and borderRadius option)
2104
2104
  */
2105
2105
  renderBorder(n, e, t) {
2106
- const { x: a, y: r, width: s, height: o, clipShape: l } = e, c = this.options.borderColor || yt(), d = this.options.selectedBorderColor || en();
2106
+ const { x: a, y: r, width: s, height: o, clipShape: l } = e, c = this.options.borderColor || wt(), d = this.options.selectedBorderColor || en();
2107
2107
  if (n.strokeStyle = t ? d : c, n.lineWidth = t ? this.options.selectedBorderWidth : this.options.borderWidth, n.beginPath(), !l || l === "rectangle")
2108
2108
  if (this.options.borderRadius > 0) {
2109
2109
  const f = Math.min(this.options.borderRadius, Math.min(s, o) / 2);
@@ -2122,7 +2122,7 @@ class Ze {
2122
2122
  n.save(), n.translate(a, r), n.stroke(f), n.restore();
2123
2123
  return;
2124
2124
  } catch (f) {
2125
- oe.warn("Invalid SVG path for border, falling back to rectangle:", f), n.rect(a, r, s, o);
2125
+ le.warn("Invalid SVG path for border, falling back to rectangle:", f), n.rect(a, r, s, o);
2126
2126
  }
2127
2127
  n.stroke();
2128
2128
  }
@@ -2132,7 +2132,7 @@ class Ze {
2132
2132
  renderLabel(n, e, t) {
2133
2133
  const a = this.options.labelFontSize, r = this.options.labelPadding, s = `${e.name} (${Math.round(e.width)} × ${Math.round(e.height)})`, o = e.x, l = e.y - r;
2134
2134
  n.font = `${a}px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`;
2135
- const c = this.options.selectedBorderColor || en(), d = this.options.labelColor || xt();
2135
+ const c = this.options.selectedBorderColor || en(), d = this.options.labelColor || St();
2136
2136
  n.fillStyle = t ? c : d, n.textAlign = "left", n.textBaseline = "bottom", n.fillText(s, o, l);
2137
2137
  }
2138
2138
  /**
@@ -2176,7 +2176,7 @@ class Ze {
2176
2176
  n.translate(t, a), n.clip(l), n.translate(-t, -a);
2177
2177
  return;
2178
2178
  } catch (l) {
2179
- oe.warn("Invalid SVG path, falling back to rectangle:", l), n.rect(t, a, r, s);
2179
+ le.warn("Invalid SVG path, falling back to rectangle:", l), n.rect(t, a, r, s);
2180
2180
  }
2181
2181
  n.clip();
2182
2182
  }
@@ -2235,7 +2235,7 @@ class Ze {
2235
2235
  * Use this when exporting to ensure preview background is never included
2236
2236
  */
2237
2237
  static createForExport(n = {}) {
2238
- return new Ze({
2238
+ return new at({
2239
2239
  ...n,
2240
2240
  showPreviewBackground: !1
2241
2241
  // CRITICAL: Never show preview in exports
@@ -2248,42 +2248,42 @@ class Ze {
2248
2248
  return !!(this.options.showPreviewBackground && n.previewBackgroundColor && n.previewBackgroundColor !== "transparent");
2249
2249
  }
2250
2250
  }
2251
- function sr(i) {
2252
- return i instanceof $t;
2251
+ function cr(i) {
2252
+ return i instanceof Ct;
2253
2253
  }
2254
- function na(i) {
2254
+ function ra(i) {
2255
2255
  return i instanceof Un;
2256
2256
  }
2257
- function le(i) {
2258
- return i instanceof Ve;
2257
+ function ce(i) {
2258
+ return i instanceof Ke;
2259
2259
  }
2260
- function ir(i) {
2261
- return i instanceof Xe;
2260
+ function dr(i) {
2261
+ return i instanceof Ze;
2262
2262
  }
2263
- function or(i) {
2264
- return i instanceof je;
2263
+ function fr(i) {
2264
+ return i instanceof Je;
2265
2265
  }
2266
- function ve(i, n, e = {}) {
2266
+ function we(i, n, e = {}) {
2267
2267
  const t = e.mode || "both";
2268
2268
  switch (i.save(), i.translate(n.x || 0, n.y || 0), i.rotate(-(n.rotation || 0) * Math.PI / 180), n.transformType) {
2269
2269
  case "image":
2270
- ta(i, n, t, e);
2270
+ ia(i, n, t, e);
2271
2271
  break;
2272
2272
  case "shape":
2273
- aa(i, n, t, e);
2273
+ oa(i, n, t, e);
2274
2274
  break;
2275
2275
  case "group":
2276
2276
  break;
2277
2277
  default:
2278
- ea(i, n, t, e);
2278
+ sa(i, n, t, e);
2279
2279
  break;
2280
2280
  }
2281
2281
  i.restore();
2282
2282
  }
2283
- function ea(i, n, e, t) {
2283
+ function sa(i, n, e, t) {
2284
2284
  var s;
2285
2285
  const a = n, r = a.text || "";
2286
- r && ((e === "stroke" || e === "both") && ((s = n.stroke) != null && s.enabled) && (i.save(), vt(i, n, { ...t.renderingContext, positionApplied: !0 }), i.restore()), (e === "fill" || e === "both") && (i.save(), wt(i, {
2286
+ r && ((e === "stroke" || e === "both") && ((s = n.stroke) != null && s.enabled) && (i.save(), kt(i, n, { ...t.renderingContext, positionApplied: !0 }), i.restore()), (e === "fill" || e === "both") && (i.save(), Tt(i, {
2287
2287
  text: r,
2288
2288
  fontSize: a.fontSize || 24,
2289
2289
  fontFamily: a.fontFamily || "Arial",
@@ -2293,12 +2293,12 @@ function ea(i, n, e, t) {
2293
2293
  color: a.color || "#000000"
2294
2294
  }), i.restore()));
2295
2295
  }
2296
- function ta(i, n, e, t) {
2296
+ function ia(i, n, e, t) {
2297
2297
  var r;
2298
2298
  if (!n.transformData) return;
2299
2299
  const a = n.transformData;
2300
2300
  if (e === "fill" || e === "both")
2301
- if (la(i, n), t.loadedImage) {
2301
+ if (ua(i, n), t.loadedImage) {
2302
2302
  i.save(), i.clip();
2303
2303
  const s = a.flipHorizontal ? -1 : 1, o = a.flipVertical ? -1 : 1;
2304
2304
  i.scale(s, o);
@@ -2306,34 +2306,34 @@ function ta(i, n, e, t) {
2306
2306
  i.drawImage(t.loadedImage, -l / 2, -c / 2, l, c), i.restore();
2307
2307
  } else
2308
2308
  i.fillStyle = "#cccccc", i.fill();
2309
- (e === "stroke" || e === "both") && ((r = n.stroke) != null && r.enabled) && (i.save(), St(i, n, t.renderingContext), i.restore());
2309
+ (e === "stroke" || e === "both") && ((r = n.stroke) != null && r.enabled) && (i.save(), _t(i, n, t.renderingContext), i.restore());
2310
2310
  }
2311
- function aa(i, n, e, t) {
2311
+ function oa(i, n, e, t) {
2312
2312
  var s, o;
2313
2313
  if (!n.transformData) return;
2314
2314
  const a = n.transformData, r = ((s = t.renderingContext) == null ? void 0 : s.isKnockout) === !0;
2315
- i.beginPath(), Qe(i, a), (e === "fill" || e === "both") && (i.fillStyle = r ? "#000000" : a.fillColor || "#3b82f6", i.globalAlpha = r ? 1 : a.fillOpacity ?? 1, i.fill()), (e === "stroke" || e === "both") && ((o = n.stroke) != null && o.enabled) && (i.save(), oa(i, n, t.renderingContext), i.restore());
2315
+ i.beginPath(), rt(i, a), (e === "fill" || e === "both") && (i.fillStyle = r ? "#000000" : a.fillColor || "#3b82f6", i.globalAlpha = r ? 1 : a.fillOpacity ?? 1, i.fill()), (e === "stroke" || e === "both") && ((o = n.stroke) != null && o.enabled) && (i.save(), fa(i, n, t.renderingContext), i.restore());
2316
2316
  }
2317
- function Qe(i, n) {
2317
+ function rt(i, n) {
2318
2318
  const { shapeType: e } = n, t = n.width ?? 100, a = n.height ?? 100;
2319
2319
  switch (e) {
2320
2320
  case "rectangle":
2321
- Pe(i, n, t, a);
2321
+ Re(i, n, t, a);
2322
2322
  break;
2323
2323
  case "circle":
2324
- ra(i, Math.min(t, a) / 2);
2324
+ la(i, Math.min(t, a) / 2);
2325
2325
  break;
2326
2326
  case "ellipse":
2327
- sa(i, t / 2, a / 2);
2327
+ ca(i, t / 2, a / 2);
2328
2328
  break;
2329
2329
  case "star":
2330
- ia(i, n, Math.min(t, a) / 2);
2330
+ da(i, n, Math.min(t, a) / 2);
2331
2331
  break;
2332
2332
  default:
2333
- Pe(i, n, t, a);
2333
+ Re(i, n, t, a);
2334
2334
  }
2335
2335
  }
2336
- function Pe(i, n, e, t) {
2336
+ function Re(i, n, e, t) {
2337
2337
  const a = n.borderRadius || 0, r = -e / 2, s = -t / 2;
2338
2338
  if (a > 0) {
2339
2339
  const o = Math.min(a / 100 * Math.min(e, t), e / 2, t / 2);
@@ -2341,13 +2341,13 @@ function Pe(i, n, e, t) {
2341
2341
  } else
2342
2342
  i.rect(r, s, e, t);
2343
2343
  }
2344
- function ra(i, n) {
2344
+ function la(i, n) {
2345
2345
  i.arc(0, 0, n, 0, Math.PI * 2);
2346
2346
  }
2347
- function sa(i, n, e) {
2347
+ function ca(i, n, e) {
2348
2348
  i.ellipse(0, 0, n, e, 0, 0, Math.PI * 2);
2349
2349
  }
2350
- function ia(i, n, e) {
2350
+ function da(i, n, e) {
2351
2351
  const t = Math.max(3, Math.min(20, n.points || 5)), a = Math.max(0.1, Math.min(0.9, n.innerRadius || 0.4)), r = e * a, s = Math.PI / t, o = -Math.PI / 2;
2352
2352
  for (let l = 0; l < t * 2; l++) {
2353
2353
  const c = o + s * l, d = l % 2 === 0 ? e : r, f = Math.cos(c) * d, h = Math.sin(c) * d;
@@ -2355,13 +2355,13 @@ function ia(i, n, e) {
2355
2355
  }
2356
2356
  i.closePath();
2357
2357
  }
2358
- function oa(i, n, e) {
2358
+ function fa(i, n, e) {
2359
2359
  var a;
2360
2360
  if (!((a = n.stroke) != null && a.enabled) || !n.transformData) return;
2361
2361
  const t = (e == null ? void 0 : e.isKnockout) === !0;
2362
- i.save(), t ? (i.strokeStyle = "#000000", i.lineWidth = n.stroke.width, i.lineCap = n.stroke.lineCap || "butt", i.lineJoin = n.stroke.lineJoin || "miter", i.globalAlpha = 1) : (i.strokeStyle = n.stroke.color, i.lineWidth = n.stroke.width, i.lineCap = n.stroke.lineCap || "butt", i.lineJoin = n.stroke.lineJoin || "miter", n.stroke.opacity !== void 0 && (i.globalAlpha = n.stroke.opacity)), n.stroke.miterLimit !== void 0 && (i.miterLimit = n.stroke.miterLimit), n.stroke.dashArray && n.stroke.dashArray.length > 0 && i.setLineDash(n.stroke.dashArray), !t && n.stroke.feather && n.stroke.feather > 0 && "filter" in i && (i.filter = `blur(${n.stroke.feather}px)`), i.beginPath(), Qe(i, n.transformData), i.stroke(), i.restore();
2362
+ i.save(), t ? (i.strokeStyle = "#000000", i.lineWidth = n.stroke.width, i.lineCap = n.stroke.lineCap || "butt", i.lineJoin = n.stroke.lineJoin || "miter", i.globalAlpha = 1) : (i.strokeStyle = n.stroke.color, i.lineWidth = n.stroke.width, i.lineCap = n.stroke.lineCap || "butt", i.lineJoin = n.stroke.lineJoin || "miter", n.stroke.opacity !== void 0 && (i.globalAlpha = n.stroke.opacity)), n.stroke.miterLimit !== void 0 && (i.miterLimit = n.stroke.miterLimit), n.stroke.dashArray && n.stroke.dashArray.length > 0 && i.setLineDash(n.stroke.dashArray), !t && n.stroke.feather && n.stroke.feather > 0 && "filter" in i && (i.filter = `blur(${n.stroke.feather}px)`), i.beginPath(), rt(i, n.transformData), i.stroke(), i.restore();
2363
2363
  }
2364
- function la(i, n) {
2364
+ function ua(i, n) {
2365
2365
  if (!n.transformData) return;
2366
2366
  const { borderRadius: e } = n.transformData, t = n.transformData.width ?? 100, a = n.transformData.height ?? 100, r = -t / 2, s = -a / 2;
2367
2367
  if (i.beginPath(), e && e > 0) {
@@ -2379,21 +2379,21 @@ function qn(i, n, e, t, a, r, s = "destination-out") {
2379
2379
  }
2380
2380
  const l = i.getTransform();
2381
2381
  i.save();
2382
- const c = n.knockoutParts.scope || "group", d = ca(n, c, e);
2382
+ const c = n.knockoutParts.scope || "group", d = ha(n, c, e);
2383
2383
  if (d.length === 0 && c === "artboard") {
2384
- fa(i, n, t), i.restore();
2384
+ ga(i, n, t), i.restore();
2385
2385
  return;
2386
2386
  }
2387
2387
  if (d.length === 0) {
2388
2388
  t(i, n), i.restore();
2389
2389
  return;
2390
2390
  }
2391
- const f = i.canvas, u = i.getTransform().a, g = ua(f.width, f.height), m = g.getContext("2d");
2391
+ const f = i.canvas, u = i.getTransform().a, g = ba(f.width, f.height), m = g.getContext("2d");
2392
2392
  if (!m) return;
2393
2393
  m.scale(u, u), a && r && (m.fillStyle = a, m.fillRect(r.x, r.y, r.width, r.height));
2394
2394
  for (const x of d)
2395
2395
  t(m, x);
2396
- n.knockoutParts.fill && !n.knockoutParts.stroke && (($ = n.stroke) != null && $.enabled) && (m.save(), he(m, n), m.restore()), m.save(), m.globalCompositeOperation = s, n.knockoutParts.fill && ue(m, n), n.knockoutParts.stroke && he(m, n), m.restore(), n.knockoutParts.fill || (m.save(), ue(m, n), m.restore());
2396
+ n.knockoutParts.fill && !n.knockoutParts.stroke && (($ = n.stroke) != null && $.enabled) && (m.save(), pe(m, n), m.restore()), m.save(), m.globalCompositeOperation = s, n.knockoutParts.fill && he(m, n), n.knockoutParts.stroke && pe(m, n), m.restore(), n.knockoutParts.fill || (m.save(), he(m, n), m.restore());
2397
2397
  const p = f.width / u, y = f.height / u;
2398
2398
  i.drawImage(g, 0, 0, p, y), i.restore();
2399
2399
  const b = i.getTransform();
@@ -2406,59 +2406,59 @@ function qn(i, n, e, t, a, r, s = "destination-out") {
2406
2406
  l.f
2407
2407
  );
2408
2408
  }
2409
- function lr(i, n, e, t, a, r) {
2409
+ function ur(i, n, e, t, a, r) {
2410
2410
  qn(i, n, e, t, a, r, "destination-out");
2411
2411
  }
2412
- function ca(i, n, e) {
2413
- return n === "artboard" ? nt(i, e) : da(i, e);
2412
+ function ha(i, n, e) {
2413
+ return n === "artboard" ? st(i, e) : pa(i, e);
2414
2414
  }
2415
- function nt(i, n) {
2415
+ function st(i, n) {
2416
2416
  const e = n.findIndex((t) => t.id === i.id);
2417
2417
  return e === -1 ? [] : n.slice(0, e);
2418
2418
  }
2419
- function da(i, n) {
2420
- const e = et(i, n);
2419
+ function pa(i, n) {
2420
+ const e = it(i, n);
2421
2421
  if (!e)
2422
- return nt(i, n);
2422
+ return st(i, n);
2423
2423
  if (e.transformType !== "group" || !e.children)
2424
2424
  return [];
2425
2425
  const t = e.children.findIndex((a) => a.id === i.id);
2426
2426
  return t === -1 ? [] : e.children.slice(0, t);
2427
2427
  }
2428
- function et(i, n) {
2428
+ function it(i, n) {
2429
2429
  for (const e of n)
2430
2430
  if (e.transformType === "group" && e.children) {
2431
2431
  if (e.children.some((a) => a.id === i.id))
2432
2432
  return e;
2433
- const t = et(i, e.children);
2433
+ const t = it(i, e.children);
2434
2434
  if (t)
2435
2435
  return t;
2436
2436
  }
2437
2437
  return null;
2438
2438
  }
2439
- function ue(i, n, e) {
2440
- ve(i, n, {
2439
+ function he(i, n, e) {
2440
+ we(i, n, {
2441
2441
  mode: "fill",
2442
2442
  renderingContext: { isKnockout: !0 }
2443
2443
  });
2444
2444
  }
2445
- function he(i, n) {
2445
+ function pe(i, n) {
2446
2446
  var e;
2447
- (e = n.stroke) != null && e.enabled && ve(i, n, {
2447
+ (e = n.stroke) != null && e.enabled && we(i, n, {
2448
2448
  mode: "stroke",
2449
2449
  renderingContext: { isKnockout: !0 }
2450
2450
  });
2451
2451
  }
2452
- function fa(i, n, e) {
2452
+ function ga(i, n, e) {
2453
2453
  var a;
2454
2454
  const t = n.knockoutParts;
2455
2455
  if (!t) {
2456
2456
  e(i, n);
2457
2457
  return;
2458
2458
  }
2459
- t.fill || (i.save(), ue(i, n), i.restore()), !t.stroke && ((a = n.stroke) != null && a.enabled) && (i.save(), he(i, n), i.restore());
2459
+ t.fill || (i.save(), he(i, n), i.restore()), !t.stroke && ((a = n.stroke) != null && a.enabled) && (i.save(), pe(i, n), i.restore());
2460
2460
  }
2461
- function ua(i, n) {
2461
+ function ba(i, n) {
2462
2462
  if (typeof OffscreenCanvas < "u")
2463
2463
  return new OffscreenCanvas(i, n);
2464
2464
  if (typeof document < "u") {
@@ -2467,7 +2467,7 @@ function ua(i, n) {
2467
2467
  }
2468
2468
  throw new Error("No canvas context available");
2469
2469
  }
2470
- function Ie(i, n, e, t, a = 0) {
2470
+ function Fe(i, n, e, t, a = 0) {
2471
2471
  if (e <= 0 || t <= 0 || i <= 0 || n <= 0)
2472
2472
  return { width: i + a, height: n + a };
2473
2473
  const r = e / t, s = i / n;
@@ -2477,11 +2477,11 @@ function Ie(i, n, e, t, a = 0) {
2477
2477
  height: l + a
2478
2478
  };
2479
2479
  }
2480
- const Fn = 64, ce = 512;
2481
- function ha(i, n) {
2480
+ const Fn = 64, de = 512;
2481
+ function ma(i, n) {
2482
2482
  i.beginPath(), i.arc(n / 2, n / 2, n * 0.45, 0, Math.PI * 2), i.fill();
2483
2483
  }
2484
- function pa(i, n) {
2484
+ function ya(i, n) {
2485
2485
  const e = n / 2, t = n / 2, a = n * 0.45, r = a * 0.4, s = 5;
2486
2486
  i.beginPath();
2487
2487
  for (let o = 0; o < s * 2; o++) {
@@ -2490,15 +2490,15 @@ function pa(i, n) {
2490
2490
  }
2491
2491
  i.closePath(), i.fill();
2492
2492
  }
2493
- function ga(i, n) {
2493
+ function xa(i, n) {
2494
2494
  const e = n / 2, t = n * 0.42;
2495
2495
  i.beginPath(), i.moveTo(e, n * 0.82), i.bezierCurveTo(e - t * 1.1, n * 0.6, e - t * 1.3, n * 0.2, e, n * 0.35), i.bezierCurveTo(e + t * 1.3, n * 0.2, e + t * 1.1, n * 0.6, e, n * 0.82), i.closePath(), i.fill();
2496
2496
  }
2497
- function ba(i, n) {
2497
+ function $a(i, n) {
2498
2498
  const e = n / 2, t = n / 2, a = n * 0.4, r = n * 0.48;
2499
2499
  i.beginPath(), i.moveTo(e, t - r), i.lineTo(e + a, t), i.lineTo(e, t + r), i.lineTo(e - a, t), i.closePath(), i.fill();
2500
2500
  }
2501
- function ma(i, n) {
2501
+ function va(i, n) {
2502
2502
  const e = n / 2, t = n / 2, a = n * 0.44;
2503
2503
  i.beginPath();
2504
2504
  for (let r = 0; r < 6; r++) {
@@ -2507,11 +2507,11 @@ function ma(i, n) {
2507
2507
  }
2508
2508
  i.closePath(), i.fill();
2509
2509
  }
2510
- function ya(i, n) {
2510
+ function wa(i, n) {
2511
2511
  const e = n / 2, t = n * 0.4, a = n * 0.12;
2512
2512
  i.beginPath(), i.moveTo(e, a), i.lineTo(e + t, n * 0.25), i.lineTo(e + t, n * 0.55), i.quadraticCurveTo(e + t * 0.3, n * 0.8, e, n * 0.9), i.quadraticCurveTo(e - t * 0.3, n * 0.8, e - t, n * 0.55), i.lineTo(e - t, n * 0.25), i.closePath(), i.fill();
2513
2513
  }
2514
- function xa(i, n) {
2514
+ function Sa(i, n) {
2515
2515
  const e = n / 2, t = n / 2;
2516
2516
  let a = 42;
2517
2517
  const r = () => (a = (a * 16807 + 0) % 2147483647, a / 2147483647);
@@ -2521,7 +2521,7 @@ function xa(i, n) {
2521
2521
  i.beginPath(), i.arc(e + Math.cos(o) * l, t + Math.sin(o) * l, c, 0, Math.PI * 2), i.fill();
2522
2522
  }
2523
2523
  }
2524
- function $a(i, n) {
2524
+ function Ca(i, n) {
2525
2525
  let e = 123;
2526
2526
  const t = () => (e = (e * 16807 + 0) % 2147483647, e / 2147483647), a = n * 0.08, r = 40;
2527
2527
  i.beginPath(), i.moveTo(a, a);
@@ -2543,7 +2543,7 @@ function $a(i, n) {
2543
2543
  }
2544
2544
  i.closePath(), i.fill();
2545
2545
  }
2546
- function va(i, n) {
2546
+ function ka(i, n) {
2547
2547
  let e = 77;
2548
2548
  const t = () => (e = (e * 16807 + 0) % 2147483647, e / 2147483647), a = n * 0.25, r = n * 0.75, s = n * 0.1;
2549
2549
  i.beginPath(), i.moveTo(s, a + t() * n * 0.05);
@@ -2557,58 +2557,58 @@ function va(i, n) {
2557
2557
  }
2558
2558
  i.closePath(), i.fill();
2559
2559
  }
2560
- function wa(i, n) {
2560
+ function Ta(i, n) {
2561
2561
  const e = n / 2, t = n * 0.55;
2562
2562
  i.beginPath(), i.arc(e, t, n * 0.2, 0, Math.PI * 2), i.fill(), i.beginPath(), i.arc(e - n * 0.18, t + n * 0.02, n * 0.15, 0, Math.PI * 2), i.fill(), i.beginPath(), i.arc(e + n * 0.18, t + n * 0.02, n * 0.16, 0, Math.PI * 2), i.fill(), i.beginPath(), i.arc(e - n * 0.06, t - n * 0.14, n * 0.14, 0, Math.PI * 2), i.fill(), i.beginPath(), i.arc(e + n * 0.1, t - n * 0.12, n * 0.12, 0, Math.PI * 2), i.fill();
2563
2563
  }
2564
- const Sa = [
2564
+ const _a = [
2565
2565
  // Geometric
2566
- { id: "circle", name: "Circle", description: "Perfect circle", imageUrl: "builtin-mask:circle", thumbnailUrl: "", category: "geometric", draw: ha },
2567
- { id: "star", name: "Star", description: "5-pointed star", imageUrl: "builtin-mask:star", thumbnailUrl: "", category: "geometric", draw: pa },
2568
- { id: "heart", name: "Heart", description: "Heart shape", imageUrl: "builtin-mask:heart", thumbnailUrl: "", category: "geometric", draw: ga },
2569
- { id: "diamond", name: "Diamond", description: "Diamond/rhombus", imageUrl: "builtin-mask:diamond", thumbnailUrl: "", category: "geometric", draw: ba },
2570
- { id: "hexagon", name: "Hexagon", description: "Regular hexagon", imageUrl: "builtin-mask:hexagon", thumbnailUrl: "", category: "geometric", draw: ma },
2571
- { id: "shield", name: "Shield", description: "Shield/crest shape", imageUrl: "builtin-mask:shield", thumbnailUrl: "", category: "geometric", draw: ya },
2566
+ { id: "circle", name: "Circle", description: "Perfect circle", imageUrl: "builtin-mask:circle", thumbnailUrl: "", category: "geometric", draw: ma },
2567
+ { id: "star", name: "Star", description: "5-pointed star", imageUrl: "builtin-mask:star", thumbnailUrl: "", category: "geometric", draw: ya },
2568
+ { id: "heart", name: "Heart", description: "Heart shape", imageUrl: "builtin-mask:heart", thumbnailUrl: "", category: "geometric", draw: xa },
2569
+ { id: "diamond", name: "Diamond", description: "Diamond/rhombus", imageUrl: "builtin-mask:diamond", thumbnailUrl: "", category: "geometric", draw: $a },
2570
+ { id: "hexagon", name: "Hexagon", description: "Regular hexagon", imageUrl: "builtin-mask:hexagon", thumbnailUrl: "", category: "geometric", draw: va },
2571
+ { id: "shield", name: "Shield", description: "Shield/crest shape", imageUrl: "builtin-mask:shield", thumbnailUrl: "", category: "geometric", draw: wa },
2572
2572
  // Organic
2573
- { id: "splatter", name: "Splatter", description: "Ink splatter", imageUrl: "builtin-mask:splatter", thumbnailUrl: "", category: "organic", draw: xa },
2574
- { id: "torn-edge", name: "Torn Edge", description: "Rough torn paper edge", imageUrl: "builtin-mask:torn-edge", thumbnailUrl: "", category: "organic", draw: $a },
2575
- { id: "paint-stroke", name: "Paint Stroke", description: "Horizontal brush stroke", imageUrl: "builtin-mask:paint-stroke", thumbnailUrl: "", category: "organic", draw: va },
2576
- { id: "cloud", name: "Cloud", description: "Soft cloud shape", imageUrl: "builtin-mask:cloud", thumbnailUrl: "", category: "organic", draw: wa }
2573
+ { id: "splatter", name: "Splatter", description: "Ink splatter", imageUrl: "builtin-mask:splatter", thumbnailUrl: "", category: "organic", draw: Sa },
2574
+ { id: "torn-edge", name: "Torn Edge", description: "Rough torn paper edge", imageUrl: "builtin-mask:torn-edge", thumbnailUrl: "", category: "organic", draw: Ca },
2575
+ { id: "paint-stroke", name: "Paint Stroke", description: "Horizontal brush stroke", imageUrl: "builtin-mask:paint-stroke", thumbnailUrl: "", category: "organic", draw: ka },
2576
+ { id: "cloud", name: "Cloud", description: "Soft cloud shape", imageUrl: "builtin-mask:cloud", thumbnailUrl: "", category: "organic", draw: Ta }
2577
2577
  ];
2578
- let De = !1;
2579
- function Re(i, n) {
2578
+ let Me = !1;
2579
+ function Oe(i, n) {
2580
2580
  if (typeof document > "u") return null;
2581
2581
  const e = document.createElement("canvas");
2582
2582
  return e.width = i, e.height = n, e;
2583
2583
  }
2584
- function Ca() {
2585
- if (typeof document > "u" || De) return;
2586
- De = !0;
2587
- const i = ne.getInstance();
2588
- for (const n of Sa) {
2589
- const e = Re(ce, ce);
2584
+ function Ea() {
2585
+ if (typeof document > "u" || Me) return;
2586
+ Me = !0;
2587
+ const i = ee.getInstance();
2588
+ for (const n of _a) {
2589
+ const e = Oe(de, de);
2590
2590
  if (!e) continue;
2591
2591
  const t = e.getContext("2d");
2592
2592
  if (!t) continue;
2593
- t.fillStyle = "white", n.draw(t, ce);
2593
+ t.fillStyle = "white", n.draw(t, de);
2594
2594
  const a = e.toDataURL("image/png"), r = i.acquire(n.imageUrl);
2595
2595
  r.crossOrigin = "anonymous", r.src = a;
2596
- const s = Re(Fn, Fn);
2596
+ const s = Oe(Fn, Fn);
2597
2597
  if (s) {
2598
2598
  const o = s.getContext("2d");
2599
2599
  o && (o.fillStyle = "#1a1a2e", o.fillRect(0, 0, Fn, Fn), o.fillStyle = "white", n.draw(o, Fn), n.thumbnailUrl = s.toDataURL("image/png"));
2600
2600
  }
2601
2601
  }
2602
2602
  }
2603
- const ka = xn("MaskRenderer"), pe = /* @__PURE__ */ new Map(), Ta = /* @__PURE__ */ new Map();
2604
- function cr(i) {
2603
+ const Aa = mn("MaskRenderer"), ge = /* @__PURE__ */ new Map(), Pa = /* @__PURE__ */ new Map();
2604
+ function hr(i) {
2605
2605
  const n = [];
2606
- pe.forEach((e, t) => {
2606
+ ge.forEach((e, t) => {
2607
2607
  t.startsWith(i) && n.push(t);
2608
- }), n.forEach((e) => pe.delete(e));
2608
+ }), n.forEach((e) => ge.delete(e));
2609
2609
  }
2610
- function dr() {
2611
- pe.clear();
2610
+ function pr() {
2611
+ ge.clear();
2612
2612
  }
2613
2613
  function An(i, n, e) {
2614
2614
  if (!n.masks || n.masks.length === 0) {
@@ -2617,41 +2617,41 @@ function An(i, n, e) {
2617
2617
  }
2618
2618
  const t = i.canvas, a = Yn(t.width, t.height), r = a.getContext("2d");
2619
2619
  if (!r) {
2620
- ka.error("[renderWithMasks] Failed to get offscreen context");
2620
+ Aa.error("[renderWithMasks] Failed to get offscreen context");
2621
2621
  return;
2622
2622
  }
2623
2623
  const s = i.getTransform();
2624
2624
  r.setTransform(s), e(r);
2625
2625
  for (const o of n.masks)
2626
- _a(r, o, n);
2626
+ Ia(r, o, n);
2627
2627
  i.save(), i.setTransform(1, 0, 0, 1, 0, 0), i.drawImage(a, 0, 0), i.restore();
2628
2628
  }
2629
- function _a(i, n, e) {
2629
+ function Ia(i, n, e) {
2630
2630
  switch (n.type) {
2631
2631
  case "clip":
2632
- Ea(i, n, e);
2632
+ Da(i, n, e);
2633
2633
  break;
2634
2634
  case "alpha":
2635
- Aa(i, n, e);
2635
+ Ra(i, n, e);
2636
2636
  break;
2637
2637
  case "luma":
2638
- Pa(i, n, e);
2638
+ Fa(i, n, e);
2639
2639
  break;
2640
2640
  case "distress":
2641
- Ia(i, n, e);
2641
+ Ma(i, n, e);
2642
2642
  break;
2643
2643
  }
2644
2644
  }
2645
- function Ea(i, n, e) {
2646
- i.save(), i.globalCompositeOperation = n.inverted ? "destination-out" : "destination-in", n.opacity !== void 0 && (i.globalAlpha = n.opacity), ee(i, n.maskElement, e), i.restore();
2645
+ function Da(i, n, e) {
2646
+ i.save(), i.globalCompositeOperation = n.inverted ? "destination-out" : "destination-in", n.opacity !== void 0 && (i.globalAlpha = n.opacity), te(i, n.maskElement, e), i.restore();
2647
2647
  }
2648
- function Aa(i, n, e) {
2649
- i.save(), i.globalCompositeOperation = n.inverted ? "destination-out" : "destination-in", n.opacity !== void 0 && (i.globalAlpha = n.opacity), ee(i, n.maskElement, e), n.feather && n.feather > 0 && tt(i, n.feather), i.restore();
2648
+ function Ra(i, n, e) {
2649
+ i.save(), i.globalCompositeOperation = n.inverted ? "destination-out" : "destination-in", n.opacity !== void 0 && (i.globalAlpha = n.opacity), te(i, n.maskElement, e), n.feather && n.feather > 0 && ot(i, n.feather), i.restore();
2650
2650
  }
2651
- function Pa(i, n, e) {
2651
+ function Fa(i, n, e) {
2652
2652
  const t = Yn(i.canvas.width, i.canvas.height), a = t.getContext("2d");
2653
2653
  if (!a) return;
2654
- ee(a, n.maskElement, e);
2654
+ te(a, n.maskElement, e);
2655
2655
  const r = a.getImageData(0, 0, t.width, t.height), s = r.data;
2656
2656
  for (let o = 0; o < s.length; o += 4) {
2657
2657
  const l = s[o], c = s[o + 1], d = s[o + 2], f = 0.299 * l + 0.587 * c + 0.114 * d;
@@ -2659,10 +2659,10 @@ function Pa(i, n, e) {
2659
2659
  }
2660
2660
  a.putImageData(r, 0, 0), i.save(), i.globalCompositeOperation = "destination-in", n.opacity !== void 0 && (i.globalAlpha = n.opacity), i.drawImage(t, 0, 0), i.restore();
2661
2661
  }
2662
- function Ia(i, n, e) {
2663
- i.save(), i.globalCompositeOperation = n.inverted ? "destination-in" : "destination-out", n.opacity !== void 0 && (i.globalAlpha = n.opacity), ee(i, n.maskElement, e), n.feather && n.feather > 0 && tt(i, n.feather), i.restore();
2662
+ function Ma(i, n, e) {
2663
+ i.save(), i.globalCompositeOperation = n.inverted ? "destination-in" : "destination-out", n.opacity !== void 0 && (i.globalAlpha = n.opacity), te(i, n.maskElement, e), n.feather && n.feather > 0 && ot(i, n.feather), i.restore();
2664
2664
  }
2665
- function ee(i, n, e) {
2665
+ function te(i, n, e) {
2666
2666
  const t = e.x || 0, a = e.y || 0, r = n.x || 0, s = n.y || 0, o = {
2667
2667
  ...n,
2668
2668
  x: t + r,
@@ -2680,18 +2680,18 @@ function ee(i, n, e) {
2680
2680
  const x = n;
2681
2681
  if (x.imageUrl)
2682
2682
  if (typeof document < "u") {
2683
- x.imageUrl.startsWith("builtin-mask:") && Ca();
2684
- const w = ne.getInstance(), v = w.acquire(x.imageUrl);
2683
+ x.imageUrl.startsWith("builtin-mask:") && Ea();
2684
+ const w = ee.getInstance(), v = w.acquire(x.imageUrl);
2685
2685
  v.complete && v.naturalWidth > 0 && (g = v), w.release(x.imageUrl);
2686
2686
  } else
2687
- m = Ta.get(x.imageUrl);
2687
+ m = Pa.get(x.imageUrl);
2688
2688
  }
2689
2689
  const p = o.transformData, y = (u == null ? void 0 : u.width) || 0, b = (u == null ? void 0 : u.height) || 0, $ = y > 0 && b > 0 && f > 0 && h > 0 && Math.abs(y / b - f / h) > 1e-3;
2690
2690
  if (m) {
2691
2691
  i.save();
2692
2692
  const x = (p == null ? void 0 : p.width) || m.width, w = (p == null ? void 0 : p.height) || m.height;
2693
2693
  if (i.translate(o.x || 0, o.y || 0), i.rotate(-(o.rotation || 0) * Math.PI / 180), $) {
2694
- const v = Ie(
2694
+ const v = Fe(
2695
2695
  x,
2696
2696
  w,
2697
2697
  y,
@@ -2703,7 +2703,7 @@ function ee(i, n, e) {
2703
2703
  i.drawImage(m, -x / 2, -w / 2, x, w);
2704
2704
  i.restore();
2705
2705
  } else if ($ && g) {
2706
- const x = (p == null ? void 0 : p.width) || f, w = (p == null ? void 0 : p.height) || h, v = Ie(
2706
+ const x = (p == null ? void 0 : p.width) || f, w = (p == null ? void 0 : p.height) || h, v = Fe(
2707
2707
  x,
2708
2708
  w,
2709
2709
  y,
@@ -2712,9 +2712,9 @@ function ee(i, n, e) {
2712
2712
  );
2713
2713
  i.save(), i.translate(o.x || 0, o.y || 0), i.rotate(-(o.rotation || 0) * Math.PI / 180), i.drawImage(g, -v.width / 2, -v.height / 2, v.width, v.height), i.restore();
2714
2714
  } else
2715
- ve(i, o, { mode: "both", loadedImage: g });
2715
+ we(i, o, { mode: "both", loadedImage: g });
2716
2716
  }
2717
- function tt(i, n) {
2717
+ function ot(i, n) {
2718
2718
  "filter" in i && (i.filter = `blur(${n}px)`);
2719
2719
  }
2720
2720
  function Yn(i, n) {
@@ -2726,9 +2726,9 @@ function Yn(i, n) {
2726
2726
  }
2727
2727
  throw new Error("No canvas context available");
2728
2728
  }
2729
- function at(i, n, e, t) {
2729
+ function lt(i, n, e, t) {
2730
2730
  if (!n.enabled || !n.imageUrl || n.opacity <= 0) return;
2731
- const a = ne.getInstance(), r = a.acquire(n.imageUrl);
2731
+ const a = ee.getInstance(), r = a.acquire(n.imageUrl);
2732
2732
  if (!r.complete || r.naturalWidth === 0) {
2733
2733
  a.release(n.imageUrl);
2734
2734
  return;
@@ -2770,7 +2770,7 @@ function at(i, n, e, t) {
2770
2770
  b.globalCompositeOperation = $, b.globalAlpha = n.opacity / 100, b.drawImage(r, 0, 0, m, p);
2771
2771
  b.globalCompositeOperation = "source-over", b.globalAlpha = 1, i.save(), i.setTransform(1, 0, 0, 1, 0, 0), i.clearRect(f, h, u, g), t && (i.fillStyle = t, i.fillRect(f, h, u, g)), i.drawImage(y, f, h), i.restore(), a.release(n.imageUrl);
2772
2772
  }
2773
- class Da {
2773
+ class Oa {
2774
2774
  constructor(n = Math.random()) {
2775
2775
  this.perm = [];
2776
2776
  for (let t = 0; t < 256; t++)
@@ -2808,8 +2808,8 @@ class Da {
2808
2808
  );
2809
2809
  }
2810
2810
  }
2811
- function de(i, n, e, t = Date.now()) {
2812
- const s = te(i, n).getContext("2d").createImageData(i, n), o = s.data, l = new Da(t), c = 0.02, d = 1 - e / 100;
2811
+ function fe(i, n, e, t = Date.now()) {
2812
+ const s = ae(i, n).getContext("2d").createImageData(i, n), o = s.data, l = new Oa(t), c = 0.02, d = 1 - e / 100;
2813
2813
  for (let f = 0; f < n; f++)
2814
2814
  for (let h = 0; h < i; h++) {
2815
2815
  const u = (f * i + h) * 4;
@@ -2822,30 +2822,30 @@ function de(i, n, e, t = Date.now()) {
2822
2822
  }
2823
2823
  return s;
2824
2824
  }
2825
- function Ra(i, n, e, t = Date.now()) {
2826
- const r = te(i, n).getContext("2d");
2825
+ function Ba(i, n, e, t = Date.now()) {
2826
+ const r = ae(i, n).getContext("2d");
2827
2827
  r.clearRect(0, 0, i, n), r.strokeStyle = "#000000", r.lineWidth = 1 + e / 50, r.lineCap = "round";
2828
- const s = we(t), o = Math.floor(e / 100 * 30 + 5);
2828
+ const s = Se(t), o = Math.floor(e / 100 * 30 + 5);
2829
2829
  for (let l = 0; l < o; l++) {
2830
2830
  const c = s() * i, d = s() * n;
2831
- ge(r, c, d, s() * Math.PI * 2, 50 + s() * 100, s, 0);
2831
+ be(r, c, d, s() * Math.PI * 2, 50 + s() * 100, s, 0);
2832
2832
  }
2833
2833
  return r.getImageData(0, 0, i, n);
2834
2834
  }
2835
- function ge(i, n, e, t, a, r, s) {
2835
+ function be(i, n, e, t, a, r, s) {
2836
2836
  if (s > 3 || a < 10) return;
2837
2837
  const o = n + Math.cos(t) * a, l = e + Math.sin(t) * a;
2838
2838
  if (i.beginPath(), i.moveTo(n, e), i.lineTo(o, l), i.stroke(), r() > 0.5) {
2839
2839
  const c = t + (r() - 0.5) * Math.PI / 2;
2840
- ge(i, o, l, c, a * 0.6, r, s + 1);
2840
+ be(i, o, l, c, a * 0.6, r, s + 1);
2841
2841
  }
2842
2842
  if (r() > 0.7) {
2843
2843
  const c = t - (r() - 0.5) * Math.PI / 2;
2844
- ge(i, o, l, c, a * 0.6, r, s + 1);
2844
+ be(i, o, l, c, a * 0.6, r, s + 1);
2845
2845
  }
2846
2846
  }
2847
2847
  function jn(i, n, e, t = Date.now()) {
2848
- const s = te(i, n).getContext("2d").createImageData(i, n), o = s.data, l = we(t), c = e / 100 * 0.5;
2848
+ const s = ae(i, n).getContext("2d").createImageData(i, n), o = s.data, l = Se(t), c = e / 100 * 0.5;
2849
2849
  for (let d = 0; d < n; d++)
2850
2850
  for (let f = 0; f < i; f++) {
2851
2851
  const h = (d * i + f) * 4, g = l() < c ? 255 : 0;
@@ -2853,10 +2853,10 @@ function jn(i, n, e, t = Date.now()) {
2853
2853
  }
2854
2854
  return s;
2855
2855
  }
2856
- function Fa(i, n, e, t = Date.now()) {
2857
- const r = te(i, n).getContext("2d");
2856
+ function La(i, n, e, t = Date.now()) {
2857
+ const r = ae(i, n).getContext("2d");
2858
2858
  r.fillStyle = "#000000";
2859
- const s = we(t), o = 4 + e / 100 * 6, l = o * 2;
2859
+ const s = Se(t), o = 4 + e / 100 * 6, l = o * 2;
2860
2860
  for (let c = 0; c < n; c += l)
2861
2861
  for (let d = 0; d < i; d += l)
2862
2862
  if (s() < e / 100) {
@@ -2865,7 +2865,7 @@ function Fa(i, n, e, t = Date.now()) {
2865
2865
  }
2866
2866
  return r.getImageData(0, 0, i, n);
2867
2867
  }
2868
- function te(i, n) {
2868
+ function ae(i, n) {
2869
2869
  if (typeof OffscreenCanvas < "u")
2870
2870
  return new OffscreenCanvas(i, n);
2871
2871
  if (typeof document < "u") {
@@ -2874,24 +2874,24 @@ function te(i, n) {
2874
2874
  }
2875
2875
  throw new Error("No canvas context available");
2876
2876
  }
2877
- function we(i) {
2877
+ function Se(i) {
2878
2878
  let n = Math.sin(i++) * 1e4;
2879
2879
  return () => (n = Math.sin(i++) * 1e4, n - Math.floor(n));
2880
2880
  }
2881
2881
  const ln = 42, Tn = 512, _n = 64;
2882
- function be(i) {
2882
+ function me(i) {
2883
2883
  const n = i.data;
2884
2884
  for (let e = 0; e < n.length; e += 4)
2885
2885
  n[e] = 255, n[e + 1] = 255, n[e + 2] = 255;
2886
2886
  return i;
2887
2887
  }
2888
- function Ma(i, n) {
2888
+ function Na(i, n) {
2889
2889
  const e = i.data, t = n.data;
2890
2890
  for (let a = 0; a < e.length; a += 4)
2891
2891
  e[a] = 255, e[a + 1] = 255, e[a + 2] = 255, e[a + 3] = Math.min(255, e[a + 3] + t[a + 3]);
2892
2892
  return i;
2893
2893
  }
2894
- const Oa = [
2894
+ const Ua = [
2895
2895
  {
2896
2896
  id: "grunge-heavy",
2897
2897
  name: "Heavy Grunge",
@@ -2914,7 +2914,7 @@ const Oa = [
2914
2914
  textureUrl: "builtin:concrete",
2915
2915
  thumbnailUrl: "",
2916
2916
  description: "Rough surface via Perlin noise",
2917
- generate: (i, n) => de(i, n, 55, ln + 2)
2917
+ generate: (i, n) => fe(i, n, 55, ln + 2)
2918
2918
  },
2919
2919
  {
2920
2920
  id: "paper",
@@ -2922,7 +2922,7 @@ const Oa = [
2922
2922
  textureUrl: "builtin:paper",
2923
2923
  thumbnailUrl: "",
2924
2924
  description: "Subtle aging",
2925
- generate: (i, n) => de(i, n, 20, ln + 3)
2925
+ generate: (i, n) => fe(i, n, 20, ln + 3)
2926
2926
  },
2927
2927
  {
2928
2928
  id: "rust",
@@ -2931,8 +2931,8 @@ const Oa = [
2931
2931
  thumbnailUrl: "",
2932
2932
  description: "Noise + splatter combined",
2933
2933
  generate: (i, n) => {
2934
- const e = de(i, n, 45, ln + 4), t = jn(i, n, 35, ln + 5);
2935
- return Ma(be(e), be(t));
2934
+ const e = fe(i, n, 45, ln + 4), t = jn(i, n, 35, ln + 5);
2935
+ return Na(me(e), me(t));
2936
2936
  }
2937
2937
  },
2938
2938
  {
@@ -2941,7 +2941,7 @@ const Oa = [
2941
2941
  textureUrl: "builtin:scratches",
2942
2942
  thumbnailUrl: "",
2943
2943
  description: "Branching crack lines",
2944
- generate: (i, n) => Ra(i, n, 55, ln + 6)
2944
+ generate: (i, n) => Ba(i, n, 55, ln + 6)
2945
2945
  },
2946
2946
  {
2947
2947
  id: "halftone",
@@ -2949,7 +2949,7 @@ const Oa = [
2949
2949
  textureUrl: "builtin:halftone",
2950
2950
  thumbnailUrl: "",
2951
2951
  description: "Dot grid pattern",
2952
- generate: (i, n) => Fa(i, n, 55, ln + 7)
2952
+ generate: (i, n) => La(i, n, 55, ln + 7)
2953
2953
  },
2954
2954
  {
2955
2955
  id: "spray",
@@ -2960,25 +2960,25 @@ const Oa = [
2960
2960
  generate: (i, n) => jn(i, n, 55, ln + 8)
2961
2961
  }
2962
2962
  ];
2963
- let Fe = !1;
2964
- function Ba(i, n) {
2963
+ let Be = !1;
2964
+ function za(i, n) {
2965
2965
  if (typeof OffscreenCanvas < "u")
2966
2966
  return new OffscreenCanvas(i, n);
2967
2967
  const e = document.createElement("canvas");
2968
2968
  return e.width = i, e.height = n, e;
2969
2969
  }
2970
- function Me(i, n) {
2970
+ function Le(i, n) {
2971
2971
  if (typeof document > "u") return null;
2972
2972
  const e = document.createElement("canvas");
2973
2973
  return e.width = i, e.height = n, e;
2974
2974
  }
2975
- function La(i) {
2976
- const n = Me(i.width, i.height);
2975
+ function Wa(i) {
2976
+ const n = Le(i.width, i.height);
2977
2977
  if (!n) return "";
2978
2978
  const e = n.getContext("2d");
2979
2979
  if (!e) return "";
2980
2980
  e.putImageData(i, 0, 0);
2981
- const t = Me(_n, _n);
2981
+ const t = Le(_n, _n);
2982
2982
  if (!t) return "";
2983
2983
  const a = t.getContext("2d");
2984
2984
  if (!a) return "";
@@ -2990,29 +2990,29 @@ function La(i) {
2990
2990
  }
2991
2991
  return a.putImageData(r, 0, 0), t.toDataURL("image/png");
2992
2992
  }
2993
- function Na() {
2994
- if (!Fe) {
2995
- Fe = !0;
2996
- for (const i of Oa) {
2993
+ function Ha() {
2994
+ if (!Be) {
2995
+ Be = !0;
2996
+ for (const i of Ua) {
2997
2997
  const n = i.generate(Tn, Tn);
2998
- be(n);
2999
- const e = Ba(Tn, Tn), t = e.getContext("2d");
3000
- t && (t.putImageData(n, 0, 0), Ua(i.textureUrl, e, Tn, Tn)), typeof document < "u" && (i.thumbnailUrl = La(n));
2998
+ me(n);
2999
+ const e = za(Tn, Tn), t = e.getContext("2d");
3000
+ t && (t.putImageData(n, 0, 0), Ga(i.textureUrl, e, Tn, Tn)), typeof document < "u" && (i.thumbnailUrl = Wa(n));
3001
3001
  }
3002
3002
  }
3003
3003
  }
3004
3004
  const gn = /* @__PURE__ */ new Set(), bn = /* @__PURE__ */ new Map(), Kn = /* @__PURE__ */ new Map();
3005
- function Oe(i, n) {
3005
+ function Ne(i, n) {
3006
3006
  if (typeof OffscreenCanvas < "u")
3007
3007
  return new OffscreenCanvas(i, n);
3008
3008
  const e = document.createElement("canvas");
3009
3009
  return e.width = i, e.height = n, e;
3010
3010
  }
3011
- function Be(i) {
3011
+ function Ue(i) {
3012
3012
  return i.getContext("2d");
3013
3013
  }
3014
- function Le(i) {
3015
- const { width: n, height: e } = i, t = Oe(n, e), a = Be(t);
3014
+ function ze(i) {
3015
+ const { width: n, height: e } = i, t = Ne(n, e), a = Ue(t);
3016
3016
  if (!a) throw new Error("Failed to get 2d context for temp canvas");
3017
3017
  a.drawImage(i, 0, 0);
3018
3018
  const r = a.getImageData(0, 0, n, e), s = r.data;
@@ -3020,67 +3020,67 @@ function Le(i) {
3020
3020
  const d = s[c], f = s[c + 1], h = s[c + 2], g = 255 - (0.299 * d + 0.587 * f + 0.114 * h);
3021
3021
  s[c] = 255, s[c + 1] = 255, s[c + 2] = 255, s[c + 3] = g;
3022
3022
  }
3023
- const o = Oe(n, e), l = Be(o);
3023
+ const o = Ne(n, e), l = Ue(o);
3024
3024
  if (!l) throw new Error("Failed to get 2d context for mask canvas");
3025
3025
  return l.putImageData(r, 0, 0), { alphaMask: o, width: n, height: e };
3026
3026
  }
3027
- function rt(i) {
3027
+ function ct(i) {
3028
3028
  const n = bn.get(i);
3029
3029
  if (n) return n;
3030
3030
  if (i.startsWith("builtin:")) {
3031
- Na();
3031
+ Ha();
3032
3032
  const e = bn.get(i);
3033
3033
  return e || null;
3034
3034
  }
3035
- return gn.has(i) || (gn.add(i), st(i)), null;
3035
+ return gn.has(i) || (gn.add(i), dt(i)), null;
3036
3036
  }
3037
- function fr(i) {
3037
+ function gr(i) {
3038
3038
  return bn.has(i) ? Promise.resolve() : new Promise((n) => {
3039
3039
  if (bn.has(i)) {
3040
3040
  n();
3041
3041
  return;
3042
3042
  }
3043
3043
  const e = Kn.get(i) || [];
3044
- e.push(n), Kn.set(i, e), gn.has(i) || (gn.add(i), st(i));
3044
+ e.push(n), Kn.set(i, e), gn.has(i) || (gn.add(i), dt(i));
3045
3045
  });
3046
3046
  }
3047
- function Ua(i, n, e, t) {
3047
+ function Ga(i, n, e, t) {
3048
3048
  bn.has(i) || (bn.set(i, { alphaMask: n, width: e, height: t }), On(i));
3049
3049
  }
3050
3050
  function On(i) {
3051
3051
  const n = Kn.get(i);
3052
3052
  n && (n.forEach((e) => e()), Kn.delete(i));
3053
3053
  }
3054
- function st(i) {
3054
+ function dt(i) {
3055
3055
  if (typeof document < "u") {
3056
3056
  const n = new Image();
3057
3057
  n.crossOrigin = "anonymous", n.onload = () => {
3058
- const e = Le(n);
3058
+ const e = ze(n);
3059
3059
  bn.set(i, e), gn.delete(i), On(i);
3060
3060
  }, n.onerror = () => {
3061
3061
  gn.delete(i), On(i);
3062
3062
  }, n.src = i;
3063
3063
  } else
3064
3064
  fetch(i).then((n) => n.blob()).then((n) => createImageBitmap(n)).then((n) => {
3065
- const e = Le(n);
3065
+ const e = ze(n);
3066
3066
  bn.set(i, e), gn.delete(i), On(i);
3067
3067
  }).catch(() => {
3068
3068
  gn.delete(i), On(i);
3069
3069
  });
3070
3070
  }
3071
- function it(i, n) {
3071
+ function ft(i, n) {
3072
3072
  if (typeof OffscreenCanvas < "u")
3073
3073
  return new OffscreenCanvas(i, n);
3074
3074
  const e = document.createElement("canvas");
3075
3075
  return e.width = i, e.height = n, e;
3076
3076
  }
3077
- function ot(i, n, e, t) {
3077
+ function ut(i, n, e, t) {
3078
3078
  if (!n.enabled || !n.textureUrl || n.intensity <= 0) return;
3079
- const a = rt(n.textureUrl);
3079
+ const a = ct(n.textureUrl);
3080
3080
  if (!a) return;
3081
3081
  const { x: r, y: s, width: o, height: l } = e, c = i.getTransform(), d = c.a * r + c.e, f = c.d * s + c.f, h = c.a * o, u = c.d * l, g = Math.ceil(h), m = Math.ceil(u);
3082
3082
  if (g <= 0 || m <= 0) return;
3083
- const p = it(g, m), y = p.getContext("2d");
3083
+ const p = ft(g, m), y = p.getContext("2d");
3084
3084
  if (!y) return;
3085
3085
  y.drawImage(
3086
3086
  i.canvas,
@@ -3110,7 +3110,7 @@ function ot(i, n, e, t) {
3110
3110
  }
3111
3111
  function Jn(i, n, e, t) {
3112
3112
  if (!n.enabled || n.style !== "custom" || !n.textureUrl) return;
3113
- const a = rt(n.textureUrl);
3113
+ const a = ct(n.textureUrl);
3114
3114
  if (!a) {
3115
3115
  t(i);
3116
3116
  return;
@@ -3125,7 +3125,7 @@ function Jn(i, n, e, t) {
3125
3125
  t(i);
3126
3126
  return;
3127
3127
  }
3128
- const x = it(b, $), w = x.getContext("2d");
3128
+ const x = ft(b, $), w = x.getContext("2d");
3129
3129
  if (!w) {
3130
3130
  t(i);
3131
3131
  return;
@@ -3178,14 +3178,14 @@ class En {
3178
3178
  const s = e.getVisualBoundingBox(), o = Math.round(s.width), l = Math.round(s.height), c = `${o} × ${l}`, d = t.rotationHandle, f = d.x * r, h = d.y * r - 20;
3179
3179
  n.save(), n.font = "10px system-ui, -apple-system, sans-serif";
3180
3180
  const g = n.measureText(c).width + 12, m = 18;
3181
- n.shadowColor = Ct(n.canvas), n.shadowBlur = 4, n.shadowOffsetY = 1, n.fillStyle = kt(n.canvas), n.beginPath(), n.roundRect(
3181
+ n.shadowColor = Et(n.canvas), n.shadowBlur = 4, n.shadowOffsetY = 1, n.fillStyle = At(n.canvas), n.beginPath(), n.roundRect(
3182
3182
  f - g / 2,
3183
3183
  h - m / 2,
3184
3184
  g,
3185
3185
  m,
3186
3186
  3
3187
3187
  // Smaller border radius
3188
- ), n.fill(), n.shadowColor = "transparent", n.shadowBlur = 0, n.shadowOffsetY = 0, n.fillStyle = Tt(n.canvas), n.textAlign = "center", n.textBaseline = "middle", n.fillText(c, f, h + 0.5), n.restore();
3188
+ ), n.fill(), n.shadowColor = "transparent", n.shadowBlur = 0, n.shadowOffsetY = 0, n.fillStyle = Pt(n.canvas), n.textAlign = "center", n.textBaseline = "middle", n.fillText(c, f, h + 0.5), n.restore();
3189
3189
  }
3190
3190
  /**
3191
3191
  * Render transform handles layer
@@ -3208,7 +3208,7 @@ class En {
3208
3208
  );
3209
3209
  }
3210
3210
  }
3211
- class me {
3211
+ class ye {
3212
3212
  /**
3213
3213
  * Render hover highlights layer with fade-in animation
3214
3214
  * Outlines the actual element shape instead of a rectangular border
@@ -3223,7 +3223,7 @@ class me {
3223
3223
  const f = performance.now() - e.startTime;
3224
3224
  d = Math.min(f / l, 1) * c;
3225
3225
  }
3226
- n.strokeStyle = _t(n.canvas), n.globalAlpha = d, n.lineWidth = 3, this.renderElementOutline(n, o, r, s), n.restore();
3226
+ n.strokeStyle = It(n.canvas), n.globalAlpha = d, n.lineWidth = 3, this.renderElementOutline(n, o, r, s), n.restore();
3227
3227
  }
3228
3228
  /**
3229
3229
  * Render outline for a specific element type
@@ -3351,7 +3351,7 @@ class me {
3351
3351
  */
3352
3352
  static renderHoverRingEffect(n, e, t) {
3353
3353
  n.save(), n.translate(e.x * t, e.y * t), t !== 1 && n.scale(t, t);
3354
- const a = e.fontSize, r = e.fontFamily, s = e.bold || !1, o = e.italic || !1, l = e.textAlign || "center", c = qe(a, r, s, o), d = a * 1.2, f = 4 / t, h = 4 / t, u = document.createElement("canvas");
3354
+ const a = e.fontSize, r = e.fontFamily, s = e.bold || !1, o = e.italic || !1, l = e.textAlign || "center", c = Qe(a, r, s, o), d = a * 1.2, f = 4 / t, h = 4 / t, u = document.createElement("canvas");
3355
3355
  u.width = n.canvas.width, u.height = n.canvas.height;
3356
3356
  const g = u.getContext("2d");
3357
3357
  if (!g) {
@@ -3361,10 +3361,10 @@ class me {
3361
3361
  g.setTransform(n.getTransform()), g.textBaseline = "alphabetic", g.lineJoin = "round";
3362
3362
  const m = e.getRichText ? e.getRichText() : null;
3363
3363
  if (m) {
3364
- const p = Ye(m), y = [], b = [];
3364
+ const p = nt(m), y = [], b = [];
3365
3365
  p.forEach((w) => {
3366
3366
  if (e.transformType === "custom" && e.transformData) {
3367
- const v = e.transformData.width - Xn * 2, S = Ke(w, v, {
3367
+ const v = e.transformData.width - Xn * 2, S = et(w, v, {
3368
3368
  fontSize: a,
3369
3369
  fontFamily: r,
3370
3370
  bold: s,
@@ -3406,7 +3406,7 @@ class me {
3406
3406
  L = L.substring(0, U);
3407
3407
  }
3408
3408
  }
3409
- L.length > 0 && (n.save(), n.font = ie(W, X, q, Q), k += n.measureText(L).width, n.restore()), I += P.text.length;
3409
+ L.length > 0 && (n.save(), n.font = oe(W, X, q, Q), k += n.measureText(L).width, n.restore()), I += P.text.length;
3410
3410
  });
3411
3411
  let A = 0;
3412
3412
  l === "center" ? A = -k / 2 : l === "right" && (A = -k);
@@ -3428,14 +3428,14 @@ class me {
3428
3428
  L = L.substring(0, U);
3429
3429
  }
3430
3430
  }
3431
- I += P.text.length, L.length > 0 && (g.font = ie(W, X, q, Q), g.textAlign = "left", g.globalCompositeOperation = "source-over", g.strokeStyle = n.strokeStyle, g.globalAlpha = Math.min(n.globalAlpha * 1.6, 0.8), g.lineWidth = (h + f) * 2, g.strokeText(L, A, R), g.globalCompositeOperation = "destination-out", g.globalAlpha = 1, g.lineWidth = h * 2, g.strokeText(L, A, R), g.fillText(L, A, R), A += g.measureText(L).width);
3431
+ I += P.text.length, L.length > 0 && (g.font = oe(W, X, q, Q), g.textAlign = "left", g.globalCompositeOperation = "source-over", g.strokeStyle = n.strokeStyle, g.globalAlpha = Math.min(n.globalAlpha * 1.6, 0.8), g.lineWidth = (h + f) * 2, g.strokeText(L, A, R), g.globalCompositeOperation = "destination-out", g.globalAlpha = 1, g.lineWidth = h * 2, g.strokeText(L, A, R), g.fillText(L, A, R), A += g.measureText(L).width);
3432
3432
  });
3433
3433
  });
3434
3434
  } else {
3435
- n.font = ie(a, r, s, o), g.font = n.font, g.textAlign = l;
3435
+ n.font = oe(a, r, s, o), g.font = n.font, g.textAlign = l;
3436
3436
  let p, y;
3437
3437
  if (e.transformType === "custom" && e.transformData) {
3438
- const x = e.transformData.width - Xn * 2, { lines: w } = Et(
3438
+ const x = e.transformData.width - Xn * 2, { lines: w } = Dt(
3439
3439
  e.text,
3440
3440
  x,
3441
3441
  a,
@@ -3451,7 +3451,7 @@ class me {
3451
3451
  `);
3452
3452
  const x = e.text.includes(`
3453
3453
  `);
3454
- p = At(p, x);
3454
+ p = Rt(p, x);
3455
3455
  }
3456
3456
  p.length === 0 ? y = 0 : p.length === 1 ? y = c.height : y = (p.length - 1) * d + c.height;
3457
3457
  const b = -y / 2, $ = e.text.includes(`
@@ -3542,7 +3542,7 @@ class me {
3542
3542
  let o = -t.reduce((l, c) => l + c, 0) / 2;
3543
3543
  return e.forEach((l, c) => {
3544
3544
  const d = t[c], f = o + d / 2, h = f / (a.width / 2), u = a.amplitude * n.fontSize * Math.sin(a.frequency * Math.PI * h), g = a.amplitude * a.frequency * Math.PI * Math.cos(a.frequency * Math.PI * h);
3545
- r.push({ x: f, y: u, angle: 0, skewY: g * Pt }), o += d;
3545
+ r.push({ x: f, y: u, angle: 0, skewY: g * Ft }), o += d;
3546
3546
  }), r;
3547
3547
  }
3548
3548
  /**
@@ -3604,7 +3604,7 @@ class Mn {
3604
3604
  */
3605
3605
  static renderSpacingIndicatorsLayer(n, e = []) {
3606
3606
  e.length !== 0 && (n.save(), n.setLineDash([]), e.forEach((t) => {
3607
- const a = Te(n.canvas);
3607
+ const a = Ee(n.canvas);
3608
3608
  if (n.strokeStyle = a, n.fillStyle = a, n.lineWidth = sn.canvas.spacingIndicatorWidth, n.beginPath(), t.type === "horizontal") {
3609
3609
  const r = t.x1 ?? 0, s = t.x2 ?? 0, o = t.y ?? 0;
3610
3610
  n.moveTo(r, o), n.lineTo(s, o), n.stroke();
@@ -3629,10 +3629,10 @@ class Mn {
3629
3629
  const r = `${a}`;
3630
3630
  n.font = `600 ${sn.canvas.spacingLabelFontSize}px ${sn.canvas.spacingLabelFontFamily}`;
3631
3631
  const o = n.measureText(r).width, l = sn.canvas.spacingLabelFontSize, c = 4, d = o + c * 2, f = l + c * 2;
3632
- n.fillStyle = Te(n.canvas), n.beginPath(), n.roundRect(e - d / 2, t - f / 2, d, f, It), n.fill(), n.fillStyle = Dt, n.textAlign = "center", n.textBaseline = "middle", n.fillText(r, e, t);
3632
+ n.fillStyle = Ee(n.canvas), n.beginPath(), n.roundRect(e - d / 2, t - f / 2, d, f, Mt), n.fill(), n.fillStyle = Ot, n.textAlign = "center", n.textBaseline = "middle", n.fillText(r, e, t);
3633
3633
  }
3634
3634
  }
3635
- class fe {
3635
+ class ue {
3636
3636
  /**
3637
3637
  * Render edit mode features: cursor and text selection highlight
3638
3638
  * This renders on the main canvas at world coordinates (same as the element)
@@ -3646,14 +3646,14 @@ class fe {
3646
3646
  }
3647
3647
  const p = r.fontSize || 24, y = r.fontFamily || "Arial", b = r.bold || !1, $ = r.italic || !1, x = r.underline || !1, w = r.strikethrough || !1, v = r.textAlign || "center";
3648
3648
  n.save(), n.translate(r.x, r.y), n.rotate(-r.rotation * Math.PI / 180);
3649
- const S = qe(p, y, b, $), T = S.height, k = p * 1.2;
3649
+ const S = Qe(p, y, b, $), T = S.height, k = p * 1.2;
3650
3650
  let _, C, E;
3651
3651
  if (d && r.transformType === "custom" && r.transformData.width) {
3652
3652
  const L = r.transformData.width - Xn * 2;
3653
3653
  E = L;
3654
- const D = Ye(d);
3654
+ const D = nt(d);
3655
3655
  _ = [], C = [], D.forEach((F) => {
3656
- const B = Ke(F, L, {
3656
+ const B = et(F, L, {
3657
3657
  fontSize: r.fontSize,
3658
3658
  fontFamily: r.fontFamily,
3659
3659
  bold: r.bold,
@@ -3686,7 +3686,7 @@ class fe {
3686
3686
  var U, V;
3687
3687
  const F = C[D].isParagraphStart, B = C[D].isParagraphEnd, M = [];
3688
3688
  L.forEach((dn) => {
3689
- Array.from(dn.text).forEach((mn) => {
3689
+ Array.from(dn.text).forEach((yn) => {
3690
3690
  let H = p, on = y, tn = b, J = $;
3691
3691
  if (d && W < c.length) {
3692
3692
  const Z = d.getStyleAt(W);
@@ -3695,12 +3695,12 @@ class fe {
3695
3695
  n.save();
3696
3696
  const an = tn ? "bold" : "normal", N = J ? "italic" : "normal";
3697
3697
  n.font = `${N} ${an} ${H}px "${on}", Arial, sans-serif`;
3698
- const Y = n.measureText(mn).width;
3699
- n.restore(), M.push({ char: mn, width: Y, fontSize: H, index: W }), W++;
3698
+ const Y = n.measureText(yn).width;
3699
+ n.restore(), M.push({ char: yn, width: Y, fontSize: H, index: W }), W++;
3700
3700
  });
3701
3701
  });
3702
3702
  {
3703
- const dn = D === 0, $n = D === _.length - 1, mn = M.map((N) => N.char).join(""), H = ((U = mn.match(/^ +/)) == null ? void 0 : U[0].length) || 0, on = ((V = mn.match(/ +$/)) == null ? void 0 : V[0].length) || 0;
3703
+ const dn = D === 0, $n = D === _.length - 1, yn = M.map((N) => N.char).join(""), H = ((U = yn.match(/^ +/)) == null ? void 0 : U[0].length) || 0, on = ((V = yn.match(/ +$/)) == null ? void 0 : V[0].length) || 0;
3704
3704
  let tn = 0;
3705
3705
  for (let N = 0; N < M.length; N++)
3706
3706
  !dn && N < H || !$n && N >= M.length - on || (tn += M[N].width);
@@ -3718,8 +3718,8 @@ class fe {
3718
3718
  }, an += Y.width;
3719
3719
  }
3720
3720
  if (M.length > 0) {
3721
- const N = M[0].index, Y = M[M.length - 1].index, yn = D < _.length - 1 && Y + 1 === W ? Y : Y + 1;
3722
- if (s >= N && s <= yn)
3721
+ const N = M[0].index, Y = M[M.length - 1].index, xn = D < _.length - 1 && Y + 1 === W ? Y : Y + 1;
3722
+ if (s >= N && s <= xn)
3723
3723
  if (s === N)
3724
3724
  R = J, z = A, O = T;
3725
3725
  else {
@@ -3743,16 +3743,16 @@ class fe {
3743
3743
  let q = null, Q = null;
3744
3744
  if (X) {
3745
3745
  const L = Math.min(o, l), D = Math.max(o, l);
3746
- n.save(), n.fillStyle = Rt(n.canvas);
3746
+ n.save(), n.fillStyle = Bt(n.canvas);
3747
3747
  let F = 0, B = -I / 2;
3748
3748
  if (_.forEach((M, U) => {
3749
3749
  var on, tn;
3750
- const V = C[U].isParagraphStart, dn = C[U].isParagraphEnd, $n = U === 0, mn = U === _.length - 1, H = [];
3750
+ const V = C[U].isParagraphStart, dn = C[U].isParagraphEnd, $n = U === 0, yn = U === _.length - 1, H = [];
3751
3751
  if (M.forEach((J) => {
3752
3752
  Array.from(J.text).forEach((an) => {
3753
- const N = J.style || {}, Y = N.fontSize !== void 0 ? N.fontSize : p, Z = N.fontFamily !== void 0 ? N.fontFamily : y, vn = N.bold !== void 0 ? N.bold : b, yn = N.italic !== void 0 ? N.italic : $;
3753
+ const N = J.style || {}, Y = N.fontSize !== void 0 ? N.fontSize : p, Z = N.fontFamily !== void 0 ? N.fontFamily : y, vn = N.bold !== void 0 ? N.bold : b, xn = N.italic !== void 0 ? N.italic : $;
3754
3754
  n.save();
3755
- const wn = vn ? "bold" : "normal", rn = yn ? "italic" : "normal";
3755
+ const wn = vn ? "bold" : "normal", rn = xn ? "italic" : "normal";
3756
3756
  n.font = `${rn} ${wn} ${Y}px "${Z}", Arial, sans-serif`;
3757
3757
  const fn = n.measureText(an).width;
3758
3758
  n.restore(), H.push({ char: an, index: F, width: fn, style: N }), F++;
@@ -3764,21 +3764,21 @@ class fe {
3764
3764
  const N = H.map((G) => G.char).join(""), Y = ((on = N.match(/^ +/)) == null ? void 0 : on[0].length) || 0, Z = ((tn = N.match(/ +$/)) == null ? void 0 : tn[0].length) || 0;
3765
3765
  let vn = 0;
3766
3766
  for (let G = 0; G < H.length; G++)
3767
- !$n && G < Y || !mn && G >= H.length - Z || (vn += H[G].width);
3768
- let yn = 0;
3769
- v === "center" ? yn = -vn / 2 : v === "right" && (yn = -vn);
3767
+ !$n && G < Y || !yn && G >= H.length - Z || (vn += H[G].width);
3768
+ let xn = 0;
3769
+ v === "center" ? xn = -vn / 2 : v === "right" && (xn = -vn);
3770
3770
  const wn = Math.max(L, J), rn = Math.min(D, an + 1);
3771
3771
  let fn = 0;
3772
3772
  for (let G = 0; G < H.length && H[G].index < wn; G++) {
3773
- const In = H[G], Dn = G < Y, ae = G >= H.length - Z, re = !V && Y > 0, se = !dn && Z > 0;
3774
- !(Dn && re || ae && se) && (fn += In.width);
3773
+ const In = H[G], Dn = G < Y, re = G >= H.length - Z, se = !V && Y > 0, ie = !dn && Z > 0;
3774
+ !(Dn && se || re && ie) && (fn += In.width);
3775
3775
  }
3776
3776
  let Hn = 0;
3777
3777
  for (let G = 0; G < H.length && H[G].index < rn; G++) {
3778
- const In = H[G], Dn = G < Y, ae = G >= H.length - Z, re = !V && Y > 0, se = !dn && Z > 0;
3779
- !(Dn && re || ae && se) && (Hn += In.width);
3778
+ const In = H[G], Dn = G < Y, re = G >= H.length - Z, se = !V && Y > 0, ie = !dn && Z > 0;
3779
+ !(Dn && se || re && ie) && (Hn += In.width);
3780
3780
  }
3781
- const Sn = yn + fn, Gn = Hn - fn;
3781
+ const Sn = xn + fn, Gn = Hn - fn;
3782
3782
  n.fillRect(Sn, B, Gn, T), q === null && (q = { x: Sn, y: B }), Q = { x: Sn + Gn, y: B + T }, n.restore();
3783
3783
  }
3784
3784
  }
@@ -3786,7 +3786,7 @@ class fe {
3786
3786
  }), n.restore(), d) {
3787
3787
  n.save();
3788
3788
  const M = r.transformType === "custom" ? r.transformData : null, U = M != null && M.width ? M.width - Xn * 2 : void 0;
3789
- Ft(n, d, {
3789
+ Lt(n, d, {
3790
3790
  fontSize: p,
3791
3791
  fontFamily: y,
3792
3792
  color: r.color || "#000000",
@@ -3828,7 +3828,7 @@ class fe {
3828
3828
  n.save(), n.translate(e.x, e.y), n.rotate(-e.rotation * Math.PI / 180);
3829
3829
  const f = c ? "bold" : "normal", h = d ? "italic" : "normal";
3830
3830
  n.font = `${h} ${f} ${o}px ${l}`;
3831
- const u = Array.from(e.text), g = u.map((p) => n.measureText(p).width), m = me.calculateCharPositions(e, u, g);
3831
+ const u = Array.from(e.text), g = u.map((p) => n.measureText(p).width), m = ye.calculateCharPositions(e, u, g);
3832
3832
  if (r >= 0 && r <= u.length && s > 0) {
3833
3833
  let p;
3834
3834
  if (r === 0)
@@ -3870,7 +3870,7 @@ class fe {
3870
3870
  if (!(e instanceof Un) || !e.isCropping) return;
3871
3871
  const r = e, s = r.getCropBoxBounds();
3872
3872
  if (!s) return;
3873
- const o = 4 / a, l = 2 / a, c = Mt / a, d = Ot / a, f = 1 / a;
3873
+ const o = 4 / a, l = 2 / a, c = Nt / a, d = Ut / a, f = 1 / a;
3874
3874
  n.save(), n.translate(e.x * a, e.y * a), n.rotate(pn.toRadians(e.rotation));
3875
3875
  const h = r.transformData.flipHorizontal ? -1 : 1, u = r.transformData.flipVertical ? -1 : 1;
3876
3876
  n.scale(h * a, u * a);
@@ -3932,7 +3932,7 @@ class fe {
3932
3932
  }
3933
3933
  }
3934
3934
  }
3935
- const za = xn("CanvasRenderer"), j = class j {
3935
+ const Va = mn("CanvasRenderer"), j = class j {
3936
3936
  /**
3937
3937
  * Get a pooled offscreen canvas for clipping content, only recreating
3938
3938
  * when dimensions change. Eliminates per-frame canvas allocation.
@@ -3956,7 +3956,7 @@ const za = xn("CanvasRenderer"), j = class j {
3956
3956
  e.render(n, t, a);
3957
3957
  } catch (r) {
3958
3958
  const s = r instanceof Error ? r : new Error(String(r));
3959
- za.error(`Failed to render element ${e.id}:`, s), j.onRenderError && j.onRenderError({
3959
+ Va.error(`Failed to render element ${e.id}:`, s), j.onRenderError && j.onRenderError({
3960
3960
  category: "render",
3961
3961
  message: `Failed to render element: ${s.message}`,
3962
3962
  originalError: s,
@@ -4083,7 +4083,7 @@ const za = xn("CanvasRenderer"), j = class j {
4083
4083
  ) : e.forEach((y) => {
4084
4084
  var T, k;
4085
4085
  if (m.has(y.id) || y.visible === !1) return;
4086
- const b = y.id === t, $ = (a == null ? void 0 : a.type) === "element" && ((T = a == null ? void 0 : a.data) == null ? void 0 : T.id) === y.id, x = f && h && le(y) && y.id === t, w = b && !x, v = u[e.indexOf(y)], S = ((k = v == null ? void 0 : v.distressEffect) == null ? void 0 : k.enabled) && v.distressEffect.style === "custom" && v.distressEffect.textureUrl;
4086
+ const b = y.id === t, $ = (a == null ? void 0 : a.type) === "element" && ((T = a == null ? void 0 : a.data) == null ? void 0 : T.id) === y.id, x = f && h && ce(y) && y.id === t, w = b && !x, v = u[e.indexOf(y)], S = ((k = v == null ? void 0 : v.distressEffect) == null ? void 0 : k.enabled) && v.distressEffect.style === "custom" && v.distressEffect.textureUrl;
4087
4087
  if (v && v.masks && v.masks.length > 0)
4088
4088
  An(n, v, (_) => {
4089
4089
  const C = (E) => {
@@ -4131,7 +4131,7 @@ const za = xn("CanvasRenderer"), j = class j {
4131
4131
  if (!b.mask)
4132
4132
  b.content.forEach(($, x) => {
4133
4133
  var _;
4134
- const w = $.id === a, v = (r == null ? void 0 : r.type) === "element" && ((_ = r == null ? void 0 : r.data) == null ? void 0 : _.id) === $.id, S = s && o && le($) && $.id === a, T = w && !S, k = b.contentConfigs[x];
4134
+ const w = $.id === a, v = (r == null ? void 0 : r.type) === "element" && ((_ = r == null ? void 0 : r.data) == null ? void 0 : _.id) === $.id, S = s && o && ce($) && $.id === a, T = w && !S, k = b.contentConfigs[x];
4135
4135
  k && k.masks && k.masks.length > 0 ? An(n, k, (C) => {
4136
4136
  c && (C.save(), C.globalAlpha = nn), $.render(C, T, v), c && C.restore();
4137
4137
  }) : (c && (n.save(), n.globalAlpha = nn), $.render(n, T, v), c && n.restore());
@@ -4141,7 +4141,7 @@ const za = xn("CanvasRenderer"), j = class j {
4141
4141
  if (!x) continue;
4142
4142
  x.setTransform(1, 0, 0, 1, 0, 0), x.clearRect(0, 0, f, h), x.globalCompositeOperation = "source-over", x.setTransform(u), b.content.forEach((k, _) => {
4143
4143
  var z;
4144
- const C = k.id === a, E = (r == null ? void 0 : r.type) === "element" && ((z = r == null ? void 0 : r.data) == null ? void 0 : z.id) === k.id, I = s && o && le(k) && k.id === a, A = C && !I, R = b.contentConfigs[_];
4144
+ const C = k.id === a, E = (r == null ? void 0 : r.type) === "element" && ((z = r == null ? void 0 : r.data) == null ? void 0 : z.id) === k.id, I = s && o && ce(k) && k.id === a, A = C && !I, R = b.contentConfigs[_];
4145
4145
  R && R.masks && R.masks.length > 0 ? An(x, R, (O) => {
4146
4146
  c && (O.save(), O.globalAlpha = nn), k.render(O, A, E), c && O.restore();
4147
4147
  }) : (c && (x.save(), x.globalAlpha = nn), k.render(x, A, E), c && x.restore());
@@ -4215,14 +4215,14 @@ const za = xn("CanvasRenderer"), j = class j {
4215
4215
  * @see HoverRenderer.renderHoverLayer
4216
4216
  */
4217
4217
  static renderHoverLayer(n, e, t, a = !1, r = 1, s) {
4218
- me.renderHoverLayer(n, e, t, a, r, s);
4218
+ ye.renderHoverLayer(n, e, t, a, r, s);
4219
4219
  }
4220
4220
  /**
4221
4221
  * Render crop box layer (for images in crop mode)
4222
4222
  * @see EditModeRenderer.renderCropBoxLayer
4223
4223
  */
4224
4224
  static renderCropBoxLayer(n, e, t, a = 1) {
4225
- fe.renderCropBoxLayer(n, e, t, a);
4225
+ ue.renderCropBoxLayer(n, e, t, a);
4226
4226
  }
4227
4227
  // =========================================================================
4228
4228
  // Main Render Orchestration
@@ -4270,7 +4270,7 @@ const za = xn("CanvasRenderer"), j = class j {
4270
4270
  h,
4271
4271
  m,
4272
4272
  p
4273
- ), y != null && y.enabled && f && ot(n, y, f, d), b != null && b.enabled && f && at(n, b, f, d), s && $ && a && fe.renderEditModeLayer(n, a, $, u), u !== 1) {
4273
+ ), y != null && y.enabled && f && ut(n, y, f, d), b != null && b.enabled && f && lt(n, b, f, d), s && $ && a && ue.renderEditModeLayer(n, a, $, u), u !== 1) {
4274
4274
  n.save();
4275
4275
  const S = n.getTransform().a / u, T = g.x * u * S, k = g.y * u * S;
4276
4276
  n.setTransform(S, 0, 0, S, T, k);
@@ -4331,8 +4331,8 @@ const za = xn("CanvasRenderer"), j = class j {
4331
4331
  const $ = n.getTransform().a / m, x = p.x * m * $, w = p.y * m * $;
4332
4332
  n.setTransform($, 0, 0, $, x, w);
4333
4333
  }
4334
- if (e && na(e) && e.isCropping)
4335
- t && fe.renderCropBoxLayer(n, e, t, m);
4334
+ if (e && ra(e) && e.isCropping)
4335
+ t && ue.renderCropBoxLayer(n, e, t, m);
4336
4336
  else if (!c && a && En.renderSelectionLayer(n, e, a, m), t && a && En.renderPositionSizeInfo(n, e, t, a, m), !c && t && a && En.renderHandlesLayer(
4337
4337
  n,
4338
4338
  e,
@@ -4349,19 +4349,19 @@ const za = xn("CanvasRenderer"), j = class j {
4349
4349
  const b = u, $ = b.x * m, x = b.y * m, w = b.width * m, v = b.height * m, S = (b.borderRadius ?? 0) * m;
4350
4350
  n.beginPath(), S > 0 ? n.roundRect($, x, w, v, S) : n.rect($, x, w, v), n.clip();
4351
4351
  }
4352
- me.renderHoverLayer(n, o, l, f, m, h), u && n.restore();
4352
+ ye.renderHoverLayer(n, o, l, f, m, h), u && n.restore();
4353
4353
  }
4354
4354
  m !== 1 && n.restore();
4355
4355
  }
4356
4356
  };
4357
4357
  j._contentCanvas = null, j._contentCanvasSize = { width: 0, height: 0 }, j._maskCanvas = null, j._maskCanvasSize = { width: 0, height: 0 }, j._cachedElementsRef = null, j._cachedElementConfigs = null, j._cachedElementMap = null, j._knockoutRenderedIds = /* @__PURE__ */ new Set(), j.onRenderError = null;
4358
- let Ne = j;
4359
- const Ue = xn("element-serializer"), lt = 4e3, zn = /* @__PURE__ */ new Set();
4360
- function Wa(i, n) {
4361
- const e = n ? Ha(n) : "no-src";
4358
+ let We = j;
4359
+ const He = mn("element-serializer"), ht = 4e3, zn = /* @__PURE__ */ new Set();
4360
+ function ja(i, n) {
4361
+ const e = n ? Xa(n) : "no-src";
4362
4362
  return `${i}:${e}`;
4363
4363
  }
4364
- function Ha(i) {
4364
+ function Xa(i) {
4365
4365
  let n = 0;
4366
4366
  for (let e = 0; e < i.length; e++) {
4367
4367
  const t = i.charCodeAt(e);
@@ -4369,20 +4369,20 @@ function Ha(i) {
4369
4369
  }
4370
4370
  return n.toString(36);
4371
4371
  }
4372
- function ye() {
4372
+ function xe() {
4373
4373
  zn.clear();
4374
4374
  }
4375
- function ct(i) {
4375
+ function pt(i) {
4376
4376
  for (const n of zn)
4377
4377
  n.startsWith(`${i}:`) && zn.delete(n);
4378
4378
  }
4379
- function Ga(i) {
4379
+ function qa(i) {
4380
4380
  zn.add(i);
4381
4381
  }
4382
- function Va(i) {
4382
+ function Ya(i) {
4383
4383
  return zn.has(i);
4384
4384
  }
4385
- async function ja(i, n = lt) {
4385
+ async function Ka(i, n = ht) {
4386
4386
  const { naturalWidth: e, naturalHeight: t } = i;
4387
4387
  if (e <= n && t <= n)
4388
4388
  return createImageBitmap(i);
@@ -4394,19 +4394,19 @@ async function ja(i, n = lt) {
4394
4394
  });
4395
4395
  }
4396
4396
  let Zn = null, Qn = null;
4397
- function Xa(i, n) {
4397
+ function Ja(i, n) {
4398
4398
  Zn = i, Qn = n;
4399
4399
  }
4400
- function qa() {
4400
+ function Za() {
4401
4401
  Zn = null, Qn = null;
4402
4402
  }
4403
- function ur() {
4404
- ye(), Zn && Zn();
4403
+ function br() {
4404
+ xe(), Zn && Zn();
4405
4405
  }
4406
- function hr(i) {
4407
- ct(i), Qn && Qn(i);
4406
+ function mr(i) {
4407
+ pt(i), Qn && Qn(i);
4408
4408
  }
4409
- function xe(i, n) {
4409
+ function $e(i, n) {
4410
4410
  const e = i;
4411
4411
  if (typeof e.fontFamily == "string" && n.add(e.fontFamily), e.richText && typeof e.richText == "object") {
4412
4412
  const t = e.richText;
@@ -4421,14 +4421,14 @@ function xe(i, n) {
4421
4421
  }
4422
4422
  if (e.children && Array.isArray(e.children))
4423
4423
  for (const t of e.children)
4424
- xe(t, n);
4424
+ $e(t, n);
4425
4425
  if (i.masks && Array.isArray(i.masks))
4426
4426
  for (const t of i.masks)
4427
- t.maskElement && xe(t.maskElement, n);
4427
+ t.maskElement && $e(t.maskElement, n);
4428
4428
  }
4429
- function ze(i) {
4429
+ function Ge(i) {
4430
4430
  if (typeof document > "u") return i;
4431
- const n = ne.getInstance();
4431
+ const n = ee.getInstance();
4432
4432
  return i.map((e) => {
4433
4433
  if (!(e != null && e.maskElement) || e.maskElement.transformType !== "image") return e;
4434
4434
  const t = e.maskElement.imageUrl;
@@ -4444,20 +4444,20 @@ function ze(i) {
4444
4444
  } : e;
4445
4445
  });
4446
4446
  }
4447
- async function We(i, n, e = lt) {
4447
+ async function Ve(i, n, e = ht) {
4448
4448
  const t = n.filter((l) => i.hasElementId(l.id)), a = [], r = [], s = /* @__PURE__ */ new Set();
4449
4449
  for (const l of t) {
4450
4450
  const c = l.toJSON();
4451
- if (xe(c, s), l instanceof Un && !l.imageElement) {
4452
- Ue.warn(`[element-serializer] Skipping image ${l.id}: image not loaded (state: ${l.imageLoadState})`);
4451
+ if ($e(c, s), l instanceof Un && !l.imageElement) {
4452
+ He.warn(`[element-serializer] Skipping image ${l.id}: image not loaded (state: ${l.imageLoadState})`);
4453
4453
  continue;
4454
4454
  }
4455
4455
  if (l instanceof Un && l.imageElement)
4456
4456
  try {
4457
- const d = Wa(l.id, l.imageUrl);
4458
- if (!Va(d)) {
4459
- const $ = await ja(l.imageElement, e);
4460
- r.push({ cacheKey: d, bitmap: $ }), Ga(d);
4457
+ const d = ja(l.id, l.imageUrl);
4458
+ if (!Ya(d)) {
4459
+ const $ = await Ka(l.imageElement, e);
4460
+ r.push({ cacheKey: d, bitmap: $ }), qa(d);
4461
4461
  }
4462
4462
  const h = l.transformData || {}, u = c.masks && c.masks.length > 0, g = u ? h.width : h.width * (h.cropWidth ?? 1), m = u ? h.height : h.height * (h.cropHeight ?? 1), p = {
4463
4463
  id: l.id,
@@ -4476,9 +4476,9 @@ async function We(i, n, e = lt) {
4476
4476
  }
4477
4477
  h.flipHorizontal && (p.flipHorizontal = h.flipHorizontal), h.flipVertical && (p.flipVertical = h.flipVertical), h.borderRadius && (p.borderRadius = h.borderRadius), l.opacity !== void 0 && (p.opacity = l.opacity);
4478
4478
  const b = p;
4479
- l.distressEffect && (b.distressEffect = { ...l.distressEffect }), c.masks && c.masks.length > 0 && (b.masks = ze(c.masks)), c.blendMode && (b.blendMode = c.blendMode), c.knockoutParts && (b.knockoutParts = c.knockoutParts), "getVisualBoundingBox" in l && typeof l.getVisualBoundingBox == "function" ? b._boundingBox = l.getVisualBoundingBox() : "getBoundingBox" in l && typeof l.getBoundingBox == "function" && (b._boundingBox = l.getBoundingBox()), a.push(b);
4479
+ l.distressEffect && (b.distressEffect = { ...l.distressEffect }), c.masks && c.masks.length > 0 && (b.masks = Ge(c.masks)), c.blendMode && (b.blendMode = c.blendMode), c.knockoutParts && (b.knockoutParts = c.knockoutParts), "getVisualBoundingBox" in l && typeof l.getVisualBoundingBox == "function" ? b._boundingBox = l.getVisualBoundingBox() : "getBoundingBox" in l && typeof l.getBoundingBox == "function" && (b._boundingBox = l.getBoundingBox()), a.push(b);
4480
4480
  } catch (d) {
4481
- Ue.error(`[element-serializer] Failed to create ImageBitmap for ${c.id}:`, d);
4481
+ He.error(`[element-serializer] Failed to create ImageBitmap for ${c.id}:`, d);
4482
4482
  }
4483
4483
  else {
4484
4484
  const d = {
@@ -4486,7 +4486,7 @@ async function We(i, n, e = lt) {
4486
4486
  type: c.transformType
4487
4487
  // Map transformType to type for worker compatibility
4488
4488
  };
4489
- d.masks && Array.isArray(d.masks) && d.masks.length > 0 && (d.masks = ze(d.masks)), "getVisualBoundingBox" in l && typeof l.getVisualBoundingBox == "function" ? d._boundingBox = l.getVisualBoundingBox() : "getBoundingBox" in l && typeof l.getBoundingBox == "function" && (d._boundingBox = l.getBoundingBox()), a.push(d);
4489
+ d.masks && Array.isArray(d.masks) && d.masks.length > 0 && (d.masks = Ge(d.masks)), "getVisualBoundingBox" in l && typeof l.getVisualBoundingBox == "function" ? d._boundingBox = l.getVisualBoundingBox() : "getBoundingBox" in l && typeof l.getBoundingBox == "function" && (d._boundingBox = l.getBoundingBox()), a.push(d);
4490
4490
  }
4491
4491
  }
4492
4492
  const o = Array.from(s);
@@ -4511,7 +4511,7 @@ async function We(i, n, e = lt) {
4511
4511
  newBitmaps: r
4512
4512
  };
4513
4513
  }
4514
- const Ya = `"use strict";
4514
+ const Qa = `"use strict";
4515
4515
  (() => {
4516
4516
  var __create = Object.create;
4517
4517
  var __defProp = Object.defineProperty;
@@ -28370,7 +28370,7 @@ const Ya = `"use strict";
28370
28370
  console.error("[Export Worker] Unhandled promise rejection:", event.reason);
28371
28371
  };
28372
28372
  })();
28373
- `, K = xn("WorkerExport");
28373
+ `, K = mn("WorkerExport");
28374
28374
  class Wn {
28375
28375
  constructor() {
28376
28376
  this.worker = null, this.workerBlobUrl = null, this.pendingRequests = /* @__PURE__ */ new Map(), this.requestQueue = [], this.blobRequestQueue = [], this.isProcessingQueue = !1, this.isReady = !1, this.readyPromise = null, this.requestIdCounter = 0, this.workerCrashCount = 0, this.MAX_CRASHES_BEFORE_FALLBACK = 3, this.lastCrashTime = 0, this.CRASH_RESET_TIMEOUT = 6e4, this.progressListeners = /* @__PURE__ */ new Set(), this.idleTimeout = null, this.IDLE_TIMEOUT_MS = 3e4;
@@ -28433,7 +28433,7 @@ class Wn {
28433
28433
  * Call this when exiting editor mode to free memory.
28434
28434
  */
28435
28435
  clearWorkerBitmapCache() {
28436
- if (ye(), this.worker && this.isReady) {
28436
+ if (xe(), this.worker && this.isReady) {
28437
28437
  const n = {
28438
28438
  type: "clear-all-bitmaps"
28439
28439
  };
@@ -28445,7 +28445,7 @@ class Wn {
28445
28445
  * Call this when an element is removed or its image source changes.
28446
28446
  */
28447
28447
  clearWorkerBitmap(n) {
28448
- if (ct(n), this.worker && this.isReady) {
28448
+ if (pt(n), this.worker && this.isReady) {
28449
28449
  const e = {
28450
28450
  type: "clear-bitmap",
28451
28451
  elementId: n
@@ -28475,7 +28475,7 @@ class Wn {
28475
28475
  try {
28476
28476
  let t;
28477
28477
  try {
28478
- const s = new Blob([Ya], { type: "application/javascript" });
28478
+ const s = new Blob([Qa], { type: "application/javascript" });
28479
28479
  t = URL.createObjectURL(s), this.workerBlobUrl = t;
28480
28480
  } catch (s) {
28481
28481
  K.error("Failed to create worker blob:", s), e(new Error(`Worker creation failed: ${s instanceof Error ? s.message : String(s)}`));
@@ -28489,7 +28489,7 @@ class Wn {
28489
28489
  const a = setTimeout(() => {
28490
28490
  e(new Error("Worker initialization timeout"));
28491
28491
  }, 15e3), r = (s) => {
28492
- s.data.type === "ready" && (clearTimeout(a), this.isReady = !0, Xa(
28492
+ s.data.type === "ready" && (clearTimeout(a), this.isReady = !0, Ja(
28493
28493
  () => this.clearWorkerBitmapCache(),
28494
28494
  (o) => this.clearWorkerBitmap(o)
28495
28495
  ), n());
@@ -28566,7 +28566,7 @@ class Wn {
28566
28566
  const { artboard: e, elements: t, config: a } = n;
28567
28567
  if ((!this.worker || !this.isReady) && await this.initialize(), !this.worker)
28568
28568
  throw new Error("Worker is not initialized");
28569
- const r = `export-${++this.requestIdCounter}-${Date.now()}`, s = performance.now(), { data: o, newBitmaps: l } = await We(e, t);
28569
+ const r = `export-${++this.requestIdCounter}-${Date.now()}`, s = performance.now(), { data: o, newBitmaps: l } = await Ve(e, t);
28570
28570
  l.length > 0 && this.registerBitmapsWithWorker(l);
28571
28571
  const c = {
28572
28572
  type: "export",
@@ -28623,7 +28623,7 @@ class Wn {
28623
28623
  const { artboard: e, elements: t, config: a } = n;
28624
28624
  if ((!this.worker || !this.isReady) && await this.initialize(), !this.worker)
28625
28625
  throw new Error("Worker is not initialized");
28626
- const r = `export-blob-${++this.requestIdCounter}-${Date.now()}`, s = performance.now(), { data: o, newBitmaps: l } = await We(e, t);
28626
+ const r = `export-blob-${++this.requestIdCounter}-${Date.now()}`, s = performance.now(), { data: o, newBitmaps: l } = await Ve(e, t);
28627
28627
  l.length > 0 && this.registerBitmapsWithWorker(l);
28628
28628
  const c = {
28629
28629
  type: "export",
@@ -28737,7 +28737,7 @@ class Wn {
28737
28737
  e.reject(new Error("Worker terminated")), this.pendingRequests.delete(n);
28738
28738
  for (; this.requestQueue.length > 0; )
28739
28739
  this.requestQueue.shift().reject(new Error("Worker terminated"));
28740
- this.worker.terminate(), this.worker = null, this.isReady = !1, this.readyPromise = null, ye(), qa(), this.workerBlobUrl && (URL.revokeObjectURL(this.workerBlobUrl), this.workerBlobUrl = null);
28740
+ this.worker.terminate(), this.worker = null, this.isReady = !1, this.readyPromise = null, xe(), Za(), this.workerBlobUrl && (URL.revokeObjectURL(this.workerBlobUrl), this.workerBlobUrl = null);
28741
28741
  }
28742
28742
  }
28743
28743
  /**
@@ -28753,30 +28753,30 @@ class Wn {
28753
28753
  }
28754
28754
  }
28755
28755
  let Pn = null;
28756
- function pr() {
28756
+ function yr() {
28757
28757
  return Pn || (Pn = new Wn()), Pn;
28758
28758
  }
28759
- function gr() {
28759
+ function xr() {
28760
28760
  Pn && (Pn.terminate(), Pn = null);
28761
28761
  }
28762
- const hn = xn("Export");
28763
- function $e(i, n) {
28762
+ const hn = mn("Export");
28763
+ function ve(i, n) {
28764
28764
  var e;
28765
28765
  if (!(!i || typeof i != "object")) {
28766
28766
  if (typeof i.fontFamily == "string" && i.fontFamily.trim() && n.add(i.fontFamily), i.richText && Array.isArray(i.richText.spans))
28767
28767
  for (const t of i.richText.spans)
28768
28768
  (e = t == null ? void 0 : t.style) != null && e.fontFamily && typeof t.style.fontFamily == "string" && n.add(t.style.fontFamily);
28769
28769
  if (Array.isArray(i.children))
28770
- for (const t of i.children) $e(t, n);
28770
+ for (const t of i.children) ve(t, n);
28771
28771
  if (Array.isArray(i.masks))
28772
28772
  for (const t of i.masks)
28773
- t != null && t.maskElement && $e(t.maskElement, n);
28773
+ t != null && t.maskElement && ve(t.maskElement, n);
28774
28774
  }
28775
28775
  }
28776
- async function He(i) {
28776
+ async function je(i) {
28777
28777
  if (typeof document > "u" || !document.fonts) return;
28778
28778
  const n = /* @__PURE__ */ new Set();
28779
- for (const t of i) $e(t, n);
28779
+ for (const t of i) ve(t, n);
28780
28780
  if (n.size === 0) return;
28781
28781
  const e = [];
28782
28782
  for (const t of n)
@@ -28944,7 +28944,7 @@ const Nn = class Nn {
28944
28944
  transparentBackground: l = !1,
28945
28945
  backgroundColor: c = n.backgroundColor
28946
28946
  } = a;
28947
- await He(e);
28947
+ await je(e);
28948
28948
  const d = document.createElement("canvas"), f = n.width * o, h = n.height * o;
28949
28949
  d.width = f, d.height = h;
28950
28950
  const u = d.getContext("2d");
@@ -29012,7 +29012,7 @@ const Nn = class Nn {
29012
29012
  transparentBackground: l = !1,
29013
29013
  backgroundColor: c = n.backgroundColor
29014
29014
  } = a;
29015
- await He(e);
29015
+ await je(e);
29016
29016
  const d = document.createElement("canvas"), f = n.width * o, h = n.height * o;
29017
29017
  d.width = f, d.height = h;
29018
29018
  const u = d.getContext("2d");
@@ -29072,12 +29072,12 @@ const Nn = class Nn {
29072
29072
  } else
29073
29073
  S.render(u, !1);
29074
29074
  }
29075
- }), (w = n.distressTexture) != null && w.enabled && ot(u, n.distressTexture, {
29075
+ }), (w = n.distressTexture) != null && w.enabled && ut(u, n.distressTexture, {
29076
29076
  x: n.x,
29077
29077
  y: n.y,
29078
29078
  width: n.width,
29079
29079
  height: n.height
29080
- }), (v = n.imageMask) != null && v.enabled && at(u, n.imageMask, {
29080
+ }), (v = n.imageMask) != null && v.enabled && lt(u, n.imageMask, {
29081
29081
  x: n.x,
29082
29082
  y: n.y,
29083
29083
  width: n.width,
@@ -29317,8 +29317,8 @@ const Nn = class Nn {
29317
29317
  }
29318
29318
  };
29319
29319
  Nn.CURRENT_VERSION = "2.0.0", Nn.workerManager = null, Nn.workerInitPromise = null;
29320
- let Ge = Nn;
29321
- class dt {
29320
+ let Xe = Nn;
29321
+ class ne {
29322
29322
  /**
29323
29323
  * Create an element instance from a JSON configuration
29324
29324
  * TypeScript ensures all transform types are handled
@@ -29331,27 +29331,27 @@ class dt {
29331
29331
  const { transformType: e } = n;
29332
29332
  switch (e) {
29333
29333
  case "custom":
29334
- return new Ht(n);
29334
+ return new Xt(n);
29335
29335
  case "distort":
29336
29336
  throw new Error("DistortTransform is not yet implemented");
29337
29337
  case "circle":
29338
- return new Wt(n);
29338
+ return new jt(n);
29339
29339
  case "lean":
29340
- return new zt(n);
29340
+ return new Vt(n);
29341
29341
  case "arch":
29342
- return new Ut(n);
29342
+ return new Gt(n);
29343
29343
  case "ascend":
29344
- return new Nt(n);
29344
+ return new Ht(n);
29345
29345
  case "wave":
29346
- return new Lt(n);
29346
+ return new Wt(n);
29347
29347
  case "flag":
29348
- return new Bt(n);
29348
+ return new zt(n);
29349
29349
  case "image":
29350
29350
  return new Un(n);
29351
29351
  case "group":
29352
29352
  const t = (n.children || []).map(
29353
- (s) => dt.createFromJSON(s)
29354
- ), a = new Ve({
29353
+ (s) => ne.createFromJSON(s)
29354
+ ), a = new Ke({
29355
29355
  id: n.id,
29356
29356
  x: n.x,
29357
29357
  y: n.y,
@@ -29359,9 +29359,9 @@ class dt {
29359
29359
  });
29360
29360
  return t.forEach((s) => a.addChild(s)), a;
29361
29361
  case "shape":
29362
- return new Xe(n);
29362
+ return new Ze(n);
29363
29363
  case "path":
29364
- return new je(n);
29364
+ return new Je(n);
29365
29365
  default:
29366
29366
  const r = e;
29367
29367
  throw new Error(`Unknown transform type: ${r}`);
@@ -29575,43 +29575,260 @@ class dt {
29575
29575
  return this.createFromJSON(e);
29576
29576
  }
29577
29577
  }
29578
+ const qe = mn("ImportManager"), Ce = class Ce {
29579
+ /**
29580
+ * Import workspace from JSON file
29581
+ */
29582
+ static async importFromJSON(n) {
29583
+ try {
29584
+ const e = await this.readFileAsText(n), t = JSON.parse(e);
29585
+ if (this.validateDocument(t), !this.SUPPORTED_VERSIONS.includes(t.metadata.version))
29586
+ throw new Error(
29587
+ `Unsupported version: ${t.metadata.version}. Supported versions: ${this.SUPPORTED_VERSIONS.join(", ")}`
29588
+ );
29589
+ if (t.metadata.version === "1.0.0")
29590
+ return this.migrateV1Document(t);
29591
+ const a = [], r = [];
29592
+ return t.artboards.forEach((s) => {
29593
+ const o = Ae.fromJSON({
29594
+ id: s.id,
29595
+ name: s.name,
29596
+ x: s.x,
29597
+ y: s.y,
29598
+ width: s.width,
29599
+ height: s.height,
29600
+ backgroundColor: s.backgroundColor,
29601
+ elementIds: s.elements.map((c) => c.id || "")
29602
+ }), l = s.elements.map((c) => {
29603
+ try {
29604
+ return ne.createFromJSON(c);
29605
+ } catch (d) {
29606
+ return qe.error("Failed to create element:", c, d), null;
29607
+ }
29608
+ }).filter((c) => c !== null);
29609
+ a.push(o), r.push(...l);
29610
+ }), await this.preloadAllImages(r), {
29611
+ success: !0,
29612
+ artboards: a,
29613
+ elements: r,
29614
+ activeArtboardId: t.activeArtboardId
29615
+ };
29616
+ } catch (e) {
29617
+ return {
29618
+ success: !1,
29619
+ error: e instanceof Error ? e.message : "Unknown error"
29620
+ };
29621
+ }
29622
+ }
29623
+ /**
29624
+ * Migrate v1 document (no artboards) to v2 (with artboards)
29625
+ */
29626
+ static async migrateV1Document(n) {
29627
+ var e, t, a;
29628
+ try {
29629
+ const r = n.elements || [], s = new Ae({
29630
+ id: "artboard-migrated",
29631
+ name: "Artboard 1",
29632
+ x: 0,
29633
+ y: 0,
29634
+ width: ((e = n.canvas) == null ? void 0 : e.width) || 1920,
29635
+ height: ((t = n.canvas) == null ? void 0 : t.height) || 1080,
29636
+ backgroundColor: ((a = n.canvas) == null ? void 0 : a.backgroundColor) || "#ffffff"
29637
+ }), o = r.map((l) => {
29638
+ try {
29639
+ return ne.createFromJSON(l);
29640
+ } catch (c) {
29641
+ return qe.error("Failed to create element:", l, c), null;
29642
+ }
29643
+ }).filter((l) => l !== null);
29644
+ return o.forEach((l) => {
29645
+ s.addElementId(l.id);
29646
+ }), await this.preloadAllImages(o), {
29647
+ success: !0,
29648
+ artboards: [s],
29649
+ elements: o,
29650
+ activeArtboardId: s.id
29651
+ };
29652
+ } catch (r) {
29653
+ return {
29654
+ success: !1,
29655
+ error: r instanceof Error ? r.message : "Migration failed"
29656
+ };
29657
+ }
29658
+ }
29659
+ /**
29660
+ * Import image file
29661
+ */
29662
+ static async importImage(n) {
29663
+ try {
29664
+ if (!n.type.startsWith("image/"))
29665
+ throw new Error("File is not an image");
29666
+ const e = 10 * 1024 * 1024;
29667
+ if (n.size > e)
29668
+ throw new Error("Image file is too large (max 10MB)");
29669
+ const t = await this.readFileAsDataURL(n), { width: a, height: r } = await this.getImageDimensions(t);
29670
+ return {
29671
+ success: !0,
29672
+ dataUrl: t,
29673
+ filename: n.name,
29674
+ width: a,
29675
+ height: r
29676
+ };
29677
+ } catch (e) {
29678
+ return {
29679
+ success: !1,
29680
+ error: e instanceof Error ? e.message : "Unknown error"
29681
+ };
29682
+ }
29683
+ }
29684
+ /**
29685
+ * Validate document structure
29686
+ */
29687
+ static validateDocument(n) {
29688
+ if (!n || typeof n != "object")
29689
+ throw new Error("Invalid document");
29690
+ const e = n;
29691
+ if (!e.metadata)
29692
+ throw new Error("Missing metadata");
29693
+ if (!e.metadata.version)
29694
+ throw new Error("Missing version in metadata");
29695
+ if (!e.artboards && !e.elements)
29696
+ throw new Error("Missing artboards or elements array");
29697
+ if (e.artboards && !Array.isArray(e.artboards))
29698
+ throw new Error("Invalid artboards array");
29699
+ }
29700
+ /**
29701
+ * Read file as text
29702
+ */
29703
+ static readFileAsText(n) {
29704
+ return new Promise((e, t) => {
29705
+ const a = new FileReader();
29706
+ a.onload = (r) => {
29707
+ var s;
29708
+ return e((s = r.target) == null ? void 0 : s.result);
29709
+ }, a.onerror = () => t(new Error("Failed to read file")), a.readAsText(n);
29710
+ });
29711
+ }
29712
+ /**
29713
+ * Read file as data URL
29714
+ */
29715
+ static readFileAsDataURL(n) {
29716
+ return new Promise((e, t) => {
29717
+ const a = new FileReader();
29718
+ a.onload = (r) => {
29719
+ var s;
29720
+ return e((s = r.target) == null ? void 0 : s.result);
29721
+ }, a.onerror = () => t(new Error("Failed to read file")), a.readAsDataURL(n);
29722
+ });
29723
+ }
29724
+ /**
29725
+ * Get image dimensions from data URL
29726
+ */
29727
+ static getImageDimensions(n) {
29728
+ return new Promise((e, t) => {
29729
+ const a = new Image();
29730
+ a.onload = () => {
29731
+ e({ width: a.width, height: a.height });
29732
+ }, a.onerror = () => t(new Error("Failed to load image")), a.src = n;
29733
+ });
29734
+ }
29735
+ /**
29736
+ * Validate imported data before applying to state
29737
+ */
29738
+ static validateImportedData(n, e) {
29739
+ const t = [], a = /* @__PURE__ */ new Set();
29740
+ n.forEach((s) => {
29741
+ a.has(s.id) && t.push(`Duplicate artboard ID: ${s.id}`), a.add(s.id);
29742
+ });
29743
+ const r = /* @__PURE__ */ new Set();
29744
+ return e.forEach((s) => {
29745
+ r.has(s.id) && t.push(`Duplicate element ID: ${s.id}`), r.add(s.id);
29746
+ }), n.forEach((s) => {
29747
+ s.getElementIds().forEach((o) => {
29748
+ r.has(o) || t.push(`Artboard "${s.name}" references missing element: ${o}`);
29749
+ });
29750
+ }), {
29751
+ valid: t.length === 0,
29752
+ errors: t
29753
+ };
29754
+ }
29755
+ /**
29756
+ * Get import summary (for UI display before confirming)
29757
+ */
29758
+ static getImportSummary(n, e) {
29759
+ const t = this.validateImportedData(n, e);
29760
+ return {
29761
+ artboardCount: n.length,
29762
+ elementCount: e.length,
29763
+ artboardNames: n.map((a) => a.name),
29764
+ warnings: t.errors
29765
+ };
29766
+ }
29767
+ /**
29768
+ * Preload all images in parallel for fast artboard switching
29769
+ * Recursively finds all ImageElements (including those in groups)
29770
+ */
29771
+ static async preloadAllImages(n) {
29772
+ const e = [], t = (r) => {
29773
+ r.transformType === "image" ? e.push(r) : r.transformType === "group" && "children" in r && r.children.forEach((s) => t(s));
29774
+ };
29775
+ n.forEach(t);
29776
+ const a = e.map((r) => new Promise((s) => {
29777
+ if (r.imageLoaded)
29778
+ s();
29779
+ else if (r.imageElement) {
29780
+ const o = r.imageElement, l = () => {
29781
+ o.removeEventListener("load", l), o.removeEventListener("error", c), s();
29782
+ }, c = () => {
29783
+ o.removeEventListener("load", l), o.removeEventListener("error", c), s();
29784
+ };
29785
+ o.addEventListener("load", l), o.addEventListener("error", c);
29786
+ } else
29787
+ s();
29788
+ }));
29789
+ await Promise.all(a);
29790
+ }
29791
+ };
29792
+ Ce.SUPPORTED_VERSIONS = ["1.0.0", "2.0.0"];
29793
+ let Ye = Ce;
29578
29794
  export {
29579
- Ze as A,
29580
- ct as B,
29581
- Ne as C,
29582
- Oa as D,
29583
- dt as E,
29584
- tr as I,
29585
- Sa as M,
29586
- Jt as R,
29587
- rr as S,
29588
- cn as T,
29795
+ at as A,
29796
+ xr as B,
29797
+ We as C,
29798
+ Ua as D,
29799
+ ne as E,
29800
+ pt as F,
29801
+ Ye as I,
29802
+ _a as M,
29803
+ ea as R,
29804
+ lr as S,
29805
+ rr as T,
29589
29806
  Wn as W,
29590
- Ca as a,
29591
- Ge as b,
29592
- le as c,
29593
- or as d,
29594
- Na as e,
29595
- ir as f,
29596
- sr as g,
29597
- _e as h,
29598
- na as i,
29599
- Za as j,
29600
- Ja as k,
29601
- er as l,
29602
- nr as m,
29603
- ar as n,
29604
- lt as o,
29605
- fr as p,
29606
- ur as q,
29607
- Qa as r,
29608
- dr as s,
29609
- ye as t,
29610
- pr as u,
29611
- cr as v,
29807
+ ra as a,
29808
+ fr as b,
29809
+ dr as c,
29810
+ cr as d,
29811
+ tr as e,
29812
+ er as f,
29813
+ Pe as g,
29814
+ sr as h,
29815
+ ce as i,
29816
+ or as j,
29817
+ ir as k,
29818
+ Ha as l,
29819
+ Xe as m,
29820
+ cn as n,
29821
+ Ea as o,
29822
+ gr as p,
29823
+ ht as q,
29824
+ ar as r,
29825
+ br as s,
29826
+ pr as t,
29827
+ xe as u,
29828
+ yr as v,
29612
29829
  hr as w,
29613
- lr as x,
29614
- An as y,
29615
- gr as z
29830
+ mr as x,
29831
+ ur as y,
29832
+ An as z
29616
29833
  };
29617
- //# sourceMappingURL=ElementFactory-Ckv6sSev.js.map
29834
+ //# sourceMappingURL=ImportManager-Oqu2yB54.js.map