@varianta/sdk 0.1.4 → 0.1.6

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.
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.umd.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":["N","t","e","s","n","a","o","l","d","b","y","w","v","x","C","S","z","u","p","g","m","T","D","O","E","M","H","B","A","I","F","Z","$","V","Y","W","L","X","R","G","J","K","_","Q","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":"sOAAA,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,IA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