@snowcone-app/canvas 0.19.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/{CanvasRenderer-DUc-MOeR.js → CanvasRenderer-CwiYq8qg.js} +3 -3
  2. package/dist/{CanvasRenderer-DUc-MOeR.js.map → CanvasRenderer-CwiYq8qg.js.map} +1 -1
  3. package/dist/{CanvasStateV1-Bq48qhv5.js → CanvasStateV1-BFabcAKC.js} +35 -30
  4. package/dist/{CanvasStateV1-Bq48qhv5.js.map → CanvasStateV1-BFabcAKC.js.map} +1 -1
  5. package/dist/{ContextualToolbars-CkLjHNPn.js → ContextualToolbars--vTtorNg.js} +5 -5
  6. package/dist/{ContextualToolbars-CkLjHNPn.js.map → ContextualToolbars--vTtorNg.js.map} +1 -1
  7. package/dist/{EditorCanvasImpl-Cthm-KSe.js → EditorCanvasImpl-UBKdG0c0.js} +18 -17
  8. package/dist/{EditorCanvasImpl-Cthm-KSe.js.map → EditorCanvasImpl-UBKdG0c0.js.map} +1 -1
  9. package/dist/{ImportManager-D--7JnvW.js → ExportManager-DK7CdI-G.js} +24758 -24758
  10. package/dist/ExportManager-DK7CdI-G.js.map +1 -0
  11. package/dist/{FontAnalyzer-DIlqmyuf.js → FontAnalyzer-BpsTYowD.js} +5 -2
  12. package/dist/FontAnalyzer-BpsTYowD.js.map +1 -0
  13. package/dist/SnowconeCanvas-B01o5LmS.js +1172 -0
  14. package/dist/SnowconeCanvas-B01o5LmS.js.map +1 -0
  15. package/dist/{MenuButton-CeoEAtzP.js → UnifiedFontService-B1PGVu8O.js} +3704 -3429
  16. package/dist/UnifiedFontService-B1PGVu8O.js.map +1 -0
  17. package/dist/advanced.mjs +13 -13
  18. package/dist/api/embed.d.ts +4 -2
  19. package/dist/api/stable.d.ts +2 -2
  20. package/dist/components/editor/commerceStore.d.ts +22 -2
  21. package/dist/components/editor/index.d.ts +1 -0
  22. package/dist/components/editor/useProductSelection.d.ts +15 -9
  23. package/dist/components/embed/SnowconeCanvas.d.ts +10 -2
  24. package/dist/core/ArtboardElement.d.ts +2 -1
  25. package/dist/default-editor/SnowconeEditor.d.ts +39 -0
  26. package/dist/design/design-builder.d.ts +44 -19
  27. package/dist/design/template-fields.d.ts +32 -0
  28. package/dist/design-builder-DMKx9UXD.js +368 -0
  29. package/dist/design-builder-DMKx9UXD.js.map +1 -0
  30. package/dist/{EditorContext-5QpqAhjh.js → editorErrors-CK1RISFa.js} +382 -358
  31. package/dist/editorErrors-CK1RISFa.js.map +1 -0
  32. package/dist/embed-uALcVSYN.js +1117 -0
  33. package/dist/embed-uALcVSYN.js.map +1 -0
  34. package/dist/embed.mjs +33 -31
  35. package/dist/hooks/useArtboards.d.ts +2 -1
  36. package/dist/index.mjs +8 -8
  37. package/dist/internals.mjs +5 -5
  38. package/dist/kits/sections.d.ts +11 -7
  39. package/dist/rendering/serialize-for-server.d.ts +3 -0
  40. package/dist/state/CanvasStateV1.d.ts +12 -0
  41. package/dist/template-fields-B9RagVpT.js +476 -0
  42. package/dist/template-fields-B9RagVpT.js.map +1 -0
  43. package/dist/testing.mjs +8 -8
  44. package/dist/types/index.d.ts +10 -0
  45. package/dist/{usePieceGuideBundle-DVOISsB1.js → usePieceGuideBundle-Ctnu5k2D.js} +2 -2
  46. package/dist/{usePieceGuideBundle-DVOISsB1.js.map → usePieceGuideBundle-Ctnu5k2D.js.map} +1 -1
  47. package/dist/{validation-0IscSfRb.js → validation-3YEMnKLB.js} +467 -463
  48. package/dist/validation-3YEMnKLB.js.map +1 -0
  49. package/package.json +6 -5
  50. package/dist/EditorContext-5QpqAhjh.js.map +0 -1
  51. package/dist/FontAnalyzer-DIlqmyuf.js.map +0 -1
  52. package/dist/ImportManager-D--7JnvW.js.map +0 -1
  53. package/dist/MenuButton-CeoEAtzP.js.map +0 -1
  54. package/dist/SnowconeCanvas-3PA17na3.js +0 -1166
  55. package/dist/SnowconeCanvas-3PA17na3.js.map +0 -1
  56. package/dist/design-builder-v4935TeS.js +0 -343
  57. package/dist/design-builder-v4935TeS.js.map +0 -1
  58. package/dist/editorErrors-DXNfVXtD.js +0 -29
  59. package/dist/editorErrors-DXNfVXtD.js.map +0 -1
  60. package/dist/embed-D0HHwCIO.js +0 -1093
  61. package/dist/embed-D0HHwCIO.js.map +0 -1
  62. package/dist/template-fields-Dr3fMItw.js +0 -329
  63. package/dist/template-fields-Dr3fMItw.js.map +0 -1
  64. package/dist/validation-0IscSfRb.js.map +0 -1
@@ -1,13 +1,13 @@
1
1
  import { jsx as H } from "react/jsx-runtime";
2
- import { useContext as X, useSyncExternalStore as ot, useCallback as a, createContext as Q, useRef as ue, useState as E, useEffect as Ce, useMemo as q } from "react";
3
- import { y as He, N as rt, a9 as it, aa as ct, G as _e, ab as st, ac as dt, ad as at, ae as lt, af as ut, c as ke, z as mt, ag as ft, ah as At, ai as pt, E as ht, L as Ve, I as xt, g as yt, S as Et, aj as St, ak as Ne } from "./FontAnalyzer-DIlqmyuf.js";
4
- const We = Q(null), bt = () => () => {
5
- }, De = () => 0;
6
- function Xt() {
7
- const t = X(We), e = ot(
8
- t ? t.subscribe : bt,
9
- t ? t.getVersion : De,
10
- t ? t.getVersion : De
2
+ import { useContext as X, useSyncExternalStore as rt, useCallback as a, createContext as Q, useRef as me, useState as E, useEffect as ve, useMemo as q } from "react";
3
+ import { y as Ve, N as it, a9 as st, aa as ct, G as ke, ab as dt, ac as at, ad as lt, ae as ut, af as mt, c as $e, z as ft, ag as At, ah as pt, ai as ht, E as xt, L as Ne, I as yt, g as Et, S as St, aj as bt, ak as De } from "./FontAnalyzer-BpsTYowD.js";
4
+ const We = Q(null), It = () => () => {
5
+ }, Le = () => 0;
6
+ function Jt() {
7
+ const t = X(We), e = rt(
8
+ t ? t.subscribe : It,
9
+ t ? t.getVersion : Le,
10
+ t ? t.getVersion : Le
11
11
  );
12
12
  return a(
13
13
  (o) => !!(t && o && t.getBoundLayer(o)),
@@ -16,27 +16,27 @@ function Xt() {
16
16
  [t, e]
17
17
  );
18
18
  }
19
- class It extends Error {
19
+ class wt extends Error {
20
20
  constructor(e, o, n = {}) {
21
21
  super(`[Editor] ${e}: ${o}`), this.name = "EditorError", this.code = e, this.data = { code: e, ...n };
22
22
  }
23
23
  }
24
- function Yt(t) {
24
+ function gt(t) {
25
25
  return t instanceof Error && t.name === "EditorError" && "code" in t;
26
26
  }
27
- function jt() {
27
+ function Tt() {
28
28
  var t;
29
- return typeof He < "u" && ((t = He.env) == null ? void 0 : t.NODE_ENV) !== "production";
29
+ return typeof Ve < "u" && ((t = Ve.env) == null ? void 0 : t.NODE_ENV) !== "production";
30
30
  }
31
- const fe = ke("useCommandHistory");
32
- function wt(t, e, o, n) {
33
- const d = ue(new rt(o)), l = X(We), i = a(
34
- (c, A) => {
35
- const y = c == null ? void 0 : c.name;
31
+ const Ae = $e("useCommandHistory");
32
+ function Pt(t, e, o, n) {
33
+ const d = me(new it(o)), l = X(We), i = a(
34
+ (s, A) => {
35
+ const y = s == null ? void 0 : s.name;
36
36
  if (!l || !y) return;
37
37
  const x = l.getBoundLayer(y);
38
38
  if (x)
39
- throw new It(
39
+ throw new wt(
40
40
  "E_BOUND_LAYER_MUTATION",
41
41
  `cannot ${A} layer "${y}" — a mounted <${x.part} layer={design.layer("${y}")}> is bound to it. Unmount that field first, or keep the layer and set its text through the field / its binding instead.`,
42
42
  { layer: y, part: x.part, operation: A, docSlug: "embed-mode" }
@@ -49,24 +49,24 @@ function wt(t, e, o, n) {
49
49
  // Per-artboard state for the active artboard
50
50
  canUndoActiveArtboard: !1,
51
51
  canRedoActiveArtboard: !1
52
- }), s = a(() => {
53
- const c = d.current, A = o.getActiveArtboardId();
52
+ }), c = a(() => {
53
+ const s = d.current, A = o.getActiveArtboardId();
54
54
  u({
55
- canUndo: c.canUndo(),
56
- canRedo: c.canRedo(),
55
+ canUndo: s.canUndo(),
56
+ canRedo: s.canRedo(),
57
57
  // Per-artboard state - only check active artboard's history
58
- canUndoActiveArtboard: A ? c.canUndoArtboard(A) : !1,
59
- canRedoActiveArtboard: A ? c.canRedoArtboard(A) : !1
58
+ canUndoActiveArtboard: A ? s.canUndoArtboard(A) : !1,
59
+ canRedoActiveArtboard: A ? s.canRedoArtboard(A) : !1
60
60
  });
61
61
  }, [o]), V = a(
62
- (c, A) => {
63
- c && c.name !== A.name && i(c, "rename");
64
- const y = new it(
62
+ (s, A) => {
63
+ s && s.name !== A.name && i(s, "rename");
64
+ const y = new st(
65
65
  A.id,
66
- c || null,
66
+ s || null,
67
67
  A,
68
68
  (P) => {
69
- e((k) => k.map((C) => C.id === P.id ? P : C));
69
+ e((k) => k.map((R) => R.id === P.id ? P : R));
70
70
  }
71
71
  ), x = o.getArtboardIdForElement(A.id);
72
72
  if (x)
@@ -75,67 +75,67 @@ function wt(t, e, o, n) {
75
75
  const P = o.getActiveArtboardId();
76
76
  P && d.current.executeOnArtboard(P, y);
77
77
  }
78
- s();
78
+ c();
79
79
  },
80
- [e, o, s, i]
80
+ [e, o, c, i]
81
81
  ), O = a(
82
- (c, A, y, x) => {
82
+ (s, A, y, x) => {
83
83
  const P = A || o.getActiveArtboardId();
84
84
  if (!P) {
85
- fe.warn("No active artboard to add element to");
85
+ Ae.warn("No active artboard to add element to");
86
86
  return;
87
87
  }
88
88
  const k = new ct(
89
- c,
90
- (C) => {
91
- const N = C;
89
+ s,
90
+ (R) => {
91
+ const N = R;
92
92
  e((v) => {
93
93
  if (x) {
94
- const U = v.findIndex((R) => R.id === x);
94
+ const U = v.findIndex((F) => F.id === x);
95
95
  if (U !== -1) {
96
- const R = [...v];
97
- return R.splice(U, 0, N), R;
96
+ const F = [...v];
97
+ return F.splice(U, 0, N), F;
98
98
  }
99
99
  }
100
100
  if (y) {
101
- const U = v.findIndex((R) => R.id === y);
101
+ const U = v.findIndex((F) => F.id === y);
102
102
  if (U !== -1) {
103
- const R = [...v];
104
- return R.splice(U + 1, 0, N), R;
103
+ const F = [...v];
104
+ return F.splice(U + 1, 0, N), F;
105
105
  }
106
- for (let R = 0; R < v.length; R++) {
107
- const Y = v[R];
108
- if (Y instanceof _e && Y.children) {
109
- const ne = Y.children.findIndex((j) => j.id === y);
106
+ for (let F = 0; F < v.length; F++) {
107
+ const j = v[F];
108
+ if (j instanceof ke && j.children) {
109
+ const ne = j.children.findIndex((Y) => Y.id === y);
110
110
  if (ne !== -1) {
111
- const j = Y.clone();
112
- j.children.splice(ne + 1, 0, N);
111
+ const Y = j.clone();
112
+ Y.children.splice(ne + 1, 0, N);
113
113
  const J = [...v];
114
- return J[R] = j, J;
114
+ return J[F] = Y, J;
115
115
  }
116
116
  }
117
117
  }
118
118
  }
119
119
  return [...v, N];
120
- }), o.addElementToArtboard(C.id, P);
120
+ }), o.addElementToArtboard(R.id, P);
121
121
  },
122
- (C) => {
123
- e((N) => N.filter((v) => v.id !== C)), o.removeElementFromArtboard(C);
122
+ (R) => {
123
+ e((N) => N.filter((v) => v.id !== R)), o.removeElementFromArtboard(R);
124
124
  }
125
125
  );
126
- d.current.executeOnArtboard(P, k), s();
126
+ d.current.executeOnArtboard(P, k), c();
127
127
  },
128
- [e, o, s]
128
+ [e, o, c]
129
129
  ), D = a(
130
- (c) => {
131
- i(c, "delete");
132
- const A = o.getArtboardIdForElement(c.id);
130
+ (s) => {
131
+ i(s, "delete");
132
+ const A = o.getArtboardIdForElement(s.id);
133
133
  if (!A) {
134
- fe.warn("Element not found in any artboard");
134
+ Ae.warn("Element not found in any artboard");
135
135
  return;
136
136
  }
137
- const y = new st(
138
- c,
137
+ const y = new dt(
138
+ s,
139
139
  (x) => {
140
140
  e((P) => [...P, x]), o.addElementToArtboard(x.id, A);
141
141
  },
@@ -143,37 +143,37 @@ function wt(t, e, o, n) {
143
143
  e((P) => P.filter((k) => k.id !== x)), o.removeElementFromArtboard(x);
144
144
  }
145
145
  );
146
- d.current.executeOnArtboard(A, y), s();
146
+ d.current.executeOnArtboard(A, y), c();
147
147
  },
148
- [e, o, s, i]
148
+ [e, o, c, i]
149
149
  ), w = a(
150
- (c) => {
151
- const A = new dt(c, o);
152
- d.current.executeGlobal(A), s(), n == null || n();
150
+ (s) => {
151
+ const A = new at(s, o);
152
+ d.current.executeGlobal(A), c(), n == null || n();
153
153
  },
154
- [o, s, n]
154
+ [o, c, n]
155
155
  ), L = a(
156
- (c) => {
157
- const A = new at(c, o);
158
- d.current.executeGlobal(A), s(), n == null || n();
156
+ (s) => {
157
+ const A = new lt(s, o);
158
+ d.current.executeGlobal(A), c(), n == null || n();
159
159
  },
160
- [o, s, n]
160
+ [o, c, n]
161
161
  ), p = a(
162
- (c, A, y) => {
163
- const x = new lt(c, A, y, o);
164
- d.current.executeGlobal(x), s(), n == null || n();
162
+ (s, A, y) => {
163
+ const x = new ut(s, A, y, o);
164
+ d.current.executeGlobal(x), c(), n == null || n();
165
165
  },
166
- [o, s, n]
166
+ [o, c, n]
167
167
  ), f = a(
168
- (c) => {
169
- if (c.length === 0)
168
+ (s) => {
169
+ if (s.length === 0)
170
170
  return;
171
171
  const A = o.getActiveArtboardId();
172
172
  if (!A) {
173
- fe.warn("No active artboard for batch execution");
173
+ Ae.warn("No active artboard for batch execution");
174
174
  return;
175
175
  }
176
- const y = c.map((x) => new class extends Object {
176
+ const y = s.map((x) => new class extends Object {
177
177
  execute() {
178
178
  x.execute();
179
179
  }
@@ -181,54 +181,54 @@ function wt(t, e, o, n) {
181
181
  x.undo();
182
182
  }
183
183
  }());
184
- d.current.executeBatchOnArtboard(A, y), s();
184
+ d.current.executeBatchOnArtboard(A, y), c();
185
185
  },
186
- [o, s]
187
- ), T = a(() => {
188
- d.current.undo() && (s(), n == null || n());
189
- }, [s, n]), z = a(() => {
190
- d.current.redo() && (s(), n == null || n());
191
- }, [s, n]), g = a(() => {
192
- const c = o.getActiveArtboardId();
193
- c && d.current.undoArtboard(c) && (s(), n == null || n());
194
- }, [o, s, n]), b = a(() => {
195
- const c = o.getActiveArtboardId();
196
- c && d.current.redoArtboard(c) && (s(), n == null || n());
197
- }, [o, s, n]), _ = a(() => {
198
- d.current.clear(), s();
199
- }, [s]), te = a(
200
- (c) => {
201
- d.current.clearArtboardHistory(c), s();
186
+ [o, c]
187
+ ), g = a(() => {
188
+ d.current.undo() && (c(), n == null || n());
189
+ }, [c, n]), z = a(() => {
190
+ d.current.redo() && (c(), n == null || n());
191
+ }, [c, n]), T = a(() => {
192
+ const s = o.getActiveArtboardId();
193
+ s && d.current.undoArtboard(s) && (c(), n == null || n());
194
+ }, [o, c, n]), b = a(() => {
195
+ const s = o.getActiveArtboardId();
196
+ s && d.current.redoArtboard(s) && (c(), n == null || n());
197
+ }, [o, c, n]), _ = a(() => {
198
+ d.current.clear(), c();
199
+ }, [c]), te = a(
200
+ (s) => {
201
+ d.current.clearArtboardHistory(s), c();
202
202
  },
203
- [s]
204
- ), B = ue(null);
205
- Ce(() => {
206
- const c = o.getActiveArtboardId();
207
- c !== B.current && (B.current = c, s());
203
+ [c]
204
+ ), B = me(null);
205
+ ve(() => {
206
+ const s = o.getActiveArtboardId();
207
+ s !== B.current && (B.current = s, c());
208
208
  });
209
- const W = a(
210
- (c, A, y) => {
211
- const x = t.map((C) => C.id), P = o.getArtboardIdForElement(c);
209
+ const $ = a(
210
+ (s, A, y) => {
211
+ const x = t.map((R) => R.id), P = o.getArtboardIdForElement(s);
212
212
  if (!P) {
213
- fe.warn("Element not found in any artboard");
213
+ Ae.warn("Element not found in any artboard");
214
214
  return;
215
215
  }
216
- const k = new ut(c, A, y, x, (C) => {
216
+ const k = new mt(s, A, y, x, (R) => {
217
217
  e((N) => {
218
218
  const v = new Map(N.map((U) => [U.id, U]));
219
- return C.map((U) => v.get(U)).filter(Boolean);
219
+ return R.map((U) => v.get(U)).filter(Boolean);
220
220
  });
221
221
  });
222
- d.current.executeOnArtboard(P, k), s();
222
+ d.current.executeOnArtboard(P, k), c();
223
223
  },
224
- [t, e, o, s]
224
+ [t, e, o, c]
225
225
  );
226
226
  return {
227
227
  // Element operations
228
228
  executeElementUpdate: V,
229
229
  executeAddElement: O,
230
230
  executeRemoveElement: D,
231
- executeReorderElement: W,
231
+ executeReorderElement: $,
232
232
  // Batch operations
233
233
  executeCommandBatch: f,
234
234
  // Artboard operations
@@ -236,10 +236,10 @@ function wt(t, e, o, n) {
236
236
  executeDeleteArtboard: L,
237
237
  executeUpdateArtboard: p,
238
238
  // Undo/redo (smart - considers last operation and active artboard)
239
- undo: T,
239
+ undo: g,
240
240
  redo: z,
241
241
  // Undo/redo for active artboard only (element operations)
242
- undoActiveArtboard: g,
242
+ undoActiveArtboard: T,
243
243
  redoActiveArtboard: b,
244
244
  clearHistory: _,
245
245
  clearArtboardHistory: te,
@@ -255,21 +255,21 @@ function wt(t, e, o, n) {
255
255
  function oe(t) {
256
256
  return t && "fontSize" in t && "color" in t && "fontFamily" in t;
257
257
  }
258
- function Tt(t, e) {
259
- const [o, n] = E(32), [d, l] = E("#333333"), [i, r] = E("Arial"), [u, s] = E("center");
260
- Ce(() => {
258
+ function Ct(t, e) {
259
+ const [o, n] = E(32), [d, l] = E("#333333"), [i, r] = E("Arial"), [u, c] = E("center");
260
+ ve(() => {
261
261
  if (t && oe(t)) {
262
- const p = t.transformType === "circle" && "getEffectiveFontSize" in t ? Math.round(t.getEffectiveFontSize()) : Math.round(t.fontSize), f = t.color, T = t.fontFamily, z = t.textAlign;
263
- n((g) => g !== p ? p : g), l((g) => g !== f ? f : g), r((g) => g !== T ? T : g), s((g) => g !== z ? z : g);
262
+ const p = t.transformType === "circle" && "getEffectiveFontSize" in t ? Math.round(t.getEffectiveFontSize()) : Math.round(t.fontSize), f = t.color, g = t.fontFamily, z = t.textAlign;
263
+ n((T) => T !== p ? p : T), l((T) => T !== f ? f : T), r((T) => T !== g ? g : T), c((T) => T !== z ? z : T);
264
264
  }
265
265
  }, [t]);
266
266
  const V = a(
267
267
  (p) => {
268
268
  if (!t || !oe(t)) return;
269
- const f = Math.max(ft, Math.min(At, o + p));
269
+ const f = Math.max(At, Math.min(pt, o + p));
270
270
  n(f);
271
- const T = t.clone();
272
- T.transformType === "circle" && "setEffectiveFontSize" in T ? T.setEffectiveFontSize(f) : T.setFontSize(f), e(T);
271
+ const g = t.clone();
272
+ g.transformType === "circle" && "setEffectiveFontSize" in g ? g.setEffectiveFontSize(f) : g.setFontSize(f), e(g);
273
273
  },
274
274
  [t, o, e]
275
275
  ), O = a(
@@ -286,8 +286,8 @@ function Tt(t, e) {
286
286
  l(p);
287
287
  const f = t.clone();
288
288
  if (f.color = p, f.richText)
289
- for (const T of f.richText.spans)
290
- T.style.color = void 0;
289
+ for (const g of f.richText.spans)
290
+ g.style.color = void 0;
291
291
  e(f);
292
292
  },
293
293
  [t, e]
@@ -295,15 +295,15 @@ function Tt(t, e) {
295
295
  (p) => {
296
296
  if (!t || !oe(t)) return;
297
297
  const f = t.fontFamily;
298
- f !== p && mt.clearCache(f), r(p);
299
- const T = t.clone();
300
- T.fontFamily = p, e(T);
298
+ f !== p && ft.clearCache(f), r(p);
299
+ const g = t.clone();
300
+ g.fontFamily = p, e(g);
301
301
  },
302
302
  [t, e]
303
303
  ), L = a(
304
304
  (p) => {
305
305
  if (!t || !oe(t)) return;
306
- s(p);
306
+ c(p);
307
307
  const f = t.clone();
308
308
  f.textAlign = p, e(f);
309
309
  },
@@ -319,7 +319,7 @@ function Tt(t, e) {
319
319
  setFontSize: n,
320
320
  setFontColor: l,
321
321
  setFontFamily: r,
322
- setTextAlign: s,
322
+ setTextAlign: c,
323
323
  // Update functions (update element + UI)
324
324
  updateFontSize: V,
325
325
  setFontSizeValue: O,
@@ -329,7 +329,7 @@ function Tt(t, e) {
329
329
  };
330
330
  }
331
331
  const Ze = "data-preserve-selection";
332
- function gt(t) {
332
+ function Ft(t) {
333
333
  if (!(t instanceof Element))
334
334
  return !1;
335
335
  let e = t;
@@ -348,18 +348,18 @@ function gt(t) {
348
348
  }
349
349
  return !1;
350
350
  }
351
- const Jt = {
351
+ const Kt = {
352
352
  [Ze]: ""
353
353
  };
354
- function Pt(t) {
355
- const e = $e(t);
354
+ function Rt(t) {
355
+ const e = Ge(t);
356
356
  return e !== null && e < 0.5;
357
357
  }
358
- function Kt(t) {
359
- const e = $e(t);
358
+ function Mt(t) {
359
+ const e = Ge(t);
360
360
  return e !== null && e >= 0.5;
361
361
  }
362
- function $e(t) {
362
+ function Ge(t) {
363
363
  const e = t.trim();
364
364
  if (e.startsWith("#")) {
365
365
  const n = e.slice(1);
@@ -369,40 +369,40 @@ function $e(t) {
369
369
  else if (n.length === 6)
370
370
  d = parseInt(n.slice(0, 2), 16), l = parseInt(n.slice(2, 4), 16), i = parseInt(n.slice(4, 6), 16);
371
371
  else return null;
372
- return Number.isNaN(d) || Number.isNaN(l) || Number.isNaN(i) ? null : Le(d, l, i);
372
+ return Number.isNaN(d) || Number.isNaN(l) || Number.isNaN(i) ? null : Be(d, l, i);
373
373
  }
374
374
  const o = e.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);
375
- return o ? Le(Number(o[1]), Number(o[2]), Number(o[3])) : null;
375
+ return o ? Be(Number(o[1]), Number(o[2]), Number(o[3])) : null;
376
376
  }
377
- function Le(t, e, o) {
377
+ function Be(t, e, o) {
378
378
  const n = (d) => {
379
379
  const l = d / 255;
380
380
  return l <= 0.03928 ? l / 12.92 : Math.pow((l + 0.055) / 1.055, 2.4);
381
381
  };
382
382
  return 0.2126 * n(t) + 0.7152 * n(e) + 0.0722 * n(o);
383
383
  }
384
- const Ft = "#333333", Rt = "#f4f4f5";
385
- function Ct(t) {
386
- return t && Pt(t) ? Rt : Ft;
384
+ const vt = "#333333", zt = "#f4f4f5";
385
+ function Ot(t) {
386
+ return t && Rt(t) ? zt : vt;
387
387
  }
388
- const Ge = Q(null), vt = 0.1, zt = 4, Be = 0.25, Ot = ({
388
+ const Xe = Q(null), Ut = 0.1, Ht = 4, _e = 0.25, Vt = ({
389
389
  children: t,
390
390
  artboardManager: e,
391
391
  canvasRef: o,
392
392
  viewPadding: n = 0.9
393
393
  }) => {
394
- const [d, l] = E(1), [i, r] = E({ x: 0, y: 0 }), [u, s] = E(!1), [V, O] = E(1), D = a(() => {
394
+ const [d, l] = E(1), [i, r] = E({ x: 0, y: 0 }), [u, c] = E(!1), [V, O] = E(1), D = a(() => {
395
395
  O(1), r({ x: 0, y: 0 });
396
396
  }, []), w = a(() => {
397
- l((z) => Math.min(z + Be, zt));
397
+ l((z) => Math.min(z + _e, Ht));
398
398
  }, []), L = a(() => {
399
- l((z) => Math.max(z - Be, vt));
399
+ l((z) => Math.max(z - _e, Ut));
400
400
  }, []), p = a(() => {
401
401
  const z = e.getActiveArtboard();
402
402
  if (!z || !o.current) return;
403
- let g = o.current.parentElement, b = 0, _ = 0;
404
- for (; g && (b = g.clientWidth, _ = g.clientHeight, !(b > 0 && _ > 0)); )
405
- g = g.parentElement;
403
+ let T = o.current.parentElement, b = 0, _ = 0;
404
+ for (; T && (b = T.clientWidth, _ = T.clientHeight, !(b > 0 && _ > 0)); )
405
+ T = T.parentElement;
406
406
  if (!b || !_) return;
407
407
  const te = Math.min(
408
408
  b * n / z.width,
@@ -413,7 +413,7 @@ const Ge = Q(null), vt = 0.1, zt = 4, Be = 0.25, Ot = ({
413
413
  l(te), r({ x: 0, y: 0 });
414
414
  }, [e, o, n]), f = a(() => {
415
415
  l(1), r({ x: 0, y: 0 });
416
- }, []), T = q(
416
+ }, []), g = q(
417
417
  () => ({
418
418
  zoom: d,
419
419
  panOffset: i,
@@ -424,23 +424,23 @@ const Ge = Q(null), vt = 0.1, zt = 4, Be = 0.25, Ot = ({
424
424
  resetView: f,
425
425
  setZoom: l,
426
426
  setPanOffset: r,
427
- setIsPanning: s,
427
+ setIsPanning: c,
428
428
  userZoom: V,
429
429
  setUserZoom: O,
430
430
  resetUserView: D
431
431
  }),
432
432
  [d, i, u, w, L, p, f, V, D]
433
433
  );
434
- return /* @__PURE__ */ H(Ge.Provider, { value: T, children: t });
434
+ return /* @__PURE__ */ H(Xe.Provider, { value: g, children: t });
435
435
  };
436
- function Ut() {
437
- const t = X(Ge);
436
+ function Nt() {
437
+ const t = X(Xe);
438
438
  if (!t)
439
439
  throw new Error("useViewportContext must be used within a ViewportProvider (or EditorProvider)");
440
440
  return t;
441
441
  }
442
- const Xe = Q(null), Ht = ({ children: t }) => {
443
- const [e, o] = E(null), [n, d] = E([]), [l, i] = E(null), [r, u] = E(null), [s, V] = E(!1), O = a((L) => {
442
+ const je = Q(null), Dt = ({ children: t }) => {
443
+ const [e, o] = E(null), [n, d] = E([]), [l, i] = E(null), [r, u] = E(null), [c, V] = E(!1), O = a((L) => {
444
444
  o(L);
445
445
  }, []), D = a((L) => {
446
446
  i(L);
@@ -450,7 +450,7 @@ const Xe = Q(null), Ht = ({ children: t }) => {
450
450
  multiSelection: n,
451
451
  activeChildElement: l,
452
452
  hoveredElementId: r,
453
- hideHandles: s,
453
+ hideHandles: c,
454
454
  setSelectedId: o,
455
455
  setMultiSelection: d,
456
456
  setHoveredElementId: u,
@@ -463,20 +463,20 @@ const Xe = Q(null), Ht = ({ children: t }) => {
463
463
  n,
464
464
  l,
465
465
  r,
466
- s,
466
+ c,
467
467
  O,
468
468
  D
469
469
  ]
470
470
  );
471
- return /* @__PURE__ */ H(Xe.Provider, { value: w, children: t });
471
+ return /* @__PURE__ */ H(je.Provider, { value: w, children: t });
472
472
  };
473
- function Vt() {
474
- const t = X(Xe);
473
+ function Lt() {
474
+ const t = X(je);
475
475
  if (!t)
476
476
  throw new Error("useSelectionContext must be used within a SelectionProvider (or EditorProvider)");
477
477
  return t;
478
478
  }
479
- const Ye = Q(null), Nt = ({ children: t, value: e }) => {
479
+ const Ye = Q(null), Bt = ({ children: t, value: e }) => {
480
480
  const o = q(
481
481
  () => ({
482
482
  undo: e.undo,
@@ -501,14 +501,14 @@ const Ye = Q(null), Nt = ({ children: t, value: e }) => {
501
501
  );
502
502
  return /* @__PURE__ */ H(Ye.Provider, { value: o, children: t });
503
503
  };
504
- function Mt() {
504
+ function qt() {
505
505
  const t = X(Ye);
506
506
  if (!t)
507
507
  throw new Error("useHistoryContext must be used within a HistoryProvider (or EditorProvider)");
508
508
  return t;
509
509
  }
510
- const je = Q(null), Dt = ({ children: t }) => {
511
- const [e, o] = E(null), [n, d] = E(!1), [l, i] = E(0), [r, u] = E(!1), [s, V] = E(!1), O = q(
510
+ const Je = Q(null), _t = ({ children: t }) => {
511
+ const [e, o] = E(null), [n, d] = E(!1), [l, i] = E(0), [r, u] = E(!1), [c, V] = E(!1), O = q(
512
512
  () => ({
513
513
  expandedPanelType: e,
514
514
  setExpandedPanelType: o,
@@ -518,20 +518,20 @@ const je = Q(null), Dt = ({ children: t }) => {
518
518
  setTextSelectionVersion: i,
519
519
  isCanvasReady: r,
520
520
  setCanvasReady: u,
521
- isRotating: s,
521
+ isRotating: c,
522
522
  setIsRotating: V
523
523
  }),
524
- [e, n, l, r, s]
524
+ [e, n, l, r, c]
525
525
  );
526
- return /* @__PURE__ */ H(je.Provider, { value: O, children: t });
526
+ return /* @__PURE__ */ H(Je.Provider, { value: O, children: t });
527
527
  };
528
- function Lt() {
529
- const t = X(je);
528
+ function kt() {
529
+ const t = X(Je);
530
530
  if (!t)
531
531
  throw new Error("useToolStateContext must be used within a ToolStateProvider (or EditorProvider)");
532
532
  return t;
533
533
  }
534
- const Je = Q(null), Bt = ({ children: t, value: e }) => {
534
+ const Ke = Q(null), $t = ({ children: t, value: e }) => {
535
535
  const o = q(
536
536
  () => ({
537
537
  elements: e.elements,
@@ -586,15 +586,15 @@ const Je = Q(null), Bt = ({ children: t, value: e }) => {
586
586
  e.canvasEditorRef
587
587
  ]
588
588
  );
589
- return /* @__PURE__ */ H(Je.Provider, { value: o, children: t });
589
+ return /* @__PURE__ */ H(Ke.Provider, { value: o, children: t });
590
590
  };
591
- function qt() {
592
- const t = X(Je);
591
+ function Qt() {
592
+ const t = X(Ke);
593
593
  if (!t)
594
594
  throw new Error("useElementsContext must be used within an ElementsProvider (or EditorProvider)");
595
595
  return t;
596
596
  }
597
- const Ke = Q(null), _t = ({ children: t, value: e }) => {
597
+ const Me = Q(null), Wt = ({ children: t, value: e }) => {
598
598
  const o = q(
599
599
  () => ({
600
600
  executeElementUpdate: e.executeElementUpdate,
@@ -635,53 +635,53 @@ const Ke = Q(null), _t = ({ children: t, value: e }) => {
635
635
  e.historyManager
636
636
  ]
637
637
  );
638
- return /* @__PURE__ */ H(Ke.Provider, { value: o, children: t });
638
+ return /* @__PURE__ */ H(Me.Provider, { value: o, children: t });
639
639
  };
640
- function Qt() {
641
- const t = X(Ke);
640
+ function en() {
641
+ const t = X(Me);
642
642
  if (!t)
643
643
  throw new Error("useCommandContext must be used within a CommandProvider (or EditorProvider)");
644
644
  return t;
645
645
  }
646
- const kt = ke("EditorContext"), Me = Q(null), qe = Q(null), en = () => {
647
- const t = X(qe);
646
+ const Zt = $e("EditorContext"), qe = Q(null), Qe = Q(null), tn = () => {
647
+ const t = X(Qe);
648
648
  if (!t)
649
649
  throw new Error("useEditorHandles must be used within EditorProvider");
650
650
  return t;
651
- }, Wt = ({ children: t, artboardManager: e, canvasRef: o, canvasEditorRef: n }) => {
652
- const d = ue(null), l = q(() => ({ get: () => d.current }), []), i = Ut(), r = Vt(), u = Lt(), [s, V] = E(
651
+ }, Gt = ({ children: t, artboardManager: e, canvasRef: o, canvasEditorRef: n }) => {
652
+ const d = me(null), l = q(() => ({ get: () => d.current }), []), i = Nt(), r = Lt(), u = kt(), [c, V] = E(
653
653
  () => e.getAllArtboards()
654
654
  ), [O, D] = E(0), [w, L] = E(
655
- () => new Ve()
655
+ () => new Ne()
656
656
  ), p = q(() => w.toArray(), [w]), f = a((m) => {
657
657
  L((h) => {
658
- const I = h.toArray(), F = typeof m == "function" ? m(I) : m;
659
- return F === I ? h : Ve.fromArray(F);
658
+ const I = h.toArray(), C = typeof m == "function" ? m(I) : m;
659
+ return C === I ? h : Ne.fromArray(C);
660
660
  });
661
- }, []), T = a(
661
+ }, []), g = a(
662
662
  (m) => w.get(m),
663
663
  [w]
664
- ), [z, g] = E([]), b = r.selectedId ? w.get(r.selectedId) : void 0, _ = a(() => {
664
+ ), [z, T] = E([]), b = r.selectedId ? w.get(r.selectedId) : void 0, _ = a(() => {
665
665
  V([...e.getAllArtboards()]), D((m) => m + 1);
666
666
  }, [e]), {
667
667
  historyManager: te,
668
668
  executeElementUpdate: B,
669
- executeAddElement: W,
670
- executeRemoveElement: c,
669
+ executeAddElement: $,
670
+ executeRemoveElement: s,
671
671
  executeReorderElement: A,
672
672
  executeCommandBatch: y,
673
673
  executeCreateArtboard: x,
674
674
  executeDeleteArtboard: P,
675
675
  executeUpdateArtboard: k,
676
- undo: C,
676
+ undo: R,
677
677
  redo: N,
678
678
  canUndo: v,
679
679
  canRedo: U,
680
- undoActiveArtboard: R,
681
- redoActiveArtboard: Y,
680
+ undoActiveArtboard: F,
681
+ redoActiveArtboard: j,
682
682
  canUndoActiveArtboard: ne,
683
- canRedoActiveArtboard: j
684
- } = wt(
683
+ canRedoActiveArtboard: Y
684
+ } = Pt(
685
685
  p,
686
686
  f,
687
687
  e,
@@ -692,43 +692,43 @@ const kt = ke("EditorContext"), Me = Q(null), qe = Q(null), en = () => {
692
692
  B(h, m);
693
693
  },
694
694
  [w, B]
695
- ), Qe = a(
695
+ ), et = a(
696
696
  (m) => {
697
- if (!b || !(b instanceof _e))
697
+ if (!b || !(b instanceof ke))
698
698
  return;
699
699
  const h = b.clone(), I = h.children.findIndex(
700
- (F) => F.id === m.id
700
+ (C) => C.id === m.id
701
701
  );
702
702
  I >= 0 && (h.children[I] = m, J(h));
703
703
  },
704
704
  [b, J]
705
- ), et = r.activeChildElement || b, tt = r.activeChildElement ? Qe : J, {
706
- fontSize: Ae,
707
- fontColor: pe,
708
- fontFamily: he,
709
- textAlign: xe,
710
- updateFontSize: ye,
711
- setFontSizeValue: Ee,
712
- updateFontColor: Se,
713
- updateFontFamily: be,
714
- updateTextAlign: Ie
715
- } = Tt(et, tt), we = a(
705
+ ), tt = r.activeChildElement || b, nt = r.activeChildElement ? et : J, {
706
+ fontSize: pe,
707
+ fontColor: he,
708
+ fontFamily: xe,
709
+ textAlign: ye,
710
+ updateFontSize: Ee,
711
+ setFontSizeValue: Se,
712
+ updateFontColor: be,
713
+ updateFontFamily: Ie,
714
+ updateTextAlign: we
715
+ } = Ct(tt, nt), ge = a(
716
716
  async (m, h) => {
717
- var ze;
717
+ var Oe;
718
718
  const I = e.getActiveArtboardId();
719
719
  if (!I) {
720
720
  alert("Please create or select an artboard first");
721
721
  return;
722
722
  }
723
- const F = `element-${Date.now()}`, S = e.getActiveArtboard(), re = S ? S.x + S.width / 2 : window.innerWidth / 2, ie = S ? S.y + S.height / 2 : window.innerHeight / 2, Z = ((ze = n.current) == null ? void 0 : ze.getZoom()) || i.zoom || 1;
723
+ const C = `element-${Date.now()}`, S = e.getActiveArtboard(), ie = S ? S.x + S.width / 2 : window.innerWidth / 2, se = S ? S.y + S.height / 2 : window.innerHeight / 2, W = ((Oe = n.current) == null ? void 0 : Oe.getZoom()) || i.zoom || 1;
724
724
  if (m === "image") {
725
- const le = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==", ee = 200 / Z, K = h == null ? void 0 : h.src, G = new xt({
726
- id: F,
727
- x: re,
728
- y: ie,
725
+ const ue = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==", ee = 200 / W, K = h == null ? void 0 : h.src, G = new yt({
726
+ id: C,
727
+ x: ie,
728
+ y: se,
729
729
  // Defer loading `src` until after the element is in the store so a
730
730
  // synchronously-cached image can't fire onLoadCallback too early.
731
- imageUrl: K ? "" : le,
731
+ imageUrl: K ? "" : ue,
732
732
  transformData: {
733
733
  type: "image",
734
734
  width: ee,
@@ -743,32 +743,32 @@ const kt = ke("EditorContext"), Me = Q(null), qe = Q(null), en = () => {
743
743
  }
744
744
  });
745
745
  K && (G.imageLoaded = !1, G.imageElement = null, G.isCropping = !1, G.imageUrl = K, G.preserveDimensions = !1, G.onLoadCallback = (M) => {
746
- const Oe = M.transformData.width, Ue = M.transformData.height, Re = Math.min(ee / Oe, ee / Ue, 1);
747
- Re < 1 && (M.transformData.width = Oe * Re, M.transformData.height = Ue * Re), M.transformData.cropX = 0, M.transformData.cropY = 0, M.transformData.cropWidth = 1, M.transformData.cropHeight = 1, B(G, M);
748
- }), W(G, I), r.setSelectedId(G.id), K && G.loadImage(K);
746
+ const Ue = M.transformData.width, He = M.transformData.height, Re = Math.min(ee / Ue, ee / He, 1);
747
+ Re < 1 && (M.transformData.width = Ue * Re, M.transformData.height = He * Re), M.transformData.cropX = 0, M.transformData.cropY = 0, M.transformData.cropWidth = 1, M.transformData.cropHeight = 1, B(G, M);
748
+ }), $(G, I), r.setSelectedId(G.id), K && G.loadImage(K);
749
749
  return;
750
750
  }
751
751
  let ce;
752
- const $ = {
752
+ const Z = {
753
753
  text: "custom",
754
754
  circle: "circle",
755
755
  wave: "wave",
756
756
  arch: "arch",
757
757
  shape: "shape"
758
- }[m] || "custom", de = yt($);
759
- if (!de || !de.Component)
758
+ }[m] || "custom", ae = Et(Z);
759
+ if (!ae || !ae.Component)
760
760
  return;
761
- const ae = e.getActiveArtboard(), nt = ae ? Math.min(ae.width, ae.height) * 0.1 : 80, Fe = ae ? ae.width * 0.5 : 300;
761
+ const le = e.getActiveArtboard(), ot = le ? Math.min(le.width, le.height) * 0.1 : 80, Fe = le ? le.width * 0.5 : 300;
762
762
  if (m === "shape") {
763
- const le = (h == null ? void 0 : h.shapeType) ?? "rectangle";
764
- let ee = 200 / Z, K = 200 / Z;
765
- le === "ellipse" ? (ee = 150 / Z, K = 250 / Z) : le === "line" && (ee = 300 / Z, K = 8 / Z), ce = new Et({
766
- id: F,
767
- x: re,
768
- y: ie,
763
+ const ue = (h == null ? void 0 : h.shapeType) ?? "rectangle";
764
+ let ee = 200 / W, K = 200 / W;
765
+ ue === "ellipse" ? (ee = 150 / W, K = 250 / W) : ue === "line" && (ee = 300 / W, K = 8 / W), ce = new St({
766
+ id: C,
767
+ x: ie,
768
+ y: se,
769
769
  transformData: {
770
770
  type: "shape",
771
- shapeType: le,
771
+ shapeType: ue,
772
772
  width: ee,
773
773
  height: K,
774
774
  fillColor: "#3b82f6",
@@ -776,35 +776,35 @@ const kt = ke("EditorContext"), Me = Q(null), qe = Q(null), en = () => {
776
776
  }
777
777
  });
778
778
  } else
779
- ce = new de.Component({
780
- id: F,
779
+ ce = new ae.Component({
780
+ id: C,
781
781
  text: "New Text",
782
- x: re,
783
- y: ie,
784
- fontSize: nt,
782
+ x: ie,
783
+ y: se,
784
+ fontSize: ot,
785
785
  fontFamily: "Poppins",
786
- color: Ct(S == null ? void 0 : S.backgroundColor),
787
- transformData: $ === "arch" ? {
786
+ color: Ot(S == null ? void 0 : S.backgroundColor),
787
+ transformData: Z === "arch" ? {
788
788
  type: "arch",
789
789
  width: Fe,
790
- archHeight: St.archHeight
791
- } : $ === "wave" ? {
790
+ archHeight: bt.archHeight
791
+ } : Z === "wave" ? {
792
792
  type: "wave",
793
793
  width: Fe,
794
- amplitude: Ne.amplitude,
795
- frequency: Ne.frequency
796
- } : $ === "circle" ? {
794
+ amplitude: De.amplitude,
795
+ frequency: De.frequency
796
+ } : Z === "circle" ? {
797
797
  type: "circle",
798
798
  radius: Fe / 2
799
799
  } : void 0
800
800
  });
801
- e.addElementToArtboard(F, I), W(
801
+ e.addElementToArtboard(C, I), $(
802
802
  ce,
803
803
  I,
804
804
  r.selectedId || void 0
805
- ), r.setSelectedId(F);
805
+ ), r.setSelectedId(C);
806
806
  },
807
- [e, W, B, r, i.zoom, n]
807
+ [e, $, B, r, i.zoom, n]
808
808
  ), Te = a(() => {
809
809
  const m = [];
810
810
  if (r.multiSelection.length > 0) {
@@ -815,33 +815,33 @@ const kt = ke("EditorContext"), Me = Q(null), qe = Q(null), en = () => {
815
815
  } else b && m.push(b);
816
816
  if (m.length > 0) {
817
817
  const h = m.map((I) => I.clone());
818
- g(h);
818
+ T(h);
819
819
  }
820
- }, [b, r.multiSelection, p]), ge = a(() => {
820
+ }, [b, r.multiSelection, p]), Pe = a(() => {
821
821
  if (z.length === 0) return;
822
822
  const m = [], h = 30, I = 30;
823
- z.forEach((F) => {
824
- const S = w.get(F.id), re = S ? S.x : F.x, ie = S ? S.y : F.y, Z = F.toJSON();
825
- delete Z.id;
826
- const ce = F.constructor, se = new ce(Z);
827
- se.x = re + h, se.y = ie + I;
828
- let $ = null;
829
- if (S && ($ = e.getArtboardIdForElement(
823
+ z.forEach((C) => {
824
+ const S = w.get(C.id), ie = S ? S.x : C.x, se = S ? S.y : C.y, W = C.toJSON();
825
+ delete W.id;
826
+ const ce = C.constructor, de = new ce(W);
827
+ de.x = ie + h, de.y = se + I;
828
+ let Z = null;
829
+ if (S && (Z = e.getArtboardIdForElement(
830
830
  S.id
831
- )), $ || ($ = e.getActiveArtboardId()), !$) {
832
- kt.warn("[handlePasteElements] No artboard found for pasting");
831
+ )), Z || (Z = e.getActiveArtboardId()), !Z) {
832
+ Zt.warn("[handlePasteElements] No artboard found for pasting");
833
833
  return;
834
834
  }
835
- const de = S ? S.id : void 0;
836
- W(se, $, de), m.push(se.id);
835
+ const ae = S ? S.id : void 0;
836
+ $(de, Z, ae), m.push(de.id);
837
837
  }), m.length === 1 ? r.handleSelectionChange(m[0]) : m.length > 1 && r.setMultiSelection(m);
838
838
  }, [
839
839
  z,
840
840
  w,
841
841
  e,
842
- W,
842
+ $,
843
843
  r
844
- ]), me = a(() => {
844
+ ]), fe = a(() => {
845
845
  if (u.expandedPanelType === "crop" && (b == null ? void 0 : b.transformType) === "image") {
846
846
  const m = b;
847
847
  if (m.isCropping) {
@@ -856,10 +856,10 @@ const kt = ke("EditorContext"), Me = Q(null), qe = Q(null), en = () => {
856
856
  b,
857
857
  B
858
858
  ]);
859
- Ce(() => {
859
+ ve(() => {
860
860
  const m = (h) => {
861
861
  const I = h.target;
862
- if (I.tagName === "CANVAS" || gt(I))
862
+ if (I.tagName === "CANVAS" || Ft(I))
863
863
  return;
864
864
  const S = document.activeElement;
865
865
  if (S != null && S.hasAttribute("data-preserve-selection")) {
@@ -867,21 +867,21 @@ const kt = ke("EditorContext"), Me = Q(null), qe = Q(null), en = () => {
867
867
  return;
868
868
  }
869
869
  if (u.expandedPanelType !== null) {
870
- me();
870
+ fe();
871
871
  return;
872
872
  }
873
873
  r.selectedId !== null && r.setSelectedId(null), r.multiSelection.length > 0 && r.setMultiSelection([]);
874
874
  };
875
875
  return document.addEventListener("pointerdown", m), () => document.removeEventListener("pointerdown", m);
876
- }, [u.expandedPanelType, me, r]);
877
- const Pe = a(
876
+ }, [u.expandedPanelType, fe, r]);
877
+ const Ce = a(
878
878
  (m, h, I) => {
879
- e.clear(), m.forEach((F) => {
880
- e.createArtboard(F.toJSON());
881
- }), I && e.setActiveArtboard(I), V([...e.getAllArtboards()]), D((F) => F + 1), f(h), r.setSelectedId(null);
879
+ e.clear(), m.forEach((C) => {
880
+ e.createArtboard(C.toJSON());
881
+ }), I && e.setActiveArtboard(I), V([...e.getAllArtboards()]), D((C) => C + 1), f(h), r.setSelectedId(null);
882
882
  },
883
883
  [e, r, f]
884
- ), ve = q(() => ({
884
+ ), ze = q(() => ({
885
885
  // From ViewportContext
886
886
  zoom: i.zoom,
887
887
  panOffset: i.panOffset,
@@ -917,13 +917,13 @@ const kt = ke("EditorContext"), Me = Q(null), qe = Q(null), en = () => {
917
917
  isRotating: u.isRotating,
918
918
  setIsRotating: u.setIsRotating,
919
919
  // Cross-context handler
920
- clearExpandedPanel: me,
920
+ clearExpandedPanel: fe,
921
921
  // Core state (element/artboard domain)
922
922
  artboardManager: e,
923
- artboards: s,
923
+ artboards: c,
924
924
  elements: p,
925
925
  elementStore: w,
926
- getElementById: T,
926
+ getElementById: g,
927
927
  // Derived state (cross-context)
928
928
  selectedElement: b,
929
929
  // Refs
@@ -936,38 +936,38 @@ const kt = ke("EditorContext"), Me = Q(null), qe = Q(null), en = () => {
936
936
  // Handlers
937
937
  refreshArtboards: _,
938
938
  handleElementUpdate: J,
939
- handleAddElement: we,
940
- handleLoadWorkspace: Pe,
939
+ handleAddElement: ge,
940
+ handleLoadWorkspace: Ce,
941
941
  handleCopyElements: Te,
942
- handlePasteElements: ge,
942
+ handlePasteElements: Pe,
943
943
  // Command history (undo/redo actions + execute functions)
944
944
  historyManager: te,
945
945
  executeElementUpdate: B,
946
- executeAddElement: W,
947
- executeRemoveElement: c,
946
+ executeAddElement: $,
947
+ executeRemoveElement: s,
948
948
  executeReorderElement: A,
949
949
  executeCommandBatch: y,
950
950
  executeCreateArtboard: x,
951
951
  executeDeleteArtboard: P,
952
952
  executeUpdateArtboard: k,
953
- undo: C,
953
+ undo: R,
954
954
  redo: N,
955
955
  canUndo: v,
956
956
  canRedo: U,
957
- undoActiveArtboard: R,
958
- redoActiveArtboard: Y,
957
+ undoActiveArtboard: F,
958
+ redoActiveArtboard: j,
959
959
  canUndoActiveArtboard: ne,
960
- canRedoActiveArtboard: j,
960
+ canRedoActiveArtboard: Y,
961
961
  // Element properties
962
- fontSize: Ae,
963
- fontColor: pe,
964
- fontFamily: he,
965
- textAlign: xe,
966
- updateFontSize: ye,
967
- setFontSizeValue: Ee,
968
- updateFontColor: Se,
969
- updateFontFamily: be,
970
- updateTextAlign: Ie
962
+ fontSize: pe,
963
+ fontColor: he,
964
+ fontFamily: xe,
965
+ textAlign: ye,
966
+ updateFontSize: Ee,
967
+ setFontSizeValue: Se,
968
+ updateFontColor: be,
969
+ updateFontFamily: Ie,
970
+ updateTextAlign: we
971
971
  }), [
972
972
  // Viewport
973
973
  i.zoom,
@@ -1003,13 +1003,13 @@ const kt = ke("EditorContext"), Me = Q(null), qe = Q(null), en = () => {
1003
1003
  u.setCanvasReady,
1004
1004
  u.isRotating,
1005
1005
  u.setIsRotating,
1006
- me,
1006
+ fe,
1007
1007
  // Element/artboard domain
1008
1008
  e,
1009
- s,
1009
+ c,
1010
1010
  p,
1011
1011
  w,
1012
- T,
1012
+ g,
1013
1013
  b,
1014
1014
  o,
1015
1015
  n,
@@ -1017,30 +1017,29 @@ const kt = ke("EditorContext"), Me = Q(null), qe = Q(null), en = () => {
1017
1017
  O,
1018
1018
  _,
1019
1019
  J,
1020
- we,
1021
- Pe,
1022
- Te,
1023
1020
  ge,
1021
+ Ce,
1022
+ Te,
1023
+ Pe,
1024
1024
  // Command history
1025
1025
  te,
1026
1026
  B,
1027
- W,
1028
- c,
1027
+ $,
1028
+ s,
1029
1029
  A,
1030
1030
  y,
1031
1031
  x,
1032
1032
  P,
1033
1033
  k,
1034
- C,
1034
+ R,
1035
1035
  N,
1036
1036
  v,
1037
1037
  U,
1038
- R,
1039
- Y,
1040
- ne,
1038
+ F,
1041
1039
  j,
1040
+ ne,
1041
+ Y,
1042
1042
  // Element properties
1043
- Ae,
1044
1043
  pe,
1045
1044
  he,
1046
1045
  xe,
@@ -1048,103 +1047,104 @@ const kt = ke("EditorContext"), Me = Q(null), qe = Q(null), en = () => {
1048
1047
  Ee,
1049
1048
  Se,
1050
1049
  be,
1051
- Ie
1050
+ Ie,
1051
+ we
1052
1052
  ]);
1053
- return d.current = ve, /* @__PURE__ */ H(qe.Provider, { value: l, children: /* @__PURE__ */ H(
1054
- Nt,
1053
+ return d.current = ze, /* @__PURE__ */ H(Qe.Provider, { value: l, children: /* @__PURE__ */ H(
1054
+ Bt,
1055
1055
  {
1056
1056
  value: {
1057
- undo: C,
1057
+ undo: R,
1058
1058
  redo: N,
1059
1059
  canUndo: v,
1060
1060
  canRedo: U,
1061
- undoActiveArtboard: R,
1062
- redoActiveArtboard: Y,
1061
+ undoActiveArtboard: F,
1062
+ redoActiveArtboard: j,
1063
1063
  canUndoActiveArtboard: ne,
1064
- canRedoActiveArtboard: j
1064
+ canRedoActiveArtboard: Y
1065
1065
  },
1066
1066
  children: /* @__PURE__ */ H(
1067
- Bt,
1067
+ $t,
1068
1068
  {
1069
1069
  value: {
1070
1070
  elements: p,
1071
1071
  elementStore: w,
1072
- artboards: s,
1072
+ artboards: c,
1073
1073
  artboardManager: e,
1074
1074
  artboardVersion: O,
1075
1075
  setElements: f,
1076
1076
  refreshArtboards: _,
1077
- getElementById: T,
1078
- handleAddElement: we,
1077
+ getElementById: g,
1078
+ handleAddElement: ge,
1079
1079
  handleElementUpdate: J,
1080
- handleLoadWorkspace: Pe,
1080
+ handleLoadWorkspace: Ce,
1081
1081
  handleCopyElements: Te,
1082
- handlePasteElements: ge,
1083
- fontSize: Ae,
1084
- fontColor: pe,
1085
- fontFamily: he,
1086
- textAlign: xe,
1087
- updateFontSize: ye,
1088
- setFontSizeValue: Ee,
1089
- updateFontColor: Se,
1090
- updateFontFamily: be,
1091
- updateTextAlign: Ie,
1082
+ handlePasteElements: Pe,
1083
+ fontSize: pe,
1084
+ fontColor: he,
1085
+ fontFamily: xe,
1086
+ textAlign: ye,
1087
+ updateFontSize: Ee,
1088
+ setFontSizeValue: Se,
1089
+ updateFontColor: be,
1090
+ updateFontFamily: Ie,
1091
+ updateTextAlign: we,
1092
1092
  canvasRef: o,
1093
1093
  canvasEditorRef: n
1094
1094
  },
1095
1095
  children: /* @__PURE__ */ H(
1096
- _t,
1096
+ Wt,
1097
1097
  {
1098
1098
  value: {
1099
1099
  executeElementUpdate: B,
1100
- executeAddElement: W,
1101
- executeRemoveElement: c,
1100
+ executeAddElement: $,
1101
+ executeRemoveElement: s,
1102
1102
  executeReorderElement: A,
1103
1103
  executeCommandBatch: y,
1104
1104
  executeCreateArtboard: x,
1105
1105
  executeDeleteArtboard: P,
1106
1106
  executeUpdateArtboard: k,
1107
- undo: C,
1107
+ undo: R,
1108
1108
  redo: N,
1109
1109
  canUndo: v,
1110
1110
  canRedo: U,
1111
- undoActiveArtboard: R,
1112
- redoActiveArtboard: Y,
1111
+ undoActiveArtboard: F,
1112
+ redoActiveArtboard: j,
1113
1113
  canUndoActiveArtboard: ne,
1114
- canRedoActiveArtboard: j,
1114
+ canRedoActiveArtboard: Y,
1115
1115
  historyManager: te
1116
1116
  },
1117
- children: /* @__PURE__ */ H(Me.Provider, { value: ve, children: t })
1117
+ children: /* @__PURE__ */ H(qe.Provider, { value: ze, children: t })
1118
1118
  }
1119
1119
  )
1120
1120
  }
1121
1121
  )
1122
1122
  }
1123
1123
  ) });
1124
- }, tn = ({
1124
+ }, nn = ({
1125
1125
  children: t,
1126
1126
  initialArtboardConfig: e = {},
1127
1127
  viewPadding: o = 0.9
1128
1128
  }) => {
1129
1129
  const [n] = E(() => {
1130
- const i = new ht(), r = {
1130
+ const i = new xt(), r = {
1131
1131
  name: e.name || "Artboard 1",
1132
1132
  x: e.x ?? 0,
1133
1133
  y: e.y ?? 0,
1134
1134
  width: e.width ?? 1e3,
1135
1135
  height: e.height ?? 1e3,
1136
- backgroundColor: e.backgroundColor || pt
1136
+ backgroundColor: e.backgroundColor || ht
1137
1137
  };
1138
1138
  return i.createArtboard(r), i;
1139
- }), d = ue(null), l = ue(null);
1139
+ }), d = me(null), l = me(null);
1140
1140
  return /* @__PURE__ */ H(
1141
- Ot,
1141
+ Vt,
1142
1142
  {
1143
1143
  artboardManager: n,
1144
1144
  canvasRef: d,
1145
1145
  viewPadding: o,
1146
- children: /* @__PURE__ */ H(Ht, { children: /* @__PURE__ */ H(Dt, { children: /* @__PURE__ */ H(
1147
- Wt,
1146
+ children: /* @__PURE__ */ H(Dt, { children: /* @__PURE__ */ H(_t, { children: /* @__PURE__ */ H(
1147
+ Gt,
1148
1148
  {
1149
1149
  artboardManager: n,
1150
1150
  canvasRef: d,
@@ -1154,31 +1154,55 @@ const kt = ke("EditorContext"), Me = Q(null), qe = Q(null), en = () => {
1154
1154
  ) }) })
1155
1155
  }
1156
1156
  );
1157
- }, nn = () => {
1158
- const t = X(Me);
1157
+ }, on = () => {
1158
+ const t = X(qe);
1159
1159
  if (!t)
1160
1160
  throw new Error("useEditor must be used within EditorProvider");
1161
1161
  return t;
1162
- };
1162
+ }, re = [];
1163
+ function rn(t) {
1164
+ Tt() && re.push(t);
1165
+ }
1166
+ function sn() {
1167
+ return [...re];
1168
+ }
1169
+ function cn() {
1170
+ re.length = 0;
1171
+ }
1172
+ function dn() {
1173
+ if (re.length === 0) return;
1174
+ const t = re.map((e) => gt(e) ? `${e.code}: ${e.message}` : `${e.name}: ${e.message}`).join(`
1175
+ - `);
1176
+ throw re.length = 0, new Error(
1177
+ `expectNoEditorErrors: ${t.includes(`
1178
+ `) ? "errors were" : "an error was"} contained by <Editor.Root>'s boundary during this test:
1179
+ - ${t}
1180
+ A contained error renders an error card in prod — this composition is broken even if the test rendered "successfully".`
1181
+ );
1182
+ }
1163
1183
  export {
1164
1184
  We as B,
1165
- tn as E,
1185
+ nn as E,
1166
1186
  Ze as P,
1167
- Ut as a,
1168
- Qt as b,
1169
- qt as c,
1170
- Mt as d,
1171
- Vt as e,
1172
- Lt as f,
1173
- It as g,
1174
- Yt as h,
1175
- jt as i,
1176
- en as j,
1177
- Xt as k,
1178
- Pt as l,
1179
- Kt as m,
1180
- Jt as p,
1181
- gt as s,
1182
- nn as u
1187
+ Nt as a,
1188
+ en as b,
1189
+ Qt as c,
1190
+ qt as d,
1191
+ Lt as e,
1192
+ kt as f,
1193
+ wt as g,
1194
+ Jt as h,
1195
+ gt as i,
1196
+ Tt as j,
1197
+ tn as k,
1198
+ dn as l,
1199
+ sn as m,
1200
+ cn as n,
1201
+ Rt as o,
1202
+ Kt as p,
1203
+ Mt as q,
1204
+ rn as r,
1205
+ Ft as s,
1206
+ on as u
1183
1207
  };
1184
- //# sourceMappingURL=EditorContext-5QpqAhjh.js.map
1208
+ //# sourceMappingURL=editorErrors-CK1RISFa.js.map