@mypixia/simplex-designer 2.0.6 → 2.0.7

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.
package/dist/index.es.js CHANGED
@@ -1,8 +1,8 @@
1
- import Qe, { useState as N, useRef as gt, useEffect as ot, useMemo as ie, forwardRef as $e, useCallback as rt, useReducer as He, useImperativeHandle as Ge } from "react";
1
+ import Qe, { useState as N, useRef as gt, useEffect as rt, useMemo as ie, forwardRef as $e, useCallback as at, useReducer as He, useImperativeHandle as Ge } from "react";
2
2
  import _e from "qrcode";
3
3
  import Ye from "react-barcode";
4
4
  import oe from "axios";
5
- import './index_external.css';var Et = { exports: {} }, Tt = {};
5
+ import './index_external.css';var Et = { exports: {} }, jt = {};
6
6
  /**
7
7
  * @license React
8
8
  * react-jsx-runtime.production.js
@@ -14,27 +14,27 @@ import './index_external.css';var Et = { exports: {} }, Tt = {};
14
14
  */
15
15
  var re;
16
16
  function qe() {
17
- if (re) return Tt;
17
+ if (re) return jt;
18
18
  re = 1;
19
19
  var f = Symbol.for("react.transitional.element"), o = Symbol.for("react.fragment");
20
- function a(l, s, h) {
21
- var x = null;
22
- if (h !== void 0 && (x = "" + h), s.key !== void 0 && (x = "" + s.key), "key" in s) {
23
- h = {};
20
+ function a(l, s, g) {
21
+ var h = null;
22
+ if (g !== void 0 && (h = "" + g), s.key !== void 0 && (h = "" + s.key), "key" in s) {
23
+ g = {};
24
24
  for (var n in s)
25
- n !== "key" && (h[n] = s[n]);
26
- } else h = s;
27
- return s = h.ref, {
25
+ n !== "key" && (g[n] = s[n]);
26
+ } else g = s;
27
+ return s = g.ref, {
28
28
  $$typeof: f,
29
29
  type: l,
30
- key: x,
30
+ key: h,
31
31
  ref: s !== void 0 ? s : null,
32
- props: h
32
+ props: g
33
33
  };
34
34
  }
35
- return Tt.Fragment = o, Tt.jsx = a, Tt.jsxs = a, Tt;
35
+ return jt.Fragment = o, jt.jsx = a, jt.jsxs = a, jt;
36
36
  }
37
- var jt = {};
37
+ var Tt = {};
38
38
  /**
39
39
  * @license React
40
40
  * react-jsx-runtime.development.js
@@ -47,163 +47,163 @@ var jt = {};
47
47
  var ae;
48
48
  function Ve() {
49
49
  return ae || (ae = 1, process.env.NODE_ENV !== "production" && function() {
50
- function f(u) {
51
- if (u == null) return null;
52
- if (typeof u == "function")
53
- return u.$$typeof === _ ? null : u.displayName || u.name || null;
54
- if (typeof u == "string") return u;
55
- switch (u) {
56
- case b:
50
+ function f(y) {
51
+ if (y == null) return null;
52
+ if (typeof y == "function")
53
+ return y.$$typeof === _ ? null : y.displayName || y.name || null;
54
+ if (typeof y == "string") return y;
55
+ switch (y) {
56
+ case p:
57
57
  return "Fragment";
58
- case J:
58
+ case X:
59
59
  return "Profiler";
60
- case F:
60
+ case v:
61
61
  return "StrictMode";
62
- case st:
62
+ case Z:
63
63
  return "Suspense";
64
64
  case W:
65
65
  return "SuspenseList";
66
66
  case ft:
67
67
  return "Activity";
68
68
  }
69
- if (typeof u == "object")
70
- switch (typeof u.tag == "number" && console.error(
69
+ if (typeof y == "object")
70
+ switch (typeof y.tag == "number" && console.error(
71
71
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
72
- ), u.$$typeof) {
73
- case B:
72
+ ), y.$$typeof) {
73
+ case j:
74
74
  return "Portal";
75
75
  case O:
76
- return (u.displayName || "Context") + ".Provider";
76
+ return (y.displayName || "Context") + ".Provider";
77
77
  case T:
78
- return (u._context.displayName || "Context") + ".Consumer";
79
- case v:
80
- var D = u.render;
81
- return u = u.displayName, u || (u = D.displayName || D.name || "", u = u !== "" ? "ForwardRef(" + u + ")" : "ForwardRef"), u;
78
+ return (y._context.displayName || "Context") + ".Consumer";
79
+ case k:
80
+ var D = y.render;
81
+ return y = y.displayName, y || (y = D.displayName || D.name || "", y = y !== "" ? "ForwardRef(" + y + ")" : "ForwardRef"), y;
82
82
  case xt:
83
- return D = u.displayName || null, D !== null ? D : f(u.type) || "Memo";
83
+ return D = y.displayName || null, D !== null ? D : f(y.type) || "Memo";
84
84
  case Q:
85
- D = u._payload, u = u._init;
85
+ D = y._payload, y = y._init;
86
86
  try {
87
- return f(u(D));
87
+ return f(y(D));
88
88
  } catch {
89
89
  }
90
90
  }
91
91
  return null;
92
92
  }
93
- function o(u) {
94
- return "" + u;
93
+ function o(y) {
94
+ return "" + y;
95
95
  }
96
- function a(u) {
96
+ function a(y) {
97
97
  try {
98
- o(u);
98
+ o(y);
99
99
  var D = !1;
100
100
  } catch {
101
101
  D = !0;
102
102
  }
103
103
  if (D) {
104
104
  D = console;
105
- var L = D.error, H = typeof Symbol == "function" && Symbol.toStringTag && u[Symbol.toStringTag] || u.constructor.name || "Object";
105
+ var L = D.error, H = typeof Symbol == "function" && Symbol.toStringTag && y[Symbol.toStringTag] || y.constructor.name || "Object";
106
106
  return L.call(
107
107
  D,
108
108
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
109
109
  H
110
- ), o(u);
110
+ ), o(y);
111
111
  }
112
112
  }
113
- function l(u) {
114
- if (u === b) return "<>";
115
- if (typeof u == "object" && u !== null && u.$$typeof === Q)
113
+ function l(y) {
114
+ if (y === p) return "<>";
115
+ if (typeof y == "object" && y !== null && y.$$typeof === Q)
116
116
  return "<...>";
117
117
  try {
118
- var D = f(u);
118
+ var D = f(y);
119
119
  return D ? "<" + D + ">" : "<...>";
120
120
  } catch {
121
121
  return "<...>";
122
122
  }
123
123
  }
124
124
  function s() {
125
- var u = at.A;
126
- return u === null ? null : u.getOwner();
125
+ var y = st.A;
126
+ return y === null ? null : y.getOwner();
127
127
  }
128
- function h() {
128
+ function g() {
129
129
  return Error("react-stack-top-frame");
130
130
  }
131
- function x(u) {
132
- if (M.call(u, "key")) {
133
- var D = Object.getOwnPropertyDescriptor(u, "key").get;
131
+ function h(y) {
132
+ if (M.call(y, "key")) {
133
+ var D = Object.getOwnPropertyDescriptor(y, "key").get;
134
134
  if (D && D.isReactWarning) return !1;
135
135
  }
136
- return u.key !== void 0;
136
+ return y.key !== void 0;
137
137
  }
138
- function n(u, D) {
138
+ function n(y, D) {
139
139
  function L() {
140
140
  ct || (ct = !0, console.error(
141
141
  "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
142
142
  D
143
143
  ));
144
144
  }
145
- L.isReactWarning = !0, Object.defineProperty(u, "key", {
145
+ L.isReactWarning = !0, Object.defineProperty(y, "key", {
146
146
  get: L,
147
147
  configurable: !0
148
148
  });
149
149
  }
150
- function d() {
151
- var u = f(this.type);
152
- return Y[u] || (Y[u] = !0, console.error(
150
+ function c() {
151
+ var y = f(this.type);
152
+ return Y[y] || (Y[y] = !0, console.error(
153
153
  "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
154
- )), u = this.props.ref, u !== void 0 ? u : null;
154
+ )), y = this.props.ref, y !== void 0 ? y : null;
155
155
  }
156
- function j(u, D, L, H, G, et, X, q) {
157
- return L = et.ref, u = {
158
- $$typeof: E,
159
- type: u,
156
+ function F(y, D, L, H, G, it, J, q) {
157
+ return L = it.ref, y = {
158
+ $$typeof: B,
159
+ type: y,
160
160
  key: D,
161
- props: et,
161
+ props: it,
162
162
  _owner: G
163
- }, (L !== void 0 ? L : null) !== null ? Object.defineProperty(u, "ref", {
163
+ }, (L !== void 0 ? L : null) !== null ? Object.defineProperty(y, "ref", {
164
164
  enumerable: !1,
165
- get: d
166
- }) : Object.defineProperty(u, "ref", { enumerable: !1, value: null }), u._store = {}, Object.defineProperty(u._store, "validated", {
165
+ get: c
166
+ }) : Object.defineProperty(y, "ref", { enumerable: !1, value: null }), y._store = {}, Object.defineProperty(y._store, "validated", {
167
167
  configurable: !1,
168
168
  enumerable: !1,
169
169
  writable: !0,
170
170
  value: 0
171
- }), Object.defineProperty(u, "_debugInfo", {
171
+ }), Object.defineProperty(y, "_debugInfo", {
172
172
  configurable: !1,
173
173
  enumerable: !1,
174
174
  writable: !0,
175
175
  value: null
176
- }), Object.defineProperty(u, "_debugStack", {
176
+ }), Object.defineProperty(y, "_debugStack", {
177
177
  configurable: !1,
178
178
  enumerable: !1,
179
179
  writable: !0,
180
- value: X
181
- }), Object.defineProperty(u, "_debugTask", {
180
+ value: J
181
+ }), Object.defineProperty(y, "_debugTask", {
182
182
  configurable: !1,
183
183
  enumerable: !1,
184
184
  writable: !0,
185
185
  value: q
186
- }), Object.freeze && (Object.freeze(u.props), Object.freeze(u)), u;
186
+ }), Object.freeze && (Object.freeze(y.props), Object.freeze(y)), y;
187
187
  }
188
- function S(u, D, L, H, G, et, X, q) {
188
+ function I(y, D, L, H, G, it, J, q) {
189
189
  var U = D.children;
190
190
  if (U !== void 0)
191
191
  if (H)
192
192
  if (nt(U)) {
193
193
  for (H = 0; H < U.length; H++)
194
- I(U[H]);
194
+ E(U[H]);
195
195
  Object.freeze && Object.freeze(U);
196
196
  } else
197
197
  console.error(
198
198
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
199
199
  );
200
- else I(U);
200
+ else E(U);
201
201
  if (M.call(D, "key")) {
202
- U = f(u);
203
- var K = Object.keys(D).filter(function(mt) {
204
- return mt !== "key";
202
+ U = f(y);
203
+ var K = Object.keys(D).filter(function(pt) {
204
+ return pt !== "key";
205
205
  });
206
- H = 0 < K.length ? "{key: someKey, " + K.join(": ..., ") + ": ...}" : "{key: someKey}", tt[U + H] || (K = 0 < K.length ? "{" + K.join(": ..., ") + ": ...}" : "{}", console.error(
206
+ H = 0 < K.length ? "{key: someKey, " + K.join(": ..., ") + ": ...}" : "{key: someKey}", et[U + H] || (K = 0 < K.length ? "{" + K.join(": ..., ") + ": ...}" : "{}", console.error(
207
207
  `A props object containing a "key" prop is being spread into JSX:
208
208
  let props = %s;
209
209
  <%s {...props} />
@@ -214,68 +214,68 @@ React keys must be passed directly to JSX without using spread:
214
214
  U,
215
215
  K,
216
216
  U
217
- ), tt[U + H] = !0);
217
+ ), et[U + H] = !0);
218
218
  }
219
- if (U = null, L !== void 0 && (a(L), U = "" + L), x(D) && (a(D.key), U = "" + D.key), "key" in D) {
219
+ if (U = null, L !== void 0 && (a(L), U = "" + L), h(D) && (a(D.key), U = "" + D.key), "key" in D) {
220
220
  L = {};
221
221
  for (var kt in D)
222
222
  kt !== "key" && (L[kt] = D[kt]);
223
223
  } else L = D;
224
224
  return U && n(
225
225
  L,
226
- typeof u == "function" ? u.displayName || u.name || "Unknown" : u
227
- ), j(
228
- u,
226
+ typeof y == "function" ? y.displayName || y.name || "Unknown" : y
227
+ ), F(
228
+ y,
229
229
  U,
230
- et,
230
+ it,
231
231
  G,
232
232
  s(),
233
233
  L,
234
- X,
234
+ J,
235
235
  q
236
236
  );
237
237
  }
238
- function I(u) {
239
- typeof u == "object" && u !== null && u.$$typeof === E && u._store && (u._store.validated = 1);
238
+ function E(y) {
239
+ typeof y == "object" && y !== null && y.$$typeof === B && y._store && (y._store.validated = 1);
240
240
  }
241
- var y = Qe, E = Symbol.for("react.transitional.element"), B = Symbol.for("react.portal"), b = Symbol.for("react.fragment"), F = Symbol.for("react.strict_mode"), J = Symbol.for("react.profiler"), T = Symbol.for("react.consumer"), O = Symbol.for("react.context"), v = Symbol.for("react.forward_ref"), st = Symbol.for("react.suspense"), W = Symbol.for("react.suspense_list"), xt = Symbol.for("react.memo"), Q = Symbol.for("react.lazy"), ft = Symbol.for("react.activity"), _ = Symbol.for("react.client.reference"), at = y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, M = Object.prototype.hasOwnProperty, nt = Array.isArray, Z = console.createTask ? console.createTask : function() {
241
+ var m = Qe, B = Symbol.for("react.transitional.element"), j = Symbol.for("react.portal"), p = Symbol.for("react.fragment"), v = Symbol.for("react.strict_mode"), X = Symbol.for("react.profiler"), T = Symbol.for("react.consumer"), O = Symbol.for("react.context"), k = Symbol.for("react.forward_ref"), Z = Symbol.for("react.suspense"), W = Symbol.for("react.suspense_list"), xt = Symbol.for("react.memo"), Q = Symbol.for("react.lazy"), ft = Symbol.for("react.activity"), _ = Symbol.for("react.client.reference"), st = m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, M = Object.prototype.hasOwnProperty, nt = Array.isArray, tt = console.createTask ? console.createTask : function() {
242
242
  return null;
243
243
  };
244
- y = {
245
- "react-stack-bottom-frame": function(u) {
246
- return u();
244
+ m = {
245
+ "react-stack-bottom-frame": function(y) {
246
+ return y();
247
247
  }
248
248
  };
249
- var ct, Y = {}, P = y["react-stack-bottom-frame"].bind(
250
- y,
251
- h
252
- )(), C = Z(l(h)), tt = {};
253
- jt.Fragment = b, jt.jsx = function(u, D, L, H, G) {
254
- var et = 1e4 > at.recentlyCreatedOwnerStacks++;
255
- return S(
256
- u,
249
+ var ct, Y = {}, P = m["react-stack-bottom-frame"].bind(
250
+ m,
251
+ g
252
+ )(), C = tt(l(g)), et = {};
253
+ Tt.Fragment = p, Tt.jsx = function(y, D, L, H, G) {
254
+ var it = 1e4 > st.recentlyCreatedOwnerStacks++;
255
+ return I(
256
+ y,
257
257
  D,
258
258
  L,
259
259
  !1,
260
260
  H,
261
261
  G,
262
- et ? Error("react-stack-top-frame") : P,
263
- et ? Z(l(u)) : C
262
+ it ? Error("react-stack-top-frame") : P,
263
+ it ? tt(l(y)) : C
264
264
  );
265
- }, jt.jsxs = function(u, D, L, H, G) {
266
- var et = 1e4 > at.recentlyCreatedOwnerStacks++;
267
- return S(
268
- u,
265
+ }, Tt.jsxs = function(y, D, L, H, G) {
266
+ var it = 1e4 > st.recentlyCreatedOwnerStacks++;
267
+ return I(
268
+ y,
269
269
  D,
270
270
  L,
271
271
  !0,
272
272
  H,
273
273
  G,
274
- et ? Error("react-stack-top-frame") : P,
275
- et ? Z(l(u)) : C
274
+ it ? Error("react-stack-top-frame") : P,
275
+ it ? tt(l(y)) : C
276
276
  );
277
277
  };
278
- }()), jt;
278
+ }()), Tt;
279
279
  }
280
280
  var se;
281
281
  function Xe() {
@@ -381,24 +381,24 @@ const Ut = {
381
381
  ), Je = (f) => ne().filter(
382
382
  (a) => a.name.toLowerCase().includes(f.toLowerCase()) || a.category.toLowerCase().includes(f.toLowerCase())
383
383
  ), Ke = ({ onSelectIcon: f, disabled: o = !1 }) => {
384
- const [a, l] = N(!1), [s, h] = N(""), [x, n] = N("all"), d = gt(null);
385
- ot(() => {
386
- const y = (E) => {
387
- d.current && !d.current.contains(E.target) && l(!1);
384
+ const [a, l] = N(!1), [s, g] = N(""), [h, n] = N("all"), c = gt(null);
385
+ rt(() => {
386
+ const m = (B) => {
387
+ c.current && !c.current.contains(B.target) && l(!1);
388
388
  };
389
- return document.addEventListener("mousedown", y), () => document.removeEventListener("mousedown", y);
389
+ return document.addEventListener("mousedown", m), () => document.removeEventListener("mousedown", m);
390
390
  }, []);
391
- const j = (y) => {
392
- f(y), l(!1), h("");
393
- }, I = (() => {
394
- let y = ne();
395
- if (s.trim() && (y = Je(s)), x !== "all") {
396
- const E = Ut[x];
397
- E && (y = y.filter((B) => B.category === E.name));
391
+ const F = (m) => {
392
+ f(m), l(!1), g("");
393
+ }, E = (() => {
394
+ let m = ne();
395
+ if (s.trim() && (m = Je(s)), h !== "all") {
396
+ const B = Ut[h];
397
+ B && (m = m.filter((j) => j.category === B.name));
398
398
  }
399
- return y;
399
+ return m;
400
400
  })();
401
- return /* @__PURE__ */ i.jsxs("div", { className: "icon-selector", ref: d, children: [
401
+ return /* @__PURE__ */ i.jsxs("div", { className: "icon-selector", ref: c, children: [
402
402
  /* @__PURE__ */ i.jsxs(
403
403
  "button",
404
404
  {
@@ -421,49 +421,49 @@ const Ut = {
421
421
  type: "text",
422
422
  placeholder: "Search icons...",
423
423
  value: s,
424
- onChange: (y) => h(y.target.value),
424
+ onChange: (m) => g(m.target.value),
425
425
  className: "icon-search"
426
426
  }
427
427
  ),
428
428
  /* @__PURE__ */ i.jsxs(
429
429
  "select",
430
430
  {
431
- value: x,
432
- onChange: (y) => n(y.target.value),
431
+ value: h,
432
+ onChange: (m) => n(m.target.value),
433
433
  className: "category-select",
434
434
  children: [
435
435
  /* @__PURE__ */ i.jsx("option", { value: "all", children: "All Categories" }),
436
- Object.entries(Ut).map(([y, E]) => /* @__PURE__ */ i.jsx("option", { value: y, children: E.name }, y))
436
+ Object.entries(Ut).map(([m, B]) => /* @__PURE__ */ i.jsx("option", { value: m, children: B.name }, m))
437
437
  ]
438
438
  }
439
439
  )
440
440
  ] }),
441
- /* @__PURE__ */ i.jsx("div", { className: "icon-grid", children: I.length === 0 ? /* @__PURE__ */ i.jsx("div", { className: "no-icons", children: s ? "No icons found" : "No icons in this category" }) : I.map((y, E) => /* @__PURE__ */ i.jsxs(
441
+ /* @__PURE__ */ i.jsx("div", { className: "icon-grid", children: E.length === 0 ? /* @__PURE__ */ i.jsx("div", { className: "no-icons", children: s ? "No icons found" : "No icons in this category" }) : E.map((m, B) => /* @__PURE__ */ i.jsxs(
442
442
  "button",
443
443
  {
444
444
  className: "icon-item",
445
- onClick: () => j(y),
446
- title: `${y.name} (${y.category})`,
445
+ onClick: () => F(m),
446
+ title: `${m.name} (${m.category})`,
447
447
  children: [
448
- /* @__PURE__ */ i.jsx("span", { className: "icon-symbol", children: y.symbol }),
449
- /* @__PURE__ */ i.jsx("span", { className: "icon-name", children: y.name })
448
+ /* @__PURE__ */ i.jsx("span", { className: "icon-symbol", children: m.symbol }),
449
+ /* @__PURE__ */ i.jsx("span", { className: "icon-name", children: m.name })
450
450
  ]
451
451
  },
452
- `${y.name}-${E}`
452
+ `${m.name}-${B}`
453
453
  )) }),
454
454
  /* @__PURE__ */ i.jsx("div", { className: "icon-dropdown-footer", children: /* @__PURE__ */ i.jsxs("span", { className: "icon-count", children: [
455
- I.length,
455
+ E.length,
456
456
  " icon",
457
- I.length !== 1 ? "s" : ""
457
+ E.length !== 1 ? "s" : ""
458
458
  ] }) })
459
459
  ] })
460
460
  ] });
461
461
  }, Ze = ({ isOpen: f, onClose: o, onAddQRCode: a, theme: l }) => {
462
- const [s, h] = N(""), [x, n] = N(""), [d, j] = N(200), [S, I] = N("M"), y = () => {
462
+ const [s, g] = N(""), [h, n] = N(""), [c, F] = N(200), [I, E] = N("M"), m = () => {
463
463
  if (!s.trim()) return;
464
- const b = {
465
- width: d,
466
- errorCorrectionLevel: S,
464
+ const p = {
465
+ width: c,
466
+ errorCorrectionLevel: I,
467
467
  type: "image/png",
468
468
  quality: 0.92,
469
469
  margin: 1,
@@ -472,40 +472,40 @@ const Ut = {
472
472
  light: "#FFFFFF"
473
473
  }
474
474
  };
475
- _e.toDataURL(s, b, (F, J) => {
476
- if (F) {
477
- console.error("QR Code generation error:", F);
475
+ _e.toDataURL(s, p, (v, X) => {
476
+ if (v) {
477
+ console.error("QR Code generation error:", v);
478
478
  return;
479
479
  }
480
- n(J);
480
+ n(X);
481
481
  });
482
- }, E = () => {
483
- if (!x) return;
484
- const b = new Image();
485
- b.onload = () => {
482
+ }, B = () => {
483
+ if (!h) return;
484
+ const p = new Image();
485
+ p.onload = () => {
486
486
  a({
487
487
  type: "qrcode",
488
- src: x,
488
+ src: h,
489
489
  data: s,
490
- width: d,
491
- height: d,
490
+ width: c,
491
+ height: c,
492
492
  x: 100,
493
493
  y: 100,
494
- imageObject: b
494
+ imageObject: p
495
495
  // Store the loaded image object
496
- }), B();
497
- }, b.src = x;
498
- }, B = () => {
499
- h(""), n(""), o();
496
+ }), j();
497
+ }, p.src = h;
498
+ }, j = () => {
499
+ g(""), n(""), o();
500
500
  };
501
- return f ? /* @__PURE__ */ i.jsx("div", { className: "qr-modal-overlay", onClick: B, children: /* @__PURE__ */ i.jsxs("div", { className: "qr-modal-content", onClick: (b) => b.stopPropagation(), children: [
501
+ return f ? /* @__PURE__ */ i.jsx("div", { className: "qr-modal-overlay", onClick: j, children: /* @__PURE__ */ i.jsxs("div", { className: "qr-modal-content", onClick: (p) => p.stopPropagation(), children: [
502
502
  /* @__PURE__ */ i.jsxs("div", { className: "qr-modal-header", children: [
503
503
  /* @__PURE__ */ i.jsx("h3", { children: "Generate QR Code" }),
504
504
  /* @__PURE__ */ i.jsx(
505
505
  "button",
506
506
  {
507
507
  className: "qr-modal-close",
508
- onClick: B,
508
+ onClick: j,
509
509
  "aria-label": "Close",
510
510
  children: "×"
511
511
  }
@@ -519,7 +519,7 @@ const Ut = {
519
519
  {
520
520
  id: "qr-data",
521
521
  value: s,
522
- onChange: (b) => h(b.target.value),
522
+ onChange: (p) => g(p.target.value),
523
523
  placeholder: "https://example.com or any text...",
524
524
  rows: 3
525
525
  }
@@ -533,8 +533,8 @@ const Ut = {
533
533
  {
534
534
  type: "number",
535
535
  id: "qr-size",
536
- value: d,
537
- onChange: (b) => j(Math.max(50, Math.min(500, parseInt(b.target.value) || 200))),
536
+ value: c,
537
+ onChange: (p) => F(Math.max(50, Math.min(500, parseInt(p.target.value) || 200))),
538
538
  min: "50",
539
539
  max: "500"
540
540
  }
@@ -546,8 +546,8 @@ const Ut = {
546
546
  "select",
547
547
  {
548
548
  id: "qr-error-level",
549
- value: S,
550
- onChange: (b) => I(b.target.value),
549
+ value: I,
550
+ onChange: (p) => E(p.target.value),
551
551
  children: [
552
552
  /* @__PURE__ */ i.jsx("option", { value: "L", children: "Low (7%)" }),
553
553
  /* @__PURE__ */ i.jsx("option", { value: "M", children: "Medium (15%)" }),
@@ -562,19 +562,19 @@ const Ut = {
562
562
  "button",
563
563
  {
564
564
  className: "qr-btn qr-btn-generate",
565
- onClick: y,
565
+ onClick: m,
566
566
  disabled: !s.trim(),
567
567
  children: "Generate QR Code"
568
568
  }
569
569
  ) }),
570
- x && /* @__PURE__ */ i.jsxs("div", { className: "qr-preview", children: [
570
+ h && /* @__PURE__ */ i.jsxs("div", { className: "qr-preview", children: [
571
571
  /* @__PURE__ */ i.jsx("h4", { children: "Preview" }),
572
- /* @__PURE__ */ i.jsx("div", { className: "qr-preview-container", children: /* @__PURE__ */ i.jsx("img", { src: x, alt: "QR Code Preview" }) }),
572
+ /* @__PURE__ */ i.jsx("div", { className: "qr-preview-container", children: /* @__PURE__ */ i.jsx("img", { src: h, alt: "QR Code Preview" }) }),
573
573
  /* @__PURE__ */ i.jsx(
574
574
  "button",
575
575
  {
576
576
  className: "qr-btn qr-btn-add",
577
- onClick: E,
577
+ onClick: B,
578
578
  style: {
579
579
  backgroundColor: (l == null ? void 0 : l.primaryColor) || "#3b82f6",
580
580
  borderColor: (l == null ? void 0 : l.primaryColor) || "#3b82f6"
@@ -586,7 +586,7 @@ const Ut = {
586
586
  ] })
587
587
  ] }) }) : null;
588
588
  }, ti = ({ isOpen: f, onClose: o, onAddBarcode: a, theme: l }) => {
589
- const [s, h] = N(""), [x, n] = N("CODE128"), [d, j] = N(null), [S, I] = N(2), [y, E] = N(100), [B, b] = N(20), [F, J] = N("center"), [T, O] = N("bottom"), [v, st] = N(10), W = gt(null), xt = [
589
+ const [s, g] = N(""), [h, n] = N("CODE128"), [c, F] = N(null), [I, E] = N(2), [m, B] = N(100), [j, p] = N(20), [v, X] = N("center"), [T, O] = N("bottom"), [k, Z] = N(10), W = gt(null), xt = [
590
590
  { value: "CODE128", label: "CODE128 (Most Common)" },
591
591
  { value: "EAN13", label: "EAN-13 (European Article Number)" },
592
592
  { value: "EAN8", label: "EAN-8 (Short EAN)" },
@@ -599,17 +599,17 @@ const Ut = {
599
599
  ], Q = () => {
600
600
  if (s.trim())
601
601
  try {
602
- j(/* @__PURE__ */ i.jsx(
602
+ F(/* @__PURE__ */ i.jsx(
603
603
  Ye,
604
604
  {
605
605
  value: s,
606
- format: x,
607
- width: S,
608
- height: y,
609
- fontSize: B,
610
- textAlign: F,
606
+ format: h,
607
+ width: I,
608
+ height: m,
609
+ fontSize: j,
610
+ textAlign: v,
611
611
  textPosition: T,
612
- margin: v,
612
+ margin: k,
613
613
  background: "#ffffff",
614
614
  lineColor: "#000000"
615
615
  }
@@ -618,40 +618,40 @@ const Ut = {
618
618
  console.error("Barcode generation error:", M), alert("Invalid data for selected barcode format. Please check your input.");
619
619
  }
620
620
  }, ft = () => {
621
- var M, nt, Z, ct;
622
- if (!(!d || !W.current))
621
+ var M, nt, tt, ct;
622
+ if (!(!c || !W.current))
623
623
  try {
624
624
  const Y = W.current.querySelector("svg");
625
625
  if (!Y) {
626
626
  console.error("No SVG element found in barcode");
627
627
  return;
628
628
  }
629
- const P = document.createElement("canvas"), C = P.getContext("2d"), tt = Y.getBoundingClientRect(), u = ((nt = (M = Y.width) == null ? void 0 : M.baseVal) == null ? void 0 : nt.value) || tt.width || 200, D = ((ct = (Z = Y.height) == null ? void 0 : Z.baseVal) == null ? void 0 : ct.value) || tt.height || 100;
630
- P.width = u, P.height = D;
631
- const L = new XMLSerializer().serializeToString(Y), H = new Blob([L], { type: "image/svg+xml;charset=utf-8" }), G = URL.createObjectURL(H), et = new Image();
632
- et.onload = () => {
633
- C.drawImage(et, 0, 0);
634
- const X = P.toDataURL("image/png"), q = new Image();
629
+ const P = document.createElement("canvas"), C = P.getContext("2d"), et = Y.getBoundingClientRect(), y = ((nt = (M = Y.width) == null ? void 0 : M.baseVal) == null ? void 0 : nt.value) || et.width || 200, D = ((ct = (tt = Y.height) == null ? void 0 : tt.baseVal) == null ? void 0 : ct.value) || et.height || 100;
630
+ P.width = y, P.height = D;
631
+ const L = new XMLSerializer().serializeToString(Y), H = new Blob([L], { type: "image/svg+xml;charset=utf-8" }), G = URL.createObjectURL(H), it = new Image();
632
+ it.onload = () => {
633
+ C.drawImage(it, 0, 0);
634
+ const J = P.toDataURL("image/png"), q = new Image();
635
635
  q.onload = () => {
636
636
  a({
637
637
  type: "barcode",
638
- src: X,
638
+ src: J,
639
639
  data: s,
640
- format: x,
641
- width: u,
640
+ format: h,
641
+ width: y,
642
642
  height: D,
643
643
  x: 100,
644
644
  y: 100,
645
645
  imageObject: q
646
646
  }), _();
647
- }, q.src = X, URL.revokeObjectURL(G);
648
- }, et.src = G;
647
+ }, q.src = J, URL.revokeObjectURL(G);
648
+ }, it.src = G;
649
649
  } catch (Y) {
650
650
  console.error("Error adding barcode to canvas:", Y), alert("Failed to add barcode to canvas. Please try again.");
651
651
  }
652
652
  }, _ = () => {
653
- h(""), j(null), n("CODE128"), I(2), E(100), b(20), o();
654
- }, at = (M) => ({
653
+ g(""), F(null), n("CODE128"), E(2), B(100), p(20), o();
654
+ }, st = (M) => ({
655
655
  CODE128: "Supports all ASCII characters. Most versatile format.",
656
656
  EAN13: "Requires exactly 12 digits (13th is checksum). Used for retail products.",
657
657
  EAN8: "Requires exactly 7 digits (8th is checksum). Compact version of EAN-13.",
@@ -684,7 +684,7 @@ const Ut = {
684
684
  type: "text",
685
685
  id: "barcode-data",
686
686
  value: s,
687
- onChange: (M) => h(M.target.value),
687
+ onChange: (M) => g(M.target.value),
688
688
  placeholder: "Enter your data..."
689
689
  }
690
690
  )
@@ -695,12 +695,12 @@ const Ut = {
695
695
  "select",
696
696
  {
697
697
  id: "barcode-format",
698
- value: x,
698
+ value: h,
699
699
  onChange: (M) => n(M.target.value),
700
700
  children: xt.map((M) => /* @__PURE__ */ i.jsx("option", { value: M.value, children: M.label }, M.value))
701
701
  }
702
702
  ),
703
- /* @__PURE__ */ i.jsx("small", { className: "format-description", children: at(x) })
703
+ /* @__PURE__ */ i.jsx("small", { className: "format-description", children: st(h) })
704
704
  ] }),
705
705
  /* @__PURE__ */ i.jsxs("div", { className: "barcode-options", children: [
706
706
  /* @__PURE__ */ i.jsxs("div", { className: "barcode-form-group", children: [
@@ -713,12 +713,12 @@ const Ut = {
713
713
  min: "1",
714
714
  max: "4",
715
715
  step: "0.5",
716
- value: S,
717
- onChange: (M) => I(parseFloat(M.target.value))
716
+ value: I,
717
+ onChange: (M) => E(parseFloat(M.target.value))
718
718
  }
719
719
  ),
720
720
  /* @__PURE__ */ i.jsxs("span", { className: "range-value", children: [
721
- S,
721
+ I,
722
722
  "px"
723
723
  ] })
724
724
  ] }),
@@ -731,12 +731,12 @@ const Ut = {
731
731
  id: "barcode-height",
732
732
  min: "50",
733
733
  max: "200",
734
- value: y,
735
- onChange: (M) => E(parseInt(M.target.value))
734
+ value: m,
735
+ onChange: (M) => B(parseInt(M.target.value))
736
736
  }
737
737
  ),
738
738
  /* @__PURE__ */ i.jsxs("span", { className: "range-value", children: [
739
- y,
739
+ m,
740
740
  "px"
741
741
  ] })
742
742
  ] }),
@@ -749,12 +749,12 @@ const Ut = {
749
749
  id: "barcode-fontsize",
750
750
  min: "10",
751
751
  max: "30",
752
- value: B,
753
- onChange: (M) => b(parseInt(M.target.value))
752
+ value: j,
753
+ onChange: (M) => p(parseInt(M.target.value))
754
754
  }
755
755
  ),
756
756
  /* @__PURE__ */ i.jsxs("span", { className: "range-value", children: [
757
- B,
757
+ j,
758
758
  "px"
759
759
  ] })
760
760
  ] }),
@@ -783,9 +783,9 @@ const Ut = {
783
783
  children: "Generate Barcode"
784
784
  }
785
785
  ) }),
786
- d && /* @__PURE__ */ i.jsxs("div", { className: "barcode-preview", children: [
786
+ c && /* @__PURE__ */ i.jsxs("div", { className: "barcode-preview", children: [
787
787
  /* @__PURE__ */ i.jsx("h4", { children: "Preview" }),
788
- /* @__PURE__ */ i.jsx("div", { className: "barcode-preview-container", ref: W, children: d }),
788
+ /* @__PURE__ */ i.jsx("div", { className: "barcode-preview-container", ref: W, children: c }),
789
789
  /* @__PURE__ */ i.jsx(
790
790
  "button",
791
791
  {
@@ -864,30 +864,30 @@ const Ut = {
864
864
  100% { transform: rotate(360deg); }
865
865
  }
866
866
  ` })
867
- ] }), ii = ({ isOpen: f, onClose: o, onAddSticker: a, theme: l, apiKey: s, apiEndpoint: h }) => {
868
- const [x, n] = N([]), [d, j] = N(!1), [S, I] = N(null), [y, E] = N(""), [B, b] = N(""), [F, J] = N({});
867
+ ] }), ii = ({ isOpen: f, onClose: o, onAddSticker: a, theme: l, apiKey: s, apiEndpoint: g }) => {
868
+ const [h, n] = N([]), [c, F] = N(!1), [I, E] = N(null), [m, B] = N(""), [j, p] = N(""), [v, X] = N({});
869
869
  gt(null);
870
- const [T, O] = N(!1), [v, st] = N(!1), [W, xt] = N(!1), Q = `${h}/api/v1/designer`;
871
- ot(() => {
870
+ const [T, O] = N(!1), [k, Z] = N(!1), [W, xt] = N(!1), Q = `${g}/api/v1/designer`;
871
+ rt(() => {
872
872
  f && s && ft();
873
873
  }, [f, s]);
874
874
  const ft = async () => {
875
875
  const P = sessionStorage.getItem("apc_x_sub_status");
876
- P === "active" ? (O(!0), st(!0), at()) : P === "inactive" ? (O(!1), st(!0)) : (xt(!0), await _());
876
+ P === "active" ? (O(!0), Z(!0), st()) : P === "inactive" ? (O(!1), Z(!0)) : (xt(!0), await _());
877
877
  }, _ = async () => {
878
878
  if (!s) {
879
- O(!1), st(!0), xt(!1);
879
+ O(!1), Z(!0), xt(!1);
880
880
  return;
881
881
  }
882
882
  const P = `${Q}/get-subscription-status/${s}`;
883
883
  try {
884
- (await oe.get(P)).data.object === "active" ? (sessionStorage.setItem("apc_x_sub_status", "active"), O(!0), at()) : (sessionStorage.setItem("apc_x_sub_status", "inactive"), O(!1));
884
+ (await oe.get(P)).data.object === "active" ? (sessionStorage.setItem("apc_x_sub_status", "active"), O(!0), st()) : (sessionStorage.setItem("apc_x_sub_status", "inactive"), O(!1));
885
885
  } catch (C) {
886
886
  console.error("Subscription check failed:", C), sessionStorage.setItem("apc_x_sub_status", "inactive"), O(!1);
887
887
  } finally {
888
- xt(!1), st(!0);
888
+ xt(!1), Z(!0);
889
889
  }
890
- }, at = async () => {
890
+ }, st = async () => {
891
891
  const P = sessionStorage.getItem("apc_stickers");
892
892
  if (P)
893
893
  try {
@@ -897,18 +897,18 @@ const Ut = {
897
897
  } catch {
898
898
  console.warn("Failed to parse cached stickers, fetching fresh data");
899
899
  }
900
- j(!0), I(null);
900
+ F(!0), E(null);
901
901
  try {
902
902
  const C = await oe.get(`${Q}/get-stickers`);
903
903
  if (C.data && C.data.object && C.data.object.contents) {
904
- const tt = C.data.object.contents;
905
- n(tt), sessionStorage.setItem("apc_stickers", JSON.stringify(tt));
904
+ const et = C.data.object.contents;
905
+ n(et), sessionStorage.setItem("apc_stickers", JSON.stringify(et));
906
906
  } else
907
907
  throw new Error("Invalid response format");
908
908
  } catch (C) {
909
- console.error("Error fetching stickers:", C), I("Failed to load stickers. Please try again.");
909
+ console.error("Error fetching stickers:", C), E("Failed to load stickers. Please try again.");
910
910
  } finally {
911
- j(!1);
911
+ F(!1);
912
912
  }
913
913
  }, M = (P, C) => {
914
914
  a({
@@ -921,31 +921,31 @@ const Ut = {
921
921
  y: 100
922
922
  }), o();
923
923
  }, nt = (P) => {
924
- J((C) => ({
924
+ X((C) => ({
925
925
  ...C,
926
926
  [P]: !C[P]
927
927
  }));
928
- }, Z = (P) => {
928
+ }, tt = (P) => {
929
929
  const C = {};
930
- return P.forEach((tt) => {
931
- const u = tt.name.split("/");
930
+ return P.forEach((et) => {
931
+ const y = et.name.split("/");
932
932
  let D = C;
933
- u.forEach((L, H) => {
934
- D[L] || (D[L] = H === u.length - 1 ? tt : {}), D = D[L];
933
+ y.forEach((L, H) => {
934
+ D[L] || (D[L] = H === y.length - 1 ? et : {}), D = D[L];
935
935
  });
936
936
  }), C;
937
- }, ct = (P, C = "", tt = 0) => /* @__PURE__ */ i.jsx("div", { className: "sticker-tree-level", style: { paddingLeft: `${tt * 15}px` }, children: Object.keys(P).map((u) => {
938
- const D = `${C}/${u}`, L = F[D];
939
- return P[u].type === "image" ? !B || u.toLowerCase().includes(B.toLowerCase()) ? /* @__PURE__ */ i.jsx(
937
+ }, ct = (P, C = "", et = 0) => /* @__PURE__ */ i.jsx("div", { className: "sticker-tree-level", style: { paddingLeft: `${et * 15}px` }, children: Object.keys(P).map((y) => {
938
+ const D = `${C}/${y}`, L = v[D];
939
+ return P[y].type === "image" ? !j || y.toLowerCase().includes(j.toLowerCase()) ? /* @__PURE__ */ i.jsx(
940
940
  "div",
941
941
  {
942
942
  className: "sticker-item",
943
- onClick: () => M(P[u].url, u),
943
+ onClick: () => M(P[y].url, y),
944
944
  children: /* @__PURE__ */ i.jsx("div", { className: "sticker-preview", children: /* @__PURE__ */ i.jsx(
945
945
  "img",
946
946
  {
947
- src: P[u].url,
948
- alt: u,
947
+ src: P[y].url,
948
+ alt: y,
949
949
  loading: "lazy",
950
950
  onError: (G) => {
951
951
  G.target.style.display = "none";
@@ -962,14 +962,14 @@ const Ut = {
962
962
  onClick: () => nt(D),
963
963
  children: [
964
964
  /* @__PURE__ */ i.jsx("span", { className: `expand-icon ${L ? "expanded" : ""}`, children: "▶" }),
965
- /* @__PURE__ */ i.jsx("span", { className: "category-name", children: u })
965
+ /* @__PURE__ */ i.jsx("span", { className: "category-name", children: y })
966
966
  ]
967
967
  }
968
968
  ),
969
- L && ct(P[u], D, tt + 1)
969
+ L && ct(P[y], D, et + 1)
970
970
  ] }, D);
971
- }) }), Y = x.filter(
972
- (P) => !B || P.name.toLowerCase().includes(B.toLowerCase())
971
+ }) }), Y = h.filter(
972
+ (P) => !j || P.name.toLowerCase().includes(j.toLowerCase())
973
973
  );
974
974
  return f ? /* @__PURE__ */ i.jsx("div", { className: "sticker-modal-overlay", onClick: o, children: /* @__PURE__ */ i.jsxs("div", { className: "sticker-modal-content", onClick: (P) => P.stopPropagation(), children: [
975
975
  /* @__PURE__ */ i.jsxs("div", { className: "sticker-modal-header", children: [
@@ -986,24 +986,24 @@ const Ut = {
986
986
  ] }),
987
987
  /* @__PURE__ */ i.jsxs("div", { className: "sticker-modal-body", children: [
988
988
  W && /* @__PURE__ */ i.jsx(le, {}),
989
- !T && !W && v && /* @__PURE__ */ i.jsx(ei, { theme: l }),
990
- T && v && /* @__PURE__ */ i.jsxs(i.Fragment, { children: [
989
+ !T && !W && k && /* @__PURE__ */ i.jsx(ei, { theme: l }),
990
+ T && k && /* @__PURE__ */ i.jsxs(i.Fragment, { children: [
991
991
  /* @__PURE__ */ i.jsx("div", { className: "sticker-modal-controls", children: /* @__PURE__ */ i.jsx("div", { className: "search-container", children: /* @__PURE__ */ i.jsx(
992
992
  "input",
993
993
  {
994
994
  type: "text",
995
995
  placeholder: "Search stickers...",
996
- value: B,
997
- onChange: (P) => b(P.target.value),
996
+ value: j,
997
+ onChange: (P) => p(P.target.value),
998
998
  className: "sticker-search"
999
999
  }
1000
1000
  ) }) }),
1001
- d && /* @__PURE__ */ i.jsx(le, {}),
1002
- S && /* @__PURE__ */ i.jsxs("div", { className: "sticker-error", children: [
1003
- /* @__PURE__ */ i.jsx("p", { children: S }),
1004
- /* @__PURE__ */ i.jsx("button", { onClick: at, children: "Retry" })
1001
+ c && /* @__PURE__ */ i.jsx(le, {}),
1002
+ I && /* @__PURE__ */ i.jsxs("div", { className: "sticker-error", children: [
1003
+ /* @__PURE__ */ i.jsx("p", { children: I }),
1004
+ /* @__PURE__ */ i.jsx("button", { onClick: st, children: "Retry" })
1005
1005
  ] }),
1006
- !d && !S && x.length > 0 && /* @__PURE__ */ i.jsx("div", { className: "sticker-grid", children: ct(Z(Y)) })
1006
+ !c && !I && h.length > 0 && /* @__PURE__ */ i.jsx("div", { className: "sticker-grid", children: ct(tt(Y)) })
1007
1007
  ] })
1008
1008
  ] })
1009
1009
  ] }) }) : null;
@@ -2559,33 +2559,33 @@ const Ut = {
2559
2559
  category: "Geometric",
2560
2560
  description: "Complex mandala flower pattern"
2561
2561
  }
2562
- ], ri = ({ isOpen: f, onClose: o, onAddEmbroidery: a, theme: l, apiKey: s, apiEndpoint: h }) => {
2563
- const [x, n] = N([]), [d, j] = N(!1), [S, I] = N(null), [y, E] = N(""), [B, b] = N("All"), F = gt(null), J = ["All", "Floral", "Nature", "Geometric", "Traditional", "Sports", "Hobbies", "Food", "Symbols", "Holiday", "Text"];
2564
- ot(() => {
2562
+ ], ri = ({ isOpen: f, onClose: o, onAddEmbroidery: a, theme: l, apiKey: s, apiEndpoint: g }) => {
2563
+ const [h, n] = N([]), [c, F] = N(!1), [I, E] = N(null), [m, B] = N(""), [j, p] = N("All"), v = gt(null), X = ["All", "Floral", "Nature", "Geometric", "Traditional", "Sports", "Hobbies", "Food", "Symbols", "Holiday", "Text"];
2564
+ rt(() => {
2565
2565
  f && n(oi);
2566
2566
  }, [f]);
2567
- const T = (v) => {
2567
+ const T = (k) => {
2568
2568
  a({
2569
2569
  type: "embroidery",
2570
- src: v.url,
2571
- name: v.name,
2572
- description: v.description,
2573
- category: v.category,
2570
+ src: k.url,
2571
+ name: k.name,
2572
+ description: k.description,
2573
+ category: k.category,
2574
2574
  width: 120,
2575
2575
  height: 120,
2576
2576
  x: 100,
2577
2577
  y: 100
2578
2578
  }), o();
2579
- }, O = x.filter((v) => {
2580
- const st = !y || v.name.toLowerCase().includes(y.toLowerCase()) || v.description.toLowerCase().includes(y.toLowerCase()), W = B === "All" || v.category === B;
2581
- return st && W;
2579
+ }, O = h.filter((k) => {
2580
+ const Z = !m || k.name.toLowerCase().includes(m.toLowerCase()) || k.description.toLowerCase().includes(m.toLowerCase()), W = j === "All" || k.category === j;
2581
+ return Z && W;
2582
2582
  });
2583
2583
  return f ? /* @__PURE__ */ i.jsx("div", { className: "embroidery-modal-overlay", onClick: o, children: /* @__PURE__ */ i.jsxs(
2584
2584
  "div",
2585
2585
  {
2586
2586
  className: "embroidery-modal-content",
2587
- onClick: (v) => v.stopPropagation(),
2588
- ref: F,
2587
+ onClick: (k) => k.stopPropagation(),
2588
+ ref: v,
2589
2589
  children: [
2590
2590
  /* @__PURE__ */ i.jsxs("div", { className: "embroidery-modal-header", children: [
2591
2591
  /* @__PURE__ */ i.jsx("h3", { children: "Choose an Embroidery Design" }),
@@ -2605,8 +2605,8 @@ const Ut = {
2605
2605
  {
2606
2606
  type: "text",
2607
2607
  placeholder: "Search embroidery designs...",
2608
- value: y,
2609
- onChange: (v) => E(v.target.value),
2608
+ value: m,
2609
+ onChange: (k) => B(k.target.value),
2610
2610
  className: "embroidery-search"
2611
2611
  }
2612
2612
  ) }),
@@ -2615,47 +2615,47 @@ const Ut = {
2615
2615
  /* @__PURE__ */ i.jsx(
2616
2616
  "select",
2617
2617
  {
2618
- value: B,
2619
- onChange: (v) => b(v.target.value),
2618
+ value: j,
2619
+ onChange: (k) => p(k.target.value),
2620
2620
  className: "category-select",
2621
- children: J.map((v) => /* @__PURE__ */ i.jsx("option", { value: v, children: v }, v))
2621
+ children: X.map((k) => /* @__PURE__ */ i.jsx("option", { value: k, children: k }, k))
2622
2622
  }
2623
2623
  )
2624
2624
  ] })
2625
2625
  ] }),
2626
2626
  /* @__PURE__ */ i.jsxs("div", { className: "embroidery-modal-body", children: [
2627
- d && /* @__PURE__ */ i.jsxs("div", { className: "embroidery-loading", children: [
2627
+ c && /* @__PURE__ */ i.jsxs("div", { className: "embroidery-loading", children: [
2628
2628
  /* @__PURE__ */ i.jsx("div", { className: "loading-spinner" }),
2629
2629
  /* @__PURE__ */ i.jsx("p", { children: "Loading embroidery designs..." })
2630
2630
  ] }),
2631
- S && /* @__PURE__ */ i.jsx("div", { className: "embroidery-error", children: /* @__PURE__ */ i.jsx("p", { children: S }) }),
2632
- !d && !S && /* @__PURE__ */ i.jsx("div", { className: "embroidery-grid", children: O.map((v) => /* @__PURE__ */ i.jsxs(
2631
+ I && /* @__PURE__ */ i.jsx("div", { className: "embroidery-error", children: /* @__PURE__ */ i.jsx("p", { children: I }) }),
2632
+ !c && !I && /* @__PURE__ */ i.jsx("div", { className: "embroidery-grid", children: O.map((k) => /* @__PURE__ */ i.jsxs(
2633
2633
  "div",
2634
2634
  {
2635
2635
  className: "embroidery-item",
2636
- onClick: () => T(v),
2637
- title: v.description,
2636
+ onClick: () => T(k),
2637
+ title: k.description,
2638
2638
  children: [
2639
2639
  /* @__PURE__ */ i.jsx("div", { className: "embroidery-preview", children: /* @__PURE__ */ i.jsx(
2640
2640
  "img",
2641
2641
  {
2642
- src: v.url,
2643
- alt: v.name,
2642
+ src: k.url,
2643
+ alt: k.name,
2644
2644
  loading: "lazy",
2645
- onError: (st) => {
2646
- console.error("Failed to load embroidery image:", v.url), st.target.style.display = "none";
2645
+ onError: (Z) => {
2646
+ console.error("Failed to load embroidery image:", k.url), Z.target.style.display = "none";
2647
2647
  }
2648
2648
  }
2649
2649
  ) }),
2650
2650
  /* @__PURE__ */ i.jsxs("div", { className: "embroidery-info", children: [
2651
- /* @__PURE__ */ i.jsx("div", { className: "embroidery-name", children: v.name }),
2652
- /* @__PURE__ */ i.jsx("div", { className: "embroidery-category", children: v.category })
2651
+ /* @__PURE__ */ i.jsx("div", { className: "embroidery-name", children: k.name }),
2652
+ /* @__PURE__ */ i.jsx("div", { className: "embroidery-category", children: k.category })
2653
2653
  ] })
2654
2654
  ]
2655
2655
  },
2656
- v.id
2656
+ k.id
2657
2657
  )) }),
2658
- !d && !S && O.length === 0 && /* @__PURE__ */ i.jsx("div", { className: "no-embroideries", children: /* @__PURE__ */ i.jsx("p", { children: "No embroidery designs found matching your search." }) })
2658
+ !c && !I && O.length === 0 && /* @__PURE__ */ i.jsx("div", { className: "no-embroideries", children: /* @__PURE__ */ i.jsx("p", { children: "No embroidery designs found matching your search." }) })
2659
2659
  ] }),
2660
2660
  /* @__PURE__ */ i.jsx("div", { className: "embroidery-modal-footer", children: /* @__PURE__ */ i.jsxs("div", { className: "embroidery-disclaimer", children: [
2661
2661
  /* @__PURE__ */ i.jsx("span", { className: "disclaimer-icon", children: "ℹ️" }),
@@ -4602,23 +4602,23 @@ const Ut = {
4602
4602
  textAlign: "center"
4603
4603
  }
4604
4604
  ], ai = ({ isOpen: f, onClose: o, onAddText: a, theme: l }) => {
4605
- const [s, h] = N(""), [x, n] = N("All"), d = ie(() => {
4606
- const y = Nt.reduce((E, B) => (E[B.category] = (E[B.category] || 0) + 1, E), {});
4605
+ const [s, g] = N(""), [h, n] = N("All"), c = ie(() => {
4606
+ const m = Nt.reduce((B, j) => (B[j.category] = (B[j.category] || 0) + 1, B), {});
4607
4607
  return [
4608
4608
  { name: "All", count: Nt.length },
4609
- ...Object.entries(y).map(([E, B]) => ({ name: E, count: B }))
4609
+ ...Object.entries(m).map(([B, j]) => ({ name: B, count: j }))
4610
4610
  ];
4611
- }, [Nt]), j = ie(() => Nt.filter((y) => {
4612
- const E = !s || y.text.toLowerCase().includes(s.toLowerCase()) || y.category.toLowerCase().includes(s.toLowerCase()), B = x === "All" || y.category === x;
4613
- return E && B;
4614
- }), [Nt, s, x]), S = (y) => {
4615
- const E = {
4616
- ...y,
4611
+ }, [Nt]), F = ie(() => Nt.filter((m) => {
4612
+ const B = !s || m.text.toLowerCase().includes(s.toLowerCase()) || m.category.toLowerCase().includes(s.toLowerCase()), j = h === "All" || m.category === h;
4613
+ return B && j;
4614
+ }), [Nt, s, h]), I = (m) => {
4615
+ const B = {
4616
+ ...m,
4617
4617
  x: 100,
4618
4618
  y: 100
4619
4619
  };
4620
- a("text", E), o();
4621
- }, I = () => {
4620
+ a("text", B), o();
4621
+ }, E = () => {
4622
4622
  a("text", {
4623
4623
  text: "Your Text Here",
4624
4624
  fontSize: 24,
@@ -4628,7 +4628,7 @@ const Ut = {
4628
4628
  y: 100
4629
4629
  }), o();
4630
4630
  };
4631
- return f ? /* @__PURE__ */ i.jsx("div", { className: "text-templates-modal-overlay", onClick: o, children: /* @__PURE__ */ i.jsxs("div", { className: "text-templates-modal", onClick: (y) => y.stopPropagation(), children: [
4631
+ return f ? /* @__PURE__ */ i.jsx("div", { className: "text-templates-modal-overlay", onClick: o, children: /* @__PURE__ */ i.jsxs("div", { className: "text-templates-modal", onClick: (m) => m.stopPropagation(), children: [
4632
4632
  /* @__PURE__ */ i.jsxs("div", { className: "modal-header", children: [
4633
4633
  /* @__PURE__ */ i.jsx("h2", { children: "Text Templates" }),
4634
4634
  /* @__PURE__ */ i.jsx("button", { className: "close-btn", onClick: o, "aria-label": "Close", children: "×" })
@@ -4640,70 +4640,70 @@ const Ut = {
4640
4640
  type: "text",
4641
4641
  placeholder: "Search templates...",
4642
4642
  value: s,
4643
- onChange: (y) => h(y.target.value),
4643
+ onChange: (m) => g(m.target.value),
4644
4644
  className: "search-input"
4645
4645
  }
4646
4646
  ) }),
4647
- /* @__PURE__ */ i.jsx("div", { className: "category-tabs", children: d.map((y) => /* @__PURE__ */ i.jsxs(
4647
+ /* @__PURE__ */ i.jsx("div", { className: "category-tabs", children: c.map((m) => /* @__PURE__ */ i.jsxs(
4648
4648
  "button",
4649
4649
  {
4650
- className: `category-tab ${x === y.name ? "active" : ""}`,
4651
- onClick: () => n(y.name),
4650
+ className: `category-tab ${h === m.name ? "active" : ""}`,
4651
+ onClick: () => n(m.name),
4652
4652
  children: [
4653
- y.name,
4653
+ m.name,
4654
4654
  /* @__PURE__ */ i.jsxs("span", { className: "count", children: [
4655
4655
  "(",
4656
- y.count,
4656
+ m.count,
4657
4657
  ")"
4658
4658
  ] })
4659
4659
  ]
4660
4660
  },
4661
- y.name
4661
+ m.name
4662
4662
  )) })
4663
4663
  ] }),
4664
4664
  /* @__PURE__ */ i.jsxs("div", { className: "templates-grid", children: [
4665
- /* @__PURE__ */ i.jsx("div", { className: "custom-text-option", onClick: I, children: /* @__PURE__ */ i.jsxs("div", { className: "custom-text-preview", children: [
4665
+ /* @__PURE__ */ i.jsx("div", { className: "custom-text-option", onClick: E, children: /* @__PURE__ */ i.jsxs("div", { className: "custom-text-preview", children: [
4666
4666
  /* @__PURE__ */ i.jsx("div", { className: "custom-icon", children: "✏️" }),
4667
4667
  /* @__PURE__ */ i.jsx("div", { className: "custom-label", children: "Create Custom Text" })
4668
4668
  ] }) }),
4669
- j.map((y) => /* @__PURE__ */ i.jsxs(
4669
+ F.map((m) => /* @__PURE__ */ i.jsxs(
4670
4670
  "div",
4671
4671
  {
4672
4672
  className: "template-item",
4673
- onClick: () => S(y),
4673
+ onClick: () => I(m),
4674
4674
  children: [
4675
4675
  /* @__PURE__ */ i.jsx(
4676
4676
  "div",
4677
4677
  {
4678
4678
  className: "template-preview",
4679
4679
  style: {
4680
- fontFamily: y.fontFamily,
4681
- fontSize: `${Math.min(y.fontSize * 0.6, 18)}px`,
4682
- fontWeight: y.fontWeight,
4683
- fontStyle: y.fontStyle,
4684
- color: y.fill,
4685
- backgroundColor: y.hasBackground ? y.backgroundColor : "transparent",
4686
- textAlign: y.textAlign || "left",
4687
- textTransform: y.textTransform || "none",
4688
- letterSpacing: y.letterSpacing ? `${y.letterSpacing}px` : "normal",
4689
- textShadow: y.hasTextShadow ? `${y.textShadowX}px ${y.textShadowY}px ${y.textShadowBlur}px ${y.textShadowColor}` : "none"
4680
+ fontFamily: m.fontFamily,
4681
+ fontSize: `${Math.min(m.fontSize * 0.6, 18)}px`,
4682
+ fontWeight: m.fontWeight,
4683
+ fontStyle: m.fontStyle,
4684
+ color: m.fill,
4685
+ backgroundColor: m.hasBackground ? m.backgroundColor : "transparent",
4686
+ textAlign: m.textAlign || "left",
4687
+ textTransform: m.textTransform || "none",
4688
+ letterSpacing: m.letterSpacing ? `${m.letterSpacing}px` : "normal",
4689
+ textShadow: m.hasTextShadow ? `${m.textShadowX}px ${m.textShadowY}px ${m.textShadowBlur}px ${m.textShadowColor}` : "none"
4690
4690
  },
4691
- children: y.text
4691
+ children: m.text
4692
4692
  }
4693
4693
  ),
4694
4694
  /* @__PURE__ */ i.jsxs("div", { className: "template-info", children: [
4695
- /* @__PURE__ */ i.jsx("span", { className: "template-category", children: y.category }),
4696
- /* @__PURE__ */ i.jsx("span", { className: "template-font", children: y.fontFamily })
4695
+ /* @__PURE__ */ i.jsx("span", { className: "template-category", children: m.category }),
4696
+ /* @__PURE__ */ i.jsx("span", { className: "template-font", children: m.fontFamily })
4697
4697
  ] })
4698
4698
  ]
4699
4699
  },
4700
- y.id
4700
+ m.id
4701
4701
  ))
4702
4702
  ] }),
4703
4703
  /* @__PURE__ */ i.jsx("div", { className: "modal-footer", children: /* @__PURE__ */ i.jsxs("div", { className: "results-count", children: [
4704
- j.length,
4704
+ F.length,
4705
4705
  " template",
4706
- j.length !== 1 ? "s" : "",
4706
+ F.length !== 1 ? "s" : "",
4707
4707
  " found"
4708
4708
  ] }) })
4709
4709
  ] }) }) : null;
@@ -4713,24 +4713,24 @@ const Ut = {
4713
4713
  onDuplicateElement: a,
4714
4714
  onUndo: l,
4715
4715
  onRedo: s,
4716
- onToggleGrid: h,
4717
- onToggleRulers: x,
4716
+ onToggleGrid: g,
4717
+ onToggleRulers: h,
4718
4718
  onToggleSnap: n,
4719
- onImageUpload: d,
4720
- canUndo: j,
4721
- canRedo: S,
4722
- showGrid: I,
4723
- showRulers: y,
4724
- snapToGrid: E,
4725
- selectedElement: B,
4726
- theme: b,
4727
- readOnly: F,
4728
- apiKey: J,
4719
+ onImageUpload: c,
4720
+ canUndo: F,
4721
+ canRedo: I,
4722
+ showGrid: E,
4723
+ showRulers: m,
4724
+ snapToGrid: B,
4725
+ selectedElement: j,
4726
+ theme: p,
4727
+ readOnly: v,
4728
+ apiKey: X,
4729
4729
  apiEndpoint: T
4730
4730
  }) => {
4731
- const [O, v] = N(!1), [st, W] = N(!1), [xt, Q] = N(!1), [ft, _] = N(!1), [at, M] = N(!1), [nt, Z] = N(!1), [ct, Y] = N(!1), P = (U) => {
4731
+ const [O, k] = N(!1), [Z, W] = N(!1), [xt, Q] = N(!1), [ft, _] = N(!1), [st, M] = N(!1), [nt, tt] = N(!1), [ct, Y] = N(!1), P = (U) => {
4732
4732
  const K = U.target.files[0];
4733
- K && K.type.startsWith("image/") && d(K), U.target.value = "";
4733
+ K && K.type.startsWith("image/") && c(K), U.target.value = "";
4734
4734
  }, C = (U) => {
4735
4735
  f("icon", {
4736
4736
  iconData: U,
@@ -4739,9 +4739,9 @@ const Ut = {
4739
4739
  fontFamily: "Arial",
4740
4740
  fill: "#000000"
4741
4741
  });
4742
- }, tt = (U) => {
4742
+ }, et = (U) => {
4743
4743
  f("qrcode", U);
4744
- }, u = (U) => {
4744
+ }, y = (U) => {
4745
4745
  f("barcode", U);
4746
4746
  }, D = (U) => {
4747
4747
  f("sticker", U);
@@ -4750,11 +4750,11 @@ const Ut = {
4750
4750
  }, H = (U, K) => {
4751
4751
  f(U, K);
4752
4752
  }, G = () => {
4753
- Z(!nt), Y(!1);
4754
- }, et = () => {
4755
- Y(!ct), Z(!1);
4756
- }, X = (U) => {
4757
- U === "custom" ? f("text") : U === "templates" && M(!0), Z(!1);
4753
+ tt(!nt), Y(!1);
4754
+ }, it = () => {
4755
+ Y(!ct), tt(!1);
4756
+ }, J = (U) => {
4757
+ U === "custom" ? f("text") : U === "templates" && M(!0), tt(!1);
4758
4758
  }, q = (U) => {
4759
4759
  f(U), Y(!1);
4760
4760
  };
@@ -4766,7 +4766,7 @@ const Ut = {
4766
4766
  {
4767
4767
  className: "toolbar-btn compact",
4768
4768
  onClick: l,
4769
- disabled: !j || F,
4769
+ disabled: !F || v,
4770
4770
  title: "Undo (Ctrl+Z)",
4771
4771
  children: [
4772
4772
  /* @__PURE__ */ i.jsx("span", { className: "icon", children: "↶" }),
@@ -4779,7 +4779,7 @@ const Ut = {
4779
4779
  {
4780
4780
  className: "toolbar-btn compact",
4781
4781
  onClick: s,
4782
- disabled: !S || F,
4782
+ disabled: !I || v,
4783
4783
  title: "Redo (Ctrl+Y)",
4784
4784
  children: [
4785
4785
  /* @__PURE__ */ i.jsx("span", { className: "icon", children: "↷" }),
@@ -4795,7 +4795,7 @@ const Ut = {
4795
4795
  "button",
4796
4796
  {
4797
4797
  className: "toolbar-btn compact dropdown-trigger",
4798
- disabled: F,
4798
+ disabled: v,
4799
4799
  title: "Add Text",
4800
4800
  onClick: G,
4801
4801
  children: [
@@ -4806,11 +4806,11 @@ const Ut = {
4806
4806
  }
4807
4807
  ),
4808
4808
  /* @__PURE__ */ i.jsxs("div", { className: `dropdown-menu ${nt ? "show" : ""}`, children: [
4809
- /* @__PURE__ */ i.jsxs("button", { onClick: () => X("custom"), children: [
4809
+ /* @__PURE__ */ i.jsxs("button", { onClick: () => J("custom"), children: [
4810
4810
  /* @__PURE__ */ i.jsx("span", { className: "icon", children: "𝐓" }),
4811
4811
  " Custom Text"
4812
4812
  ] }),
4813
- /* @__PURE__ */ i.jsxs("button", { onClick: () => X("templates"), children: [
4813
+ /* @__PURE__ */ i.jsxs("button", { onClick: () => J("templates"), children: [
4814
4814
  /* @__PURE__ */ i.jsx("span", { className: "icon", children: "📝" }),
4815
4815
  " Text Templates"
4816
4816
  ] })
@@ -4821,8 +4821,8 @@ const Ut = {
4821
4821
  "button",
4822
4822
  {
4823
4823
  className: "toolbar-btn compact dropdown-trigger",
4824
- disabled: F,
4825
- onClick: et,
4824
+ disabled: v,
4825
+ onClick: it,
4826
4826
  children: [
4827
4827
  /* @__PURE__ */ i.jsx("span", { className: "icon", children: "◩" }),
4828
4828
  /* @__PURE__ */ i.jsx("span", { className: "label", children: "Shapes" }),
@@ -4882,7 +4882,7 @@ const Ut = {
4882
4882
  ] })
4883
4883
  ] }),
4884
4884
  /* @__PURE__ */ i.jsx("div", { className: "toolbar-separator" }),
4885
- /* @__PURE__ */ i.jsxs("label", { className: "toolbar-btn compact file-upload", style: { cursor: F ? "not-allowed" : "pointer" }, children: [
4885
+ /* @__PURE__ */ i.jsxs("label", { className: "toolbar-btn compact file-upload", style: { cursor: v ? "not-allowed" : "pointer" }, children: [
4886
4886
  /* @__PURE__ */ i.jsx("span", { className: "icon", children: "☁️" }),
4887
4887
  /* @__PURE__ */ i.jsx("span", { className: "label", children: "Upload" }),
4888
4888
  /* @__PURE__ */ i.jsx(
@@ -4891,18 +4891,18 @@ const Ut = {
4891
4891
  type: "file",
4892
4892
  accept: "image/*",
4893
4893
  onChange: P,
4894
- disabled: F
4894
+ disabled: v
4895
4895
  }
4896
4896
  )
4897
4897
  ] }),
4898
4898
  /* @__PURE__ */ i.jsx("div", { className: "toolbar-separator" }),
4899
- /* @__PURE__ */ i.jsx(Ke, { onSelectIcon: C, theme: b, disabled: F }),
4899
+ /* @__PURE__ */ i.jsx(Ke, { onSelectIcon: C, theme: p, disabled: v }),
4900
4900
  /* @__PURE__ */ i.jsxs(
4901
4901
  "button",
4902
4902
  {
4903
4903
  className: "toolbar-btn compact",
4904
4904
  onClick: () => Q(!0),
4905
- disabled: F,
4905
+ disabled: v,
4906
4906
  title: "Add Sticker",
4907
4907
  children: [
4908
4908
  /* @__PURE__ */ i.jsx("span", { className: "icon", children: "🎨" }),
@@ -4915,8 +4915,8 @@ const Ut = {
4915
4915
  "button",
4916
4916
  {
4917
4917
  className: "toolbar-btn compact",
4918
- onClick: () => v(!0),
4919
- disabled: F,
4918
+ onClick: () => k(!0),
4919
+ disabled: v,
4920
4920
  title: "Add QR Code",
4921
4921
  children: [
4922
4922
  /* @__PURE__ */ i.jsx("span", { className: "icon", children: "▦" }),
@@ -4929,7 +4929,7 @@ const Ut = {
4929
4929
  {
4930
4930
  className: "toolbar-btn compact",
4931
4931
  onClick: () => W(!0),
4932
- disabled: F,
4932
+ disabled: v,
4933
4933
  title: "Add Barcode",
4934
4934
  children: [
4935
4935
  /* @__PURE__ */ i.jsx("span", { className: "icon", children: "▤" }),
@@ -4944,7 +4944,7 @@ const Ut = {
4944
4944
  {
4945
4945
  className: "toolbar-btn compact",
4946
4946
  onClick: () => _(!0),
4947
- disabled: F,
4947
+ disabled: v,
4948
4948
  title: "Add Embroidery Design",
4949
4949
  children: [
4950
4950
  /* @__PURE__ */ i.jsx("span", { className: "icon", children: "🧵" }),
@@ -4952,7 +4952,7 @@ const Ut = {
4952
4952
  ]
4953
4953
  }
4954
4954
  ) }),
4955
- B && /* @__PURE__ */ i.jsxs(i.Fragment, { children: [
4955
+ j && /* @__PURE__ */ i.jsxs(i.Fragment, { children: [
4956
4956
  /* @__PURE__ */ i.jsx("div", { className: "toolbar-separator" }),
4957
4957
  /* @__PURE__ */ i.jsxs("div", { className: "toolbar-group", children: [
4958
4958
  /* @__PURE__ */ i.jsxs(
@@ -4960,7 +4960,7 @@ const Ut = {
4960
4960
  {
4961
4961
  className: "toolbar-btn compact success",
4962
4962
  onClick: a,
4963
- disabled: F,
4963
+ disabled: v,
4964
4964
  title: "Duplicate Element (Ctrl+D)",
4965
4965
  children: [
4966
4966
  /* @__PURE__ */ i.jsx("span", { className: "icon", children: "⧉" }),
@@ -4973,7 +4973,7 @@ const Ut = {
4973
4973
  {
4974
4974
  className: "toolbar-btn compact danger",
4975
4975
  onClick: o,
4976
- disabled: F,
4976
+ disabled: v,
4977
4977
  title: "Delete Element (Delete)",
4978
4978
  children: [
4979
4979
  /* @__PURE__ */ i.jsx("span", { className: "icon", children: "🗑️" }),
@@ -4988,8 +4988,8 @@ const Ut = {
4988
4988
  /* @__PURE__ */ i.jsxs(
4989
4989
  "button",
4990
4990
  {
4991
- className: `toolbar-btn compact ${I ? "active" : ""}`,
4992
- onClick: h,
4991
+ className: `toolbar-btn compact ${E ? "active" : ""}`,
4992
+ onClick: g,
4993
4993
  title: "Toggle Grid",
4994
4994
  children: [
4995
4995
  /* @__PURE__ */ i.jsx("span", { className: "icon", children: "⚏" }),
@@ -5000,8 +5000,8 @@ const Ut = {
5000
5000
  /* @__PURE__ */ i.jsxs(
5001
5001
  "button",
5002
5002
  {
5003
- className: `toolbar-btn compact ${y ? "active" : ""}`,
5004
- onClick: x,
5003
+ className: `toolbar-btn compact ${m ? "active" : ""}`,
5004
+ onClick: h,
5005
5005
  title: "Toggle Rulers",
5006
5006
  children: [
5007
5007
  /* @__PURE__ */ i.jsx("span", { className: "icon", children: "📐" }),
@@ -5012,7 +5012,7 @@ const Ut = {
5012
5012
  /* @__PURE__ */ i.jsxs(
5013
5013
  "button",
5014
5014
  {
5015
- className: `toolbar-btn compact ${E ? "active" : ""}`,
5015
+ className: `toolbar-btn compact ${B ? "active" : ""}`,
5016
5016
  onClick: n,
5017
5017
  title: "Snap to Grid",
5018
5018
  children: [
@@ -5027,18 +5027,18 @@ const Ut = {
5027
5027
  Ze,
5028
5028
  {
5029
5029
  isOpen: O,
5030
- onClose: () => v(!1),
5031
- onAddQRCode: tt,
5032
- theme: b
5030
+ onClose: () => k(!1),
5031
+ onAddQRCode: et,
5032
+ theme: p
5033
5033
  }
5034
5034
  ),
5035
5035
  /* @__PURE__ */ i.jsx(
5036
5036
  ti,
5037
5037
  {
5038
- isOpen: st,
5038
+ isOpen: Z,
5039
5039
  onClose: () => W(!1),
5040
- onAddBarcode: u,
5041
- theme: b
5040
+ onAddBarcode: y,
5041
+ theme: p
5042
5042
  }
5043
5043
  ),
5044
5044
  /* @__PURE__ */ i.jsx(
@@ -5047,8 +5047,8 @@ const Ut = {
5047
5047
  isOpen: xt,
5048
5048
  onClose: () => Q(!1),
5049
5049
  onAddSticker: D,
5050
- theme: b,
5051
- apiKey: J,
5050
+ theme: p,
5051
+ apiKey: X,
5052
5052
  apiEndpoint: T
5053
5053
  }
5054
5054
  ),
@@ -5058,18 +5058,18 @@ const Ut = {
5058
5058
  isOpen: ft,
5059
5059
  onClose: () => _(!1),
5060
5060
  onAddEmbroidery: L,
5061
- theme: b,
5062
- apiKey: J,
5061
+ theme: p,
5062
+ apiKey: X,
5063
5063
  apiEndpoint: T
5064
5064
  }
5065
5065
  ),
5066
5066
  /* @__PURE__ */ i.jsx(
5067
5067
  ai,
5068
5068
  {
5069
- isOpen: at,
5069
+ isOpen: st,
5070
5070
  onClose: () => M(!1),
5071
5071
  onAddText: H,
5072
- theme: b
5072
+ theme: p
5073
5073
  }
5074
5074
  )
5075
5075
  ] });
@@ -5080,16 +5080,16 @@ const Ut = {
5080
5080
  availableFonts: l,
5081
5081
  theme: s
5082
5082
  }) => {
5083
- const [h, x] = N(!1);
5083
+ const [g, h] = N(!1);
5084
5084
  if (!f)
5085
5085
  return /* @__PURE__ */ i.jsxs("div", { className: "properties-panel", children: [
5086
5086
  /* @__PURE__ */ i.jsx("h3", { children: "Properties" }),
5087
5087
  /* @__PURE__ */ i.jsx("p", { className: "no-selection", children: "Select an element to edit its properties" })
5088
5088
  ] });
5089
- const n = (b, F) => {
5090
- o(f.id, { [b]: F });
5091
- }, d = () => {
5092
- var b, F, J;
5089
+ const n = (p, v) => {
5090
+ o(f.id, { [p]: v });
5091
+ }, c = () => {
5092
+ var p, v, X;
5093
5093
  return /* @__PURE__ */ i.jsxs("div", { className: "property-group", children: [
5094
5094
  /* @__PURE__ */ i.jsx("h4", { children: "Text Content" }),
5095
5095
  /* @__PURE__ */ i.jsxs("div", { className: "property-row", children: [
@@ -5191,9 +5191,9 @@ const Ut = {
5191
5191
  /* @__PURE__ */ i.jsx(
5192
5192
  "button",
5193
5193
  {
5194
- className: (b = f.textDecoration) != null && b.includes("underline") ? "active" : "",
5194
+ className: (p = f.textDecoration) != null && p.includes("underline") ? "active" : "",
5195
5195
  onClick: () => {
5196
- const T = f.textDecoration || "", O = T.split(" ").filter((v) => v && v !== "underline");
5196
+ const T = f.textDecoration || "", O = T.split(" ").filter((k) => k && k !== "underline");
5197
5197
  T.includes("underline") || O.push("underline"), n("textDecoration", O.join(" ").trim());
5198
5198
  },
5199
5199
  title: "Underline",
@@ -5203,9 +5203,9 @@ const Ut = {
5203
5203
  /* @__PURE__ */ i.jsx(
5204
5204
  "button",
5205
5205
  {
5206
- className: (F = f.textDecoration) != null && F.includes("overline") ? "active" : "",
5206
+ className: (v = f.textDecoration) != null && v.includes("overline") ? "active" : "",
5207
5207
  onClick: () => {
5208
- const T = f.textDecoration || "", O = T.split(" ").filter((v) => v && v !== "overline");
5208
+ const T = f.textDecoration || "", O = T.split(" ").filter((k) => k && k !== "overline");
5209
5209
  T.includes("overline") || O.push("overline"), n("textDecoration", O.join(" ").trim());
5210
5210
  },
5211
5211
  title: "Overline",
@@ -5215,9 +5215,9 @@ const Ut = {
5215
5215
  /* @__PURE__ */ i.jsx(
5216
5216
  "button",
5217
5217
  {
5218
- className: (J = f.textDecoration) != null && J.includes("line-through") ? "active" : "",
5218
+ className: (X = f.textDecoration) != null && X.includes("line-through") ? "active" : "",
5219
5219
  onClick: () => {
5220
- const T = f.textDecoration || "", O = T.split(" ").filter((v) => v && v !== "line-through");
5220
+ const T = f.textDecoration || "", O = T.split(" ").filter((k) => k && k !== "line-through");
5221
5221
  T.includes("line-through") || O.push("line-through"), n("textDecoration", O.join(" ").trim());
5222
5222
  },
5223
5223
  title: "Strikethrough",
@@ -5344,7 +5344,7 @@ const Ut = {
5344
5344
  ] })
5345
5345
  ] })
5346
5346
  ] }) }),
5347
- h && /* @__PURE__ */ i.jsxs(i.Fragment, { children: [
5347
+ g && /* @__PURE__ */ i.jsxs(i.Fragment, { children: [
5348
5348
  /* @__PURE__ */ i.jsxs("div", { className: "property-row", children: [
5349
5349
  /* @__PURE__ */ i.jsxs("div", { className: "input-group", children: [
5350
5350
  /* @__PURE__ */ i.jsx("label", { children: "Letter Spacing" }),
@@ -5552,7 +5552,7 @@ const Ut = {
5552
5552
  ] })
5553
5553
  ] })
5554
5554
  ] });
5555
- }, j = () => /* @__PURE__ */ i.jsxs("div", { className: "property-group", children: [
5555
+ }, F = () => /* @__PURE__ */ i.jsxs("div", { className: "property-group", children: [
5556
5556
  /* @__PURE__ */ i.jsx("h4", { children: "Shape Properties" }),
5557
5557
  /* @__PURE__ */ i.jsxs("div", { className: "property-row", children: [
5558
5558
  /* @__PURE__ */ i.jsx("label", { children: "Fill Color" }),
@@ -5561,7 +5561,7 @@ const Ut = {
5561
5561
  {
5562
5562
  type: "color",
5563
5563
  value: f.fill || "#000000",
5564
- onChange: (b) => n("fill", b.target.value)
5564
+ onChange: (p) => n("fill", p.target.value)
5565
5565
  }
5566
5566
  )
5567
5567
  ] }),
@@ -5572,7 +5572,7 @@ const Ut = {
5572
5572
  {
5573
5573
  type: "color",
5574
5574
  value: f.stroke || "#000000",
5575
- onChange: (b) => n("stroke", b.target.value)
5575
+ onChange: (p) => n("stroke", p.target.value)
5576
5576
  }
5577
5577
  )
5578
5578
  ] }),
@@ -5583,7 +5583,7 @@ const Ut = {
5583
5583
  {
5584
5584
  type: "number",
5585
5585
  value: f.strokeWidth || 2,
5586
- onChange: (b) => n("strokeWidth", parseInt(b.target.value)),
5586
+ onChange: (p) => n("strokeWidth", parseInt(p.target.value)),
5587
5587
  min: "0",
5588
5588
  max: "20"
5589
5589
  }
@@ -5596,7 +5596,7 @@ const Ut = {
5596
5596
  {
5597
5597
  type: "number",
5598
5598
  value: f.numPoints || 5,
5599
- onChange: (b) => n("numPoints", parseInt(b.target.value)),
5599
+ onChange: (p) => n("numPoints", parseInt(p.target.value)),
5600
5600
  min: "3",
5601
5601
  max: "20"
5602
5602
  }
@@ -5609,13 +5609,13 @@ const Ut = {
5609
5609
  {
5610
5610
  type: "number",
5611
5611
  value: f.cornerRadius || 10,
5612
- onChange: (b) => n("cornerRadius", parseInt(b.target.value)),
5612
+ onChange: (p) => n("cornerRadius", parseInt(p.target.value)),
5613
5613
  min: "0",
5614
5614
  max: "50"
5615
5615
  }
5616
5616
  )
5617
5617
  ] })
5618
- ] }), S = () => /* @__PURE__ */ i.jsxs("div", { className: "property-group", children: [
5618
+ ] }), I = () => /* @__PURE__ */ i.jsxs("div", { className: "property-group", children: [
5619
5619
  /* @__PURE__ */ i.jsx("h4", { children: "Image Properties" }),
5620
5620
  /* @__PURE__ */ i.jsxs("div", { className: "property-row", children: [
5621
5621
  /* @__PURE__ */ i.jsx("label", { children: "Opacity" }),
@@ -5627,7 +5627,7 @@ const Ut = {
5627
5627
  max: "1",
5628
5628
  step: "0.1",
5629
5629
  value: f.opacity || 1,
5630
- onChange: (b) => n("opacity", parseFloat(b.target.value))
5630
+ onChange: (p) => n("opacity", parseFloat(p.target.value))
5631
5631
  }
5632
5632
  ),
5633
5633
  /* @__PURE__ */ i.jsxs("span", { children: [
@@ -5635,20 +5635,20 @@ const Ut = {
5635
5635
  "%"
5636
5636
  ] })
5637
5637
  ] }),
5638
- h && /* @__PURE__ */ i.jsxs("div", { className: "property-row", children: [
5638
+ g && /* @__PURE__ */ i.jsxs("div", { className: "property-row", children: [
5639
5639
  /* @__PURE__ */ i.jsx("label", { children: "Border Radius" }),
5640
5640
  /* @__PURE__ */ i.jsx(
5641
5641
  "input",
5642
5642
  {
5643
5643
  type: "number",
5644
5644
  value: f.borderRadius || 0,
5645
- onChange: (b) => n("borderRadius", parseInt(b.target.value)),
5645
+ onChange: (p) => n("borderRadius", parseInt(p.target.value)),
5646
5646
  min: "0",
5647
5647
  max: "50"
5648
5648
  }
5649
5649
  )
5650
5650
  ] })
5651
- ] }), I = () => /* @__PURE__ */ i.jsxs("div", { className: "property-group", children: [
5651
+ ] }), E = () => /* @__PURE__ */ i.jsxs("div", { className: "property-group", children: [
5652
5652
  /* @__PURE__ */ i.jsx("h4", { children: "Position & Size" }),
5653
5653
  /* @__PURE__ */ i.jsxs("div", { className: "property-row", children: [
5654
5654
  /* @__PURE__ */ i.jsxs("div", { className: "input-group", children: [
@@ -5658,7 +5658,7 @@ const Ut = {
5658
5658
  {
5659
5659
  type: "number",
5660
5660
  value: Math.round(f.x) || 0,
5661
- onChange: (b) => n("x", parseInt(b.target.value))
5661
+ onChange: (p) => n("x", parseInt(p.target.value))
5662
5662
  }
5663
5663
  )
5664
5664
  ] }),
@@ -5669,7 +5669,7 @@ const Ut = {
5669
5669
  {
5670
5670
  type: "number",
5671
5671
  value: Math.round(f.y) || 0,
5672
- onChange: (b) => n("y", parseInt(b.target.value))
5672
+ onChange: (p) => n("y", parseInt(p.target.value))
5673
5673
  }
5674
5674
  )
5675
5675
  ] })
@@ -5682,7 +5682,7 @@ const Ut = {
5682
5682
  {
5683
5683
  type: "number",
5684
5684
  value: Math.round(f.width) || 0,
5685
- onChange: (b) => n("width", parseInt(b.target.value)),
5685
+ onChange: (p) => n("width", parseInt(p.target.value)),
5686
5686
  min: "1"
5687
5687
  }
5688
5688
  )
@@ -5694,7 +5694,7 @@ const Ut = {
5694
5694
  {
5695
5695
  type: "number",
5696
5696
  value: Math.round(f.height) || 0,
5697
- onChange: (b) => n("height", parseInt(b.target.value)),
5697
+ onChange: (p) => n("height", parseInt(p.target.value)),
5698
5698
  min: "1"
5699
5699
  }
5700
5700
  )
@@ -5709,7 +5709,7 @@ const Ut = {
5709
5709
  min: "-180",
5710
5710
  max: "180",
5711
5711
  value: f.rotation || 0,
5712
- onChange: (b) => n("rotation", parseInt(b.target.value))
5712
+ onChange: (p) => n("rotation", parseInt(p.target.value))
5713
5713
  }
5714
5714
  ),
5715
5715
  /* @__PURE__ */ i.jsxs("span", { children: [
@@ -5717,7 +5717,7 @@ const Ut = {
5717
5717
  "°"
5718
5718
  ] })
5719
5719
  ] })
5720
- ] }), y = () => /* @__PURE__ */ i.jsxs("div", { className: "property-group", children: [
5720
+ ] }), m = () => /* @__PURE__ */ i.jsxs("div", { className: "property-group", children: [
5721
5721
  /* @__PURE__ */ i.jsx("h4", { children: "Line Properties" }),
5722
5722
  /* @__PURE__ */ i.jsxs("div", { className: "property-row", children: [
5723
5723
  /* @__PURE__ */ i.jsxs("div", { className: "input-group", children: [
@@ -5727,9 +5727,9 @@ const Ut = {
5727
5727
  {
5728
5728
  type: "number",
5729
5729
  value: f.strokeWidth || f.height || 2,
5730
- onChange: (b) => {
5731
- const F = parseInt(b.target.value);
5732
- n("strokeWidth", F), n("height", F);
5730
+ onChange: (p) => {
5731
+ const v = parseInt(p.target.value);
5732
+ n("strokeWidth", v), n("height", v);
5733
5733
  },
5734
5734
  min: "1",
5735
5735
  max: "50"
@@ -5743,7 +5743,7 @@ const Ut = {
5743
5743
  {
5744
5744
  type: "number",
5745
5745
  value: f.width || 200,
5746
- onChange: (b) => n("width", parseInt(b.target.value)),
5746
+ onChange: (p) => n("width", parseInt(p.target.value)),
5747
5747
  min: "10",
5748
5748
  max: "1000"
5749
5749
  }
@@ -5758,8 +5758,8 @@ const Ut = {
5758
5758
  {
5759
5759
  type: "color",
5760
5760
  value: f.stroke || f.fill || "#000000",
5761
- onChange: (b) => {
5762
- n("stroke", b.target.value), n("fill", b.target.value);
5761
+ onChange: (p) => {
5762
+ n("stroke", p.target.value), n("fill", p.target.value);
5763
5763
  }
5764
5764
  }
5765
5765
  ),
@@ -5768,15 +5768,15 @@ const Ut = {
5768
5768
  {
5769
5769
  type: "text",
5770
5770
  value: f.stroke || f.fill || "#000000",
5771
- onChange: (b) => {
5772
- n("stroke", b.target.value), n("fill", b.target.value);
5771
+ onChange: (p) => {
5772
+ n("stroke", p.target.value), n("fill", p.target.value);
5773
5773
  },
5774
5774
  placeholder: "#000000"
5775
5775
  }
5776
5776
  )
5777
5777
  ] })
5778
5778
  ] })
5779
- ] }), E = () => /* @__PURE__ */ i.jsxs("div", { className: "property-group", children: [
5779
+ ] }), B = () => /* @__PURE__ */ i.jsxs("div", { className: "property-group", children: [
5780
5780
  /* @__PURE__ */ i.jsx("h4", { children: "Layer Controls" }),
5781
5781
  /* @__PURE__ */ i.jsxs("div", { className: "button-group vertical", children: [
5782
5782
  /* @__PURE__ */ i.jsx("button", { onClick: () => a(f.id, "top"), children: "Bring to Front" }),
@@ -5784,7 +5784,7 @@ const Ut = {
5784
5784
  /* @__PURE__ */ i.jsx("button", { onClick: () => a(f.id, "down"), children: "Send Backward" }),
5785
5785
  /* @__PURE__ */ i.jsx("button", { onClick: () => a(f.id, "bottom"), children: "Send to Back" })
5786
5786
  ] })
5787
- ] }), B = [
5787
+ ] }), j = [
5788
5788
  "rectangle",
5789
5789
  "circle",
5790
5790
  "triangle",
@@ -5803,19 +5803,19 @@ const Ut = {
5803
5803
  /* @__PURE__ */ i.jsx("span", { className: "element-type", children: f.type })
5804
5804
  ] }),
5805
5805
  /* @__PURE__ */ i.jsxs("div", { className: "panel-content", children: [
5806
- f.type === "text" && d(),
5807
- B.includes(f.type) && j(),
5808
- f.type === "image" && S(),
5809
- f.type === "horizontalLine" && y(),
5810
- I(),
5806
+ f.type === "text" && c(),
5807
+ j.includes(f.type) && F(),
5808
+ f.type === "image" && I(),
5809
+ f.type === "horizontalLine" && m(),
5811
5810
  E(),
5811
+ B(),
5812
5812
  /* @__PURE__ */ i.jsx("div", { className: "property-group", children: /* @__PURE__ */ i.jsxs(
5813
5813
  "button",
5814
5814
  {
5815
5815
  className: "toggle-advanced",
5816
- onClick: () => x(!h),
5816
+ onClick: () => h(!g),
5817
5817
  children: [
5818
- h ? "Hide" : "Show",
5818
+ g ? "Hide" : "Show",
5819
5819
  " Advanced Options"
5820
5820
  ]
5821
5821
  }
@@ -5828,10 +5828,10 @@ const Ut = {
5828
5828
  onSelectElement: a,
5829
5829
  onMoveLayer: l,
5830
5830
  onDeleteElement: s,
5831
- theme: h
5831
+ theme: g
5832
5832
  }) => {
5833
- const x = (d, j) => {
5834
- switch (d) {
5833
+ const h = (c, F) => {
5834
+ switch (c) {
5835
5835
  case "text":
5836
5836
  return "T";
5837
5837
  case "rectangle":
@@ -5871,42 +5871,42 @@ const Ut = {
5871
5871
  default:
5872
5872
  return "?";
5873
5873
  }
5874
- }, n = (d) => {
5875
- var j, S;
5876
- if (d.type === "text")
5877
- return d.isIcon && d.iconData ? `Icon: ${d.iconData.name}` : ((j = d.text) == null ? void 0 : j.substring(0, 20)) + (((S = d.text) == null ? void 0 : S.length) > 20 ? "..." : "") || "Text";
5878
- if (d.type === "qrcode")
5879
- return `QR Code: ${(d.data || "").substring(0, 15) + ((d.data || "").length > 15 ? "..." : "")}`;
5880
- if (d.type === "barcode") {
5881
- const I = d.format || "CODE128", y = d.data || "";
5882
- return `Barcode (${I}): ${y.substring(0, 10) + (y.length > 10 ? "..." : "")}`;
5874
+ }, n = (c) => {
5875
+ var F, I;
5876
+ if (c.type === "text")
5877
+ return c.isIcon && c.iconData ? `Icon: ${c.iconData.name}` : ((F = c.text) == null ? void 0 : F.substring(0, 20)) + (((I = c.text) == null ? void 0 : I.length) > 20 ? "..." : "") || "Text";
5878
+ if (c.type === "qrcode")
5879
+ return `QR Code: ${(c.data || "").substring(0, 15) + ((c.data || "").length > 15 ? "..." : "")}`;
5880
+ if (c.type === "barcode") {
5881
+ const E = c.format || "CODE128", m = c.data || "";
5882
+ return `Barcode (${E}): ${m.substring(0, 10) + (m.length > 10 ? "..." : "")}`;
5883
5883
  }
5884
- return d.type === "sticker" ? `Sticker: ${(d.name || "Untitled").substring(0, 15)}` : d.type === "embroidery" ? `Embroidery: ${(d.name || "Design").substring(0, 15)}` : d.type.charAt(0).toUpperCase() + d.type.slice(1);
5884
+ return c.type === "sticker" ? `Sticker: ${(c.name || "Untitled").substring(0, 15)}` : c.type === "embroidery" ? `Embroidery: ${(c.name || "Design").substring(0, 15)}` : c.type.charAt(0).toUpperCase() + c.type.slice(1);
5885
5885
  };
5886
5886
  return /* @__PURE__ */ i.jsxs("div", { className: "layers-panel", children: [
5887
5887
  /* @__PURE__ */ i.jsxs("div", { className: "panel-header", children: [
5888
5888
  /* @__PURE__ */ i.jsx("h3", { children: "Layers" }),
5889
5889
  /* @__PURE__ */ i.jsx("span", { className: "layer-count", children: f.length })
5890
5890
  ] }),
5891
- /* @__PURE__ */ i.jsx("div", { className: "layers-list", children: f.length === 0 ? /* @__PURE__ */ i.jsx("div", { className: "no-layers", children: "No elements added yet" }) : [...f].reverse().map((d, j) => /* @__PURE__ */ i.jsxs(
5891
+ /* @__PURE__ */ i.jsx("div", { className: "layers-list", children: f.length === 0 ? /* @__PURE__ */ i.jsx("div", { className: "no-layers", children: "No elements added yet" }) : [...f].reverse().map((c, F) => /* @__PURE__ */ i.jsxs(
5892
5892
  "div",
5893
5893
  {
5894
- className: `layer-item ${(o == null ? void 0 : o.id) === d.id ? "selected" : ""}`,
5895
- onClick: () => a(d),
5894
+ className: `layer-item ${(o == null ? void 0 : o.id) === c.id ? "selected" : ""}`,
5895
+ onClick: () => a(c),
5896
5896
  children: [
5897
5897
  /* @__PURE__ */ i.jsxs("div", { className: "layer-info", children: [
5898
- /* @__PURE__ */ i.jsx("span", { className: "layer-icon", children: x(d.type) }),
5899
- /* @__PURE__ */ i.jsx("span", { className: "layer-name", children: n(d) })
5898
+ /* @__PURE__ */ i.jsx("span", { className: "layer-icon", children: h(c.type) }),
5899
+ /* @__PURE__ */ i.jsx("span", { className: "layer-name", children: n(c) })
5900
5900
  ] }),
5901
5901
  /* @__PURE__ */ i.jsxs("div", { className: "layer-controls", children: [
5902
5902
  /* @__PURE__ */ i.jsx(
5903
5903
  "button",
5904
5904
  {
5905
5905
  className: "layer-btn",
5906
- onClick: (S) => {
5907
- S.stopPropagation(), l(d.id, "up");
5906
+ onClick: (I) => {
5907
+ I.stopPropagation(), l(c.id, "up");
5908
5908
  },
5909
- disabled: j === 0,
5909
+ disabled: F === 0,
5910
5910
  title: "Move Up",
5911
5911
  children: "↑"
5912
5912
  }
@@ -5915,10 +5915,10 @@ const Ut = {
5915
5915
  "button",
5916
5916
  {
5917
5917
  className: "layer-btn",
5918
- onClick: (S) => {
5919
- S.stopPropagation(), l(d.id, "down");
5918
+ onClick: (I) => {
5919
+ I.stopPropagation(), l(c.id, "down");
5920
5920
  },
5921
- disabled: j === f.length - 1,
5921
+ disabled: F === f.length - 1,
5922
5922
  title: "Move Down",
5923
5923
  children: "↓"
5924
5924
  }
@@ -5927,8 +5927,8 @@ const Ut = {
5927
5927
  "button",
5928
5928
  {
5929
5929
  className: "layer-btn delete",
5930
- onClick: (S) => {
5931
- S.stopPropagation(), s(d.id);
5930
+ onClick: (I) => {
5931
+ I.stopPropagation(), s(c.id);
5932
5932
  },
5933
5933
  title: "Delete",
5934
5934
  children: "×"
@@ -5937,7 +5937,7 @@ const Ut = {
5937
5937
  ] })
5938
5938
  ]
5939
5939
  },
5940
- d.id
5940
+ c.id
5941
5941
  )) })
5942
5942
  ] });
5943
5943
  };
@@ -5946,34 +5946,34 @@ class ci {
5946
5946
  this.canvas = document.createElement("canvas"), this.ctx = this.canvas.getContext("2d");
5947
5947
  }
5948
5948
  // Add this method to the ExportManager class
5949
- async exportAllSections(o, a, l, s, h = "png", x = !0) {
5950
- const n = {};
5951
- for (const d of a) {
5952
- const j = d.id || d.sectionName, S = o[j];
5953
- if (!S || !S.elements || S.elements.length === 0) {
5954
- console.log(`Skipping section ${j} - no elements`);
5949
+ async exportAllSections(o, a, l, s, g = "png", h = !0, n = null) {
5950
+ const c = {};
5951
+ for (const F of a) {
5952
+ const I = F.id || F.sectionName, E = o[I];
5953
+ if (!E || !E.elements || E.elements.length === 0) {
5954
+ console.log(`Skipping section ${I} - no elements`);
5955
5955
  continue;
5956
5956
  }
5957
- if (this.canvas.width = l, this.canvas.height = s, this.ctx.clearRect(0, 0, l, s), x) {
5958
- const y = d.image || d.sectionImage;
5959
- if (y)
5957
+ if (this.canvas.width = l, this.canvas.height = s, this.ctx.clearRect(0, 0, l, s), h) {
5958
+ let B = F.image || F.sectionImage;
5959
+ if (n && n.sectionImage && (F.sectionName === "Front" || n.sections && Object.keys(n.sections).includes(F.sectionName)) && (B = n.sectionImage), B)
5960
5960
  try {
5961
- const E = await this.loadImage(y);
5962
- await this.processImageColor(E, S.selectedColor || "#FFFFFF"), this.ctx.drawImage(this.processedImage, 0, 0, l, s);
5963
- } catch (E) {
5964
- console.warn("Failed to load background image:", E);
5961
+ const j = await this.loadImage(B);
5962
+ await this.processImageColor(j, E.selectedColor || "#FFFFFF"), this.ctx.drawImage(this.processedImage, 0, 0, l, s);
5963
+ } catch (j) {
5964
+ console.warn("Failed to load background image:", j);
5965
5965
  }
5966
5966
  } else
5967
5967
  this.ctx.clearRect(0, 0, l, s);
5968
- for (const y of S.elements)
5969
- await this.drawElement(y);
5970
- const I = this.canvas.toDataURL(`image/${h}`, h === "jpeg" ? 0.9 : void 0);
5971
- n[j] = {
5972
- dataUrl: I,
5973
- blob: await this.dataUrlToBlob(I)
5968
+ for (const B of E.elements)
5969
+ await this.drawElement(B);
5970
+ const m = this.canvas.toDataURL(`image/${g}`, g === "jpeg" ? 0.9 : void 0);
5971
+ c[I] = {
5972
+ dataUrl: m,
5973
+ blob: await this.dataUrlToBlob(m)
5974
5974
  };
5975
5975
  }
5976
- return n;
5976
+ return c;
5977
5977
  }
5978
5978
  // Also add a method to download all exports
5979
5979
  async downloadExports(o, a = "design") {
@@ -5983,12 +5983,12 @@ class ci {
5983
5983
  return;
5984
5984
  }
5985
5985
  if (l.length === 1) {
5986
- const s = l[0], { blob: h } = o[s], x = URL.createObjectURL(h), n = document.createElement("a");
5987
- n.href = x, n.download = `${a}-${s}.png`, document.body.appendChild(n), n.click(), document.body.removeChild(n), URL.revokeObjectURL(x);
5986
+ const s = l[0], { blob: g } = o[s], h = URL.createObjectURL(g), n = document.createElement("a");
5987
+ n.href = h, n.download = `${a}-${s}.png`, document.body.appendChild(n), n.click(), document.body.removeChild(n), URL.revokeObjectURL(h);
5988
5988
  } else
5989
5989
  for (const s of l) {
5990
- const { blob: h } = o[s], x = URL.createObjectURL(h), n = document.createElement("a");
5991
- n.href = x, n.download = `${a}-${s}.png`, document.body.appendChild(n), n.click(), document.body.removeChild(n), URL.revokeObjectURL(x), await new Promise((d) => setTimeout(d, 100));
5990
+ const { blob: g } = o[s], h = URL.createObjectURL(g), n = document.createElement("a");
5991
+ n.href = h, n.download = `${a}-${s}.png`, document.body.appendChild(n), n.click(), document.body.removeChild(n), URL.revokeObjectURL(h), await new Promise((c) => setTimeout(c, 100));
5992
5992
  }
5993
5993
  }
5994
5994
  async loadImage(o) {
@@ -6005,22 +6005,22 @@ class ci {
6005
6005
  async processImageColor(o, a) {
6006
6006
  const l = document.createElement("canvas"), s = l.getContext("2d");
6007
6007
  l.width = o.width, l.height = o.height, s.clearRect(0, 0, l.width, l.height), s.drawImage(o, 0, 0);
6008
- const h = s.getImageData(0, 0, l.width, l.height), x = h.data, n = this.hexToRgb(a);
6008
+ const g = s.getImageData(0, 0, l.width, l.height), h = g.data, n = this.hexToRgb(a);
6009
6009
  if (!n) {
6010
6010
  console.warn("Invalid target color:", a);
6011
6011
  return;
6012
6012
  }
6013
- const { r: d, g: j, b: S } = n;
6014
- for (let I = 0; I < x.length; I += 4) {
6015
- if (x[I + 3] === 0) continue;
6016
- const E = this.getLuma(x[I], x[I + 1], x[I + 2]);
6017
- x[I] = Math.round(d * E), x[I + 1] = Math.round(j * E), x[I + 2] = Math.round(S * E);
6013
+ const { r: c, g: F, b: I } = n;
6014
+ for (let E = 0; E < h.length; E += 4) {
6015
+ if (h[E + 3] === 0) continue;
6016
+ const B = this.getLuma(h[E], h[E + 1], h[E + 2]);
6017
+ h[E] = Math.round(c * B), h[E + 1] = Math.round(F * B), h[E + 2] = Math.round(I * B);
6018
6018
  }
6019
- return s.putImageData(h, 0, 0), this.processedImage = new Image(), new Promise((I) => {
6019
+ return s.putImageData(g, 0, 0), this.processedImage = new Image(), new Promise((E) => {
6020
6020
  this.processedImage.onload = () => {
6021
- I();
6021
+ E();
6022
6022
  }, this.processedImage.onerror = () => {
6023
- console.error("Failed to create processed image"), I();
6023
+ console.error("Failed to create processed image"), E();
6024
6024
  }, this.processedImage.src = l.toDataURL("image/png");
6025
6025
  });
6026
6026
  }
@@ -6080,7 +6080,7 @@ class ci {
6080
6080
  await this.drawEmbroidery(o);
6081
6081
  break;
6082
6082
  case "image":
6083
- o.imageData && this.ctx.drawImage(o.imageData, 0, 0, o.width, o.height);
6083
+ await this.drawImage(o);
6084
6084
  break;
6085
6085
  }
6086
6086
  this.ctx.restore();
@@ -6089,9 +6089,9 @@ class ci {
6089
6089
  this.ctx.font = `${o.fontStyle || "normal"} ${o.fontWeight || "normal"} ${o.fontSize || 20}px ${o.fontFamily || "Arial"}`, this.ctx.fillStyle = o.fill || "#000000", this.ctx.textAlign = o.textAlign || "left", this.ctx.textBaseline = "top", o.stroke && o.strokeWidth > 0 && (this.ctx.strokeStyle = o.stroke, this.ctx.lineWidth = o.strokeWidth);
6090
6090
  const a = (o.text || "Text").split(`
6091
6091
  `), l = (o.fontSize || 20) * 1.2;
6092
- a.forEach((s, h) => {
6093
- const x = h * l;
6094
- o.stroke && o.strokeWidth > 0 && this.ctx.strokeText(s, 0, x), this.ctx.fillText(s, 0, x);
6092
+ a.forEach((s, g) => {
6093
+ const h = g * l;
6094
+ o.stroke && o.strokeWidth > 0 && this.ctx.strokeText(s, 0, h), this.ctx.fillText(s, 0, h);
6095
6095
  });
6096
6096
  }
6097
6097
  drawRectangle(o) {
@@ -6106,11 +6106,11 @@ class ci {
6106
6106
  this.ctx.beginPath(), this.ctx.moveTo(a, 0), this.ctx.lineTo(0, o.height), this.ctx.lineTo(o.width, o.height), this.ctx.closePath(), o.fill && o.fill !== "transparent" && (this.ctx.fillStyle = o.fill, this.ctx.fill()), o.stroke && o.strokeWidth > 0 && (this.ctx.strokeStyle = o.stroke, this.ctx.lineWidth = o.strokeWidth, this.ctx.stroke());
6107
6107
  }
6108
6108
  drawStar(o) {
6109
- const a = o.width / 2, l = o.height / 2, s = Math.min(o.width, o.height) / 2, h = s * 0.4, x = o.numPoints || 5;
6109
+ const a = o.width / 2, l = o.height / 2, s = Math.min(o.width, o.height) / 2, g = s * 0.4, h = o.numPoints || 5;
6110
6110
  this.ctx.beginPath();
6111
- for (let n = 0; n < x * 2; n++) {
6112
- const d = n % 2 === 0 ? s : h, j = n * Math.PI / x, S = a + Math.cos(j) * d, I = l + Math.sin(j) * d;
6113
- n === 0 ? this.ctx.moveTo(S, I) : this.ctx.lineTo(S, I);
6111
+ for (let n = 0; n < h * 2; n++) {
6112
+ const c = n % 2 === 0 ? s : g, F = n * Math.PI / h, I = a + Math.cos(F) * c, E = l + Math.sin(F) * c;
6113
+ n === 0 ? this.ctx.moveTo(I, E) : this.ctx.lineTo(I, E);
6114
6114
  }
6115
6115
  this.ctx.closePath(), o.fill && o.fill !== "transparent" && (this.ctx.fillStyle = o.fill, this.ctx.fill()), o.stroke && o.strokeWidth > 0 && (this.ctx.strokeStyle = o.stroke, this.ctx.lineWidth = o.strokeWidth, this.ctx.stroke());
6116
6116
  }
@@ -6120,10 +6120,10 @@ class ci {
6120
6120
  }
6121
6121
  async dataUrlToBlob(o) {
6122
6122
  return new Promise((a) => {
6123
- const l = document.createElement("canvas"), s = l.getContext("2d"), h = new Image();
6124
- h.onload = () => {
6125
- l.width = h.width, l.height = h.height, s.drawImage(h, 0, 0), l.toBlob(a);
6126
- }, h.src = o;
6123
+ const l = document.createElement("canvas"), s = l.getContext("2d"), g = new Image();
6124
+ g.onload = () => {
6125
+ l.width = g.width, l.height = g.height, s.drawImage(g, 0, 0), l.toBlob(a);
6126
+ }, g.src = o;
6127
6127
  });
6128
6128
  }
6129
6129
  hexToRgb(o) {
@@ -6140,67 +6140,67 @@ class ci {
6140
6140
  this.ctx.beginPath(), this.ctx.moveTo(a, 0), this.ctx.lineTo(o.width, l), this.ctx.lineTo(a, o.height), this.ctx.lineTo(0, l), this.ctx.closePath(), o.fill && o.fill !== "transparent" && (this.ctx.fillStyle = o.fill, this.ctx.fill()), o.stroke && o.strokeWidth > 0 && (this.ctx.strokeStyle = o.stroke, this.ctx.lineWidth = o.strokeWidth, this.ctx.stroke());
6141
6141
  }
6142
6142
  drawHexagon(o) {
6143
- const a = o.width / 2, l = o.height / 2, s = Math.min(o.width, o.height) / 2, h = 6;
6143
+ const a = o.width / 2, l = o.height / 2, s = Math.min(o.width, o.height) / 2, g = 6;
6144
6144
  this.ctx.beginPath();
6145
- for (let x = 0; x < h; x++) {
6146
- const n = x * 2 * Math.PI / h - Math.PI / 2, d = a + s * Math.cos(n), j = l + s * Math.sin(n);
6147
- x === 0 ? this.ctx.moveTo(d, j) : this.ctx.lineTo(d, j);
6145
+ for (let h = 0; h < g; h++) {
6146
+ const n = h * 2 * Math.PI / g - Math.PI / 2, c = a + s * Math.cos(n), F = l + s * Math.sin(n);
6147
+ h === 0 ? this.ctx.moveTo(c, F) : this.ctx.lineTo(c, F);
6148
6148
  }
6149
6149
  this.ctx.closePath(), o.fill && o.fill !== "transparent" && (this.ctx.fillStyle = o.fill, this.ctx.fill()), o.stroke && o.strokeWidth > 0 && (this.ctx.strokeStyle = o.stroke, this.ctx.lineWidth = o.strokeWidth, this.ctx.stroke());
6150
6150
  }
6151
6151
  drawPentagon(o) {
6152
- const a = o.width / 2, l = o.height / 2, s = Math.min(o.width, o.height) / 2, h = 5;
6152
+ const a = o.width / 2, l = o.height / 2, s = Math.min(o.width, o.height) / 2, g = 5;
6153
6153
  this.ctx.beginPath();
6154
- for (let x = 0; x < h; x++) {
6155
- const n = x * 2 * Math.PI / h - Math.PI / 2, d = a + s * Math.cos(n), j = l + s * Math.sin(n);
6156
- x === 0 ? this.ctx.moveTo(d, j) : this.ctx.lineTo(d, j);
6154
+ for (let h = 0; h < g; h++) {
6155
+ const n = h * 2 * Math.PI / g - Math.PI / 2, c = a + s * Math.cos(n), F = l + s * Math.sin(n);
6156
+ h === 0 ? this.ctx.moveTo(c, F) : this.ctx.lineTo(c, F);
6157
6157
  }
6158
6158
  this.ctx.closePath(), o.fill && o.fill !== "transparent" && (this.ctx.fillStyle = o.fill, this.ctx.fill()), o.stroke && o.strokeWidth > 0 && (this.ctx.strokeStyle = o.stroke, this.ctx.lineWidth = o.strokeWidth, this.ctx.stroke());
6159
6159
  }
6160
6160
  drawHeart(o) {
6161
- const a = o.width, l = o.height, s = 0, h = 0;
6161
+ const a = o.width, l = o.height, s = 0, g = 0;
6162
6162
  this.ctx.beginPath();
6163
- const x = l * 0.3;
6164
- this.ctx.moveTo(s + a / 2, h + x), this.ctx.bezierCurveTo(
6163
+ const h = l * 0.3;
6164
+ this.ctx.moveTo(s + a / 2, g + h), this.ctx.bezierCurveTo(
6165
6165
  s + a / 2,
6166
- h,
6166
+ g,
6167
6167
  s,
6168
- h,
6168
+ g,
6169
6169
  s,
6170
- h + x
6170
+ g + h
6171
6171
  ), this.ctx.bezierCurveTo(
6172
6172
  s,
6173
- h + (l + x) / 2,
6173
+ g + (l + h) / 2,
6174
6174
  s + a / 2,
6175
- h + (l + x) / 2,
6175
+ g + (l + h) / 2,
6176
6176
  s + a / 2,
6177
- h + l
6177
+ g + l
6178
6178
  ), this.ctx.bezierCurveTo(
6179
6179
  s + a / 2,
6180
- h + (l + x) / 2,
6180
+ g + (l + h) / 2,
6181
6181
  s + a,
6182
- h + (l + x) / 2,
6182
+ g + (l + h) / 2,
6183
6183
  s + a,
6184
- h + x
6184
+ g + h
6185
6185
  ), this.ctx.bezierCurveTo(
6186
6186
  s + a,
6187
- h,
6187
+ g,
6188
6188
  s + a / 2,
6189
- h,
6189
+ g,
6190
6190
  s + a / 2,
6191
- h + x
6191
+ g + h
6192
6192
  ), this.ctx.closePath(), o.fill && o.fill !== "transparent" && (this.ctx.fillStyle = o.fill, this.ctx.fill()), o.stroke && o.strokeWidth > 0 && (this.ctx.strokeStyle = o.stroke, this.ctx.lineWidth = o.strokeWidth, this.ctx.stroke());
6193
6193
  }
6194
6194
  drawOval(o) {
6195
- const a = o.width / 2, l = o.height / 2, s = o.width / 2, h = o.height / 2;
6196
- this.ctx.beginPath(), this.ctx.ellipse(a, l, s, h, 0, 0, 2 * Math.PI), o.fill && o.fill !== "transparent" && (this.ctx.fillStyle = o.fill, this.ctx.fill()), o.stroke && o.strokeWidth > 0 && (this.ctx.strokeStyle = o.stroke, this.ctx.lineWidth = o.strokeWidth, this.ctx.stroke());
6195
+ const a = o.width / 2, l = o.height / 2, s = o.width / 2, g = o.height / 2;
6196
+ this.ctx.beginPath(), this.ctx.ellipse(a, l, s, g, 0, 0, 2 * Math.PI), o.fill && o.fill !== "transparent" && (this.ctx.fillStyle = o.fill, this.ctx.fill()), o.stroke && o.strokeWidth > 0 && (this.ctx.strokeStyle = o.stroke, this.ctx.lineWidth = o.strokeWidth, this.ctx.stroke());
6197
6197
  }
6198
6198
  drawRoundedRectangle(o) {
6199
6199
  const a = Math.min(o.width, o.height) * 0.1;
6200
6200
  this.drawRoundedRect(0, 0, o.width, o.height, a), o.fill && o.fill !== "transparent" && (this.ctx.fillStyle = o.fill, this.ctx.fill()), o.stroke && o.strokeWidth > 0 && (this.ctx.strokeStyle = o.stroke, this.ctx.lineWidth = o.strokeWidth, this.ctx.stroke());
6201
6201
  }
6202
- drawRoundedRect(o, a, l, s, h) {
6203
- this.ctx.beginPath(), this.ctx.moveTo(o + h, a), this.ctx.lineTo(o + l - h, a), this.ctx.quadraticCurveTo(o + l, a, o + l, a + h), this.ctx.lineTo(o + l, a + s - h), this.ctx.quadraticCurveTo(o + l, a + s, o + l - h, a + s), this.ctx.lineTo(o + h, a + s), this.ctx.quadraticCurveTo(o, a + s, o, a + s - h), this.ctx.lineTo(o, a + h), this.ctx.quadraticCurveTo(o, a, o + h, a), this.ctx.closePath();
6202
+ drawRoundedRect(o, a, l, s, g) {
6203
+ this.ctx.beginPath(), this.ctx.moveTo(o + g, a), this.ctx.lineTo(o + l - g, a), this.ctx.quadraticCurveTo(o + l, a, o + l, a + g), this.ctx.lineTo(o + l, a + s - g), this.ctx.quadraticCurveTo(o + l, a + s, o + l - g, a + s), this.ctx.lineTo(o + g, a + s), this.ctx.quadraticCurveTo(o, a + s, o, a + s - g), this.ctx.lineTo(o, a + g), this.ctx.quadraticCurveTo(o, a, o + g, a), this.ctx.closePath();
6204
6204
  }
6205
6205
  async drawQRCode(o) {
6206
6206
  if (o.imageObject)
@@ -6263,6 +6263,54 @@ class ci {
6263
6263
  console.warn("Failed to draw embroidery:", a), this.ctx.fillStyle = "#ffebee", this.ctx.fillRect(0, 0, o.width, o.height), this.ctx.strokeStyle = "#f44336", this.ctx.strokeRect(0, 0, o.width, o.height), this.ctx.fillStyle = "#f44336", this.ctx.font = "12px Arial", this.ctx.textAlign = "center", this.ctx.textBaseline = "middle", this.ctx.fillText("Error", o.width / 2, o.height / 2);
6264
6264
  }
6265
6265
  }
6266
+ // Add this new method to handle image elements more robustly
6267
+ async drawImage(o) {
6268
+ try {
6269
+ let a = null;
6270
+ if (o.imageObject && o.imageObject instanceof HTMLImageElement)
6271
+ a = o.imageObject;
6272
+ else if (o.imageData) {
6273
+ if (o.imageData instanceof HTMLImageElement)
6274
+ a = o.imageData;
6275
+ else if (typeof o.imageData == "string")
6276
+ try {
6277
+ a = await this.loadImage(o.imageData);
6278
+ } catch (l) {
6279
+ console.warn("Failed to load image from imageData URL:", o.imageData, l), a = await this.loadImageWithFallback(o.imageData);
6280
+ }
6281
+ } else if (o.src)
6282
+ try {
6283
+ a = await this.loadImage(o.src);
6284
+ } catch (l) {
6285
+ console.warn("Failed to load image from src:", o.src, l), a = await this.loadImageWithFallback(o.src);
6286
+ }
6287
+ else if (o.image)
6288
+ try {
6289
+ a = await this.loadImage(o.image);
6290
+ } catch (l) {
6291
+ console.warn("Failed to load image from image property:", o.image, l), a = await this.loadImageWithFallback(o.image);
6292
+ }
6293
+ a ? (o.opacity !== void 0 && (this.ctx.globalAlpha = o.opacity), this.ctx.drawImage(a, 0, 0, o.width, o.height)) : this.drawImagePlaceholder(o);
6294
+ } catch (a) {
6295
+ console.error("Failed to draw image element:", a), this.drawImagePlaceholder(o);
6296
+ }
6297
+ }
6298
+ // Add fallback image loading method
6299
+ async loadImageWithFallback(o) {
6300
+ return new Promise((a) => {
6301
+ const l = new Image();
6302
+ l.onload = () => a(l), l.onerror = () => {
6303
+ const s = new Image();
6304
+ s.crossOrigin = "anonymous", s.onload = () => a(s), s.onerror = () => {
6305
+ console.warn("All image loading attempts failed for:", o), a(null);
6306
+ }, s.src = o;
6307
+ }, l.src = o;
6308
+ });
6309
+ }
6310
+ // Add placeholder drawing method
6311
+ drawImagePlaceholder(o) {
6312
+ this.ctx.fillStyle = "#f0f0f0", this.ctx.fillRect(0, 0, o.width, o.height), this.ctx.strokeStyle = "#ccc", this.ctx.lineWidth = 2, this.ctx.strokeRect(0, 0, o.width, o.height), this.ctx.fillStyle = "#666", this.ctx.font = "12px Arial", this.ctx.textAlign = "center", this.ctx.textBaseline = "middle", this.ctx.fillText("Image", o.width / 2, o.height / 2 - 8), this.ctx.fillText("Not Found", o.width / 2, o.height / 2 + 8);
6313
+ }
6266
6314
  /**Export to JSON formats**/
6267
6315
  // Add these new methods to the ExportManager class
6268
6316
  // Helper method to convert blob to File
@@ -6273,189 +6321,225 @@ class ci {
6273
6321
  });
6274
6322
  }
6275
6323
  // Export all sections as JSON with File objects
6276
- async exportAllSectionsAsJSON(o, a, l, s, h = "png") {
6277
- const x = [], n = [], d = {};
6278
- for (const S of a) {
6279
- const I = S.id || S.sectionName, y = o[I];
6280
- if (!y || !y.elements || y.elements.length === 0) {
6281
- console.log(`Skipping section ${I} - no elements`);
6324
+ async exportAllSectionsAsJSON(o, a, l, s, g = "png", h = null) {
6325
+ var m, B;
6326
+ const n = [], c = [], F = {};
6327
+ for (const j of a) {
6328
+ const p = j.id || j.sectionName, v = o[p];
6329
+ if (!v || !v.elements || v.elements.length === 0) {
6330
+ console.log(`Skipping section ${p} - no elements`);
6282
6331
  continue;
6283
6332
  }
6284
- const E = {
6285
- ...y,
6286
- // Include background information
6287
- backgroundImage: S.image || S.sectionImage,
6288
- sectionImage: S.image || S.sectionImage,
6289
- sectionName: I,
6333
+ let X = j.image || j.sectionImage;
6334
+ h && h.sectionImage && (j.sectionName === "Front" || h.sections && Object.keys(h.sections).includes(j.sectionName)) && (X = h.sectionImage);
6335
+ const T = {
6336
+ ...v,
6337
+ // Include background information using the determined image
6338
+ backgroundImage: X,
6339
+ sectionImage: X,
6340
+ sectionName: p,
6290
6341
  // Ensure we have the selected color
6291
- selectedColor: y.selectedColor || "#FFFFFF",
6342
+ selectedColor: v.selectedColor || "#FFFFFF",
6292
6343
  // Include canvas dimensions
6293
6344
  canvasWidth: l,
6294
6345
  canvasHeight: s
6295
6346
  };
6296
- d[I] = E;
6297
- const B = await this.exportSectionAsBlob(
6298
- y,
6299
- S,
6347
+ F[p] = T;
6348
+ const O = await this.exportSectionAsBlob(
6349
+ v,
6350
+ j,
6300
6351
  l,
6301
6352
  s,
6302
- h,
6303
- !0
6353
+ g,
6354
+ !0,
6355
+ h
6356
+ // Pass initData to exportSectionAsBlob
6304
6357
  );
6305
- if (B) {
6306
- const F = await this.blobToFile(
6307
- B,
6308
- `${I}-full.${h}`,
6309
- `image/${h}`
6358
+ if (O) {
6359
+ const Z = await this.blobToFile(
6360
+ O,
6361
+ `${p}-full.${g}`,
6362
+ `image/${g}`
6310
6363
  );
6311
- x.push({
6312
- sectionName: I,
6313
- sectionImage: F
6364
+ n.push({
6365
+ sectionName: p,
6366
+ sectionImage: Z
6314
6367
  });
6315
6368
  }
6316
- const b = await this.exportSectionAsBlob(
6317
- y,
6318
- S,
6369
+ const k = await this.exportSectionAsBlob(
6370
+ v,
6371
+ j,
6319
6372
  l,
6320
6373
  s,
6321
- h,
6322
- !1
6374
+ g,
6375
+ !1,
6376
+ h
6377
+ // Pass initData to exportSectionAsBlob
6323
6378
  );
6324
- if (b) {
6325
- const F = await this.blobToFile(
6326
- b,
6327
- `${I}-print.${h}`,
6328
- `image/${h}`
6379
+ if (k) {
6380
+ const Z = await this.blobToFile(
6381
+ k,
6382
+ `${p}-print.${g}`,
6383
+ `image/${g}`
6329
6384
  );
6330
- n.push({
6331
- sectionName: I,
6332
- sectionImage: F
6385
+ c.push({
6386
+ sectionName: p,
6387
+ sectionImage: Z
6333
6388
  });
6334
6389
  }
6335
6390
  }
6336
- const j = {
6337
- sections: d,
6391
+ let I = ((m = a[0]) == null ? void 0 : m.image) || ((B = a[0]) == null ? void 0 : B.sectionImage);
6392
+ if (h && h.sectionImage) {
6393
+ const j = a[0];
6394
+ j && (j.sectionName === "Front" || h.sections && Object.keys(h.sections).includes(j.sectionName)) && (I = h.sectionImage);
6395
+ }
6396
+ const E = {
6397
+ sections: F,
6338
6398
  canvasWidth: l,
6339
6399
  canvasHeight: s,
6340
- sectionImage: a[0].image || a[0].sectionImage,
6341
- format: h,
6400
+ sectionImage: I,
6401
+ format: g,
6342
6402
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
6343
6403
  version: "1.0",
6404
+ // Include initData information if present
6405
+ ...h && {
6406
+ initData: {
6407
+ sectionImage: h.sectionImage,
6408
+ sections: h.sections ? Object.keys(h.sections) : []
6409
+ }
6410
+ },
6344
6411
  // Include product information for complete context
6345
6412
  product: {
6346
- sections: a.map((S) => ({
6347
- sectionName: S.sectionName || S.id,
6348
- sectionImage: S.image || S.sectionImage,
6349
- id: S.id || S.sectionName
6413
+ sections: a.map((j) => ({
6414
+ sectionName: j.sectionName || j.id,
6415
+ sectionImage: j.image || j.sectionImage,
6416
+ id: j.id || j.sectionName
6350
6417
  }))
6351
6418
  }
6352
6419
  };
6353
6420
  return {
6354
- fullDesign: x,
6355
- printReady: n,
6356
- designFile: JSON.stringify(j)
6421
+ fullDesign: n,
6422
+ printReady: c,
6423
+ designFile: JSON.stringify(E)
6357
6424
  };
6358
6425
  }
6359
6426
  // Helper method to export a single section as blob
6360
- async exportSectionAsBlob(o, a, l, s, h = "png", x = !0) {
6427
+ async exportSectionAsBlob(o, a, l, s, g = "png", h = !0, n = null) {
6361
6428
  try {
6362
- if (this.canvas.width = l, this.canvas.height = s, this.ctx.clearRect(0, 0, l, s), x) {
6363
- const n = a.image || a.sectionImage;
6364
- if (n)
6429
+ if (this.canvas.width = l, this.canvas.height = s, this.ctx.clearRect(0, 0, l, s), h) {
6430
+ let c = a.image || a.sectionImage;
6431
+ if (n && n.sectionImage && (a.sectionName === "Front" || n.sections && Object.keys(n.sections).includes(a.sectionName)) && (c = n.sectionImage), c)
6365
6432
  try {
6366
- const d = await this.loadImage(n);
6367
- await this.processImageColor(d, o.selectedColor || "#FFFFFF"), this.ctx.drawImage(this.processedImage, 0, 0, l, s);
6368
- } catch (d) {
6369
- console.warn("Failed to load background image:", d);
6433
+ const F = await this.loadImage(c);
6434
+ await this.processImageColor(F, o.selectedColor || "#FFFFFF"), this.ctx.drawImage(this.processedImage, 0, 0, l, s);
6435
+ } catch (F) {
6436
+ console.warn("Failed to load background image:", F);
6370
6437
  }
6371
6438
  } else
6372
6439
  this.ctx.clearRect(0, 0, l, s);
6373
- for (const n of o.elements)
6374
- await this.drawElement(n);
6375
- return new Promise((n) => {
6376
- this.canvas.toBlob(n, `image/${h}`, h === "jpeg" ? 0.9 : void 0);
6440
+ for (const c of o.elements)
6441
+ await this.drawElement(c);
6442
+ return new Promise((c) => {
6443
+ this.canvas.toBlob(c, `image/${g}`, g === "jpeg" ? 0.9 : void 0);
6377
6444
  });
6378
- } catch (n) {
6379
- return console.error("Error exporting section as blob:", n), null;
6445
+ } catch (c) {
6446
+ return console.error("Error exporting section as blob:", c), null;
6380
6447
  }
6381
6448
  }
6382
- async exportCurrentSectionAsJSON(o, a = "png") {
6383
- var I, y, E, B, b, F, J, T, O;
6384
- const l = ((I = o.activeSection) == null ? void 0 : I.sectionName) || "main", s = {
6449
+ async exportCurrentSectionAsJSON(o, a = "png", l = null) {
6450
+ var B, j, p;
6451
+ const s = ((B = o.activeSection) == null ? void 0 : B.sectionName) || "main";
6452
+ let g = ((j = o.activeSection) == null ? void 0 : j.sectionImage) || ((p = o.activeSection) == null ? void 0 : p.image);
6453
+ l && l.sectionImage && (s === "Front" || l.sections && Object.keys(l.sections).includes(s)) && (g = l.sectionImage);
6454
+ const h = {
6385
6455
  elements: o.elements,
6386
6456
  selectedColor: o.selectedColor,
6387
6457
  canvasWidth: o.canvasWidth,
6388
6458
  canvasHeight: o.canvasHeight,
6389
- // Include background information
6390
- backgroundImage: ((y = o.activeSection) == null ? void 0 : y.sectionImage) || ((E = o.activeSection) == null ? void 0 : E.image),
6391
- sectionImage: ((B = o.activeSection) == null ? void 0 : B.sectionImage) || ((b = o.activeSection) == null ? void 0 : b.image),
6392
- sectionName: l,
6459
+ // Include background information using the determined image
6460
+ backgroundImage: g,
6461
+ sectionImage: g,
6462
+ sectionName: s,
6393
6463
  zoomLevel: o.zoomLevel,
6394
6464
  showGrid: o.showGrid,
6395
6465
  snapToGrid: o.snapToGrid
6396
- }, h = {
6397
- id: l,
6398
- sectionName: l,
6399
- image: (F = o.activeSection) == null ? void 0 : F.sectionImage,
6400
- sectionImage: (J = o.activeSection) == null ? void 0 : J.sectionImage
6401
- }, x = [], n = [], d = await this.exportSectionAsBlob(
6402
- s,
6466
+ }, n = {
6467
+ id: s,
6468
+ sectionName: s,
6469
+ image: g,
6470
+ sectionImage: g
6471
+ }, c = [], F = [], I = await this.exportSectionAsBlob(
6403
6472
  h,
6473
+ n,
6404
6474
  o.canvasWidth,
6405
6475
  o.canvasHeight,
6406
6476
  a,
6407
- !0
6477
+ !0,
6478
+ l
6479
+ // Pass initData to exportSectionAsBlob
6408
6480
  );
6409
- if (d) {
6481
+ if (I) {
6410
6482
  const v = await this.blobToFile(
6411
- d,
6412
- `${l}-full.${a}`,
6483
+ I,
6484
+ `${s}-full.${a}`,
6413
6485
  `image/${a}`
6414
6486
  );
6415
- x.push({
6416
- sectionName: l,
6487
+ c.push({
6488
+ sectionName: s,
6417
6489
  sectionImage: v
6418
6490
  });
6419
6491
  }
6420
- const j = await this.exportSectionAsBlob(
6421
- s,
6492
+ const E = await this.exportSectionAsBlob(
6422
6493
  h,
6494
+ n,
6423
6495
  o.canvasWidth,
6424
6496
  o.canvasHeight,
6425
6497
  a,
6426
- !1
6498
+ !1,
6499
+ l
6500
+ // Pass initData to exportSectionAsBlob
6427
6501
  );
6428
- if (j) {
6502
+ if (E) {
6429
6503
  const v = await this.blobToFile(
6430
- j,
6431
- `${l}-print.${a}`,
6504
+ E,
6505
+ `${s}-print.${a}`,
6432
6506
  `image/${a}`
6433
6507
  );
6434
- n.push({
6435
- sectionName: l,
6508
+ F.push({
6509
+ sectionName: s,
6436
6510
  sectionImage: v
6437
6511
  });
6438
6512
  }
6439
- const S = {
6440
- sections: { [l]: s },
6513
+ const m = {
6514
+ sections: { [s]: h },
6441
6515
  canvasWidth: o.canvasWidth,
6442
6516
  canvasHeight: o.canvasHeight,
6517
+ sectionImage: g,
6518
+ // Use the determined image here too
6443
6519
  format: a,
6444
6520
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
6445
6521
  version: "1.0",
6522
+ // Include initData information if present
6523
+ ...l && {
6524
+ initData: {
6525
+ sectionImage: l.sectionImage,
6526
+ sections: l.sections ? Object.keys(l.sections) : []
6527
+ }
6528
+ },
6446
6529
  // Include product information for complete context
6447
6530
  productInfo: {
6448
6531
  sections: [{
6449
- sectionName: l,
6450
- sectionImage: ((T = o.activeSection) == null ? void 0 : T.sectionImage) || ((O = o.activeSection) == null ? void 0 : O.image),
6451
- id: l
6532
+ sectionName: s,
6533
+ sectionImage: g,
6534
+ // Use the determined image here too
6535
+ id: s
6452
6536
  }]
6453
6537
  }
6454
6538
  };
6455
6539
  return {
6456
- fullDesign: x,
6457
- printReady: n,
6458
- designFile: JSON.stringify(S)
6540
+ fullDesign: c,
6541
+ printReady: F,
6542
+ designFile: JSON.stringify(m)
6459
6543
  };
6460
6544
  }
6461
6545
  }
@@ -6467,10 +6551,10 @@ class di {
6467
6551
  saveDesign(o, a) {
6468
6552
  var l;
6469
6553
  try {
6470
- const s = this.generateDesignId(o), h = (/* @__PURE__ */ new Date()).toISOString(), x = {
6554
+ const s = this.generateDesignId(o), g = (/* @__PURE__ */ new Date()).toISOString(), h = {
6471
6555
  id: s,
6472
6556
  name: o,
6473
- timestamp: h,
6557
+ timestamp: g,
6474
6558
  version: "1.0",
6475
6559
  canvasData: {
6476
6560
  elements: a.elements || [],
@@ -6486,11 +6570,11 @@ class di {
6486
6570
  },
6487
6571
  metadata: {
6488
6572
  elementCount: ((l = a.elements) == null ? void 0 : l.length) || 0,
6489
- lastModified: h,
6573
+ lastModified: g,
6490
6574
  thumbnail: a.thumbnail || null
6491
6575
  }
6492
6576
  };
6493
- return this.storage.setItem(this.STORAGE_PREFIX + s, JSON.stringify(x)), this.updateDesignsList(s, o, h), { success: !0, designId: s, message: "Design saved successfully" };
6577
+ return this.storage.setItem(this.STORAGE_PREFIX + s, JSON.stringify(h)), this.updateDesignsList(s, o, g), { success: !0, designId: s, message: "Design saved successfully" };
6494
6578
  } catch (s) {
6495
6579
  return console.error("Error saving design:", s), { success: !1, error: s.message };
6496
6580
  }
@@ -6500,10 +6584,10 @@ class di {
6500
6584
  try {
6501
6585
  let a = o;
6502
6586
  if (!o.startsWith("design_")) {
6503
- const x = this.getAllDesigns().find((n) => n.name === o);
6504
- if (!x)
6587
+ const h = this.getAllDesigns().find((n) => n.name === o);
6588
+ if (!h)
6505
6589
  return { success: !1, error: "Design not found" };
6506
- a = x.id;
6590
+ a = h.id;
6507
6591
  }
6508
6592
  const l = this.storage.getItem(this.STORAGE_PREFIX + a);
6509
6593
  return l ? { success: !0, data: JSON.parse(l) } : { success: !1, error: "Design not found" };
@@ -6536,8 +6620,8 @@ class di {
6536
6620
  const a = this.loadDesign(o);
6537
6621
  if (!a.success)
6538
6622
  return a;
6539
- const l = a.data, s = JSON.stringify(l, null, 2), h = new Blob([s], { type: "application/json" }), x = URL.createObjectURL(h), n = document.createElement("a");
6540
- return n.href = x, n.download = `${l.name}_${l.id}.json`, document.body.appendChild(n), n.click(), document.body.removeChild(n), URL.revokeObjectURL(x), { success: !0, message: "Design exported successfully" };
6623
+ const l = a.data, s = JSON.stringify(l, null, 2), g = new Blob([s], { type: "application/json" }), h = URL.createObjectURL(g), n = document.createElement("a");
6624
+ return n.href = h, n.download = `${l.name}_${l.id}.json`, document.body.appendChild(n), n.click(), document.body.removeChild(n), URL.revokeObjectURL(h), { success: !0, message: "Design exported successfully" };
6541
6625
  } catch (a) {
6542
6626
  return console.error("Error exporting design:", a), { success: !1, error: a.message };
6543
6627
  }
@@ -6549,13 +6633,13 @@ class di {
6549
6633
  const l = new FileReader();
6550
6634
  l.onload = (s) => {
6551
6635
  try {
6552
- const h = JSON.parse(s.target.result);
6553
- if (!this.validateDesignData(h)) {
6636
+ const g = JSON.parse(s.target.result);
6637
+ if (!this.validateDesignData(g)) {
6554
6638
  a({ success: !1, error: "Invalid design file format" });
6555
6639
  return;
6556
6640
  }
6557
- const x = this.generateDesignId(h.name + "_imported");
6558
- h.id = x, h.name += "_imported", h.timestamp = (/* @__PURE__ */ new Date()).toISOString(), h.metadata.lastModified = h.timestamp, this.storage.setItem(this.STORAGE_PREFIX + x, JSON.stringify(h)), this.updateDesignsList(x, h.name, h.timestamp), a({ success: !0, data: h, message: "Design imported successfully" });
6641
+ const h = this.generateDesignId(g.name + "_imported");
6642
+ g.id = h, g.name += "_imported", g.timestamp = (/* @__PURE__ */ new Date()).toISOString(), g.metadata.lastModified = g.timestamp, this.storage.setItem(this.STORAGE_PREFIX + h, JSON.stringify(g)), this.updateDesignsList(h, g.name, g.timestamp), a({ success: !0, data: g, message: "Design imported successfully" });
6559
6643
  } catch {
6560
6644
  a({ success: !1, error: "Failed to parse design file" });
6561
6645
  }
@@ -6623,13 +6707,13 @@ class di {
6623
6707
  return `design_${a}_${l}`;
6624
6708
  }
6625
6709
  updateDesignsList(o, a, l) {
6626
- const s = this.getAllDesigns(), h = s.findIndex((n) => n.id === o), x = {
6710
+ const s = this.getAllDesigns(), g = s.findIndex((n) => n.id === o), h = {
6627
6711
  id: o,
6628
6712
  name: a,
6629
6713
  timestamp: l,
6630
6714
  lastModified: l
6631
6715
  };
6632
- h >= 0 ? s[h] = x : s.push(x), s.sort((n, d) => new Date(d.timestamp) - new Date(n.timestamp)), this.storage.setItem(this.DESIGNS_LIST_KEY, JSON.stringify(s));
6716
+ g >= 0 ? s[g] = h : s.push(h), s.sort((n, c) => new Date(c.timestamp) - new Date(n.timestamp)), this.storage.setItem(this.DESIGNS_LIST_KEY, JSON.stringify(s));
6633
6717
  }
6634
6718
  validateDesignData(o) {
6635
6719
  return o && o.id && o.name && o.canvasData && Array.isArray(o.canvasData.elements);
@@ -6679,17 +6763,17 @@ const fi = $e((f, o) => {
6679
6763
  }
6680
6764
  ]
6681
6765
  },
6682
- initFile: h
6683
- } = f, [x, n] = N([]), [d, j] = N(null), [S, I] = N(!1), [y, E] = N(!1), [B, b] = N(!1), [F, J] = N({ x: 0, y: 0 }), [T, O] = N(null), [v, st] = N(800), [W, xt] = N(600), [Q, ft] = N(1), [_, at] = N(s.colorSettings[0]), [M, nt] = N(!1), [Z, ct] = N(!0), [Y, P] = N(!0), [C, tt] = N(s.sections[0]), [u, D] = N(!1), [L, H] = N({}), [G, et] = N([]), [X, q] = N(-1), [U] = N(new di("localStorage")), K = gt(null), kt = gt(null), mt = gt(null), pt = gt(null), Ot = gt(null), Bt = gt(new ci()), zt = gt(!1), [wt, ce] = N(null), lt = rt(() => {
6766
+ initFile: g
6767
+ } = f, [h, n] = N([]), [c, F] = N(null), [I, E] = N(!1), [m, B] = N(!1), [j, p] = N(!1), [v, X] = N({ x: 0, y: 0 }), [T, O] = N(null), [k, Z] = N(800), [W, xt] = N(600), [Q, ft] = N(1), [_, st] = N(s.colorSettings[0]), [M, nt] = N(!1), [tt, ct] = N(!0), [Y, P] = N(!0), [C, et] = N(s.sections[0]), [y, D] = N(!1), [L, H] = N({}), [G, it] = N([]), [J, q] = N(-1), [U] = N(new di("localStorage")), K = gt(null), kt = gt(null), pt = gt(null), wt = gt(null), Ot = gt(null), Bt = gt(new ci()), zt = gt(!1), [yt, ce] = N(null), lt = at(() => {
6684
6768
  const e = {
6685
- elements: JSON.parse(JSON.stringify(x)),
6686
- selectedElement: d ? { ...d } : null,
6769
+ elements: JSON.parse(JSON.stringify(h)),
6770
+ selectedElement: c ? { ...c } : null,
6687
6771
  timestamp: Date.now()
6688
- }, t = G.slice(0, X + 1);
6689
- t.push(e), t.length > 50 ? t.shift() : q(X + 1), et(t);
6690
- }, [x, d, G, X]), St = rt(() => ({
6691
- elements: x,
6692
- canvasWidth: v,
6772
+ }, t = G.slice(0, J + 1);
6773
+ t.push(e), t.length > 50 ? t.shift() : q(J + 1), it(t);
6774
+ }, [h, c, G, J]), St = at(() => ({
6775
+ elements: h,
6776
+ canvasWidth: k,
6693
6777
  canvasHeight: W,
6694
6778
  selectedColor: _,
6695
6779
  activeSection: C,
@@ -6698,26 +6782,26 @@ const fi = $e((f, o) => {
6698
6782
  zoomLevel: Q,
6699
6783
  showGrid: M,
6700
6784
  snapToGrid: Y,
6701
- selectedElement: d ? { ...d } : null,
6785
+ selectedElement: c ? { ...c } : null,
6702
6786
  canvasRef: K
6703
6787
  // Include reference for thumbnail generation
6704
- }), [x, v, W, _, C, s, L, Q, M, Y, d]);
6705
- ot(() => {
6788
+ }), [h, k, W, _, C, s, L, Q, M, Y, c]);
6789
+ rt(() => {
6706
6790
  const t = setTimeout(async () => {
6707
- if (x.length === 0 && G.length <= 1) {
6708
- if (h)
6791
+ if (h.length === 0 && G.length <= 1) {
6792
+ if (g)
6709
6793
  try {
6710
- const A = await fetch(h);
6794
+ const A = await fetch(g);
6711
6795
  if (A.ok) {
6712
6796
  const z = await A.text();
6713
6797
  if (z.trim()) {
6714
6798
  const $ = JSON.parse(z.trim());
6715
6799
  if (console.log("Loading design from file:", $), ce($), $.sections && typeof $.sections == "object") {
6716
- const dt = Object.keys($.sections)[0], it = $.sections[dt];
6717
- if (it && it.elements) {
6718
- n(it.elements || []), st(it.canvasWidth || 800), xt(it.canvasHeight || 600), at(it.selectedColor || s.colorSettings[0]), ft(it.zoomLevel || 1), nt(it.showGrid || !1), P(it.snapToGrid || !0), j(null), $.sections && H($.sections);
6800
+ const dt = Object.keys($.sections)[0], ot = $.sections[dt];
6801
+ if (ot && ot.elements) {
6802
+ n(ot.elements || []), Z(ot.canvasWidth || 800), xt(ot.canvasHeight || 600), st(ot.selectedColor || s.colorSettings[0]), ft(ot.zoomLevel || 1), nt(ot.showGrid || !1), P(ot.snapToGrid || !0), F(null), $.sections && H($.sections);
6719
6803
  const Rt = s.sections.find((Dt) => Dt.sectionName === dt);
6720
- Rt && tt(Rt), et([]), q(-1), setTimeout(() => {
6804
+ Rt && et(Rt), it([]), q(-1), setTimeout(() => {
6721
6805
  lt();
6722
6806
  }, 100);
6723
6807
  return;
@@ -6729,20 +6813,20 @@ const fi = $e((f, o) => {
6729
6813
  } catch (A) {
6730
6814
  console.error("Error loading design file:", A), console.warn("Using default text instead");
6731
6815
  }
6732
- const r = 24, c = "Arial", g = "Change me", p = document.createElement("canvas").getContext("2d");
6733
- p.font = `${r}px ${c}`;
6734
- const w = p.measureText(g).width, R = {
6816
+ const r = 24, d = "Arial", x = "Change me", w = document.createElement("canvas").getContext("2d");
6817
+ w.font = `${r}px ${d}`;
6818
+ const b = w.measureText(x).width, R = {
6735
6819
  id: ht(),
6736
6820
  type: "text",
6737
- x: v / 2 - w / 2,
6821
+ x: k / 2 - b / 2,
6738
6822
  // Center the actual text width
6739
6823
  y: W / 2 - r / 2,
6740
6824
  // Center based on font size
6741
- width: w,
6825
+ width: b,
6742
6826
  height: r,
6743
- text: g,
6827
+ text: x,
6744
6828
  fontSize: r,
6745
- fontFamily: c,
6829
+ fontFamily: d,
6746
6830
  fontWeight: "normal",
6747
6831
  fontStyle: "normal",
6748
6832
  textAlign: "left",
@@ -6753,14 +6837,14 @@ const fi = $e((f, o) => {
6753
6837
  rotation: 0,
6754
6838
  opacity: 1
6755
6839
  };
6756
- n([R]), j(R), setTimeout(() => {
6840
+ n([R]), F(R), setTimeout(() => {
6757
6841
  lt();
6758
6842
  }, 100);
6759
6843
  }
6760
6844
  }, 300);
6761
6845
  return () => clearTimeout(t);
6762
- }, [h, s.colorSettings, s.sections]);
6763
- const Wt = rt((e = "png", t = !0) => {
6846
+ }, [g, s.colorSettings, s.sections]);
6847
+ const Wt = at((e = "png", t = !0) => {
6764
6848
  const r = St();
6765
6849
  return s.sections, Bt.current.exportAllSections(
6766
6850
  { [(C == null ? void 0 : C.sectionName) || "main"]: r },
@@ -6770,12 +6854,13 @@ const fi = $e((f, o) => {
6770
6854
  image: C == null ? void 0 : C.sectionImage,
6771
6855
  sectionImage: C == null ? void 0 : C.sectionImage
6772
6856
  }],
6773
- v,
6857
+ k,
6774
6858
  W,
6775
6859
  e,
6776
- t
6860
+ t,
6861
+ yt
6777
6862
  );
6778
- }, [St, s.sections, C, v, W]), de = [
6863
+ }, [St, s.sections, C, k, W]), de = [
6779
6864
  "Arial",
6780
6865
  "Helvetica",
6781
6866
  "Times New Roman",
@@ -6791,18 +6876,18 @@ const fi = $e((f, o) => {
6791
6876
  "Bookman",
6792
6877
  "Avant Garde",
6793
6878
  "Century Gothic"
6794
- ], At = 20;
6795
- ot(() => {
6879
+ ], It = 20;
6880
+ rt(() => {
6796
6881
  const e = () => D(window.innerWidth < 768);
6797
6882
  return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
6798
- }, []), ot(() => {
6883
+ }, []), rt(() => {
6799
6884
  const e = document.createElement("canvas");
6800
- e.width = v, e.height = W, Ot.current = e;
6801
- }, [v, W]), ot(() => {
6885
+ e.width = k, e.height = W, Ot.current = e;
6886
+ }, [k, W]), rt(() => {
6802
6887
  G.length === 0 && lt();
6803
6888
  }, []);
6804
- const It = (e, t, r, c, g, m) => {
6805
- e.beginPath(), e.moveTo(t + m, r), e.lineTo(t + c - m, r), e.quadraticCurveTo(t + c, r, t + c, r + m), e.lineTo(t + c, r + g - m), e.quadraticCurveTo(t + c, r + g, t + c - m, r + g), e.lineTo(t + m, r + g), e.quadraticCurveTo(t, r + g, t, r + g - m), e.lineTo(t, r + m), e.quadraticCurveTo(t, r, t + m, r), e.closePath();
6889
+ const At = (e, t, r, d, x, u) => {
6890
+ e.beginPath(), e.moveTo(t + u, r), e.lineTo(t + d - u, r), e.quadraticCurveTo(t + d, r, t + d, r + u), e.lineTo(t + d, r + x - u), e.quadraticCurveTo(t + d, r + x, t + d - u, r + x), e.lineTo(t + u, r + x), e.quadraticCurveTo(t, r + x, t, r + x - u), e.lineTo(t, r + u), e.quadraticCurveTo(t, r, t + u, r), e.closePath();
6806
6891
  }, Qt = (e, t) => {
6807
6892
  if (!t.isIcon)
6808
6893
  return {
@@ -6814,120 +6899,121 @@ const fi = $e((f, o) => {
6814
6899
  cy: t.y + t.height / 2
6815
6900
  };
6816
6901
  e.save(), e.font = `${t.fontStyle || ""} ${t.fontWeight || ""} ${t.fontSize}px ${t.fontFamily}`, e.textBaseline = "alphabetic", e.textAlign = "left";
6817
- const r = e.measureText(t.text), c = r.actualBoundingBoxAscent ?? t.fontSize * 0.8, g = r.actualBoundingBoxDescent ?? t.fontSize * 0.2, m = r.actualBoundingBoxLeft ?? 0, p = r.actualBoundingBoxRight ?? r.width, k = m + p, w = c + g, R = t.x, A = t.y, z = R - k / 2 - m, $ = A - w / 2 - c;
6818
- return e.restore(), { x: z, y: $, width: k, height: w, cx: R, cy: A };
6902
+ const r = e.measureText(t.text), d = r.actualBoundingBoxAscent ?? t.fontSize * 0.8, x = r.actualBoundingBoxDescent ?? t.fontSize * 0.2, u = r.actualBoundingBoxLeft ?? 0, w = r.actualBoundingBoxRight ?? r.width, S = u + w, b = d + x, R = t.x, A = t.y, z = R - S / 2 - u, $ = A - b / 2 - d;
6903
+ return e.restore(), { x: z, y: $, width: S, height: b, cx: R, cy: A };
6819
6904
  }, fe = (e, t) => {
6820
6905
  if (!t) return;
6821
- const r = 8, c = 8, g = 4, m = 30, p = Qt(e, t), k = t.isIcon ? Math.max(r, 12) : r, w = {
6822
- x: -p.width / 2 - k,
6823
- y: -p.height / 2 - k,
6824
- w: p.width + k * 2,
6825
- h: p.height + k * 2
6906
+ const r = 8, d = 8, x = 4, u = 30, w = Qt(e, t), S = t.isIcon ? Math.max(r, 12) : r, b = {
6907
+ x: -w.width / 2 - S,
6908
+ y: -w.height / 2 - S,
6909
+ w: w.width + S * 2,
6910
+ h: w.height + S * 2
6826
6911
  };
6827
- e.save(), e.translate(p.cx, p.cy), t.rotation && e.rotate(t.rotation * Math.PI / 180);
6912
+ e.save(), e.translate(w.cx, w.cy), t.rotation && e.rotate(t.rotation * Math.PI / 180);
6828
6913
  const R = e.createLinearGradient(
6829
- w.x,
6830
- w.y,
6831
- w.x + w.w,
6832
- w.y + w.h
6914
+ b.x,
6915
+ b.y,
6916
+ b.x + b.w,
6917
+ b.y + b.h
6833
6918
  );
6834
- R.addColorStop(0, "#3b82f6"), R.addColorStop(0.5, "#1d4ed8"), R.addColorStop(1, "#3b82f6"), e.strokeStyle = "rgba(59,130,246,.3)", e.lineWidth = 3, It(
6919
+ R.addColorStop(0, "#3b82f6"), R.addColorStop(0.5, "#1d4ed8"), R.addColorStop(1, "#3b82f6"), e.strokeStyle = "rgba(59,130,246,.3)", e.lineWidth = 3, At(
6835
6920
  e,
6836
- w.x - 1,
6837
- w.y - 1,
6838
- w.w + 2,
6839
- w.h + 2,
6840
- g + 1
6841
- ), e.stroke(), e.strokeStyle = R, e.lineWidth = 2, e.setLineDash([8, 4]), It(e, w.x, w.y, w.w, w.h, g), e.stroke(), e.lineDashOffset = -(Date.now() / 50) % 12, e.strokeStyle = "#ffffff", e.lineWidth = 1, e.setLineDash([4, 8]), It(e, w.x, w.y, w.w, w.h, g), e.stroke(), e.setLineDash([]), e.lineDashOffset = 0, [
6842
- { x: w.x, y: w.y },
6843
- { x: w.x + w.w, y: w.y },
6844
- { x: w.x + w.w, y: w.y + w.h },
6845
- { x: w.x, y: w.y + w.h }
6921
+ b.x - 1,
6922
+ b.y - 1,
6923
+ b.w + 2,
6924
+ b.h + 2,
6925
+ x + 1
6926
+ ), e.stroke(), e.strokeStyle = R, e.lineWidth = 2, e.setLineDash([8, 4]), At(e, b.x, b.y, b.w, b.h, x), e.stroke(), e.lineDashOffset = -(Date.now() / 50) % 12, e.strokeStyle = "#ffffff", e.lineWidth = 1, e.setLineDash([4, 8]), At(e, b.x, b.y, b.w, b.h, x), e.stroke(), e.setLineDash([]), e.lineDashOffset = 0, [
6927
+ { x: b.x, y: b.y },
6928
+ { x: b.x + b.w, y: b.y },
6929
+ { x: b.x + b.w, y: b.y + b.h },
6930
+ { x: b.x, y: b.y + b.h }
6846
6931
  ].forEach(($) => {
6847
6932
  e.fillStyle = "rgba(0,0,0,.2)", e.fillRect(
6848
- $.x - c / 2 + 1,
6849
- $.y - c / 2 + 1,
6850
- c,
6851
- c
6933
+ $.x - d / 2 + 1,
6934
+ $.y - d / 2 + 1,
6935
+ d,
6936
+ d
6852
6937
  ), e.fillStyle = "#ffffff", e.fillRect(
6853
- $.x - c / 2,
6854
- $.y - c / 2,
6855
- c,
6856
- c
6938
+ $.x - d / 2,
6939
+ $.y - d / 2,
6940
+ d,
6941
+ d
6857
6942
  ), e.strokeStyle = "#3b82f6", e.lineWidth = 1, e.strokeRect(
6858
- $.x - c / 2,
6859
- $.y - c / 2,
6860
- c,
6861
- c
6943
+ $.x - d / 2,
6944
+ $.y - d / 2,
6945
+ d,
6946
+ d
6862
6947
  );
6863
6948
  });
6864
- const A = 0, z = w.y - m;
6865
- e.strokeStyle = "#3b82f6", e.lineWidth = 1, e.setLineDash([2, 2]), e.beginPath(), e.moveTo(A, z + 12), e.lineTo(A, w.y), e.stroke(), e.setLineDash([]), e.beginPath(), e.arc(A, z, 12, 0, 2 * Math.PI), e.fillStyle = "#f59e0b", e.fill(), e.strokeStyle = "#ffffff", e.lineWidth = 2, e.stroke(), e.strokeStyle = "#ffffff", e.lineWidth = 2, e.beginPath(), e.arc(A, z, 6, -Math.PI / 2, Math.PI, !1), e.stroke(), e.beginPath(), e.moveTo(A - 6, z), e.lineTo(A - 3, z - 3), e.lineTo(A - 3, z + 3), e.closePath(), e.fillStyle = "#ffffff", e.fill(), e.restore();
6949
+ const A = 0, z = b.y - u;
6950
+ e.strokeStyle = "#3b82f6", e.lineWidth = 1, e.setLineDash([2, 2]), e.beginPath(), e.moveTo(A, z + 12), e.lineTo(A, b.y), e.stroke(), e.setLineDash([]), e.beginPath(), e.arc(A, z, 12, 0, 2 * Math.PI), e.fillStyle = "#f59e0b", e.fill(), e.strokeStyle = "#ffffff", e.lineWidth = 2, e.stroke(), e.strokeStyle = "#ffffff", e.lineWidth = 2, e.beginPath(), e.arc(A, z, 6, -Math.PI / 2, Math.PI, !1), e.stroke(), e.beginPath(), e.moveTo(A - 6, z), e.lineTo(A - 3, z - 3), e.lineTo(A - 3, z + 3), e.closePath(), e.fillStyle = "#ffffff", e.fill(), e.restore();
6866
6951
  }, he = (e, t) => {
6867
6952
  if (!t) return [];
6868
- const r = Qt(e, t), c = t.isIcon ? Math.max(8, 12) : 8, g = 8, m = 30, p = (t.rotation || 0) * Math.PI / 180, k = {
6869
- x: -r.width / 2 - c,
6870
- y: -r.height / 2 - c,
6871
- w: r.width + c * 2,
6872
- h: r.height + c * 2
6873
- }, w = [
6874
- { x: k.x, y: k.y, type: "nw-resize" },
6875
- { x: k.x + k.w, y: k.y, type: "ne-resize" },
6876
- { x: k.x + k.w, y: k.y + k.h, type: "se-resize" },
6877
- { x: k.x, y: k.y + k.h, type: "sw-resize" },
6878
- { x: 0, y: k.y - m, type: "rotate" }
6879
- ], R = Math.cos(p), A = Math.sin(p);
6880
- return w.map((z) => ({
6953
+ const r = Qt(e, t), d = t.isIcon ? Math.max(8, 12) : 8, x = 8, u = 30, w = (t.rotation || 0) * Math.PI / 180, S = {
6954
+ x: -r.width / 2 - d,
6955
+ y: -r.height / 2 - d,
6956
+ w: r.width + d * 2,
6957
+ h: r.height + d * 2
6958
+ }, b = [
6959
+ { x: S.x, y: S.y, type: "nw-resize" },
6960
+ { x: S.x + S.w, y: S.y, type: "ne-resize" },
6961
+ { x: S.x + S.w, y: S.y + S.h, type: "se-resize" },
6962
+ { x: S.x, y: S.y + S.h, type: "sw-resize" },
6963
+ { x: 0, y: S.y - u, type: "rotate" }
6964
+ ], R = Math.cos(w), A = Math.sin(w);
6965
+ return b.map((z) => ({
6881
6966
  x: r.cx + (z.x * R - z.y * A),
6882
6967
  y: r.cy + (z.x * A + z.y * R),
6883
6968
  type: z.type,
6884
- size: z.type === "rotate" ? 24 : g
6969
+ size: z.type === "rotate" ? 24 : x
6885
6970
  }));
6886
6971
  }, $t = (e, t, r) => {
6887
6972
  if (!r) return null;
6888
- const c = K.current;
6889
- if (!c) return null;
6890
- const g = c.getContext("2d"), m = he(g, r);
6891
- for (const p of m) {
6892
- const k = e - p.x, w = t - p.y;
6893
- if (Math.sqrt(k * k + w * w) <= p.size / 2)
6894
- return p.type;
6973
+ const d = K.current;
6974
+ if (!d) return null;
6975
+ const x = d.getContext("2d"), u = he(x, r);
6976
+ for (const w of u) {
6977
+ const S = e - w.x, b = t - w.y;
6978
+ if (Math.sqrt(S * S + b * b) <= w.size / 2)
6979
+ return w.type;
6895
6980
  }
6896
6981
  return null;
6897
- }, Ft = rt(() => {
6898
- if (X > 0) {
6899
- const e = G[X - 1];
6900
- n(e.elements), j(e.selectedElement), q(X - 1);
6982
+ }, Ft = at(() => {
6983
+ if (J > 0) {
6984
+ const e = G[J - 1];
6985
+ n(e.elements), F(e.selectedElement), q(J - 1);
6901
6986
  }
6902
- }, [G, X]), bt = rt(() => {
6903
- if (X < G.length - 1) {
6904
- const e = G[X + 1];
6905
- n(e.elements), j(e.selectedElement), q(X + 1);
6987
+ }, [G, J]), bt = at(() => {
6988
+ if (J < G.length - 1) {
6989
+ const e = G[J + 1];
6990
+ n(e.elements), F(e.selectedElement), q(J + 1);
6906
6991
  }
6907
- }, [G, X]), ut = (e) => Y ? Math.round(e / At) * At : e;
6908
- ot(() => {
6992
+ }, [G, J]), ut = (e) => Y ? Math.round(e / It) * It : e;
6993
+ rt(() => {
6909
6994
  if (C != null && C.sectionImage) {
6910
- mt.current = null, pt.current = null;
6995
+ pt.current = null, wt.current = null;
6911
6996
  const e = K.current;
6912
- e && e.getContext("2d").clearRect(0, 0, v, W);
6997
+ if (e && e.getContext("2d").clearRect(0, 0, k, W), g && !yt)
6998
+ return;
6913
6999
  const t = new Image();
6914
7000
  t.crossOrigin = "anonymous", t.onload = () => {
6915
- mt.current = t, Xt(t, _);
7001
+ pt.current = t, Xt(t, _);
6916
7002
  }, t.onerror = () => {
6917
7003
  console.error("Failed to load background image:", C.sectionImage), V();
6918
7004
  };
6919
7005
  let r = C.sectionImage;
6920
- wt && wt.sectionImage && (C.sectionName === "Front" || wt.sections && Object.keys(wt.sections).includes(C.sectionName)) && (r = wt.sectionImage), t.src = r;
7006
+ yt && yt.sectionImage && (C.sectionName === "Front" || yt.sections && Object.keys(yt.sections).includes(C.sectionName)) && (r = yt.sectionImage), t.src = r;
6921
7007
  } else
6922
- mt.current = null, pt.current = null, V();
6923
- }, [C, _, wt]), ot(() => {
7008
+ pt.current = null, wt.current = null, V();
7009
+ }, [C, _, yt]), rt(() => {
6924
7010
  const e = (t) => {
6925
7011
  const r = document.activeElement;
6926
7012
  if (!(r && (r.tagName === "INPUT" || r.tagName === "TEXTAREA" || r.tagName === "SELECT" || r.isContentEditable))) {
6927
- if ((t.key === "Delete" || t.key === "Backspace") && d && !l) {
7013
+ if ((t.key === "Delete" || t.key === "Backspace") && c && !l) {
6928
7014
  t.preventDefault();
6929
- const g = d;
6930
- n((m) => m.filter((p) => p.id !== g.id)), j(null), lt();
7015
+ const x = c;
7016
+ n((u) => u.filter((w) => w.id !== x.id)), F(null), lt();
6931
7017
  }
6932
7018
  if (t.ctrlKey || t.metaKey)
6933
7019
  switch (t.key) {
@@ -6943,7 +7029,7 @@ const fi = $e((f, o) => {
6943
7029
  return document.addEventListener("keydown", e), () => {
6944
7030
  document.removeEventListener("keydown", e);
6945
7031
  };
6946
- }, [d, l, Ft, bt, lt]);
7032
+ }, [c, l, Ft, bt, lt]);
6947
7033
  const ge = (e) => {
6948
7034
  const t = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);
6949
7035
  return t ? {
@@ -6953,15 +7039,15 @@ const fi = $e((f, o) => {
6953
7039
  } : null;
6954
7040
  }, ht = () => `element_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`, xe = (e) => {
6955
7041
  e.strokeStyle = "#e0e0e0", e.lineWidth = 1, e.setLineDash([1, 1]);
6956
- for (let t = 0; t <= v; t += At)
7042
+ for (let t = 0; t <= k; t += It)
6957
7043
  e.beginPath(), e.moveTo(t, 0), e.lineTo(t, W), e.stroke();
6958
- for (let t = 0; t <= W; t += At)
6959
- e.beginPath(), e.moveTo(0, t), e.lineTo(v, t), e.stroke();
7044
+ for (let t = 0; t <= W; t += It)
7045
+ e.beginPath(), e.moveTo(0, t), e.lineTo(k, t), e.stroke();
6960
7046
  e.setLineDash([]);
6961
7047
  }, ye = (e, t) => {
6962
7048
  e.save();
6963
- const r = t.x + t.width / 2, c = t.y + t.height / 2;
6964
- switch (e.translate(r, c), t.rotation && e.rotate(t.rotation * Math.PI / 180), e.translate(-t.width / 2, -t.height / 2), t.type) {
7049
+ const r = t.x + t.width / 2, d = t.y + t.height / 2;
7050
+ switch (e.translate(r, d), t.rotation && e.rotate(t.rotation * Math.PI / 180), e.translate(-t.width / 2, -t.height / 2), t.type) {
6965
7051
  case "text":
6966
7052
  pe(e, t);
6967
7053
  break;
@@ -6987,38 +7073,38 @@ const fi = $e((f, o) => {
6987
7073
  Ce(e, t);
6988
7074
  break;
6989
7075
  case "pentagon":
6990
- Te(e, t);
7076
+ je(e, t);
6991
7077
  break;
6992
7078
  case "heart":
6993
- je(e, t);
7079
+ Te(e, t);
6994
7080
  break;
6995
7081
  case "oval":
6996
7082
  Ne(e, t);
6997
7083
  break;
6998
7084
  case "roundedRectangle":
6999
- Ae(e, t);
7085
+ Ie(e, t);
7000
7086
  break;
7001
7087
  case "image":
7002
7088
  Re(e, t);
7003
7089
  break;
7004
7090
  case "qrcode":
7005
- me(e, t);
7091
+ ue(e, t);
7006
7092
  break;
7007
7093
  case "barcode":
7008
- ue(e, t);
7094
+ me(e, t);
7009
7095
  break;
7010
7096
  case "sticker":
7011
7097
  De(e, t);
7012
7098
  break;
7013
7099
  case "horizontalLine":
7014
- Ie(e, t);
7100
+ Ae(e, t);
7015
7101
  break;
7016
7102
  case "embroidery":
7017
7103
  Ee(e, t);
7018
7104
  break;
7019
7105
  }
7020
7106
  e.restore();
7021
- }, ue = (e, t) => {
7107
+ }, me = (e, t) => {
7022
7108
  if (t.imageObject)
7023
7109
  e.drawImage(t.imageObject, 0, 0, t.width, t.height);
7024
7110
  else if (t.src && !t.imageLoading) {
@@ -7026,19 +7112,19 @@ const fi = $e((f, o) => {
7026
7112
  const r = new Image();
7027
7113
  r.onload = () => {
7028
7114
  n(
7029
- (c) => c.map(
7030
- (g) => g.id === t.id ? { ...g, imageObject: r, imageLoading: !1 } : g
7115
+ (d) => d.map(
7116
+ (x) => x.id === t.id ? { ...x, imageObject: r, imageLoading: !1 } : x
7031
7117
  )
7032
7118
  );
7033
7119
  }, r.onerror = () => {
7034
7120
  n(
7035
- (c) => c.map(
7036
- (g) => g.id === t.id ? { ...g, imageLoading: !1 } : g
7121
+ (d) => d.map(
7122
+ (x) => x.id === t.id ? { ...x, imageLoading: !1 } : x
7037
7123
  )
7038
7124
  );
7039
7125
  }, r.src = t.src, e.fillStyle = "#f0f0f0", e.fillRect(0, 0, t.width, t.height), e.strokeStyle = "#ccc", e.strokeRect(0, 0, t.width, t.height), e.fillStyle = "#666", e.font = "12px Arial", e.textAlign = "center", e.textBaseline = "middle", e.fillText("Loading...", t.width / 2, t.height / 2);
7040
7126
  } else t.imageLoading ? (e.fillStyle = "#f0f0f0", e.fillRect(0, 0, t.width, t.height), e.strokeStyle = "#ccc", e.strokeRect(0, 0, t.width, t.height), e.fillStyle = "#666", e.font = "12px Arial", e.textAlign = "center", e.textBaseline = "middle", e.fillText("Loading...", t.width / 2, t.height / 2)) : (e.fillStyle = "#f0f0f0", e.fillRect(0, 0, t.width, t.height), e.strokeStyle = "#ccc", e.strokeRect(0, 0, t.width, t.height), e.fillStyle = "#666", e.font = "12px Arial", e.textAlign = "center", e.textBaseline = "middle", e.fillText("No Barcode", t.width / 2, t.height / 2));
7041
- }, me = (e, t) => {
7127
+ }, ue = (e, t) => {
7042
7128
  if (t.imageObject)
7043
7129
  e.drawImage(t.imageObject, 0, 0, t.width, t.height);
7044
7130
  else if (t.src && !t.imageLoading) {
@@ -7046,14 +7132,14 @@ const fi = $e((f, o) => {
7046
7132
  const r = new Image();
7047
7133
  r.onload = () => {
7048
7134
  n(
7049
- (c) => c.map(
7050
- (g) => g.id === t.id ? { ...g, imageObject: r, imageLoading: !1 } : g
7135
+ (d) => d.map(
7136
+ (x) => x.id === t.id ? { ...x, imageObject: r, imageLoading: !1 } : x
7051
7137
  )
7052
7138
  );
7053
7139
  }, r.onerror = () => {
7054
7140
  n(
7055
- (c) => c.map(
7056
- (g) => g.id === t.id ? { ...g, imageLoading: !1 } : g
7141
+ (d) => d.map(
7142
+ (x) => x.id === t.id ? { ...x, imageLoading: !1 } : x
7057
7143
  )
7058
7144
  );
7059
7145
  }, r.src = t.src, e.fillStyle = "#f0f0f0", e.fillRect(0, 0, t.width, t.height), e.strokeStyle = "#ccc", e.strokeRect(0, 0, t.width, t.height), e.fillStyle = "#666", e.font = "12px Arial", e.textAlign = "center", e.textBaseline = "middle", e.fillText("Loading QR...", t.width / 2, t.height / 2);
@@ -7070,37 +7156,37 @@ const fi = $e((f, o) => {
7070
7156
  r = r.toLowerCase();
7071
7157
  break;
7072
7158
  case "capitalize":
7073
- r = r.replace(/\b\w/g, (k) => k.toUpperCase());
7159
+ r = r.replace(/\b\w/g, (S) => S.toUpperCase());
7074
7160
  break;
7075
7161
  }
7076
7162
  e.font = `${t.fontStyle || "normal"} ${t.fontWeight || "normal"} ${t.fontSize || 20}px ${t.fontFamily || "Arial"}`, e.fillStyle = t.fill || "#000000", e.textAlign = t.textAlign || "left", e.textBaseline = "top", t.opacity !== void 0 && (e.globalAlpha = t.opacity), t.stroke && t.strokeWidth > 0 && (e.strokeStyle = t.stroke, e.lineWidth = t.strokeWidth);
7077
- const c = r.split(`
7078
- `), g = (t.fontSize || 20) * (t.lineHeight || 1.2), m = Math.max(...c.map((k) => e.measureText(k).width)), p = c.length * g;
7163
+ const d = r.split(`
7164
+ `), x = (t.fontSize || 20) * (t.lineHeight || 1.2), u = Math.max(...d.map((S) => e.measureText(S).width)), w = d.length * x;
7079
7165
  if (t.backgroundColor && t.backgroundColor !== "transparent") {
7080
7166
  e.fillStyle = t.backgroundColor;
7081
- const k = t.backgroundPadding || 4;
7167
+ const S = t.backgroundPadding || 4;
7082
7168
  e.fillRect(
7083
- -k,
7084
- -k,
7085
- m + k * 2,
7086
- p + k * 2
7169
+ -S,
7170
+ -S,
7171
+ u + S * 2,
7172
+ w + S * 2
7087
7173
  ), e.fillStyle = t.fill || "#000000";
7088
7174
  }
7089
- c.forEach((k, w) => {
7090
- const R = w * g, A = e.measureText(k).width;
7091
- t.stroke && t.strokeWidth > 0 && e.strokeText(k, 0, R), e.fillText(k, 0, R);
7175
+ d.forEach((S, b) => {
7176
+ const R = b * x, A = e.measureText(S).width;
7177
+ t.stroke && t.strokeWidth > 0 && e.strokeText(S, 0, R), e.fillText(S, 0, R);
7092
7178
  const z = t.fontSize || 20, $ = t.decorationColor || t.fill || "#000000", dt = Math.max(1, z / 20);
7093
7179
  if (e.strokeStyle = $, e.lineWidth = dt, t.textDecoration === "underline" || t.underline) {
7094
- const it = R + z + 2;
7095
- e.beginPath(), e.moveTo(0, it), e.lineTo(A, it), e.stroke();
7180
+ const ot = R + z + 2;
7181
+ e.beginPath(), e.moveTo(0, ot), e.lineTo(A, ot), e.stroke();
7096
7182
  }
7097
7183
  if (t.textDecoration === "overline" || t.overline) {
7098
- const it = R - 2;
7099
- e.beginPath(), e.moveTo(0, it), e.lineTo(A, it), e.stroke();
7184
+ const ot = R - 2;
7185
+ e.beginPath(), e.moveTo(0, ot), e.lineTo(A, ot), e.stroke();
7100
7186
  }
7101
7187
  if (t.textDecoration === "line-through" || t.strikethrough) {
7102
- const it = R + z / 2;
7103
- e.beginPath(), e.moveTo(0, it), e.lineTo(A, it), e.stroke();
7188
+ const ot = R + z / 2;
7189
+ e.beginPath(), e.moveTo(0, ot), e.lineTo(A, ot), e.stroke();
7104
7190
  }
7105
7191
  typeof t.textDecoration == "string" && t.textDecoration.includes(" ") && t.textDecoration.split(" ").forEach((Rt) => {
7106
7192
  switch (Rt.trim()) {
@@ -7122,81 +7208,81 @@ const fi = $e((f, o) => {
7122
7208
  }, we = (e, t) => {
7123
7209
  t.fill && t.fill !== "transparent" && (e.fillStyle = t.fill, e.fillRect(0, 0, t.width, t.height)), t.stroke && t.strokeWidth > 0 && (e.strokeStyle = t.stroke, e.lineWidth = t.strokeWidth, e.strokeRect(0, 0, t.width, t.height));
7124
7210
  }, be = (e, t) => {
7125
- const r = Math.min(t.width, t.height) / 2, c = t.width / 2, g = t.height / 2;
7126
- e.beginPath(), e.arc(c, g, r, 0, 2 * Math.PI), t.fill && t.fill !== "transparent" && (e.fillStyle = t.fill, e.fill()), t.stroke && t.strokeWidth > 0 && (e.strokeStyle = t.stroke, e.lineWidth = t.strokeWidth, e.stroke());
7211
+ const r = Math.min(t.width, t.height) / 2, d = t.width / 2, x = t.height / 2;
7212
+ e.beginPath(), e.arc(d, x, r, 0, 2 * Math.PI), t.fill && t.fill !== "transparent" && (e.fillStyle = t.fill, e.fill()), t.stroke && t.strokeWidth > 0 && (e.strokeStyle = t.stroke, e.lineWidth = t.strokeWidth, e.stroke());
7127
7213
  }, ve = (e, t) => {
7128
7214
  const r = t.width / 2;
7129
7215
  t.height / 2, e.beginPath(), e.moveTo(r, 0), e.lineTo(0, t.height), e.lineTo(t.width, t.height), e.closePath(), t.fill && t.fill !== "transparent" && (e.fillStyle = t.fill, e.fill()), t.stroke && t.strokeWidth > 0 && (e.strokeStyle = t.stroke, e.lineWidth = t.strokeWidth, e.stroke());
7130
7216
  }, ke = (e, t) => {
7131
- const r = t.width / 2, c = t.height / 2, g = Math.min(t.width, t.height) / 2, m = g * 0.4, p = t.numPoints || 5;
7217
+ const r = t.width / 2, d = t.height / 2, x = Math.min(t.width, t.height) / 2, u = x * 0.4, w = t.numPoints || 5;
7132
7218
  e.beginPath();
7133
- for (let k = 0; k < p * 2; k++) {
7134
- const w = k % 2 === 0 ? g : m, R = k * Math.PI / p, A = r + Math.cos(R) * w, z = c + Math.sin(R) * w;
7135
- k === 0 ? e.moveTo(A, z) : e.lineTo(A, z);
7219
+ for (let S = 0; S < w * 2; S++) {
7220
+ const b = S % 2 === 0 ? x : u, R = S * Math.PI / w, A = r + Math.cos(R) * b, z = d + Math.sin(R) * b;
7221
+ S === 0 ? e.moveTo(A, z) : e.lineTo(A, z);
7136
7222
  }
7137
7223
  e.closePath(), t.fill && t.fill !== "transparent" && (e.fillStyle = t.fill, e.fill()), t.stroke && t.strokeWidth > 0 && (e.strokeStyle = t.stroke, e.lineWidth = t.strokeWidth, e.stroke());
7138
7224
  }, Se = (e, t) => {
7139
- const r = t.width, c = t.height, g = r * 0.3;
7140
- e.beginPath(), e.moveTo(r / 2, 0), e.lineTo(r, c * 0.6), e.lineTo(r - g, c * 0.6), e.lineTo(r - g, c), e.lineTo(g, c), e.lineTo(g, c * 0.6), e.lineTo(0, c * 0.6), e.closePath(), t.fill && t.fill !== "transparent" && (e.fillStyle = t.fill, e.fill()), t.stroke && t.strokeWidth > 0 && (e.strokeStyle = t.stroke, e.lineWidth = t.strokeWidth, e.stroke());
7225
+ const r = t.width, d = t.height, x = r * 0.3;
7226
+ e.beginPath(), e.moveTo(r / 2, 0), e.lineTo(r, d * 0.6), e.lineTo(r - x, d * 0.6), e.lineTo(r - x, d), e.lineTo(x, d), e.lineTo(x, d * 0.6), e.lineTo(0, d * 0.6), e.closePath(), t.fill && t.fill !== "transparent" && (e.fillStyle = t.fill, e.fill()), t.stroke && t.strokeWidth > 0 && (e.strokeStyle = t.stroke, e.lineWidth = t.strokeWidth, e.stroke());
7141
7227
  }, Fe = (e, t) => {
7142
- const r = t.width / 2, c = t.height / 2;
7143
- e.beginPath(), e.moveTo(r, 0), e.lineTo(t.width, c), e.lineTo(r, t.height), e.lineTo(0, c), e.closePath(), t.fill && t.fill !== "transparent" && (e.fillStyle = t.fill, e.fill()), t.stroke && t.strokeWidth > 0 && (e.strokeStyle = t.stroke, e.lineWidth = t.strokeWidth, e.stroke());
7228
+ const r = t.width / 2, d = t.height / 2;
7229
+ e.beginPath(), e.moveTo(r, 0), e.lineTo(t.width, d), e.lineTo(r, t.height), e.lineTo(0, d), e.closePath(), t.fill && t.fill !== "transparent" && (e.fillStyle = t.fill, e.fill()), t.stroke && t.strokeWidth > 0 && (e.strokeStyle = t.stroke, e.lineWidth = t.strokeWidth, e.stroke());
7144
7230
  }, Ce = (e, t) => {
7145
- const r = t.width / 2, c = t.height / 2, g = Math.min(t.width, t.height) / 2, m = 6;
7231
+ const r = t.width / 2, d = t.height / 2, x = Math.min(t.width, t.height) / 2, u = 6;
7146
7232
  e.beginPath();
7147
- for (let p = 0; p < m; p++) {
7148
- const k = p * 2 * Math.PI / m - Math.PI / 2, w = r + g * Math.cos(k), R = c + g * Math.sin(k);
7149
- p === 0 ? e.moveTo(w, R) : e.lineTo(w, R);
7233
+ for (let w = 0; w < u; w++) {
7234
+ const S = w * 2 * Math.PI / u - Math.PI / 2, b = r + x * Math.cos(S), R = d + x * Math.sin(S);
7235
+ w === 0 ? e.moveTo(b, R) : e.lineTo(b, R);
7150
7236
  }
7151
7237
  e.closePath(), t.fill && t.fill !== "transparent" && (e.fillStyle = t.fill, e.fill()), t.stroke && t.strokeWidth > 0 && (e.strokeStyle = t.stroke, e.lineWidth = t.strokeWidth, e.stroke());
7152
- }, Te = (e, t) => {
7153
- const r = t.width / 2, c = t.height / 2, g = Math.min(t.width, t.height) / 2, m = 5;
7238
+ }, je = (e, t) => {
7239
+ const r = t.width / 2, d = t.height / 2, x = Math.min(t.width, t.height) / 2, u = 5;
7154
7240
  e.beginPath();
7155
- for (let p = 0; p < m; p++) {
7156
- const k = p * 2 * Math.PI / m - Math.PI / 2, w = r + g * Math.cos(k), R = c + g * Math.sin(k);
7157
- p === 0 ? e.moveTo(w, R) : e.lineTo(w, R);
7241
+ for (let w = 0; w < u; w++) {
7242
+ const S = w * 2 * Math.PI / u - Math.PI / 2, b = r + x * Math.cos(S), R = d + x * Math.sin(S);
7243
+ w === 0 ? e.moveTo(b, R) : e.lineTo(b, R);
7158
7244
  }
7159
7245
  e.closePath(), t.fill && t.fill !== "transparent" && (e.fillStyle = t.fill, e.fill()), t.stroke && t.strokeWidth > 0 && (e.strokeStyle = t.stroke, e.lineWidth = t.strokeWidth, e.stroke());
7160
- }, je = (e, t) => {
7161
- const r = t.width, c = t.height, g = 0, m = 0;
7246
+ }, Te = (e, t) => {
7247
+ const r = t.width, d = t.height, x = 0, u = 0;
7162
7248
  e.beginPath();
7163
- const p = c * 0.3;
7164
- e.moveTo(g + r / 2, m + p), e.bezierCurveTo(
7165
- g + r / 2,
7166
- m,
7167
- g,
7168
- m,
7169
- g,
7170
- m + p
7249
+ const w = d * 0.3;
7250
+ e.moveTo(x + r / 2, u + w), e.bezierCurveTo(
7251
+ x + r / 2,
7252
+ u,
7253
+ x,
7254
+ u,
7255
+ x,
7256
+ u + w
7171
7257
  ), e.bezierCurveTo(
7172
- g,
7173
- m + (c + p) / 2,
7174
- g + r / 2,
7175
- m + (c + p) / 2,
7176
- g + r / 2,
7177
- m + c
7258
+ x,
7259
+ u + (d + w) / 2,
7260
+ x + r / 2,
7261
+ u + (d + w) / 2,
7262
+ x + r / 2,
7263
+ u + d
7178
7264
  ), e.bezierCurveTo(
7179
- g + r / 2,
7180
- m + (c + p) / 2,
7181
- g + r,
7182
- m + (c + p) / 2,
7183
- g + r,
7184
- m + p
7265
+ x + r / 2,
7266
+ u + (d + w) / 2,
7267
+ x + r,
7268
+ u + (d + w) / 2,
7269
+ x + r,
7270
+ u + w
7185
7271
  ), e.bezierCurveTo(
7186
- g + r,
7187
- m,
7188
- g + r / 2,
7189
- m,
7190
- g + r / 2,
7191
- m + p
7272
+ x + r,
7273
+ u,
7274
+ x + r / 2,
7275
+ u,
7276
+ x + r / 2,
7277
+ u + w
7192
7278
  ), e.closePath(), t.fill && t.fill !== "transparent" && (e.fillStyle = t.fill, e.fill()), t.stroke && t.strokeWidth > 0 && (e.strokeStyle = t.stroke, e.lineWidth = t.strokeWidth, e.stroke());
7193
7279
  }, Ne = (e, t) => {
7194
- const r = t.width / 2, c = t.height / 2, g = t.width / 2, m = t.height / 2;
7195
- e.beginPath(), e.ellipse(r, c, g, m, 0, 0, 2 * Math.PI), t.fill && t.fill !== "transparent" && (e.fillStyle = t.fill, e.fill()), t.stroke && t.strokeWidth > 0 && (e.strokeStyle = t.stroke, e.lineWidth = t.strokeWidth, e.stroke());
7196
- }, Ae = (e, t) => {
7197
- const r = Math.min(t.width, t.height) * 0.1;
7198
- It(e, 0, 0, t.width, t.height, r), t.fill && t.fill !== "transparent" && (e.fillStyle = t.fill, e.fill()), t.stroke && t.strokeWidth > 0 && (e.strokeStyle = t.stroke, e.lineWidth = t.strokeWidth, e.stroke());
7280
+ const r = t.width / 2, d = t.height / 2, x = t.width / 2, u = t.height / 2;
7281
+ e.beginPath(), e.ellipse(r, d, x, u, 0, 0, 2 * Math.PI), t.fill && t.fill !== "transparent" && (e.fillStyle = t.fill, e.fill()), t.stroke && t.strokeWidth > 0 && (e.strokeStyle = t.stroke, e.lineWidth = t.strokeWidth, e.stroke());
7199
7282
  }, Ie = (e, t) => {
7283
+ const r = Math.min(t.width, t.height) * 0.1;
7284
+ At(e, 0, 0, t.width, t.height, r), t.fill && t.fill !== "transparent" && (e.fillStyle = t.fill, e.fill()), t.stroke && t.strokeWidth > 0 && (e.strokeStyle = t.stroke, e.lineWidth = t.strokeWidth, e.stroke());
7285
+ }, Ae = (e, t) => {
7200
7286
  e.save(), t.opacity !== void 0 && (e.globalAlpha = t.opacity), e.strokeStyle = t.stroke || t.fill || "#000000", e.lineWidth = t.strokeWidth || t.height || 2, e.lineCap = "round", e.beginPath(), e.moveTo(0, t.height / 2), e.lineTo(t.width, t.height / 2), e.stroke(), e.restore();
7201
7287
  }, Re = (e, t) => {
7202
7288
  const r = t.src || t.imageData;
@@ -7222,8 +7308,8 @@ const fi = $e((f, o) => {
7222
7308
  }
7223
7309
  }
7224
7310
  e.fillStyle = "#f0f0f0", e.fillRect(0, 0, t.width, t.height), e.strokeStyle = "#ccc", e.lineWidth = 1, e.strokeRect(0, 0, t.width, t.height), e.fillStyle = "#666", e.font = "14px Arial", e.textAlign = "center", e.textBaseline = "middle", e.fillText("Loading...", t.width / 2, t.height / 2);
7225
- } catch (c) {
7226
- console.error("Error drawing image:", c), e.fillStyle = "#ffebee", e.fillRect(0, 0, t.width, t.height), e.strokeStyle = "#f44336", e.lineWidth = 2, e.strokeRect(0, 0, t.width, t.height), e.fillStyle = "#f44336", e.font = "14px Arial", e.textAlign = "center", e.textBaseline = "middle", e.fillText("Error loading image", t.width / 2, t.height / 2);
7311
+ } catch (d) {
7312
+ console.error("Error drawing image:", d), e.fillStyle = "#ffebee", e.fillRect(0, 0, t.width, t.height), e.strokeStyle = "#f44336", e.lineWidth = 2, e.strokeRect(0, 0, t.width, t.height), e.fillStyle = "#f44336", e.font = "14px Arial", e.textAlign = "center", e.textBaseline = "middle", e.fillText("Error loading image", t.width / 2, t.height / 2);
7227
7313
  }
7228
7314
  else
7229
7315
  e.fillStyle = "#f8f8f8", e.fillRect(0, 0, t.width, t.height), e.strokeStyle = "#ddd", e.lineWidth = 1, e.strokeRect(0, 0, t.width, t.height), e.fillStyle = "#999", e.font = "14px Arial", e.textAlign = "center", e.textBaseline = "middle", e.fillText("No Image", t.width / 2, t.height / 2);
@@ -7257,40 +7343,40 @@ const fi = $e((f, o) => {
7257
7343
  e.fillStyle = "#f9f9f9", e.fillRect(0, 0, t.width, t.height), e.strokeStyle = "#ddd", e.lineWidth = 2, e.strokeRect(0, 0, t.width, t.height), e.fillStyle = "#999", e.font = "24px Arial", e.textAlign = "center", e.textBaseline = "middle", e.fillText("🧵", t.width / 2, t.height / 2 - 10), e.fillStyle = "#666", e.font = "12px Arial", e.fillText(r, t.width / 2, t.height / 2 + 15);
7258
7344
  }, Ht = (e, t, r) => {
7259
7345
  if (!r) return !1;
7260
- const c = r.x + r.width / 2, g = r.y + r.height / 2, m = e - c, p = t - g, k = -(r.rotation || 0) * Math.PI / 180, w = Math.cos(k), R = Math.sin(k), A = m * w - p * R, z = m * R + p * w, $ = r.width / 2, dt = r.height / 2;
7346
+ const d = r.x + r.width / 2, x = r.y + r.height / 2, u = e - d, w = t - x, S = -(r.rotation || 0) * Math.PI / 180, b = Math.cos(S), R = Math.sin(S), A = u * b - w * R, z = u * R + w * b, $ = r.width / 2, dt = r.height / 2;
7261
7347
  return A >= -$ && A <= $ && z >= -dt && z <= dt;
7262
- }, Be = rt(() => {
7263
- (S || y || B) && lt(), I(!1), E(!1), b(!1), O(null);
7348
+ }, Be = at(() => {
7349
+ (I || m || j) && lt(), E(!1), B(!1), p(!1), O(null);
7264
7350
  const e = K.current;
7265
7351
  e && (e.style.cursor = "default");
7266
- }, [S, y, B, lt]);
7267
- ot(() => {
7352
+ }, [I, m, j, lt]);
7353
+ rt(() => {
7268
7354
  const e = (t) => {
7269
7355
  if (l) return;
7270
7356
  const r = document.activeElement;
7271
- if (!(r && (r.tagName === "INPUT" || r.tagName === "TEXTAREA" || r.tagName === "SELECT" || r.isContentEditable)) && ((t.ctrlKey || t.metaKey) && (t.key === "z" && !t.shiftKey ? (t.preventDefault(), Ft()) : (t.key === "z" && t.shiftKey || t.key === "y") && (t.preventDefault(), bt())), (t.key === "Delete" || t.key === "Backspace") && d && (Mt(d.id), t.preventDefault()), (t.ctrlKey || t.metaKey) && t.key === "d" && d && (_t(d.id), t.preventDefault()), d && ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(t.key))) {
7357
+ if (!(r && (r.tagName === "INPUT" || r.tagName === "TEXTAREA" || r.tagName === "SELECT" || r.isContentEditable)) && ((t.ctrlKey || t.metaKey) && (t.key === "z" && !t.shiftKey ? (t.preventDefault(), Ft()) : (t.key === "z" && t.shiftKey || t.key === "y") && (t.preventDefault(), bt())), (t.key === "Delete" || t.key === "Backspace") && c && (Mt(c.id), t.preventDefault()), (t.ctrlKey || t.metaKey) && t.key === "d" && c && (_t(c.id), t.preventDefault()), c && ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(t.key))) {
7272
7358
  t.preventDefault();
7273
- const g = t.shiftKey ? 10 : 1;
7274
- let m = {};
7359
+ const x = t.shiftKey ? 10 : 1;
7360
+ let u = {};
7275
7361
  switch (t.key) {
7276
7362
  case "ArrowUp":
7277
- m.y = d.y - g;
7363
+ u.y = c.y - x;
7278
7364
  break;
7279
7365
  case "ArrowDown":
7280
- m.y = d.y + g;
7366
+ u.y = c.y + x;
7281
7367
  break;
7282
7368
  case "ArrowLeft":
7283
- m.x = d.x - g;
7369
+ u.x = c.x - x;
7284
7370
  break;
7285
7371
  case "ArrowRight":
7286
- m.x = d.x + g;
7372
+ u.x = c.x + x;
7287
7373
  break;
7288
7374
  }
7289
- Gt(d.id, m), lt();
7375
+ Gt(c.id, u), lt();
7290
7376
  }
7291
7377
  };
7292
7378
  return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
7293
- }, [d, Ft, bt, l]);
7379
+ }, [c, Ft, bt, l]);
7294
7380
  const ze = (e, t = {}) => {
7295
7381
  const r = {
7296
7382
  id: ht(),
@@ -7316,16 +7402,16 @@ const fi = $e((f, o) => {
7316
7402
  r.id = ht(), r.imageData = t.imageData || null, r.width = t.width || 200, r.height = t.height || 200;
7317
7403
  break;
7318
7404
  case "qrcode":
7319
- r.id = ht(), r.type = "qrcode", r.x = (t == null ? void 0 : t.x) || v / 2 - ((t == null ? void 0 : t.width) || 100) / 2, r.y = (t == null ? void 0 : t.y) || W / 2 - ((t == null ? void 0 : t.height) || 100) / 2, r.width = (t == null ? void 0 : t.width) || 100, r.height = (t == null ? void 0 : t.height) || 100, r.src = (t == null ? void 0 : t.src) || "", r.data = (t == null ? void 0 : t.data) || "", r.rotation = 0, r.opacity = 1;
7405
+ r.id = ht(), r.type = "qrcode", r.x = (t == null ? void 0 : t.x) || k / 2 - ((t == null ? void 0 : t.width) || 100) / 2, r.y = (t == null ? void 0 : t.y) || W / 2 - ((t == null ? void 0 : t.height) || 100) / 2, r.width = (t == null ? void 0 : t.width) || 100, r.height = (t == null ? void 0 : t.height) || 100, r.src = (t == null ? void 0 : t.src) || "", r.data = (t == null ? void 0 : t.data) || "", r.rotation = 0, r.opacity = 1;
7320
7406
  break;
7321
7407
  case "barcode":
7322
- r.id = ht(), r.type = "barcode", r.x = (t == null ? void 0 : t.x) || v / 2 - ((t == null ? void 0 : t.width) || 200) / 2, r.y = (t == null ? void 0 : t.y) || W / 2 - ((t == null ? void 0 : t.height) || 100) / 2, r.width = (t == null ? void 0 : t.width) || 200, r.height = (t == null ? void 0 : t.height) || 100, r.src = (t == null ? void 0 : t.src) || "", r.data = (t == null ? void 0 : t.data) || "", r.format = (t == null ? void 0 : t.format) || "CODE128", r.rotation = 0, r.opacity = 1, r.imageObject = (t == null ? void 0 : t.imageObject) || null;
7408
+ r.id = ht(), r.type = "barcode", r.x = (t == null ? void 0 : t.x) || k / 2 - ((t == null ? void 0 : t.width) || 200) / 2, r.y = (t == null ? void 0 : t.y) || W / 2 - ((t == null ? void 0 : t.height) || 100) / 2, r.width = (t == null ? void 0 : t.width) || 200, r.height = (t == null ? void 0 : t.height) || 100, r.src = (t == null ? void 0 : t.src) || "", r.data = (t == null ? void 0 : t.data) || "", r.format = (t == null ? void 0 : t.format) || "CODE128", r.rotation = 0, r.opacity = 1, r.imageObject = (t == null ? void 0 : t.imageObject) || null;
7323
7409
  break;
7324
7410
  case "sticker":
7325
7411
  r.id = ht(), r.type = "sticker", r.imageData = (t == null ? void 0 : t.imageData) || null, r.width = t.width || 200, r.height = t.height || 200;
7326
7412
  break;
7327
7413
  case "horizontalLine":
7328
- r.id = ht(), r.type = "horizontalLine", r.x = v / 2 - 100, r.y = W / 2 - 1, r.width = 200, r.height = 2, r.fill = "#000000", r.stroke = "#000000", r.strokeWidth = 2, r.rotation = 0, r.opacity = 1;
7414
+ r.id = ht(), r.type = "horizontalLine", r.x = k / 2 - 100, r.y = W / 2 - 1, r.width = 200, r.height = 2, r.fill = "#000000", r.stroke = "#000000", r.strokeWidth = 2, r.rotation = 0, r.opacity = 1;
7329
7415
  break;
7330
7416
  case "embroidery":
7331
7417
  r.id = ht(), r.type = "embroidery", r.imageData = (t == null ? void 0 : t.imageData) || null, r.width = t.width || 200, r.height = t.height || 200;
@@ -7346,15 +7432,15 @@ const fi = $e((f, o) => {
7346
7432
  console.warn(`Unknown element type: ${e}`);
7347
7433
  return;
7348
7434
  }
7349
- n((c) => [...c, r]), j(r), lt();
7435
+ n((d) => [...d, r]), F(r), lt();
7350
7436
  }, Gt = (e, t) => {
7351
7437
  n((r) => r.map(
7352
- (c) => c.id === e ? { ...c, ...t } : c
7353
- )), d && d.id === e && j((r) => ({ ...r, ...t }));
7354
- }, Mt = rt(() => {
7355
- d && (n((e) => e.filter((t) => t.id !== d.id)), j(null), lt());
7356
- }, [d, lt]), _t = (e) => {
7357
- const t = x.find((r) => r.id === e);
7438
+ (d) => d.id === e ? { ...d, ...t } : d
7439
+ )), c && c.id === e && F((r) => ({ ...r, ...t }));
7440
+ }, Mt = at(() => {
7441
+ c && (n((e) => e.filter((t) => t.id !== c.id)), F(null), lt());
7442
+ }, [c, lt]), _t = (e) => {
7443
+ const t = h.find((r) => r.id === e);
7358
7444
  if (t) {
7359
7445
  const r = {
7360
7446
  ...t,
@@ -7362,23 +7448,23 @@ const fi = $e((f, o) => {
7362
7448
  x: t.x + 20,
7363
7449
  y: t.y + 20
7364
7450
  };
7365
- n((c) => [...c, r]), j(r), lt();
7451
+ n((d) => [...d, r]), F(r), lt();
7366
7452
  }
7367
7453
  }, Yt = (e, t) => {
7368
- const r = x.findIndex((m) => m.id === e);
7454
+ const r = h.findIndex((u) => u.id === e);
7369
7455
  if (r === -1) return;
7370
- const c = [...x], g = c[r];
7371
- t === "up" && r < c.length - 1 ? (c[r] = c[r + 1], c[r + 1] = g) : t === "down" && r > 0 ? (c[r] = c[r - 1], c[r - 1] = g) : t === "top" ? (c.splice(r, 1), c.push(g)) : t === "bottom" && (c.splice(r, 1), c.unshift(g)), n(c), lt();
7456
+ const d = [...h], x = d[r];
7457
+ t === "up" && r < d.length - 1 ? (d[r] = d[r + 1], d[r + 1] = x) : t === "down" && r > 0 ? (d[r] = d[r - 1], d[r - 1] = x) : t === "top" ? (d.splice(r, 1), d.push(x)) : t === "bottom" && (d.splice(r, 1), d.unshift(x)), n(d), lt();
7372
7458
  };
7373
- rt(() => {
7459
+ at(() => {
7374
7460
  C && H((e) => ({
7375
7461
  ...e,
7376
7462
  [C.sectionName]: {
7377
- elements: [...x],
7463
+ elements: [...h],
7378
7464
  selectedColor: _
7379
7465
  }
7380
7466
  }));
7381
- }, [C, x, _]);
7467
+ }, [C, h, _]);
7382
7468
  const [, We] = He((e) => e + 1, 0);
7383
7469
  setTimeout(() => {
7384
7470
  We();
@@ -7396,25 +7482,26 @@ const fi = $e((f, o) => {
7396
7482
  try {
7397
7483
  const t = St();
7398
7484
  console.log("canvas data to export: ", t);
7399
- const r = {}, c = (C == null ? void 0 : C.sectionName) || "main";
7400
- r[c] = {
7485
+ const r = {}, d = (C == null ? void 0 : C.sectionName) || "main";
7486
+ r[d] = {
7401
7487
  elements: t.elements,
7402
7488
  selectedColor: t.selectedColor,
7403
7489
  canvasWidth: t.canvasWidth,
7404
7490
  canvasHeight: t.canvasHeight
7405
7491
  }, t.sectionDesigns && typeof t.sectionDesigns == "object" && Object.assign(r, t.sectionDesigns);
7406
- const g = s.sections && s.sections.length > 0 ? s.sections : [{
7407
- id: c,
7408
- sectionName: c,
7492
+ const x = s.sections && s.sections.length > 0 ? s.sections : [{
7493
+ id: d,
7494
+ sectionName: d,
7409
7495
  image: C == null ? void 0 : C.sectionImage,
7410
7496
  sectionImage: C == null ? void 0 : C.sectionImage
7411
7497
  }];
7412
7498
  return await Bt.current.exportAllSectionsAsJSON(
7413
7499
  r,
7414
- g,
7415
- v,
7500
+ x,
7501
+ k,
7416
7502
  W,
7417
- e
7503
+ e,
7504
+ yt
7418
7505
  );
7419
7506
  } catch (t) {
7420
7507
  throw console.error("Export as JSON failed:", t), t;
@@ -7423,272 +7510,272 @@ const fi = $e((f, o) => {
7423
7510
  exportCurrentSectionAsJSON: async (e = "png") => {
7424
7511
  try {
7425
7512
  const t = St();
7426
- return await Bt.current.exportCurrentSectionAsJSON(t, e);
7513
+ return await Bt.current.exportCurrentSectionAsJSON(t, e, yt);
7427
7514
  } catch (t) {
7428
7515
  throw console.error("Export current section as JSON failed:", t), t;
7429
7516
  }
7430
7517
  }
7431
7518
  }));
7432
- const yt = gt(null), Lt = gt(!1), V = rt(() => {
7519
+ const mt = gt(null), Lt = gt(!1), V = at(() => {
7433
7520
  const e = K.current;
7434
7521
  if (!e || Lt.current) return;
7435
7522
  Lt.current = !0;
7436
7523
  const t = e.getContext("2d");
7437
- t.clearRect(0, 0, v, W), pt.current && t.drawImage(pt.current, 0, 0, v, W), M && xe(t), x.forEach((r) => {
7524
+ t.clearRect(0, 0, k, W), wt.current && t.drawImage(wt.current, 0, 0, k, W), M && xe(t), h.forEach((r) => {
7438
7525
  t.save(), t.globalAlpha = r.opacity || 1, ye(t, r), t.restore();
7439
- }), d && fe(t, d), Lt.current = !1;
7440
- }, [x, d, v, W, M]), vt = rt(() => {
7441
- yt.current && cancelAnimationFrame(yt.current), yt.current = requestAnimationFrame(() => {
7442
- V(), yt.current = null;
7526
+ }), c && fe(t, c), Lt.current = !1;
7527
+ }, [h, c, k, W, M]), vt = at(() => {
7528
+ mt.current && cancelAnimationFrame(mt.current), mt.current = requestAnimationFrame(() => {
7529
+ V(), mt.current = null;
7443
7530
  });
7444
7531
  }, [V]);
7445
- ot(() => {
7532
+ rt(() => {
7446
7533
  vt();
7447
- }, [x, d, v, W, M, vt]), ot(() => {
7448
- pt.current && vt();
7449
- }, [pt.current, vt]), ot(() => () => {
7450
- yt.current && cancelAnimationFrame(yt.current);
7534
+ }, [h, c, k, W, M, vt]), rt(() => {
7535
+ wt.current && vt();
7536
+ }, [wt.current, vt]), rt(() => () => {
7537
+ mt.current && cancelAnimationFrame(mt.current);
7451
7538
  }, []);
7452
- const Pt = rt(() => {
7453
- V(), (S || y || B) && (yt.current = requestAnimationFrame(Pt));
7454
- }, [V, S, y, B]);
7455
- ot(() => {
7456
- S || y || B ? Pt() : (yt.current && (cancelAnimationFrame(yt.current), yt.current = null), vt());
7457
- }, [S, y, B, Pt, vt]);
7458
- const Me = rt((e) => {
7539
+ const Pt = at(() => {
7540
+ V(), (I || m || j) && (mt.current = requestAnimationFrame(Pt));
7541
+ }, [V, I, m, j]);
7542
+ rt(() => {
7543
+ I || m || j ? Pt() : (mt.current && (cancelAnimationFrame(mt.current), mt.current = null), vt());
7544
+ }, [I, m, j, Pt, vt]);
7545
+ const Me = at((e) => {
7459
7546
  if (l) return;
7460
- const r = K.current.getBoundingClientRect(), c = (e.clientX - r.left) / Q, g = (e.clientY - r.top) / Q;
7461
- if (J({ x: c, y: g }), d) {
7462
- const p = $t(c, g, d);
7463
- if (p) {
7464
- if (p === "rotate") {
7465
- b(!0);
7466
- const k = d.x + d.width / 2, w = d.y + d.height / 2, R = Math.atan2(g - w, c - k) * 180 / Math.PI;
7467
- J({
7468
- x: c,
7469
- y: g,
7547
+ const r = K.current.getBoundingClientRect(), d = (e.clientX - r.left) / Q, x = (e.clientY - r.top) / Q;
7548
+ if (X({ x: d, y: x }), c) {
7549
+ const w = $t(d, x, c);
7550
+ if (w) {
7551
+ if (w === "rotate") {
7552
+ p(!0);
7553
+ const S = c.x + c.width / 2, b = c.y + c.height / 2, R = Math.atan2(x - b, d - S) * 180 / Math.PI;
7554
+ X({
7555
+ x: d,
7556
+ y: x,
7470
7557
  initialAngle: R,
7471
- initialRotation: d.rotation || 0
7558
+ initialRotation: c.rotation || 0
7472
7559
  });
7473
7560
  } else
7474
- E(!0), O(p), J({
7475
- x: c,
7476
- y: g,
7477
- initialWidth: d.width,
7478
- initialHeight: d.height,
7479
- initialX: d.x,
7480
- initialY: d.y
7561
+ B(!0), O(w), X({
7562
+ x: d,
7563
+ y: x,
7564
+ initialWidth: c.width,
7565
+ initialHeight: c.height,
7566
+ initialX: c.x,
7567
+ initialY: c.y
7481
7568
  });
7482
7569
  return;
7483
7570
  }
7484
7571
  }
7485
- let m = null;
7486
- for (let p = x.length - 1; p >= 0; p--)
7487
- if (Ht(c, g, x[p])) {
7488
- m = x[p];
7572
+ let u = null;
7573
+ for (let w = h.length - 1; w >= 0; w--)
7574
+ if (Ht(d, x, h[w])) {
7575
+ u = h[w];
7489
7576
  break;
7490
7577
  }
7491
- m ? (j(m), I(!0), J({
7492
- x: c,
7493
- y: g,
7494
- offsetX: c - m.x,
7495
- offsetY: g - m.y
7496
- })) : j(null), V();
7497
- }, [l, Q, d, x, V]), Le = rt((e) => {
7578
+ u ? (F(u), E(!0), X({
7579
+ x: d,
7580
+ y: x,
7581
+ offsetX: d - u.x,
7582
+ offsetY: x - u.y
7583
+ })) : F(null), V();
7584
+ }, [l, Q, c, h, V]), Le = at((e) => {
7498
7585
  if (l) return;
7499
- const t = K.current, r = t.getBoundingClientRect(), c = (e.clientX - r.left) / Q, g = (e.clientY - r.top) / Q;
7500
- if (d && !S && !y && !B) {
7501
- const m = $t(c, g, d);
7502
- m ? m === "rotate" ? t.style.cursor = "grab" : t.style.cursor = m : Ht(c, g, d) ? t.style.cursor = "move" : t.style.cursor = "default";
7586
+ const t = K.current, r = t.getBoundingClientRect(), d = (e.clientX - r.left) / Q, x = (e.clientY - r.top) / Q;
7587
+ if (c && !I && !m && !j) {
7588
+ const u = $t(d, x, c);
7589
+ u ? u === "rotate" ? t.style.cursor = "grab" : t.style.cursor = u : Ht(d, x, c) ? t.style.cursor = "move" : t.style.cursor = "default";
7503
7590
  } else
7504
- t.style.cursor = S ? "grabbing" : "default";
7505
- if (B && d) {
7506
- const m = d.x + d.width / 2, p = d.y + d.height / 2, w = Math.atan2(g - p, c - m) * 180 / Math.PI - F.initialAngle;
7507
- let R = F.initialRotation + w;
7591
+ t.style.cursor = I ? "grabbing" : "default";
7592
+ if (j && c) {
7593
+ const u = c.x + c.width / 2, w = c.y + c.height / 2, b = Math.atan2(x - w, d - u) * 180 / Math.PI - v.initialAngle;
7594
+ let R = v.initialRotation + b;
7508
7595
  e.shiftKey && (R = Math.round(R / 15) * 15), R = (R % 360 + 360) % 360, n(
7509
7596
  (A) => A.map(
7510
- (z) => z.id === d.id ? { ...z, rotation: R } : z
7597
+ (z) => z.id === c.id ? { ...z, rotation: R } : z
7511
7598
  )
7512
- ), j((A) => ({ ...A, rotation: R })), V();
7599
+ ), F((A) => ({ ...A, rotation: R })), V();
7513
7600
  return;
7514
7601
  }
7515
- if (y && d && T) {
7516
- const m = c - F.x, p = g - F.y;
7517
- let k = F.initialWidth, w = F.initialHeight, R = F.initialX, A = F.initialY;
7602
+ if (m && c && T) {
7603
+ const u = d - v.x, w = x - v.y;
7604
+ let S = v.initialWidth, b = v.initialHeight, R = v.initialX, A = v.initialY;
7518
7605
  switch (T) {
7519
7606
  case "se-resize":
7520
- k = Math.max(20, F.initialWidth + m), w = Math.max(20, F.initialHeight + p);
7607
+ S = Math.max(20, v.initialWidth + u), b = Math.max(20, v.initialHeight + w);
7521
7608
  break;
7522
7609
  case "sw-resize":
7523
- k = Math.max(20, F.initialWidth - m), w = Math.max(20, F.initialHeight + p), R = F.initialX + (F.initialWidth - k);
7610
+ S = Math.max(20, v.initialWidth - u), b = Math.max(20, v.initialHeight + w), R = v.initialX + (v.initialWidth - S);
7524
7611
  break;
7525
7612
  case "ne-resize":
7526
- k = Math.max(20, F.initialWidth + m), w = Math.max(20, F.initialHeight - p), A = F.initialY + (F.initialHeight - w);
7613
+ S = Math.max(20, v.initialWidth + u), b = Math.max(20, v.initialHeight - w), A = v.initialY + (v.initialHeight - b);
7527
7614
  break;
7528
7615
  case "nw-resize":
7529
- k = Math.max(20, F.initialWidth - m), w = Math.max(20, F.initialHeight - p), R = F.initialX + (F.initialWidth - k), A = F.initialY + (F.initialHeight - w);
7616
+ S = Math.max(20, v.initialWidth - u), b = Math.max(20, v.initialHeight - w), R = v.initialX + (v.initialWidth - S), A = v.initialY + (v.initialHeight - b);
7530
7617
  break;
7531
7618
  }
7532
- if (e.shiftKey && d.type !== "text") {
7533
- const $ = F.initialWidth / F.initialHeight;
7534
- T.includes("e"), w = k / $, T.includes("n") && (A = F.initialY + (F.initialHeight - w));
7619
+ if (e.shiftKey && c.type !== "text") {
7620
+ const $ = v.initialWidth / v.initialHeight;
7621
+ T.includes("e"), b = S / $, T.includes("n") && (A = v.initialY + (v.initialHeight - b));
7535
7622
  }
7536
- Y && (R = ut(R), A = ut(A), k = ut(k), w = ut(w));
7623
+ Y && (R = ut(R), A = ut(A), S = ut(S), b = ut(b));
7537
7624
  const z = {
7538
- ...d,
7625
+ ...c,
7539
7626
  x: R,
7540
7627
  y: A,
7541
- width: k,
7542
- height: w
7628
+ width: S,
7629
+ height: b
7543
7630
  };
7544
7631
  n(
7545
7632
  ($) => $.map(
7546
- (dt) => dt.id === d.id ? z : dt
7633
+ (dt) => dt.id === c.id ? z : dt
7547
7634
  )
7548
- ), j(z), V();
7635
+ ), F(z), V();
7549
7636
  return;
7550
7637
  }
7551
- if (S && d) {
7552
- let m = c - F.offsetX, p = g - F.offsetY;
7553
- Y && (m = ut(m), p = ut(p)), m = Math.max(0, Math.min(v - d.width, m)), p = Math.max(0, Math.min(W - d.height, p));
7554
- const k = {
7555
- ...d,
7556
- x: m,
7557
- y: p
7638
+ if (I && c) {
7639
+ let u = d - v.offsetX, w = x - v.offsetY;
7640
+ Y && (u = ut(u), w = ut(w)), u = Math.max(0, Math.min(k - c.width, u)), w = Math.max(0, Math.min(W - c.height, w));
7641
+ const S = {
7642
+ ...c,
7643
+ x: u,
7644
+ y: w
7558
7645
  };
7559
7646
  n(
7560
- (w) => w.map(
7561
- (R) => R.id === d.id ? k : R
7647
+ (b) => b.map(
7648
+ (R) => R.id === c.id ? S : R
7562
7649
  )
7563
- ), j(k), V();
7650
+ ), F(S), V();
7564
7651
  }
7565
- }, [l, Q, d, S, y, B, T, F, Y, v, W, x, V]), qt = rt((e) => {
7652
+ }, [l, Q, c, I, m, j, T, v, Y, k, W, h, V]), qt = at((e) => {
7566
7653
  C && H((r) => ({
7567
7654
  ...r,
7568
7655
  [C.sectionName]: {
7569
- elements: x.map((c) => c.type === "image" ? {
7570
- ...c,
7656
+ elements: h.map((d) => d.type === "image" ? {
7657
+ ...d,
7571
7658
  // Keep the image data reference
7572
- imageData: c.imageData,
7573
- src: c.src
7574
- } : c),
7659
+ imageData: d.imageData,
7660
+ src: d.src
7661
+ } : d),
7575
7662
  selectedColor: _
7576
7663
  }
7577
7664
  }));
7578
7665
  const t = L[e.sectionName];
7579
7666
  if (t) {
7580
- const r = t.elements.map((c) => {
7581
- if (c.type === "image" && c.src && !c.imageData) {
7582
- const g = new Image();
7583
- return g.onload = () => {
7667
+ const r = t.elements.map((d) => {
7668
+ if (d.type === "image" && d.src && !d.imageData) {
7669
+ const x = new Image();
7670
+ return x.onload = () => {
7584
7671
  n(
7585
- (m) => m.map(
7586
- (p) => p.id === c.id ? { ...p, imageData: g } : p
7672
+ (u) => u.map(
7673
+ (w) => w.id === d.id ? { ...w, imageData: x } : w
7587
7674
  )
7588
7675
  ), V();
7589
- }, g.src = c.src, { ...c, imageData: g };
7676
+ }, x.src = d.src, { ...d, imageData: x };
7590
7677
  }
7591
- return c;
7678
+ return d;
7592
7679
  });
7593
- n(r), at(t.selectedColor || _);
7680
+ n(r), st(t.selectedColor || _);
7594
7681
  } else
7595
7682
  n([]);
7596
- tt(e), j(null);
7597
- }, [C, x, _, L, V]), Pe = rt((e) => {
7683
+ et(e), F(null);
7684
+ }, [C, h, _, L, V]), Pe = at((e) => {
7598
7685
  if (e && e.type.startsWith("image/")) {
7599
7686
  const t = new FileReader();
7600
7687
  t.onload = (r) => {
7601
- const c = new Image();
7602
- c.onload = () => {
7603
- const g = {
7688
+ const d = new Image();
7689
+ d.onload = () => {
7690
+ const x = {
7604
7691
  id: ht(),
7605
7692
  type: "image",
7606
- x: ut(v / 2 - 100),
7693
+ x: ut(k / 2 - 100),
7607
7694
  y: ut(W / 2 - 100),
7608
- width: Math.min(c.width, 200),
7695
+ width: Math.min(d.width, 200),
7609
7696
  // Limit initial size
7610
- height: Math.min(c.height, 200),
7697
+ height: Math.min(d.height, 200),
7611
7698
  rotation: 0,
7612
- imageData: c,
7699
+ imageData: d,
7613
7700
  src: r.target.result,
7614
- originalWidth: c.width,
7615
- originalHeight: c.height
7616
- }, m = c.width / c.height;
7617
- g.width / g.height !== m && (g.width / m <= 200 ? g.height = g.width / m : g.width = g.height * m), n((p) => [...p, g]), j(g), lt();
7618
- }, c.onerror = () => {
7701
+ originalWidth: d.width,
7702
+ originalHeight: d.height
7703
+ }, u = d.width / d.height;
7704
+ x.width / x.height !== u && (x.width / u <= 200 ? x.height = x.width / u : x.width = x.height * u), n((w) => [...w, x]), F(x), lt();
7705
+ }, d.onerror = () => {
7619
7706
  console.error("Failed to load uploaded image"), alert("Failed to load the uploaded image. Please try again.");
7620
- }, c.src = r.target.result;
7707
+ }, d.src = r.target.result;
7621
7708
  }, t.onerror = () => {
7622
7709
  console.error("Failed to read file"), alert("Failed to read the file. Please try again.");
7623
7710
  }, t.readAsDataURL(e);
7624
7711
  } else
7625
7712
  alert("Please select a valid image file.");
7626
- }, [v, W, ut, ht, lt]), Vt = rt(
7713
+ }, [k, W, ut, ht, lt]), Vt = at(
7627
7714
  Ue(() => {
7628
7715
  V();
7629
7716
  }, 16),
7630
7717
  // 60fps limit
7631
7718
  [V]
7632
7719
  );
7633
- ot(() => {
7720
+ rt(() => {
7634
7721
  zt.current || Vt();
7635
- }, [x, d, M, Vt]);
7722
+ }, [h, c, M, Vt]);
7636
7723
  function Ue(e, t) {
7637
7724
  let r;
7638
- return function(...g) {
7639
- const m = () => {
7640
- clearTimeout(r), e(...g);
7725
+ return function(...x) {
7726
+ const u = () => {
7727
+ clearTimeout(r), e(...x);
7641
7728
  };
7642
- clearTimeout(r), r = setTimeout(m, t);
7729
+ clearTimeout(r), r = setTimeout(u, t);
7643
7730
  };
7644
7731
  }
7645
- ot(() => {
7646
- mt.current && Xt(mt.current, _);
7647
- }, [_]), ot(() => {
7732
+ rt(() => {
7733
+ pt.current && Xt(pt.current, _);
7734
+ }, [_]), rt(() => {
7648
7735
  V();
7649
7736
  }, [V]);
7650
- const Oe = (e, t, r) => (0.2126 * e + 0.7152 * t + 0.0722 * r) / 255, Xt = rt((e, t) => {
7651
- const r = Ot.current, c = r.getContext("2d");
7652
- r.width = v, r.height = W, c.clearRect(0, 0, v, W), c.drawImage(e, 0, 0, v, W);
7653
- const g = c.getImageData(0, 0, v, W), m = g.data, p = ge(t);
7654
- if (!p) {
7737
+ const Oe = (e, t, r) => (0.2126 * e + 0.7152 * t + 0.0722 * r) / 255, Xt = at((e, t) => {
7738
+ const r = Ot.current, d = r.getContext("2d");
7739
+ r.width = k, r.height = W, d.clearRect(0, 0, k, W), d.drawImage(e, 0, 0, k, W);
7740
+ const x = d.getImageData(0, 0, k, W), u = x.data, w = ge(t);
7741
+ if (!w) {
7655
7742
  zt.current = !1;
7656
7743
  return;
7657
7744
  }
7658
- const { r: k, g: w, b: R } = p;
7659
- for (let z = 0; z < m.length; z += 4) {
7660
- if (m[z + 3] === 0) continue;
7661
- const dt = Oe(m[z], m[z + 1], m[z + 2]);
7662
- m[z] = Math.round(k * dt), m[z + 1] = Math.round(w * dt), m[z + 2] = Math.round(R * dt);
7745
+ const { r: S, g: b, b: R } = w;
7746
+ for (let z = 0; z < u.length; z += 4) {
7747
+ if (u[z + 3] === 0) continue;
7748
+ const dt = Oe(u[z], u[z + 1], u[z + 2]);
7749
+ u[z] = Math.round(S * dt), u[z + 1] = Math.round(b * dt), u[z + 2] = Math.round(R * dt);
7663
7750
  }
7664
- c.putImageData(g, 0, 0);
7751
+ d.putImageData(x, 0, 0);
7665
7752
  const A = new Image();
7666
7753
  A.onload = () => {
7667
- pt.current = s.plainColor === "Y" ? A : e, zt.current = !1, V();
7754
+ wt.current = s.plainColor === "Y" ? A : e, zt.current = !1, V();
7668
7755
  }, A.src = r.toDataURL("image/png");
7669
- }, [v, W, V]), Jt = (e) => {
7670
- if (!Z) return { horizontal: [], vertical: [] };
7756
+ }, [k, W, V]), Jt = (e) => {
7757
+ if (!tt) return { horizontal: [], vertical: [] };
7671
7758
  const t = document.querySelector(".ruler-horizontal"), r = document.querySelector(".ruler-vertical");
7672
7759
  if (!t || !r)
7673
7760
  return { horizontal: [], vertical: [] };
7674
- const c = t.getBoundingClientRect(), g = r.getBoundingClientRect(), m = c.width, p = g.height, k = 50, w = [], R = [];
7675
- for (let A = k; A <= m; A += k)
7676
- A <= m - 20 && w.push({
7761
+ const d = t.getBoundingClientRect(), x = r.getBoundingClientRect(), u = d.width, w = x.height, S = 50, b = [], R = [];
7762
+ for (let A = S; A <= u; A += S)
7763
+ A <= u - 20 && b.push({
7677
7764
  position: A,
7678
7765
  value: Math.round(A / e)
7679
7766
  });
7680
- for (let A = k; A <= p; A += k)
7681
- A <= p - 15 && R.push({
7767
+ for (let A = S; A <= w; A += S)
7768
+ A <= w - 15 && R.push({
7682
7769
  position: A,
7683
7770
  value: Math.round(A / e)
7684
7771
  });
7685
- return { horizontal: w, vertical: R };
7772
+ return { horizontal: b, vertical: R };
7686
7773
  }, [Kt, Zt] = N({ horizontal: [], vertical: [] });
7687
- return ot(() => {
7774
+ return rt(() => {
7688
7775
  const e = () => {
7689
7776
  setTimeout(() => {
7690
- const c = Jt(Q);
7691
- Zt(c);
7777
+ const d = Jt(Q);
7778
+ Zt(d);
7692
7779
  }, 50);
7693
7780
  };
7694
7781
  e();
@@ -7699,33 +7786,33 @@ const fi = $e((f, o) => {
7699
7786
  return window.addEventListener("resize", r), () => {
7700
7787
  window.removeEventListener("resize", r), clearTimeout(t);
7701
7788
  };
7702
- }, [Q, Z]), ot(() => {
7703
- if (Z && !u) {
7789
+ }, [Q, tt]), rt(() => {
7790
+ if (tt && !y) {
7704
7791
  const e = setTimeout(() => {
7705
7792
  const t = Jt(Q);
7706
7793
  Zt(t);
7707
7794
  }, 100);
7708
7795
  return () => clearTimeout(e);
7709
7796
  }
7710
- }, [Z, u, Q]), /* @__PURE__ */ i.jsxs("div", { className: "pure-canvas-designer", children: [
7797
+ }, [tt, y, Q]), /* @__PURE__ */ i.jsxs("div", { className: "pure-canvas-designer", children: [
7711
7798
  /* @__PURE__ */ i.jsx("div", { className: "designer-header", children: /* @__PURE__ */ i.jsx(
7712
7799
  si,
7713
7800
  {
7714
7801
  onAddElement: ze,
7715
- onDeleteElement: () => d && Mt(d.id),
7716
- onDuplicateElement: () => d && _t(d.id),
7802
+ onDeleteElement: () => c && Mt(c.id),
7803
+ onDuplicateElement: () => c && _t(c.id),
7717
7804
  onUndo: Ft,
7718
7805
  onRedo: bt,
7719
7806
  onToggleGrid: () => nt(!M),
7720
- onToggleRulers: () => ct(!Z),
7807
+ onToggleRulers: () => ct(!tt),
7721
7808
  onToggleSnap: () => P(!Y),
7722
7809
  onImageUpload: Pe,
7723
- canUndo: X > 0,
7724
- canRedo: X < G.length - 1,
7810
+ canUndo: J > 0,
7811
+ canRedo: J < G.length - 1,
7725
7812
  showGrid: M,
7726
- showRulers: Z,
7813
+ showRulers: tt,
7727
7814
  snapToGrid: Y,
7728
- selectedElement: d,
7815
+ selectedElement: c,
7729
7816
  theme: a,
7730
7817
  readOnly: l,
7731
7818
  apiKey: f.apiKey,
@@ -7733,7 +7820,7 @@ const fi = $e((f, o) => {
7733
7820
  }
7734
7821
  ) }),
7735
7822
  /* @__PURE__ */ i.jsxs("div", { className: "designer-content", children: [
7736
- Z && !u && /* @__PURE__ */ i.jsxs("div", { className: "rulers", children: [
7823
+ tt && !y && /* @__PURE__ */ i.jsxs("div", { className: "rulers", children: [
7737
7824
  /* @__PURE__ */ i.jsx("div", { className: "ruler-horizontal", children: /* @__PURE__ */ i.jsx("div", { className: "ruler-horizontal-numbers", children: Kt.horizontal.map((e, t) => /* @__PURE__ */ i.jsx(
7738
7825
  "span",
7739
7826
  {
@@ -7757,14 +7844,14 @@ const fi = $e((f, o) => {
7757
7844
  "canvas",
7758
7845
  {
7759
7846
  ref: K,
7760
- width: v,
7847
+ width: k,
7761
7848
  height: W,
7762
7849
  onMouseDown: Me,
7763
7850
  onMouseMove: Le,
7764
7851
  onMouseUp: Be,
7765
7852
  style: {
7766
7853
  border: "1px solid #e2e8f0",
7767
- cursor: S ? "grabbing" : "default",
7854
+ cursor: I ? "grabbing" : "default",
7768
7855
  transform: `scale(${Q})`,
7769
7856
  transformOrigin: "top left"
7770
7857
  }
@@ -7774,7 +7861,7 @@ const fi = $e((f, o) => {
7774
7861
  /* @__PURE__ */ i.jsx(
7775
7862
  li,
7776
7863
  {
7777
- selectedElement: d,
7864
+ selectedElement: c,
7778
7865
  onUpdate: Gt,
7779
7866
  onMoveLayer: Yt,
7780
7867
  availableFonts: de,
@@ -7784,9 +7871,9 @@ const fi = $e((f, o) => {
7784
7871
  /* @__PURE__ */ i.jsx(
7785
7872
  ni,
7786
7873
  {
7787
- elements: x,
7788
- selectedElement: d,
7789
- onSelectElement: j,
7874
+ elements: h,
7875
+ selectedElement: c,
7876
+ onSelectElement: F,
7790
7877
  onMoveLayer: Yt,
7791
7878
  onDeleteElement: Mt,
7792
7879
  theme: a
@@ -7808,8 +7895,8 @@ const fi = $e((f, o) => {
7808
7895
  className: `section-thumbnail compact ${C.sectionName === e.sectionName ? "active" : ""}`,
7809
7896
  onClick: (r) => {
7810
7897
  r.stopPropagation();
7811
- const c = s.sections.find((g) => g.sectionName === e.sectionName);
7812
- qt(c);
7898
+ const d = s.sections.find((x) => x.sectionName === e.sectionName);
7899
+ qt(d);
7813
7900
  },
7814
7901
  title: e.sectionName,
7815
7902
  children: [
@@ -7843,7 +7930,7 @@ const fi = $e((f, o) => {
7843
7930
  {
7844
7931
  className: `color-swatch-enhanced compact ${_ === e ? "active" : ""}`,
7845
7932
  onClick: (r) => {
7846
- r.stopPropagation(), at(e);
7933
+ r.stopPropagation(), st(e);
7847
7934
  },
7848
7935
  title: `Change product to ${e}`,
7849
7936
  children: [
@@ -7882,7 +7969,7 @@ const fi = $e((f, o) => {
7882
7969
  {
7883
7970
  className: `color-swatch-dropdown ${_ === e ? "active" : ""}`,
7884
7971
  onClick: (r) => {
7885
- r.stopPropagation(), at(e), r.currentTarget.parentElement.style.display = "none";
7972
+ r.stopPropagation(), st(e), r.currentTarget.parentElement.style.display = "none";
7886
7973
  },
7887
7974
  title: `Change product to ${e}`,
7888
7975
  children: [