@varianta/sdk 0.1.3 → 0.1.5
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.cjs.js +5 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +655 -778
- package/dist/index.esm.js.map +1 -1
- package/dist/react.cjs.js +2 -0
- package/dist/react.cjs.js.map +1 -0
- package/dist/react.esm.js +291 -0
- package/dist/react.esm.js.map +1 -0
- package/dist/types/index.d.ts +1 -11
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/react/Customizer.d.ts +11 -2
- package/dist/types/react/Customizer.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +36 -2
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/types/vanilla/index.d.ts.map +1 -1
- package/package.json +4 -27
- package/dist/index.umd.js +0 -8
- package/dist/index.umd.js.map +0 -1
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../../editor/dist/customizer.esm.js","../src/vanilla/index.ts","../src/react/Customizer.tsx","../src/react/useCustomizer.ts"],"sourcesContent":["class D {\n constructor(t) {\n this.animationFrameId = null, this.needsRender = !0, this.areas = [], this.contents = /* @__PURE__ */ new Map(), this.artboard = null, this.bgImageElement = null, this.loadedImages = /* @__PURE__ */ new Map(), this.loadingImages = /* @__PURE__ */ new Set(), this.zoom = 1, this.pan = { x: 0, y: 0 }, this.selectedAreaId = null, this.hoveredHandle = null, this.eventListeners = /* @__PURE__ */ new Map(), this.safeArea = null, this.safeAreaViolations = /* @__PURE__ */ new Set(), this.showAreaBorders = !0, this.areaSelectionEnabled = !0, this.renderLoop = () => {\n try {\n this.needsRender && (this.render(), this.needsRender = !1, this.emit(\"render\", void 0));\n } catch (i) {\n console.error(\"Error in render loop:\", i);\n }\n this.animationFrameId = requestAnimationFrame(this.renderLoop);\n }, this.canvas = t;\n const e = t.getContext(\"2d\");\n if (!e)\n throw new Error(\"Failed to get 2D context from canvas\");\n this.ctx = e;\n }\n /**\n * Start the render loop\n */\n start() {\n this.animationFrameId === null && this.renderLoop();\n }\n /**\n * Stop the render loop\n */\n stop() {\n this.animationFrameId !== null && (cancelAnimationFrame(this.animationFrameId), this.animationFrameId = null);\n }\n /**\n * Set artboard configuration\n */\n setArtboard(t) {\n this.artboard = t, this.requestRender();\n }\n /**\n * Get artboard configuration\n */\n getArtboard() {\n return this.artboard;\n }\n /**\n * Set areas to render\n */\n setAreas(t) {\n this.areas = [...t].sort((e, i) => e.zIndex - i.zIndex), this.requestRender();\n }\n /**\n * Get areas\n */\n getAreas() {\n return this.areas;\n }\n /**\n * Set area contents\n */\n setContents(t) {\n this.contents = t, this.loadContentImages(), this.requestRender();\n }\n /**\n * Get area contents\n */\n getContents() {\n return this.contents;\n }\n /**\n * Update content for a single area\n */\n updateContent(t, e) {\n this.contents.set(t, e), e.type === \"image\" && this.loadContentImages(), this.requestRender(), this.emit(\"content:change\", { areaId: t, content: e });\n }\n /**\n * Remove content for an area\n */\n removeContent(t) {\n this.contents.delete(t), this.loadedImages.delete(t), this.requestRender();\n }\n /**\n * Set background image\n */\n setBackgroundImage(t) {\n if (this.backgroundImage = t, t?.url && t.url !== this.bgImageElement?.src) {\n const e = new Image();\n e.crossOrigin = \"anonymous\", e.onload = () => {\n this.bgImageElement = e, this.requestRender();\n }, e.onerror = () => {\n this.bgImageElement = null, console.error(\"Failed to load background image:\", t.url), this.requestRender();\n }, e.src = t.url;\n } else t?.url || (this.bgImageElement = null);\n this.requestRender();\n }\n /**\n * Set zoom level\n */\n setZoom(t) {\n this.zoom = Math.max(0.1, Math.min(5, t)), this.requestRender();\n }\n /**\n * Set pan offset\n */\n setPan(t) {\n this.pan = t, this.requestRender();\n }\n /**\n * Get zoom level\n */\n getZoom() {\n return this.zoom;\n }\n /**\n * Get pan offset\n */\n getPan() {\n return this.pan;\n }\n /**\n * Set whether area borders are shown\n */\n setShowAreaBorders(t) {\n this.showAreaBorders = t, this.requestRender();\n }\n /**\n * Set whether area selection is enabled\n */\n setAreaSelectionEnabled(t) {\n this.areaSelectionEnabled = t;\n }\n /**\n * Calculate the pan offset needed to center the artboard at a given zoom level\n */\n getCenteredPan(t) {\n if (!this.artboard)\n return null;\n const { width: e, height: i } = this.artboard, n = window.devicePixelRatio || 1, s = this.canvas.width / n, o = this.canvas.height / n;\n return {\n x: (s / t - e) / 2,\n y: (o / t - i) / 2\n };\n }\n /**\n * Request a render on the next frame\n */\n requestRender() {\n this.needsRender = !0;\n }\n /**\n * Fit view to show the entire artboard\n */\n fitToView() {\n if (!this.artboard)\n return;\n const t = 0, { width: e, height: i } = this.artboard, n = window.devicePixelRatio || 1, s = this.canvas.width / n - t * 2, o = this.canvas.height / n - t * 2;\n if (s <= 0 || o <= 0)\n return;\n const a = s / e, r = o / i, d = Math.min(a, r), l = this.canvas.width / n, c = this.canvas.height / n, u = (l / d - e) / 2, p = (c / d - i) / 2;\n this.zoom = d, this.pan = { x: u, y: p }, this.requestRender();\n }\n /**\n * Set the selected area\n */\n setSelectedArea(t) {\n this.selectedAreaId !== t && (this.selectedAreaId = t, this.requestRender(), this.emit(\"area:select\", { areaId: t }));\n }\n /**\n * Get the selected area ID\n */\n getSelectedArea() {\n return this.selectedAreaId;\n }\n /**\n * Set the hovered handle for highlighting\n */\n setHoveredHandle(t) {\n this.hoveredHandle !== t && (this.hoveredHandle = t, this.requestRender());\n }\n /**\n * Get the currently hovered handle\n */\n getHoveredHandle() {\n return this.hoveredHandle;\n }\n /**\n * Convert screen coordinates to canvas coordinates\n */\n screenToCanvas(t, e) {\n const i = window.devicePixelRatio || 1, n = t / i, s = e / i, o = n / this.zoom - this.pan.x, a = s / this.zoom - this.pan.y;\n return { x: o, y: a };\n }\n /**\n * Get content bounds for an area (in artboard coordinates)\n */\n getContentBounds(t) {\n const e = this.areas.find((d) => d.id === t);\n if (!e)\n return null;\n const i = this.contents.get(t);\n if (!i)\n return null;\n const { location: n } = e, { x: s, y: o, width: a, height: r } = n;\n if (i.type === \"text\") {\n const d = i.offset || { x: 0, y: 0 }, l = i.scale ?? 1, c = i.rotation ?? 0, u = a * l, p = r * l, g = s + a / 2 + d.x, m = o + r / 2 + d.y;\n return {\n x: g - u / 2,\n y: m - p / 2,\n width: u,\n height: p,\n rotation: c,\n centerX: g,\n centerY: m\n };\n } else if (i.type === \"image\") {\n const d = this.loadedImages.get(t);\n if (!d)\n return null;\n const l = i.offset || { x: 0, y: 0 }, c = i.scale ?? 1, u = i.rotation ?? 0, p = d.naturalWidth / d.naturalHeight, g = a / r;\n let m, b;\n p > g ? (m = a, b = a / p) : (b = r, m = r * p);\n const y = m * c, w = b * c, v = s + a / 2 + l.x, x = o + r / 2 + l.y;\n return {\n x: v - y / 2,\n y: x - w / 2,\n width: y,\n height: w,\n rotation: u,\n centerX: v,\n centerY: x\n };\n }\n return null;\n }\n /**\n * Hit test content at given canvas coordinates\n * Returns area ID if content was hit, null otherwise\n */\n hitTestContent(t, e) {\n if (!this.areaSelectionEnabled)\n return null;\n for (let i = this.areas.length - 1; i >= 0; i--) {\n const n = this.areas[i], s = this.getContentBounds(n.id);\n if (s && this.isPointInBounds(t, e, s))\n return n.id;\n }\n return null;\n }\n /**\n * Hit test area at given canvas coordinates (ignoring content)\n * Returns area ID if point is inside area bounds\n */\n hitTestArea(t, e) {\n if (!this.areaSelectionEnabled)\n return null;\n for (let i = this.areas.length - 1; i >= 0; i--) {\n const n = this.areas[i], { x: s, y: o, width: a, height: r } = n.location;\n if (t >= s && t <= s + a && e >= o && e <= o + r)\n return n.id;\n }\n return null;\n }\n /**\n * Test if a point is inside rotated bounds\n */\n isPointInBounds(t, e, i) {\n const { centerX: n, centerY: s, width: o, height: a, rotation: r } = i, d = -r * Math.PI / 180, l = Math.cos(d), c = Math.sin(d), u = t - n, p = e - s, g = u * l - p * c, m = u * c + p * l;\n return g >= -o / 2 && g <= o / 2 && m >= -a / 2 && m <= a / 2;\n }\n /**\n * Get handle positions for the selected content\n */\n getContentHandlePositions(t) {\n const e = this.areas.find((v) => v.id === t);\n if (!e)\n return null;\n const i = this.contents.get(t);\n if (!i)\n return null;\n const n = this.getContentBounds(t);\n if (!n)\n return null;\n const { centerX: s, centerY: o, width: a, height: r, rotation: d } = n, l = 6 / this.zoom, c = 30 / this.zoom, u = d * Math.PI / 180, p = Math.cos(u), g = Math.sin(u), m = (v, x) => ({\n x: s + v * p - x * g,\n y: o + v * g + x * p\n }), b = [];\n if (i.type === \"image\" && e.imageOptions?.allowScaling || i.type === \"text\" && e.textOptions?.allowScaling) {\n const v = a / 2, x = r / 2, C = m(-v, -x);\n b.push({ type: \"nw\", ...C, radius: l });\n const E = m(v, -x);\n b.push({ type: \"ne\", ...E, radius: l });\n const k = m(v, x);\n b.push({ type: \"se\", ...k, radius: l });\n const P = m(-v, x);\n b.push({ type: \"sw\", ...P, radius: l });\n }\n if (i.type === \"image\" && e.imageOptions?.allowRotation || i.type === \"text\" && e.textOptions?.allowRotation) {\n const v = m(0, -r / 2 - c);\n b.push({ type: \"rotate\", ...v, radius: l });\n }\n return b;\n }\n /**\n * Hit test handles at given canvas coordinates\n */\n hitTestHandle(t, e, i) {\n const n = this.getContentHandlePositions(i);\n if (!n)\n return null;\n for (const s of n) {\n const o = t - s.x, a = e - s.y;\n if (Math.sqrt(o * o + a * a) <= s.radius * 2)\n return s.type;\n }\n return null;\n }\n /**\n * Check if positioning is allowed for an area\n */\n isPositioningAllowed(t) {\n const e = this.areas.find((n) => n.id === t);\n if (!e)\n return !1;\n const i = this.contents.get(t);\n return i ? i.type === \"text\" ? e.textOptions?.allowPositioning ?? !1 : e.imageOptions?.allowPositioning ?? !1 : !1;\n }\n /**\n * Get area location (for constraint calculations)\n */\n getAreaLocation(t) {\n const e = this.areas.find((i) => i.id === t);\n return e ? e.location : null;\n }\n /**\n * Get area by ID\n */\n getArea(t) {\n return this.areas.find((e) => e.id === t);\n }\n /**\n * Set safe area margins for content safety guides\n */\n setSafeArea(t) {\n this.safeArea = t ?? null, this.requestRender();\n }\n /**\n * Check if any area content extends beyond the safe area bounds.\n * Returns array of violating area IDs.\n */\n checkSafeAreaViolations() {\n if (!this.safeArea || !this.artboard)\n return [];\n const t = [], { top: e, right: i, bottom: n, left: s } = this.safeArea, o = s, a = e, r = this.artboard.width - i, d = this.artboard.height - n;\n for (const l of this.areas) {\n if (!this.contents.get(l.id))\n continue;\n const u = this.getContentBounds(l.id);\n if (!u)\n continue;\n const { centerX: p, centerY: g, width: m, height: b, rotation: y } = u, w = y * Math.PI / 180, v = Math.abs(Math.cos(w)), x = Math.abs(Math.sin(w)), C = m * v + b * x, E = m * x + b * v, k = p - C / 2, P = g - E / 2, L = p + C / 2, R = g + E / 2;\n (k < o || P < a || L > r || R > d) && t.push(l.id);\n }\n return this.safeAreaViolations = new Set(t), this.requestRender(), t;\n }\n /**\n * Add event listener\n */\n on(t, e) {\n return this.eventListeners.has(t) || this.eventListeners.set(t, /* @__PURE__ */ new Set()), this.eventListeners.get(t).add(e), () => {\n this.eventListeners.get(t)?.delete(e);\n };\n }\n /**\n * Emit event\n */\n emit(t, e) {\n const i = this.eventListeners.get(t);\n if (i)\n for (const n of i)\n n(e);\n }\n /**\n * Export to PNG at full resolution\n */\n async exportToPNG() {\n if (!this.artboard)\n throw new Error(\"No artboard configured\");\n const { width: t, height: e, backgroundColor: i } = this.artboard, n = document.createElement(\"canvas\");\n n.width = t, n.height = e;\n const s = n.getContext(\"2d\");\n if (!s)\n throw new Error(\"Failed to get 2D context for export\");\n s.fillStyle = i, s.fillRect(0, 0, t, e), this.backgroundImage?.position === \"behind\" && this.bgImageElement && this.drawBackgroundImageOnContext(s, t, e);\n for (const o of this.areas)\n this.drawAreaContentOnContext(s, o);\n return this.backgroundImage?.position === \"overlay\" && this.bgImageElement && this.drawBackgroundImageOnContext(s, t, e), new Promise((o, a) => {\n n.toBlob((r) => {\n r ? o(r) : a(new Error(\"Failed to create PNG blob\"));\n }, \"image/png\", 1);\n });\n }\n /**\n * Load images from content data URLs\n */\n loadContentImages() {\n for (const [t, e] of this.contents)\n if (e.type === \"image\" && !this.loadedImages.has(t) && !this.loadingImages.has(t)) {\n this.loadingImages.add(t);\n const i = new Image();\n i.onload = () => {\n this.loadedImages.set(t, i), this.loadingImages.delete(t), this.requestRender();\n }, i.onerror = () => {\n this.loadingImages.delete(t), console.error(\"Failed to load image for area:\", t);\n }, i.src = e.dataUrl;\n }\n for (const t of this.loadedImages.keys()) {\n const e = this.contents.get(t);\n (!e || e.type !== \"image\") && this.loadedImages.delete(t);\n }\n }\n /**\n * Render the canvas\n */\n render() {\n const { ctx: t, canvas: e } = this;\n if (t.fillStyle = \"#f3f4f6\", t.fillRect(0, 0, e.width, e.height), !this.artboard)\n return;\n t.save();\n const i = window.devicePixelRatio || 1;\n t.scale(i, i), t.scale(this.zoom, this.zoom), t.translate(this.pan.x, this.pan.y);\n const { width: n, height: s, backgroundColor: o } = this.artboard;\n t.fillStyle = o, t.fillRect(0, 0, n, s), t.strokeStyle = \"#d1d5db\", t.lineWidth = 1 / this.zoom, t.strokeRect(0, 0, n, s), this.backgroundImage?.position === \"behind\" && this.renderBackgroundImage();\n for (const a of this.areas)\n this.renderAreaWithContent(a);\n this.backgroundImage?.position === \"overlay\" && this.renderBackgroundImage(), this.renderSafeAreaGuide();\n for (const a of this.safeAreaViolations) {\n const r = this.areas.find((p) => p.id === a);\n if (!r)\n continue;\n const { x: d, y: l, width: c, height: u } = r.location;\n t.save(), t.fillStyle = \"rgba(239, 68, 68, 0.15)\", t.fillRect(d, l, c, u), t.restore();\n }\n this.selectedAreaId && this.renderSelectionOverlay(this.selectedAreaId), t.restore();\n }\n /**\n * Render selection overlay with handles\n */\n renderSelectionOverlay(t) {\n const e = this.getContentBounds(t);\n if (!e) {\n const l = this.areas.find((b) => b.id === t);\n if (!l)\n return;\n const { ctx: c } = this, { x: u, y: p, width: g, height: m } = l.location;\n c.save(), c.strokeStyle = \"#3b82f6\", c.lineWidth = 2 / this.zoom, c.setLineDash([]), c.strokeRect(u, p, g, m), c.restore();\n return;\n }\n const { ctx: i } = this, { centerX: n, centerY: s, width: o, height: a, rotation: r } = e;\n i.save(), i.translate(n, s), i.rotate(r * Math.PI / 180), i.strokeStyle = \"#3b82f6\", i.lineWidth = 2 / this.zoom, i.setLineDash([]), i.strokeRect(-o / 2, -a / 2, o, a), i.restore();\n const d = this.getContentHandlePositions(t);\n if (d)\n for (const l of d) {\n i.save();\n const c = this.hoveredHandle === l.type, u = c ? \"#dbeafe\" : \"#ffffff\", p = c ? \"#2563eb\" : \"#3b82f6\";\n if (l.type === \"rotate\") {\n const g = this.getRotatedPoint(n, s - a / 2, n, s, r);\n i.beginPath(), i.strokeStyle = p, i.lineWidth = 1 / this.zoom, i.setLineDash([4 / this.zoom, 4 / this.zoom]), i.moveTo(g.x, g.y), i.lineTo(l.x, l.y), i.stroke(), i.setLineDash([]), i.beginPath(), i.fillStyle = u, i.strokeStyle = p, i.lineWidth = 2 / this.zoom, i.arc(l.x, l.y, l.radius, 0, Math.PI * 2), i.fill(), i.stroke(), i.beginPath(), i.strokeStyle = p, i.lineWidth = 1.5 / this.zoom, i.arc(l.x, l.y, l.radius * 0.5, -Math.PI * 0.8, Math.PI * 0.5), i.stroke();\n } else\n i.fillStyle = u, i.strokeStyle = p, i.lineWidth = 2 / this.zoom, i.fillRect(l.x - l.radius, l.y - l.radius, l.radius * 2, l.radius * 2), i.strokeRect(l.x - l.radius, l.y - l.radius, l.radius * 2, l.radius * 2);\n i.restore();\n }\n }\n /**\n * Rotate a point around a center\n */\n getRotatedPoint(t, e, i, n, s) {\n const o = s * Math.PI / 180, a = Math.cos(o), r = Math.sin(o), d = t - i, l = e - n;\n return {\n x: i + d * a - l * r,\n y: n + d * r + l * a\n };\n }\n /**\n * Render background image\n */\n renderBackgroundImage() {\n if (!this.bgImageElement || !this.artboard || !this.backgroundImage)\n return;\n const { ctx: t } = this, { opacity: e } = this.backgroundImage, { width: i, height: n } = this.artboard;\n t.save(), t.globalAlpha = e;\n const s = this.bgImageElement.naturalWidth / this.bgImageElement.naturalHeight, o = i / n;\n let a, r, d, l;\n s > o ? (r = n, a = n * s, d = (i - a) / 2, l = 0) : (a = i, r = i / s, d = 0, l = (n - r) / 2), t.drawImage(this.bgImageElement, d, l, a, r), t.restore();\n }\n /**\n * Render safe area guide as dashed green rectangle\n */\n renderSafeAreaGuide() {\n if (!this.safeArea || !this.artboard)\n return;\n const { ctx: t } = this, { top: e, right: i, bottom: n, left: s } = this.safeArea, o = s, a = e, r = this.artboard.width - s - i, d = this.artboard.height - e - n;\n r <= 0 || d <= 0 || (t.save(), t.strokeStyle = \"#22c55e\", t.lineWidth = 1 / this.zoom, t.setLineDash([6 / this.zoom, 4 / this.zoom]), t.strokeRect(o, a, r, d), t.setLineDash([]), t.restore());\n }\n /**\n * Render an area with its content\n */\n renderAreaWithContent(t) {\n const { ctx: e } = this, { location: i, backgroundColor: n } = t, { x: s, y: o, width: a, height: r } = i;\n n && (e.fillStyle = n, e.fillRect(s, o, a, r));\n const d = this.contents.get(t.id);\n d && (d.type === \"text\" ? this.renderTextContent(t, d) : d.type === \"image\" && this.renderImageContent(t, d)), this.showAreaBorders && t.showBorder && (e.save(), e.strokeStyle = t.borderColor || \"#3b82f6\", e.lineWidth = 1 / this.zoom, e.setLineDash([4 / this.zoom, 4 / this.zoom]), e.strokeRect(s, o, a, r), e.setLineDash([]), e.restore());\n }\n /**\n * Render text content in an area\n */\n renderTextContent(t, e) {\n if (!e.text.trim())\n return;\n const { ctx: i } = this, { location: n } = t, { x: s, y: o, width: a, height: r } = n, d = e.offset || { x: 0, y: 0 }, l = e.scale ?? 1, c = e.rotation ?? 0, u = s + a / 2 + d.x, p = o + r / 2 + d.y;\n i.save(), i.beginPath(), i.rect(s, o, a, r), i.clip(), i.translate(u, p), i.rotate(c * Math.PI / 180), i.scale(l, l), i.font = `${e.size}px ${e.font}, sans-serif`, i.fillStyle = e.color, i.textBaseline = \"middle\";\n let g;\n switch (e.align) {\n case \"left\":\n i.textAlign = \"left\", g = -a / 2 + 10;\n break;\n case \"right\":\n i.textAlign = \"right\", g = a / 2 - 10;\n break;\n case \"center\":\n default:\n i.textAlign = \"center\", g = 0;\n break;\n }\n i.fillText(e.text, g, 0), i.restore();\n }\n /**\n * Render image content in an area\n */\n renderImageContent(t, e) {\n const i = this.loadedImages.get(t.id);\n if (!i)\n return;\n const { ctx: n } = this, { location: s } = t, { x: o, y: a, width: r, height: d } = s, l = e.offset || { x: 0, y: 0 }, c = e.scale ?? 1, u = e.rotation ?? 0;\n n.save(), n.beginPath(), n.rect(o, a, r, d), n.clip();\n const p = i.naturalWidth / i.naturalHeight, g = r / d;\n let m, b;\n p > g ? (m = r, b = r / p) : (b = d, m = d * p);\n const y = m * c, w = b * c, v = o + r / 2 + l.x, x = a + d / 2 + l.y;\n n.translate(v, x), n.rotate(u * Math.PI / 180), n.drawImage(i, -y / 2, -w / 2, y, w), n.restore();\n }\n /**\n * Draw background image on a specific context (for export)\n */\n drawBackgroundImageOnContext(t, e, i) {\n if (!this.bgImageElement || !this.backgroundImage)\n return;\n const { opacity: n } = this.backgroundImage;\n t.save(), t.globalAlpha = n;\n const s = this.bgImageElement.naturalWidth / this.bgImageElement.naturalHeight, o = e / i;\n let a, r, d, l;\n s > o ? (r = i, a = i * s, d = (e - a) / 2, l = 0) : (a = e, r = e / s, d = 0, l = (i - r) / 2), t.drawImage(this.bgImageElement, d, l, a, r), t.restore();\n }\n /**\n * Draw area content on a specific context (for export)\n */\n drawAreaContentOnContext(t, e) {\n const { location: i, backgroundColor: n } = e, { x: s, y: o, width: a, height: r } = i;\n n && (t.fillStyle = n, t.fillRect(s, o, a, r));\n const d = this.contents.get(e.id);\n if (d) {\n if (d.type === \"text\") {\n if (!d.text.trim())\n return;\n const l = d.offset || { x: 0, y: 0 }, c = d.scale ?? 1, u = d.rotation ?? 0, p = s + a / 2 + l.x, g = o + r / 2 + l.y;\n t.save(), t.beginPath(), t.rect(s, o, a, r), t.clip(), t.translate(p, g), t.rotate(u * Math.PI / 180), t.scale(c, c), t.font = `${d.size}px ${d.font}, sans-serif`, t.fillStyle = d.color, t.textBaseline = \"middle\";\n let m;\n switch (d.align) {\n case \"left\":\n t.textAlign = \"left\", m = -a / 2 + 10;\n break;\n case \"right\":\n t.textAlign = \"right\", m = a / 2 - 10;\n break;\n case \"center\":\n default:\n t.textAlign = \"center\", m = 0;\n break;\n }\n t.fillText(d.text, m, 0), t.restore();\n } else if (d.type === \"image\") {\n const l = this.loadedImages.get(e.id);\n if (!l)\n return;\n const c = d.offset || { x: 0, y: 0 }, u = d.scale ?? 1, p = d.rotation ?? 0;\n t.save(), t.beginPath(), t.rect(s, o, a, r), t.clip();\n const g = l.naturalWidth / l.naturalHeight, m = a / r;\n let b, y;\n g > m ? (b = a, y = a / g) : (y = r, b = r * g);\n const w = b * u, v = y * u, x = s + a / 2 + c.x, C = o + r / 2 + c.y;\n t.translate(x, C), t.rotate(p * Math.PI / 180), t.drawImage(l, -w / 2, -v / 2, w, v), t.restore();\n }\n }\n }\n /**\n * Cleanup resources\n */\n destroy() {\n this.stop(), this.bgImageElement = null, this.loadedImages.clear(), this.loadingImages.clear(), this.eventListeners.clear();\n }\n}\nfunction M(f) {\n const t = f.textOptions;\n return {\n type: \"text\",\n text: t?.defaultText || \"\",\n font: t?.defaultFont || \"Inter\",\n size: t?.defaultSize || 24,\n color: t?.defaultColor || \"#000000\",\n align: t?.defaultAlign || \"center\"\n };\n}\nfunction S(f) {\n return f.contentType === \"text\" || f.contentType === \"both\";\n}\nfunction z(f) {\n return f.contentType === \"image\" || f.contentType === \"both\";\n}\nconst O = 50;\nclass H {\n constructor(t) {\n this.history = [], this.historyIndex = -1, this.listeners = /* @__PURE__ */ new Set(), this.isRestoring = !1, this.state = this.cloneState(t), this.history.push({\n state: this.cloneState(t),\n timestamp: Date.now(),\n description: \"Initial state\"\n }), this.historyIndex = 0;\n }\n getState() {\n return this.state;\n }\n /**\n * Update state and save to history\n */\n setState(t, e, i = !1) {\n const n = this.state;\n this.state = { ...this.state, ...t }, !i && !this.isRestoring && this.saveToHistory(n, e), this.notifyListeners();\n }\n /**\n * Update state without saving to history\n * Use for transient changes like zoom/pan\n */\n update(t) {\n this.state = { ...this.state, ...t }, this.notifyListeners();\n }\n subscribe(t) {\n return this.listeners.add(t), () => this.listeners.delete(t);\n }\n undo() {\n return this.canUndo() ? (this.historyIndex--, this.restoreFromHistory(), !0) : !1;\n }\n redo() {\n return this.canRedo() ? (this.historyIndex++, this.restoreFromHistory(), !0) : !1;\n }\n canUndo() {\n return this.historyIndex > 0;\n }\n canRedo() {\n return this.historyIndex < this.history.length - 1;\n }\n clearHistory() {\n this.history = [], this.historyIndex = -1;\n }\n getHistory() {\n return this.history;\n }\n saveToHistory(t, e) {\n this.historyIndex < this.history.length - 1 && (this.history = this.history.slice(0, this.historyIndex + 1)), this.history.push({\n state: this.cloneState(t),\n timestamp: Date.now(),\n description: e\n }), this.history.length > O && this.history.shift(), this.historyIndex = this.history.length - 1;\n }\n restoreFromHistory() {\n const t = this.history[this.historyIndex];\n t && (this.isRestoring = !0, this.state = this.cloneState(t.state), this.notifyListeners(), this.isRestoring = !1);\n }\n notifyListeners() {\n const t = this.state;\n for (const e of this.listeners)\n try {\n e(t);\n } catch (i) {\n console.error(\"Error in state change listener:\", i);\n }\n }\n /**\n * Deep clone state. Contents are already serialized as Array<[string, AreaContent]>\n * so JSON.parse/stringify works correctly.\n */\n cloneState(t) {\n return JSON.parse(JSON.stringify(t));\n }\n}\nclass U {\n constructor(t) {\n this.listeners = /* @__PURE__ */ new Set(), this.areas = t, this.contents = this.buildInitialContents();\n }\n buildInitialContents() {\n const t = /* @__PURE__ */ new Map();\n for (const e of this.areas)\n S(e) && t.set(e.id, M(e));\n return t;\n }\n getContents() {\n return this.contents;\n }\n getContent(t) {\n return this.contents.get(t);\n }\n setTextContent(t, e) {\n const i = this.contents.get(t), n = this.areas.find((o) => o.id === t), s = n ? M(n) : {\n type: \"text\",\n text: \"\",\n font: \"Inter\",\n size: 24,\n color: \"#000000\",\n align: \"center\"\n };\n i?.type === \"text\" ? this.contents.set(t, { ...i, ...e }) : this.contents.set(t, { ...s, ...e }), this.notify();\n }\n setImageContent(t, e, i) {\n const n = {\n type: \"image\",\n dataUrl: e,\n filename: i\n };\n this.contents.set(t, n), this.notify();\n }\n clearContent(t) {\n const e = this.areas.find((i) => i.id === t);\n e && S(e) ? this.contents.set(t, M(e)) : this.contents.delete(t), this.notify();\n }\n setContentOffset(t, e) {\n const i = this.contents.get(t);\n i && (this.contents.set(t, { ...i, offset: e }), this.notify());\n }\n setImageScale(t, e) {\n const i = this.contents.get(t);\n if (!i || i.type !== \"image\") return;\n const n = Math.max(0.1, Math.min(5, e));\n this.contents.set(t, { ...i, scale: n }), this.notify();\n }\n setImageRotation(t, e) {\n const i = this.contents.get(t);\n if (!i || i.type !== \"image\") return;\n let n = e % 360;\n n < 0 && (n += 360), this.contents.set(t, { ...i, rotation: n }), this.notify();\n }\n reset() {\n this.contents = this.buildInitialContents(), this.notify();\n }\n /** Serialize for undo/redo (Map -> Array) */\n toJSON() {\n return Array.from(this.contents.entries());\n }\n /** Restore from serialized data */\n fromJSON(t) {\n this.contents = new Map(t), this.notify();\n }\n /** Replace the entire contents map (e.g. from undo/redo) without notification */\n setContentsQuiet(t) {\n this.contents = new Map(t);\n }\n subscribe(t) {\n return this.listeners.add(t), () => this.listeners.delete(t);\n }\n notify() {\n for (const t of this.listeners)\n try {\n t();\n } catch (e) {\n console.error(\"Error in AreaContentManager listener:\", e);\n }\n }\n}\nclass I {\n constructor() {\n this.listeners = /* @__PURE__ */ new Map();\n }\n /**\n * Register an event listener\n *\n * @param event - Event name\n * @param handler - Event handler function\n * @returns Unsubscribe function\n */\n on(t, e) {\n return this.listeners.has(t) || this.listeners.set(t, /* @__PURE__ */ new Set()), this.listeners.get(t).add(e), () => this.off(t, e);\n }\n /**\n * Register a one-time event listener\n *\n * @param event - Event name\n * @param handler - Event handler function\n * @returns Unsubscribe function\n */\n once(t, e) {\n const i = (s) => {\n e(s), this.off(t, i);\n };\n return this.on(t, i);\n }\n /**\n * Remove an event listener\n *\n * @param event - Event name\n * @param handler - Event handler function to remove\n */\n off(t, e) {\n const i = this.listeners.get(t);\n i && (i.delete(e), i.size === 0 && this.listeners.delete(t));\n }\n /**\n * Emit an event to all registered listeners\n *\n * @param event - Event name\n * @param data - Event data\n */\n emit(t, e) {\n const i = this.listeners.get(t);\n if (i) {\n const n = Array.from(i);\n for (const s of n)\n try {\n s(e);\n } catch (o) {\n console.error(`Error in event handler for \"${String(t)}\":`, o);\n }\n }\n }\n /**\n * Remove all listeners for an event, or all listeners if no event specified\n *\n * @param event - Optional event name to clear (clears all if not specified)\n */\n clear(t) {\n t ? this.listeners.delete(t) : this.listeners.clear();\n }\n /**\n * Get the number of listeners for an event\n *\n * @param event - Event name\n * @returns Number of listeners\n */\n listenerCount(t) {\n return this.listeners.get(t)?.size ?? 0;\n }\n}\nclass F extends I {\n constructor() {\n super(...arguments), this.activeTouches = /* @__PURE__ */ new Map(), this.initialPinchDistance = null, this.lastPinchCenter = null, this.isTwoFingerGesture = !1;\n }\n /** Whether a multi-touch gesture is currently active */\n get isMultiTouch() {\n return this.isTwoFingerGesture;\n }\n handleTouchStart(t) {\n for (let e = 0; e < t.changedTouches.length; e++) {\n const i = t.changedTouches[e];\n this.activeTouches.set(i.identifier, {\n x: i.clientX,\n y: i.clientY\n });\n }\n if (this.activeTouches.size === 2) {\n this.isTwoFingerGesture = !0, t.preventDefault();\n const [e, i] = Array.from(this.activeTouches.values());\n this.initialPinchDistance = this.getDistance(e, i), this.lastPinchCenter = this.getCenter(e, i);\n }\n }\n handleTouchMove(t) {\n for (let e = 0; e < t.changedTouches.length; e++) {\n const i = t.changedTouches[e];\n this.activeTouches.set(i.identifier, {\n x: i.clientX,\n y: i.clientY\n });\n }\n if (this.activeTouches.size === 2 && this.initialPinchDistance !== null && this.lastPinchCenter) {\n t.preventDefault();\n const [e, i] = Array.from(this.activeTouches.values()), n = this.getDistance(e, i), s = this.getCenter(e, i), o = n / this.initialPinchDistance;\n this.emit(\"pinch\", {\n scale: o,\n centerX: s.x,\n centerY: s.y\n });\n const a = s.x - this.lastPinchCenter.x, r = s.y - this.lastPinchCenter.y;\n (Math.abs(a) > 0.5 || Math.abs(r) > 0.5) && this.emit(\"pan\", { deltaX: a, deltaY: r }), this.initialPinchDistance = n, this.lastPinchCenter = s;\n }\n }\n handleTouchEnd(t) {\n for (let e = 0; e < t.changedTouches.length; e++) {\n const i = t.changedTouches[e];\n this.activeTouches.delete(i.identifier);\n }\n this.activeTouches.size < 2 && (this.initialPinchDistance = null, this.lastPinchCenter = null, this.isTwoFingerGesture = !1);\n }\n reset() {\n this.activeTouches.clear(), this.initialPinchDistance = null, this.lastPinchCenter = null, this.isTwoFingerGesture = !1;\n }\n getDistance(t, e) {\n const i = e.x - t.x, n = e.y - t.y;\n return Math.sqrt(i * i + n * n);\n }\n getCenter(t, e) {\n return {\n x: (t.x + e.x) / 2,\n y: (t.y + e.y) / 2\n };\n }\n}\nclass Z extends I {\n constructor(t, e, i, n) {\n super(), this.interactionState = { mode: \"idle\" }, this.initialPinchZoom = 1, this.canvas = t, this.engine = e, this.getContents = i, this.getSelectedAreaId = n, this.gestureHandler = new F(), this.boundMouseDown = this.handleMouseDown.bind(this), this.boundMouseMove = this.handleMouseMove.bind(this), this.boundMouseUp = this.handleMouseUp.bind(this), this.boundMouseLeave = this.handleMouseLeave.bind(this), this.boundContextMenu = this.handleContextMenu.bind(this), this.boundDoubleClick = this.handleDoubleClick.bind(this), this.boundTouchStart = this.handleTouchStart.bind(this), this.boundTouchMove = this.handleTouchMove.bind(this), this.boundTouchEnd = this.handleTouchEnd.bind(this), t.addEventListener(\"mousedown\", this.boundMouseDown), t.addEventListener(\"mousemove\", this.boundMouseMove), t.addEventListener(\"mouseup\", this.boundMouseUp), t.addEventListener(\"mouseleave\", this.boundMouseLeave), t.addEventListener(\"contextmenu\", this.boundContextMenu), t.addEventListener(\"dblclick\", this.boundDoubleClick), t.addEventListener(\"touchstart\", this.boundTouchStart, { passive: !1 }), t.addEventListener(\"touchmove\", this.boundTouchMove, { passive: !1 }), t.addEventListener(\"touchend\", this.boundTouchEnd), this.gestureHandler.on(\"pinch\", ({ scale: s }) => {\n const o = Math.max(0.1, Math.min(5, this.initialPinchZoom * s));\n this.emit(\"zoom\", { zoom: o });\n }), this.gestureHandler.on(\"pan\", ({ deltaX: s, deltaY: o }) => {\n const a = this.engine.getPan(), r = this.engine.getZoom();\n this.emit(\"pan\", {\n pan: {\n x: a.x + s / r,\n y: a.y + o / r\n }\n });\n });\n }\n getCanvasPosition(t, e) {\n const i = this.canvas.getBoundingClientRect(), n = window.devicePixelRatio || 1, s = (t - i.left) * n, o = (e - i.top) * n;\n return this.engine.screenToCanvas(s, o);\n }\n handleMouseDown(t) {\n const e = this.getCanvasPosition(t.clientX, t.clientY);\n this.processPointerDown(e);\n }\n handleMouseMove(t) {\n const e = this.getCanvasPosition(t.clientX, t.clientY);\n this.processPointerMove(e);\n }\n handleMouseUp() {\n this.processPointerUp();\n }\n handleMouseLeave() {\n this.processPointerUp(), this.emit(\"cursor\", { cursor: \"default\" });\n }\n handleContextMenu(t) {\n t.preventDefault();\n }\n handleDoubleClick(t) {\n const e = this.getCanvasPosition(t.clientX, t.clientY);\n let i = this.engine.hitTestContent(e.x, e.y);\n i || (i = this.engine.hitTestArea(e.x, e.y) ?? null), this.emit(\"context-menu\", { areaId: i, clientX: t.clientX, clientY: t.clientY });\n }\n handleTouchStart(t) {\n if (this.gestureHandler.handleTouchStart(t), this.gestureHandler.isMultiTouch) {\n this.initialPinchZoom = this.engine.getZoom(), this.interactionState.mode !== \"idle\" && (this.interactionState = { mode: \"idle\" });\n return;\n }\n if (t.touches.length !== 1) return;\n const e = t.touches[0], i = this.getCanvasPosition(e.clientX, e.clientY);\n this.processPointerDown(i) && t.preventDefault();\n }\n handleTouchMove(t) {\n if (this.gestureHandler.handleTouchMove(t), this.gestureHandler.isMultiTouch || t.touches.length !== 1 || this.interactionState.mode === \"idle\") return;\n const e = t.touches[0], i = this.getCanvasPosition(e.clientX, e.clientY);\n this.processPointerMove(i), t.preventDefault();\n }\n handleTouchEnd(t) {\n this.gestureHandler.handleTouchEnd(t), this.gestureHandler.isMultiTouch || this.processPointerUp();\n }\n /**\n * Process pointer down. Returns true if an interaction started.\n */\n processPointerDown(t) {\n const e = this.getSelectedAreaId(), i = this.getContents();\n if (e) {\n const o = this.engine.hitTestHandle(t.x, t.y, e);\n if (o) {\n const a = i.get(e), r = this.engine.getContentBounds(e);\n if (o === \"rotate\" && a?.type === \"image\" && r) {\n const d = Math.atan2(t.y - r.centerY, t.x - r.centerX) * (180 / Math.PI);\n return this.interactionState = {\n mode: \"rotating\",\n areaId: e,\n startRotation: a.rotation ?? 0,\n centerPoint: { x: r.centerX, y: r.centerY },\n startAngle: d\n }, !0;\n } else if (o !== \"rotate\" && a?.type === \"image\" && r)\n return this.interactionState = {\n mode: \"scaling\",\n areaId: e,\n handle: o,\n startScale: a.scale ?? 1,\n startMousePos: t,\n pivotPoint: { x: r.centerX, y: r.centerY }\n }, !0;\n }\n }\n const n = this.engine.hitTestContent(t.x, t.y);\n if (n) {\n if (this.emit(\"area:select\", { areaId: n }), this.engine.isPositioningAllowed(n)) {\n const a = i.get(n)?.offset ?? { x: 0, y: 0 };\n return this.interactionState = {\n mode: \"dragging\",\n areaId: n,\n startOffset: a,\n startMousePos: t\n }, !0;\n }\n return !0;\n }\n const s = this.engine.hitTestArea(t.x, t.y);\n return s ? (this.emit(\"area:select\", { areaId: s }), !1) : (this.emit(\"area:select\", { areaId: null }), !1);\n }\n processPointerMove(t) {\n if (this.interactionState.mode === \"dragging\") {\n const { areaId: e, startOffset: i, startMousePos: n } = this.interactionState, s = t.x - n.x, o = t.y - n.y;\n let a = {\n x: i.x + s,\n y: i.y + o\n };\n const r = this.engine.getAreaLocation(e);\n if (r) {\n const d = r.width / 2 - 10, l = r.height / 2 - 10;\n a.x = Math.max(-d, Math.min(d, a.x)), a.y = Math.max(-l, Math.min(l, a.y));\n }\n this.emit(\"content:drag\", { areaId: e, offset: a });\n return;\n }\n if (this.interactionState.mode === \"scaling\") {\n const { areaId: e, startScale: i, startMousePos: n, pivotPoint: s } = this.interactionState, o = Math.sqrt(\n Math.pow(n.x - s.x, 2) + Math.pow(n.y - s.y, 2)\n ), a = Math.sqrt(\n Math.pow(t.x - s.x, 2) + Math.pow(t.y - s.y, 2)\n );\n if (o > 0) {\n const r = a / o, d = Math.max(0.1, Math.min(5, i * r));\n this.emit(\"content:scale\", { areaId: e, scale: d });\n }\n return;\n }\n if (this.interactionState.mode === \"rotating\") {\n const { areaId: e, startRotation: i, centerPoint: n, startAngle: s } = this.interactionState, o = Math.atan2(t.y - n.y, t.x - n.x) * (180 / Math.PI);\n let a = i + (o - s);\n a = a % 360, a < 0 && (a += 360);\n const r = [0, 90, 180, 270, 360];\n for (const d of r)\n if (Math.abs(a - d) < 5) {\n a = d === 360 ? 0 : d;\n break;\n }\n this.emit(\"content:rotate\", { areaId: e, rotation: a });\n return;\n }\n this.updateCursor(t);\n }\n processPointerUp() {\n this.interactionState.mode !== \"idle\" && (this.interactionState = { mode: \"idle\" });\n }\n updateCursor(t) {\n const e = this.getSelectedAreaId();\n let i = \"default\";\n if (e) {\n const n = this.engine.hitTestHandle(t.x, t.y, e);\n n ? i = n === \"rotate\" ? \"crosshair\" : n === \"nw\" || n === \"se\" ? \"nwse-resize\" : \"nesw-resize\" : this.engine.hitTestContent(t.x, t.y) === e && (i = this.engine.isPositioningAllowed(e) ? \"move\" : \"pointer\");\n } else\n this.engine.hitTestContent(t.x, t.y) && (i = \"pointer\");\n this.emit(\"cursor\", { cursor: i });\n }\n setSelectedArea(t) {\n this.engine.setSelectedArea(t);\n }\n destroy() {\n this.canvas.removeEventListener(\"mousedown\", this.boundMouseDown), this.canvas.removeEventListener(\"mousemove\", this.boundMouseMove), this.canvas.removeEventListener(\"mouseup\", this.boundMouseUp), this.canvas.removeEventListener(\"mouseleave\", this.boundMouseLeave), this.canvas.removeEventListener(\"contextmenu\", this.boundContextMenu), this.canvas.removeEventListener(\"dblclick\", this.boundDoubleClick), this.canvas.removeEventListener(\"touchstart\", this.boundTouchStart), this.canvas.removeEventListener(\"touchmove\", this.boundTouchMove), this.canvas.removeEventListener(\"touchend\", this.boundTouchEnd), this.gestureHandler.reset(), this.clear();\n }\n}\nclass B {\n constructor(t = \"/api\") {\n this.baseUrl = t;\n }\n async getTemplate(t) {\n try {\n const e = await fetch(`${this.baseUrl}/templates/${t}`);\n if (!e.ok) {\n let n = `Failed to load template (${e.status} ${e.statusText}): ${t}\n\n`;\n throw e.status === 404 ? n += \"Template not found.\" : e.status === 403 ? n += \"Access forbidden.\" : e.status >= 500 && (n += \"Server error.\"), new Error(n);\n }\n return (await e.json()).templateJson;\n } catch (e) {\n throw e instanceof Error && e.message.includes(\"Failed to fetch\") ? new Error(`Network error loading template: ${t}`) : e;\n }\n }\n async finalizeDesign(t, e) {\n try {\n const i = await fetch(`${this.baseUrl}/finalize`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n shopId: t,\n templateId: e.templateId,\n designJson: e\n })\n });\n if (!i.ok) {\n let n = `Failed to finalize design (${i.status} ${i.statusText})\n\n`;\n if (i.status === 400) {\n const s = await i.json().catch(() => ({}));\n n += s.error || \"Invalid design data.\";\n } else i.status === 429 ? n += \"Rate limit exceeded.\" : i.status >= 500 && (n += \"Server error.\");\n throw new Error(n);\n }\n return i.json();\n } catch (i) {\n throw i instanceof Error && i.message.includes(\"Failed to fetch\") ? new Error(\"Network error finalizing design\") : i;\n }\n }\n async uploadAsset(t, e) {\n try {\n const i = new FormData();\n i.append(\"shopId\", e), i.append(\"file\", t);\n const n = await fetch(`${this.baseUrl}/assets/upload`, {\n method: \"POST\",\n body: i\n });\n if (!n.ok) {\n let s = `Failed to upload asset (${n.status} ${n.statusText})\n\n`;\n if (n.status === 400) {\n const o = await n.json().catch(() => ({}));\n s += o.error || \"Invalid file.\";\n } else n.status === 413 ? s += \"File too large (max 15MB).\" : n.status >= 500 && (s += \"Server error.\");\n throw new Error(s);\n }\n return n.json();\n } catch (i) {\n throw i instanceof Error && i.message.includes(\"Failed to fetch\") ? new Error(\"Network error uploading asset\") : i;\n }\n }\n async getStorageUsage(t) {\n try {\n const e = await fetch(`${this.baseUrl}/assets/usage?shopId=${encodeURIComponent(t)}`);\n if (!e.ok)\n throw new Error(`Failed to fetch storage usage (${e.status})`);\n return e.json();\n } catch (e) {\n throw e instanceof Error && e.message.includes(\"Failed to fetch\") ? new Error(\"Network error fetching storage usage\") : e;\n }\n }\n}\nfunction h(f, t, ...e) {\n const i = document.createElement(f);\n return t && Object.entries(t).forEach(([n, s]) => {\n n === \"class\" ? i.className = s : n in i ? i[n] = s : i.setAttribute(n, String(s));\n }), e.forEach((n) => {\n typeof n == \"string\" ? i.appendChild(document.createTextNode(n)) : i.appendChild(n);\n }), i;\n}\nfunction N(f, t) {\n let e = null, i = null;\n const n = (...s) => {\n i = s, e && clearTimeout(e), e = setTimeout(() => {\n i && f(...i), e = null, i = null;\n }, t);\n };\n return n.flush = () => {\n e && (clearTimeout(e), e = null), i && (f(...i), i = null);\n }, n.cancel = () => {\n e && (clearTimeout(e), e = null), i = null;\n }, n;\n}\nclass Y extends I {\n constructor() {\n super(), this.percentLabel = h(\"span\", { class: \"zoom-percent\" }, \"100%\");\n const t = h(\"button\", {\n class: \"zoom-btn\",\n title: \"Zoom out\"\n }, \"−\");\n t.addEventListener(\"click\", () => this.emit(\"zoom-out\", void 0));\n const e = h(\"button\", {\n class: \"zoom-btn\",\n title: \"Fit to view\"\n }, \"Fit\");\n e.addEventListener(\"click\", () => this.emit(\"zoom-fit\", void 0));\n const i = h(\"button\", {\n class: \"zoom-btn\",\n title: \"Zoom in\"\n }, \"+\");\n i.addEventListener(\"click\", () => this.emit(\"zoom-in\", void 0)), this.element = h(\"div\", { class: \"zoom-toolbar\" }), this.element.appendChild(t), this.element.appendChild(e), this.element.appendChild(i), this.element.appendChild(this.percentLabel);\n }\n setZoom(t) {\n this.percentLabel.textContent = `${Math.round(t * 100)}%`;\n }\n getElement() {\n return this.element;\n }\n}\nconst W = [\n { label: \"Inter\", value: \"Inter\" },\n { label: \"Arial\", value: \"Arial\" },\n { label: \"Georgia\", value: \"Georgia\" },\n { label: \"Times New Roman\", value: \"Times New Roman\" },\n { label: \"Courier New\", value: \"Courier New\" }\n], X = [\n { label: \"L\", value: \"left\" },\n { label: \"C\", value: \"center\" },\n { label: \"R\", value: \"right\" }\n], A = [\"image/png\", \"image/jpeg\", \"image/webp\", \"image/svg+xml\"], $ = 15 * 1024 * 1024;\nclass q extends I {\n constructor(t) {\n super(), this.mode = \"text\", this.isSelected = !1, this.textInputEl = null, this.fontSelectEl = null, this.sizeInputEl = null, this.colorInputEl = null, this.alignGroupEl = null, this.area = t;\n const e = S(t), i = z(t);\n this.mode = i && !e ? \"image\" : \"text\", this.element = h(\"div\", { class: \"area-card\" }), this.element.addEventListener(\"click\", (r) => {\n r.target.tagName === \"INPUT\" || r.target.tagName === \"SELECT\" || r.target.tagName === \"BUTTON\" || this.emit(\"select\", { areaId: t.id });\n });\n const n = h(\"div\", { class: \"area-card-header\" }), s = h(\"div\", { class: \"area-card-name-row\" }), o = h(\"span\", { class: \"area-card-name\" }, t.name);\n if (s.appendChild(o), t.required) {\n const r = h(\"span\", { class: \"area-card-badge\" }, \"Required\");\n s.appendChild(r);\n }\n n.appendChild(s);\n const a = h(\"button\", {\n class: \"area-card-reset-btn\",\n title: \"Reset content\"\n }, \"Reset\");\n if (a.addEventListener(\"click\", (r) => {\n r.stopPropagation(), this.emit(\"clear\", { areaId: t.id });\n }), n.appendChild(a), this.element.appendChild(n), e && i) {\n const r = h(\"div\", { class: \"area-card-mode-switcher\" }), d = h(\"button\", {\n class: \"mode-btn mode-btn-active\"\n }, \"Text\");\n d.dataset.mode = \"text\";\n const l = h(\"button\", { class: \"mode-btn\" }, \"Image\");\n l.dataset.mode = \"image\", d.addEventListener(\"click\", (c) => {\n c.stopPropagation(), this.setMode(\"text\"), d.classList.add(\"mode-btn-active\"), l.classList.remove(\"mode-btn-active\"), this.currentContent?.type === \"image\" && this.emit(\"clear\", { areaId: t.id });\n }), l.addEventListener(\"click\", (c) => {\n c.stopPropagation(), this.setMode(\"image\"), l.classList.add(\"mode-btn-active\"), d.classList.remove(\"mode-btn-active\"), this.currentContent?.type === \"text\" && this.emit(\"clear\", { areaId: t.id });\n }), r.appendChild(d), r.appendChild(l), this.element.appendChild(r);\n }\n this.contentContainer = h(\"div\", { class: \"area-card-content\" }), this.element.appendChild(this.contentContainer), this.transformContainer = h(\"div\", { class: \"area-card-transforms\" }), this.element.appendChild(this.transformContainer), this.renderContent();\n }\n setMode(t) {\n this.mode = t, this.renderContent();\n }\n setContent(t) {\n const e = this.currentContent?.type;\n this.currentContent = t, t?.type === \"image\" && (this.mode = \"image\"), this.element.querySelectorAll(\".mode-btn\").forEach((s) => {\n const o = s;\n o.classList.toggle(\"mode-btn-active\", o.dataset.mode === this.mode);\n }), t?.type !== e || t?.type === \"image\" || t === void 0 ? this.renderContent() : t?.type === \"text\" && this.updateTextValues(t), this.renderTransforms();\n }\n setSelected(t) {\n this.isSelected = t, this.element.classList.toggle(\"area-card-selected\", t), this.renderTransforms();\n }\n updateTextValues(t) {\n this.textInputEl && this.textInputEl.value !== t.text && (this.textInputEl.value = t.text), this.fontSelectEl && this.fontSelectEl.value !== t.font && (this.fontSelectEl.value = t.font), this.sizeInputEl && this.sizeInputEl.value !== String(t.size) && (this.sizeInputEl.value = String(t.size)), this.colorInputEl && this.colorInputEl.value !== t.color && (this.colorInputEl.value = t.color), this.alignGroupEl && this.alignGroupEl.querySelectorAll(\".align-btn\").forEach((e) => {\n const i = e, n = i.title === \"Left\" ? \"left\" : i.title === \"Center\" ? \"center\" : \"right\";\n i.classList.toggle(\"align-btn-active\", n === t.align);\n });\n }\n renderContent() {\n this.contentContainer.innerHTML = \"\", this.textInputEl = null, this.fontSelectEl = null, this.sizeInputEl = null, this.colorInputEl = null, this.alignGroupEl = null;\n const t = S(this.area), e = z(this.area), i = !e || t && e && this.mode === \"text\", n = !t || t && e && this.mode === \"image\";\n t && i && this.renderTextControls(), e && n && this.renderImageControls();\n }\n renderTextControls() {\n const t = this.currentContent, e = t?.type === \"text\" ? t : M(this.area), i = h(\"input\", {\n class: \"area-input-text\",\n type: \"text\",\n placeholder: this.area.placeholder || \"Enter text...\"\n });\n i.value = e.text, this.area.textOptions?.maxLength && (i.maxLength = this.area.textOptions.maxLength), i.addEventListener(\"input\", () => {\n this.emit(\"text:change\", { areaId: this.area.id, updates: { text: i.value } });\n }), this.contentContainer.appendChild(i), this.textInputEl = i;\n const n = h(\"div\", { class: \"area-input-row\" }), s = h(\"select\", { class: \"area-input-font\" });\n for (const l of W) {\n const c = h(\"option\");\n c.value = l.value, c.textContent = l.label, l.value === e.font && (c.selected = !0), s.appendChild(c);\n }\n s.addEventListener(\"change\", () => {\n this.emit(\"text:change\", { areaId: this.area.id, updates: { font: s.value } });\n }), n.appendChild(s), this.fontSelectEl = s;\n const o = h(\"input\", {\n class: \"area-input-size\",\n type: \"number\"\n });\n o.value = String(e.size), o.min = String(this.area.textOptions?.minSize || 8), o.max = String(this.area.textOptions?.maxSize || 200), o.addEventListener(\"change\", () => {\n this.emit(\"text:change\", {\n areaId: this.area.id,\n updates: { size: parseInt(o.value, 10) || 24 }\n });\n }), n.appendChild(o), this.sizeInputEl = o, this.contentContainer.appendChild(n);\n const a = h(\"div\", { class: \"area-input-row\" }), r = h(\"div\", { class: \"area-input-align\" });\n for (const l of X) {\n const c = h(\"button\", {\n class: `align-btn${e.align === l.value ? \" align-btn-active\" : \"\"}`,\n title: l.label === \"L\" ? \"Left\" : l.label === \"C\" ? \"Center\" : \"Right\"\n }, l.label);\n c.addEventListener(\"click\", (u) => {\n u.stopPropagation(), this.emit(\"text:change\", { areaId: this.area.id, updates: { align: l.value } }), r.querySelectorAll(\".align-btn\").forEach((p) => p.classList.remove(\"align-btn-active\")), c.classList.add(\"align-btn-active\");\n }), r.appendChild(c);\n }\n a.appendChild(r), this.alignGroupEl = r;\n const d = h(\"input\", {\n class: \"area-input-color\",\n type: \"color\"\n });\n d.value = e.color, d.addEventListener(\"input\", () => {\n this.emit(\"text:change\", { areaId: this.area.id, updates: { color: d.value } });\n }), a.appendChild(d), this.colorInputEl = d, this.contentContainer.appendChild(a);\n }\n renderImageControls() {\n const t = this.currentContent;\n if (t?.type === \"image\") {\n const e = h(\"div\", { class: \"area-image-preview\" }), i = h(\"img\", { class: \"area-image-thumb\" });\n i.src = t.dataUrl, i.alt = t.filename || \"Uploaded image\", e.appendChild(i);\n const n = h(\"div\", { class: \"area-image-info\" });\n n.appendChild(h(\"span\", { class: \"area-image-name\" }, t.filename || \"Image\"));\n const s = h(\"button\", { class: \"area-image-remove-btn\" }, \"Remove\");\n s.addEventListener(\"click\", (o) => {\n o.stopPropagation(), this.emit(\"clear\", { areaId: this.area.id });\n }), n.appendChild(s), e.appendChild(n), this.contentContainer.appendChild(e);\n } else {\n const e = h(\"button\", { class: \"area-upload-btn\" }, \"Upload Image\"), i = h(\"input\", { type: \"file\" });\n i.accept = A.join(\",\"), i.style.display = \"none\";\n const n = h(\"div\", { class: \"area-validation-error\" });\n n.style.display = \"none\", i.addEventListener(\"change\", () => {\n const s = i.files?.[0];\n if (!s) return;\n if (!A.includes(s.type)) {\n const a = \"Only PNG, JPEG, WebP, and SVG images are accepted\";\n n.textContent = a, n.style.display = \"block\", this.emit(\"validation:error\", { areaId: this.area.id, message: a }), i.value = \"\";\n return;\n }\n if (s.size > $) {\n const a = \"File must be smaller than 15MB\";\n n.textContent = a, n.style.display = \"block\", this.emit(\"validation:error\", { areaId: this.area.id, message: a }), i.value = \"\";\n return;\n }\n n.style.display = \"none\";\n const o = new FileReader();\n o.onload = () => {\n const a = o.result;\n this.emit(\"image:change\", { areaId: this.area.id, dataUrl: a, filename: s.name });\n }, o.readAsDataURL(s), i.value = \"\";\n }), e.addEventListener(\"click\", (s) => {\n s.stopPropagation(), i.click();\n }), this.contentContainer.appendChild(e), this.contentContainer.appendChild(i), this.contentContainer.appendChild(n);\n }\n }\n renderTransforms() {\n this.transformContainer.innerHTML = \"\";\n const t = this.currentContent;\n if (!this.isSelected || !t) return;\n const e = t.type === \"text\" ? this.area.textOptions?.allowPositioning : this.area.imageOptions?.allowPositioning, i = t.type === \"image\" && this.area.imageOptions?.allowScaling, n = t.type === \"image\" && this.area.imageOptions?.allowRotation;\n if (!e && !i && !n) return;\n const s = h(\"div\", { class: \"area-card-divider\" });\n this.transformContainer.appendChild(s);\n const o = h(\"div\", { class: \"transform-header\" });\n o.appendChild(h(\"span\", { class: \"transform-title\" }, \"Transform\"));\n const a = h(\"button\", { class: \"transform-reset-btn\" }, \"Reset\");\n a.addEventListener(\"click\", (d) => {\n d.stopPropagation(), e && this.emit(\"offset:change\", { areaId: this.area.id, offset: { x: 0, y: 0 } }), i && this.emit(\"scale:change\", { areaId: this.area.id, scale: 1 }), n && this.emit(\"rotation:change\", { areaId: this.area.id, rotation: 0 });\n }), o.appendChild(a), this.transformContainer.appendChild(o);\n const r = t.offset ?? { x: 0, y: 0 };\n if (e) {\n const d = h(\"div\", { class: \"area-input-row\" }), l = h(\"label\", { class: \"transform-label\" }, \"X\"), c = h(\"input\", { class: \"transform-input\", type: \"number\" });\n c.value = String(Math.round(r.x)), c.addEventListener(\"change\", () => {\n this.emit(\"offset:change\", {\n areaId: this.area.id,\n offset: { ...r, x: parseInt(c.value, 10) || 0 }\n });\n });\n const u = h(\"label\", { class: \"transform-label\" }, \"Y\"), p = h(\"input\", { class: \"transform-input\", type: \"number\" });\n p.value = String(Math.round(r.y)), p.addEventListener(\"change\", () => {\n this.emit(\"offset:change\", {\n areaId: this.area.id,\n offset: { ...r, y: parseInt(p.value, 10) || 0 }\n });\n }), d.appendChild(l), d.appendChild(c), d.appendChild(u), d.appendChild(p), this.transformContainer.appendChild(d);\n }\n if (i && t.type === \"image\") {\n const d = t.scale ?? 1, l = h(\"div\", { class: \"area-input-row transform-slider-row\" }), c = h(\"label\", { class: \"transform-label\" }, `Scale: ${Math.round(d * 100)}%`), u = h(\"input\", { class: \"transform-slider\", type: \"range\" });\n u.min = \"10\", u.max = \"500\", u.step = \"5\", u.value = String(Math.round(d * 100)), u.addEventListener(\"input\", () => {\n const p = parseInt(u.value, 10) / 100;\n c.textContent = `Scale: ${Math.round(p * 100)}%`, this.emit(\"scale:change\", { areaId: this.area.id, scale: p });\n }), l.appendChild(c), l.appendChild(u), this.transformContainer.appendChild(l);\n }\n if (n && t.type === \"image\") {\n const d = t.rotation ?? 0, l = h(\"div\", { class: \"area-input-row transform-slider-row\" }), c = h(\"label\", { class: \"transform-label\" }, `Rotation: ${Math.round(d)}°`), u = h(\"input\", { class: \"transform-slider\", type: \"range\" });\n u.min = \"0\", u.max = \"360\", u.step = \"1\", u.value = String(Math.round(d)), u.addEventListener(\"input\", () => {\n const p = parseInt(u.value, 10);\n c.textContent = `Rotation: ${p}°`, this.emit(\"rotation:change\", { areaId: this.area.id, rotation: p });\n }), l.appendChild(c), l.appendChild(u), this.transformContainer.appendChild(l);\n }\n }\n getElement() {\n return this.element;\n }\n}\nclass G extends I {\n constructor(t) {\n super(), this.cards = /* @__PURE__ */ new Map(), this.isMobile = !1, this.boundEscapeHandler = (n) => {\n n.key === \"Escape\" && this.emit(\"dismiss\", void 0);\n }, this.backdrop = h(\"div\", { class: \"area-panel-backdrop\" }), this.backdrop.addEventListener(\"click\", () => {\n this.emit(\"dismiss\", void 0);\n }), this.element = h(\"div\", { class: \"area-panel\" });\n const e = h(\"div\", { class: \"area-panel-header\" });\n e.appendChild(h(\"span\", { class: \"area-panel-title\" }, \"Customize\"));\n const i = h(\"button\", { class: \"area-panel-close-btn\", title: \"Close\" }, \"×\");\n if (i.addEventListener(\"click\", () => {\n this.emit(\"dismiss\", void 0);\n }), e.appendChild(i), this.element.appendChild(e), this.panelContent = h(\"div\", { class: \"area-panel-content\" }), t.length === 0) {\n const n = h(\"p\", { class: \"area-panel-empty\" }, \"No customization areas defined.\");\n this.panelContent.appendChild(n);\n } else\n for (const n of t) {\n const s = new q(n);\n this.cards.set(n.id, s), s.on(\"text:change\", (o) => this.emit(\"text:change\", o)), s.on(\"image:change\", (o) => this.emit(\"image:change\", o)), s.on(\"clear\", (o) => this.emit(\"clear\", o)), s.on(\"select\", (o) => this.emit(\"select\", o)), s.on(\"offset:change\", (o) => this.emit(\"offset:change\", o)), s.on(\"scale:change\", (o) => this.emit(\"scale:change\", o)), s.on(\"rotation:change\", (o) => this.emit(\"rotation:change\", o)), s.on(\"validation:error\", (o) => this.emit(\"validation:error\", o)), this.panelContent.appendChild(s.getElement());\n }\n this.element.appendChild(this.panelContent);\n }\n setContents(t) {\n for (const [e, i] of this.cards)\n i.setContent(t.get(e));\n }\n setSelectedArea(t) {\n for (const [e, i] of this.cards) {\n const n = e === t;\n i.setSelected(n), i.getElement().style.display = n ? \"\" : \"none\";\n }\n t ? (this.element.classList.add(\"area-panel-visible\"), this.isMobile && this.backdrop.classList.add(\"area-panel-backdrop-visible\"), document.addEventListener(\"keydown\", this.boundEscapeHandler)) : (this.element.classList.remove(\"area-panel-visible\"), this.isMobile && this.backdrop.classList.remove(\"area-panel-backdrop-visible\"), document.removeEventListener(\"keydown\", this.boundEscapeHandler));\n }\n setMobile(t) {\n this.isMobile = t, this.element.classList.toggle(\"area-panel-mobile\", t), t || (this.element.classList.remove(\"area-panel-visible\"), this.backdrop.classList.remove(\"area-panel-backdrop-visible\"));\n }\n getElement() {\n return this.element;\n }\n getBackdrop() {\n return this.backdrop;\n }\n}\nclass j {\n constructor(t = window) {\n this.target = t, this.commands = [], this.isEnabled = !0, this.handleKeyDown = (e) => {\n if (!this.isEnabled) return;\n const i = e.target;\n if (!(i.tagName === \"INPUT\" || i.tagName === \"TEXTAREA\" || i.isContentEditable)) {\n for (const n of this.commands)\n if (this.matchesCommand(e, n)) {\n e.preventDefault(), n.handler(e);\n break;\n }\n }\n }, this.target.addEventListener(\"keydown\", this.handleKeyDown);\n }\n /**\n * Register a keyboard command\n */\n register(t) {\n return this.commands.push(t), () => {\n const e = this.commands.indexOf(t);\n e !== -1 && this.commands.splice(e, 1);\n };\n }\n /**\n * Enable keyboard handling\n */\n enable() {\n this.isEnabled = !0;\n }\n /**\n * Disable keyboard handling\n */\n disable() {\n this.isEnabled = !1;\n }\n /**\n * Check if keyboard handling is enabled\n */\n isActive() {\n return this.isEnabled;\n }\n /**\n * Check if event matches a command\n */\n matchesCommand(t, e) {\n return !(t.key.toLowerCase() !== e.key.toLowerCase() || e.ctrl !== void 0 && e.ctrl !== t.ctrlKey || e.shift !== void 0 && e.shift !== t.shiftKey || e.alt !== void 0 && e.alt !== t.altKey || e.meta !== void 0 && e.meta !== t.metaKey);\n }\n /**\n * Cleanup\n */\n destroy() {\n this.target.removeEventListener(\"keydown\", this.handleKeyDown), this.commands = [];\n }\n}\nfunction J() {\n return /Mac|iPod|iPhone|iPad/.test(navigator.platform);\n}\nfunction V() {\n return J() ? \"meta\" : \"ctrl\";\n}\nfunction K(f, t, e, i) {\n const n = f / e, s = t / i;\n return Math.min(n, s);\n}\nfunction _(f, t, e = 8, i = 10, n = 300) {\n const s = K(f, t, e, i), o = s >= n;\n return {\n actualDPI: Math.round(s),\n targetDPI: n,\n width: f,\n height: t,\n passed: o,\n warning: o ? void 0 : `Image resolution is ${Math.round(s)} DPI at 100% scale. For best print quality, use images with at least ${n} DPI. This may result in pixelated or blurry prints.`\n };\n}\nconst T = ':host{--editor-bg: #f3f4f6;--editor-surface: #ffffff;--editor-border: #e5e7eb;--editor-text: #111827;--editor-text-muted: #6b7280;--editor-primary: #3b82f6;--editor-primary-hover: #2563eb;--editor-danger: #ef4444;--editor-radius: 8px;--editor-radius-sm: 4px;--editor-font: system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif;--editor-panel-width: 280px;display:block;width:100%;height:100%;font-family:var(--editor-font);font-size:13px;color:var(--editor-text);line-height:1.4}:host([theme=\"dark\"]){--editor-bg: #1f2937;--editor-surface: #374151;--editor-border: #4b5563;--editor-text: #f9fafb;--editor-text-muted: #9ca3af}.editor-container{display:flex;flex-direction:column;width:100%;height:100%;position:relative;overflow:hidden;background:var(--editor-bg)}.layout-desktop .editor-main{display:flex;flex:1;min-height:0}.layout-desktop .canvas-area{flex:1;min-width:0;position:relative;display:flex;flex-direction:column}.layout-desktop .area-panel{width:var(--editor-panel-width);border-left:1px solid var(--editor-border);background:var(--editor-surface);display:none;flex-direction:column;overflow:hidden}.layout-desktop .area-panel.area-panel-visible{display:flex}.layout-mobile .editor-main{display:flex;flex-direction:column;flex:1;min-height:0}.layout-mobile .canvas-area{flex:1;position:relative;display:flex;flex-direction:column;min-height:0}.layout-mobile .area-panel{position:absolute;bottom:0;left:0;right:0;max-height:50%;background:var(--editor-surface);border-top:1px solid var(--editor-border);border-radius:var(--editor-radius) var(--editor-radius) 0 0;box-shadow:0 -4px 20px #00000026;transform:translateY(100%);transition:transform .25s ease-out;z-index:20;display:flex;flex-direction:column;overflow:hidden}.layout-mobile .area-panel.area-panel-visible{transform:translateY(0)}.area-panel-backdrop{display:none}.layout-mobile .area-panel-backdrop{display:block;position:absolute;inset:0;background:#0000004d;z-index:15;opacity:0;pointer-events:none;transition:opacity .25s ease-out}.layout-mobile .area-panel-backdrop.area-panel-backdrop-visible{opacity:1;pointer-events:auto}.zoom-toolbar{display:flex;align-items:center;gap:4px;padding:8px 12px;background:var(--editor-surface);border-bottom:1px solid var(--editor-border)}.zoom-btn{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;border:1px solid var(--editor-border);border-radius:var(--editor-radius-sm);background:var(--editor-surface);color:var(--editor-text);cursor:pointer;font-size:14px;font-family:var(--editor-font);transition:background .15s;-webkit-tap-highlight-color:transparent;touch-action:manipulation}.zoom-btn:hover{background:var(--editor-bg)}.zoom-btn:active{background:var(--editor-border)}.zoom-percent{margin-left:8px;font-size:12px;color:var(--editor-text-muted);min-width:40px}.canvas-wrapper{flex:1;position:relative;overflow:hidden;min-height:200px}.editor-canvas{position:absolute;top:0;left:0}.area-panel-header{display:flex;justify-content:space-between;align-items:center;padding:12px 16px;border-bottom:1px solid var(--editor-border);flex-shrink:0}.area-panel-title{font-weight:600;font-size:14px}.area-panel-close-btn{width:28px;height:28px;border:none;background:none;color:var(--editor-text-muted);cursor:pointer;font-size:18px;line-height:1;border-radius:var(--editor-radius-sm);display:flex;align-items:center;justify-content:center}.area-panel-close-btn:hover{background:var(--editor-bg);color:var(--editor-text)}.area-panel-content{flex:1;overflow-y:auto;padding:12px;display:flex;flex-direction:column;gap:12px}.area-panel-empty{color:var(--editor-text-muted);font-size:12px;text-align:center;padding:20px 0}.area-card{padding:12px;border:1px solid var(--editor-border);border-radius:var(--editor-radius);background:var(--editor-surface);cursor:pointer;transition:border-color .15s}.area-card:hover{border-color:var(--editor-primary)}.area-card-selected{border-color:var(--editor-primary);box-shadow:0 0 0 1px var(--editor-primary)}.area-card-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:8px}.area-card-name-row{display:flex;align-items:center;gap:6px}.area-card-name{font-weight:600;font-size:13px}.area-card-badge{display:inline-block;padding:1px 6px;font-size:10px;font-weight:500;background:#fef3c7;color:#92400e;border-radius:10px}.area-card-reset-btn{padding:2px 8px;border:1px solid var(--editor-border);border-radius:var(--editor-radius-sm);background:none;color:var(--editor-text-muted);cursor:pointer;font-size:11px;font-family:var(--editor-font)}.area-card-reset-btn:hover{background:var(--editor-bg);color:var(--editor-danger);border-color:var(--editor-danger)}.area-card-mode-switcher{display:flex;gap:4px;margin-bottom:8px}.mode-btn{flex:1;padding:4px 8px;border:1px solid var(--editor-border);border-radius:var(--editor-radius-sm);background:var(--editor-surface);color:var(--editor-text);cursor:pointer;font-size:12px;font-family:var(--editor-font);transition:all .15s}.mode-btn-active{background:var(--editor-primary);color:#fff;border-color:var(--editor-primary)}.area-input-text{width:100%;padding:6px 8px;border:1px solid var(--editor-border);border-radius:var(--editor-radius-sm);font-family:var(--editor-font);font-size:13px;color:var(--editor-text);background:var(--editor-surface);box-sizing:border-box;margin-bottom:6px}.area-input-text:focus{outline:none;border-color:var(--editor-primary);box-shadow:0 0 0 1px var(--editor-primary)}.area-input-row{display:flex;gap:6px;align-items:center;margin-bottom:6px}.area-input-font{flex:1;padding:4px 6px;border:1px solid var(--editor-border);border-radius:var(--editor-radius-sm);font-family:var(--editor-font);font-size:12px;color:var(--editor-text);background:var(--editor-surface);min-width:0}.area-input-size{width:56px;padding:4px 6px;border:1px solid var(--editor-border);border-radius:var(--editor-radius-sm);font-family:var(--editor-font);font-size:12px;color:var(--editor-text);background:var(--editor-surface)}.area-input-align{display:flex;gap:2px}.align-btn{width:28px;height:28px;border:1px solid var(--editor-border);border-radius:var(--editor-radius-sm);background:var(--editor-surface);color:var(--editor-text);cursor:pointer;font-size:12px;font-weight:600;font-family:var(--editor-font)}.align-btn-active{background:var(--editor-primary);color:#fff;border-color:var(--editor-primary)}.area-input-color{width:32px;height:28px;padding:0;border:1px solid var(--editor-border);border-radius:var(--editor-radius-sm);cursor:pointer;background:none}.area-upload-btn{width:100%;padding:10px;border:2px dashed var(--editor-border);border-radius:var(--editor-radius);background:var(--editor-bg);color:var(--editor-text-muted);cursor:pointer;font-family:var(--editor-font);font-size:12px;text-align:center;transition:all .15s;min-height:44px}.area-upload-btn:hover{border-color:var(--editor-primary);color:var(--editor-primary)}.area-image-preview{display:flex;gap:8px;align-items:center}.area-image-thumb{width:48px;height:48px;object-fit:cover;border-radius:var(--editor-radius-sm);border:1px solid var(--editor-border)}.area-image-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:4px}.area-image-name{font-size:12px;color:var(--editor-text-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.area-image-remove-btn{padding:2px 8px;border:1px solid var(--editor-danger);border-radius:var(--editor-radius-sm);background:none;color:var(--editor-danger);cursor:pointer;font-size:11px;font-family:var(--editor-font);width:fit-content}.area-image-remove-btn:hover{background:#fef2f2}.area-card-divider{height:1px;background:var(--editor-border);margin:8px 0}.transform-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:6px}.transform-title{font-weight:600;font-size:12px}.transform-reset-btn{padding:2px 8px;border:1px solid var(--editor-border);border-radius:var(--editor-radius-sm);background:none;color:var(--editor-text-muted);cursor:pointer;font-size:11px;font-family:var(--editor-font)}.transform-reset-btn:hover{background:var(--editor-bg)}.transform-label{font-size:11px;color:var(--editor-text-muted);white-space:nowrap}.transform-input{width:60px;padding:3px 6px;border:1px solid var(--editor-border);border-radius:var(--editor-radius-sm);font-family:var(--editor-font);font-size:12px;color:var(--editor-text);background:var(--editor-surface)}.transform-slider-row{flex-direction:column;align-items:stretch}.transform-slider{width:100%;accent-color:var(--editor-primary)}.loading-container{display:flex;justify-content:center;align-items:center;width:100%;height:100%;min-height:200px}.loading-spinner{width:32px;height:32px;border:3px solid var(--editor-border);border-top-color:var(--editor-primary);border-radius:50%;animation:spin .8s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}.error-container{display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;height:100%;min-height:200px;padding:20px;text-align:center}.error-title{font-weight:600;font-size:16px;color:var(--editor-danger);margin-bottom:8px}.error-message{font-size:13px;color:var(--editor-text-muted);max-width:400px;white-space:pre-wrap}:host(:focus){outline:2px solid var(--editor-primary);outline-offset:-2px}input:focus,select:focus,button:focus-visible{outline:2px solid var(--editor-primary);outline-offset:-1px}.context-menu{position:absolute;z-index:100;min-width:160px;background:var(--editor-surface);border:1px solid var(--editor-border);border-radius:var(--editor-radius);box-shadow:0 4px 12px #00000026;padding:4px 0;font-size:13px}.context-menu-header{padding:6px 12px;font-weight:600;font-size:12px;color:var(--editor-text-muted);user-select:none}.context-menu-divider{height:1px;background:var(--editor-border);margin:4px 0}.context-menu-item{padding:6px 12px;cursor:pointer;color:var(--editor-text);user-select:none;transition:background .1s}.context-menu-item:hover{background:var(--editor-bg)}.context-menu-item:active{background:var(--editor-border)}.context-menu-item-disabled{color:var(--editor-text-muted);cursor:default;pointer-events:none}.editor-toast{position:absolute;top:16px;left:50%;transform:translate(-50%);padding:10px 20px;border-radius:var(--editor-radius);font-size:13px;font-family:var(--editor-font);line-height:1.4;z-index:200;max-width:400px;text-align:center;animation:toast-in .25s ease-out,toast-out .25s ease-in forwards;animation-delay:0s,var(--toast-duration, 3.75s);pointer-events:none;box-shadow:0 4px 12px #00000026}.editor-toast-warning{background:#fef3c7;color:#92400e;border:1px solid #f59e0b}.editor-toast-error{background:#fef2f2;color:#991b1b;border:1px solid var(--editor-danger)}.editor-toast-info{background:#eff6ff;color:#1e40af;border:1px solid var(--editor-primary)}@keyframes toast-in{0%{opacity:0;transform:translate(-50%) translateY(-10px)}to{opacity:1;transform:translate(-50%) translateY(0)}}@keyframes toast-out{0%{opacity:1;transform:translate(-50%) translateY(0)}to{opacity:0;transform:translate(-50%) translateY(-10px)}}.editor-modal-overlay{position:absolute;inset:0;background:#0006;z-index:300;display:flex;align-items:center;justify-content:center;animation:modal-overlay-in .2s ease-out}@keyframes modal-overlay-in{0%{opacity:0}to{opacity:1}}.editor-modal{background:var(--editor-surface);border-radius:var(--editor-radius);box-shadow:0 8px 32px #0003;max-width:380px;width:calc(100% - 32px);padding:20px;animation:modal-in .2s ease-out}@keyframes modal-in{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}.editor-modal-title{font-weight:600;font-size:15px;margin-bottom:8px;color:var(--editor-text)}.editor-modal-body{font-size:13px;color:var(--editor-text-muted);margin-bottom:16px;line-height:1.5}.editor-modal-actions{display:flex;justify-content:flex-end;gap:8px}.editor-modal-btn{padding:8px 16px;border-radius:var(--editor-radius-sm);font-size:13px;font-family:var(--editor-font);cursor:pointer;border:1px solid var(--editor-border);background:var(--editor-surface);color:var(--editor-text);transition:background .15s}.editor-modal-btn:hover{background:var(--editor-bg)}.editor-modal-btn-primary{background:var(--editor-primary);color:#fff;border-color:var(--editor-primary)}.editor-modal-btn-primary:hover{background:var(--editor-primary-hover)}.area-validation-error{font-size:11px;color:var(--editor-danger);margin-top:4px}@media(pointer:coarse){.zoom-btn{min-width:44px;min-height:44px}.area-input-text,.area-input-font,.area-input-size{min-height:44px;font-size:16px}.align-btn{min-width:44px;min-height:44px}.area-upload-btn{min-height:48px}}', Q = \"2.0.0\", tt = 768;\nclass et extends HTMLElement {\n constructor() {\n super(), this.resizeObserver = null, this.isReady = !1, this.currentTemplate = null, this.loadingTemplateId = null, this.isMobileLayout = !1, this.subscriptions = [], this.storageUsage = null, this.storageUsageLastRefresh = 0, this.emitChange = N(() => {\n this.dispatchEvent(\n new CustomEvent(\"change\", {\n detail: { design: this.getDesign() },\n bubbles: !0,\n composed: !0\n })\n );\n }, 300), this.shadow = this.attachShadow({ mode: \"open\" });\n }\n static get observedAttributes() {\n return [\"template-id\", \"theme\", \"mode\", \"store-id\", \"api-url\"];\n }\n async connectedCallback() {\n try {\n this.hasAttribute(\"tabindex\") || this.setAttribute(\"tabindex\", \"0\"), this.renderLoading(), await this.initialize();\n } catch (t) {\n this.showError(\"Failed to initialize editor\", t);\n }\n }\n disconnectedCallback() {\n this.cleanup();\n }\n attributeChangedCallback(t, e, i) {\n e !== i && t === \"template-id\" && this.isReady && i && this.loadTemplate(i);\n }\n // ─── Public API ───\n getDesign() {\n if (!this.currentTemplate) throw new Error(\"No design loaded\");\n return {\n templateId: this.currentTemplate.metadata.id,\n engineVersion: Q,\n contents: this.contentManager.toJSON(),\n userData: {}\n };\n }\n setDesign(t) {\n if (t.templateId !== this.currentTemplate?.metadata.id)\n throw new Error(\"Design template ID does not match current template\");\n this.contentManager.fromJSON(t.contents), this.syncEngineContents(), this.stateManager.setState({\n contents: this.contentManager.toJSON(),\n isDirty: !0\n });\n }\n undo() {\n this.stateManager.undo() && this.syncFromState();\n }\n redo() {\n this.stateManager.redo() && this.syncFromState();\n }\n clear() {\n this.contentManager.reset(), this.syncEngineContents(), this.stateManager.setState({\n contents: this.contentManager.toJSON(),\n selectedAreaId: null,\n isDirty: !1\n }), this.engine.setSelectedArea(null), this.inputPanel.setSelectedArea(null), this.engine.fitToView(), this.stateManager.update({\n zoom: this.engine.getZoom(),\n pan: this.engine.getPan()\n });\n }\n selectArea(t) {\n this.handleAreaSelect(t);\n }\n getSelectedAreaId() {\n return this.stateManager.getState().selectedAreaId;\n }\n setAreaContent(t, e) {\n e.type === \"text\" ? this.contentManager.setTextContent(t, e) : this.contentManager.setImageContent(t, e.dataUrl, e.filename), this.syncEngineContents(), this.saveContentState();\n }\n getAreaContent(t) {\n return this.contentManager.getContent(t);\n }\n async finalize() {\n const t = this.engine.checkSafeAreaViolations();\n if (t.length > 0) {\n const s = this.currentTemplate?.areas || [], o = t.map((r) => s.find((d) => d.id === r)?.name || r).join(\", \");\n if (!await this.showConfirmation(\n \"Content outside safe area\",\n `Content in ${o} extends beyond the safe area. It may be trimmed during printing. Continue?`,\n \"Cancel\",\n \"Proceed Anyway\"\n ))\n throw new Error(\"Finalization cancelled by user\");\n }\n const e = this.getDesign(), i = this.getAttribute(\"store-id\") || \"demo-shop\", n = await this.apiClient.finalizeDesign(i, e);\n return this.dispatchEvent(\n new CustomEvent(\"customizer:finalize\", {\n detail: {\n designId: n.designId,\n proofUrl: n.proofUrl,\n templateId: e.templateId,\n designJson: e,\n status: n.status\n },\n bubbles: !0,\n composed: !0\n })\n ), n;\n }\n // ─── Initialization ───\n renderLoading() {\n const t = document.createElement(\"style\");\n t.textContent = T, this.shadow.appendChild(t);\n const e = h(\n \"div\",\n { class: \"loading-container\" },\n h(\"div\", { class: \"loading-spinner\" })\n );\n this.shadow.appendChild(e);\n }\n async initialize() {\n const t = this.getAttribute(\"api-url\") || \"http://localhost:4000/public\";\n this.apiClient = new B(t);\n const e = this.getAttribute(\"template-id\");\n if (!e)\n throw new Error(\"template-id attribute is required\");\n await this.loadTemplate(e), this.isReady = !0, this.dispatchEvent(new CustomEvent(\"ready\", { bubbles: !0, composed: !0 }));\n }\n async loadTemplate(t) {\n if (this.loadingTemplateId !== t) {\n this.loadingTemplateId = t;\n try {\n const e = await this.apiClient.getTemplate(t);\n if (this.loadingTemplateId !== t) return;\n this.currentTemplate = e;\n const i = e.areas || [];\n this.contentManager = new U(i);\n const n = {\n template: e,\n contents: this.contentManager.toJSON(),\n selectedAreaId: null,\n zoom: 1,\n pan: { x: 0, y: 0 },\n isDirty: !1,\n warnings: []\n };\n this.stateManager = new H(n), this.buildUI(e, i), this.engine = new D(this.canvas), this.engine.setArtboard({\n width: e.artboard.width,\n height: e.artboard.height,\n backgroundColor: e.artboard.backgroundColor ?? \"#ffffff\"\n }), this.engine.setAreas(i), this.engine.setContents(this.contentManager.getContents()), e.backgroundImage && this.engine.setBackgroundImage(e.backgroundImage);\n const s = e.artboard.safeArea ?? e.safeArea;\n s && this.engine.setSafeArea(s), this.engine.start(), this.engine.fitToView(), this.stateManager.update({\n zoom: this.engine.getZoom(),\n pan: this.engine.getPan()\n }), this.zoomToolbar.setZoom(this.engine.getZoom()), this.interaction = new Z(\n this.canvas,\n this.engine,\n () => this.contentManager.getContents(),\n () => this.stateManager.getState().selectedAreaId\n ), this.wireInteractionEvents(), this.subscriptions.push(\n this.contentManager.subscribe(() => {\n this.syncEngineContents(), this.inputPanel.setContents(this.contentManager.getContents());\n })\n ), this.keyboard = new j(this), this.setupKeyboardShortcuts(), this.inputPanel.setContents(this.contentManager.getContents());\n const o = this.getAttribute(\"store-id\");\n o && this.apiClient.getStorageUsage(o).then((a) => {\n this.storageUsage = a, a.usagePercent >= 100 ? this.showToast(\"Storage quota exceeded. Upgrade your plan for more storage.\", \"error\") : a.usagePercent >= 80 && this.showToast(`Storage ${a.usagePercent}% full. Consider upgrading your plan.`, \"warning\");\n }).catch(() => {\n }), this.loadingTemplateId = null;\n } catch (e) {\n throw this.loadingTemplateId = null, new Error(`Failed to load template: ${e.message}`);\n }\n }\n }\n buildUI(t, e) {\n this.shadow.innerHTML = \"\";\n const i = document.createElement(\"style\");\n i.textContent = T, this.shadow.appendChild(i), this.container = h(\"div\", { class: \"editor-container\" }), this.zoomToolbar = new Y(), this.subscriptions.push(this.zoomToolbar.on(\"zoom-in\", () => this.handleZoomIn())), this.subscriptions.push(this.zoomToolbar.on(\"zoom-out\", () => this.handleZoomOut())), this.subscriptions.push(this.zoomToolbar.on(\"zoom-fit\", () => this.handleZoomFit()));\n const n = h(\"div\", { class: \"canvas-area\" });\n n.appendChild(this.zoomToolbar.getElement()), this.canvasWrapper = h(\"div\", { class: \"canvas-wrapper\" }), this.canvas = document.createElement(\"canvas\"), this.canvas.className = \"editor-canvas\", this.canvasWrapper.appendChild(this.canvas), n.appendChild(this.canvasWrapper), this.inputPanel = new G(e), this.wireInputPanelEvents();\n const s = h(\"div\", { class: \"editor-main\" });\n s.appendChild(n), s.appendChild(this.inputPanel.getBackdrop()), s.appendChild(this.inputPanel.getElement()), this.container.appendChild(s), this.shadow.appendChild(this.container), this.resizeObserver = new ResizeObserver((o) => {\n for (const a of o)\n a.target === this.canvasWrapper && this.handleCanvasResize(a.contentRect), a.target === this.container && this.handleLayoutResize(a.contentRect);\n }), this.resizeObserver.observe(this.canvasWrapper), this.resizeObserver.observe(this.container);\n }\n // ─── Event Wiring ───\n wireInteractionEvents() {\n this.subscriptions.push(\n this.interaction.on(\"area:select\", ({ areaId: t }) => {\n this.handleAreaSelect(t);\n })\n ), this.subscriptions.push(\n this.interaction.on(\"content:drag\", ({ areaId: t, offset: e }) => {\n this.contentManager.setContentOffset(t, e), this.saveContentState();\n })\n ), this.subscriptions.push(\n this.interaction.on(\"content:scale\", ({ areaId: t, scale: e }) => {\n this.contentManager.setImageScale(t, e), this.saveContentState();\n })\n ), this.subscriptions.push(\n this.interaction.on(\"content:rotate\", ({ areaId: t, rotation: e }) => {\n this.contentManager.setImageRotation(t, e), this.saveContentState();\n })\n ), this.subscriptions.push(\n this.interaction.on(\"zoom\", ({ zoom: t }) => {\n this.engine.setZoom(t);\n const e = this.engine.getCenteredPan(t);\n e && this.engine.setPan(e), this.stateManager.update({ zoom: this.engine.getZoom(), pan: this.engine.getPan() }), this.zoomToolbar.setZoom(this.engine.getZoom());\n })\n ), this.subscriptions.push(\n this.interaction.on(\"pan\", ({ pan: t }) => {\n this.engine.setPan(t), this.stateManager.update({ pan: t });\n })\n ), this.subscriptions.push(\n this.interaction.on(\"cursor\", ({ cursor: t }) => {\n this.canvas.style.cursor = t;\n })\n ), this.subscriptions.push(\n this.interaction.on(\"context-menu\", ({ areaId: t, clientX: e, clientY: i }) => {\n this.handleContextMenu(t, e, i);\n })\n );\n }\n wireInputPanelEvents() {\n this.subscriptions.push(\n this.inputPanel.on(\"text:change\", ({ areaId: t, updates: e }) => {\n this.contentManager.setTextContent(t, e), this.saveContentState();\n })\n ), this.subscriptions.push(\n this.inputPanel.on(\"image:change\", async ({ areaId: t, dataUrl: e, filename: i }) => {\n const n = this.contentManager.getContents();\n let s = 0;\n for (const [a, r] of n)\n r.type === \"image\" && a !== t && s++;\n if (s >= 10) {\n this.showToast(\"Maximum of 10 images per design reached\", \"error\");\n return;\n }\n if (await this.refreshStorageUsage(), this.storageUsage && this.storageUsage.usagePercent >= 100) {\n this.showToast(\"Storage quota exceeded. Upgrade your plan for more storage.\", \"error\");\n return;\n }\n const o = this.currentTemplate?.areas.find((a) => a.id === t);\n if (o && this.currentTemplate) {\n const a = this.currentTemplate.print.targetDpi;\n try {\n const r = new Image(), d = await new Promise((p, g) => {\n r.onload = () => p({ width: r.naturalWidth, height: r.naturalHeight }), r.onerror = () => g(new Error(\"Failed to load image\")), r.src = e;\n }), l = o.location.width / a, c = o.location.height / a, u = _(\n d.width,\n d.height,\n l,\n c,\n a\n );\n if (u.actualDPI < 150) {\n if (!await this.showConfirmation(\n \"Low resolution detected\",\n `This image is ${u.actualDPI} DPI at print size. Print may appear blurry. Recommended: ${a} DPI.`,\n \"Cancel\",\n \"Use Anyway\"\n )) return;\n } else u.actualDPI < a && (this.showToast(\n `Image resolution is ${u.actualDPI} DPI (${a} recommended)`,\n \"warning\"\n ), this.stateManager.update({\n warnings: [\n ...this.stateManager.getState().warnings,\n { type: \"dpi\", message: `${u.actualDPI} DPI`, areaId: t }\n ]\n }));\n } catch {\n }\n }\n if (this.contentManager.setImageContent(t, e, i), this.saveContentState(), this.storageUsage) {\n const a = Math.round(e.length * 0.75);\n this.storageUsage.storageUsed += a, this.storageUsage.usagePercent = this.storageUsage.storageQuota > 0 ? Math.round(this.storageUsage.storageUsed / this.storageUsage.storageQuota * 100) : 0;\n }\n })\n ), this.subscriptions.push(\n this.inputPanel.on(\"validation:error\", ({ message: t }) => {\n this.showToast(t, \"error\");\n })\n ), this.subscriptions.push(\n this.inputPanel.on(\"clear\", ({ areaId: t }) => {\n this.contentManager.clearContent(t), this.saveContentState();\n })\n ), this.subscriptions.push(\n this.inputPanel.on(\"select\", ({ areaId: t }) => {\n this.handleAreaSelect(t);\n })\n ), this.subscriptions.push(\n this.inputPanel.on(\"offset:change\", ({ areaId: t, offset: e }) => {\n this.contentManager.setContentOffset(t, e), this.saveContentState();\n })\n ), this.subscriptions.push(\n this.inputPanel.on(\"scale:change\", ({ areaId: t, scale: e }) => {\n this.contentManager.setImageScale(t, e), this.saveContentState();\n })\n ), this.subscriptions.push(\n this.inputPanel.on(\"rotation:change\", ({ areaId: t, rotation: e }) => {\n this.contentManager.setImageRotation(t, e), this.saveContentState();\n })\n ), this.subscriptions.push(\n this.inputPanel.on(\"dismiss\", () => {\n this.handleAreaSelect(null);\n })\n );\n }\n // ─── Handlers ───\n handleAreaSelect(t, e = !1) {\n this.stateManager.update({ selectedAreaId: t }), this.engine.setSelectedArea(t), this.inputPanel.setSelectedArea(e ? t : null), t && document.activeElement !== this && this.focus(), this.dispatchEvent(\n new CustomEvent(\"area:select\", {\n detail: { areaId: t },\n bubbles: !0,\n composed: !0\n })\n );\n }\n handleContextMenu(t, e, i) {\n this.handleAreaSelect(t, !!t);\n }\n handleZoomIn() {\n const t = this.engine.getZoom(), e = Math.min(t * 1.25, 5), i = this.engine.getCenteredPan(e);\n this.engine.setZoom(e), i && this.engine.setPan(i), this.stateManager.update({ zoom: this.engine.getZoom(), pan: this.engine.getPan() }), this.zoomToolbar.setZoom(this.engine.getZoom());\n }\n handleZoomOut() {\n const t = this.engine.getZoom(), e = Math.max(t * 0.8, 0.1), i = this.engine.getCenteredPan(e);\n this.engine.setZoom(e), i && this.engine.setPan(i), this.stateManager.update({ zoom: this.engine.getZoom(), pan: this.engine.getPan() }), this.zoomToolbar.setZoom(this.engine.getZoom());\n }\n handleZoomFit() {\n this.engine.fitToView(), this.stateManager.update({ zoom: this.engine.getZoom(), pan: this.engine.getPan() }), this.zoomToolbar.setZoom(this.engine.getZoom());\n }\n handleCanvasResize(t) {\n const { width: e, height: i } = t;\n if (e === 0 || i === 0) return;\n const n = window.devicePixelRatio || 1;\n this.canvas.width = e * n, this.canvas.height = i * n, this.canvas.style.width = `${e}px`, this.canvas.style.height = `${i}px`, this.engine && (this.engine.fitToView(), this.stateManager.update({ zoom: this.engine.getZoom(), pan: this.engine.getPan() }), this.zoomToolbar.setZoom(this.engine.getZoom()));\n }\n handleLayoutResize(t) {\n const e = t.width < tt;\n e !== this.isMobileLayout && (this.isMobileLayout = e, this.container.classList.toggle(\"layout-desktop\", !e), this.container.classList.toggle(\"layout-mobile\", e), this.inputPanel.setMobile(e));\n }\n // ─── State Management ───\n async refreshStorageUsage() {\n if (Date.now() - this.storageUsageLastRefresh < 3e4) return;\n const t = this.getAttribute(\"store-id\");\n if (t)\n try {\n this.storageUsage = await this.apiClient.getStorageUsage(t), this.storageUsageLastRefresh = Date.now();\n } catch {\n }\n }\n saveContentState() {\n this.stateManager.setState({\n contents: this.contentManager.toJSON(),\n isDirty: !0\n }), this.engine.checkSafeAreaViolations(), this.emitChange();\n }\n syncEngineContents() {\n this.engine?.setContents(this.contentManager.getContents());\n }\n syncFromState() {\n const t = this.stateManager.getState();\n this.contentManager.setContentsQuiet(t.contents), this.syncEngineContents(), this.inputPanel.setContents(this.contentManager.getContents()), this.engine.setSelectedArea(t.selectedAreaId), this.inputPanel.setSelectedArea(t.selectedAreaId);\n }\n // ─── Keyboard ───\n setupKeyboardShortcuts() {\n const t = V();\n this.keyboard.register({\n key: \"z\",\n [t]: !0,\n handler: () => this.undo()\n }), this.keyboard.register({\n key: \"z\",\n [t]: !0,\n shift: !0,\n handler: () => this.redo()\n }), this.keyboard.register({\n key: \"Escape\",\n handler: () => this.handleAreaSelect(null)\n });\n }\n // ─── Toast & Modal ───\n showToast(t, e = \"info\") {\n const i = h(\"div\", { class: `editor-toast editor-toast-${e}` }, t);\n this.shadow.appendChild(i), setTimeout(() => i.remove(), 4e3);\n }\n showConfirmation(t, e, i = \"Cancel\", n = \"Continue\") {\n return new Promise((s) => {\n const o = h(\"div\", { class: \"editor-modal-overlay\" }), a = h(\"div\", { class: \"editor-modal\" });\n a.appendChild(h(\"div\", { class: \"editor-modal-title\" }, t)), a.appendChild(h(\"div\", { class: \"editor-modal-body\" }, e));\n const r = h(\"div\", { class: \"editor-modal-actions\" }), d = h(\"button\", { class: \"editor-modal-btn\" }, i);\n d.addEventListener(\"click\", () => {\n o.remove(), s(!1);\n });\n const l = h(\"button\", { class: \"editor-modal-btn editor-modal-btn-primary\" }, n);\n l.addEventListener(\"click\", () => {\n o.remove(), s(!0);\n }), r.appendChild(d), r.appendChild(l), a.appendChild(r), o.appendChild(a), o.addEventListener(\"click\", (c) => {\n c.target === o && (o.remove(), s(!1));\n }), this.shadow.appendChild(o);\n });\n }\n // ─── Error / Cleanup ───\n showError(t, e) {\n this.shadow.innerHTML = \"\";\n const i = document.createElement(\"style\");\n i.textContent = T, this.shadow.appendChild(i);\n const n = h(\"div\", { class: \"error-container\" });\n n.appendChild(h(\"div\", { class: \"error-title\" }, t)), n.appendChild(h(\"div\", { class: \"error-message\" }, e?.message ?? \"\")), this.shadow.appendChild(n), this.dispatchEvent(\n new CustomEvent(\"error\", {\n detail: { message: t, error: e },\n bubbles: !0,\n composed: !0\n })\n );\n }\n cleanup() {\n for (const t of this.subscriptions)\n t();\n this.subscriptions = [], this.resizeObserver && (this.resizeObserver.disconnect(), this.resizeObserver = null), this.engine?.destroy(), this.interaction?.destroy(), this.keyboard?.destroy(), this.isReady = !1, this.currentTemplate = null;\n }\n}\ncustomElements.get(\"customizer-editor\") || customElements.define(\"customizer-editor\", et);\nexport {\n et as CustomizerEditor\n};\n//# sourceMappingURL=customizer.esm.js.map\n","/**\n * Vanilla JavaScript SDK for Customizer Editor\n * @packageDocumentation\n */\n\n// Side-effect: registers <customizer-editor> web component.\n// Using namespace import so tsc omits it from .d.ts (value-only usage).\nimport * as _editorModule from '@customizer/editor';\nvoid _editorModule;\nimport type {\n CustomizerOptions,\n CustomizerInstance,\n DesignJSON,\n FinalizeResult,\n CustomizerError,\n CustomizerEditorElement,\n} from '../types';\n\n/**\n * Initialize the customizer editor\n *\n * @param elementOrSelector - DOM element or CSS selector where to mount the editor\n * @param options - Configuration options\n * @returns CustomizerInstance with methods to control the editor\n *\n * @example\n * ```typescript\n * import { initCustomizer } from '@varianta/sdk';\n *\n * const editor = initCustomizer('#editor', {\n * templateId: 'tshirt-001',\n * theme: 'light',\n * onReady: () => console.log('Editor ready!'),\n * onChange: (design) => console.log('Design changed:', design),\n * });\n *\n * // Get current design\n * const design = editor.getDesign();\n *\n * // Finalize design\n * const result = await editor.finalize();\n * ```\n */\nexport function initCustomizer(\n elementOrSelector: HTMLElement | string,\n options: CustomizerOptions\n): CustomizerInstance {\n // Resolve the container element\n const container =\n typeof elementOrSelector === 'string'\n ? document.querySelector<HTMLElement>(elementOrSelector)\n : elementOrSelector;\n\n if (!container) {\n throw new Error(\n `Container not found: ${\n typeof elementOrSelector === 'string'\n ? elementOrSelector\n : 'provided element is null'\n }`\n );\n }\n\n // Create the editor element\n const editorElement = document.createElement('customizer-editor') as unknown as CustomizerEditorElement;\n\n // Set attributes\n editorElement.setAttribute('template-id', options.templateId);\n if (options.theme) {\n editorElement.setAttribute('theme', options.theme);\n }\n if (options.mode) {\n editorElement.setAttribute('mode', options.mode);\n }\n if (options.className) {\n editorElement.classList.add(options.className);\n }\n\n // Apply custom styles if needed\n editorElement.style.width = '100%';\n editorElement.style.height = '100%';\n\n // Event listeners tracking\n const listeners: Array<{ event: string; handler: EventListener }> = [];\n\n const addEventListener = (event: string, handler: EventListener) => {\n editorElement.addEventListener(event, handler);\n listeners.push({ event, handler });\n };\n\n // Mount the editor first\n container.innerHTML = '';\n container.appendChild(editorElement);\n\n // Create the instance API BEFORE setting up event handlers\n const instance: CustomizerInstance = {\n getDesign(): DesignJSON {\n if (typeof editorElement.getDesign !== 'function') {\n throw new Error('Editor not ready: getDesign method not available');\n }\n return editorElement.getDesign();\n },\n\n setDesign(design: DesignJSON): void {\n if (typeof editorElement.setDesign !== 'function') {\n throw new Error('Editor not ready: setDesign method not available');\n }\n editorElement.setDesign(design);\n },\n\n undo(): void {\n if (typeof editorElement.undo !== 'function') {\n throw new Error('Editor not ready: undo method not available');\n }\n editorElement.undo();\n },\n\n redo(): void {\n if (typeof editorElement.redo !== 'function') {\n throw new Error('Editor not ready: redo method not available');\n }\n editorElement.redo();\n },\n\n canUndo(): boolean {\n if (typeof editorElement.canUndo !== 'function') {\n return false;\n }\n return editorElement.canUndo();\n },\n\n canRedo(): boolean {\n if (typeof editorElement.canRedo !== 'function') {\n return false;\n }\n return editorElement.canRedo();\n },\n\n async finalize(): Promise<FinalizeResult> {\n const design = this.getDesign();\n const apiUrl = options.apiUrl || 'https://api.varianta.io';\n\n try {\n const response = await fetch(`${apiUrl}/public/finalize`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n templateId: options.templateId,\n designJson: design,\n }),\n });\n\n if (!response.ok) {\n const error = await response.json().catch(() => ({\n message: 'Finalization failed',\n }));\n throw new Error(error.message || 'Finalization failed');\n }\n\n const body = await response.json();\n let result: FinalizeResult = {\n designId: body.designId,\n status: body.status,\n proofUrl: body.proofUrl ?? null,\n errorMessage: body.errorMessage ?? null,\n };\n\n // Poll until the render completes (or fails)\n const POLL_INTERVAL = 1500;\n const MAX_POLLS = 40; // ~60 s total\n let polls = 0;\n\n while (result.status === 'processing' && polls < MAX_POLLS) {\n await new Promise((r) => setTimeout(r, POLL_INTERVAL));\n polls++;\n\n const statusRes = await fetch(\n `${apiUrl}/public/designs/${result.designId}/status`,\n );\n if (!statusRes.ok) {\n throw new Error('Failed to check design status');\n }\n const statusBody = await statusRes.json();\n result = {\n designId: statusBody.designId,\n status: statusBody.status,\n proofUrl: statusBody.proofUrl ?? null,\n errorMessage: statusBody.errorMessage ?? null,\n };\n }\n\n if (result.status === 'processing') {\n result = { ...result, status: 'failed', errorMessage: 'Render timed out' };\n }\n\n if (options.onFinalize) {\n options.onFinalize(result);\n }\n\n return result;\n } catch (error) {\n const customizerError: CustomizerError = {\n code: 'FINALIZE_ERROR',\n message: error instanceof Error ? error.message : 'Unknown error',\n details: error,\n };\n\n if (options.onError) {\n options.onError(customizerError);\n }\n\n throw error;\n }\n },\n\n addTextLayer(text?: string): void {\n if (typeof editorElement.addTextLayer !== 'function') {\n throw new Error('Editor not ready: addTextLayer method not available');\n }\n editorElement.addTextLayer(text);\n },\n\n async addImageLayer(url: string): Promise<void> {\n if (typeof editorElement.addImageLayer !== 'function') {\n throw new Error('Editor not ready: addImageLayer method not available');\n }\n return editorElement.addImageLayer(url);\n },\n\n removeLayer(layerId: string): void {\n if (typeof editorElement.removeLayer !== 'function') {\n throw new Error('Editor not ready: removeLayer method not available');\n }\n editorElement.removeLayer(layerId);\n },\n\n selectLayer(layerId: string | null): void {\n if (typeof editorElement.selectLayer !== 'function') {\n throw new Error('Editor not ready: selectLayer method not available');\n }\n editorElement.selectLayer(layerId);\n },\n\n getSelectedLayerId(): string | null {\n if (typeof editorElement.getSelectedLayerId !== 'function') {\n return null;\n }\n return editorElement.getSelectedLayerId();\n },\n\n setTheme(theme: 'light' | 'dark'): void {\n editorElement.setAttribute('theme', theme);\n },\n\n setMode(mode: 'edit' | 'preview'): void {\n editorElement.setAttribute('mode', mode);\n },\n\n destroy(): void {\n // Remove all event listeners\n listeners.forEach(({ event, handler }) => {\n editorElement.removeEventListener(event, handler);\n });\n\n // Remove the element from DOM\n if (editorElement.parentNode) {\n editorElement.parentNode.removeChild(editorElement);\n }\n },\n\n getElement(): HTMLElement {\n return editorElement;\n },\n };\n\n // NOW set up event handlers (after instance is fully created)\n if (options.onReady) {\n addEventListener('ready', (() => {\n options.onReady?.(instance);\n }) as EventListener);\n }\n\n if (options.onChange) {\n addEventListener('change', ((e: CustomEvent) => {\n const design = e.detail.design;\n options.onChange?.(design);\n }) as EventListener);\n }\n\n if (options.onLayerSelect) {\n addEventListener('layer:select', ((e: CustomEvent) => {\n options.onLayerSelect?.(e.detail.layerId);\n }) as EventListener);\n }\n\n if (options.onLayerAdd) {\n addEventListener('layer:add', ((e: CustomEvent) => {\n options.onLayerAdd?.(e.detail.layerId);\n }) as EventListener);\n }\n\n if (options.onLayerRemove) {\n addEventListener('layer:remove', ((e: CustomEvent) => {\n options.onLayerRemove?.(e.detail.layerId);\n }) as EventListener);\n }\n\n if (options.onLayerUpdate) {\n addEventListener('layer:update', ((e: CustomEvent) => {\n options.onLayerUpdate?.(e.detail.layerId);\n }) as EventListener);\n }\n\n if (options.onError) {\n addEventListener('error', ((e: CustomEvent) => {\n const error: CustomizerError = e.detail.error;\n options.onError?.(error);\n }) as EventListener);\n }\n\n // Set initial design if provided\n if (options.initialDesign) {\n // Wait for the editor to be ready before setting the design\n editorElement.addEventListener(\n 'ready',\n () => {\n if (options.initialDesign) {\n editorElement.setDesign(options.initialDesign);\n }\n },\n { once: true }\n );\n }\n\n if (options.debug) {\n console.log('[Customizer SDK] Initialized with options:', options);\n console.log('[Customizer SDK] Instance:', instance);\n }\n\n return instance;\n}\n\n/**\n * Re-export types for convenience\n */\nexport type * from '../types';\n","/**\n * React wrapper for Customizer Editor\n * @packageDocumentation\n */\n\nimport {\n useRef,\n useEffect,\n useImperativeHandle,\n forwardRef,\n type CSSProperties,\n} from 'react';\nimport { initCustomizer } from '../vanilla';\nimport type {\n CustomizerOptions,\n CustomizerInstance,\n DesignJSON,\n FinalizeResult,\n CustomizerError,\n} from '../types';\n\n/**\n * Props for the Customizer React component\n */\nexport interface CustomizerProps {\n /**\n * Template ID to load\n */\n templateId: string;\n\n /**\n * API base URL for fetching templates and finalizing designs\n * @default 'https://api.varianta.io'\n */\n apiUrl?: string;\n\n /**\n * Visual theme\n * @default 'light'\n */\n theme?: 'light' | 'dark';\n\n /**\n * Editor mode\n * @default 'edit'\n */\n mode?: 'edit' | 'preview';\n\n /**\n * Enable debug mode with additional logging\n * @default false\n */\n debug?: boolean;\n\n /**\n * Custom CSS class name\n */\n className?: string;\n\n /**\n * Custom inline styles\n */\n style?: CSSProperties;\n\n /**\n * Initial design data to load\n */\n initialDesign?: DesignJSON;\n\n /**\n * Called when the editor is ready\n */\n onReady?: () => void;\n\n /**\n * Called when the design changes\n */\n onChange?: (design: DesignJSON) => void;\n\n /**\n * Called when a layer is selected\n */\n onLayerSelect?: (layerId: string | null) => void;\n\n /**\n * Called when a layer is added\n */\n onLayerAdd?: (layerId: string) => void;\n\n /**\n * Called when a layer is removed\n */\n onLayerRemove?: (layerId: string) => void;\n\n /**\n * Called when a layer is updated\n */\n onLayerUpdate?: (layerId: string) => void;\n\n /**\n * Called when an error occurs\n */\n onError?: (error: CustomizerError) => void;\n\n /**\n * Called when finalization is complete\n */\n onFinalize?: (result: FinalizeResult) => void;\n}\n\n/**\n * Handle type exposed via ref\n */\nexport interface CustomizerHandle extends CustomizerInstance {}\n\n/**\n * Customizer React Component\n *\n * @example\n * ```tsx\n * import { Customizer, CustomizerHandle } from '@varianta/sdk/react';\n * import { useRef } from 'react';\n *\n * function App() {\n * const customizerRef = useRef<CustomizerHandle>(null);\n *\n * const handleFinalize = async () => {\n * if (customizerRef.current) {\n * const result = await customizerRef.current.finalize();\n * console.log('Finalized:', result);\n * }\n * };\n *\n * return (\n * <div style={{ width: '100vw', height: '100vh' }}>\n * <Customizer\n * ref={customizerRef}\n * templateId=\"tshirt-001\"\n * theme=\"light\"\n * onChange={(design) => console.log('Design changed:', design)}\n * onReady={() => console.log('Editor ready!')}\n * />\n * <button onClick={handleFinalize}>Finalize Design</button>\n * </div>\n * );\n * }\n * ```\n */\nexport const Customizer = forwardRef<CustomizerHandle, CustomizerProps>(\n (props, ref) => {\n const {\n templateId,\n apiUrl,\n theme = 'light',\n mode = 'edit',\n debug = false,\n className,\n style,\n initialDesign,\n onReady,\n onChange,\n onLayerSelect,\n onLayerAdd,\n onLayerRemove,\n onLayerUpdate,\n onError,\n onFinalize,\n } = props;\n\n const containerRef = useRef<HTMLDivElement>(null);\n const instanceRef = useRef<CustomizerInstance | null>(null);\n\n // Store latest callbacks in a ref to avoid stale closures\n const callbacksRef = useRef({\n onReady,\n onChange,\n onLayerSelect,\n onLayerAdd,\n onLayerRemove,\n onLayerUpdate,\n onError,\n onFinalize,\n });\n\n // Update callbacks ref whenever they change\n useEffect(() => {\n callbacksRef.current = {\n onReady,\n onChange,\n onLayerSelect,\n onLayerAdd,\n onLayerRemove,\n onLayerUpdate,\n onError,\n onFinalize,\n };\n }, [onReady, onChange, onLayerSelect, onLayerAdd, onLayerRemove, onLayerUpdate, onError, onFinalize]);\n\n // Initialize the editor\n useEffect(() => {\n if (!containerRef.current) return;\n\n const options: CustomizerOptions = {\n templateId,\n apiUrl,\n theme,\n mode,\n debug,\n initialDesign,\n // Use callback refs to always get latest callbacks\n onReady: () => callbacksRef.current.onReady?.(),\n onChange: (design) => callbacksRef.current.onChange?.(design),\n onLayerSelect: (layerId) => callbacksRef.current.onLayerSelect?.(layerId),\n onLayerAdd: (layerId) => callbacksRef.current.onLayerAdd?.(layerId),\n onLayerRemove: (layerId) => callbacksRef.current.onLayerRemove?.(layerId),\n onLayerUpdate: (layerId) => callbacksRef.current.onLayerUpdate?.(layerId),\n onError: (error) => callbacksRef.current.onError?.(error),\n onFinalize: (result) => callbacksRef.current.onFinalize?.(result),\n };\n\n try {\n const instance = initCustomizer(containerRef.current, options);\n instanceRef.current = instance;\n } catch (error) {\n console.error('[Customizer React] Failed to initialize:', error);\n callbacksRef.current.onError?.({\n code: 'INIT_ERROR',\n message: error instanceof Error ? error.message : 'Unknown error',\n details: error,\n });\n }\n\n // Cleanup\n return () => {\n if (instanceRef.current) {\n instanceRef.current.destroy();\n instanceRef.current = null;\n }\n };\n }, [templateId, apiUrl, debug, initialDesign]); // Only re-initialize on structural changes\n\n // Update theme when it changes\n useEffect(() => {\n if (instanceRef.current) {\n instanceRef.current.setTheme(theme);\n }\n }, [theme]);\n\n // Update mode when it changes\n useEffect(() => {\n if (instanceRef.current) {\n instanceRef.current.setMode(mode);\n }\n }, [mode]);\n\n // Expose methods via ref\n useImperativeHandle(\n ref,\n () => {\n // Return API that always uses current instanceRef\n return {\n getDesign: () => {\n if (!instanceRef.current) {\n throw new Error('Editor not initialized');\n }\n return instanceRef.current.getDesign();\n },\n setDesign: (design: DesignJSON) => {\n if (!instanceRef.current) {\n throw new Error('Editor not initialized');\n }\n instanceRef.current.setDesign(design);\n },\n undo: () => {\n if (!instanceRef.current) {\n throw new Error('Editor not initialized');\n }\n instanceRef.current.undo();\n },\n redo: () => {\n if (!instanceRef.current) {\n throw new Error('Editor not initialized');\n }\n instanceRef.current.redo();\n },\n canUndo: () => {\n if (!instanceRef.current) return false;\n return instanceRef.current.canUndo();\n },\n canRedo: () => {\n if (!instanceRef.current) return false;\n return instanceRef.current.canRedo();\n },\n finalize: async () => {\n if (!instanceRef.current) {\n throw new Error('Editor not initialized');\n }\n return instanceRef.current.finalize();\n },\n addTextLayer: (text?: string) => {\n if (!instanceRef.current) {\n throw new Error('Editor not initialized');\n }\n instanceRef.current.addTextLayer(text);\n },\n addImageLayer: async (url: string) => {\n if (!instanceRef.current) {\n throw new Error('Editor not initialized');\n }\n return instanceRef.current.addImageLayer(url);\n },\n removeLayer: (layerId: string) => {\n if (!instanceRef.current) {\n throw new Error('Editor not initialized');\n }\n instanceRef.current.removeLayer(layerId);\n },\n selectLayer: (layerId: string | null) => {\n if (!instanceRef.current) {\n throw new Error('Editor not initialized');\n }\n instanceRef.current.selectLayer(layerId);\n },\n getSelectedLayerId: () => {\n if (!instanceRef.current) return null;\n return instanceRef.current.getSelectedLayerId();\n },\n setTheme: (newTheme: 'light' | 'dark') => {\n if (!instanceRef.current) {\n throw new Error('Editor not initialized');\n }\n instanceRef.current.setTheme(newTheme);\n },\n setMode: (newMode: 'edit' | 'preview') => {\n if (!instanceRef.current) {\n throw new Error('Editor not initialized');\n }\n instanceRef.current.setMode(newMode);\n },\n destroy: () => {\n if (!instanceRef.current) return;\n instanceRef.current.destroy();\n instanceRef.current = null;\n },\n getElement: () => {\n if (!instanceRef.current) {\n throw new Error('Editor not initialized');\n }\n return instanceRef.current.getElement();\n },\n };\n },\n [] // Empty deps is OK - we always read from instanceRef.current\n );\n\n return (\n <div\n ref={containerRef}\n className={className}\n style={{\n width: '100%',\n height: '100%',\n ...style,\n }}\n />\n );\n }\n);\n\nCustomizer.displayName = 'Customizer';\n","/**\n * React hook for controlling the customizer editor\n * @packageDocumentation\n */\n\nimport { useRef, useCallback, useState, useEffect } from 'react';\nimport type { CustomizerHandle } from './Customizer';\nimport type { DesignJSON, FinalizeResult } from '../types';\n\n/**\n * Options for the useCustomizer hook\n */\nexport interface UseCustomizerOptions {\n /**\n * Auto-save design to localStorage\n */\n autoSave?: boolean;\n\n /**\n * localStorage key for auto-save\n * @default 'customizer-design'\n */\n autoSaveKey?: string;\n\n /**\n * Debounce time for auto-save in ms\n * @default 1000\n */\n autoSaveDebounce?: number;\n}\n\n/**\n * Return type for useCustomizer hook\n */\nexport interface UseCustomizerReturn {\n /**\n * Ref to attach to the Customizer component\n */\n customizerRef: React.RefObject<CustomizerHandle | null>;\n\n /**\n * Current design state\n */\n design: DesignJSON | null;\n\n /**\n * Whether undo is available\n */\n canUndo: boolean;\n\n /**\n * Whether redo is available\n */\n canRedo: boolean;\n\n /**\n * Selected layer ID\n */\n selectedLayerId: string | null;\n\n /**\n * Whether finalization is in progress\n */\n isFinalizing: boolean;\n\n /**\n * Finalization result\n */\n finalizeResult: FinalizeResult | null;\n\n /**\n * Get the current design\n */\n getDesign: () => DesignJSON | null;\n\n /**\n * Set a new design\n */\n setDesign: (design: DesignJSON) => void;\n\n /**\n * Undo the last action\n */\n undo: () => void;\n\n /**\n * Redo the last undone action\n */\n redo: () => void;\n\n /**\n * Finalize the design\n */\n finalize: () => Promise<FinalizeResult | null>;\n\n /**\n * Add a text layer\n */\n addTextLayer: (text?: string) => void;\n\n /**\n * Add an image layer\n */\n addImageLayer: (url: string) => Promise<void>;\n\n /**\n * Remove a layer\n */\n removeLayer: (layerId: string) => void;\n\n /**\n * Select a layer\n */\n selectLayer: (layerId: string | null) => void;\n}\n\n/**\n * React hook for controlling the customizer editor\n *\n * @example\n * ```tsx\n * import { Customizer } from '@varianta/sdk/react';\n * import { useCustomizer } from '@varianta/sdk/react';\n *\n * function App() {\n * const {\n * customizerRef,\n * design,\n * canUndo,\n * canRedo,\n * undo,\n * redo,\n * finalize,\n * isFinalizing,\n * } = useCustomizer({ autoSave: true });\n *\n * return (\n * <>\n * <Customizer\n * ref={customizerRef}\n * templateId=\"tshirt-001\"\n * onChange={(d) => console.log('Changed:', d)}\n * />\n * <button onClick={undo} disabled={!canUndo}>Undo</button>\n * <button onClick={redo} disabled={!canRedo}>Redo</button>\n * <button onClick={finalize} disabled={isFinalizing}>\n * {isFinalizing ? 'Finalizing...' : 'Finalize'}\n * </button>\n * </>\n * );\n * }\n * ```\n */\nexport function useCustomizer(\n options: UseCustomizerOptions = {}\n): UseCustomizerReturn {\n const {\n autoSave = false,\n autoSaveKey = 'customizer-design',\n autoSaveDebounce = 1000,\n } = options;\n\n const customizerRef = useRef<CustomizerHandle>(null);\n const [design, setDesign] = useState<DesignJSON | null>(null);\n const [canUndo, setCanUndo] = useState(false);\n const [canRedo, setCanRedo] = useState(false);\n const [selectedLayerId, setSelectedLayerId] = useState<string | null>(null);\n const [isFinalizing, setIsFinalizing] = useState(false);\n const [finalizeResult, setFinalizeResult] = useState<FinalizeResult | null>(\n null\n );\n\n const autoSaveTimeoutRef = useRef<NodeJS.Timeout | undefined>(undefined);\n\n // Auto-save to localStorage\n useEffect(() => {\n if (!autoSave || !design) return;\n\n // Clear existing timeout\n if (autoSaveTimeoutRef.current) {\n clearTimeout(autoSaveTimeoutRef.current);\n }\n\n // Set new timeout\n autoSaveTimeoutRef.current = setTimeout(() => {\n try {\n localStorage.setItem(autoSaveKey, JSON.stringify(design));\n } catch (error) {\n console.error('[useCustomizer] Auto-save failed:', error);\n }\n }, autoSaveDebounce);\n\n return () => {\n if (autoSaveTimeoutRef.current) {\n clearTimeout(autoSaveTimeoutRef.current);\n }\n };\n }, [design, autoSave, autoSaveKey, autoSaveDebounce]);\n\n const getDesign = useCallback(() => {\n if (!customizerRef.current) return null;\n try {\n return customizerRef.current.getDesign();\n } catch (error) {\n console.error('[useCustomizer] getDesign failed:', error);\n return null;\n }\n }, []);\n\n const setDesignCallback = useCallback((newDesign: DesignJSON) => {\n if (!customizerRef.current) return;\n try {\n customizerRef.current.setDesign(newDesign);\n setDesign(newDesign);\n } catch (error) {\n console.error('[useCustomizer] setDesign failed:', error);\n }\n }, []);\n\n const undo = useCallback(() => {\n if (!customizerRef.current) return;\n try {\n customizerRef.current.undo();\n setCanUndo(customizerRef.current.canUndo());\n setCanRedo(customizerRef.current.canRedo());\n } catch (error) {\n console.error('[useCustomizer] undo failed:', error);\n }\n }, []);\n\n const redo = useCallback(() => {\n if (!customizerRef.current) return;\n try {\n customizerRef.current.redo();\n setCanUndo(customizerRef.current.canUndo());\n setCanRedo(customizerRef.current.canRedo());\n } catch (error) {\n console.error('[useCustomizer] redo failed:', error);\n }\n }, []);\n\n const finalize = useCallback(async () => {\n if (!customizerRef.current || isFinalizing) return null;\n\n setIsFinalizing(true);\n try {\n const result = await customizerRef.current.finalize();\n setFinalizeResult(result);\n return result;\n } catch (error) {\n console.error('[useCustomizer] finalize failed:', error);\n return null;\n } finally {\n setIsFinalizing(false);\n }\n }, [isFinalizing]);\n\n const addTextLayer = useCallback((text?: string) => {\n if (!customizerRef.current) return;\n try {\n customizerRef.current.addTextLayer(text);\n } catch (error) {\n console.error('[useCustomizer] addTextLayer failed:', error);\n }\n }, []);\n\n const addImageLayer = useCallback(async (url: string) => {\n if (!customizerRef.current) return;\n try {\n await customizerRef.current.addImageLayer(url);\n } catch (error) {\n console.error('[useCustomizer] addImageLayer failed:', error);\n }\n }, []);\n\n const removeLayer = useCallback((layerId: string) => {\n if (!customizerRef.current) return;\n try {\n customizerRef.current.removeLayer(layerId);\n } catch (error) {\n console.error('[useCustomizer] removeLayer failed:', error);\n }\n }, []);\n\n const selectLayer = useCallback((layerId: string | null) => {\n if (!customizerRef.current) return;\n try {\n customizerRef.current.selectLayer(layerId);\n setSelectedLayerId(layerId);\n } catch (error) {\n console.error('[useCustomizer] selectLayer failed:', error);\n }\n }, []);\n\n return {\n customizerRef,\n design,\n canUndo,\n canRedo,\n selectedLayerId,\n isFinalizing,\n finalizeResult,\n getDesign,\n setDesign: setDesignCallback,\n undo,\n redo,\n finalize,\n addTextLayer,\n addImageLayer,\n removeLayer,\n selectLayer,\n };\n}\n"],"names":["D","t","e","s","o","a","r","c","p","g","m","b","y","w","v","x","C","E","k","P","u","L","R","M","f","S","z","O","H","U","I","F","Z","B","n","h","N","Y","W","X","A","$","q","G","j","J","V","K","_","T","Q","tt","et","d","initCustomizer","elementOrSelector","options","container","editorElement","listeners","addEventListener","event","handler","instance","design","apiUrl","response","error","body","result","POLL_INTERVAL","MAX_POLLS","polls","statusRes","statusBody","customizerError","text","url","layerId","theme","mode","Customizer","forwardRef","props","ref","templateId","debug","className","style","initialDesign","onReady","onChange","onLayerSelect","onLayerAdd","onLayerRemove","onLayerUpdate","onError","onFinalize","containerRef","useRef","instanceRef","callbacksRef","useEffect","useImperativeHandle","newTheme","newMode","jsx","useCustomizer","autoSave","autoSaveKey","autoSaveDebounce","customizerRef","setDesign","useState","canUndo","setCanUndo","canRedo","setCanRedo","selectedLayerId","setSelectedLayerId","isFinalizing","setIsFinalizing","finalizeResult","setFinalizeResult","autoSaveTimeoutRef","getDesign","useCallback","setDesignCallback","newDesign","undo","redo","finalize","addTextLayer","addImageLayer","removeLayer","selectLayer"],"mappings":"wIAAA,MAAMA,CAAE,CACN,YAAYC,EAAG,CACb,KAAK,iBAAmB,KAAM,KAAK,YAAc,GAAI,KAAK,MAAQ,CAAA,EAAI,KAAK,SAA2B,IAAI,IAAO,KAAK,SAAW,KAAM,KAAK,eAAiB,KAAM,KAAK,aAA+B,IAAI,IAAO,KAAK,cAAgC,IAAI,IAAO,KAAK,KAAO,EAAG,KAAK,IAAM,CAAE,EAAG,EAAG,EAAG,CAAC,EAAI,KAAK,eAAiB,KAAM,KAAK,cAAgB,KAAM,KAAK,eAAiC,IAAI,IAAO,KAAK,SAAW,KAAM,KAAK,mBAAqC,IAAI,IAAO,KAAK,gBAAkB,GAAI,KAAK,qBAAuB,GAAI,KAAK,WAAa,IAAM,CAChjB,GAAI,CACF,KAAK,cAAgB,KAAK,OAAM,EAAI,KAAK,YAAc,GAAI,KAAK,KAAK,SAAU,MAAM,EACvF,OAAS,EAAG,CACV,QAAQ,MAAM,wBAAyB,CAAC,CAC1C,CACA,KAAK,iBAAmB,sBAAsB,KAAK,UAAU,CAC/D,EAAG,KAAK,OAASA,EACjB,MAAMC,EAAID,EAAE,WAAW,IAAI,EAC3B,GAAI,CAACC,EACH,MAAM,IAAI,MAAM,sCAAsC,EACxD,KAAK,IAAMA,CACb,CAIA,OAAQ,CACN,KAAK,mBAAqB,MAAQ,KAAK,WAAU,CACnD,CAIA,MAAO,CACL,KAAK,mBAAqB,OAAS,qBAAqB,KAAK,gBAAgB,EAAG,KAAK,iBAAmB,KAC1G,CAIA,YAAYD,EAAG,CACb,KAAK,SAAWA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AAalD,GAAkB,CAClD,GAAKmC,EAAc,QACnB,GAAI,CACFA,EAAc,QAAQ,aAAanC,CAAI,CACzC,OAAST,EAAO,CACd,QAAQ,MAAM,uCAAwCA,CAAK,CAC7D,CACF,EAAG,CAAA,CAAE,EAECkE,EAAgBP,cAAY,MAAOjD,GAAgB,CACvD,GAAKkC,EAAc,QACnB,GAAI,CACF,MAAMA,EAAc,QAAQ,cAAclC,CAAG,CAC/C,OAASV,EAAO,CACd,QAAQ,MAAM,wCAAyCA,CAAK,CAC9D,CACF,EAAG,CAAA,CAAE,EAECmE,EAAcR,cAAahD,GAAoB,CACnD,GAAKiC,EAAc,QACnB,GAAI,CACFA,EAAc,QAAQ,YAAYjC,CAAO,CAC3C,OAASX,EAAO,CACd,QAAQ,MAAM,sCAAuCA,CAAK,CAC5D,CACF,EAAG,CAAA,CAAE,EAECoE,EAAcT,cAAahD,GAA2B,CAC1D,GAAKiC,EAAc,QACnB,GAAI,CACFA,EAAc,QAAQ,YAAYjC,CAAO,EACzCyC,EAAmBzC,CAAO,CAC5B,OAASX,EAAO,CACd,QAAQ,MAAM,sCAAuCA,CAAK,CAC5D,CACF,EAAG,CAAA,CAAE,EAEL,MAAO,CACL,cAAA4C,EACA,OAAA/C,EACA,QAAAkD,EACA,QAAAE,EACA,gBAAAE,EACA,aAAAE,EACA,eAAAE,EACA,UAAAG,EACA,UAAWE,EACX,KAAAE,EACA,KAAAC,EACA,SAAAC,EACA,aAAAC,EACA,cAAAC,EACA,YAAAC,EACA,YAAAC,CAAA,CAEJ"}
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../../editor/dist/customizer.esm.js","../src/vanilla/index.ts"],"sourcesContent":["class N {\n constructor(t) {\n this.animationFrameId = null, this.needsRender = !0, this.areas = [], this.contents = /* @__PURE__ */ new Map(), this.artboard = null, this.bgImageElement = null, this.loadedImages = /* @__PURE__ */ new Map(), this.loadingImages = /* @__PURE__ */ new Set(), this.zoom = 1, this.pan = { x: 0, y: 0 }, this.selectedAreaId = null, this.hoveredHandle = null, this.eventListeners = /* @__PURE__ */ new Map(), this.safeArea = null, this.safeAreaViolations = /* @__PURE__ */ new Set(), this.showAreaBorders = !0, this.areaSelectionEnabled = !0, this.renderLoop = () => {\n try {\n this.needsRender && (this.render(), this.needsRender = !1, this.emit(\"render\", void 0));\n } catch (i) {\n console.error(\"Error in render loop:\", i);\n }\n this.animationFrameId = requestAnimationFrame(this.renderLoop);\n }, this.canvas = t;\n const e = t.getContext(\"2d\");\n if (!e)\n throw new Error(\"Failed to get 2D context from canvas\");\n this.ctx = e;\n }\n /**\n * Start the render loop\n */\n start() {\n this.animationFrameId === null && this.renderLoop();\n }\n /**\n * Stop the render loop\n */\n stop() {\n this.animationFrameId !== null && (cancelAnimationFrame(this.animationFrameId), this.animationFrameId = null);\n }\n /**\n * Set artboard configuration\n */\n setArtboard(t) {\n this.artboard = t, this.requestRender();\n }\n /**\n * Get artboard configuration\n */\n getArtboard() {\n return this.artboard;\n }\n /**\n * Set areas to render\n */\n setAreas(t) {\n this.areas = [...t].sort((e, i) => e.zIndex - i.zIndex), this.requestRender();\n }\n /**\n * Get areas\n */\n getAreas() {\n return this.areas;\n }\n /**\n * Set area contents\n */\n setContents(t) {\n this.contents = t, this.loadContentImages(), this.requestRender();\n }\n /**\n * Get area contents\n */\n getContents() {\n return this.contents;\n }\n /**\n * Update content for a single area\n */\n updateContent(t, e) {\n this.contents.set(t, e), e.type === \"image\" && this.loadContentImages(), this.requestRender(), this.emit(\"content:change\", { areaId: t, content: e });\n }\n /**\n * Remove content for an area\n */\n removeContent(t) {\n this.contents.delete(t), this.loadedImages.delete(t), this.requestRender();\n }\n /**\n * Set background image\n */\n setBackgroundImage(t) {\n if (this.backgroundImage = t, t?.url && t.url !== this.bgImageElement?.src) {\n const e = new Image();\n e.crossOrigin = \"anonymous\", e.onload = () => {\n this.bgImageElement = e, this.requestRender();\n }, e.onerror = () => {\n this.bgImageElement = null, console.error(\"Failed to load background image:\", t.url), this.requestRender();\n }, e.src = t.url;\n } else t?.url || (this.bgImageElement = null);\n this.requestRender();\n }\n /**\n * Set zoom level\n */\n setZoom(t) {\n this.zoom = Math.max(0.1, Math.min(5, t)), this.requestRender();\n }\n /**\n * Set pan offset\n */\n setPan(t) {\n this.pan = t, this.requestRender();\n }\n /**\n * Get zoom level\n */\n getZoom() {\n return this.zoom;\n }\n /**\n * Get pan offset\n */\n getPan() {\n return this.pan;\n }\n /**\n * Set whether area borders are shown\n */\n setShowAreaBorders(t) {\n this.showAreaBorders = t, this.requestRender();\n }\n /**\n * Set whether area selection is enabled\n */\n setAreaSelectionEnabled(t) {\n this.areaSelectionEnabled = t;\n }\n /**\n * Calculate the pan offset needed to center the artboard at a given zoom level\n */\n getCenteredPan(t) {\n if (!this.artboard)\n return null;\n const { width: e, height: i } = this.artboard, s = window.devicePixelRatio || 1, n = this.canvas.width / s, a = this.canvas.height / s;\n return {\n x: (n / t - e) / 2,\n y: (a / t - i) / 2\n };\n }\n /**\n * Request a render on the next frame\n */\n requestRender() {\n this.needsRender = !0;\n }\n /**\n * Fit view to show the entire artboard\n */\n fitToView() {\n if (!this.artboard)\n return;\n const t = 0, { width: e, height: i } = this.artboard, s = window.devicePixelRatio || 1, n = this.canvas.width / s - t * 2, a = this.canvas.height / s - t * 2;\n if (n <= 0 || a <= 0)\n return;\n const o = n / e, r = a / i, l = Math.min(o, r), d = this.canvas.width / s, c = this.canvas.height / s, u = (d / l - e) / 2, p = (c / l - i) / 2;\n this.zoom = l, this.pan = { x: u, y: p }, this.requestRender();\n }\n /**\n * Set the selected area\n */\n setSelectedArea(t) {\n this.selectedAreaId !== t && (this.selectedAreaId = t, this.requestRender(), this.emit(\"area:select\", { areaId: t }));\n }\n /**\n * Get the selected area ID\n */\n getSelectedArea() {\n return this.selectedAreaId;\n }\n /**\n * Set the hovered handle for highlighting\n */\n setHoveredHandle(t) {\n this.hoveredHandle !== t && (this.hoveredHandle = t, this.requestRender());\n }\n /**\n * Get the currently hovered handle\n */\n getHoveredHandle() {\n return this.hoveredHandle;\n }\n /**\n * Convert screen coordinates to canvas coordinates\n */\n screenToCanvas(t, e) {\n const i = window.devicePixelRatio || 1, s = t / i, n = e / i, a = s / this.zoom - this.pan.x, o = n / this.zoom - this.pan.y;\n return { x: a, y: o };\n }\n /**\n * Get content bounds for an area (in artboard coordinates)\n */\n getContentBounds(t) {\n const e = this.areas.find((l) => l.id === t);\n if (!e)\n return null;\n const i = this.contents.get(t);\n if (!i)\n return null;\n const { location: s } = e, { x: n, y: a, width: o, height: r } = s;\n if (i.type === \"text\") {\n const l = i.offset || { x: 0, y: 0 }, d = i.scale ?? 1, c = i.rotation ?? 0, u = o * d, p = r * d, g = n + o / 2 + l.x, m = a + r / 2 + l.y;\n return {\n x: g - u / 2,\n y: m - p / 2,\n width: u,\n height: p,\n rotation: c,\n centerX: g,\n centerY: m\n };\n } else if (i.type === \"image\") {\n const l = this.loadedImages.get(t);\n if (!l)\n return null;\n const d = i.offset || { x: 0, y: 0 }, c = i.scale ?? 1, u = i.rotation ?? 0, p = l.naturalWidth / l.naturalHeight, g = o / r;\n let m, b;\n p > g ? (m = o, b = o / p) : (b = r, m = r * p);\n const y = m * c, w = b * c, v = n + o / 2 + d.x, x = a + r / 2 + d.y;\n return {\n x: v - y / 2,\n y: x - w / 2,\n width: y,\n height: w,\n rotation: u,\n centerX: v,\n centerY: x\n };\n }\n return null;\n }\n /**\n * Hit test content at given canvas coordinates\n * Returns area ID if content was hit, null otherwise\n */\n hitTestContent(t, e) {\n if (!this.areaSelectionEnabled)\n return null;\n for (let i = this.areas.length - 1; i >= 0; i--) {\n const s = this.areas[i], n = this.getContentBounds(s.id);\n if (n && this.isPointInBounds(t, e, n))\n return s.id;\n }\n return null;\n }\n /**\n * Hit test area at given canvas coordinates (ignoring content)\n * Returns area ID if point is inside area bounds\n */\n hitTestArea(t, e) {\n if (!this.areaSelectionEnabled)\n return null;\n for (let i = this.areas.length - 1; i >= 0; i--) {\n const s = this.areas[i], { x: n, y: a, width: o, height: r } = s.location;\n if (t >= n && t <= n + o && e >= a && e <= a + r)\n return s.id;\n }\n return null;\n }\n /**\n * Test if a point is inside rotated bounds\n */\n isPointInBounds(t, e, i) {\n const { centerX: s, centerY: n, width: a, height: o, rotation: r } = i, l = -r * Math.PI / 180, d = Math.cos(l), c = Math.sin(l), u = t - s, p = e - n, g = u * d - p * c, m = u * c + p * d;\n return g >= -a / 2 && g <= a / 2 && m >= -o / 2 && m <= o / 2;\n }\n /**\n * Get handle positions for the selected content\n */\n getContentHandlePositions(t) {\n const e = this.areas.find((v) => v.id === t);\n if (!e)\n return null;\n const i = this.contents.get(t);\n if (!i)\n return null;\n const s = this.getContentBounds(t);\n if (!s)\n return null;\n const { centerX: n, centerY: a, width: o, height: r, rotation: l } = s, d = 6 / this.zoom, c = 30 / this.zoom, u = l * Math.PI / 180, p = Math.cos(u), g = Math.sin(u), m = (v, x) => ({\n x: n + v * p - x * g,\n y: a + v * g + x * p\n }), b = [];\n if (i.type === \"image\" && e.imageOptions?.allowScaling || i.type === \"text\" && e.textOptions?.allowScaling) {\n const v = o / 2, x = r / 2, C = m(-v, -x);\n b.push({ type: \"nw\", ...C, radius: d });\n const S = m(v, -x);\n b.push({ type: \"ne\", ...S, radius: d });\n const z = m(v, x);\n b.push({ type: \"se\", ...z, radius: d });\n const T = m(-v, x);\n b.push({ type: \"sw\", ...T, radius: d });\n }\n if (i.type === \"image\" && e.imageOptions?.allowRotation || i.type === \"text\" && e.textOptions?.allowRotation) {\n const v = m(0, -r / 2 - c);\n b.push({ type: \"rotate\", ...v, radius: d });\n }\n return b;\n }\n /**\n * Hit test handles at given canvas coordinates\n */\n hitTestHandle(t, e, i) {\n const s = this.getContentHandlePositions(i);\n if (!s)\n return null;\n for (const n of s) {\n const a = t - n.x, o = e - n.y;\n if (Math.sqrt(a * a + o * o) <= n.radius * 2)\n return n.type;\n }\n return null;\n }\n /**\n * Check if positioning is allowed for an area\n */\n isPositioningAllowed(t) {\n const e = this.areas.find((s) => s.id === t);\n if (!e)\n return !1;\n const i = this.contents.get(t);\n return i ? i.type === \"text\" ? e.textOptions?.allowPositioning ?? !1 : e.imageOptions?.allowPositioning ?? !1 : !1;\n }\n /**\n * Get area location (for constraint calculations)\n */\n getAreaLocation(t) {\n const e = this.areas.find((i) => i.id === t);\n return e ? e.location : null;\n }\n /**\n * Get area by ID\n */\n getArea(t) {\n return this.areas.find((e) => e.id === t);\n }\n /**\n * Set safe area margins for content safety guides\n */\n setSafeArea(t) {\n this.safeArea = t ?? null, this.requestRender();\n }\n /**\n * Check if any area content extends beyond the safe area bounds.\n * Returns array of violating area IDs.\n */\n checkSafeAreaViolations() {\n if (!this.safeArea || !this.artboard)\n return [];\n const t = [], { top: e, right: i, bottom: s, left: n } = this.safeArea, a = n, o = e, r = this.artboard.width - i, l = this.artboard.height - s;\n for (const d of this.areas) {\n if (!this.contents.get(d.id))\n continue;\n const u = this.getContentBounds(d.id);\n if (!u)\n continue;\n const { centerX: p, centerY: g, width: m, height: b, rotation: y } = u, w = y * Math.PI / 180, v = Math.abs(Math.cos(w)), x = Math.abs(Math.sin(w)), C = m * v + b * x, S = m * x + b * v, z = p - C / 2, T = g - S / 2, D = p + C / 2, O = g + S / 2;\n (z < a || T < o || D > r || O > l) && t.push(d.id);\n }\n return this.safeAreaViolations = new Set(t), this.requestRender(), t;\n }\n /**\n * Add event listener\n */\n on(t, e) {\n return this.eventListeners.has(t) || this.eventListeners.set(t, /* @__PURE__ */ new Set()), this.eventListeners.get(t).add(e), () => {\n this.eventListeners.get(t)?.delete(e);\n };\n }\n /**\n * Emit event\n */\n emit(t, e) {\n const i = this.eventListeners.get(t);\n if (i)\n for (const s of i)\n s(e);\n }\n /**\n * Export to PNG at full resolution\n */\n async exportToPNG() {\n if (!this.artboard)\n throw new Error(\"No artboard configured\");\n const { width: t, height: e, backgroundColor: i } = this.artboard, s = document.createElement(\"canvas\");\n s.width = t, s.height = e;\n const n = s.getContext(\"2d\");\n if (!n)\n throw new Error(\"Failed to get 2D context for export\");\n n.fillStyle = i, n.fillRect(0, 0, t, e), this.backgroundImage?.position === \"behind\" && this.bgImageElement && this.drawBackgroundImageOnContext(n, t, e);\n for (const a of this.areas)\n this.drawAreaContentOnContext(n, a);\n return this.backgroundImage?.position === \"overlay\" && this.bgImageElement && this.drawBackgroundImageOnContext(n, t, e), new Promise((a, o) => {\n s.toBlob((r) => {\n r ? a(r) : o(new Error(\"Failed to create PNG blob\"));\n }, \"image/png\", 1);\n });\n }\n /**\n * Load images from content data URLs\n */\n loadContentImages() {\n for (const [t, e] of this.contents)\n if (e.type === \"image\" && !this.loadedImages.has(t) && !this.loadingImages.has(t)) {\n this.loadingImages.add(t);\n const i = new Image();\n i.onload = () => {\n this.loadedImages.set(t, i), this.loadingImages.delete(t), this.requestRender();\n }, i.onerror = () => {\n this.loadingImages.delete(t), console.error(\"Failed to load image for area:\", t);\n }, i.src = e.dataUrl;\n }\n for (const t of this.loadedImages.keys()) {\n const e = this.contents.get(t);\n (!e || e.type !== \"image\") && this.loadedImages.delete(t);\n }\n }\n /**\n * Render the canvas\n */\n render() {\n const { ctx: t, canvas: e } = this;\n if (t.fillStyle = \"#f3f4f6\", t.fillRect(0, 0, e.width, e.height), !this.artboard)\n return;\n t.save();\n const i = window.devicePixelRatio || 1;\n t.scale(i, i), t.scale(this.zoom, this.zoom), t.translate(this.pan.x, this.pan.y);\n const { width: s, height: n, backgroundColor: a } = this.artboard;\n t.fillStyle = a, t.fillRect(0, 0, s, n), t.strokeStyle = \"#d1d5db\", t.lineWidth = 1 / this.zoom, t.strokeRect(0, 0, s, n), this.backgroundImage?.position === \"behind\" && this.renderBackgroundImage();\n for (const o of this.areas)\n this.renderAreaWithContent(o);\n this.backgroundImage?.position === \"overlay\" && this.renderBackgroundImage(), this.renderSafeAreaGuide();\n for (const o of this.safeAreaViolations) {\n const r = this.areas.find((p) => p.id === o);\n if (!r)\n continue;\n const { x: l, y: d, width: c, height: u } = r.location;\n t.save(), t.fillStyle = \"rgba(239, 68, 68, 0.15)\", t.fillRect(l, d, c, u), t.restore();\n }\n this.selectedAreaId && this.renderSelectionOverlay(this.selectedAreaId), t.restore();\n }\n /**\n * Render selection overlay with handles\n */\n renderSelectionOverlay(t) {\n const e = this.getContentBounds(t);\n if (!e) {\n const d = this.areas.find((b) => b.id === t);\n if (!d)\n return;\n const { ctx: c } = this, { x: u, y: p, width: g, height: m } = d.location;\n c.save(), c.strokeStyle = \"#3b82f6\", c.lineWidth = 2 / this.zoom, c.setLineDash([]), c.strokeRect(u, p, g, m), c.restore();\n return;\n }\n const { ctx: i } = this, { centerX: s, centerY: n, width: a, height: o, rotation: r } = e;\n i.save(), i.translate(s, n), i.rotate(r * Math.PI / 180), i.strokeStyle = \"#3b82f6\", i.lineWidth = 2 / this.zoom, i.setLineDash([]), i.strokeRect(-a / 2, -o / 2, a, o), i.restore();\n const l = this.getContentHandlePositions(t);\n if (l)\n for (const d of l) {\n i.save();\n const c = this.hoveredHandle === d.type, u = c ? \"#dbeafe\" : \"#ffffff\", p = c ? \"#2563eb\" : \"#3b82f6\";\n if (d.type === \"rotate\") {\n const g = this.getRotatedPoint(s, n - o / 2, s, n, r);\n i.beginPath(), i.strokeStyle = p, i.lineWidth = 1 / this.zoom, i.setLineDash([4 / this.zoom, 4 / this.zoom]), i.moveTo(g.x, g.y), i.lineTo(d.x, d.y), i.stroke(), i.setLineDash([]), i.beginPath(), i.fillStyle = u, i.strokeStyle = p, i.lineWidth = 2 / this.zoom, i.arc(d.x, d.y, d.radius, 0, Math.PI * 2), i.fill(), i.stroke(), i.beginPath(), i.strokeStyle = p, i.lineWidth = 1.5 / this.zoom, i.arc(d.x, d.y, d.radius * 0.5, -Math.PI * 0.8, Math.PI * 0.5), i.stroke();\n } else\n i.fillStyle = u, i.strokeStyle = p, i.lineWidth = 2 / this.zoom, i.fillRect(d.x - d.radius, d.y - d.radius, d.radius * 2, d.radius * 2), i.strokeRect(d.x - d.radius, d.y - d.radius, d.radius * 2, d.radius * 2);\n i.restore();\n }\n }\n /**\n * Rotate a point around a center\n */\n getRotatedPoint(t, e, i, s, n) {\n const a = n * Math.PI / 180, o = Math.cos(a), r = Math.sin(a), l = t - i, d = e - s;\n return {\n x: i + l * o - d * r,\n y: s + l * r + d * o\n };\n }\n /**\n * Render background image\n */\n renderBackgroundImage() {\n if (!this.bgImageElement || !this.artboard || !this.backgroundImage)\n return;\n const { ctx: t } = this, { opacity: e } = this.backgroundImage, { width: i, height: s } = this.artboard;\n t.save(), t.globalAlpha = e;\n const n = this.bgImageElement.naturalWidth / this.bgImageElement.naturalHeight, a = i / s;\n let o, r, l, d;\n n > a ? (r = s, o = s * n, l = (i - o) / 2, d = 0) : (o = i, r = i / n, l = 0, d = (s - r) / 2), t.drawImage(this.bgImageElement, l, d, o, r), t.restore();\n }\n /**\n * Render safe area guide as dashed green rectangle\n */\n renderSafeAreaGuide() {\n if (!this.safeArea || !this.artboard)\n return;\n const { ctx: t } = this, { top: e, right: i, bottom: s, left: n } = this.safeArea, a = n, o = e, r = this.artboard.width - n - i, l = this.artboard.height - e - s;\n r <= 0 || l <= 0 || (t.save(), t.strokeStyle = \"#22c55e\", t.lineWidth = 1 / this.zoom, t.setLineDash([6 / this.zoom, 4 / this.zoom]), t.strokeRect(a, o, r, l), t.setLineDash([]), t.restore());\n }\n /**\n * Render an area with its content\n */\n renderAreaWithContent(t) {\n const { ctx: e } = this, { location: i, backgroundColor: s } = t, { x: n, y: a, width: o, height: r } = i;\n s && (e.fillStyle = s, e.fillRect(n, a, o, r));\n const l = this.contents.get(t.id);\n l && (l.type === \"text\" ? this.renderTextContent(t, l) : l.type === \"image\" && this.renderImageContent(t, l)), this.showAreaBorders && t.showBorder && (e.save(), e.strokeStyle = t.borderColor || \"#3b82f6\", e.lineWidth = 1 / this.zoom, e.setLineDash([4 / this.zoom, 4 / this.zoom]), e.strokeRect(n, a, o, r), e.setLineDash([]), e.restore());\n }\n /**\n * Render text content in an area\n */\n renderTextContent(t, e) {\n if (!e.text.trim())\n return;\n const { ctx: i } = this, { location: s } = t, { x: n, y: a, width: o, height: r } = s, l = e.offset || { x: 0, y: 0 }, d = e.scale ?? 1, c = e.rotation ?? 0, u = n + o / 2 + l.x, p = a + r / 2 + l.y;\n i.save(), i.beginPath(), i.rect(n, a, o, r), i.clip(), i.translate(u, p), i.rotate(c * Math.PI / 180), i.scale(d, d), i.font = `${e.size}px ${e.font}, sans-serif`, i.fillStyle = e.color, i.textBaseline = \"middle\";\n let g;\n switch (e.align) {\n case \"left\":\n i.textAlign = \"left\", g = -o / 2 + 10;\n break;\n case \"right\":\n i.textAlign = \"right\", g = o / 2 - 10;\n break;\n case \"center\":\n default:\n i.textAlign = \"center\", g = 0;\n break;\n }\n i.fillText(e.text, g, 0), i.restore();\n }\n /**\n * Render image content in an area\n */\n renderImageContent(t, e) {\n const i = this.loadedImages.get(t.id);\n if (!i)\n return;\n const { ctx: s } = this, { location: n } = t, { x: a, y: o, width: r, height: l } = n, d = e.offset || { x: 0, y: 0 }, c = e.scale ?? 1, u = e.rotation ?? 0;\n s.save(), s.beginPath(), s.rect(a, o, r, l), s.clip();\n const p = i.naturalWidth / i.naturalHeight, g = r / l;\n let m, b;\n p > g ? (m = r, b = r / p) : (b = l, m = l * p);\n const y = m * c, w = b * c, v = a + r / 2 + d.x, x = o + l / 2 + d.y;\n s.translate(v, x), s.rotate(u * Math.PI / 180), s.drawImage(i, -y / 2, -w / 2, y, w), s.restore();\n }\n /**\n * Draw background image on a specific context (for export)\n */\n drawBackgroundImageOnContext(t, e, i) {\n if (!this.bgImageElement || !this.backgroundImage)\n return;\n const { opacity: s } = this.backgroundImage;\n t.save(), t.globalAlpha = s;\n const n = this.bgImageElement.naturalWidth / this.bgImageElement.naturalHeight, a = e / i;\n let o, r, l, d;\n n > a ? (r = i, o = i * n, l = (e - o) / 2, d = 0) : (o = e, r = e / n, l = 0, d = (i - r) / 2), t.drawImage(this.bgImageElement, l, d, o, r), t.restore();\n }\n /**\n * Draw area content on a specific context (for export)\n */\n drawAreaContentOnContext(t, e) {\n const { location: i, backgroundColor: s } = e, { x: n, y: a, width: o, height: r } = i;\n s && (t.fillStyle = s, t.fillRect(n, a, o, r));\n const l = this.contents.get(e.id);\n if (l) {\n if (l.type === \"text\") {\n if (!l.text.trim())\n return;\n const d = l.offset || { x: 0, y: 0 }, c = l.scale ?? 1, u = l.rotation ?? 0, p = n + o / 2 + d.x, g = a + r / 2 + d.y;\n t.save(), t.beginPath(), t.rect(n, a, o, r), t.clip(), t.translate(p, g), t.rotate(u * Math.PI / 180), t.scale(c, c), t.font = `${l.size}px ${l.font}, sans-serif`, t.fillStyle = l.color, t.textBaseline = \"middle\";\n let m;\n switch (l.align) {\n case \"left\":\n t.textAlign = \"left\", m = -o / 2 + 10;\n break;\n case \"right\":\n t.textAlign = \"right\", m = o / 2 - 10;\n break;\n case \"center\":\n default:\n t.textAlign = \"center\", m = 0;\n break;\n }\n t.fillText(l.text, m, 0), t.restore();\n } else if (l.type === \"image\") {\n const d = this.loadedImages.get(e.id);\n if (!d)\n return;\n const c = l.offset || { x: 0, y: 0 }, u = l.scale ?? 1, p = l.rotation ?? 0;\n t.save(), t.beginPath(), t.rect(n, a, o, r), t.clip();\n const g = d.naturalWidth / d.naturalHeight, m = o / r;\n let b, y;\n g > m ? (b = o, y = o / g) : (y = r, b = r * g);\n const w = b * u, v = y * u, x = n + o / 2 + c.x, C = a + r / 2 + c.y;\n t.translate(x, C), t.rotate(p * Math.PI / 180), t.drawImage(d, -w / 2, -v / 2, w, v), t.restore();\n }\n }\n }\n /**\n * Cleanup resources\n */\n destroy() {\n this.stop(), this.bgImageElement = null, this.loadedImages.clear(), this.loadingImages.clear(), this.eventListeners.clear();\n }\n}\nfunction E(f) {\n const t = f.textOptions;\n return {\n type: \"text\",\n text: t?.defaultText || \"\",\n font: t?.defaultFont || \"Inter\",\n size: t?.defaultSize || 24,\n color: t?.defaultColor || \"#000000\",\n align: t?.defaultAlign || \"center\"\n };\n}\nfunction M(f) {\n return f.contentType === \"text\" || f.contentType === \"both\";\n}\nfunction P(f) {\n return f.contentType === \"image\" || f.contentType === \"both\";\n}\nconst H = 50;\nclass B {\n constructor(t) {\n this.history = [], this.historyIndex = -1, this.listeners = /* @__PURE__ */ new Set(), this.isRestoring = !1, this.state = this.cloneState(t), this.history.push({\n state: this.cloneState(t),\n timestamp: Date.now(),\n description: \"Initial state\"\n }), this.historyIndex = 0;\n }\n getState() {\n return this.state;\n }\n /**\n * Update state and save to history\n */\n setState(t, e, i = !1) {\n const s = this.state;\n this.state = { ...this.state, ...t }, !i && !this.isRestoring && this.saveToHistory(s, e), this.notifyListeners();\n }\n /**\n * Update state without saving to history\n * Use for transient changes like zoom/pan\n */\n update(t) {\n this.state = { ...this.state, ...t }, this.notifyListeners();\n }\n subscribe(t) {\n return this.listeners.add(t), () => this.listeners.delete(t);\n }\n undo() {\n return this.canUndo() ? (this.historyIndex--, this.restoreFromHistory(), !0) : !1;\n }\n redo() {\n return this.canRedo() ? (this.historyIndex++, this.restoreFromHistory(), !0) : !1;\n }\n canUndo() {\n return this.historyIndex > 0;\n }\n canRedo() {\n return this.historyIndex < this.history.length - 1;\n }\n clearHistory() {\n this.history = [], this.historyIndex = -1;\n }\n getHistory() {\n return this.history;\n }\n saveToHistory(t, e) {\n this.historyIndex < this.history.length - 1 && (this.history = this.history.slice(0, this.historyIndex + 1)), this.history.push({\n state: this.cloneState(t),\n timestamp: Date.now(),\n description: e\n }), this.history.length > H && this.history.shift(), this.historyIndex = this.history.length - 1;\n }\n restoreFromHistory() {\n const t = this.history[this.historyIndex];\n t && (this.isRestoring = !0, this.state = this.cloneState(t.state), this.notifyListeners(), this.isRestoring = !1);\n }\n notifyListeners() {\n const t = this.state;\n for (const e of this.listeners)\n try {\n e(t);\n } catch (i) {\n console.error(\"Error in state change listener:\", i);\n }\n }\n /**\n * Deep clone state. Contents are already serialized as Array<[string, AreaContent]>\n * so JSON.parse/stringify works correctly.\n */\n cloneState(t) {\n return JSON.parse(JSON.stringify(t));\n }\n}\nclass A {\n constructor(t) {\n this.listeners = /* @__PURE__ */ new Set(), this.areas = t, this.contents = this.buildInitialContents();\n }\n buildInitialContents() {\n const t = /* @__PURE__ */ new Map();\n for (const e of this.areas)\n M(e) && t.set(e.id, E(e));\n return t;\n }\n getContents() {\n return this.contents;\n }\n getContent(t) {\n return this.contents.get(t);\n }\n setTextContent(t, e) {\n const i = this.contents.get(t), s = this.areas.find((a) => a.id === t), n = s ? E(s) : {\n type: \"text\",\n text: \"\",\n font: \"Inter\",\n size: 24,\n color: \"#000000\",\n align: \"center\"\n };\n i?.type === \"text\" ? this.contents.set(t, { ...i, ...e }) : this.contents.set(t, { ...n, ...e }), this.notify();\n }\n setImageContent(t, e, i) {\n const s = {\n type: \"image\",\n dataUrl: e,\n filename: i\n };\n this.contents.set(t, s), this.notify();\n }\n clearContent(t) {\n const e = this.areas.find((i) => i.id === t);\n e && M(e) ? this.contents.set(t, E(e)) : this.contents.delete(t), this.notify();\n }\n setContentOffset(t, e) {\n const i = this.contents.get(t);\n i && (this.contents.set(t, { ...i, offset: e }), this.notify());\n }\n setImageScale(t, e) {\n const i = this.contents.get(t);\n if (!i || i.type !== \"image\") return;\n const s = Math.max(0.1, Math.min(5, e));\n this.contents.set(t, { ...i, scale: s }), this.notify();\n }\n setImageRotation(t, e) {\n const i = this.contents.get(t);\n if (!i || i.type !== \"image\") return;\n let s = e % 360;\n s < 0 && (s += 360), this.contents.set(t, { ...i, rotation: s }), this.notify();\n }\n reset() {\n this.contents = this.buildInitialContents(), this.notify();\n }\n /** Serialize for undo/redo (Map -> Array) */\n toJSON() {\n return Array.from(this.contents.entries());\n }\n /** Restore from serialized data */\n fromJSON(t) {\n this.contents = new Map(t), this.notify();\n }\n /** Replace the entire contents map (e.g. from undo/redo) without notification */\n setContentsQuiet(t) {\n this.contents = new Map(t);\n }\n subscribe(t) {\n return this.listeners.add(t), () => this.listeners.delete(t);\n }\n notify() {\n for (const t of this.listeners)\n try {\n t();\n } catch (e) {\n console.error(\"Error in AreaContentManager listener:\", e);\n }\n }\n}\nclass I {\n constructor() {\n this.listeners = /* @__PURE__ */ new Map();\n }\n /**\n * Register an event listener\n *\n * @param event - Event name\n * @param handler - Event handler function\n * @returns Unsubscribe function\n */\n on(t, e) {\n return this.listeners.has(t) || this.listeners.set(t, /* @__PURE__ */ new Set()), this.listeners.get(t).add(e), () => this.off(t, e);\n }\n /**\n * Register a one-time event listener\n *\n * @param event - Event name\n * @param handler - Event handler function\n * @returns Unsubscribe function\n */\n once(t, e) {\n const i = (n) => {\n e(n), this.off(t, i);\n };\n return this.on(t, i);\n }\n /**\n * Remove an event listener\n *\n * @param event - Event name\n * @param handler - Event handler function to remove\n */\n off(t, e) {\n const i = this.listeners.get(t);\n i && (i.delete(e), i.size === 0 && this.listeners.delete(t));\n }\n /**\n * Emit an event to all registered listeners\n *\n * @param event - Event name\n * @param data - Event data\n */\n emit(t, e) {\n const i = this.listeners.get(t);\n if (i) {\n const s = Array.from(i);\n for (const n of s)\n try {\n n(e);\n } catch (a) {\n console.error(`Error in event handler for \"${String(t)}\":`, a);\n }\n }\n }\n /**\n * Remove all listeners for an event, or all listeners if no event specified\n *\n * @param event - Optional event name to clear (clears all if not specified)\n */\n clear(t) {\n t ? this.listeners.delete(t) : this.listeners.clear();\n }\n /**\n * Get the number of listeners for an event\n *\n * @param event - Event name\n * @returns Number of listeners\n */\n listenerCount(t) {\n return this.listeners.get(t)?.size ?? 0;\n }\n}\nclass U extends I {\n constructor() {\n super(...arguments), this.activeTouches = /* @__PURE__ */ new Map(), this.initialPinchDistance = null, this.lastPinchCenter = null, this.isTwoFingerGesture = !1;\n }\n /** Whether a multi-touch gesture is currently active */\n get isMultiTouch() {\n return this.isTwoFingerGesture;\n }\n handleTouchStart(t) {\n for (let e = 0; e < t.changedTouches.length; e++) {\n const i = t.changedTouches[e];\n this.activeTouches.set(i.identifier, {\n x: i.clientX,\n y: i.clientY\n });\n }\n if (this.activeTouches.size === 2) {\n this.isTwoFingerGesture = !0, t.preventDefault();\n const [e, i] = Array.from(this.activeTouches.values());\n this.initialPinchDistance = this.getDistance(e, i), this.lastPinchCenter = this.getCenter(e, i);\n }\n }\n handleTouchMove(t) {\n for (let e = 0; e < t.changedTouches.length; e++) {\n const i = t.changedTouches[e];\n this.activeTouches.set(i.identifier, {\n x: i.clientX,\n y: i.clientY\n });\n }\n if (this.activeTouches.size === 2 && this.initialPinchDistance !== null && this.lastPinchCenter) {\n t.preventDefault();\n const [e, i] = Array.from(this.activeTouches.values()), s = this.getDistance(e, i), n = this.getCenter(e, i), a = s / this.initialPinchDistance;\n this.emit(\"pinch\", {\n scale: a,\n centerX: n.x,\n centerY: n.y\n });\n const o = n.x - this.lastPinchCenter.x, r = n.y - this.lastPinchCenter.y;\n (Math.abs(o) > 0.5 || Math.abs(r) > 0.5) && this.emit(\"pan\", { deltaX: o, deltaY: r }), this.initialPinchDistance = s, this.lastPinchCenter = n;\n }\n }\n handleTouchEnd(t) {\n for (let e = 0; e < t.changedTouches.length; e++) {\n const i = t.changedTouches[e];\n this.activeTouches.delete(i.identifier);\n }\n this.activeTouches.size < 2 && (this.initialPinchDistance = null, this.lastPinchCenter = null, this.isTwoFingerGesture = !1);\n }\n reset() {\n this.activeTouches.clear(), this.initialPinchDistance = null, this.lastPinchCenter = null, this.isTwoFingerGesture = !1;\n }\n getDistance(t, e) {\n const i = e.x - t.x, s = e.y - t.y;\n return Math.sqrt(i * i + s * s);\n }\n getCenter(t, e) {\n return {\n x: (t.x + e.x) / 2,\n y: (t.y + e.y) / 2\n };\n }\n}\nclass F extends I {\n constructor(t, e, i, s) {\n super(), this.interactionState = { mode: \"idle\" }, this.initialPinchZoom = 1, this.canvas = t, this.engine = e, this.getContents = i, this.getSelectedAreaId = s, this.gestureHandler = new U(), this.boundMouseDown = this.handleMouseDown.bind(this), this.boundMouseMove = this.handleMouseMove.bind(this), this.boundMouseUp = this.handleMouseUp.bind(this), this.boundMouseLeave = this.handleMouseLeave.bind(this), this.boundContextMenu = this.handleContextMenu.bind(this), this.boundDoubleClick = this.handleDoubleClick.bind(this), this.boundTouchStart = this.handleTouchStart.bind(this), this.boundTouchMove = this.handleTouchMove.bind(this), this.boundTouchEnd = this.handleTouchEnd.bind(this), t.addEventListener(\"mousedown\", this.boundMouseDown), t.addEventListener(\"mousemove\", this.boundMouseMove), t.addEventListener(\"mouseup\", this.boundMouseUp), t.addEventListener(\"mouseleave\", this.boundMouseLeave), t.addEventListener(\"contextmenu\", this.boundContextMenu), t.addEventListener(\"dblclick\", this.boundDoubleClick), t.addEventListener(\"touchstart\", this.boundTouchStart, { passive: !1 }), t.addEventListener(\"touchmove\", this.boundTouchMove, { passive: !1 }), t.addEventListener(\"touchend\", this.boundTouchEnd), this.gestureHandler.on(\"pinch\", ({ scale: n }) => {\n const a = Math.max(0.1, Math.min(5, this.initialPinchZoom * n));\n this.emit(\"zoom\", { zoom: a });\n }), this.gestureHandler.on(\"pan\", ({ deltaX: n, deltaY: a }) => {\n const o = this.engine.getPan(), r = this.engine.getZoom();\n this.emit(\"pan\", {\n pan: {\n x: o.x + n / r,\n y: o.y + a / r\n }\n });\n });\n }\n getCanvasPosition(t, e) {\n const i = this.canvas.getBoundingClientRect(), s = window.devicePixelRatio || 1, n = (t - i.left) * s, a = (e - i.top) * s;\n return this.engine.screenToCanvas(n, a);\n }\n handleMouseDown(t) {\n const e = this.getCanvasPosition(t.clientX, t.clientY);\n this.processPointerDown(e);\n }\n handleMouseMove(t) {\n const e = this.getCanvasPosition(t.clientX, t.clientY);\n this.processPointerMove(e);\n }\n handleMouseUp() {\n this.processPointerUp();\n }\n handleMouseLeave() {\n this.processPointerUp(), this.emit(\"cursor\", { cursor: \"default\" });\n }\n handleContextMenu(t) {\n t.preventDefault();\n }\n handleDoubleClick(t) {\n const e = this.getCanvasPosition(t.clientX, t.clientY);\n let i = this.engine.hitTestContent(e.x, e.y);\n i || (i = this.engine.hitTestArea(e.x, e.y) ?? null), this.emit(\"context-menu\", { areaId: i, clientX: t.clientX, clientY: t.clientY });\n }\n handleTouchStart(t) {\n if (this.gestureHandler.handleTouchStart(t), this.gestureHandler.isMultiTouch) {\n this.initialPinchZoom = this.engine.getZoom(), this.interactionState.mode !== \"idle\" && (this.interactionState = { mode: \"idle\" });\n return;\n }\n if (t.touches.length !== 1) return;\n const e = t.touches[0], i = this.getCanvasPosition(e.clientX, e.clientY);\n this.processPointerDown(i) && t.preventDefault();\n }\n handleTouchMove(t) {\n if (this.gestureHandler.handleTouchMove(t), this.gestureHandler.isMultiTouch || t.touches.length !== 1 || this.interactionState.mode === \"idle\") return;\n const e = t.touches[0], i = this.getCanvasPosition(e.clientX, e.clientY);\n this.processPointerMove(i), t.preventDefault();\n }\n handleTouchEnd(t) {\n this.gestureHandler.handleTouchEnd(t), this.gestureHandler.isMultiTouch || this.processPointerUp();\n }\n /**\n * Process pointer down. Returns true if an interaction started.\n */\n processPointerDown(t) {\n const e = this.getSelectedAreaId(), i = this.getContents();\n if (e) {\n const a = this.engine.hitTestHandle(t.x, t.y, e);\n if (a) {\n const o = i.get(e), r = this.engine.getContentBounds(e);\n if (a === \"rotate\" && o?.type === \"image\" && r) {\n const l = Math.atan2(t.y - r.centerY, t.x - r.centerX) * (180 / Math.PI);\n return this.interactionState = {\n mode: \"rotating\",\n areaId: e,\n startRotation: o.rotation ?? 0,\n centerPoint: { x: r.centerX, y: r.centerY },\n startAngle: l\n }, !0;\n } else if (a !== \"rotate\" && o?.type === \"image\" && r)\n return this.interactionState = {\n mode: \"scaling\",\n areaId: e,\n handle: a,\n startScale: o.scale ?? 1,\n startMousePos: t,\n pivotPoint: { x: r.centerX, y: r.centerY }\n }, !0;\n }\n }\n const s = this.engine.hitTestContent(t.x, t.y);\n if (s) {\n if (this.emit(\"area:select\", { areaId: s }), this.engine.isPositioningAllowed(s)) {\n const o = i.get(s)?.offset ?? { x: 0, y: 0 };\n return this.interactionState = {\n mode: \"dragging\",\n areaId: s,\n startOffset: o,\n startMousePos: t\n }, !0;\n }\n return !0;\n }\n const n = this.engine.hitTestArea(t.x, t.y);\n return n ? (this.emit(\"area:select\", { areaId: n }), !1) : (this.emit(\"area:select\", { areaId: null }), !1);\n }\n processPointerMove(t) {\n if (this.interactionState.mode === \"dragging\") {\n const { areaId: e, startOffset: i, startMousePos: s } = this.interactionState, n = t.x - s.x, a = t.y - s.y;\n let o = {\n x: i.x + n,\n y: i.y + a\n };\n const r = this.engine.getAreaLocation(e);\n if (r) {\n const l = r.width / 2 - 10, d = r.height / 2 - 10;\n o.x = Math.max(-l, Math.min(l, o.x)), o.y = Math.max(-d, Math.min(d, o.y));\n }\n this.emit(\"content:drag\", { areaId: e, offset: o });\n return;\n }\n if (this.interactionState.mode === \"scaling\") {\n const { areaId: e, startScale: i, startMousePos: s, pivotPoint: n } = this.interactionState, a = Math.sqrt(\n Math.pow(s.x - n.x, 2) + Math.pow(s.y - n.y, 2)\n ), o = Math.sqrt(\n Math.pow(t.x - n.x, 2) + Math.pow(t.y - n.y, 2)\n );\n if (a > 0) {\n const r = o / a, l = Math.max(0.1, Math.min(5, i * r));\n this.emit(\"content:scale\", { areaId: e, scale: l });\n }\n return;\n }\n if (this.interactionState.mode === \"rotating\") {\n const { areaId: e, startRotation: i, centerPoint: s, startAngle: n } = this.interactionState, a = Math.atan2(t.y - s.y, t.x - s.x) * (180 / Math.PI);\n let o = i + (a - n);\n o = o % 360, o < 0 && (o += 360);\n const r = [0, 90, 180, 270, 360];\n for (const l of r)\n if (Math.abs(o - l) < 5) {\n o = l === 360 ? 0 : l;\n break;\n }\n this.emit(\"content:rotate\", { areaId: e, rotation: o });\n return;\n }\n this.updateCursor(t);\n }\n processPointerUp() {\n this.interactionState.mode !== \"idle\" && (this.interactionState = { mode: \"idle\" });\n }\n updateCursor(t) {\n const e = this.getSelectedAreaId();\n let i = \"default\";\n if (e) {\n const s = this.engine.hitTestHandle(t.x, t.y, e);\n s ? i = s === \"rotate\" ? \"crosshair\" : s === \"nw\" || s === \"se\" ? \"nwse-resize\" : \"nesw-resize\" : this.engine.hitTestContent(t.x, t.y) === e && (i = this.engine.isPositioningAllowed(e) ? \"move\" : \"pointer\");\n } else\n this.engine.hitTestContent(t.x, t.y) && (i = \"pointer\");\n this.emit(\"cursor\", { cursor: i });\n }\n setSelectedArea(t) {\n this.engine.setSelectedArea(t);\n }\n destroy() {\n this.canvas.removeEventListener(\"mousedown\", this.boundMouseDown), this.canvas.removeEventListener(\"mousemove\", this.boundMouseMove), this.canvas.removeEventListener(\"mouseup\", this.boundMouseUp), this.canvas.removeEventListener(\"mouseleave\", this.boundMouseLeave), this.canvas.removeEventListener(\"contextmenu\", this.boundContextMenu), this.canvas.removeEventListener(\"dblclick\", this.boundDoubleClick), this.canvas.removeEventListener(\"touchstart\", this.boundTouchStart), this.canvas.removeEventListener(\"touchmove\", this.boundTouchMove), this.canvas.removeEventListener(\"touchend\", this.boundTouchEnd), this.gestureHandler.reset(), this.clear();\n }\n}\nclass Z {\n constructor(t = \"/api\") {\n this.baseUrl = t;\n }\n async getTemplate(t) {\n try {\n const e = await fetch(`${this.baseUrl}/templates/${t}`);\n if (!e.ok) {\n let s = `Failed to load template (${e.status} ${e.statusText}): ${t}\n\n`;\n throw e.status === 404 ? s += \"Template not found.\" : e.status === 403 ? s += \"Access forbidden.\" : e.status >= 500 && (s += \"Server error.\"), new Error(s);\n }\n return (await e.json()).templateJson;\n } catch (e) {\n throw e instanceof Error && e.message.includes(\"Failed to fetch\") ? new Error(`Network error loading template: ${t}`) : e;\n }\n }\n async getProduct(t) {\n try {\n const e = await fetch(`${this.baseUrl}/products/${t}`);\n if (!e.ok) {\n let i = `Failed to load product (${e.status} ${e.statusText}): ${t}\n\n`;\n throw e.status === 404 ? i += \"Product not found.\" : e.status === 403 ? i += \"Access forbidden.\" : e.status >= 500 && (i += \"Server error.\"), new Error(i);\n }\n return e.json();\n } catch (e) {\n throw e instanceof Error && e.message.includes(\"Failed to fetch\") ? new Error(`Network error loading product: ${t}`) : e;\n }\n }\n async finalizeDesign(t, e) {\n try {\n const i = await fetch(`${this.baseUrl}/finalize`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n shopId: t,\n templateId: e.templateId,\n designJson: e\n })\n });\n if (!i.ok) {\n let s = `Failed to finalize design (${i.status} ${i.statusText})\n\n`;\n if (i.status === 400) {\n const n = await i.json().catch(() => ({}));\n s += n.error || \"Invalid design data.\";\n } else i.status === 429 ? s += \"Rate limit exceeded.\" : i.status >= 500 && (s += \"Server error.\");\n throw new Error(s);\n }\n return i.json();\n } catch (i) {\n throw i instanceof Error && i.message.includes(\"Failed to fetch\") ? new Error(\"Network error finalizing design\") : i;\n }\n }\n async uploadAsset(t, e) {\n try {\n const i = new FormData();\n i.append(\"shopId\", e), i.append(\"file\", t);\n const s = await fetch(`${this.baseUrl}/assets/upload`, {\n method: \"POST\",\n body: i\n });\n if (!s.ok) {\n let n = `Failed to upload asset (${s.status} ${s.statusText})\n\n`;\n if (s.status === 400) {\n const a = await s.json().catch(() => ({}));\n n += a.error || \"Invalid file.\";\n } else s.status === 413 ? n += \"File too large (max 15MB).\" : s.status >= 500 && (n += \"Server error.\");\n throw new Error(n);\n }\n return s.json();\n } catch (i) {\n throw i instanceof Error && i.message.includes(\"Failed to fetch\") ? new Error(\"Network error uploading asset\") : i;\n }\n }\n async getStorageUsage(t) {\n try {\n const e = await fetch(`${this.baseUrl}/assets/usage?shopId=${encodeURIComponent(t)}`);\n if (!e.ok)\n throw new Error(`Failed to fetch storage usage (${e.status})`);\n return e.json();\n } catch (e) {\n throw e instanceof Error && e.message.includes(\"Failed to fetch\") ? new Error(\"Network error fetching storage usage\") : e;\n }\n }\n}\nfunction h(f, t, ...e) {\n const i = document.createElement(f);\n return t && Object.entries(t).forEach(([s, n]) => {\n s === \"class\" ? i.className = n : s in i ? i[s] = n : i.setAttribute(s, String(n));\n }), e.forEach((s) => {\n typeof s == \"string\" ? i.appendChild(document.createTextNode(s)) : i.appendChild(s);\n }), i;\n}\nfunction $(f, t) {\n let e = null, i = null;\n const s = (...n) => {\n i = n, e && clearTimeout(e), e = setTimeout(() => {\n i && f(...i), e = null, i = null;\n }, t);\n };\n return s.flush = () => {\n e && (clearTimeout(e), e = null), i && (f(...i), i = null);\n }, s.cancel = () => {\n e && (clearTimeout(e), e = null), i = null;\n }, s;\n}\nclass V extends I {\n constructor() {\n super(), this.percentLabel = h(\"span\", { class: \"zoom-percent\" }, \"100%\");\n const t = h(\"button\", {\n class: \"zoom-btn\",\n title: \"Zoom out\"\n }, \"−\");\n t.addEventListener(\"click\", () => this.emit(\"zoom-out\", void 0));\n const e = h(\"button\", {\n class: \"zoom-btn\",\n title: \"Fit to view\"\n }, \"Fit\");\n e.addEventListener(\"click\", () => this.emit(\"zoom-fit\", void 0));\n const i = h(\"button\", {\n class: \"zoom-btn\",\n title: \"Zoom in\"\n }, \"+\");\n i.addEventListener(\"click\", () => this.emit(\"zoom-in\", void 0)), this.viewSelect = document.createElement(\"select\"), this.viewSelect.className = \"view-select\", this.viewSelect.title = \"Switch view\", this.viewSelect.style.display = \"none\", this.viewSelect.addEventListener(\"change\", () => {\n this.emit(\"view-change\", { viewName: this.viewSelect.value });\n }), this.element = h(\"div\", { class: \"zoom-toolbar\" }), this.element.appendChild(t), this.element.appendChild(e), this.element.appendChild(i), this.element.appendChild(this.percentLabel), this.element.appendChild(this.viewSelect);\n const s = h(\"div\", { class: \"zoom-toolbar-spacer\" });\n this.element.appendChild(s);\n const n = h(\"button\", {\n class: \"zoom-btn zoom-close-btn\",\n title: \"Close editor\"\n }, \"✕ Close\");\n n.addEventListener(\"click\", () => this.emit(\"close\", void 0)), this.element.appendChild(n), this.saveBtn = h(\"button\", {\n class: \"zoom-btn zoom-save-btn\",\n title: \"Save customization\"\n }, \"Save Customization\"), this.saveBtn.style.display = \"none\", this.saveBtn.addEventListener(\"click\", () => this.emit(\"save\", void 0)), this.element.appendChild(this.saveBtn);\n }\n setZoom(t) {\n this.percentLabel.textContent = `${Math.round(t * 100)}%`;\n }\n showSaveButton(t) {\n this.saveBtn.style.display = t ? \"\" : \"none\";\n }\n setSaveDisabled(t, e) {\n this.saveBtn.disabled = t, e && (this.saveBtn.textContent = e);\n }\n setViews(t) {\n this.viewSelect.innerHTML = \"\";\n for (const e of t) {\n const i = document.createElement(\"option\");\n i.value = e.viewName, i.textContent = e.viewName, this.viewSelect.appendChild(i);\n }\n this.viewSelect.style.display = t.length > 1 ? \"\" : \"none\";\n }\n setActiveView(t) {\n this.viewSelect.value = t;\n }\n getElement() {\n return this.element;\n }\n}\nconst Y = [\n { label: \"Inter\", value: \"Inter\" },\n { label: \"Arial\", value: \"Arial\" },\n { label: \"Georgia\", value: \"Georgia\" },\n { label: \"Times New Roman\", value: \"Times New Roman\" },\n { label: \"Courier New\", value: \"Courier New\" }\n], W = [\n { label: \"L\", value: \"left\" },\n { label: \"C\", value: \"center\" },\n { label: \"R\", value: \"right\" }\n], L = [\"image/png\", \"image/jpeg\", \"image/webp\", \"image/svg+xml\"], X = 15 * 1024 * 1024;\nclass R extends I {\n constructor(t) {\n super(), this.mode = \"text\", this.isSelected = !1, this.textInputEl = null, this.fontSelectEl = null, this.sizeInputEl = null, this.colorInputEl = null, this.alignGroupEl = null, this.area = t;\n const e = M(t), i = P(t);\n this.mode = i && !e ? \"image\" : \"text\", this.element = h(\"div\", { class: \"area-card\" }), this.element.addEventListener(\"click\", (r) => {\n r.target.tagName === \"INPUT\" || r.target.tagName === \"SELECT\" || r.target.tagName === \"BUTTON\" || this.emit(\"select\", { areaId: t.id });\n });\n const s = h(\"div\", { class: \"area-card-header\" }), n = h(\"div\", { class: \"area-card-name-row\" }), a = h(\"span\", { class: \"area-card-name\" }, t.name);\n if (n.appendChild(a), t.required) {\n const r = h(\"span\", { class: \"area-card-badge\" }, \"Required\");\n n.appendChild(r);\n }\n s.appendChild(n);\n const o = h(\"button\", {\n class: \"area-card-reset-btn\",\n title: \"Reset content\"\n }, \"Reset\");\n if (o.addEventListener(\"click\", (r) => {\n r.stopPropagation(), this.emit(\"clear\", { areaId: t.id });\n }), s.appendChild(o), this.element.appendChild(s), e && i) {\n const r = h(\"div\", { class: \"area-card-mode-switcher\" }), l = h(\"button\", {\n class: \"mode-btn mode-btn-active\"\n }, \"Text\");\n l.dataset.mode = \"text\";\n const d = h(\"button\", { class: \"mode-btn\" }, \"Image\");\n d.dataset.mode = \"image\", l.addEventListener(\"click\", (c) => {\n c.stopPropagation(), this.setMode(\"text\"), l.classList.add(\"mode-btn-active\"), d.classList.remove(\"mode-btn-active\"), this.currentContent?.type === \"image\" && this.emit(\"clear\", { areaId: t.id });\n }), d.addEventListener(\"click\", (c) => {\n c.stopPropagation(), this.setMode(\"image\"), d.classList.add(\"mode-btn-active\"), l.classList.remove(\"mode-btn-active\"), this.currentContent?.type === \"text\" && this.emit(\"clear\", { areaId: t.id });\n }), r.appendChild(l), r.appendChild(d), this.element.appendChild(r);\n }\n this.contentContainer = h(\"div\", { class: \"area-card-content\" }), this.element.appendChild(this.contentContainer), this.transformContainer = h(\"div\", { class: \"area-card-transforms\" }), this.element.appendChild(this.transformContainer), this.renderContent();\n }\n setMode(t) {\n this.mode = t, this.renderContent();\n }\n setContent(t) {\n const e = this.currentContent?.type;\n this.currentContent = t, t?.type === \"image\" && (this.mode = \"image\"), this.element.querySelectorAll(\".mode-btn\").forEach((n) => {\n const a = n;\n a.classList.toggle(\"mode-btn-active\", a.dataset.mode === this.mode);\n }), t?.type !== e || t?.type === \"image\" || t === void 0 ? this.renderContent() : t?.type === \"text\" && this.updateTextValues(t), this.renderTransforms();\n }\n setSelected(t) {\n this.isSelected = t, this.element.classList.toggle(\"area-card-selected\", t), this.renderTransforms();\n }\n updateTextValues(t) {\n this.textInputEl && this.textInputEl.value !== t.text && (this.textInputEl.value = t.text), this.fontSelectEl && this.fontSelectEl.value !== t.font && (this.fontSelectEl.value = t.font), this.sizeInputEl && this.sizeInputEl.value !== String(t.size) && (this.sizeInputEl.value = String(t.size)), this.colorInputEl && this.colorInputEl.value !== t.color && (this.colorInputEl.value = t.color), this.alignGroupEl && this.alignGroupEl.querySelectorAll(\".align-btn\").forEach((e) => {\n const i = e, s = i.title === \"Left\" ? \"left\" : i.title === \"Center\" ? \"center\" : \"right\";\n i.classList.toggle(\"align-btn-active\", s === t.align);\n });\n }\n renderContent() {\n this.contentContainer.innerHTML = \"\", this.textInputEl = null, this.fontSelectEl = null, this.sizeInputEl = null, this.colorInputEl = null, this.alignGroupEl = null;\n const t = M(this.area), e = P(this.area), i = !e || t && e && this.mode === \"text\", s = !t || t && e && this.mode === \"image\";\n t && i && this.renderTextControls(), e && s && this.renderImageControls();\n }\n renderTextControls() {\n const t = this.currentContent, e = t?.type === \"text\" ? t : E(this.area), i = h(\"input\", {\n class: \"area-input-text\",\n type: \"text\",\n placeholder: this.area.placeholder || \"Enter text...\"\n });\n i.value = e.text, this.area.textOptions?.maxLength && (i.maxLength = this.area.textOptions.maxLength), i.addEventListener(\"input\", () => {\n this.emit(\"text:change\", { areaId: this.area.id, updates: { text: i.value } });\n }), this.contentContainer.appendChild(i), this.textInputEl = i;\n const s = h(\"div\", { class: \"area-input-row\" }), n = h(\"select\", { class: \"area-input-font\" });\n for (const d of Y) {\n const c = h(\"option\");\n c.value = d.value, c.textContent = d.label, d.value === e.font && (c.selected = !0), n.appendChild(c);\n }\n n.addEventListener(\"change\", () => {\n this.emit(\"text:change\", { areaId: this.area.id, updates: { font: n.value } });\n }), s.appendChild(n), this.fontSelectEl = n;\n const a = h(\"input\", {\n class: \"area-input-size\",\n type: \"number\"\n });\n a.value = String(e.size), a.min = String(this.area.textOptions?.minSize || 8), a.max = String(this.area.textOptions?.maxSize || 200), a.addEventListener(\"change\", () => {\n this.emit(\"text:change\", {\n areaId: this.area.id,\n updates: { size: parseInt(a.value, 10) || 24 }\n });\n }), s.appendChild(a), this.sizeInputEl = a, this.contentContainer.appendChild(s);\n const o = h(\"div\", { class: \"area-input-row\" }), r = h(\"div\", { class: \"area-input-align\" });\n for (const d of W) {\n const c = h(\"button\", {\n class: `align-btn${e.align === d.value ? \" align-btn-active\" : \"\"}`,\n title: d.label === \"L\" ? \"Left\" : d.label === \"C\" ? \"Center\" : \"Right\"\n }, d.label);\n c.addEventListener(\"click\", (u) => {\n u.stopPropagation(), this.emit(\"text:change\", { areaId: this.area.id, updates: { align: d.value } }), r.querySelectorAll(\".align-btn\").forEach((p) => p.classList.remove(\"align-btn-active\")), c.classList.add(\"align-btn-active\");\n }), r.appendChild(c);\n }\n o.appendChild(r), this.alignGroupEl = r;\n const l = h(\"input\", {\n class: \"area-input-color\",\n type: \"color\"\n });\n l.value = e.color, l.addEventListener(\"input\", () => {\n this.emit(\"text:change\", { areaId: this.area.id, updates: { color: l.value } });\n }), o.appendChild(l), this.colorInputEl = l, this.contentContainer.appendChild(o);\n }\n renderImageControls() {\n const t = this.currentContent;\n if (t?.type === \"image\") {\n const e = h(\"div\", { class: \"area-image-preview\" }), i = h(\"img\", { class: \"area-image-thumb\" });\n i.src = t.dataUrl, i.alt = t.filename || \"Uploaded image\", e.appendChild(i);\n const s = h(\"div\", { class: \"area-image-info\" });\n s.appendChild(h(\"span\", { class: \"area-image-name\" }, t.filename || \"Image\"));\n const n = h(\"button\", { class: \"area-image-remove-btn\" }, \"Remove\");\n n.addEventListener(\"click\", (a) => {\n a.stopPropagation(), this.emit(\"clear\", { areaId: this.area.id });\n }), s.appendChild(n), e.appendChild(s), this.contentContainer.appendChild(e);\n } else {\n const e = h(\"button\", { class: \"area-upload-btn\" }, \"Upload Image\"), i = h(\"input\", { type: \"file\" });\n i.accept = L.join(\",\"), i.style.display = \"none\";\n const s = h(\"div\", { class: \"area-validation-error\" });\n s.style.display = \"none\", i.addEventListener(\"change\", () => {\n const n = i.files?.[0];\n if (!n) return;\n if (!L.includes(n.type)) {\n const o = \"Only PNG, JPEG, WebP, and SVG images are accepted\";\n s.textContent = o, s.style.display = \"block\", this.emit(\"validation:error\", { areaId: this.area.id, message: o }), i.value = \"\";\n return;\n }\n if (n.size > X) {\n const o = \"File must be smaller than 15MB\";\n s.textContent = o, s.style.display = \"block\", this.emit(\"validation:error\", { areaId: this.area.id, message: o }), i.value = \"\";\n return;\n }\n s.style.display = \"none\";\n const a = new FileReader();\n a.onload = () => {\n const o = a.result;\n this.emit(\"image:change\", { areaId: this.area.id, dataUrl: o, filename: n.name });\n }, a.readAsDataURL(n), i.value = \"\";\n }), e.addEventListener(\"click\", (n) => {\n n.stopPropagation(), i.click();\n }), this.contentContainer.appendChild(e), this.contentContainer.appendChild(i), this.contentContainer.appendChild(s);\n }\n }\n renderTransforms() {\n this.transformContainer.innerHTML = \"\";\n const t = this.currentContent;\n if (!this.isSelected || !t) return;\n const e = t.type === \"text\" ? this.area.textOptions?.allowPositioning : this.area.imageOptions?.allowPositioning, i = t.type === \"image\" && this.area.imageOptions?.allowScaling, s = t.type === \"image\" && this.area.imageOptions?.allowRotation;\n if (!e && !i && !s) return;\n const n = h(\"div\", { class: \"area-card-divider\" });\n this.transformContainer.appendChild(n);\n const a = h(\"div\", { class: \"transform-header\" });\n a.appendChild(h(\"span\", { class: \"transform-title\" }, \"Transform\"));\n const o = h(\"button\", { class: \"transform-reset-btn\" }, \"Reset\");\n o.addEventListener(\"click\", (l) => {\n l.stopPropagation(), e && this.emit(\"offset:change\", { areaId: this.area.id, offset: { x: 0, y: 0 } }), i && this.emit(\"scale:change\", { areaId: this.area.id, scale: 1 }), s && this.emit(\"rotation:change\", { areaId: this.area.id, rotation: 0 });\n }), a.appendChild(o), this.transformContainer.appendChild(a);\n const r = t.offset ?? { x: 0, y: 0 };\n if (e) {\n const l = h(\"div\", { class: \"area-input-row\" }), d = h(\"label\", { class: \"transform-label\" }, \"X\"), c = h(\"input\", { class: \"transform-input\", type: \"number\" });\n c.value = String(Math.round(r.x)), c.addEventListener(\"change\", () => {\n this.emit(\"offset:change\", {\n areaId: this.area.id,\n offset: { ...r, x: parseInt(c.value, 10) || 0 }\n });\n });\n const u = h(\"label\", { class: \"transform-label\" }, \"Y\"), p = h(\"input\", { class: \"transform-input\", type: \"number\" });\n p.value = String(Math.round(r.y)), p.addEventListener(\"change\", () => {\n this.emit(\"offset:change\", {\n areaId: this.area.id,\n offset: { ...r, y: parseInt(p.value, 10) || 0 }\n });\n }), l.appendChild(d), l.appendChild(c), l.appendChild(u), l.appendChild(p), this.transformContainer.appendChild(l);\n }\n if (i && t.type === \"image\") {\n const l = t.scale ?? 1, d = h(\"div\", { class: \"area-input-row transform-slider-row\" }), c = h(\"label\", { class: \"transform-label\" }, `Scale: ${Math.round(l * 100)}%`), u = h(\"input\", { class: \"transform-slider\", type: \"range\" });\n u.min = \"10\", u.max = \"500\", u.step = \"5\", u.value = String(Math.round(l * 100)), u.addEventListener(\"input\", () => {\n const p = parseInt(u.value, 10) / 100;\n c.textContent = `Scale: ${Math.round(p * 100)}%`, this.emit(\"scale:change\", { areaId: this.area.id, scale: p });\n }), d.appendChild(c), d.appendChild(u), this.transformContainer.appendChild(d);\n }\n if (s && t.type === \"image\") {\n const l = t.rotation ?? 0, d = h(\"div\", { class: \"area-input-row transform-slider-row\" }), c = h(\"label\", { class: \"transform-label\" }, `Rotation: ${Math.round(l)}°`), u = h(\"input\", { class: \"transform-slider\", type: \"range\" });\n u.min = \"0\", u.max = \"360\", u.step = \"1\", u.value = String(Math.round(l)), u.addEventListener(\"input\", () => {\n const p = parseInt(u.value, 10);\n c.textContent = `Rotation: ${p}°`, this.emit(\"rotation:change\", { areaId: this.area.id, rotation: p });\n }), d.appendChild(c), d.appendChild(u), this.transformContainer.appendChild(d);\n }\n }\n getElement() {\n return this.element;\n }\n}\nclass q extends I {\n constructor(t) {\n super(), this.cards = /* @__PURE__ */ new Map(), this.isMobile = !1, this.boundEscapeHandler = (s) => {\n s.key === \"Escape\" && this.emit(\"dismiss\", void 0);\n }, this.backdrop = h(\"div\", { class: \"area-panel-backdrop\" }), this.backdrop.addEventListener(\"click\", () => {\n this.emit(\"dismiss\", void 0);\n }), this.element = h(\"div\", { class: \"area-panel\" });\n const e = h(\"div\", { class: \"area-panel-header\" });\n e.appendChild(h(\"span\", { class: \"area-panel-title\" }, \"Customize\"));\n const i = h(\"button\", { class: \"area-panel-close-btn\", title: \"Close\" }, \"×\");\n if (i.addEventListener(\"click\", () => {\n this.emit(\"dismiss\", void 0);\n }), e.appendChild(i), this.element.appendChild(e), this.panelContent = h(\"div\", { class: \"area-panel-content\" }), t.length === 0) {\n const s = h(\"p\", { class: \"area-panel-empty\" }, \"No customization areas defined.\");\n this.panelContent.appendChild(s);\n } else\n for (const s of t) {\n const n = new R(s);\n this.cards.set(s.id, n), n.on(\"text:change\", (a) => this.emit(\"text:change\", a)), n.on(\"image:change\", (a) => this.emit(\"image:change\", a)), n.on(\"clear\", (a) => this.emit(\"clear\", a)), n.on(\"select\", (a) => this.emit(\"select\", a)), n.on(\"offset:change\", (a) => this.emit(\"offset:change\", a)), n.on(\"scale:change\", (a) => this.emit(\"scale:change\", a)), n.on(\"rotation:change\", (a) => this.emit(\"rotation:change\", a)), n.on(\"validation:error\", (a) => this.emit(\"validation:error\", a)), this.panelContent.appendChild(n.getElement());\n }\n this.element.appendChild(this.panelContent);\n }\n setAreas(t) {\n if (this.cards.clear(), this.panelContent.innerHTML = \"\", t.length === 0) {\n const e = h(\"p\", { class: \"area-panel-empty\" }, \"No customization areas defined.\");\n this.panelContent.appendChild(e);\n } else\n for (const e of t) {\n const i = new R(e);\n this.cards.set(e.id, i), i.on(\"text:change\", (s) => this.emit(\"text:change\", s)), i.on(\"image:change\", (s) => this.emit(\"image:change\", s)), i.on(\"clear\", (s) => this.emit(\"clear\", s)), i.on(\"select\", (s) => this.emit(\"select\", s)), i.on(\"offset:change\", (s) => this.emit(\"offset:change\", s)), i.on(\"scale:change\", (s) => this.emit(\"scale:change\", s)), i.on(\"rotation:change\", (s) => this.emit(\"rotation:change\", s)), i.on(\"validation:error\", (s) => this.emit(\"validation:error\", s)), this.panelContent.appendChild(i.getElement());\n }\n }\n setContents(t) {\n for (const [e, i] of this.cards)\n i.setContent(t.get(e));\n }\n setSelectedArea(t) {\n for (const [e, i] of this.cards) {\n const s = e === t;\n i.setSelected(s), i.getElement().style.display = s ? \"\" : \"none\";\n }\n t ? (this.element.classList.add(\"area-panel-visible\"), this.isMobile && this.backdrop.classList.add(\"area-panel-backdrop-visible\"), document.addEventListener(\"keydown\", this.boundEscapeHandler)) : (this.element.classList.remove(\"area-panel-visible\"), this.isMobile && this.backdrop.classList.remove(\"area-panel-backdrop-visible\"), document.removeEventListener(\"keydown\", this.boundEscapeHandler));\n }\n setMobile(t) {\n this.isMobile = t, this.element.classList.toggle(\"area-panel-mobile\", t), t || (this.element.classList.remove(\"area-panel-visible\"), this.backdrop.classList.remove(\"area-panel-backdrop-visible\"));\n }\n getElement() {\n return this.element;\n }\n getBackdrop() {\n return this.backdrop;\n }\n}\nclass G {\n constructor(t = window) {\n this.target = t, this.commands = [], this.isEnabled = !0, this.handleKeyDown = (e) => {\n if (!this.isEnabled) return;\n const i = e.target;\n if (!(i.tagName === \"INPUT\" || i.tagName === \"TEXTAREA\" || i.isContentEditable)) {\n for (const s of this.commands)\n if (this.matchesCommand(e, s)) {\n e.preventDefault(), s.handler(e);\n break;\n }\n }\n }, this.target.addEventListener(\"keydown\", this.handleKeyDown);\n }\n /**\n * Register a keyboard command\n */\n register(t) {\n return this.commands.push(t), () => {\n const e = this.commands.indexOf(t);\n e !== -1 && this.commands.splice(e, 1);\n };\n }\n /**\n * Enable keyboard handling\n */\n enable() {\n this.isEnabled = !0;\n }\n /**\n * Disable keyboard handling\n */\n disable() {\n this.isEnabled = !1;\n }\n /**\n * Check if keyboard handling is enabled\n */\n isActive() {\n return this.isEnabled;\n }\n /**\n * Check if event matches a command\n */\n matchesCommand(t, e) {\n return !(t.key.toLowerCase() !== e.key.toLowerCase() || e.ctrl !== void 0 && e.ctrl !== t.ctrlKey || e.shift !== void 0 && e.shift !== t.shiftKey || e.alt !== void 0 && e.alt !== t.altKey || e.meta !== void 0 && e.meta !== t.metaKey);\n }\n /**\n * Cleanup\n */\n destroy() {\n this.target.removeEventListener(\"keydown\", this.handleKeyDown), this.commands = [];\n }\n}\nfunction j() {\n return /Mac|iPod|iPhone|iPad/.test(navigator.platform);\n}\nfunction J() {\n return j() ? \"meta\" : \"ctrl\";\n}\nfunction K(f, t, e, i) {\n const s = f / e, n = t / i;\n return Math.min(s, n);\n}\nfunction _(f, t, e = 8, i = 10, s = 300) {\n const n = K(f, t, e, i), a = n >= s;\n return {\n actualDPI: Math.round(n),\n targetDPI: s,\n width: f,\n height: t,\n passed: a,\n warning: a ? void 0 : `Image resolution is ${Math.round(n)} DPI at 100% scale. For best print quality, use images with at least ${s} DPI. This may result in pixelated or blurry prints.`\n };\n}\nconst k = ':host{--editor-bg: #f3f4f6;--editor-surface: #ffffff;--editor-border: #e5e7eb;--editor-text: #111827;--editor-text-muted: #6b7280;--editor-primary: #3b82f6;--editor-primary-hover: #2563eb;--editor-danger: #ef4444;--editor-radius: 8px;--editor-radius-sm: 4px;--editor-font: system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif;--editor-panel-width: 280px;display:block;width:100%;height:100%;font-family:var(--editor-font);font-size:13px;color:var(--editor-text);line-height:1.4}:host([theme=\"dark\"]){--editor-bg: #1f2937;--editor-surface: #374151;--editor-border: #4b5563;--editor-text: #f9fafb;--editor-text-muted: #9ca3af}.editor-container{display:flex;flex-direction:column;width:100%;height:100%;position:relative;overflow:hidden;background:var(--editor-bg)}.layout-desktop .editor-main{display:flex;flex:1;min-height:0}.layout-desktop .canvas-area{flex:1;min-width:0;position:relative;display:flex;flex-direction:column}.layout-desktop .area-panel{width:var(--editor-panel-width);border-left:1px solid var(--editor-border);background:var(--editor-surface);display:none;flex-direction:column;overflow:hidden}.layout-desktop .area-panel.area-panel-visible{display:flex}.layout-mobile .editor-main{display:flex;flex-direction:column;flex:1;min-height:0}.layout-mobile .canvas-area{flex:1;position:relative;display:flex;flex-direction:column;min-height:0}.layout-mobile .area-panel{position:absolute;bottom:0;left:0;right:0;max-height:50%;background:var(--editor-surface);border-top:1px solid var(--editor-border);border-radius:var(--editor-radius) var(--editor-radius) 0 0;box-shadow:0 -4px 20px #00000026;transform:translateY(100%);transition:transform .25s ease-out;z-index:20;display:flex;flex-direction:column;overflow:hidden}.layout-mobile .area-panel.area-panel-visible{transform:translateY(0)}.area-panel-backdrop{display:none}.layout-mobile .area-panel-backdrop{display:block;position:absolute;inset:0;background:#0000004d;z-index:15;opacity:0;pointer-events:none;transition:opacity .25s ease-out}.layout-mobile .area-panel-backdrop.area-panel-backdrop-visible{opacity:1;pointer-events:auto}.zoom-toolbar{display:flex;align-items:center;gap:4px;padding:8px 12px;background:var(--editor-surface);border-bottom:1px solid var(--editor-border)}.zoom-btn{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;border:1px solid var(--editor-border);border-radius:var(--editor-radius-sm);background:var(--editor-surface);color:var(--editor-text);cursor:pointer;font-size:14px;font-family:var(--editor-font);transition:background .15s;-webkit-tap-highlight-color:transparent;touch-action:manipulation}.zoom-btn:hover{background:var(--editor-bg)}.zoom-btn:active{background:var(--editor-border)}.zoom-percent{margin-left:8px;font-size:12px;color:var(--editor-text-muted);min-width:40px}.view-select{margin-left:8px;padding:4px 8px;height:32px;border:1px solid var(--editor-border);border-radius:var(--editor-radius-sm);background:var(--editor-surface);color:var(--editor-text);font-family:var(--editor-font);font-size:12px;cursor:pointer;-webkit-tap-highlight-color:transparent}.view-select:hover{background:var(--editor-bg)}.view-select:focus{outline:2px solid var(--editor-primary);outline-offset:-1px}.zoom-toolbar-spacer{flex:1}.zoom-close-btn{width:auto;padding:0 12px;font-size:13px;gap:4px}.zoom-save-btn{width:auto;padding:0 16px;margin-left:8px;font-size:13px;font-weight:600;background:var(--editor-primary);color:#fff;border-color:var(--editor-primary)}.zoom-save-btn:hover{background:var(--editor-primary-hover)}.zoom-save-btn:disabled{opacity:.5;cursor:not-allowed}.canvas-wrapper{flex:1;position:relative;overflow:hidden;min-height:200px}.editor-canvas{position:absolute;top:0;left:0}.area-panel-header{display:flex;justify-content:space-between;align-items:center;padding:12px 16px;border-bottom:1px solid var(--editor-border);flex-shrink:0}.area-panel-title{font-weight:600;font-size:14px}.area-panel-close-btn{width:28px;height:28px;border:none;background:none;color:var(--editor-text-muted);cursor:pointer;font-size:18px;line-height:1;border-radius:var(--editor-radius-sm);display:flex;align-items:center;justify-content:center}.area-panel-close-btn:hover{background:var(--editor-bg);color:var(--editor-text)}.area-panel-content{flex:1;overflow-y:auto;padding:12px;display:flex;flex-direction:column;gap:12px}.area-panel-empty{color:var(--editor-text-muted);font-size:12px;text-align:center;padding:20px 0}.area-card{padding:12px;border:1px solid var(--editor-border);border-radius:var(--editor-radius);background:var(--editor-surface);cursor:pointer;transition:border-color .15s}.area-card:hover{border-color:var(--editor-primary)}.area-card-selected{border-color:var(--editor-primary);box-shadow:0 0 0 1px var(--editor-primary)}.area-card-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:8px}.area-card-name-row{display:flex;align-items:center;gap:6px}.area-card-name{font-weight:600;font-size:13px}.area-card-badge{display:inline-block;padding:1px 6px;font-size:10px;font-weight:500;background:#fef3c7;color:#92400e;border-radius:10px}.area-card-reset-btn{padding:2px 8px;border:1px solid var(--editor-border);border-radius:var(--editor-radius-sm);background:none;color:var(--editor-text-muted);cursor:pointer;font-size:11px;font-family:var(--editor-font)}.area-card-reset-btn:hover{background:var(--editor-bg);color:var(--editor-danger);border-color:var(--editor-danger)}.area-card-mode-switcher{display:flex;gap:4px;margin-bottom:8px}.mode-btn{flex:1;padding:4px 8px;border:1px solid var(--editor-border);border-radius:var(--editor-radius-sm);background:var(--editor-surface);color:var(--editor-text);cursor:pointer;font-size:12px;font-family:var(--editor-font);transition:all .15s}.mode-btn-active{background:var(--editor-primary);color:#fff;border-color:var(--editor-primary)}.area-input-text{width:100%;padding:6px 8px;border:1px solid var(--editor-border);border-radius:var(--editor-radius-sm);font-family:var(--editor-font);font-size:13px;color:var(--editor-text);background:var(--editor-surface);box-sizing:border-box;margin-bottom:6px}.area-input-text:focus{outline:none;border-color:var(--editor-primary);box-shadow:0 0 0 1px var(--editor-primary)}.area-input-row{display:flex;gap:6px;align-items:center;margin-bottom:6px}.area-input-font{flex:1;padding:4px 6px;border:1px solid var(--editor-border);border-radius:var(--editor-radius-sm);font-family:var(--editor-font);font-size:12px;color:var(--editor-text);background:var(--editor-surface);min-width:0}.area-input-size{width:56px;padding:4px 6px;border:1px solid var(--editor-border);border-radius:var(--editor-radius-sm);font-family:var(--editor-font);font-size:12px;color:var(--editor-text);background:var(--editor-surface)}.area-input-align{display:flex;gap:2px}.align-btn{width:28px;height:28px;border:1px solid var(--editor-border);border-radius:var(--editor-radius-sm);background:var(--editor-surface);color:var(--editor-text);cursor:pointer;font-size:12px;font-weight:600;font-family:var(--editor-font)}.align-btn-active{background:var(--editor-primary);color:#fff;border-color:var(--editor-primary)}.area-input-color{width:32px;height:28px;padding:0;border:1px solid var(--editor-border);border-radius:var(--editor-radius-sm);cursor:pointer;background:none}.area-upload-btn{width:100%;padding:10px;border:2px dashed var(--editor-border);border-radius:var(--editor-radius);background:var(--editor-bg);color:var(--editor-text-muted);cursor:pointer;font-family:var(--editor-font);font-size:12px;text-align:center;transition:all .15s;min-height:44px}.area-upload-btn:hover{border-color:var(--editor-primary);color:var(--editor-primary)}.area-image-preview{display:flex;gap:8px;align-items:center}.area-image-thumb{width:48px;height:48px;object-fit:cover;border-radius:var(--editor-radius-sm);border:1px solid var(--editor-border)}.area-image-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:4px}.area-image-name{font-size:12px;color:var(--editor-text-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.area-image-remove-btn{padding:2px 8px;border:1px solid var(--editor-danger);border-radius:var(--editor-radius-sm);background:none;color:var(--editor-danger);cursor:pointer;font-size:11px;font-family:var(--editor-font);width:fit-content}.area-image-remove-btn:hover{background:#fef2f2}.area-card-divider{height:1px;background:var(--editor-border);margin:8px 0}.transform-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:6px}.transform-title{font-weight:600;font-size:12px}.transform-reset-btn{padding:2px 8px;border:1px solid var(--editor-border);border-radius:var(--editor-radius-sm);background:none;color:var(--editor-text-muted);cursor:pointer;font-size:11px;font-family:var(--editor-font)}.transform-reset-btn:hover{background:var(--editor-bg)}.transform-label{font-size:11px;color:var(--editor-text-muted);white-space:nowrap}.transform-input{width:60px;padding:3px 6px;border:1px solid var(--editor-border);border-radius:var(--editor-radius-sm);font-family:var(--editor-font);font-size:12px;color:var(--editor-text);background:var(--editor-surface)}.transform-slider-row{flex-direction:column;align-items:stretch}.transform-slider{width:100%;accent-color:var(--editor-primary)}.loading-container{display:flex;justify-content:center;align-items:center;width:100%;height:100%;min-height:200px}.loading-spinner{width:32px;height:32px;border:3px solid var(--editor-border);border-top-color:var(--editor-primary);border-radius:50%;animation:spin .8s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}.error-container{display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;height:100%;min-height:200px;padding:20px;text-align:center}.error-title{font-weight:600;font-size:16px;color:var(--editor-danger);margin-bottom:8px}.error-message{font-size:13px;color:var(--editor-text-muted);max-width:400px;white-space:pre-wrap}:host(:focus){outline:2px solid var(--editor-primary);outline-offset:-2px}input:focus,select:focus,button:focus-visible{outline:2px solid var(--editor-primary);outline-offset:-1px}.context-menu{position:absolute;z-index:100;min-width:160px;background:var(--editor-surface);border:1px solid var(--editor-border);border-radius:var(--editor-radius);box-shadow:0 4px 12px #00000026;padding:4px 0;font-size:13px}.context-menu-header{padding:6px 12px;font-weight:600;font-size:12px;color:var(--editor-text-muted);user-select:none}.context-menu-divider{height:1px;background:var(--editor-border);margin:4px 0}.context-menu-item{padding:6px 12px;cursor:pointer;color:var(--editor-text);user-select:none;transition:background .1s}.context-menu-item:hover{background:var(--editor-bg)}.context-menu-item:active{background:var(--editor-border)}.context-menu-item-disabled{color:var(--editor-text-muted);cursor:default;pointer-events:none}.editor-toast{position:absolute;top:16px;left:50%;transform:translate(-50%);padding:10px 20px;border-radius:var(--editor-radius);font-size:13px;font-family:var(--editor-font);line-height:1.4;z-index:200;max-width:400px;text-align:center;animation:toast-in .25s ease-out,toast-out .25s ease-in forwards;animation-delay:0s,var(--toast-duration, 3.75s);pointer-events:none;box-shadow:0 4px 12px #00000026}.editor-toast-warning{background:#fef3c7;color:#92400e;border:1px solid #f59e0b}.editor-toast-error{background:#fef2f2;color:#991b1b;border:1px solid var(--editor-danger)}.editor-toast-info{background:#eff6ff;color:#1e40af;border:1px solid var(--editor-primary)}@keyframes toast-in{0%{opacity:0;transform:translate(-50%) translateY(-10px)}to{opacity:1;transform:translate(-50%) translateY(0)}}@keyframes toast-out{0%{opacity:1;transform:translate(-50%) translateY(0)}to{opacity:0;transform:translate(-50%) translateY(-10px)}}.editor-modal-overlay{position:absolute;inset:0;background:#0006;z-index:300;display:flex;align-items:center;justify-content:center;animation:modal-overlay-in .2s ease-out}@keyframes modal-overlay-in{0%{opacity:0}to{opacity:1}}.editor-modal{background:var(--editor-surface);border-radius:var(--editor-radius);box-shadow:0 8px 32px #0003;max-width:380px;width:calc(100% - 32px);padding:20px;animation:modal-in .2s ease-out}@keyframes modal-in{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}.editor-modal-title{font-weight:600;font-size:15px;margin-bottom:8px;color:var(--editor-text)}.editor-modal-body{font-size:13px;color:var(--editor-text-muted);margin-bottom:16px;line-height:1.5}.editor-modal-actions{display:flex;justify-content:flex-end;gap:8px}.editor-modal-btn{padding:8px 16px;border-radius:var(--editor-radius-sm);font-size:13px;font-family:var(--editor-font);cursor:pointer;border:1px solid var(--editor-border);background:var(--editor-surface);color:var(--editor-text);transition:background .15s}.editor-modal-btn:hover{background:var(--editor-bg)}.editor-modal-btn-primary{background:var(--editor-primary);color:#fff;border-color:var(--editor-primary)}.editor-modal-btn-primary:hover{background:var(--editor-primary-hover)}.area-validation-error{font-size:11px;color:var(--editor-danger);margin-top:4px}@media(pointer:coarse){.zoom-btn{min-width:44px;min-height:44px}.area-input-text,.area-input-font,.area-input-size{min-height:44px;font-size:16px}.align-btn{min-width:44px;min-height:44px}.area-upload-btn{min-height:48px}.view-select{min-height:44px;font-size:16px}}', Q = \"2.0.0\", tt = 768;\nclass et extends HTMLElement {\n constructor() {\n super(), this.resizeObserver = null, this.isReady = !1, this.currentTemplate = null, this.loadingTemplateId = null, this.isMobileLayout = !1, this.productViews = [], this.activeViewName = null, this.perViewContents = /* @__PURE__ */ new Map(), this.subscriptions = [], this.storageUsage = null, this.storageUsageLastRefresh = 0, this.emitChange = $(() => {\n this.dispatchEvent(\n new CustomEvent(\"change\", {\n detail: { design: this.getDesign() },\n bubbles: !0,\n composed: !0\n })\n );\n }, 300), this.shadow = this.attachShadow({ mode: \"open\" });\n }\n static get observedAttributes() {\n return [\"template-id\", \"product-id\", \"theme\", \"mode\", \"store-id\", \"api-url\"];\n }\n async connectedCallback() {\n try {\n this.hasAttribute(\"tabindex\") || this.setAttribute(\"tabindex\", \"0\"), this.renderLoading(), await this.initialize();\n } catch (t) {\n this.showError(\"Failed to initialize editor\", t);\n }\n }\n disconnectedCallback() {\n this.cleanup();\n }\n attributeChangedCallback(t, e, i) {\n e !== i && (t === \"template-id\" && this.isReady && i && this.loadTemplate(i), t === \"product-id\" && this.isReady && i && this.loadProduct(i));\n }\n // ─── Public API ───\n getDesign() {\n if (!this.currentTemplate) throw new Error(\"No design loaded\");\n return {\n templateId: this.currentTemplate.metadata.id,\n engineVersion: Q,\n contents: this.contentManager.toJSON(),\n userData: {}\n };\n }\n setDesign(t) {\n if (t.templateId !== this.currentTemplate?.metadata.id)\n throw new Error(\"Design template ID does not match current template\");\n this.contentManager.fromJSON(t.contents), this.syncEngineContents(), this.stateManager.setState({\n contents: this.contentManager.toJSON(),\n isDirty: !0\n });\n }\n undo() {\n this.stateManager.undo() && this.syncFromState();\n }\n redo() {\n this.stateManager.redo() && this.syncFromState();\n }\n clear() {\n this.contentManager.reset(), this.syncEngineContents(), this.stateManager.setState({\n contents: this.contentManager.toJSON(),\n selectedAreaId: null,\n isDirty: !1\n }), this.zoomToolbar?.showSaveButton(!1), this.engine.setSelectedArea(null), this.inputPanel.setSelectedArea(null), this.engine.fitToView(), this.stateManager.update({\n zoom: this.engine.getZoom(),\n pan: this.engine.getPan()\n });\n }\n selectArea(t) {\n this.handleAreaSelect(t);\n }\n getSelectedAreaId() {\n return this.stateManager.getState().selectedAreaId;\n }\n getActiveView() {\n return this.activeViewName;\n }\n getViews() {\n return this.productViews.map((t) => ({\n viewName: t.viewName,\n viewOrder: t.viewOrder,\n isRequired: t.isRequired,\n isDefault: t.isDefault,\n templateId: t.template.id\n }));\n }\n setActiveView(t) {\n if (this.activeViewName === t) return;\n const e = this.productViews.find((i) => i.viewName === t);\n if (!e) throw new Error(`View not found: ${t}`);\n this.switchToView(e);\n }\n setAreaContent(t, e) {\n e.type === \"text\" ? this.contentManager.setTextContent(t, e) : this.contentManager.setImageContent(t, e.dataUrl, e.filename), this.syncEngineContents(), this.saveContentState();\n }\n getAreaContent(t) {\n return this.contentManager.getContent(t);\n }\n async finalize() {\n const t = this.engine.checkSafeAreaViolations();\n if (t.length > 0) {\n const n = this.currentTemplate?.areas || [], a = t.map((r) => n.find((l) => l.id === r)?.name || r).join(\", \");\n if (!await this.showConfirmation(\n \"Content outside safe area\",\n `Content in ${a} extends beyond the safe area. It may be trimmed during printing. Continue?`,\n \"Cancel\",\n \"Proceed Anyway\"\n ))\n throw new Error(\"Finalization cancelled by user\");\n }\n const e = this.getDesign(), i = this.getAttribute(\"store-id\") || \"demo-shop\", s = await this.apiClient.finalizeDesign(i, e);\n return this.dispatchEvent(\n new CustomEvent(\"customizer:finalize\", {\n detail: {\n designId: s.designId,\n proofUrl: s.proofUrl,\n templateId: e.templateId,\n designJson: e,\n status: s.status\n },\n bubbles: !0,\n composed: !0\n })\n ), s;\n }\n // ─── Initialization ───\n renderLoading() {\n const t = document.createElement(\"style\");\n t.textContent = k, this.shadow.appendChild(t);\n const e = h(\n \"div\",\n { class: \"loading-container\" },\n h(\"div\", { class: \"loading-spinner\" })\n );\n this.shadow.appendChild(e);\n }\n async initialize() {\n const t = this.getAttribute(\"api-url\") || \"http://localhost:4000\";\n this.apiClient = new Z(`${t.replace(/\\/+$/, \"\")}/public`);\n const e = this.getAttribute(\"product-id\"), i = this.getAttribute(\"template-id\");\n if (!e && !i)\n throw new Error(\"Either template-id or product-id attribute is required\");\n e ? await this.loadProduct(e) : await this.loadTemplate(i), this.isReady = !0, this.dispatchEvent(new CustomEvent(\"ready\", { bubbles: !0, composed: !0 }));\n }\n async loadTemplate(t) {\n if (this.loadingTemplateId !== t) {\n this.loadingTemplateId = t;\n try {\n const e = await this.apiClient.getTemplate(t);\n if (this.loadingTemplateId !== t) return;\n await this.loadTemplateData(e), this.loadingTemplateId = null;\n } catch (e) {\n throw this.loadingTemplateId = null, new Error(`Failed to load template: ${e.message}`);\n }\n }\n }\n async loadTemplateData(t) {\n this.currentTemplate = t;\n const e = t.areas || [];\n this.contentManager = new A(e);\n const i = {\n template: t,\n contents: this.contentManager.toJSON(),\n selectedAreaId: null,\n zoom: 1,\n pan: { x: 0, y: 0 },\n isDirty: !1,\n warnings: []\n };\n this.stateManager = new B(i), this.buildUI(t, e), this.engine = new N(this.canvas), this.engine.setArtboard({\n width: t.artboard.width,\n height: t.artboard.height,\n backgroundColor: t.artboard.backgroundColor ?? \"#ffffff\"\n }), this.engine.setAreas(e), this.engine.setContents(this.contentManager.getContents()), t.backgroundImage && this.engine.setBackgroundImage(t.backgroundImage);\n const s = t.artboard.safeArea ?? t.safeArea;\n s && this.engine.setSafeArea(s), this.engine.start(), this.engine.fitToView(), this.stateManager.update({\n zoom: this.engine.getZoom(),\n pan: this.engine.getPan()\n }), this.zoomToolbar.setZoom(this.engine.getZoom()), this.interaction = new F(\n this.canvas,\n this.engine,\n () => this.contentManager.getContents(),\n () => this.stateManager.getState().selectedAreaId\n ), this.wireInteractionEvents(), this.subscriptions.push(\n this.contentManager.subscribe(() => {\n this.syncEngineContents(), this.inputPanel.setContents(this.contentManager.getContents());\n })\n ), this.keyboard = new G(this), this.setupKeyboardShortcuts(), this.inputPanel.setContents(this.contentManager.getContents());\n const n = this.getAttribute(\"store-id\");\n n && this.apiClient.getStorageUsage(n).then((a) => {\n this.storageUsage = a, a.usagePercent >= 100 ? this.showToast(\"Storage quota exceeded. Upgrade your plan for more storage.\", \"error\") : a.usagePercent >= 80 && this.showToast(`Storage ${a.usagePercent}% full. Consider upgrading your plan.`, \"warning\");\n }).catch(() => {\n });\n }\n async loadProduct(t) {\n try {\n const e = await this.apiClient.getProduct(t);\n if (e.views.length === 0)\n throw new Error(\"Product has no active templates\");\n this.productViews = e.views, this.perViewContents.clear();\n const i = e.views.find((s) => s.isDefault) || e.views[0];\n await this.loadTemplateData(i.template.templateJson), this.activeViewName = i.viewName, this.zoomToolbar && e.views.length > 1 && (this.zoomToolbar.setViews(this.getViews()), this.zoomToolbar.setActiveView(i.viewName));\n } catch (e) {\n throw new Error(`Failed to load product: ${e.message}`);\n }\n }\n switchToView(t) {\n this.activeViewName && this.contentManager && this.perViewContents.set(this.activeViewName, this.contentManager.toJSON()), this.activeViewName = t.viewName, this.zoomToolbar?.setActiveView(t.viewName);\n const e = t.template.templateJson;\n this.currentTemplate = e;\n const i = e.areas || [];\n this.contentManager = new A(i);\n const s = this.perViewContents.get(t.viewName);\n s && this.contentManager.fromJSON(s), this.engine.setArtboard({\n width: e.artboard.width,\n height: e.artboard.height,\n backgroundColor: e.artboard.backgroundColor ?? \"#ffffff\"\n }), this.engine.setAreas(i), this.engine.setContents(this.contentManager.getContents()), this.engine.setBackgroundImage(e.backgroundImage ?? void 0);\n const n = e.artboard.safeArea ?? e.safeArea;\n this.engine.setSafeArea(n ?? null), this.engine.fitToView(), this.stateManager.setState({\n template: e,\n contents: this.contentManager.toJSON(),\n selectedAreaId: null,\n isDirty: this.stateManager.getState().isDirty,\n zoom: this.engine.getZoom(),\n pan: this.engine.getPan(),\n warnings: []\n }), this.zoomToolbar.setZoom(this.engine.getZoom()), this.inputPanel.setAreas(i), this.inputPanel.setContents(this.contentManager.getContents()), this.inputPanel.setSelectedArea(null), this.engine.setSelectedArea(null), this.dispatchEvent(\n new CustomEvent(\"view-change\", {\n detail: { viewName: t.viewName },\n bubbles: !0,\n composed: !0\n })\n );\n }\n buildUI(t, e) {\n this.shadow.innerHTML = \"\";\n const i = document.createElement(\"style\");\n i.textContent = k, this.shadow.appendChild(i), this.container = h(\"div\", { class: \"editor-container\" }), this.zoomToolbar = new V(), this.subscriptions.push(this.zoomToolbar.on(\"zoom-in\", () => this.handleZoomIn())), this.subscriptions.push(this.zoomToolbar.on(\"zoom-out\", () => this.handleZoomOut())), this.subscriptions.push(this.zoomToolbar.on(\"zoom-fit\", () => this.handleZoomFit())), this.subscriptions.push(this.zoomToolbar.on(\"view-change\", ({ viewName: a }) => {\n const o = this.productViews.find((r) => r.viewName === a);\n o && this.switchToView(o);\n })), this.subscriptions.push(this.zoomToolbar.on(\"close\", () => {\n this.dispatchEvent(new CustomEvent(\"customizer:close\", {\n bubbles: !0,\n composed: !0\n }));\n })), this.subscriptions.push(this.zoomToolbar.on(\"save\", async () => {\n this.zoomToolbar.setSaveDisabled(!0, \"Saving...\");\n try {\n await this.finalize(), this.zoomToolbar.setSaveDisabled(!0, \"Saved!\"), this.showToast(\"Design saved successfully!\", \"info\"), setTimeout(() => {\n this.zoomToolbar.setSaveDisabled(!1, \"Save Customization\"), this.zoomToolbar.showSaveButton(!1), this.stateManager.update({ isDirty: !1 });\n }, 2e3);\n } catch (a) {\n console.error(\"Customizer: finalize failed\", a);\n const o = a instanceof Error ? a.message : \"Save failed. Please try again.\";\n this.showToast(o, \"error\"), this.zoomToolbar.setSaveDisabled(!1, \"Save Customization\");\n }\n }));\n const s = h(\"div\", { class: \"canvas-area\" });\n s.appendChild(this.zoomToolbar.getElement()), this.canvasWrapper = h(\"div\", { class: \"canvas-wrapper\" }), this.canvas = document.createElement(\"canvas\"), this.canvas.className = \"editor-canvas\", this.canvasWrapper.appendChild(this.canvas), s.appendChild(this.canvasWrapper), this.inputPanel = new q(e), this.wireInputPanelEvents();\n const n = h(\"div\", { class: \"editor-main\" });\n n.appendChild(s), n.appendChild(this.inputPanel.getBackdrop()), n.appendChild(this.inputPanel.getElement()), this.container.appendChild(n), this.shadow.appendChild(this.container), this.resizeObserver = new ResizeObserver((a) => {\n for (const o of a)\n o.target === this.canvasWrapper && this.handleCanvasResize(o.contentRect), o.target === this.container && this.handleLayoutResize(o.contentRect);\n }), this.resizeObserver.observe(this.canvasWrapper), this.resizeObserver.observe(this.container);\n }\n // ─── Event Wiring ───\n wireInteractionEvents() {\n this.subscriptions.push(\n this.interaction.on(\"area:select\", ({ areaId: t }) => {\n this.handleAreaSelect(t);\n })\n ), this.subscriptions.push(\n this.interaction.on(\"content:drag\", ({ areaId: t, offset: e }) => {\n this.contentManager.setContentOffset(t, e), this.saveContentState();\n })\n ), this.subscriptions.push(\n this.interaction.on(\"content:scale\", ({ areaId: t, scale: e }) => {\n this.contentManager.setImageScale(t, e), this.saveContentState();\n })\n ), this.subscriptions.push(\n this.interaction.on(\"content:rotate\", ({ areaId: t, rotation: e }) => {\n this.contentManager.setImageRotation(t, e), this.saveContentState();\n })\n ), this.subscriptions.push(\n this.interaction.on(\"zoom\", ({ zoom: t }) => {\n this.engine.setZoom(t);\n const e = this.engine.getCenteredPan(t);\n e && this.engine.setPan(e), this.stateManager.update({ zoom: this.engine.getZoom(), pan: this.engine.getPan() }), this.zoomToolbar.setZoom(this.engine.getZoom());\n })\n ), this.subscriptions.push(\n this.interaction.on(\"pan\", ({ pan: t }) => {\n this.engine.setPan(t), this.stateManager.update({ pan: t });\n })\n ), this.subscriptions.push(\n this.interaction.on(\"cursor\", ({ cursor: t }) => {\n this.canvas.style.cursor = t;\n })\n ), this.subscriptions.push(\n this.interaction.on(\"context-menu\", ({ areaId: t, clientX: e, clientY: i }) => {\n this.handleContextMenu(t, e, i);\n })\n );\n }\n wireInputPanelEvents() {\n this.subscriptions.push(\n this.inputPanel.on(\"text:change\", ({ areaId: t, updates: e }) => {\n this.contentManager.setTextContent(t, e), this.saveContentState();\n })\n ), this.subscriptions.push(\n this.inputPanel.on(\"image:change\", async ({ areaId: t, dataUrl: e, filename: i }) => {\n const s = this.contentManager.getContents();\n let n = 0;\n for (const [o, r] of s)\n r.type === \"image\" && o !== t && n++;\n if (n >= 10) {\n this.showToast(\"Maximum of 10 images per design reached\", \"error\");\n return;\n }\n if (await this.refreshStorageUsage(), this.storageUsage && this.storageUsage.usagePercent >= 100) {\n this.showToast(\"Storage quota exceeded. Upgrade your plan for more storage.\", \"error\");\n return;\n }\n const a = this.currentTemplate?.areas.find((o) => o.id === t);\n if (a && this.currentTemplate) {\n const o = this.currentTemplate.print.targetDpi;\n try {\n const r = new Image(), l = await new Promise((p, g) => {\n r.onload = () => p({ width: r.naturalWidth, height: r.naturalHeight }), r.onerror = () => g(new Error(\"Failed to load image\")), r.src = e;\n }), d = a.location.width / o, c = a.location.height / o, u = _(\n l.width,\n l.height,\n d,\n c,\n o\n );\n if (u.actualDPI < 150) {\n if (!await this.showConfirmation(\n \"Low resolution detected\",\n `This image is ${u.actualDPI} DPI at print size. Print may appear blurry. Recommended: ${o} DPI.`,\n \"Cancel\",\n \"Use Anyway\"\n )) return;\n } else u.actualDPI < o && (this.showToast(\n `Image resolution is ${u.actualDPI} DPI (${o} recommended)`,\n \"warning\"\n ), this.stateManager.update({\n warnings: [\n ...this.stateManager.getState().warnings,\n { type: \"dpi\", message: `${u.actualDPI} DPI`, areaId: t }\n ]\n }));\n } catch {\n }\n }\n if (this.contentManager.setImageContent(t, e, i), this.saveContentState(), this.storageUsage) {\n const o = Math.round(e.length * 0.75);\n this.storageUsage.storageUsed += o, this.storageUsage.usagePercent = this.storageUsage.storageQuota > 0 ? Math.round(this.storageUsage.storageUsed / this.storageUsage.storageQuota * 100) : 0;\n }\n })\n ), this.subscriptions.push(\n this.inputPanel.on(\"validation:error\", ({ message: t }) => {\n this.showToast(t, \"error\");\n })\n ), this.subscriptions.push(\n this.inputPanel.on(\"clear\", ({ areaId: t }) => {\n this.contentManager.clearContent(t), this.saveContentState();\n })\n ), this.subscriptions.push(\n this.inputPanel.on(\"select\", ({ areaId: t }) => {\n this.handleAreaSelect(t);\n })\n ), this.subscriptions.push(\n this.inputPanel.on(\"offset:change\", ({ areaId: t, offset: e }) => {\n this.contentManager.setContentOffset(t, e), this.saveContentState();\n })\n ), this.subscriptions.push(\n this.inputPanel.on(\"scale:change\", ({ areaId: t, scale: e }) => {\n this.contentManager.setImageScale(t, e), this.saveContentState();\n })\n ), this.subscriptions.push(\n this.inputPanel.on(\"rotation:change\", ({ areaId: t, rotation: e }) => {\n this.contentManager.setImageRotation(t, e), this.saveContentState();\n })\n ), this.subscriptions.push(\n this.inputPanel.on(\"dismiss\", () => {\n this.handleAreaSelect(null);\n })\n );\n }\n // ─── Handlers ───\n handleAreaSelect(t, e = !1) {\n this.stateManager.update({ selectedAreaId: t }), this.engine.setSelectedArea(t), this.inputPanel.setSelectedArea(e ? t : null), t && document.activeElement !== this && this.focus(), this.dispatchEvent(\n new CustomEvent(\"area:select\", {\n detail: { areaId: t },\n bubbles: !0,\n composed: !0\n })\n );\n }\n handleContextMenu(t, e, i) {\n this.handleAreaSelect(t, !!t);\n }\n handleZoomIn() {\n const t = this.engine.getZoom(), e = Math.min(t * 1.25, 5), i = this.engine.getCenteredPan(e);\n this.engine.setZoom(e), i && this.engine.setPan(i), this.stateManager.update({ zoom: this.engine.getZoom(), pan: this.engine.getPan() }), this.zoomToolbar.setZoom(this.engine.getZoom());\n }\n handleZoomOut() {\n const t = this.engine.getZoom(), e = Math.max(t * 0.8, 0.1), i = this.engine.getCenteredPan(e);\n this.engine.setZoom(e), i && this.engine.setPan(i), this.stateManager.update({ zoom: this.engine.getZoom(), pan: this.engine.getPan() }), this.zoomToolbar.setZoom(this.engine.getZoom());\n }\n handleZoomFit() {\n this.engine.fitToView(), this.stateManager.update({ zoom: this.engine.getZoom(), pan: this.engine.getPan() }), this.zoomToolbar.setZoom(this.engine.getZoom());\n }\n handleCanvasResize(t) {\n const { width: e, height: i } = t;\n if (e === 0 || i === 0) return;\n const s = window.devicePixelRatio || 1;\n this.canvas.width = e * s, this.canvas.height = i * s, this.canvas.style.width = `${e}px`, this.canvas.style.height = `${i}px`, this.engine && (this.engine.fitToView(), this.stateManager.update({ zoom: this.engine.getZoom(), pan: this.engine.getPan() }), this.zoomToolbar.setZoom(this.engine.getZoom()));\n }\n handleLayoutResize(t) {\n const e = t.width < tt;\n this.container.classList.toggle(\"layout-desktop\", !e), this.container.classList.toggle(\"layout-mobile\", e), e !== this.isMobileLayout && (this.isMobileLayout = e, this.inputPanel.setMobile(e));\n }\n // ─── State Management ───\n async refreshStorageUsage() {\n if (Date.now() - this.storageUsageLastRefresh < 3e4) return;\n const t = this.getAttribute(\"store-id\");\n if (t)\n try {\n this.storageUsage = await this.apiClient.getStorageUsage(t), this.storageUsageLastRefresh = Date.now();\n } catch {\n }\n }\n saveContentState() {\n this.stateManager.setState({\n contents: this.contentManager.toJSON(),\n isDirty: !0\n }), this.zoomToolbar?.showSaveButton(!0), this.engine.checkSafeAreaViolations(), this.emitChange();\n }\n syncEngineContents() {\n this.engine?.setContents(this.contentManager.getContents());\n }\n syncFromState() {\n const t = this.stateManager.getState();\n this.contentManager.setContentsQuiet(t.contents), this.syncEngineContents(), this.inputPanel.setContents(this.contentManager.getContents()), this.engine.setSelectedArea(t.selectedAreaId), this.inputPanel.setSelectedArea(t.selectedAreaId);\n }\n // ─── Keyboard ───\n setupKeyboardShortcuts() {\n const t = J();\n this.keyboard.register({\n key: \"z\",\n [t]: !0,\n handler: () => this.undo()\n }), this.keyboard.register({\n key: \"z\",\n [t]: !0,\n shift: !0,\n handler: () => this.redo()\n }), this.keyboard.register({\n key: \"Escape\",\n handler: () => this.handleAreaSelect(null)\n });\n }\n // ─── Toast & Modal ───\n showToast(t, e = \"info\") {\n const i = h(\"div\", { class: `editor-toast editor-toast-${e}` }, t);\n this.shadow.appendChild(i), setTimeout(() => i.remove(), 4e3);\n }\n showConfirmation(t, e, i = \"Cancel\", s = \"Continue\") {\n return new Promise((n) => {\n const a = h(\"div\", { class: \"editor-modal-overlay\" }), o = h(\"div\", { class: \"editor-modal\" });\n o.appendChild(h(\"div\", { class: \"editor-modal-title\" }, t)), o.appendChild(h(\"div\", { class: \"editor-modal-body\" }, e));\n const r = h(\"div\", { class: \"editor-modal-actions\" }), l = h(\"button\", { class: \"editor-modal-btn\" }, i);\n l.addEventListener(\"click\", () => {\n a.remove(), n(!1);\n });\n const d = h(\"button\", { class: \"editor-modal-btn editor-modal-btn-primary\" }, s);\n d.addEventListener(\"click\", () => {\n a.remove(), n(!0);\n }), r.appendChild(l), r.appendChild(d), o.appendChild(r), a.appendChild(o), a.addEventListener(\"click\", (c) => {\n c.target === a && (a.remove(), n(!1));\n }), this.shadow.appendChild(a);\n });\n }\n // ─── Error / Cleanup ───\n showError(t, e) {\n this.shadow.innerHTML = \"\";\n const i = document.createElement(\"style\");\n i.textContent = k, this.shadow.appendChild(i);\n const s = h(\"div\", { class: \"error-container\" });\n s.appendChild(h(\"div\", { class: \"error-title\" }, t)), s.appendChild(h(\"div\", { class: \"error-message\" }, e?.message ?? \"\")), this.shadow.appendChild(s), this.dispatchEvent(\n new CustomEvent(\"error\", {\n detail: { message: t, error: e },\n bubbles: !0,\n composed: !0\n })\n );\n }\n cleanup() {\n for (const t of this.subscriptions)\n t();\n this.subscriptions = [], this.resizeObserver && (this.resizeObserver.disconnect(), this.resizeObserver = null), this.engine?.destroy(), this.interaction?.destroy(), this.keyboard?.destroy(), this.isReady = !1, this.currentTemplate = null, this.productViews = [], this.activeViewName = null, this.perViewContents.clear();\n }\n}\ncustomElements.get(\"customizer-editor\") || customElements.define(\"customizer-editor\", et);\nexport {\n et as CustomizerEditor\n};\n//# sourceMappingURL=customizer.esm.js.map\n","/**\n * Vanilla JavaScript SDK for Customizer Editor\n * @packageDocumentation\n */\n\n// Side-effect: registers <customizer-editor> web component.\n// Using namespace import so tsc omits it from .d.ts (value-only usage).\nimport * as _editorModule from '@customizer/editor';\nvoid _editorModule;\nimport type {\n CustomizerOptions,\n CustomizerInstance,\n DesignJSON,\n FinalizeResult,\n CustomizerError,\n CustomizerEditorElement,\n ViewInfo,\n} from '../types';\n\n/**\n * Initialize the customizer editor\n *\n * @param elementOrSelector - DOM element or CSS selector where to mount the editor\n * @param options - Configuration options\n * @returns CustomizerInstance with methods to control the editor\n *\n * @example\n * ```typescript\n * import { initCustomizer } from '@varianta/sdk';\n *\n * const editor = initCustomizer('#editor', {\n * templateId: 'tshirt-001',\n * theme: 'light',\n * onReady: () => console.log('Editor ready!'),\n * onChange: (design) => console.log('Design changed:', design),\n * });\n *\n * // Get current design\n * const design = editor.getDesign();\n *\n * // Finalize design\n * const result = await editor.finalize();\n * ```\n */\nexport function initCustomizer(\n elementOrSelector: HTMLElement | string,\n options: CustomizerOptions\n): CustomizerInstance {\n // Resolve the container element\n const container =\n typeof elementOrSelector === 'string'\n ? document.querySelector<HTMLElement>(elementOrSelector)\n : elementOrSelector;\n\n if (!container) {\n throw new Error(\n `Container not found: ${\n typeof elementOrSelector === 'string'\n ? elementOrSelector\n : 'provided element is null'\n }`\n );\n }\n\n // Validate that exactly one of templateId or productId is provided\n if (!options.templateId && !options.productId) {\n throw new Error('Either templateId or productId must be provided');\n }\n if (options.templateId && options.productId) {\n throw new Error('Only one of templateId or productId should be provided, not both');\n }\n\n // Create the editor element\n const editorElement = document.createElement('customizer-editor') as unknown as CustomizerEditorElement;\n\n // Set attributes\n if (options.productId) {\n editorElement.setAttribute('product-id', options.productId);\n } else {\n editorElement.setAttribute('template-id', options.templateId!);\n }\n if (options.theme) {\n editorElement.setAttribute('theme', options.theme);\n }\n if (options.mode) {\n editorElement.setAttribute('mode', options.mode);\n }\n if (options.className) {\n editorElement.classList.add(options.className);\n }\n\n // Apply custom styles if needed\n editorElement.style.width = '100%';\n editorElement.style.height = '100%';\n\n // Event listeners tracking\n const listeners: Array<{ event: string; handler: EventListener }> = [];\n\n const addEventListener = (event: string, handler: EventListener) => {\n editorElement.addEventListener(event, handler);\n listeners.push({ event, handler });\n };\n\n // Mount the editor first\n container.innerHTML = '';\n container.appendChild(editorElement);\n\n // Create the instance API BEFORE setting up event handlers\n const instance: CustomizerInstance = {\n getDesign(): DesignJSON {\n if (typeof editorElement.getDesign !== 'function') {\n throw new Error('Editor not ready: getDesign method not available');\n }\n return editorElement.getDesign();\n },\n\n setDesign(design: DesignJSON): void {\n if (typeof editorElement.setDesign !== 'function') {\n throw new Error('Editor not ready: setDesign method not available');\n }\n editorElement.setDesign(design);\n },\n\n undo(): void {\n if (typeof editorElement.undo !== 'function') {\n throw new Error('Editor not ready: undo method not available');\n }\n editorElement.undo();\n },\n\n redo(): void {\n if (typeof editorElement.redo !== 'function') {\n throw new Error('Editor not ready: redo method not available');\n }\n editorElement.redo();\n },\n\n canUndo(): boolean {\n if (typeof editorElement.canUndo !== 'function') {\n return false;\n }\n return editorElement.canUndo();\n },\n\n canRedo(): boolean {\n if (typeof editorElement.canRedo !== 'function') {\n return false;\n }\n return editorElement.canRedo();\n },\n\n async finalize(): Promise<FinalizeResult> {\n const design = this.getDesign();\n const apiUrl = options.apiUrl || 'https://api.varianta.io';\n\n try {\n const response = await fetch(`${apiUrl}/public/finalize`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n templateId: (design as any).templateId || options.templateId,\n designJson: design,\n }),\n });\n\n if (!response.ok) {\n const error = await response.json().catch(() => ({\n message: 'Finalization failed',\n }));\n throw new Error(error.message || 'Finalization failed');\n }\n\n const body = await response.json();\n let result: FinalizeResult = {\n designId: body.designId,\n status: body.status,\n proofUrl: body.proofUrl ?? null,\n errorMessage: body.errorMessage ?? null,\n };\n\n // Poll until the render completes (or fails)\n const POLL_INTERVAL = 1500;\n const MAX_POLLS = 40; // ~60 s total\n let polls = 0;\n\n while (result.status === 'processing' && polls < MAX_POLLS) {\n await new Promise((r) => setTimeout(r, POLL_INTERVAL));\n polls++;\n\n const statusRes = await fetch(\n `${apiUrl}/public/designs/${result.designId}/status`,\n );\n if (!statusRes.ok) {\n throw new Error('Failed to check design status');\n }\n const statusBody = await statusRes.json();\n result = {\n designId: statusBody.designId,\n status: statusBody.status,\n proofUrl: statusBody.proofUrl ?? null,\n errorMessage: statusBody.errorMessage ?? null,\n };\n }\n\n if (result.status === 'processing') {\n result = { ...result, status: 'failed', errorMessage: 'Render timed out' };\n }\n\n if (options.onFinalize) {\n options.onFinalize(result);\n }\n\n return result;\n } catch (error) {\n const customizerError: CustomizerError = {\n code: 'FINALIZE_ERROR',\n message: error instanceof Error ? error.message : 'Unknown error',\n details: error,\n };\n\n if (options.onError) {\n options.onError(customizerError);\n }\n\n throw error;\n }\n },\n\n addTextLayer(text?: string): void {\n if (typeof editorElement.addTextLayer !== 'function') {\n throw new Error('Editor not ready: addTextLayer method not available');\n }\n editorElement.addTextLayer(text);\n },\n\n async addImageLayer(url: string): Promise<void> {\n if (typeof editorElement.addImageLayer !== 'function') {\n throw new Error('Editor not ready: addImageLayer method not available');\n }\n return editorElement.addImageLayer(url);\n },\n\n removeLayer(layerId: string): void {\n if (typeof editorElement.removeLayer !== 'function') {\n throw new Error('Editor not ready: removeLayer method not available');\n }\n editorElement.removeLayer(layerId);\n },\n\n selectLayer(layerId: string | null): void {\n if (typeof editorElement.selectLayer !== 'function') {\n throw new Error('Editor not ready: selectLayer method not available');\n }\n editorElement.selectLayer(layerId);\n },\n\n getSelectedLayerId(): string | null {\n if (typeof editorElement.getSelectedLayerId !== 'function') {\n return null;\n }\n return editorElement.getSelectedLayerId();\n },\n\n getActiveView(): string | null {\n if (typeof editorElement.getActiveView !== 'function') {\n return null;\n }\n return editorElement.getActiveView();\n },\n\n getViews(): ViewInfo[] {\n if (typeof editorElement.getViews !== 'function') {\n return [];\n }\n return editorElement.getViews();\n },\n\n setActiveView(viewName: string): void {\n if (typeof editorElement.setActiveView !== 'function') {\n throw new Error('Editor not ready: setActiveView method not available');\n }\n editorElement.setActiveView(viewName);\n },\n\n setTheme(theme: 'light' | 'dark'): void {\n editorElement.setAttribute('theme', theme);\n },\n\n setMode(mode: 'edit' | 'preview'): void {\n editorElement.setAttribute('mode', mode);\n },\n\n destroy(): void {\n // Remove all event listeners\n listeners.forEach(({ event, handler }) => {\n editorElement.removeEventListener(event, handler);\n });\n\n // Remove the element from DOM\n if (editorElement.parentNode) {\n editorElement.parentNode.removeChild(editorElement);\n }\n },\n\n getElement(): HTMLElement {\n return editorElement;\n },\n };\n\n // NOW set up event handlers (after instance is fully created)\n if (options.onReady) {\n addEventListener('ready', (() => {\n options.onReady?.(instance);\n }) as EventListener);\n }\n\n if (options.onChange) {\n addEventListener('change', ((e: CustomEvent) => {\n const design = e.detail.design;\n options.onChange?.(design);\n }) as EventListener);\n }\n\n if (options.onLayerSelect) {\n addEventListener('layer:select', ((e: CustomEvent) => {\n options.onLayerSelect?.(e.detail.layerId);\n }) as EventListener);\n }\n\n if (options.onLayerAdd) {\n addEventListener('layer:add', ((e: CustomEvent) => {\n options.onLayerAdd?.(e.detail.layerId);\n }) as EventListener);\n }\n\n if (options.onLayerRemove) {\n addEventListener('layer:remove', ((e: CustomEvent) => {\n options.onLayerRemove?.(e.detail.layerId);\n }) as EventListener);\n }\n\n if (options.onLayerUpdate) {\n addEventListener('layer:update', ((e: CustomEvent) => {\n options.onLayerUpdate?.(e.detail.layerId);\n }) as EventListener);\n }\n\n if (options.onError) {\n addEventListener('error', ((e: CustomEvent) => {\n const error: CustomizerError = e.detail.error;\n options.onError?.(error);\n }) as EventListener);\n }\n\n if (options.onViewChange) {\n addEventListener('view-change', ((e: CustomEvent) => {\n options.onViewChange?.(e.detail.viewName);\n }) as EventListener);\n }\n\n // Set initial design if provided\n if (options.initialDesign) {\n // Wait for the editor to be ready before setting the design\n editorElement.addEventListener(\n 'ready',\n () => {\n if (options.initialDesign) {\n editorElement.setDesign(options.initialDesign);\n }\n },\n { once: true }\n );\n }\n\n if (options.debug) {\n console.log('[Customizer SDK] Initialized with options:', options);\n console.log('[Customizer SDK] Instance:', instance);\n }\n\n return instance;\n}\n\n/**\n * Re-export types for convenience\n */\nexport type * from '../types';\n"],"names":["t","e","s","n","a","o","l","d","b","y","w","v","x","C","S","z","T","u","p","g","m","O","M","P","H","B","A","U","Z","$","V","Y","W","L","X","R","q","G","j","K","_","k","tt","et","r","initCustomizer","elementOrSelector","options","container","editorElement","listeners","addEventListener","event","handler","instance","design","apiUrl","response","error","body","result","POLL_INTERVAL","MAX_POLLS","polls","statusRes","statusBody","customizerError","text","url","layerId","viewName","theme","mode"],"mappings":"gFAAA,MAAM,CAAE,CACN,YAAYA,EAAG,CACb,KAAK,iBAAmB,KAAM,KAAK,YAAc,GAAI,KAAK,MAAQ,CAAA,EAAI,KAAK,SAA2B,IAAI,IAAO,KAAK,SAAW,KAAM,KAAK,eAAiB,KAAM,KAAK,aAA+B,IAAI,IAAO,KAAK,cAAgC,IAAI,IAAO,KAAK,KAAO,EAAG,KAAK,IAAM,CAAE,EAAG,EAAG,EAAG,CAAC,EAAI,KAAK,eAAiB,KAAM,KAAK,cAAgB,KAAM,KAAK,eAAiC,IAAI,IAAO,KAAK,SAAW,KAAM,KAAK,mBAAqC,IAAI,IAAO,KAAK,gBAAkB,GAAI,KAAK,qBAAuB,GAAI,KAAK,WAAa,IAAM,CAChjB,GAAI,CACF,KAAK,cAAgB,KAAK,OAAM,EAAI,KAAK,YAAc,GAAI,KAAK,KAAK,SAAU,MAAM,EACvF,OAAS,EAAG,CACV,QAAQ,MAAM,wBAAyB,CAAC,CAC1C,CACA,KAAK,iBAAmB,sBAAsB,KAAK,UAAU,CAC/D,EAAG,KAAK,OAASA,EACjB,MAAMC,EAAID,EAAE,WAAW,IAAI,EAC3B,GAAI,CAACC,EACH,MAAM,IAAI,MAAM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