@snowcone-app/canvas 0.43.7 → 0.44.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 (67) hide show
  1. package/dist/{CanvasRenderer-DIug_mjX.js → CanvasRenderer-B8BADU_r.js} +876 -830
  2. package/dist/CanvasRenderer-B8BADU_r.js.map +1 -0
  3. package/dist/{CanvasStateV1-BWd358xJ.js → CanvasStateV1-BlDWgOzV.js} +3 -3
  4. package/dist/{CanvasStateV1-BWd358xJ.js.map → CanvasStateV1-BlDWgOzV.js.map} +1 -1
  5. package/dist/ContextualToolbars-rCZo-KCm.js +6808 -0
  6. package/dist/ContextualToolbars-rCZo-KCm.js.map +1 -0
  7. package/dist/EditorCanvasImpl-C63QS2OK.js +144 -0
  8. package/dist/EditorCanvasImpl-C63QS2OK.js.map +1 -0
  9. package/dist/{ExportManager-BDH9jW4Q.js → ExportManager-xRsXgyNo.js} +2 -2
  10. package/dist/{ExportManager-BDH9jW4Q.js.map → ExportManager-xRsXgyNo.js.map} +1 -1
  11. package/dist/{FontAnalyzer-CyhywbAM.js → FontAnalyzer-Ds3Wdba7.js} +239 -236
  12. package/dist/FontAnalyzer-Ds3Wdba7.js.map +1 -0
  13. package/dist/{ImagePanel-CIGpLY3B.js → ImagePanel-DhOWKvIN.js} +6 -6
  14. package/dist/{ImagePanel-CIGpLY3B.js.map → ImagePanel-DhOWKvIN.js.map} +1 -1
  15. package/dist/{SnowconeCanvas-Bs34CUv5.js → SnowconeCanvas-C-AGGT44.js} +478 -465
  16. package/dist/SnowconeCanvas-C-AGGT44.js.map +1 -0
  17. package/dist/adjust-CDVzlVBY.js +145 -0
  18. package/dist/adjust-CDVzlVBY.js.map +1 -0
  19. package/dist/advanced.mjs +15 -15
  20. package/dist/api/stable.d.ts +2 -0
  21. package/dist/components/ImageToolbar.d.ts +3 -0
  22. package/dist/components/ShapeToolbar.d.ts +2 -0
  23. package/dist/components/TextToolbar.d.ts +2 -1
  24. package/dist/components/embed/SnowconeCanvas.d.ts +8 -0
  25. package/dist/components/toolbars/SecondaryPanels.d.ts +24 -0
  26. package/dist/components/toolbars/index.d.ts +2 -2
  27. package/dist/core/ArtboardElement.d.ts +2 -0
  28. package/dist/core/CanvasRenderer.d.ts +3 -1
  29. package/dist/core/pickOrder.d.ts +4 -0
  30. package/dist/{custom-icons-sT5sNRcG.js → custom-icons-C4bzABm2.js} +2 -2
  31. package/dist/{custom-icons-sT5sNRcG.js.map → custom-icons-C4bzABm2.js.map} +1 -1
  32. package/dist/{design-builder-CwfefZJC.js → design-builder-DCHVrEFV.js} +315 -314
  33. package/dist/design-builder-DCHVrEFV.js.map +1 -0
  34. package/dist/{embed-BcYaDLRo.js → embed-DnjyfavG.js} +10 -10
  35. package/dist/{embed-BcYaDLRo.js.map → embed-DnjyfavG.js.map} +1 -1
  36. package/dist/embed.mjs +19 -19
  37. package/dist/engrave/EngraveSync.d.ts +5 -0
  38. package/dist/engrave/adjust.d.ts +36 -0
  39. package/dist/engrave/makeEngraved.d.ts +23 -0
  40. package/dist/engrave/types.d.ts +33 -0
  41. package/dist/{guards-Dvw7Qch0.js → guards-DwYEoqcn.js} +2 -2
  42. package/dist/{guards-Dvw7Qch0.js.map → guards-DwYEoqcn.js.map} +1 -1
  43. package/dist/index.mjs +57 -54
  44. package/dist/index.mjs.map +1 -1
  45. package/dist/internals.mjs +6 -6
  46. package/dist/rendering/EngraveViewRenderer.d.ts +15 -0
  47. package/dist/{template-fields-DF1ijCl9.js → template-fields-CK7Uvvc8.js} +5 -5
  48. package/dist/{template-fields-DF1ijCl9.js.map → template-fields-CK7Uvvc8.js.map} +1 -1
  49. package/dist/testing.mjs +3 -3
  50. package/dist/types/index.d.ts +5 -0
  51. package/dist/{useCommands-wwGeWCn6.js → useCommands-BrkGKdXr.js} +7 -7
  52. package/dist/{useCommands-wwGeWCn6.js.map → useCommands-BrkGKdXr.js.map} +1 -1
  53. package/dist/{usePieceGuideBundle-BWQINIJR.js → usePieceGuideBundle-BWdobHQE.js} +2 -2
  54. package/dist/{usePieceGuideBundle-BWQINIJR.js.map → usePieceGuideBundle-BWdobHQE.js.map} +1 -1
  55. package/dist/{validation-B6sLZULE.js → validation-DETfj7tg.js} +2923 -2906
  56. package/dist/validation-DETfj7tg.js.map +1 -0
  57. package/example/package.json +1 -1
  58. package/package.json +3 -3
  59. package/dist/CanvasRenderer-DIug_mjX.js.map +0 -1
  60. package/dist/ContextualToolbars-CspkC1T3.js +0 -6604
  61. package/dist/ContextualToolbars-CspkC1T3.js.map +0 -1
  62. package/dist/EditorCanvasImpl-DpssZT6w.js +0 -144
  63. package/dist/EditorCanvasImpl-DpssZT6w.js.map +0 -1
  64. package/dist/FontAnalyzer-CyhywbAM.js.map +0 -1
  65. package/dist/SnowconeCanvas-Bs34CUv5.js.map +0 -1
  66. package/dist/design-builder-CwfefZJC.js.map +0 -1
  67. package/dist/validation-B6sLZULE.js.map +0 -1
@@ -1,16 +1,16 @@
1
- import { p as ee, c as te, u as ze, t as ae, I as Ge, v as Ue, x as Ve, y as Xe } from "./FontAnalyzer-CyhywbAM.js";
2
- import { jsx as v, Fragment as Je, jsxs as _ } from "react/jsx-runtime";
3
- import Qe, { useMemo as Re, useRef as N, useEffect as S, Component as Ye, useState as oe, useCallback as V, useImperativeHandle as Ze, forwardRef as Ce } from "react";
4
- import { a as qe, b as _e, c as et, G as tt, d as rt, Z as nt, g as at, e as ot, D as st, r as it, v as ct, S as lt, K as dt, f as ut } from "./validation-B6sLZULE.js";
5
- import { ImagePanel as ft } from "./ImagePanel-CIGpLY3B.js";
6
- import { C as mt, a as gt } from "./ContextualToolbars-CspkC1T3.js";
7
- import { n as ht, o as pt, E as bt, C as vt, b as he, k as Et } from "./useCommands-wwGeWCn6.js";
8
- import { C as yt, D as xt } from "./template-fields-DF1ijCl9.js";
9
- import { E as wt, b as se, i as It, l as At, j as Ie } from "./design-builder-CwfefZJC.js";
1
+ import { p as ee, c as te, u as ze, t as ae, I as Ge, v as Ue, x as Ve, y as Xe } from "./FontAnalyzer-Ds3Wdba7.js";
2
+ import { jsx as y, Fragment as Je, jsxs as _ } from "react/jsx-runtime";
3
+ import Qe, { useMemo as Re, useRef as N, useEffect as F, Component as Ye, useState as oe, useCallback as V, useImperativeHandle as Ze, forwardRef as Ce } from "react";
4
+ import { a as qe, b as _e, c as et, G as tt, d as rt, Z as nt, g as at, e as ot, D as st, r as it, v as ct, S as lt, K as dt, f as ut } from "./validation-DETfj7tg.js";
5
+ import { ImagePanel as ft } from "./ImagePanel-DhOWKvIN.js";
6
+ import { C as mt, a as gt } from "./ContextualToolbars-rCZo-KCm.js";
7
+ import { n as ht, o as pt, E as bt, C as vt, b as he, k as Et } from "./useCommands-BrkGKdXr.js";
8
+ import { C as yt, D as xt } from "./template-fields-CK7Uvvc8.js";
9
+ import { E as wt, b as se, i as It, l as At, j as Ie } from "./design-builder-DCHVrEFV.js";
10
10
  import { T as Ae } from "./ThemeContext-Rjz25x9X.js";
11
11
  import { c as St } from "./placement-tSiIVhrL.js";
12
- import { a as kt, G as ce, E as Me, H as Ft } from "./ExportManager-BDH9jW4Q.js";
13
- import { C as fe } from "./CanvasRenderer-DIug_mjX.js";
12
+ import { a as kt, G as ce, E as Me, H as Ft } from "./ExportManager-xRsXgyNo.js";
13
+ import { C as fe } from "./CanvasRenderer-B8BADU_r.js";
14
14
  const pe = te("KitLayout"), ne = "canvas", me = 320;
15
15
  let Se = !1;
16
16
  function Rt() {
@@ -36,10 +36,10 @@ function Ct({ children: r }) {
36
36
  ...pt((a) => pe.error("[kit section]", a))
37
37
  };
38
38
  }
39
- return /* @__PURE__ */ v(bt.Provider, { value: n.current, children: r });
39
+ return /* @__PURE__ */ y(bt.Provider, { value: n.current, children: r });
40
40
  }
41
41
  function le({ ids: r }) {
42
- return !r || r.length === 0 ? null : /* @__PURE__ */ v(Ct, { children: r.map((n) => {
42
+ return !r || r.length === 0 ? null : /* @__PURE__ */ y(Ct, { children: r.map((n) => {
43
43
  var t;
44
44
  if (n === ne) return null;
45
45
  const e = at(n);
@@ -48,51 +48,51 @@ function le({ ids: r }) {
48
48
  `Kit layout references unknown section "${n}" — skipping. Register it with registerSection("${n}", { ... }).`
49
49
  ), null;
50
50
  const a = e.component;
51
- return /* @__PURE__ */ v(a, {}, n);
51
+ return /* @__PURE__ */ y(a, {}, n);
52
52
  }) });
53
53
  }
54
54
  function Mt({ kit: r, canvas: n }) {
55
- var b, d, E, y;
55
+ var v, c, w, A;
56
56
  Rt();
57
- const e = r.layout.slots, a = !!((b = e.topbar) != null && b.some((x) => x !== ne)), t = !!((d = e.left) != null && d.some((x) => x !== ne)), o = !!((E = e.right) != null && E.some((x) => x !== ne)), l = !!((y = e.bottombar) != null && y.some((x) => x !== ne)), u = Re(
58
- () => !a && !t && !o && !l,
59
- [a, t, o, l]
60
- ), s = N(null), f = a || t || o || l, h = N(!1);
61
- return S(() => {
62
- var i;
63
- if (typeof ee > "u" || ((i = ee.env) == null ? void 0 : i.NODE_ENV) !== "development" || !f) return;
64
- const x = s.current;
65
- if (!x || typeof ResizeObserver > "u") return;
66
- const $ = (g) => {
67
- g > 0 && g < me && !h.current ? (h.current = !0, pe.warn(
68
- `Kit "${r.name}" declares chrome (toolbar / panels) but its container is only ${Math.round(g)}px wide — below the ~${me}px needed to render it, so the toolbar / panels are suppressed and the editor looks like a bare canvas. Give the editor more container width, or pass kit="embed-only" if a chrome-less canvas is intended.`
69
- )) : g >= me && (h.current = !1);
57
+ const e = r.layout.slots, a = !!((v = e.topbar) != null && v.some((S) => S !== ne)), t = !!((c = e.left) != null && c.some((S) => S !== ne)), o = !!((w = e.right) != null && w.some((S) => S !== ne)), i = !!((A = e.bottombar) != null && A.some((S) => S !== ne)), l = Re(
58
+ () => !a && !t && !o && !i,
59
+ [a, t, o, i]
60
+ ), s = N(null), m = a || t || o || i, h = N(!1);
61
+ return F(() => {
62
+ var u;
63
+ if (typeof ee > "u" || ((u = ee.env) == null ? void 0 : u.NODE_ENV) !== "development" || !m) return;
64
+ const S = s.current;
65
+ if (!S || typeof ResizeObserver > "u") return;
66
+ const $ = (x) => {
67
+ x > 0 && x < me && !h.current ? (h.current = !0, pe.warn(
68
+ `Kit "${r.name}" declares chrome (toolbar / panels) but its container is only ${Math.round(x)}px wide — below the ~${me}px needed to render it, so the toolbar / panels are suppressed and the editor looks like a bare canvas. Give the editor more container width, or pass kit="embed-only" if a chrome-less canvas is intended.`
69
+ )) : x >= me && (h.current = !1);
70
70
  };
71
- $(x.getBoundingClientRect().width);
72
- const M = new ResizeObserver((g) => {
73
- for (const w of g) $(w.contentRect.width);
71
+ $(S.getBoundingClientRect().width);
72
+ const T = new ResizeObserver((x) => {
73
+ for (const d of x) $(d.contentRect.width);
74
74
  });
75
- return M.observe(x), () => M.disconnect();
76
- }, [f, r.name]), u ? /* @__PURE__ */ v(Je, { children: n }) : /* @__PURE__ */ _("div", { ref: s, className: "sc-kit-layout", style: { display: "flex", flexDirection: "column", height: "100%", minHeight: 0 }, children: [
77
- a && /* @__PURE__ */ v(
75
+ return T.observe(S), () => T.disconnect();
76
+ }, [m, r.name]), l ? /* @__PURE__ */ y(Je, { children: n }) : /* @__PURE__ */ _("div", { ref: s, className: "sc-kit-layout", style: { display: "flex", flexDirection: "column", height: "100%", minHeight: 0 }, children: [
77
+ a && /* @__PURE__ */ y(
78
78
  "div",
79
79
  {
80
80
  className: "sc-kit-topbar sc-toolbar",
81
81
  style: { display: "flex", alignItems: "center", gap: 8, flexWrap: "wrap", flexShrink: 0 },
82
- children: /* @__PURE__ */ v(le, { ids: e.topbar })
82
+ children: /* @__PURE__ */ y(le, { ids: e.topbar })
83
83
  }
84
84
  ),
85
85
  /* @__PURE__ */ _("div", { className: "sc-kit-body", style: { display: "flex", flex: 1, minHeight: 0 }, children: [
86
- t && /* @__PURE__ */ v("div", { className: "sc-kit-left", style: { flexShrink: 0, overflow: "auto" }, children: /* @__PURE__ */ v(le, { ids: e.left }) }),
87
- /* @__PURE__ */ v("div", { className: "sc-kit-canvas", style: { flex: 1, minWidth: 0, position: "relative" }, children: n }),
88
- o && /* @__PURE__ */ v("div", { className: "sc-kit-right", style: { flexShrink: 0, overflow: "auto" }, children: /* @__PURE__ */ v(le, { ids: e.right }) })
86
+ t && /* @__PURE__ */ y("div", { className: "sc-kit-left", style: { flexShrink: 0, overflow: "auto" }, children: /* @__PURE__ */ y(le, { ids: e.left }) }),
87
+ /* @__PURE__ */ y("div", { className: "sc-kit-canvas", style: { flex: 1, minWidth: 0, position: "relative" }, children: n }),
88
+ o && /* @__PURE__ */ y("div", { className: "sc-kit-right", style: { flexShrink: 0, overflow: "auto" }, children: /* @__PURE__ */ y(le, { ids: e.right }) })
89
89
  ] }),
90
- l && /* @__PURE__ */ v(
90
+ i && /* @__PURE__ */ y(
91
91
  "div",
92
92
  {
93
93
  className: "sc-kit-bottombar sc-toolbar",
94
94
  style: { display: "flex", alignItems: "center", gap: 8, flexShrink: 0 },
95
- children: /* @__PURE__ */ v(le, { ids: e.bottombar })
95
+ children: /* @__PURE__ */ y(le, { ids: e.bottombar })
96
96
  }
97
97
  )
98
98
  ] });
@@ -140,8 +140,8 @@ class Nt extends Ye {
140
140
  fontFamily: "system-ui, sans-serif"
141
141
  },
142
142
  children: [
143
- /* @__PURE__ */ v("h2", { style: { margin: "0 0 16px 0", fontSize: "18px", fontWeight: 600 }, children: "Something went wrong" }),
144
- /* @__PURE__ */ v(
143
+ /* @__PURE__ */ y("h2", { style: { margin: "0 0 16px 0", fontSize: "18px", fontWeight: 600 }, children: "Something went wrong" }),
144
+ /* @__PURE__ */ y(
145
145
  "pre",
146
146
  {
147
147
  style: {
@@ -156,7 +156,7 @@ class Nt extends Ye {
156
156
  children: this.state.error.message
157
157
  }
158
158
  ),
159
- /* @__PURE__ */ v(
159
+ /* @__PURE__ */ y(
160
160
  "button",
161
161
  {
162
162
  onClick: this.resetError,
@@ -185,83 +185,83 @@ function Lt({
185
185
  viewPadding: a,
186
186
  children: t
187
187
  }) {
188
- const o = n ? /* @__PURE__ */ v(Ae, { defaultTheme: "light", passive: r, children: t }) : /* @__PURE__ */ v(Ae, { defaultTheme: "light", passive: r, children: /* @__PURE__ */ v(wt, { viewPadding: a, children: t }) });
189
- return e ? /* @__PURE__ */ v(vt, { services: e, children: o }) : o;
188
+ const o = n ? /* @__PURE__ */ y(Ae, { defaultTheme: "light", passive: r, children: t }) : /* @__PURE__ */ y(Ae, { defaultTheme: "light", passive: r, children: /* @__PURE__ */ y(wt, { viewPadding: a, children: t }) });
189
+ return e ? /* @__PURE__ */ y(vt, { services: e, children: o }) : o;
190
190
  }
191
191
  const Pt = te("useAutoExport");
192
192
  function $t(r) {
193
- const { config: n, historyManager: e, artboards: a, elements: t, onExport: o, onExportScheduled: l, isCanvasReady: u = !1 } = r, s = N(null), f = N(!1), h = N({
193
+ const { config: n, historyManager: e, artboards: a, elements: t, onExport: o, onExportScheduled: i, isCanvasReady: l = !1 } = r, s = N(null), m = N(!1), h = N({
194
194
  totalExports: 0,
195
195
  skippedExports: 0,
196
196
  lastExportTime: null,
197
197
  avgExportInterval: 0
198
- }), [b, d] = oe(h.current), E = N(o);
199
- E.current = o, S(() => {
200
- const i = new ot({
198
+ }), [v, c] = oe(h.current), w = N(o);
199
+ w.current = o, F(() => {
200
+ const u = new ot({
201
201
  ...st,
202
202
  ...n
203
203
  });
204
- return i.onExport(async () => {
204
+ return u.onExport(async () => {
205
205
  try {
206
- await E.current(), h.current = i.getStats();
207
- } catch (g) {
208
- Pt.error("[useAutoExport] Export failed:", g);
206
+ await w.current(), h.current = u.getStats();
207
+ } catch (x) {
208
+ Pt.error("[useAutoExport] Export failed:", x);
209
209
  }
210
- }), s.current = i, () => {
211
- i.destroy();
210
+ }), s.current = u, () => {
211
+ u.destroy();
212
212
  };
213
- }, []), S(() => {
214
- u && f.current && s.current && (f.current = !1, s.current.forceExport());
215
- }, [u]), S(() => {
213
+ }, []), F(() => {
214
+ l && m.current && s.current && (m.current = !1, s.current.forceExport());
215
+ }, [l]), F(() => {
216
216
  s.current && n && s.current.updateConfig(n);
217
- }, [n == null ? void 0 : n.enabled, n == null ? void 0 : n.debounceMs, n == null ? void 0 : n.maxWaitMs]), S(() => {
218
- s.current && l && s.current.onExportScheduled(l);
219
- }, [l]), S(() => {
217
+ }, [n == null ? void 0 : n.enabled, n == null ? void 0 : n.debounceMs, n == null ? void 0 : n.maxWaitMs]), F(() => {
218
+ s.current && i && s.current.onExportScheduled(i);
219
+ }, [i]), F(() => {
220
220
  if (!e || !s.current)
221
221
  return;
222
- const i = e.onCommandExecuted(() => {
222
+ const u = e.onCommandExecuted(() => {
223
223
  if (s.current) {
224
- if (!u) {
225
- f.current = !0;
224
+ if (!l) {
225
+ m.current = !0;
226
226
  return;
227
227
  }
228
228
  s.current.scheduleExport();
229
229
  }
230
230
  });
231
231
  return () => {
232
- i();
232
+ u();
233
233
  };
234
- }, [e, u]), S(() => {
234
+ }, [e, l]), F(() => {
235
235
  if (s.current) {
236
- if (!u) {
237
- f.current = !0;
236
+ if (!l) {
237
+ m.current = !0;
238
238
  return;
239
239
  }
240
240
  s.current.scheduleExport();
241
241
  }
242
- }, [t, a, u]), S(() => ze((g) => {
243
- if (!s.current || !u) return;
244
- t.some((I) => I.id === g) && s.current.scheduleExport();
245
- }), [t, u]);
246
- const y = V((i) => {
247
- s.current && s.current.updateConfig(i);
248
- }, []), x = V(async () => {
249
- s.current && (await s.current.forceExport(), h.current = s.current.getStats(), d(h.current));
242
+ }, [t, a, l]), F(() => ze((x) => {
243
+ if (!s.current || !l) return;
244
+ t.some((p) => p.id === x) && s.current.scheduleExport();
245
+ }), [t, l]);
246
+ const A = V((u) => {
247
+ s.current && s.current.updateConfig(u);
248
+ }, []), S = V(async () => {
249
+ s.current && (await s.current.forceExport(), h.current = s.current.getStats(), c(h.current));
250
250
  }, []), $ = V(() => {
251
- s.current && (s.current.resetStats(), h.current = s.current.getStats(), d(h.current));
252
- }, []), M = V(() => {
251
+ s.current && (s.current.resetStats(), h.current = s.current.getStats(), c(h.current));
252
+ }, []), T = V(() => {
253
253
  s.current && s.current.resetChangeDetection();
254
254
  }, []);
255
255
  return {
256
- stats: b,
257
- updateConfig: y,
258
- forceExport: x,
256
+ stats: v,
257
+ updateConfig: A,
258
+ forceExport: S,
259
259
  resetStats: $,
260
- resetChangeDetection: M
260
+ resetChangeDetection: T
261
261
  };
262
262
  }
263
263
  const Te = te("useContentReady");
264
- function Dt(r) {
264
+ function Ot(r) {
265
265
  var e;
266
266
  const n = /* @__PURE__ */ new Set();
267
267
  for (const a of r)
@@ -275,7 +275,7 @@ function Dt(r) {
275
275
  }
276
276
  return Array.from(n);
277
277
  }
278
- async function Ot(r) {
278
+ async function Dt(r) {
279
279
  if (r.length === 0 || typeof document > "u" || !document.fonts) return;
280
280
  const n = [];
281
281
  for (const e of r) {
@@ -291,23 +291,23 @@ function Bt() {
291
291
  return new Promise((r) => requestAnimationFrame(() => r()));
292
292
  }
293
293
  function Wt(r) {
294
- const { isCanvasReady: n, elements: e, hasInitialElements: a, initialElementsLoaded: t } = r, [o, l] = oe(!1), u = N(!1);
295
- return S(() => {
296
- if (o || !n || a && !t || a && e.length === 0 || u.current) return;
297
- u.current = !0;
294
+ const { isCanvasReady: n, elements: e, hasInitialElements: a, initialElementsLoaded: t } = r, [o, i] = oe(!1), l = N(!1);
295
+ return F(() => {
296
+ if (o || !n || a && !t || a && e.length === 0 || l.current) return;
297
+ l.current = !0;
298
298
  let s = !1;
299
299
  return (async () => {
300
300
  try {
301
- const f = Dt(e);
302
- if (f.length > 0 && (await Ot(f), s) || (await Bt(), s)) return;
303
- l(!0);
304
- } catch (f) {
305
- Te.error("Error during content readiness check:", f), s || l(!0);
301
+ const m = Ot(e);
302
+ if (m.length > 0 && (await Dt(m), s) || (await Bt(), s)) return;
303
+ i(!0);
304
+ } catch (m) {
305
+ Te.error("Error during content readiness check:", m), s || i(!0);
306
306
  } finally {
307
- u.current = !1;
307
+ l.current = !1;
308
308
  }
309
309
  })(), () => {
310
- s = !0, u.current = !1;
310
+ s = !0, l.current = !1;
311
311
  };
312
312
  }, [n, e, a, t, o]), o;
313
313
  }
@@ -328,7 +328,7 @@ function Ht(r, n) {
328
328
  }), r;
329
329
  }
330
330
  function Kt(r, n, e) {
331
- const a = r.fontSize * n.height, t = (r.letterSpacing ?? 0) * n.height, o = e(r.text, a, r.fontFamily, t), l = n.left + r.left * n.width, u = (r.width ?? 0) * n.width, s = r.align === "center" ? l + u / 2 : r.align === "right" ? l + u - o.advance / 2 : l + o.advance / 2, f = n.top + r.baseline * n.height;
331
+ const a = r.fontSize * n.height, t = (r.letterSpacing ?? 0) * n.height, o = e(r.text, a, r.fontFamily, t), i = n.left + r.left * n.width, l = (r.width ?? 0) * n.width, s = r.align === "center" ? i + l / 2 : r.align === "right" ? i + l - o.advance / 2 : i + o.advance / 2, m = n.top + r.baseline * n.height;
332
332
  return {
333
333
  transformType: "custom",
334
334
  name: r.name ?? r.text,
@@ -340,7 +340,7 @@ function Kt(r, n, e) {
340
340
  ...t !== 0 ? { letterSpacing: t } : {},
341
341
  ...r.stroke ? { stroke: { enabled: !0, color: r.stroke.color, width: r.stroke.width * n.height, lineJoin: "round", lineCap: "round" } } : {},
342
342
  x: s,
343
- y: f - o.ascent + (o.ascent + o.descent) / 2,
343
+ y: m - o.ascent + (o.ascent + o.descent) / 2,
344
344
  rotation: 0,
345
345
  // Room past the measured advance: the editor wraps a line at its box, and measures spaced letters a little
346
346
  // wider when it wraps than when it measures (a spaced "BRIDE SQUAD" broke onto two lines at its exact width).
@@ -360,22 +360,22 @@ function Ne(r) {
360
360
  async function zt(r, n, e) {
361
361
  const a = Date.now();
362
362
  for (; ; ) {
363
- const t = Ne(n.filter((l) => l.visible !== !1)).filter((l) => !l.imageElement || !l.imageLoaded);
363
+ const t = Ne(n.filter((i) => i.visible !== !1)).filter((i) => !i.imageElement || !i.imageLoaded);
364
364
  if (t.length === 0) return;
365
- const o = t.filter((l) => l.imageLoadState === "error");
365
+ const o = t.filter((i) => i.imageLoadState === "error");
366
366
  if (o.length > 0 || Date.now() - a > e) {
367
- const l = (o.length > 0 ? o : t).map((u) => u.id);
367
+ const i = (o.length > 0 ? o : t).map((l) => l.id);
368
368
  throw new ae(
369
369
  "E_PRINT_FILE_FAILED",
370
- `the print file of "${r.name}" needs every picture on it, and ${l.join(", ")} ${o.length > 0 ? "failed to load" : `has not loaded after ${e} ms`}: remove or re-add that picture, then ask again.`,
371
- { artboard: r.name, elements: l, state: o.length > 0 ? "error" : "loading" }
370
+ `the print file of "${r.name}" needs every picture on it, and ${i.join(", ")} ${o.length > 0 ? "failed to load" : `has not loaded after ${e} ms`}: remove or re-add that picture, then ask again.`,
371
+ { artboard: r.name, elements: i, state: o.length > 0 ? "error" : "loading" }
372
372
  );
373
373
  }
374
- await new Promise((l) => setTimeout(l, 100));
374
+ await new Promise((i) => setTimeout(i, 100));
375
375
  }
376
376
  }
377
377
  async function Gt(r, n, e = {}, a = {}) {
378
- var l, u;
378
+ var i, l;
379
379
  const t = r.map((s) => s.name);
380
380
  for (const s of Object.keys(e.regions ?? {}))
381
381
  if (!t.includes(s))
@@ -385,13 +385,13 @@ async function Gt(r, n, e = {}, a = {}) {
385
385
  });
386
386
  const o = {};
387
387
  for (const s of r) {
388
- const f = n(s);
389
- await zt(s, f, a.imageWaitMs ?? jt);
390
- const h = (l = e.regions) == null ? void 0 : l[s.name], b = h ? h.map((d) => ({ key: d.id, region: d })) : [{ key: s.name }];
391
- for (const { key: d, region: E } of b) {
392
- if (d in o)
393
- throw new ae("E_PRINT_FILE_FAILED", `two print files are keyed "${d}": region ids and artboard names must all differ.`, { key: d });
394
- o[d] = await kt.exportPrintFile(s, f, { scale: ((u = e.scale) == null ? void 0 : u[d]) ?? 1, region: E });
388
+ const m = n(s);
389
+ await zt(s, m, a.imageWaitMs ?? jt);
390
+ const h = (i = e.regions) == null ? void 0 : i[s.name], v = h ? h.map((c) => ({ key: c.id, region: c })) : [{ key: s.name }];
391
+ for (const { key: c, region: w } of v) {
392
+ if (c in o)
393
+ throw new ae("E_PRINT_FILE_FAILED", `two print files are keyed "${c}": region ids and artboard names must all differ.`, { key: c });
394
+ o[c] = await kt.exportPrintFile(s, m, { scale: ((l = e.scale) == null ? void 0 : l[c]) ?? 1, region: w });
395
395
  }
396
396
  }
397
397
  return o;
@@ -403,7 +403,7 @@ function ge(r, n, e, a) {
403
403
  const t = r * e, o = n * e;
404
404
  if (Math.max(t, o) <= a)
405
405
  return e;
406
- const u = Math.max(r, n), s = a / u;
406
+ const l = Math.max(r, n), s = a / l;
407
407
  return Math.min(s, e);
408
408
  }
409
409
  function Ut(r) {
@@ -413,7 +413,7 @@ function Ut(r) {
413
413
  var o;
414
414
  Q.error(`[${t.category}] ${t.message}`, t.originalError), (o = n.current) == null || o.call(n, t);
415
415
  }, []);
416
- S(() => (fe.onRenderError = e, () => {
416
+ F(() => (fe.onRenderError = e, () => {
417
417
  fe.onRenderError === e && (fe.onRenderError = null);
418
418
  }), [e]);
419
419
  const a = V((t) => {
@@ -433,151 +433,164 @@ function Vt(r) {
433
433
  height: a,
434
434
  pieceGuides: t,
435
435
  controlledActiveArtboard: o,
436
- onArtboardChange: l,
437
- resetDocumentOnMount: u
436
+ onArtboardChange: i,
437
+ resetDocumentOnMount: l
438
438
  } = r, {
439
439
  setElements: s,
440
- setSelectedId: f,
440
+ setSelectedId: m,
441
441
  setMultiSelection: h,
442
- artboardManager: b,
443
- refreshArtboards: d
444
- } = se(), { createArtboard: E, selectArtboard: y, artboards: x } = he(), $ = N(!1), M = N(!1);
445
- S(() => {
442
+ artboardManager: v,
443
+ refreshArtboards: c
444
+ } = se(), { createArtboard: w, selectArtboard: A, artboards: S } = he(), $ = N(!1), T = N(!1);
445
+ F(() => {
446
446
  if ($.current) return;
447
447
  $.current = !0;
448
- const i = n || [{ name: "Design", width: e, height: a }], g = t ? "transparent" : void 0, w = (c) => c.exportBackground ?? (!!c.backgroundColor && c.backgroundColor !== "transparent"), I = () => {
449
- for (const c of b.getAllArtboards())
450
- c.imageFit = It(i.find((m) => m.name === c.name));
448
+ const d = n || [{ name: "Design", width: e, height: a }], p = t ? "transparent" : void 0, b = (E) => E.exportBackground ?? (!!E.backgroundColor && E.backgroundColor !== "transparent"), g = () => {
449
+ for (const E of v.getAllArtboards()) {
450
+ const f = d.find((I) => I.name === E.name);
451
+ E.imageFit = It(f), E.engrave = f != null && f.engrave ? { ...f.engrave } : void 0;
452
+ }
451
453
  };
452
- if (u) {
453
- b.clear(), s([]), f(null), h([]);
454
- for (const m of i)
455
- b.createArtboard({
456
- name: m.name,
457
- width: m.width,
458
- height: m.height,
459
- backgroundColor: m.backgroundColor ?? g,
460
- exportBackground: w(m),
461
- clipShape: m.clipShape,
462
- role: m.role
454
+ if (l) {
455
+ v.clear(), s([]), m(null), h([]);
456
+ for (const f of d)
457
+ v.createArtboard({
458
+ name: f.name,
459
+ width: f.width,
460
+ height: f.height,
461
+ backgroundColor: f.backgroundColor ?? p,
462
+ exportBackground: b(f),
463
+ clipShape: f.clipShape,
464
+ role: f.role
463
465
  });
464
- const c = b.getAllArtboards();
465
- c.length > 0 && !o && b.setActiveArtboard(c[0].id), I(), d();
466
+ const E = v.getAllArtboards();
467
+ E.length > 0 && !o && v.setActiveArtboard(E[0].id), g(), c();
466
468
  return;
467
469
  }
468
- const p = b.getAllArtboards();
469
- if (p.length > 0) {
470
- const c = i[0], m = p[0];
471
- m.name = c.name, m.width = c.width, m.height = c.height, m.clipShape = c.clipShape, m.exportBackground = w(c), m.role = c.role, c.backgroundColor ? m.backgroundColor = c.backgroundColor : g && (m.backgroundColor = g);
472
- for (let A = 1; A < i.length; A++)
473
- E(i[A].width, i[A].height, {
474
- name: i[A].name,
475
- backgroundColor: i[A].backgroundColor ?? g,
476
- exportBackground: w(i[A]),
477
- clipShape: i[A].clipShape,
478
- role: i[A].role
470
+ const k = v.getAllArtboards();
471
+ if (k.length > 0) {
472
+ const E = d[0], f = k[0];
473
+ f.name = E.name, f.width = E.width, f.height = E.height, f.clipShape = E.clipShape, f.exportBackground = b(E), f.role = E.role, E.backgroundColor ? f.backgroundColor = E.backgroundColor : p && (f.backgroundColor = p);
474
+ for (let I = 1; I < d.length; I++)
475
+ w(d[I].width, d[I].height, {
476
+ name: d[I].name,
477
+ backgroundColor: d[I].backgroundColor ?? p,
478
+ exportBackground: b(d[I]),
479
+ clipShape: d[I].clipShape,
480
+ role: d[I].role
479
481
  });
480
- !o && i.length > 1 && b.setActiveArtboard(m.id);
482
+ !o && d.length > 1 && v.setActiveArtboard(f.id);
481
483
  }
482
- I(), d();
483
- }, []), S(() => {
484
+ g(), c();
485
+ }, []);
486
+ const u = JSON.stringify((n ?? []).map((d) => [d.name, d.engrave ?? null])), x = N(u);
487
+ F(() => {
488
+ if (x.current !== u) {
489
+ x.current = u;
490
+ for (const d of v.getAllArtboards()) {
491
+ const p = (n ?? []).find((b) => b.name === d.name);
492
+ d.engrave = p != null && p.engrave ? { ...p.engrave } : void 0;
493
+ }
494
+ c();
495
+ }
496
+ }, [u]), F(() => {
484
497
  if (!o) {
485
- M.current = !0;
498
+ T.current = !0;
486
499
  return;
487
500
  }
488
- const i = x.find((g) => g.name === o);
489
- if (i) {
490
- const g = b.getActiveArtboard();
491
- (g == null ? void 0 : g.name) !== o && y(i.id), M.current = !0;
501
+ const d = S.find((p) => p.name === o);
502
+ if (d) {
503
+ const p = v.getActiveArtboard();
504
+ (p == null ? void 0 : p.name) !== o && A(d.id), T.current = !0;
492
505
  }
493
- }, [o, x]), S(() => {
494
- if (!l || !M.current) return;
495
- const i = b.getActiveArtboard();
496
- i && l(i.name);
497
- }, [b.getActiveArtboardId()]);
506
+ }, [o, S]), F(() => {
507
+ if (!i || !T.current) return;
508
+ const d = v.getActiveArtboard();
509
+ d && i(d.name);
510
+ }, [v.getActiveArtboardId()]);
498
511
  }
499
512
  function Xt(r) {
500
- const { initialElements: n, emitError: e, customFonts: a } = r, { setElements: t, artboardManager: o } = se(), l = N(!1), [u, s] = oe(!1), f = N(!0);
501
- return S(() => (f.current = !0, () => {
502
- f.current = !1;
503
- }), []), S(() => {
504
- if (!(!n || n.length === 0) && !l.current) {
505
- l.current = !0, s(!0);
513
+ const { initialElements: n, emitError: e, customFonts: a } = r, { setElements: t, artboardManager: o } = se(), i = N(!1), [l, s] = oe(!1), m = N(!0);
514
+ return F(() => (m.current = !0, () => {
515
+ m.current = !1;
516
+ }), []), F(() => {
517
+ if (!(!n || n.length === 0) && !i.current) {
518
+ i.current = !0, s(!0);
506
519
  try {
507
520
  a && a.length > 0 && ce.register(a);
508
- const h = Me.createManyFromJSON(n), b = o.getAllArtboards();
509
- if (b.length > 0) {
510
- const E = new Map(b.map((y) => [y.name, y]));
511
- h.forEach((y, x) => {
512
- var i;
513
- const $ = (i = n[x]) == null ? void 0 : i.artboard, M = $ && E.get($) || b[0];
514
- o.addElementToArtboard(y.id, M.id);
521
+ const h = Me.createManyFromJSON(n), v = o.getAllArtboards();
522
+ if (v.length > 0) {
523
+ const w = new Map(v.map((A) => [A.name, A]));
524
+ h.forEach((A, S) => {
525
+ var u;
526
+ const $ = (u = n[S]) == null ? void 0 : u.artboard, T = $ && w.get($) || v[0];
527
+ o.addElementToArtboard(A.id, T.id);
515
528
  });
516
529
  }
517
530
  t(h);
518
- const d = /* @__PURE__ */ new Set();
519
- for (const E of h) {
520
- const y = E.fontFamily;
521
- typeof y == "string" && y.trim().length > 0 && d.add(y);
531
+ const c = /* @__PURE__ */ new Set();
532
+ for (const w of h) {
533
+ const A = w.fontFamily;
534
+ typeof A == "string" && A.trim().length > 0 && c.add(A);
522
535
  }
523
- if (d.size > 0 && typeof document < "u") {
524
- const E = document.fonts ?? null, y = Array.from(d).filter(
525
- (i) => ce.has(i)
526
- ), x = Ft(
527
- ce.forFamilies(y),
536
+ if (c.size > 0 && typeof document < "u") {
537
+ const w = document.fonts ?? null, A = Array.from(c).filter(
538
+ (u) => ce.has(u)
539
+ ), S = Ft(
540
+ ce.forFamilies(A),
528
541
  {
529
- onLoadError: (i) => {
530
- f.current && e({
542
+ onLoadError: (u) => {
543
+ m.current && e({
531
544
  category: "import",
532
- message: i.message,
533
- originalError: i,
545
+ message: u.message,
546
+ originalError: u,
534
547
  recoverable: !0
535
548
  });
536
549
  }
537
550
  }
538
- ), M = Array.from(d).filter(
539
- (i) => !ce.has(i)
540
- ).map((i) => {
541
- const g = `font-${i.replace(/\s+/g, "-").toLowerCase()}`;
542
- let w = document.getElementById(g);
543
- return w || (w = document.createElement("link"), w.id = g, w.rel = "stylesheet", w.href = `https://fonts.googleapis.com/css2?family=${i.replace(
551
+ ), T = Array.from(c).filter(
552
+ (u) => !ce.has(u)
553
+ ).map((u) => {
554
+ const x = `font-${u.replace(/\s+/g, "-").toLowerCase()}`;
555
+ let d = document.getElementById(x);
556
+ return d || (d = document.createElement("link"), d.id = x, d.rel = "stylesheet", d.href = `https://fonts.googleapis.com/css2?family=${u.replace(
544
557
  /\s+/g,
545
558
  "+"
546
- )}:wght@400;700&display=swap`, document.head.appendChild(w)), new Promise((I) => {
547
- if (w.sheet) {
548
- I(i);
559
+ )}:wght@400;700&display=swap`, document.head.appendChild(d)), new Promise((p) => {
560
+ if (d.sheet) {
561
+ p(u);
549
562
  return;
550
563
  }
551
- const p = () => I(i);
552
- w.addEventListener("load", p, { once: !0 }), w.addEventListener("error", p, { once: !0 }), setTimeout(p, 4e3);
564
+ const b = () => p(u);
565
+ d.addEventListener("load", b, { once: !0 }), d.addEventListener("error", b, { once: !0 }), setTimeout(b, 4e3);
553
566
  });
554
567
  });
555
- Promise.all([Promise.all(M), x]).then(([i]) => {
556
- if (!(!f.current || !E))
568
+ Promise.all([Promise.all(T), S]).then(([u]) => {
569
+ if (!(!m.current || !w))
557
570
  return Promise.all(
558
- i.flatMap((g) => [
559
- E.load(`400 16px "${g}"`).catch(() => {
571
+ u.flatMap((x) => [
572
+ w.load(`400 16px "${x}"`).catch(() => {
560
573
  }),
561
- E.load(`700 16px "${g}"`).catch(() => {
574
+ w.load(`700 16px "${x}"`).catch(() => {
562
575
  })
563
576
  ])
564
577
  );
565
578
  }).then(() => {
566
- f.current && t((i) => i.slice());
579
+ m.current && t((u) => u.slice());
567
580
  });
568
581
  }
569
582
  } catch (h) {
570
583
  Q.error("Failed to load initial elements:", h);
571
- const b = h instanceof Error ? h : new Error(String(h));
584
+ const v = h instanceof Error ? h : new Error(String(h));
572
585
  e({
573
586
  category: "import",
574
- message: `Failed to load initial elements: ${b.message}`,
575
- originalError: b,
587
+ message: `Failed to load initial elements: ${v.message}`,
588
+ originalError: v,
576
589
  recoverable: !0
577
590
  });
578
591
  }
579
592
  }
580
- }, [n, o, t, e, a]), { initialElementsLoadedState: u };
593
+ }, [n, o, t, e, a]), { initialElementsLoadedState: l };
581
594
  }
582
595
  function Jt(r) {
583
596
  const {
@@ -586,151 +599,151 @@ function Jt(r) {
586
599
  initialImageAlignment: a,
587
600
  initialImageScale: t,
588
601
  initialImageScaleMode: o,
589
- initialImageRole: l,
590
- artboardConfigs: u,
602
+ initialImageRole: i,
603
+ artboardConfigs: l,
591
604
  onImageLoad: s,
592
- onImageError: f,
605
+ onImageError: m,
593
606
  emitError: h
594
- } = r, { elements: b, setElements: d, artboardManager: E } = se(), [y, x] = oe("idle"), [$, M] = oe(null), i = N(void 0);
595
- return S(() => {
596
- if (!n || i.current === n) return;
597
- if (b.length > 0) {
598
- i.current = n;
607
+ } = r, { elements: v, setElements: c, artboardManager: w } = se(), [A, S] = oe("idle"), [$, T] = oe(null), u = N(void 0);
608
+ return F(() => {
609
+ if (!n || u.current === n) return;
610
+ if (v.length > 0) {
611
+ u.current = n;
599
612
  return;
600
613
  }
601
- i.current = n, (async () => {
602
- x("loading"), M(null);
614
+ u.current = n, (async () => {
615
+ S("loading"), T(null);
603
616
  try {
604
- const w = E.getAllArtboards();
605
- if (w.length === 0)
617
+ const d = w.getAllArtboards();
618
+ if (d.length === 0)
606
619
  throw new Error("No artboards available");
607
- const I = [];
608
- for (const p of w) {
609
- const c = u == null ? void 0 : u.find((T) => T.name === p.name), m = (c == null ? void 0 : c.scaleMode) || o, A = (c == null ? void 0 : c.imageRegions) ?? [];
610
- if (A.length > 0) {
611
- const T = await At(n);
612
- if (!T.success || !T.width || !T.height) {
613
- Q.error("Failed to load image for artboard:", p.name, T.error);
620
+ const p = [];
621
+ for (const b of d) {
622
+ const g = l == null ? void 0 : l.find((I) => I.name === b.name), k = (g == null ? void 0 : g.scaleMode) || o, E = (g == null ? void 0 : g.imageRegions) ?? [];
623
+ if (E.length > 0) {
624
+ const I = await At(n);
625
+ if (!I.success || !I.width || !I.height) {
626
+ Q.error("Failed to load image for artboard:", b.name, I.error);
614
627
  continue;
615
628
  }
616
- for (const W of A) {
617
- const L = St(T.width / T.height, W), H = await Ie(
629
+ for (const W of E) {
630
+ const L = St(I.width / I.height, W), H = await Ie(
618
631
  n,
619
632
  {
620
- artboard: { width: L.width, height: L.height, x: p.x + L.centerX - L.width / 2, y: p.y + L.centerY - L.height / 2 },
633
+ artboard: { width: L.width, height: L.height, x: b.x + L.centerX - L.width / 2, y: b.y + L.centerY - L.height / 2 },
621
634
  alignment: "center",
622
635
  scale: 1,
623
636
  scaleMode: "cover"
624
637
  },
625
638
  { transformData: { type: "image", width: L.width, height: L.height, cropX: L.cropX, cropY: L.cropY, cropWidth: L.cropWidth, cropHeight: L.cropHeight } }
626
639
  );
627
- H.success && H.element ? (E.addElementToArtboard(H.element.id, p.id), I.push(H.element)) : Q.error("Failed to load image for a panel of artboard:", p.name, H.error);
640
+ H.success && H.element ? (w.addElementToArtboard(H.element.id, b.id), p.push(H.element)) : Q.error("Failed to load image for a panel of artboard:", b.name, H.error);
628
641
  }
629
642
  continue;
630
643
  }
631
- const k = await Ie(
644
+ const f = await Ie(
632
645
  n,
633
646
  {
634
647
  artboard: {
635
- width: p.width,
636
- height: p.height,
637
- x: p.x,
638
- y: p.y
648
+ width: b.width,
649
+ height: b.height,
650
+ x: b.x,
651
+ y: b.y
639
652
  },
640
- alignment: (c == null ? void 0 : c.fitAlign) || a,
653
+ alignment: (g == null ? void 0 : g.fitAlign) || a,
641
654
  scale: t,
642
- scaleMode: m,
643
- marginTop: c == null ? void 0 : c.fitMarginTop,
644
- marginRight: c == null ? void 0 : c.fitMarginRight,
645
- marginBottom: c == null ? void 0 : c.fitMarginBottom,
646
- marginLeft: c == null ? void 0 : c.fitMarginLeft
655
+ scaleMode: k,
656
+ marginTop: g == null ? void 0 : g.fitMarginTop,
657
+ marginRight: g == null ? void 0 : g.fitMarginRight,
658
+ marginBottom: g == null ? void 0 : g.fitMarginBottom,
659
+ marginLeft: g == null ? void 0 : g.fitMarginLeft
647
660
  }
648
661
  );
649
- k.success && k.element ? (E.addElementToArtboard(k.element.id, p.id), I.push(k.element)) : Q.error("Failed to load image for artboard:", p.name, k.error);
662
+ f.success && f.element ? (w.addElementToArtboard(f.element.id, b.id), p.push(f.element)) : Q.error("Failed to load image for artboard:", b.name, f.error);
650
663
  }
651
- if (e.length > 0 && I.length > 0) {
652
- const p = await Zt(Array.from(new Set(e.map((m) => m.fontFamily))));
653
- for (const m of p)
664
+ if (e.length > 0 && p.length > 0) {
665
+ const b = await Zt(Array.from(new Set(e.map((k) => k.fontFamily))));
666
+ for (const k of b)
654
667
  h({
655
668
  category: "import",
656
- message: `E_FONT_LOAD_FAILED: the font "${m}" for initialImageText could not be loaded; its words are drawn in a fallback font until it loads.`,
669
+ message: `E_FONT_LOAD_FAILED: the font "${k}" for initialImageText could not be loaded; its words are drawn in a fallback font until it loads.`,
657
670
  recoverable: !0
658
671
  });
659
- const c = (m, A, k, T) => {
660
- const W = Ue(A, k);
661
- return { advance: Ve(m, A, k, !1, !1, T), ascent: W.ascent, descent: W.descent };
672
+ const g = (k, E, f, I) => {
673
+ const W = Ue(E, f);
674
+ return { advance: Ve(k, E, f, !1, !1, I), ascent: W.ascent, descent: W.descent };
662
675
  };
663
- for (const m of I.slice()) {
664
- const A = E.getArtboardForElement(m.id), k = m.transformData, T = (k == null ? void 0 : k.width) ?? 0, W = (k == null ? void 0 : k.height) ?? 0;
665
- if (!A || !(T > 0) || !(W > 0)) continue;
666
- const L = { left: m.x - T / 2, top: m.y - W / 2, width: T, height: W };
676
+ for (const k of p.slice()) {
677
+ const E = w.getArtboardForElement(k.id), f = k.transformData, I = (f == null ? void 0 : f.width) ?? 0, W = (f == null ? void 0 : f.height) ?? 0;
678
+ if (!E || !(I > 0) || !(W > 0)) continue;
679
+ const L = { left: k.x - I / 2, top: k.y - W / 2, width: I, height: W };
667
680
  for (const H of e) {
668
- const Y = Me.createFromJSON(Kt(H, L, c));
669
- E.addElementToArtboard(Y.id, A.id), I.push(Y);
681
+ const Y = Me.createFromJSON(Kt(H, L, g));
682
+ w.addElementToArtboard(Y.id, E.id), p.push(Y);
670
683
  }
671
684
  }
672
685
  }
673
- if (I.length > 0)
674
- l === "placeholder" && E.markPlaceholders(I.map((p) => p.id)), d((p) => [...p, ...I]), x("success"), s == null || s(n);
686
+ if (p.length > 0)
687
+ i === "placeholder" && w.markPlaceholders(p.map((b) => b.id)), c((b) => [...b, ...p]), S("success"), s == null || s(n);
675
688
  else {
676
- const p = new Error("Failed to load image into any artboard");
677
- x("error"), M(p), f == null || f(n, p), h({
689
+ const b = new Error("Failed to load image into any artboard");
690
+ S("error"), T(b), m == null || m(n, b), h({
678
691
  category: "image",
679
- message: p.message,
680
- originalError: p,
692
+ message: b.message,
693
+ originalError: b,
681
694
  recoverable: !0
682
695
  });
683
696
  }
684
- } catch (w) {
685
- const I = w instanceof Error ? w : new Error(String(w));
686
- x("error"), M(I), f == null || f(n, I), h({
697
+ } catch (d) {
698
+ const p = d instanceof Error ? d : new Error(String(d));
699
+ S("error"), T(p), m == null || m(n, p), h({
687
700
  category: "image",
688
- message: I.message,
689
- originalError: I,
701
+ message: p.message,
702
+ originalError: p,
690
703
  recoverable: !0
691
704
  });
692
705
  }
693
706
  })();
694
- }, [n, e, a, t, o, l]), { imageLoadingState: y, imageError: $ };
707
+ }, [n, e, a, t, o, i]), { imageLoadingState: A, imageError: $ };
695
708
  }
696
709
  function Qt(r) {
697
- const { onChange: n, onSelectionChange: e } = r, { elements: a, selectedId: t, artboardManager: o } = se(), { artboards: l } = he(), u = N(e);
698
- u.current = e, S(() => {
699
- var f;
700
- (f = u.current) == null || f.call(u, t);
710
+ const { onChange: n, onSelectionChange: e } = r, { elements: a, selectedId: t, artboardManager: o } = se(), { artboards: i } = he(), l = N(e);
711
+ l.current = e, F(() => {
712
+ var m;
713
+ (m = l.current) == null || m.call(l, t);
701
714
  }, [t]);
702
715
  const s = N(n);
703
- s.current = n, S(() => {
704
- const f = s.current;
705
- if (!f) return;
706
- const h = o.getActiveArtboard(), b = {
716
+ s.current = n, F(() => {
717
+ const m = s.current;
718
+ if (!m) return;
719
+ const h = o.getActiveArtboard(), v = {
707
720
  // Stamp each element with the NAME of the artboard it lives on (the
708
721
  // manager is the membership source of truth). Without this the public
709
722
  // state is flat and a multi-placement design cannot round-trip: restore
710
723
  // collapses everything onto the first artboard, and per-placement render
711
724
  // states can't be derived from onChange. Pinned by
712
725
  // SnowconeCanvas.artboard-membership.test.tsx.
713
- elements: a.map((d) => {
714
- const E = d.toJSON(), y = o.getArtboardForElement(d.id);
715
- return y ? { ...E, artboard: y.name } : E;
726
+ elements: a.map((c) => {
727
+ const w = c.toJSON(), A = o.getArtboardForElement(c.id);
728
+ return A ? { ...w, artboard: A.name } : w;
716
729
  }),
717
- artboards: l.map((d) => ({
718
- name: d.name,
719
- width: d.width,
720
- height: d.height,
721
- clipShape: d.clipShape,
722
- backgroundColor: d.backgroundColor,
730
+ artboards: i.map((c) => ({
731
+ name: c.name,
732
+ width: c.width,
733
+ height: c.height,
734
+ clipShape: c.clipShape,
735
+ backgroundColor: c.backgroundColor,
723
736
  // Carried so serializeStateForServer / saved states keep an
724
737
  // explicitly-set background renderable (mockup matches editor).
725
- exportBackground: d.exportBackground,
738
+ exportBackground: c.exportBackground,
726
739
  // Pacing role for multi-page templates (ADR-0086) — emitted only when
727
740
  // set so non-template states stay byte-identical.
728
- ...d.role ? { role: d.role } : {}
741
+ ...c.role ? { role: c.role } : {}
729
742
  })),
730
743
  activeArtboard: (h == null ? void 0 : h.name) || "Design"
731
744
  };
732
- f(b);
733
- }, [a, l]);
745
+ m(v);
746
+ }, [a, i]);
734
747
  }
735
748
  function Yt(r, n) {
736
749
  const {
@@ -738,163 +751,163 @@ function Yt(r, n) {
738
751
  autoExportConfig: a,
739
752
  autoExportFormat: t,
740
753
  autoExportAll: o,
741
- exportScale: l,
742
- maxExportSize: u,
754
+ exportScale: i,
755
+ maxExportSize: l,
743
756
  exportImageFormat: s,
744
- exportImageQuality: f,
757
+ exportImageQuality: m,
745
758
  onExport: h,
746
- onExportScheduled: b,
747
- onExportStatus: d,
748
- onExportReady: E,
749
- onReady: y,
750
- hasInitialElements: x,
759
+ onExportScheduled: v,
760
+ onExportStatus: c,
761
+ onExportReady: w,
762
+ onReady: A,
763
+ hasInitialElements: S,
751
764
  initialElementsLoaded: $,
752
- emitError: M
765
+ emitError: T
753
766
  } = r, {
754
- elements: i,
755
- artboardManager: g,
756
- historyManager: w,
757
- isCanvasReady: I,
758
- setCanvasReady: p
759
- } = se(), { artboards: c } = he(), { exportArtboard: m, exportAllArtboards: A, exportArtboardAsBlob: k, exportAllArtboardsAsBlobs: T } = Et(), W = N(0), L = N(0), H = N(i);
760
- H.current = i, Ze(n, () => ({
761
- exportArtboards: async (D = {}) => {
762
- const P = D.format || t, B = D.scale || l, K = D.all ?? !1;
767
+ elements: u,
768
+ artboardManager: x,
769
+ historyManager: d,
770
+ isCanvasReady: p,
771
+ setCanvasReady: b
772
+ } = se(), { artboards: g } = he(), { exportArtboard: k, exportAllArtboards: E, exportArtboardAsBlob: f, exportAllArtboardsAsBlobs: I } = Et(), W = N(0), L = N(0), H = N(u);
773
+ H.current = u, Ze(n, () => ({
774
+ exportArtboards: async (O = {}) => {
775
+ const P = O.format || t, B = O.scale || i, K = O.all ?? !1;
763
776
  let j = B;
764
- if (u > 0 && isFinite(u))
765
- for (const C of c) {
766
- const R = ge(C.width, C.height, B, u);
767
- j = Math.min(j, R);
777
+ if (l > 0 && isFinite(l))
778
+ for (const M of g) {
779
+ const C = ge(M.width, M.height, B, l);
780
+ j = Math.min(j, C);
768
781
  }
769
- const F = { scale: j, format: s, quality: f };
782
+ const R = { scale: j, format: s, quality: m };
770
783
  if (K) {
771
- const C = P === "blob" ? await T(F) : await A(F), R = {};
772
- for (const [O, X] of Object.entries(C)) {
773
- const z = c.find((J) => J.id === O);
774
- z && (R[z.name] = X);
784
+ const M = P === "blob" ? await I(R) : await E(R), C = {};
785
+ for (const [D, X] of Object.entries(M)) {
786
+ const z = g.find((J) => J.id === D);
787
+ z && (C[z.name] = X);
775
788
  }
776
- return R;
789
+ return C;
777
790
  } else {
778
- const C = g.getActiveArtboard();
779
- if (!C)
791
+ const M = x.getActiveArtboard();
792
+ if (!M)
780
793
  throw new Error("[SnowconeCanvas] No active artboard found");
781
794
  if (P === "blob") {
782
- const R = await k(C.id, F);
783
- return { [C.name]: R };
795
+ const C = await f(M.id, R);
796
+ return { [M.name]: C };
784
797
  } else {
785
- const R = await m(C.id, F);
786
- return { [C.name]: R };
798
+ const C = await k(M.id, R);
799
+ return { [M.name]: C };
787
800
  }
788
801
  }
789
802
  },
790
803
  // Print files: every artboard (or its regions), lossless PNG, full size, original picture pixels, one at a time.
791
804
  // Never the auto-export's format / maxExportSize: those keep the live preview light, a print file is the product.
792
- exportPrintFiles: (D = {}) => Gt(
793
- c,
805
+ exportPrintFiles: (O = {}) => Gt(
806
+ g,
794
807
  (P) => {
795
- const B = new Set(g.getElementsOnArtboard(P.id));
808
+ const B = new Set(x.getElementsOnArtboard(P.id));
796
809
  return H.current.filter((K) => B.has(K.id));
797
810
  },
798
- D
811
+ O
799
812
  )
800
- }), [m, A, k, T, t, l, u, s, f, g, c]), S(() => {
801
- E && E(async () => {
802
- const P = g.getActiveArtboard();
813
+ }), [k, E, f, I, t, i, l, s, m, x, g]), F(() => {
814
+ w && w(async () => {
815
+ const P = x.getActiveArtboard();
803
816
  if (!P)
804
817
  throw new Error("[SnowconeCanvas] No active artboard found");
805
818
  const B = ge(
806
819
  P.width,
807
820
  P.height,
808
- l,
809
- u
810
- ), K = t === "blob" ? await k(P.id, { scale: B }) : await m(P.id, { scale: B });
821
+ i,
822
+ l
823
+ ), K = t === "blob" ? await f(P.id, { scale: B }) : await k(P.id, { scale: B });
811
824
  return { [P.name]: K };
812
825
  });
813
- }, [E, m, k, g, t, l, u]);
826
+ }, [w, k, f, x, t, i, l]);
814
827
  const Y = V(async () => {
815
- if (!h && !d) return;
816
- const D = ++L.current, P = Date.now();
817
- let B = l;
818
- if (u > 0 && isFinite(u))
819
- for (const F of c) {
820
- const C = ge(F.width, F.height, l, u);
821
- B = Math.min(B, C);
828
+ if (!h && !c) return;
829
+ const O = ++L.current, P = Date.now();
830
+ let B = i;
831
+ if (l > 0 && isFinite(l))
832
+ for (const R of g) {
833
+ const M = ge(R.width, R.height, i, l);
834
+ B = Math.min(B, M);
822
835
  }
823
- const K = g.getActiveArtboard(), j = (K == null ? void 0 : K.id) ?? "unknown";
824
- d == null || d({ status: "rendering", artboardId: j }), W.current = P;
836
+ const K = x.getActiveArtboard(), j = (K == null ? void 0 : K.id) ?? "unknown";
837
+ c == null || c({ status: "rendering", artboardId: j }), W.current = P;
825
838
  try {
826
- let F;
827
- const C = {
839
+ let R;
840
+ const M = {
828
841
  format: s,
829
842
  scale: B,
830
- quality: f
843
+ quality: m
831
844
  };
832
845
  if (t === "blob")
833
846
  if (o) {
834
- const R = await T(C);
835
- F = {};
836
- for (const [O, X] of Object.entries(R)) {
837
- const z = c.find((J) => J.id === O);
838
- z && (F[z.name] = X);
847
+ const C = await I(M);
848
+ R = {};
849
+ for (const [D, X] of Object.entries(C)) {
850
+ const z = g.find((J) => J.id === D);
851
+ z && (R[z.name] = X);
839
852
  }
840
853
  } else {
841
- const R = g.getActiveArtboard();
842
- if (!R) return;
843
- const O = await k(R.id, C);
844
- F = { [R.name]: O };
854
+ const C = x.getActiveArtboard();
855
+ if (!C) return;
856
+ const D = await f(C.id, M);
857
+ R = { [C.name]: D };
845
858
  }
846
859
  else if (o) {
847
- const R = await A(C);
848
- F = {};
849
- for (const [O, X] of Object.entries(R)) {
850
- const z = c.find((J) => J.id === O);
851
- z && (F[z.name] = X);
860
+ const C = await E(M);
861
+ R = {};
862
+ for (const [D, X] of Object.entries(C)) {
863
+ const z = g.find((J) => J.id === D);
864
+ z && (R[z.name] = X);
852
865
  }
853
866
  } else {
854
- const R = g.getActiveArtboard();
855
- if (!R) return;
856
- const O = await m(R.id, C);
857
- F = { [R.name]: O };
867
+ const C = x.getActiveArtboard();
868
+ if (!C) return;
869
+ const D = await k(C.id, M);
870
+ R = { [C.name]: D };
858
871
  }
859
- h == null || h(F), d == null || d({ status: "complete", artboardId: j, result: F });
860
- } catch (F) {
861
- const C = F instanceof Error ? F.message : String(F);
862
- if (C.includes("Canvas ref not available"))
872
+ h == null || h(R), c == null || c({ status: "complete", artboardId: j, result: R });
873
+ } catch (R) {
874
+ const M = R instanceof Error ? R.message : String(R);
875
+ if (M.includes("Canvas ref not available"))
863
876
  return;
864
- const R = Date.now() - P;
865
- Q.error("Export failed (export #" + D + "):", {
866
- duration: `${R}ms`,
867
- error: C
877
+ const C = Date.now() - P;
878
+ Q.error("Export failed (export #" + O + "):", {
879
+ duration: `${C}ms`,
880
+ error: M
868
881
  });
869
- const O = F instanceof Error ? F : new Error(C);
870
- d == null || d({ status: "error", artboardId: j, error: O }), M({
882
+ const D = R instanceof Error ? R : new Error(M);
883
+ c == null || c({ status: "error", artboardId: j, error: D }), T({
871
884
  category: "export",
872
- message: O.message,
873
- originalError: O,
885
+ message: D.message,
886
+ originalError: D,
874
887
  artboardId: j,
875
888
  recoverable: !0
876
889
  });
877
890
  }
878
- }, [h, d, o, t, l, u, s, f, m, A, k, T, c, g, i, a, M]);
879
- S(() => {
891
+ }, [h, c, o, t, i, l, s, m, k, E, f, I, g, x, u, a, T]);
892
+ F(() => {
880
893
  e !== void 0 && e > 0 && Q.warn(
881
894
  "autoExportInterval is deprecated and ignored. Use autoExportConfig={{ enabled: true, debounceMs: 100, maxWaitMs: 1000 }} instead."
882
895
  );
883
896
  }, []);
884
897
  const de = V(() => {
885
- if (b == null || b(), d) {
886
- const D = g.getActiveArtboard();
887
- d({ status: "scheduled", artboardId: (D == null ? void 0 : D.id) ?? "unknown" });
898
+ if (v == null || v(), c) {
899
+ const O = x.getActiveArtboard();
900
+ c({ status: "scheduled", artboardId: (O == null ? void 0 : O.id) ?? "unknown" });
888
901
  }
889
- }, [b, d, g]), re = Wt({
890
- isCanvasReady: I,
891
- elements: i,
892
- hasInitialElements: x,
902
+ }, [v, c, x]), re = Wt({
903
+ isCanvasReady: p,
904
+ elements: u,
905
+ hasInitialElements: S,
893
906
  initialElementsLoaded: $
894
907
  }), ie = N(!1);
895
- S(() => {
896
- re && !ie.current && (ie.current = !0, y == null || y());
897
- }, [re, y]), $t({
908
+ F(() => {
909
+ re && !ie.current && (ie.current = !0, A == null || A());
910
+ }, [re, A]), $t({
898
911
  config: a ? {
899
912
  enabled: a.enabled ?? !0,
900
913
  debounceMs: a.debounceMs ?? 100,
@@ -903,23 +916,23 @@ function Yt(r, n) {
903
916
  enabled: !1
904
917
  // Only use smart export if autoExportConfig is provided
905
918
  },
906
- historyManager: w,
907
- artboards: c,
908
- elements: i,
919
+ historyManager: d,
920
+ artboards: g,
921
+ elements: u,
909
922
  onExport: Y,
910
923
  onExportScheduled: de,
911
924
  isCanvasReady: re
912
925
  // Gate exports until content is fully ready (fonts loaded, elements deserialized)
913
- }), S(() => {
914
- if (c.length > 0 && !I) {
915
- const D = requestAnimationFrame(() => {
916
- p(!0);
926
+ }), F(() => {
927
+ if (g.length > 0 && !p) {
928
+ const O = requestAnimationFrame(() => {
929
+ b(!0);
917
930
  });
918
- return () => cancelAnimationFrame(D);
931
+ return () => cancelAnimationFrame(O);
919
932
  }
920
- }, [c.length, I, p]), S(() => () => {
921
- p(!1);
922
- }, [p]);
933
+ }, [g.length, p, b]), F(() => () => {
934
+ b(!1);
935
+ }, [b]);
923
936
  }
924
937
  async function Zt(r) {
925
938
  if (typeof document > "u" || r.length === 0) return [];
@@ -949,66 +962,66 @@ const Fe = te("SnowconeCanvas"), Le = Ce((r, n) => {
949
962
  imageConfig: a,
950
963
  layoutConfig: t,
951
964
  kit: o,
952
- artboards: l,
953
- activeArtboard: u,
965
+ artboards: i,
966
+ activeArtboard: l,
954
967
  onArtboardChange: s,
955
- initialElements: f,
968
+ initialElements: m,
956
969
  customFonts: h,
957
- onChange: b,
958
- onSelectionChange: d,
959
- autoExportInterval: E,
960
- onExport: y,
961
- onExportScheduled: x,
970
+ onChange: v,
971
+ onSelectionChange: c,
972
+ autoExportInterval: w,
973
+ onExport: A,
974
+ onExportScheduled: S,
962
975
  onExportStatus: $,
963
- onExportReady: M,
964
- onImageLoad: i,
965
- onImageError: g,
966
- onImageLoadError: w,
967
- onError: I,
968
- onReady: p,
969
- className: c,
970
- style: m,
971
- enableShortcuts: A,
972
- overlay: k,
973
- resetDocumentOnMount: T
974
- } = r, W = E, L = r.autoExportConfig ?? (e == null ? void 0 : e.autoExportConfig), H = r.autoExportFormat ?? (e == null ? void 0 : e.format) ?? "dataUrl", Y = r.autoExportAll ?? (e == null ? void 0 : e.exportAll) ?? !1, de = r.exportScale ?? (e == null ? void 0 : e.scale) ?? 2, re = r.maxExportSize ?? (e == null ? void 0 : e.maxSize) ?? 4e3, ie = r.exportImageFormat ?? (e == null ? void 0 : e.imageFormat) ?? "png", D = r.exportImageQuality ?? (e == null ? void 0 : e.imageQuality) ?? 0.92, P = r.initialImage ?? (a == null ? void 0 : a.src), B = r.initialImageAlignment ?? (a == null ? void 0 : a.alignment) ?? "center", K = r.initialImageScale ?? (a == null ? void 0 : a.scale) ?? 1, j = r.initialImageScaleMode ?? (a == null ? void 0 : a.scaleMode) ?? "cover", F = r.initialImageRole ?? (a == null ? void 0 : a.role) ?? "design", C = Qe.useMemo(() => Ht(r.initialImageText, P), [r.initialImageText, P]), R = r.width ?? (t == null ? void 0 : t.width) ?? 1200, O = r.height ?? (t == null ? void 0 : t.height) ?? 1200, X = r.viewPadding ?? (t == null ? void 0 : t.viewPadding) ?? 0.9, z = r.artboardBorderRadius ?? (t == null ? void 0 : t.artboardBorderRadius) ?? 0, J = r.fixedMargin ?? (t == null ? void 0 : t.fixedMargin), Pe = r.maxHeight ?? (t == null ? void 0 : t.maxHeight), $e = r.showRotationHandle ?? (t == null ? void 0 : t.showRotationHandle) ?? !0, De = r.hideCanvas ?? (t == null ? void 0 : t.hideCanvas) ?? !1, be = r.canvasWrapperClassName ?? (t == null ? void 0 : t.canvasWrapperClassName), ve = r.canvasWrapperStyle ?? (t == null ? void 0 : t.canvasWrapperStyle), Oe = r.canvasCutouts ?? (t == null ? void 0 : t.canvasCutouts), Ee = r.pieceGuides, Be = r.pieceFocus, We = A ?? !0, Z = Re(() => it(o ?? "pro-studio"), [o]);
975
- S(() => {
976
+ onExportReady: T,
977
+ onImageLoad: u,
978
+ onImageError: x,
979
+ onImageLoadError: d,
980
+ onError: p,
981
+ onReady: b,
982
+ className: g,
983
+ style: k,
984
+ enableShortcuts: E,
985
+ overlay: f,
986
+ resetDocumentOnMount: I
987
+ } = r, W = w, L = r.autoExportConfig ?? (e == null ? void 0 : e.autoExportConfig), H = r.autoExportFormat ?? (e == null ? void 0 : e.format) ?? "dataUrl", Y = r.autoExportAll ?? (e == null ? void 0 : e.exportAll) ?? !1, de = r.exportScale ?? (e == null ? void 0 : e.scale) ?? 2, re = r.maxExportSize ?? (e == null ? void 0 : e.maxSize) ?? 4e3, ie = r.exportImageFormat ?? (e == null ? void 0 : e.imageFormat) ?? "png", O = r.exportImageQuality ?? (e == null ? void 0 : e.imageQuality) ?? 0.92, P = r.initialImage ?? (a == null ? void 0 : a.src), B = r.initialImageAlignment ?? (a == null ? void 0 : a.alignment) ?? "center", K = r.initialImageScale ?? (a == null ? void 0 : a.scale) ?? 1, j = r.initialImageScaleMode ?? (a == null ? void 0 : a.scaleMode) ?? "cover", R = r.initialImageRole ?? (a == null ? void 0 : a.role) ?? "design", M = Qe.useMemo(() => Ht(r.initialImageText, P), [r.initialImageText, P]), C = r.width ?? (t == null ? void 0 : t.width) ?? 1200, D = r.height ?? (t == null ? void 0 : t.height) ?? 1200, X = r.viewPadding ?? (t == null ? void 0 : t.viewPadding) ?? 0.9, z = r.artboardBorderRadius ?? (t == null ? void 0 : t.artboardBorderRadius) ?? 0, J = r.fixedMargin ?? (t == null ? void 0 : t.fixedMargin), Pe = r.maxHeight ?? (t == null ? void 0 : t.maxHeight), $e = r.showRotationHandle ?? (t == null ? void 0 : t.showRotationHandle) ?? !0, Oe = r.hideCanvas ?? (t == null ? void 0 : t.hideCanvas) ?? !1, be = r.canvasWrapperClassName ?? (t == null ? void 0 : t.canvasWrapperClassName), ve = r.canvasWrapperStyle ?? (t == null ? void 0 : t.canvasWrapperStyle), De = r.canvasCutouts ?? (t == null ? void 0 : t.canvasCutouts), Ee = r.pieceGuides, Be = r.pieceFocus, We = E ?? !0, Z = Re(() => it(o ?? "pro-studio"), [o]);
988
+ F(() => {
976
989
  var U;
977
990
  if (typeof ee < "u" && ((U = ee.env) == null ? void 0 : U.NODE_ENV) === "development" && Z) {
978
991
  const G = ct(Z);
979
992
  G.valid || Fe.warn("Kit validation warnings:", G.errors), G.warnings.length > 0 && Fe.warn("Kit validation warnings:", G.warnings);
980
993
  }
981
- }, [Z]), S(() => {
982
- if (w)
983
- return Xe(w);
984
- }, [w]);
985
- const { emitError: ue, handleBoundaryError: He } = Ut(I);
994
+ }, [Z]), F(() => {
995
+ if (d)
996
+ return Xe(d);
997
+ }, [d]);
998
+ const { emitError: ue, handleBoundaryError: He } = Ut(p);
986
999
  Vt({
987
- artboardConfigs: l,
988
- width: R,
989
- height: O,
1000
+ artboardConfigs: i,
1001
+ width: C,
1002
+ height: D,
990
1003
  pieceGuides: Ee,
991
- controlledActiveArtboard: u,
1004
+ controlledActiveArtboard: l,
992
1005
  onArtboardChange: s,
993
- resetDocumentOnMount: T
1006
+ resetDocumentOnMount: I
994
1007
  });
995
1008
  const { initialElementsLoadedState: Ke } = Xt({
996
- initialElements: f,
1009
+ initialElements: m,
997
1010
  customFonts: h,
998
1011
  emitError: ue
999
1012
  }), { imageLoadingState: ye, imageError: xe } = Jt({
1000
1013
  initialImage: P,
1001
- initialImageText: C,
1014
+ initialImageText: M,
1002
1015
  initialImageAlignment: B,
1003
1016
  initialImageScale: K,
1004
1017
  initialImageScaleMode: j,
1005
- initialImageRole: F,
1006
- artboardConfigs: l,
1007
- onImageLoad: i,
1008
- onImageError: g,
1018
+ initialImageRole: R,
1019
+ artboardConfigs: i,
1020
+ onImageLoad: u,
1021
+ onImageError: x,
1009
1022
  emitError: ue
1010
1023
  });
1011
- if (Qt({ onChange: b, onSelectionChange: d }), Yt(
1024
+ if (Qt({ onChange: v, onSelectionChange: c }), Yt(
1012
1025
  {
1013
1026
  autoExportInterval: W,
1014
1027
  autoExportConfig: L,
@@ -1017,39 +1030,39 @@ const Fe = te("SnowconeCanvas"), Le = Ce((r, n) => {
1017
1030
  exportScale: de,
1018
1031
  maxExportSize: re,
1019
1032
  exportImageFormat: ie,
1020
- exportImageQuality: D,
1021
- onExport: y,
1022
- onExportScheduled: x,
1033
+ exportImageQuality: O,
1034
+ onExport: A,
1035
+ onExportScheduled: S,
1023
1036
  onExportStatus: $,
1024
- onExportReady: M,
1025
- onReady: p,
1026
- hasInitialElements: !!f && f.length > 0,
1037
+ onExportReady: T,
1038
+ onReady: b,
1039
+ hasInitialElements: !!m && m.length > 0,
1027
1040
  initialElementsLoaded: Ke,
1028
1041
  emitError: ue
1029
1042
  },
1030
1043
  n
1031
1044
  ), ye === "loading")
1032
- return /* @__PURE__ */ v(
1045
+ return /* @__PURE__ */ y(
1033
1046
  "div",
1034
1047
  {
1035
- className: c,
1048
+ className: g,
1036
1049
  style: {
1037
- ...m,
1050
+ ...k,
1038
1051
  display: "flex",
1039
1052
  alignItems: "center",
1040
1053
  justifyContent: "center",
1041
1054
  backgroundColor: "var(--surface, #f5f5f5)"
1042
1055
  },
1043
- children: /* @__PURE__ */ v(lt, { size: 48 })
1056
+ children: /* @__PURE__ */ y(lt, { size: 48 })
1044
1057
  }
1045
1058
  );
1046
1059
  if (ye === "error" && xe)
1047
- return /* @__PURE__ */ v(
1060
+ return /* @__PURE__ */ y(
1048
1061
  "div",
1049
1062
  {
1050
- className: c,
1063
+ className: g,
1051
1064
  style: {
1052
- ...m,
1065
+ ...k,
1053
1066
  display: "flex",
1054
1067
  alignItems: "center",
1055
1068
  justifyContent: "center",
@@ -1058,15 +1071,15 @@ const Fe = te("SnowconeCanvas"), Le = Ce((r, n) => {
1058
1071
  padding: "1rem"
1059
1072
  },
1060
1073
  children: /* @__PURE__ */ _("div", { className: "sc:text-center", children: [
1061
- /* @__PURE__ */ v("div", { className: "sc:font-medium", children: "Failed to load image" }),
1062
- /* @__PURE__ */ v("div", { className: "sc:text-sm sc:mt-1 sc:opacity-70", children: xe.message })
1074
+ /* @__PURE__ */ y("div", { className: "sc:font-medium", children: "Failed to load image" }),
1075
+ /* @__PURE__ */ y("div", { className: "sc:text-sm sc:mt-1 sc:opacity-70", children: xe.message })
1063
1076
  ] })
1064
1077
  }
1065
1078
  );
1066
1079
  const je = Object.entries(((we = Z.layout) == null ? void 0 : we.slots) ?? {}).every(
1067
1080
  ([U, G]) => U === "canvas" || !G || G.length === 0
1068
1081
  ) ? { "--color-canvas-bg": "transparent" } : void 0;
1069
- return /* @__PURE__ */ v(dt, { kit: Z, children: /* @__PURE__ */ v("div", { className: `sc-root ${c || ""}`, style: { ...je, ...m, position: "relative" }, children: /* @__PURE__ */ _(
1082
+ return /* @__PURE__ */ y(dt, { kit: Z, children: /* @__PURE__ */ y("div", { className: `sc-root ${g || ""}`, style: { ...je, ...k, position: "relative" }, children: /* @__PURE__ */ _(
1070
1083
  Nt,
1071
1084
  {
1072
1085
  onError: He,
@@ -1086,9 +1099,9 @@ const Fe = te("SnowconeCanvas"), Le = Ce((r, n) => {
1086
1099
  textAlign: "center"
1087
1100
  },
1088
1101
  children: [
1089
- /* @__PURE__ */ v("div", { style: { fontSize: "18px", fontWeight: 600, marginBottom: "8px" }, children: "Something went wrong" }),
1090
- /* @__PURE__ */ v("div", { style: { fontSize: "14px", opacity: 0.7, marginBottom: "16px", maxWidth: "400px" }, children: U.message }),
1091
- /* @__PURE__ */ v(
1102
+ /* @__PURE__ */ y("div", { style: { fontSize: "18px", fontWeight: 600, marginBottom: "8px" }, children: "Something went wrong" }),
1103
+ /* @__PURE__ */ y("div", { style: { fontSize: "14px", opacity: 0.7, marginBottom: "16px", maxWidth: "400px" }, children: U.message }),
1104
+ /* @__PURE__ */ y(
1092
1105
  "button",
1093
1106
  {
1094
1107
  onClick: G,
@@ -1109,8 +1122,8 @@ const Fe = te("SnowconeCanvas"), Le = Ce((r, n) => {
1109
1122
  }
1110
1123
  ),
1111
1124
  children: [
1112
- !De && /* @__PURE__ */ (() => {
1113
- const U = /* @__PURE__ */ v(
1125
+ !Oe && /* @__PURE__ */ (() => {
1126
+ const U = /* @__PURE__ */ y(
1114
1127
  ut,
1115
1128
  {
1116
1129
  style: { width: "100%" },
@@ -1120,30 +1133,30 @@ const Fe = te("SnowconeCanvas"), Le = Ce((r, n) => {
1120
1133
  maxHeight: Pe,
1121
1134
  showRotationHandle: $e,
1122
1135
  enableShortcuts: We,
1123
- canvasCutouts: Oe,
1136
+ canvasCutouts: De,
1124
1137
  pieceGuides: Ee,
1125
1138
  pieceFocus: Be
1126
1139
  }
1127
1140
  );
1128
- return /* @__PURE__ */ v(Mt, { kit: Z, canvas: be || ve ? /* @__PURE__ */ v("div", { className: be, style: ve, children: U }) : U });
1141
+ return /* @__PURE__ */ y(Mt, { kit: Z, canvas: be || ve ? /* @__PURE__ */ y("div", { className: be, style: ve, children: U }) : U });
1129
1142
  })(),
1130
- k
1143
+ f
1131
1144
  ]
1132
1145
  }
1133
1146
  ) }) });
1134
1147
  });
1135
1148
  Le.displayName = "SnowconeCanvasInner";
1136
1149
  const qt = Ce((r, n) => {
1137
- var l;
1138
- const { inheritTheme: e, externalProvider: a, services: t } = r, o = r.viewPadding ?? ((l = r.layoutConfig) == null ? void 0 : l.viewPadding);
1139
- return /* @__PURE__ */ v(
1150
+ var i;
1151
+ const { inheritTheme: e, externalProvider: a, services: t } = r, o = r.viewPadding ?? ((i = r.layoutConfig) == null ? void 0 : i.viewPadding);
1152
+ return /* @__PURE__ */ y(
1140
1153
  Lt,
1141
1154
  {
1142
1155
  inheritTheme: e,
1143
1156
  externalProvider: a,
1144
1157
  services: t,
1145
1158
  viewPadding: o,
1146
- children: /* @__PURE__ */ v(Le, { ref: n, ...r })
1159
+ children: /* @__PURE__ */ y(Le, { ref: n, ...r })
1147
1160
  }
1148
1161
  );
1149
1162
  });
@@ -1154,4 +1167,4 @@ export {
1154
1167
  Wt as a,
1155
1168
  $t as u
1156
1169
  };
1157
- //# sourceMappingURL=SnowconeCanvas-Bs34CUv5.js.map
1170
+ //# sourceMappingURL=SnowconeCanvas-C-AGGT44.js.map