@snowcone-app/canvas 0.17.3 → 0.18.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 (65) hide show
  1. package/dist/{ImportManager-C_wBjWaV.js → CanvasRenderer-DUc-MOeR.js} +586 -806
  2. package/dist/CanvasRenderer-DUc-MOeR.js.map +1 -0
  3. package/dist/{CanvasStateV1-BG2hEc3-.js → CanvasStateV1-Bq48qhv5.js} +3 -3
  4. package/dist/{CanvasStateV1-BG2hEc3-.js.map → CanvasStateV1-Bq48qhv5.js.map} +1 -1
  5. package/dist/ContextualToolbars-CkLjHNPn.js +5833 -0
  6. package/dist/ContextualToolbars-CkLjHNPn.js.map +1 -0
  7. package/dist/EditorCanvasImpl-Bv4yagew.js +81 -0
  8. package/dist/EditorCanvasImpl-Bv4yagew.js.map +1 -0
  9. package/dist/EditorContext-5QpqAhjh.js +1184 -0
  10. package/dist/{EditorContext-CGkfmbgo.js.map → EditorContext-5QpqAhjh.js.map} +1 -1
  11. package/dist/{FontAnalyzer-CLv7_msL.js → FontAnalyzer-DIlqmyuf.js} +35 -35
  12. package/dist/FontAnalyzer-DIlqmyuf.js.map +1 -0
  13. package/dist/{ElementFactory-CuHSAPfg.js → ImportManager-D--7JnvW.js} +699 -476
  14. package/dist/ImportManager-D--7JnvW.js.map +1 -0
  15. package/dist/MenuButton-CeoEAtzP.js +7444 -0
  16. package/dist/MenuButton-CeoEAtzP.js.map +1 -0
  17. package/dist/SnowconeCanvas-C_O-aeaQ.js +1166 -0
  18. package/dist/SnowconeCanvas-C_O-aeaQ.js.map +1 -0
  19. package/dist/advanced.mjs +266 -264
  20. package/dist/advanced.mjs.map +1 -1
  21. package/dist/api/embed.d.ts +1 -1
  22. package/dist/components/ContextualToolbars.d.ts +8 -0
  23. package/dist/components/editor/EditorAdd.d.ts +11 -0
  24. package/dist/components/editor/EditorCanvasImpl.d.ts +6 -0
  25. package/dist/components/editor/EditorControls.d.ts +14 -0
  26. package/dist/components/editor/EditorHistory.d.ts +11 -0
  27. package/dist/components/editor/EditorLayers.d.ts +16 -0
  28. package/dist/components/editor/EditorMenu.d.ts +11 -0
  29. package/dist/components/editor/RootInternals.d.ts +7 -0
  30. package/dist/components/editor/index.d.ts +20 -0
  31. package/dist/components/embed/addElementTypes.d.ts +9 -0
  32. package/dist/contexts/EditorContext.d.ts +38 -0
  33. package/dist/core/preview-registry.d.ts +34 -0
  34. package/dist/{editorErrors-BY4Pdg7a.js → editorErrors-DXNfVXtD.js} +2 -2
  35. package/dist/{editorErrors-BY4Pdg7a.js.map → editorErrors-DXNfVXtD.js.map} +1 -1
  36. package/dist/embed-Cdbjay9i.js +961 -0
  37. package/dist/embed-Cdbjay9i.js.map +1 -0
  38. package/dist/embed.mjs +5 -5
  39. package/dist/index.mjs +7 -7
  40. package/dist/internals.mjs +12 -12
  41. package/dist/{template-fields-Z9x13sjM.js → template-fields-DgoBtajp.js} +266 -240
  42. package/dist/template-fields-DgoBtajp.js.map +1 -0
  43. package/dist/testing.mjs +3 -3
  44. package/dist/{usePieceGuideBundle-C1ipFnZd.js → usePieceGuideBundle-DVOISsB1.js} +2 -2
  45. package/dist/{usePieceGuideBundle-C1ipFnZd.js.map → usePieceGuideBundle-DVOISsB1.js.map} +1 -1
  46. package/dist/validation-0IscSfRb.js +9304 -0
  47. package/dist/validation-0IscSfRb.js.map +1 -0
  48. package/package.json +1 -1
  49. package/dist/EditorCanvasImpl-DQxqdgpq.js +0 -70
  50. package/dist/EditorCanvasImpl-DQxqdgpq.js.map +0 -1
  51. package/dist/EditorContext-CGkfmbgo.js +0 -1178
  52. package/dist/ElementFactory-CuHSAPfg.js.map +0 -1
  53. package/dist/FontAnalyzer-CLv7_msL.js.map +0 -1
  54. package/dist/ImportManager-C_wBjWaV.js.map +0 -1
  55. package/dist/SnowconeCanvas-DBbmx9qW.js +0 -1187
  56. package/dist/SnowconeCanvas-DBbmx9qW.js.map +0 -1
  57. package/dist/UnifiedFontService-Dsu5cwfT.js +0 -1478
  58. package/dist/UnifiedFontService-Dsu5cwfT.js.map +0 -1
  59. package/dist/embed--B8ot6Lj.js +0 -746
  60. package/dist/embed--B8ot6Lj.js.map +0 -1
  61. package/dist/iconify-D6eVIEy4.js +0 -1089
  62. package/dist/iconify-D6eVIEy4.js.map +0 -1
  63. package/dist/template-fields-Z9x13sjM.js.map +0 -1
  64. package/dist/validation-C795COGQ.js +0 -19959
  65. package/dist/validation-C795COGQ.js.map +0 -1
@@ -0,0 +1,1184 @@
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
11
+ );
12
+ return a(
13
+ (o) => !!(t && o && t.getBoundLayer(o)),
14
+ // `version` is the reactivity key: a registry change must mint a new
15
+ // callback so memoized consumers re-evaluate.
16
+ [t, e]
17
+ );
18
+ }
19
+ class It extends Error {
20
+ constructor(e, o, n = {}) {
21
+ super(`[Editor] ${e}: ${o}`), this.name = "EditorError", this.code = e, this.data = { code: e, ...n };
22
+ }
23
+ }
24
+ function Yt(t) {
25
+ return t instanceof Error && t.name === "EditorError" && "code" in t;
26
+ }
27
+ function jt() {
28
+ var t;
29
+ return typeof He < "u" && ((t = He.env) == null ? void 0 : t.NODE_ENV) !== "production";
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;
36
+ if (!l || !y) return;
37
+ const x = l.getBoundLayer(y);
38
+ if (x)
39
+ throw new It(
40
+ "E_BOUND_LAYER_MUTATION",
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
+ { layer: y, part: x.part, operation: A, docSlug: "embed-mode" }
43
+ );
44
+ },
45
+ [l]
46
+ ), [r, u] = E({
47
+ canUndo: !1,
48
+ canRedo: !1,
49
+ // Per-artboard state for the active artboard
50
+ canUndoActiveArtboard: !1,
51
+ canRedoActiveArtboard: !1
52
+ }), s = a(() => {
53
+ const c = d.current, A = o.getActiveArtboardId();
54
+ u({
55
+ canUndo: c.canUndo(),
56
+ canRedo: c.canRedo(),
57
+ // Per-artboard state - only check active artboard's history
58
+ canUndoActiveArtboard: A ? c.canUndoArtboard(A) : !1,
59
+ canRedoActiveArtboard: A ? c.canRedoArtboard(A) : !1
60
+ });
61
+ }, [o]), V = a(
62
+ (c, A) => {
63
+ c && c.name !== A.name && i(c, "rename");
64
+ const y = new it(
65
+ A.id,
66
+ c || null,
67
+ A,
68
+ (P) => {
69
+ e((k) => k.map((C) => C.id === P.id ? P : C));
70
+ }
71
+ ), x = o.getArtboardIdForElement(A.id);
72
+ if (x)
73
+ d.current.executeOnArtboard(x, y);
74
+ else {
75
+ const P = o.getActiveArtboardId();
76
+ P && d.current.executeOnArtboard(P, y);
77
+ }
78
+ s();
79
+ },
80
+ [e, o, s, i]
81
+ ), O = a(
82
+ (c, A, y, x) => {
83
+ const P = A || o.getActiveArtboardId();
84
+ if (!P) {
85
+ fe.warn("No active artboard to add element to");
86
+ return;
87
+ }
88
+ const k = new ct(
89
+ c,
90
+ (C) => {
91
+ const N = C;
92
+ e((v) => {
93
+ if (x) {
94
+ const U = v.findIndex((R) => R.id === x);
95
+ if (U !== -1) {
96
+ const R = [...v];
97
+ return R.splice(U, 0, N), R;
98
+ }
99
+ }
100
+ if (y) {
101
+ const U = v.findIndex((R) => R.id === y);
102
+ if (U !== -1) {
103
+ const R = [...v];
104
+ return R.splice(U + 1, 0, N), R;
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);
110
+ if (ne !== -1) {
111
+ const j = Y.clone();
112
+ j.children.splice(ne + 1, 0, N);
113
+ const J = [...v];
114
+ return J[R] = j, J;
115
+ }
116
+ }
117
+ }
118
+ }
119
+ return [...v, N];
120
+ }), o.addElementToArtboard(C.id, P);
121
+ },
122
+ (C) => {
123
+ e((N) => N.filter((v) => v.id !== C)), o.removeElementFromArtboard(C);
124
+ }
125
+ );
126
+ d.current.executeOnArtboard(P, k), s();
127
+ },
128
+ [e, o, s]
129
+ ), D = a(
130
+ (c) => {
131
+ i(c, "delete");
132
+ const A = o.getArtboardIdForElement(c.id);
133
+ if (!A) {
134
+ fe.warn("Element not found in any artboard");
135
+ return;
136
+ }
137
+ const y = new st(
138
+ c,
139
+ (x) => {
140
+ e((P) => [...P, x]), o.addElementToArtboard(x.id, A);
141
+ },
142
+ (x) => {
143
+ e((P) => P.filter((k) => k.id !== x)), o.removeElementFromArtboard(x);
144
+ }
145
+ );
146
+ d.current.executeOnArtboard(A, y), s();
147
+ },
148
+ [e, o, s, i]
149
+ ), w = a(
150
+ (c) => {
151
+ const A = new dt(c, o);
152
+ d.current.executeGlobal(A), s(), n == null || n();
153
+ },
154
+ [o, s, n]
155
+ ), L = a(
156
+ (c) => {
157
+ const A = new at(c, o);
158
+ d.current.executeGlobal(A), s(), n == null || n();
159
+ },
160
+ [o, s, n]
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();
165
+ },
166
+ [o, s, n]
167
+ ), f = a(
168
+ (c) => {
169
+ if (c.length === 0)
170
+ return;
171
+ const A = o.getActiveArtboardId();
172
+ if (!A) {
173
+ fe.warn("No active artboard for batch execution");
174
+ return;
175
+ }
176
+ const y = c.map((x) => new class extends Object {
177
+ execute() {
178
+ x.execute();
179
+ }
180
+ undo() {
181
+ x.undo();
182
+ }
183
+ }());
184
+ d.current.executeBatchOnArtboard(A, y), s();
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();
202
+ },
203
+ [s]
204
+ ), B = ue(null);
205
+ Ce(() => {
206
+ const c = o.getActiveArtboardId();
207
+ c !== B.current && (B.current = c, s());
208
+ });
209
+ const W = a(
210
+ (c, A, y) => {
211
+ const x = t.map((C) => C.id), P = o.getArtboardIdForElement(c);
212
+ if (!P) {
213
+ fe.warn("Element not found in any artboard");
214
+ return;
215
+ }
216
+ const k = new ut(c, A, y, x, (C) => {
217
+ e((N) => {
218
+ const v = new Map(N.map((U) => [U.id, U]));
219
+ return C.map((U) => v.get(U)).filter(Boolean);
220
+ });
221
+ });
222
+ d.current.executeOnArtboard(P, k), s();
223
+ },
224
+ [t, e, o, s]
225
+ );
226
+ return {
227
+ // Element operations
228
+ executeElementUpdate: V,
229
+ executeAddElement: O,
230
+ executeRemoveElement: D,
231
+ executeReorderElement: W,
232
+ // Batch operations
233
+ executeCommandBatch: f,
234
+ // Artboard operations
235
+ executeCreateArtboard: w,
236
+ executeDeleteArtboard: L,
237
+ executeUpdateArtboard: p,
238
+ // Undo/redo (smart - considers last operation and active artboard)
239
+ undo: T,
240
+ redo: z,
241
+ // Undo/redo for active artboard only (element operations)
242
+ undoActiveArtboard: g,
243
+ redoActiveArtboard: b,
244
+ clearHistory: _,
245
+ clearArtboardHistory: te,
246
+ // State (smart - considers last operation)
247
+ canUndo: r.canUndo,
248
+ canRedo: r.canRedo,
249
+ // State for active artboard only
250
+ canUndoActiveArtboard: r.canUndoActiveArtboard,
251
+ canRedoActiveArtboard: r.canRedoActiveArtboard,
252
+ historyManager: d.current
253
+ };
254
+ }
255
+ function oe(t) {
256
+ return t && "fontSize" in t && "color" in t && "fontFamily" in t;
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(() => {
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);
264
+ }
265
+ }, [t]);
266
+ const V = a(
267
+ (p) => {
268
+ if (!t || !oe(t)) return;
269
+ const f = Math.max(ft, Math.min(At, o + p));
270
+ n(f);
271
+ const T = t.clone();
272
+ T.transformType === "circle" && "setEffectiveFontSize" in T ? T.setEffectiveFontSize(f) : T.setFontSize(f), e(T);
273
+ },
274
+ [t, o, e]
275
+ ), O = a(
276
+ (p) => {
277
+ if (!t || !oe(t)) return;
278
+ n(p);
279
+ const f = t.clone();
280
+ f.transformType === "circle" && "setEffectiveFontSize" in f ? f.setEffectiveFontSize(p) : f.setFontSize(p), e(f);
281
+ },
282
+ [t, e]
283
+ ), D = a(
284
+ (p) => {
285
+ if (!t || !oe(t)) return;
286
+ l(p);
287
+ const f = t.clone();
288
+ if (f.color = p, f.richText)
289
+ for (const T of f.richText.spans)
290
+ T.style.color = void 0;
291
+ e(f);
292
+ },
293
+ [t, e]
294
+ ), w = a(
295
+ (p) => {
296
+ if (!t || !oe(t)) return;
297
+ const f = t.fontFamily;
298
+ f !== p && mt.clearCache(f), r(p);
299
+ const T = t.clone();
300
+ T.fontFamily = p, e(T);
301
+ },
302
+ [t, e]
303
+ ), L = a(
304
+ (p) => {
305
+ if (!t || !oe(t)) return;
306
+ s(p);
307
+ const f = t.clone();
308
+ f.textAlign = p, e(f);
309
+ },
310
+ [t, e]
311
+ );
312
+ return {
313
+ // State
314
+ fontSize: o,
315
+ fontColor: d,
316
+ fontFamily: i,
317
+ textAlign: u,
318
+ // State setters (for UI only)
319
+ setFontSize: n,
320
+ setFontColor: l,
321
+ setFontFamily: r,
322
+ setTextAlign: s,
323
+ // Update functions (update element + UI)
324
+ updateFontSize: V,
325
+ setFontSizeValue: O,
326
+ updateFontColor: D,
327
+ updateFontFamily: w,
328
+ updateTextAlign: L
329
+ };
330
+ }
331
+ const Ze = "data-preserve-selection";
332
+ function gt(t) {
333
+ if (!(t instanceof Element))
334
+ return !1;
335
+ let e = t;
336
+ const o = [];
337
+ for (; e; ) {
338
+ const n = e.id ? `#${e.id}` : "", d = e.className ? `.${String(e.className).split(" ").slice(0, 2).join(".")}` : "";
339
+ if (o.push(`${e.tagName.toLowerCase()}${n}${d}`), e.hasAttribute(Ze))
340
+ return !0;
341
+ const l = e.getAttribute("role");
342
+ if (l === "dialog" || l === "alertdialog" || l === "menu" || l === "listbox")
343
+ return !0;
344
+ const i = e.getAttribute("data-slot");
345
+ if (i && (i.includes("popover") || i.includes("dialog")) || e.hasAttribute("data-radix-popper-content-wrapper"))
346
+ return !0;
347
+ e = e.parentElement;
348
+ }
349
+ return !1;
350
+ }
351
+ const Jt = {
352
+ [Ze]: ""
353
+ };
354
+ function Pt(t) {
355
+ const e = $e(t);
356
+ return e !== null && e < 0.5;
357
+ }
358
+ function Kt(t) {
359
+ const e = $e(t);
360
+ return e !== null && e >= 0.5;
361
+ }
362
+ function $e(t) {
363
+ const e = t.trim();
364
+ if (e.startsWith("#")) {
365
+ const n = e.slice(1);
366
+ let d, l, i;
367
+ if (n.length === 3)
368
+ d = parseInt(n[0] + n[0], 16), l = parseInt(n[1] + n[1], 16), i = parseInt(n[2] + n[2], 16);
369
+ else if (n.length === 6)
370
+ d = parseInt(n.slice(0, 2), 16), l = parseInt(n.slice(2, 4), 16), i = parseInt(n.slice(4, 6), 16);
371
+ else return null;
372
+ return Number.isNaN(d) || Number.isNaN(l) || Number.isNaN(i) ? null : Le(d, l, i);
373
+ }
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;
376
+ }
377
+ function Le(t, e, o) {
378
+ const n = (d) => {
379
+ const l = d / 255;
380
+ return l <= 0.03928 ? l / 12.92 : Math.pow((l + 0.055) / 1.055, 2.4);
381
+ };
382
+ return 0.2126 * n(t) + 0.7152 * n(e) + 0.0722 * n(o);
383
+ }
384
+ const Ft = "#333333", Rt = "#f4f4f5";
385
+ function Ct(t) {
386
+ return t && Pt(t) ? Rt : Ft;
387
+ }
388
+ const Ge = Q(null), vt = 0.1, zt = 4, Be = 0.25, Ot = ({
389
+ children: t,
390
+ artboardManager: e,
391
+ canvasRef: o,
392
+ viewPadding: n = 0.9
393
+ }) => {
394
+ const [d, l] = E(1), [i, r] = E({ x: 0, y: 0 }), [u, s] = E(!1), [V, O] = E(1), D = a(() => {
395
+ O(1), r({ x: 0, y: 0 });
396
+ }, []), w = a(() => {
397
+ l((z) => Math.min(z + Be, zt));
398
+ }, []), L = a(() => {
399
+ l((z) => Math.max(z - Be, vt));
400
+ }, []), p = a(() => {
401
+ const z = e.getActiveArtboard();
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;
406
+ if (!b || !_) return;
407
+ const te = Math.min(
408
+ b * n / z.width,
409
+ _ * n / z.height,
410
+ 1
411
+ // Never zoom in beyond 100%
412
+ );
413
+ l(te), r({ x: 0, y: 0 });
414
+ }, [e, o, n]), f = a(() => {
415
+ l(1), r({ x: 0, y: 0 });
416
+ }, []), T = q(
417
+ () => ({
418
+ zoom: d,
419
+ panOffset: i,
420
+ isPanning: u,
421
+ zoomIn: w,
422
+ zoomOut: L,
423
+ zoomToFit: p,
424
+ resetView: f,
425
+ setZoom: l,
426
+ setPanOffset: r,
427
+ setIsPanning: s,
428
+ userZoom: V,
429
+ setUserZoom: O,
430
+ resetUserView: D
431
+ }),
432
+ [d, i, u, w, L, p, f, V, D]
433
+ );
434
+ return /* @__PURE__ */ H(Ge.Provider, { value: T, children: t });
435
+ };
436
+ function Ut() {
437
+ const t = X(Ge);
438
+ if (!t)
439
+ throw new Error("useViewportContext must be used within a ViewportProvider (or EditorProvider)");
440
+ return t;
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) => {
444
+ o(L);
445
+ }, []), D = a((L) => {
446
+ i(L);
447
+ }, []), w = q(
448
+ () => ({
449
+ selectedId: e,
450
+ multiSelection: n,
451
+ activeChildElement: l,
452
+ hoveredElementId: r,
453
+ hideHandles: s,
454
+ setSelectedId: o,
455
+ setMultiSelection: d,
456
+ setHoveredElementId: u,
457
+ setHideHandles: V,
458
+ handleSelectionChange: O,
459
+ handleActiveChildChange: D
460
+ }),
461
+ [
462
+ e,
463
+ n,
464
+ l,
465
+ r,
466
+ s,
467
+ O,
468
+ D
469
+ ]
470
+ );
471
+ return /* @__PURE__ */ H(Xe.Provider, { value: w, children: t });
472
+ };
473
+ function Vt() {
474
+ const t = X(Xe);
475
+ if (!t)
476
+ throw new Error("useSelectionContext must be used within a SelectionProvider (or EditorProvider)");
477
+ return t;
478
+ }
479
+ const Ye = Q(null), Nt = ({ children: t, value: e }) => {
480
+ const o = q(
481
+ () => ({
482
+ undo: e.undo,
483
+ redo: e.redo,
484
+ canUndo: e.canUndo,
485
+ canRedo: e.canRedo,
486
+ undoActiveArtboard: e.undoActiveArtboard,
487
+ redoActiveArtboard: e.redoActiveArtboard,
488
+ canUndoActiveArtboard: e.canUndoActiveArtboard,
489
+ canRedoActiveArtboard: e.canRedoActiveArtboard
490
+ }),
491
+ [
492
+ e.undo,
493
+ e.redo,
494
+ e.canUndo,
495
+ e.canRedo,
496
+ e.undoActiveArtboard,
497
+ e.redoActiveArtboard,
498
+ e.canUndoActiveArtboard,
499
+ e.canRedoActiveArtboard
500
+ ]
501
+ );
502
+ return /* @__PURE__ */ H(Ye.Provider, { value: o, children: t });
503
+ };
504
+ function Mt() {
505
+ const t = X(Ye);
506
+ if (!t)
507
+ throw new Error("useHistoryContext must be used within a HistoryProvider (or EditorProvider)");
508
+ return t;
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(
512
+ () => ({
513
+ expandedPanelType: e,
514
+ setExpandedPanelType: o,
515
+ isToolbarMenuOpen: n,
516
+ setIsToolbarMenuOpen: d,
517
+ textSelectionVersion: l,
518
+ setTextSelectionVersion: i,
519
+ isCanvasReady: r,
520
+ setCanvasReady: u,
521
+ isRotating: s,
522
+ setIsRotating: V
523
+ }),
524
+ [e, n, l, r, s]
525
+ );
526
+ return /* @__PURE__ */ H(je.Provider, { value: O, children: t });
527
+ };
528
+ function Lt() {
529
+ const t = X(je);
530
+ if (!t)
531
+ throw new Error("useToolStateContext must be used within a ToolStateProvider (or EditorProvider)");
532
+ return t;
533
+ }
534
+ const Je = Q(null), Bt = ({ children: t, value: e }) => {
535
+ const o = q(
536
+ () => ({
537
+ elements: e.elements,
538
+ elementStore: e.elementStore,
539
+ artboards: e.artboards,
540
+ artboardManager: e.artboardManager,
541
+ artboardVersion: e.artboardVersion,
542
+ setElements: e.setElements,
543
+ refreshArtboards: e.refreshArtboards,
544
+ getElementById: e.getElementById,
545
+ handleAddElement: e.handleAddElement,
546
+ handleElementUpdate: e.handleElementUpdate,
547
+ handleLoadWorkspace: e.handleLoadWorkspace,
548
+ handleCopyElements: e.handleCopyElements,
549
+ handlePasteElements: e.handlePasteElements,
550
+ fontSize: e.fontSize,
551
+ fontColor: e.fontColor,
552
+ fontFamily: e.fontFamily,
553
+ textAlign: e.textAlign,
554
+ updateFontSize: e.updateFontSize,
555
+ setFontSizeValue: e.setFontSizeValue,
556
+ updateFontColor: e.updateFontColor,
557
+ updateFontFamily: e.updateFontFamily,
558
+ updateTextAlign: e.updateTextAlign,
559
+ canvasRef: e.canvasRef,
560
+ canvasEditorRef: e.canvasEditorRef
561
+ }),
562
+ [
563
+ e.elements,
564
+ e.elementStore,
565
+ e.artboards,
566
+ e.artboardManager,
567
+ e.artboardVersion,
568
+ e.setElements,
569
+ e.refreshArtboards,
570
+ e.getElementById,
571
+ e.handleAddElement,
572
+ e.handleElementUpdate,
573
+ e.handleLoadWorkspace,
574
+ e.handleCopyElements,
575
+ e.handlePasteElements,
576
+ e.fontSize,
577
+ e.fontColor,
578
+ e.fontFamily,
579
+ e.textAlign,
580
+ e.updateFontSize,
581
+ e.setFontSizeValue,
582
+ e.updateFontColor,
583
+ e.updateFontFamily,
584
+ e.updateTextAlign,
585
+ e.canvasRef,
586
+ e.canvasEditorRef
587
+ ]
588
+ );
589
+ return /* @__PURE__ */ H(Je.Provider, { value: o, children: t });
590
+ };
591
+ function qt() {
592
+ const t = X(Je);
593
+ if (!t)
594
+ throw new Error("useElementsContext must be used within an ElementsProvider (or EditorProvider)");
595
+ return t;
596
+ }
597
+ const Ke = Q(null), _t = ({ children: t, value: e }) => {
598
+ const o = q(
599
+ () => ({
600
+ executeElementUpdate: e.executeElementUpdate,
601
+ executeAddElement: e.executeAddElement,
602
+ executeRemoveElement: e.executeRemoveElement,
603
+ executeReorderElement: e.executeReorderElement,
604
+ executeCreateArtboard: e.executeCreateArtboard,
605
+ executeDeleteArtboard: e.executeDeleteArtboard,
606
+ executeUpdateArtboard: e.executeUpdateArtboard,
607
+ executeCommandBatch: e.executeCommandBatch,
608
+ undo: e.undo,
609
+ redo: e.redo,
610
+ canUndo: e.canUndo,
611
+ canRedo: e.canRedo,
612
+ undoActiveArtboard: e.undoActiveArtboard,
613
+ redoActiveArtboard: e.redoActiveArtboard,
614
+ canUndoActiveArtboard: e.canUndoActiveArtboard,
615
+ canRedoActiveArtboard: e.canRedoActiveArtboard,
616
+ historyManager: e.historyManager
617
+ }),
618
+ [
619
+ e.executeElementUpdate,
620
+ e.executeAddElement,
621
+ e.executeRemoveElement,
622
+ e.executeReorderElement,
623
+ e.executeCreateArtboard,
624
+ e.executeDeleteArtboard,
625
+ e.executeUpdateArtboard,
626
+ e.executeCommandBatch,
627
+ e.undo,
628
+ e.redo,
629
+ e.canUndo,
630
+ e.canRedo,
631
+ e.undoActiveArtboard,
632
+ e.redoActiveArtboard,
633
+ e.canUndoActiveArtboard,
634
+ e.canRedoActiveArtboard,
635
+ e.historyManager
636
+ ]
637
+ );
638
+ return /* @__PURE__ */ H(Ke.Provider, { value: o, children: t });
639
+ };
640
+ function Qt() {
641
+ const t = X(Ke);
642
+ if (!t)
643
+ throw new Error("useCommandContext must be used within a CommandProvider (or EditorProvider)");
644
+ return t;
645
+ }
646
+ const kt = ke("EditorContext"), Me = Q(null), qe = Q(null), en = () => {
647
+ const t = X(qe);
648
+ if (!t)
649
+ throw new Error("useEditorHandles must be used within EditorProvider");
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(
653
+ () => e.getAllArtboards()
654
+ ), [O, D] = E(0), [w, L] = E(
655
+ () => new Ve()
656
+ ), p = q(() => w.toArray(), [w]), f = a((m) => {
657
+ L((h) => {
658
+ const I = h.toArray(), F = typeof m == "function" ? m(I) : m;
659
+ return F === I ? h : Ve.fromArray(F);
660
+ });
661
+ }, []), T = a(
662
+ (m) => w.get(m),
663
+ [w]
664
+ ), [z, g] = E([]), b = r.selectedId ? w.get(r.selectedId) : void 0, _ = a(() => {
665
+ V([...e.getAllArtboards()]), D((m) => m + 1);
666
+ }, [e]), {
667
+ historyManager: te,
668
+ executeElementUpdate: B,
669
+ executeAddElement: W,
670
+ executeRemoveElement: c,
671
+ executeReorderElement: A,
672
+ executeCommandBatch: y,
673
+ executeCreateArtboard: x,
674
+ executeDeleteArtboard: P,
675
+ executeUpdateArtboard: k,
676
+ undo: C,
677
+ redo: N,
678
+ canUndo: v,
679
+ canRedo: U,
680
+ undoActiveArtboard: R,
681
+ redoActiveArtboard: Y,
682
+ canUndoActiveArtboard: ne,
683
+ canRedoActiveArtboard: j
684
+ } = wt(
685
+ p,
686
+ f,
687
+ e,
688
+ _
689
+ ), J = a(
690
+ (m) => {
691
+ const h = w.get(m.id);
692
+ B(h, m);
693
+ },
694
+ [w, B]
695
+ ), Qe = a(
696
+ (m) => {
697
+ if (!b || !(b instanceof _e))
698
+ return;
699
+ const h = b.clone(), I = h.children.findIndex(
700
+ (F) => F.id === m.id
701
+ );
702
+ I >= 0 && (h.children[I] = m, J(h));
703
+ },
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(
716
+ async (m, h) => {
717
+ var ze;
718
+ const I = e.getActiveArtboardId();
719
+ if (!I) {
720
+ alert("Please create or select an artboard first");
721
+ return;
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;
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,
729
+ // Defer loading `src` until after the element is in the store so a
730
+ // synchronously-cached image can't fire onLoadCallback too early.
731
+ imageUrl: K ? "" : le,
732
+ transformData: {
733
+ type: "image",
734
+ width: ee,
735
+ height: ee,
736
+ cropX: 0,
737
+ cropY: 0,
738
+ cropWidth: 1,
739
+ cropHeight: 1,
740
+ flipHorizontal: !1,
741
+ flipVertical: !1,
742
+ borderRadius: 0
743
+ }
744
+ });
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);
749
+ return;
750
+ }
751
+ let ce;
752
+ const $ = {
753
+ text: "custom",
754
+ circle: "circle",
755
+ wave: "wave",
756
+ arch: "arch",
757
+ shape: "shape"
758
+ }[m] || "custom", de = yt($);
759
+ if (!de || !de.Component)
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;
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,
769
+ transformData: {
770
+ type: "shape",
771
+ shapeType: le,
772
+ width: ee,
773
+ height: K,
774
+ fillColor: "#3b82f6",
775
+ fillOpacity: 1
776
+ }
777
+ });
778
+ } else
779
+ ce = new de.Component({
780
+ id: F,
781
+ text: "New Text",
782
+ x: re,
783
+ y: ie,
784
+ fontSize: nt,
785
+ fontFamily: "Poppins",
786
+ color: Ct(S == null ? void 0 : S.backgroundColor),
787
+ transformData: $ === "arch" ? {
788
+ type: "arch",
789
+ width: Fe,
790
+ archHeight: St.archHeight
791
+ } : $ === "wave" ? {
792
+ type: "wave",
793
+ width: Fe,
794
+ amplitude: Ne.amplitude,
795
+ frequency: Ne.frequency
796
+ } : $ === "circle" ? {
797
+ type: "circle",
798
+ radius: Fe / 2
799
+ } : void 0
800
+ });
801
+ e.addElementToArtboard(F, I), W(
802
+ ce,
803
+ I,
804
+ r.selectedId || void 0
805
+ ), r.setSelectedId(F);
806
+ },
807
+ [e, W, B, r, i.zoom, n]
808
+ ), Te = a(() => {
809
+ const m = [];
810
+ if (r.multiSelection.length > 0) {
811
+ const h = p.filter(
812
+ (I) => r.multiSelection.includes(I.id)
813
+ );
814
+ m.push(...h);
815
+ } else b && m.push(b);
816
+ if (m.length > 0) {
817
+ const h = m.map((I) => I.clone());
818
+ g(h);
819
+ }
820
+ }, [b, r.multiSelection, p]), ge = a(() => {
821
+ if (z.length === 0) return;
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(
830
+ S.id
831
+ )), $ || ($ = e.getActiveArtboardId()), !$) {
832
+ kt.warn("[handlePasteElements] No artboard found for pasting");
833
+ return;
834
+ }
835
+ const de = S ? S.id : void 0;
836
+ W(se, $, de), m.push(se.id);
837
+ }), m.length === 1 ? r.handleSelectionChange(m[0]) : m.length > 1 && r.setMultiSelection(m);
838
+ }, [
839
+ z,
840
+ w,
841
+ e,
842
+ W,
843
+ r
844
+ ]), me = a(() => {
845
+ if (u.expandedPanelType === "crop" && (b == null ? void 0 : b.transformType) === "image") {
846
+ const m = b;
847
+ if (m.isCropping) {
848
+ const h = m.clone();
849
+ h.exitCropMode(), B(m, h);
850
+ }
851
+ }
852
+ u.setExpandedPanelType(null);
853
+ }, [
854
+ u.expandedPanelType,
855
+ u.setExpandedPanelType,
856
+ b,
857
+ B
858
+ ]);
859
+ Ce(() => {
860
+ const m = (h) => {
861
+ const I = h.target;
862
+ if (I.tagName === "CANVAS" || gt(I))
863
+ return;
864
+ const S = document.activeElement;
865
+ if (S != null && S.hasAttribute("data-preserve-selection")) {
866
+ S.blur();
867
+ return;
868
+ }
869
+ if (u.expandedPanelType !== null) {
870
+ me();
871
+ return;
872
+ }
873
+ r.selectedId !== null && r.setSelectedId(null), r.multiSelection.length > 0 && r.setMultiSelection([]);
874
+ };
875
+ return document.addEventListener("pointerdown", m), () => document.removeEventListener("pointerdown", m);
876
+ }, [u.expandedPanelType, me, r]);
877
+ const Pe = a(
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);
882
+ },
883
+ [e, r, f]
884
+ ), ve = q(() => ({
885
+ // From ViewportContext
886
+ zoom: i.zoom,
887
+ panOffset: i.panOffset,
888
+ isPanning: i.isPanning,
889
+ zoomIn: i.zoomIn,
890
+ zoomOut: i.zoomOut,
891
+ zoomToFit: i.zoomToFit,
892
+ resetView: i.resetView,
893
+ setZoom: i.setZoom,
894
+ setPanOffset: i.setPanOffset,
895
+ setIsPanning: i.setIsPanning,
896
+ // From SelectionContext
897
+ selectedId: r.selectedId,
898
+ multiSelection: r.multiSelection,
899
+ activeChildElement: r.activeChildElement,
900
+ hoveredElementId: r.hoveredElementId,
901
+ hideHandles: r.hideHandles,
902
+ setSelectedId: r.setSelectedId,
903
+ setMultiSelection: r.setMultiSelection,
904
+ setHoveredElementId: r.setHoveredElementId,
905
+ setHideHandles: r.setHideHandles,
906
+ handleSelectionChange: r.handleSelectionChange,
907
+ handleActiveChildChange: r.handleActiveChildChange,
908
+ // From ToolStateContext
909
+ expandedPanelType: u.expandedPanelType,
910
+ setExpandedPanelType: u.setExpandedPanelType,
911
+ isToolbarMenuOpen: u.isToolbarMenuOpen,
912
+ setIsToolbarMenuOpen: u.setIsToolbarMenuOpen,
913
+ textSelectionVersion: u.textSelectionVersion,
914
+ setTextSelectionVersion: u.setTextSelectionVersion,
915
+ isCanvasReady: u.isCanvasReady,
916
+ setCanvasReady: u.setCanvasReady,
917
+ isRotating: u.isRotating,
918
+ setIsRotating: u.setIsRotating,
919
+ // Cross-context handler
920
+ clearExpandedPanel: me,
921
+ // Core state (element/artboard domain)
922
+ artboardManager: e,
923
+ artboards: s,
924
+ elements: p,
925
+ elementStore: w,
926
+ getElementById: T,
927
+ // Derived state (cross-context)
928
+ selectedElement: b,
929
+ // Refs
930
+ canvasRef: o,
931
+ canvasEditorRef: n,
932
+ // Element setters
933
+ setElements: f,
934
+ // Artboard version counter
935
+ artboardVersion: O,
936
+ // Handlers
937
+ refreshArtboards: _,
938
+ handleElementUpdate: J,
939
+ handleAddElement: we,
940
+ handleLoadWorkspace: Pe,
941
+ handleCopyElements: Te,
942
+ handlePasteElements: ge,
943
+ // Command history (undo/redo actions + execute functions)
944
+ historyManager: te,
945
+ executeElementUpdate: B,
946
+ executeAddElement: W,
947
+ executeRemoveElement: c,
948
+ executeReorderElement: A,
949
+ executeCommandBatch: y,
950
+ executeCreateArtboard: x,
951
+ executeDeleteArtboard: P,
952
+ executeUpdateArtboard: k,
953
+ undo: C,
954
+ redo: N,
955
+ canUndo: v,
956
+ canRedo: U,
957
+ undoActiveArtboard: R,
958
+ redoActiveArtboard: Y,
959
+ canUndoActiveArtboard: ne,
960
+ canRedoActiveArtboard: j,
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
971
+ }), [
972
+ // Viewport
973
+ i.zoom,
974
+ i.panOffset,
975
+ i.isPanning,
976
+ i.zoomIn,
977
+ i.zoomOut,
978
+ i.zoomToFit,
979
+ i.resetView,
980
+ i.setZoom,
981
+ i.setPanOffset,
982
+ i.setIsPanning,
983
+ // Selection
984
+ r.selectedId,
985
+ r.multiSelection,
986
+ r.activeChildElement,
987
+ r.hoveredElementId,
988
+ r.hideHandles,
989
+ r.setSelectedId,
990
+ r.setMultiSelection,
991
+ r.setHoveredElementId,
992
+ r.setHideHandles,
993
+ r.handleSelectionChange,
994
+ r.handleActiveChildChange,
995
+ // Tool state
996
+ u.expandedPanelType,
997
+ u.setExpandedPanelType,
998
+ u.isToolbarMenuOpen,
999
+ u.setIsToolbarMenuOpen,
1000
+ u.textSelectionVersion,
1001
+ u.setTextSelectionVersion,
1002
+ u.isCanvasReady,
1003
+ u.setCanvasReady,
1004
+ u.isRotating,
1005
+ u.setIsRotating,
1006
+ me,
1007
+ // Element/artboard domain
1008
+ e,
1009
+ s,
1010
+ p,
1011
+ w,
1012
+ T,
1013
+ b,
1014
+ o,
1015
+ n,
1016
+ f,
1017
+ O,
1018
+ _,
1019
+ J,
1020
+ we,
1021
+ Pe,
1022
+ Te,
1023
+ ge,
1024
+ // Command history
1025
+ te,
1026
+ B,
1027
+ W,
1028
+ c,
1029
+ A,
1030
+ y,
1031
+ x,
1032
+ P,
1033
+ k,
1034
+ C,
1035
+ N,
1036
+ v,
1037
+ U,
1038
+ R,
1039
+ Y,
1040
+ ne,
1041
+ j,
1042
+ // Element properties
1043
+ Ae,
1044
+ pe,
1045
+ he,
1046
+ xe,
1047
+ ye,
1048
+ Ee,
1049
+ Se,
1050
+ be,
1051
+ Ie
1052
+ ]);
1053
+ return d.current = ve, /* @__PURE__ */ H(qe.Provider, { value: l, children: /* @__PURE__ */ H(
1054
+ Nt,
1055
+ {
1056
+ value: {
1057
+ undo: C,
1058
+ redo: N,
1059
+ canUndo: v,
1060
+ canRedo: U,
1061
+ undoActiveArtboard: R,
1062
+ redoActiveArtboard: Y,
1063
+ canUndoActiveArtboard: ne,
1064
+ canRedoActiveArtboard: j
1065
+ },
1066
+ children: /* @__PURE__ */ H(
1067
+ Bt,
1068
+ {
1069
+ value: {
1070
+ elements: p,
1071
+ elementStore: w,
1072
+ artboards: s,
1073
+ artboardManager: e,
1074
+ artboardVersion: O,
1075
+ setElements: f,
1076
+ refreshArtboards: _,
1077
+ getElementById: T,
1078
+ handleAddElement: we,
1079
+ handleElementUpdate: J,
1080
+ handleLoadWorkspace: Pe,
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,
1092
+ canvasRef: o,
1093
+ canvasEditorRef: n
1094
+ },
1095
+ children: /* @__PURE__ */ H(
1096
+ _t,
1097
+ {
1098
+ value: {
1099
+ executeElementUpdate: B,
1100
+ executeAddElement: W,
1101
+ executeRemoveElement: c,
1102
+ executeReorderElement: A,
1103
+ executeCommandBatch: y,
1104
+ executeCreateArtboard: x,
1105
+ executeDeleteArtboard: P,
1106
+ executeUpdateArtboard: k,
1107
+ undo: C,
1108
+ redo: N,
1109
+ canUndo: v,
1110
+ canRedo: U,
1111
+ undoActiveArtboard: R,
1112
+ redoActiveArtboard: Y,
1113
+ canUndoActiveArtboard: ne,
1114
+ canRedoActiveArtboard: j,
1115
+ historyManager: te
1116
+ },
1117
+ children: /* @__PURE__ */ H(Me.Provider, { value: ve, children: t })
1118
+ }
1119
+ )
1120
+ }
1121
+ )
1122
+ }
1123
+ ) });
1124
+ }, tn = ({
1125
+ children: t,
1126
+ initialArtboardConfig: e = {},
1127
+ viewPadding: o = 0.9
1128
+ }) => {
1129
+ const [n] = E(() => {
1130
+ const i = new ht(), r = {
1131
+ name: e.name || "Artboard 1",
1132
+ x: e.x ?? 0,
1133
+ y: e.y ?? 0,
1134
+ width: e.width ?? 1e3,
1135
+ height: e.height ?? 1e3,
1136
+ backgroundColor: e.backgroundColor || pt
1137
+ };
1138
+ return i.createArtboard(r), i;
1139
+ }), d = ue(null), l = ue(null);
1140
+ return /* @__PURE__ */ H(
1141
+ Ot,
1142
+ {
1143
+ artboardManager: n,
1144
+ canvasRef: d,
1145
+ viewPadding: o,
1146
+ children: /* @__PURE__ */ H(Ht, { children: /* @__PURE__ */ H(Dt, { children: /* @__PURE__ */ H(
1147
+ Wt,
1148
+ {
1149
+ artboardManager: n,
1150
+ canvasRef: d,
1151
+ canvasEditorRef: l,
1152
+ children: t
1153
+ }
1154
+ ) }) })
1155
+ }
1156
+ );
1157
+ }, nn = () => {
1158
+ const t = X(Me);
1159
+ if (!t)
1160
+ throw new Error("useEditor must be used within EditorProvider");
1161
+ return t;
1162
+ };
1163
+ export {
1164
+ We as B,
1165
+ tn as E,
1166
+ 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
1183
+ };
1184
+ //# sourceMappingURL=EditorContext-5QpqAhjh.js.map