@wewear/virtual-try-on 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/widget.ts","../src/installer.ts"],"sourcesContent":["/**\n * WeWear Virtual Try-On Widget Implementation\n *\n * Core widget class that handles virtual try-on functionality integration.\n * Manages button creation, API communication, and modal display.\n */\n\nimport type { VirtualTryOnConfig, VirtualTryOnResult } from \"./index.js\";\n\n/** Default configuration constants */\nconst DEFAULT_CONFIG = {\n BASE_URL: \"https://virtual-try-on-widget.vercel.app\",\n PRODUCT_PAGE_SELECTOR: \"/product/\",\n GALLERY_SELECTOR: \".woocommerce-product-gallery__image\",\n SKU_SELECTOR: \".sku\",\n BUTTON_POSITION: \"bottom-right\" as const,\n} as const;\n\n/** CSS class names for consistent styling */\nconst CSS_CLASSES = {\n BUTTON_CONTAINER: \"wewear-vto-button-container\",\n BUTTON: \"wewear-vto-button\",\n MODAL: \"wewear-vto-modal\",\n} as const;\n\n/** Z-index values for proper layering */\nconst Z_INDEX = {\n BUTTON: 10,\n MODAL: 99999,\n} as const;\n\nexport class VirtualTryOnWidget {\n private readonly config: Required<VirtualTryOnConfig>;\n\n constructor(config: VirtualTryOnConfig = {}) {\n this.config = {\n baseUrl: config.baseUrl || DEFAULT_CONFIG.BASE_URL,\n productPageSelector:\n config.productPageSelector || DEFAULT_CONFIG.PRODUCT_PAGE_SELECTOR,\n gallerySelector:\n config.gallerySelector || DEFAULT_CONFIG.GALLERY_SELECTOR,\n skuSelector: config.skuSelector || DEFAULT_CONFIG.SKU_SELECTOR,\n buttonPosition: config.buttonPosition || DEFAULT_CONFIG.BUTTON_POSITION,\n };\n }\n\n /**\n * Retrieves a cookie value by name\n * @param name - Cookie name to retrieve\n * @returns Cookie value or null if not found\n */\n private getCookie(name: string): string | null {\n if (typeof document === \"undefined\") return null;\n\n const value = `; ${document.cookie}`;\n const parts = value.split(`; ${name}=`);\n\n if (parts.length === 2) {\n const part = parts.pop();\n return part ? part.split(\";\").shift()?.trim() || null : null;\n }\n\n return null;\n }\n\n /**\n * Makes API call to virtual try-on service\n * @param ww_access_token - Optional authentication token\n * @param ww_user_id - User identifier\n * @param ww_product_id - Product identifier\n * @returns Promise with virtual try-on result or null if failed\n */\n private async callVirtualTryOnApi(\n ww_access_token: string | null,\n ww_user_id: string,\n ww_product_id: string,\n ): Promise<VirtualTryOnResult | null> {\n try {\n const response = await fetch(\n `${this.config.baseUrl}/api/virtual-try-on`,\n {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n },\n body: JSON.stringify({\n ww_access_token,\n ww_user_id,\n ww_product_id,\n }),\n },\n );\n\n if (!response.ok) {\n throw new Error(\n `API responded with status ${response.status}: ${response.statusText}`,\n );\n }\n\n const result = await response.json();\n\n if (!result.imageUrl) {\n throw new Error(\"API response missing imageUrl\");\n }\n\n return result;\n } catch (error) {\n console.error(\"[WeWear VTO] API call failed:\", error);\n return null;\n }\n }\n\n /**\n * Creates the virtual try-on button element\n * @param onClick - Click handler function\n * @returns Button container element\n */\n private createButton(onClick: () => void): HTMLElement {\n const container = document.createElement(\"div\");\n container.className = CSS_CLASSES.BUTTON_CONTAINER;\n\n const positionStyles = this.getPositionStyles();\n container.style.cssText = `\n position: absolute;\n ${positionStyles}\n display: flex;\n border-radius: 50%;\n background: #000000;\n padding: 4px;\n box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);\n z-index: ${Z_INDEX.BUTTON};\n transition: transform 0.2s ease, box-shadow 0.2s ease;\n `;\n\n const button = document.createElement(\"button\");\n button.type = \"button\";\n button.className = CSS_CLASSES.BUTTON;\n button.setAttribute(\"aria-label\", \"Virtual Try-On\");\n button.setAttribute(\"title\", \"Try this product virtually\");\n button.style.cssText = `\n display: flex;\n width: 36px;\n height: 36px;\n cursor: pointer;\n align-items: center;\n justify-content: center;\n border-radius: 50%;\n padding: 10px;\n border: none;\n background: transparent;\n color: #ffffff;\n `;\n\n // Add hover effects\n container.addEventListener(\"mouseenter\", () => {\n container.style.transform = \"scale(1.05)\";\n container.style.boxShadow = \"0 30px 60px -12px rgba(0, 0, 0, 0.35)\";\n });\n\n container.addEventListener(\"mouseleave\", () => {\n container.style.transform = \"scale(1)\";\n container.style.boxShadow = \"0 25px 50px -12px rgba(0, 0, 0, 0.25)\";\n });\n\n button.innerHTML = `\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\">\n <path d=\"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z\"></path>\n <circle cx=\"12\" cy=\"13\" r=\"3\"></circle>\n </svg>\n `;\n\n button.onclick = onClick;\n container.appendChild(button);\n return container;\n }\n\n /**\n * Gets CSS position styles based on button position configuration\n * @returns CSS position string\n */\n private getPositionStyles(): string {\n switch (this.config.buttonPosition) {\n case \"bottom-left\":\n return \"left: 20px; bottom: 20px;\";\n case \"top-right\":\n return \"right: 20px; top: 20px;\";\n case \"top-left\":\n return \"left: 20px; top: 20px;\";\n default:\n return \"right: 20px; bottom: 20px;\";\n }\n }\n\n /**\n * Displays the virtual try-on result in a modal\n * @param imageUrl - URL of the virtual try-on image\n */\n private showImageModal(imageUrl: string): void {\n // Remove any existing modals first\n const existingModals = document.querySelectorAll(`.${CSS_CLASSES.MODAL}`);\n existingModals.forEach((modal) => {\n modal.remove();\n });\n\n const modal = document.createElement(\"div\");\n modal.className = CSS_CLASSES.MODAL;\n modal.setAttribute(\"role\", \"dialog\");\n modal.setAttribute(\"aria-modal\", \"true\");\n modal.setAttribute(\"aria-label\", \"Virtual Try-On Result\");\n modal.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.8);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: ${Z_INDEX.MODAL};\n animation: fadeIn 0.3s ease;\n `;\n\n modal.innerHTML = `\n <div style=\"\n background: #ffffff;\n padding: 20px;\n border-radius: 12px;\n max-width: 90vw;\n max-height: 90vh;\n box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);\n animation: slideIn 0.3s ease;\n \">\n <img \n src=\"${imageUrl}\" \n alt=\"Virtual Try-On Result\"\n style=\"\n max-width: 100%;\n max-height: 80vh;\n border-radius: 8px;\n display: block;\n \" \n />\n <div style=\"\n text-align: right;\n margin-top: 15px;\n \">\n <button \n type=\"button\"\n style=\"\n padding: 8px 16px;\n border: none;\n background: #000000;\n color: #ffffff;\n border-radius: 6px;\n cursor: pointer;\n font-size: 14px;\n font-weight: 500;\n transition: background-color 0.2s ease;\n \"\n onmouseover=\"this.style.backgroundColor='#333333'\"\n onmouseout=\"this.style.backgroundColor='#000000'\"\n >\n Close\n </button>\n </div>\n </div>\n <style>\n @keyframes fadeIn {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n @keyframes slideIn {\n from { transform: scale(0.9) translateY(20px); opacity: 0; }\n to { transform: scale(1) translateY(0); opacity: 1; }\n }\n </style>\n `;\n\n const closeButton = modal.querySelector(\"button\");\n const modalContent = modal.querySelector(\"div\");\n\n // Close on button click\n if (closeButton) {\n closeButton.onclick = () => modal.remove();\n }\n\n // Close on backdrop click\n modal.onclick = (e) => {\n if (e.target === modal) {\n modal.remove();\n }\n };\n\n // Prevent content clicks from closing modal\n if (modalContent) {\n modalContent.onclick = (e) => e.stopPropagation();\n }\n\n // Close on Escape key\n const handleEscape = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") {\n modal.remove();\n document.removeEventListener(\"keydown\", handleEscape);\n }\n };\n document.addEventListener(\"keydown\", handleEscape);\n\n document.body.appendChild(modal);\n }\n\n /**\n * Initializes the virtual try-on widget on the current page\n * @returns Promise that resolves when initialization is complete\n */\n public async init(): Promise<void> {\n try {\n // Check if we're on a product page\n if (!window.location.pathname.includes(this.config.productPageSelector)) {\n return;\n }\n\n // Find the gallery container\n const container = document.querySelector(this.config.gallerySelector);\n if (!container || !(container instanceof HTMLElement)) {\n console.warn(\n \"[WeWear VTO] Gallery container not found:\",\n this.config.gallerySelector,\n );\n return;\n }\n\n // Ensure container has relative positioning for button placement\n if (getComputedStyle(container).position === \"static\") {\n container.style.position = \"relative\";\n }\n\n // Create and add the virtual try-on button\n const button = this.createButton(async () => {\n await this.handleTryOnClick();\n });\n\n container.appendChild(button);\n console.log(\"[WeWear VTO] Widget initialized successfully\");\n } catch (error) {\n console.error(\"[WeWear VTO] Initialization failed:\", error);\n }\n }\n\n /**\n * Handles virtual try-on button click\n * @private\n */\n private async handleTryOnClick(): Promise<void> {\n try {\n // Get required data\n const ww_access_token = this.getCookie(\"ww_access_token\");\n const ww_user_id = this.getCookie(\"ww_user_id\");\n const skuElement = document.querySelector(this.config.skuSelector);\n const ww_product_id = skuElement?.textContent?.trim();\n\n // Validate required data\n if (!ww_user_id) {\n console.warn(\"[WeWear VTO] Missing required cookie: ww_user_id\");\n this.showError(\"Please sign in to use virtual try-on\");\n return;\n }\n\n if (!ww_product_id) {\n console.warn(\n \"[WeWear VTO] Product SKU not found:\",\n this.config.skuSelector,\n );\n this.showError(\"Product information not available\");\n return;\n }\n\n // Show loading state (could be implemented)\n console.log(\"[WeWear VTO] Processing virtual try-on request...\");\n\n // Make API call\n const result = await this.callVirtualTryOnApi(\n ww_access_token,\n ww_user_id,\n ww_product_id,\n );\n\n if (result?.imageUrl) {\n this.showImageModal(result.imageUrl);\n } else {\n this.showError(\n \"Virtual try-on service is currently unavailable. Please try again later.\",\n );\n }\n } catch (error) {\n console.error(\"[WeWear VTO] Try-on request failed:\", error);\n this.showError(\"An unexpected error occurred. Please try again.\");\n }\n }\n\n /**\n * Shows an error message to the user\n * @param message - Error message to display\n * @private\n */\n private showError(message: string): void {\n // Simple alert for now - could be enhanced with a custom modal\n alert(`WeWear Virtual Try-On: ${message}`);\n }\n\n /**\n * Destroys the widget and cleans up resources\n */\n public destroy(): void {\n try {\n // Remove all buttons\n const buttons = document.querySelectorAll(\n `.${CSS_CLASSES.BUTTON_CONTAINER}`,\n );\n buttons.forEach((button) => {\n button.remove();\n });\n\n // Remove all modals\n const modals = document.querySelectorAll(`.${CSS_CLASSES.MODAL}`);\n modals.forEach((modal) => {\n modal.remove();\n });\n\n console.log(\"[WeWear VTO] Widget destroyed successfully\");\n } catch (error) {\n console.error(\"[WeWear VTO] Error during widget destruction:\", error);\n }\n }\n}\n","/**\n * WeWear Virtual Try-On Widget Auto-Installer\n *\n * Provides automatic initialization and management of the virtual try-on widget.\n * Handles DOM ready states and widget lifecycle management.\n */\n\nimport type { VirtualTryOnConfig } from \"./index.js\";\nimport { VirtualTryOnWidget } from \"./widget.js\";\n\nlet widgetInstance: VirtualTryOnWidget | null = null;\n\n/**\n * Initializes the virtual try-on widget with optional configuration\n * @param config - Widget configuration options\n */\nexport function initVirtualTryOn(config?: VirtualTryOnConfig): void {\n try {\n // Clean up any existing instance\n if (widgetInstance) {\n widgetInstance.destroy();\n widgetInstance = null;\n }\n\n // Create and initialize new instance\n widgetInstance = new VirtualTryOnWidget(config);\n\n // Initialize immediately if DOM is ready, otherwise wait for it\n if (document.readyState === \"loading\") {\n document.addEventListener(\"DOMContentLoaded\", () => {\n widgetInstance?.init().catch((error) => {\n console.error(\n \"[WeWear VTO] Failed to initialize after DOM ready:\",\n error,\n );\n });\n });\n } else {\n widgetInstance.init().catch((error) => {\n console.error(\"[WeWear VTO] Failed to initialize:\", error);\n });\n }\n } catch (error) {\n console.error(\"[WeWear VTO] Initialization error:\", error);\n }\n}\n\n/**\n * Destroys the current widget instance and cleans up resources\n */\nexport function destroyVirtualTryOn(): void {\n try {\n if (widgetInstance) {\n widgetInstance.destroy();\n widgetInstance = null;\n console.log(\"[WeWear VTO] Widget instance destroyed\");\n }\n } catch (error) {\n console.error(\"[WeWear VTO] Error destroying widget:\", error);\n }\n}\n\n/**\n * Gets the current widget instance (for debugging purposes)\n * @returns Current widget instance or null\n */\nexport function getWidgetInstance(): VirtualTryOnWidget | null {\n return widgetInstance;\n}\n\n// Auto-initialize if window object exists (browser environment)\nif (typeof window !== \"undefined\") {\n initVirtualTryOn();\n}\n"],"names":[],"mappings":"AAAA;;;;;AAKG;AAIH;AACA,MAAM,cAAc,GAAG;AACrB,IAAA,QAAQ,EAAE,0CAA0C;AACpD,IAAA,qBAAqB,EAAE,WAAW;AAClC,IAAA,gBAAgB,EAAE,qCAAqC;AACvD,IAAA,YAAY,EAAE,MAAM;AACpB,IAAA,eAAe,EAAE,cAAuB;CAChC;AAEV;AACA,MAAM,WAAW,GAAG;AAClB,IAAA,gBAAgB,EAAE,6BAA6B;AAC/C,IAAA,MAAM,EAAE,mBAAmB;AAC3B,IAAA,KAAK,EAAE,kBAAkB;CACjB;AAEV;AACA,MAAM,OAAO,GAAG;AACd,IAAA,MAAM,EAAE,EAAE;AACV,IAAA,KAAK,EAAE,KAAK;CACJ;MAEG,kBAAkB,CAAA;AAG7B,IAAA,WAAA,CAAY,SAA6B,EAAE,EAAA;QACzC,IAAI,CAAC,MAAM,GAAG;AACZ,YAAA,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,cAAc,CAAC,QAAQ;AAClD,YAAA,mBAAmB,EACjB,MAAM,CAAC,mBAAmB,IAAI,cAAc,CAAC,qBAAqB;AACpE,YAAA,eAAe,EACb,MAAM,CAAC,eAAe,IAAI,cAAc,CAAC,gBAAgB;AAC3D,YAAA,WAAW,EAAE,MAAM,CAAC,WAAW,IAAI,cAAc,CAAC,YAAY;AAC9D,YAAA,cAAc,EAAE,MAAM,CAAC,cAAc,IAAI,cAAc,CAAC,eAAe;SACxE;IACH;AAEA;;;;AAIG;AACK,IAAA,SAAS,CAAC,IAAY,EAAA;;QAC5B,IAAI,OAAO,QAAQ,KAAK,WAA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oCAAoC,EAAE,KAAK,CAAC;IAC5D;AACF;AAEA;;AAEG;SACa,mBAAmB,GAAA;AACjC,IAAA,IAAI;QACF,IAAI,cAAc,EAAE;YAClB,cAAc,CAAC,OAAO,EAAE;YACxB,cAAc,GAAG,IAAI;AACrB,YAAA,OAAO,CAAC,GAAG,CAAC,wCAAwC,CAAC;QACvD;IACF;IAAE,OAAO,KAAK,EAAE;AACd,QAAA,OAAO,CAAC,KAAK,CAAC,uCAAuC,EAAE,KAAK,CAAC;IAC/D;AACF;AAUA;AACA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AACjC,IAAA,gBAAgB,EAAE;AACpB;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":["../src/widget.ts","../src/installer.ts"],"sourcesContent":["/**\n * WeWear Virtual Try-On Widget Implementation\n *\n * Core widget class that handles virtual try-on functionality integration.\n * Manages button creation, API communication, and modal display.\n */\n\nimport type { VirtualTryOnConfig, VirtualTryOnResult } from \"./index.js\";\n\n/** Default configuration constants */\nconst DEFAULT_CONFIG = {\n BASE_URL: \"https://virtual-try-on-widget.vercel.app\",\n PRODUCT_PAGE_SELECTOR: \"/product/\",\n GALLERY_SELECTOR: \".woocommerce-product-gallery__image\",\n SKU_SELECTOR: \".sku\",\n BUTTON_POSITION: \"bottom-right\" as const,\n} as const;\n\n/** CSS class names for consistent styling */\nconst CSS_CLASSES = {\n BUTTON_CONTAINER: \"wewear-vto-button-container\",\n BUTTON: \"wewear-vto-button\",\n MODAL: \"wewear-vto-modal\",\n} as const;\n\n/** Z-index values for proper layering */\nconst Z_INDEX = {\n BUTTON: 10,\n MODAL: 99999,\n} as const;\n\nexport class VirtualTryOnWidget {\n private readonly config: Required<VirtualTryOnConfig>;\n\n constructor(config: VirtualTryOnConfig = {}) {\n this.config = {\n baseUrl: config.baseUrl || DEFAULT_CONFIG.BASE_URL,\n productPageSelector:\n config.productPageSelector || DEFAULT_CONFIG.PRODUCT_PAGE_SELECTOR,\n gallerySelector:\n config.gallerySelector || DEFAULT_CONFIG.GALLERY_SELECTOR,\n skuSelector: config.skuSelector || DEFAULT_CONFIG.SKU_SELECTOR,\n buttonPosition: config.buttonPosition || DEFAULT_CONFIG.BUTTON_POSITION,\n };\n }\n\n /**\n * Retrieves a cookie value by name\n * @param name - Cookie name to retrieve\n * @returns Cookie value or null if not found\n */\n private getCookie(name: string): string | null {\n if (typeof document === \"undefined\") return null;\n\n const value = `; ${document.cookie}`;\n const parts = value.split(`; ${name}=`);\n\n if (parts.length === 2) {\n const part = parts.pop();\n return part ? part.split(\";\").shift()?.trim() || null : null;\n }\n\n return null;\n }\n\n /**\n * Makes API call to virtual try-on service\n * @param ww_access_token - Optional authentication token\n * @param ww_user_id - User identifier\n /**\n * Creates the virtual try-on button element\n * @param onClick - Click handler function\n * @returns Button container element\n */\n private createButton(onClick: () => void): HTMLElement {\n const container = document.createElement(\"div\");\n container.className = CSS_CLASSES.BUTTON_CONTAINER;\n\n const positionStyles = this.getPositionStyles();\n container.style.cssText = `\n position: absolute;\n ${positionStyles}\n display: flex;\n border-radius: 50%;\n background: #000000;\n padding: 4px;\n box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);\n z-index: ${Z_INDEX.BUTTON};\n transition: transform 0.2s ease, box-shadow 0.2s ease;\n `;\n\n const button = document.createElement(\"button\");\n button.type = \"button\";\n button.className = CSS_CLASSES.BUTTON;\n button.setAttribute(\"aria-label\", \"Virtual Try-On\");\n button.setAttribute(\"title\", \"Try this product virtually\");\n button.style.cssText = `\n display: flex;\n width: 36px;\n height: 36px;\n cursor: pointer;\n align-items: center;\n justify-content: center;\n border-radius: 50%;\n padding: 10px;\n border: none;\n background: transparent;\n color: #ffffff;\n `;\n\n // Add hover effects\n container.addEventListener(\"mouseenter\", () => {\n container.style.transform = \"scale(1.05)\";\n container.style.boxShadow = \"0 30px 60px -12px rgba(0, 0, 0, 0.35)\";\n });\n\n container.addEventListener(\"mouseleave\", () => {\n container.style.transform = \"scale(1)\";\n container.style.boxShadow = \"0 25px 50px -12px rgba(0, 0, 0, 0.25)\";\n });\n\n button.innerHTML = `\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\">\n <path d=\"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z\"></path>\n <circle cx=\"12\" cy=\"13\" r=\"3\"></circle>\n </svg>\n `;\n\n button.onclick = onClick;\n container.appendChild(button);\n return container;\n }\n\n /**\n * Gets CSS position styles based on button position configuration\n * @returns CSS position string\n */\n private getPositionStyles(): string {\n switch (this.config.buttonPosition) {\n case \"bottom-left\":\n return \"left: 20px; bottom: 20px;\";\n case \"top-right\":\n return \"right: 20px; top: 20px;\";\n case \"top-left\":\n return \"left: 20px; top: 20px;\";\n default:\n return \"right: 20px; bottom: 20px;\";\n }\n }\n\n /**\n * Displays the virtual try-on result in a modal\n * @param imageUrl - URL of the virtual try-on image\n */\n private showImageModal(imageUrl: string): void {\n // Remove any existing modals first\n const existingModals = document.querySelectorAll(`.${CSS_CLASSES.MODAL}`);\n existingModals.forEach((modal) => {\n modal.remove();\n });\n\n // Create modal container\n const modal = document.createElement(\"div\");\n modal.className = CSS_CLASSES.MODAL;\n modal.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.9);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: ${Z_INDEX.MODAL};\n padding: 20px;\n box-sizing: border-box;\n `;\n\n // Create image container\n const imageContainer = document.createElement(\"div\");\n imageContainer.style.cssText = `\n position: relative;\n max-width: 90%;\n max-height: 90%;\n background-color: white;\n border-radius: 8px;\n box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);\n overflow: hidden;\n `;\n\n // Create image element\n const image = document.createElement(\"img\");\n image.src = imageUrl;\n image.alt = \"Virtual Try-On Result\";\n image.style.cssText = `\n width: 100%;\n height: 100%;\n object-fit: contain;\n display: block;\n `;\n\n // Create close button\n const closeButton = document.createElement(\"button\");\n closeButton.innerHTML = \"×\";\n closeButton.style.cssText = `\n position: absolute;\n top: 10px;\n right: 10px;\n width: 30px;\n height: 30px;\n border: none;\n background-color: rgba(0, 0, 0, 0.7);\n color: white;\n font-size: 20px;\n font-weight: bold;\n cursor: pointer;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n `;\n\n closeButton.onclick = () => {\n modal.remove();\n };\n\n // Close on backdrop click\n modal.onclick = (e) => {\n if (e.target === modal) {\n modal.remove();\n }\n };\n\n // Close on Escape key\n const handleEscape = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") {\n modal.remove();\n document.removeEventListener(\"keydown\", handleEscape);\n }\n };\n document.addEventListener(\"keydown\", handleEscape);\n\n imageContainer.appendChild(image);\n imageContainer.appendChild(closeButton);\n modal.appendChild(imageContainer);\n document.body.appendChild(modal);\n }\n\n /**\n * Shows the camera capture modal\n * @param ww_access_token - Access token for API\n * @param ww_user_id - User identifier\n * @param ww_product_id - Product identifier\n */\n private showCameraModal(\n ww_access_token: string | null,\n ww_user_id: string,\n ww_product_id: string,\n ): void {\n console.log(\"[WeWear VTO] Opening camera modal...\");\n\n // Remove any existing modals first\n const existingModals = document.querySelectorAll(`.${CSS_CLASSES.MODAL}`);\n existingModals.forEach((modal) => {\n modal.remove();\n });\n\n // Create modal container\n const modal = document.createElement(\"div\");\n modal.className = CSS_CLASSES.MODAL;\n modal.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.95);\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n z-index: ${Z_INDEX.MODAL};\n padding: 20px;\n box-sizing: border-box;\n `;\n\n // Create camera container\n const cameraContainer = document.createElement(\"div\");\n cameraContainer.style.cssText = `\n position: relative;\n width: 100%;\n max-width: 500px;\n height: 70vh;\n background-color: #000;\n border-radius: 12px;\n overflow: hidden;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n `;\n\n // Create video element\n const video = document.createElement(\"video\");\n video.autoplay = true;\n video.playsInline = true;\n video.muted = true;\n video.style.cssText = `\n width: 100%;\n height: 100%;\n object-fit: cover;\n border-radius: 12px;\n `;\n\n // Create canvas for capturing\n const canvas = document.createElement(\"canvas\");\n canvas.style.display = \"none\";\n\n // Create capture button\n const captureButton = document.createElement(\"button\");\n captureButton.innerHTML = `\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"white\">\n <circle cx=\"12\" cy=\"12\" r=\"10\" stroke=\"white\" stroke-width=\"2\" fill=\"none\"/>\n <circle cx=\"12\" cy=\"12\" r=\"6\" fill=\"white\"/>\n </svg>\n `;\n captureButton.style.cssText = `\n position: absolute;\n bottom: 20px;\n left: 50%;\n transform: translateX(-50%);\n width: 60px;\n height: 60px;\n border: 3px solid white;\n background-color: transparent;\n border-radius: 50%;\n cursor: pointer;\n display: none;\n align-items: center;\n justify-content: center;\n transition: all 0.2s ease;\n `;\n\n // Create close button\n const closeButton = document.createElement(\"button\");\n closeButton.innerHTML = \"×\";\n closeButton.style.cssText = `\n position: absolute;\n top: 15px;\n right: 15px;\n width: 40px;\n height: 40px;\n border: none;\n background-color: rgba(0, 0, 0, 0.7);\n color: white;\n font-size: 24px;\n font-weight: bold;\n cursor: pointer;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n `;\n\n // Create loading indicator\n const loadingIndicator = document.createElement(\"div\");\n loadingIndicator.innerHTML = \"Initializing camera...\";\n loadingIndicator.style.cssText = `\n color: white;\n font-size: 16px;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n `;\n\n // Add event listeners\n closeButton.onclick = () => {\n this.stopCamera(video);\n modal.remove();\n };\n\n captureButton.onclick = () => {\n this.captureImage(\n video,\n canvas,\n ww_access_token,\n ww_user_id,\n ww_product_id,\n modal,\n );\n };\n\n // Assemble the camera modal\n cameraContainer.appendChild(video);\n cameraContainer.appendChild(canvas);\n cameraContainer.appendChild(captureButton);\n cameraContainer.appendChild(closeButton);\n cameraContainer.appendChild(loadingIndicator);\n modal.appendChild(cameraContainer);\n\n document.body.appendChild(modal);\n console.log(\"[WeWear VTO] Camera modal added to DOM\");\n\n // Start camera\n this.startCamera(video, loadingIndicator, captureButton);\n } /**\n * Initializes the virtual try-on widget on the current page\n * @returns Promise that resolves when initialization is complete\n */\n public async init(): Promise<void> {\n try {\n // Check if we're on a product page\n if (!window.location.pathname.includes(this.config.productPageSelector)) {\n return;\n }\n\n // Find the gallery container\n const container = document.querySelector(this.config.gallerySelector);\n if (!container || !(container instanceof HTMLElement)) {\n console.warn(\n \"[WeWear VTO] Gallery container not found:\",\n this.config.gallerySelector,\n );\n return;\n }\n\n // Ensure container has relative positioning for button placement\n if (getComputedStyle(container).position === \"static\") {\n container.style.position = \"relative\";\n }\n\n // Create and add the virtual try-on button\n const button = this.createButton(async () => {\n await this.handleTryOnClick();\n });\n\n container.appendChild(button);\n console.log(\"[WeWear VTO] Widget initialized successfully\");\n } catch (error) {\n console.error(\"[WeWear VTO] Initialization failed:\", error);\n }\n }\n\n /**\n * Handles virtual try-on button click\n * @private\n */\n private async handleTryOnClick(): Promise<void> {\n console.log(\"[WeWear VTO] Button clicked, starting try-on process...\");\n\n try {\n // Get required data\n const ww_access_token = this.getCookie(\"ww_access_token\");\n const ww_user_id = this.getCookie(\"ww_user_id\");\n const skuElement = document.querySelector(this.config.skuSelector);\n const ww_product_id = skuElement?.textContent?.trim();\n\n console.log(\"[WeWear VTO] Retrieved data:\", {\n ww_user_id,\n ww_product_id,\n ww_access_token: !!ww_access_token,\n });\n\n // Validate required data\n if (!ww_user_id) {\n console.warn(\"[WeWear VTO] Missing required cookie: ww_user_id\");\n this.showError(\"Please sign in to use virtual try-on\");\n return;\n }\n\n if (!ww_product_id) {\n console.warn(\n \"[WeWear VTO] Product SKU not found:\",\n this.config.skuSelector,\n );\n this.showError(\"Product information not available\");\n return;\n }\n\n // Show camera capture modal\n this.showCameraModal(ww_access_token, ww_user_id, ww_product_id);\n } catch (error) {\n console.error(\"[WeWear VTO] Try-on request failed:\", error);\n this.showError(\"An unexpected error occurred. Please try again.\");\n }\n }\n\n /**\n * Shows an error message to the user\n * @param message - Error message to display\n * @private\n */\n private showError(message: string): void {\n // Simple alert for now - could be enhanced with a custom modal\n alert(`WeWear Virtual Try-On: ${message}`);\n }\n\n /**\n * Starts the camera stream\n * @param video - Video element to display camera stream\n * @param loadingIndicator - Loading indicator element\n * @param captureButton - Capture button element\n */\n private async startCamera(\n video: HTMLVideoElement,\n loadingIndicator: HTMLElement,\n captureButton: HTMLButtonElement,\n ): Promise<void> {\n console.log(\"[WeWear VTO] Starting camera...\");\n\n try {\n const constraints = {\n video: {\n width: { ideal: 1280 },\n height: { ideal: 720 },\n facingMode: \"user\", // Front-facing camera\n },\n audio: false,\n };\n\n console.log(\"[WeWear VTO] Requesting camera access...\");\n const stream = await navigator.mediaDevices.getUserMedia(constraints);\n video.srcObject = stream;\n\n video.onloadedmetadata = () => {\n console.log(\"[WeWear VTO] Camera stream loaded successfully\");\n loadingIndicator.style.display = \"none\";\n captureButton.style.display = \"flex\";\n };\n } catch (error) {\n console.error(\"[WeWear VTO] Camera access error:\", error);\n loadingIndicator.innerHTML =\n \"Camera access denied. Please allow camera permissions.\";\n }\n }\n\n /**\n * Stops the camera stream\n * @param video - Video element with camera stream\n */\n private stopCamera(video: HTMLVideoElement): void {\n const stream = video.srcObject as MediaStream;\n if (stream) {\n const tracks = stream.getTracks();\n tracks.forEach((track) => {\n track.stop();\n });\n video.srcObject = null;\n }\n }\n\n /**\n * Captures an image from the video stream\n * @param video - Video element with camera stream\n * @param canvas - Canvas element for capturing\n * @param ww_access_token - Access token for API\n * @param ww_user_id - User identifier\n * @param ww_product_id - Product identifier\n * @param modal - Modal element to close after processing\n */\n private async captureImage(\n video: HTMLVideoElement,\n canvas: HTMLCanvasElement,\n ww_access_token: string | null,\n ww_user_id: string,\n ww_product_id: string,\n modal: HTMLElement,\n ): Promise<void> {\n try {\n // Set canvas dimensions to match video\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n\n // Draw video frame to canvas\n const ctx = canvas.getContext(\"2d\");\n if (!ctx) {\n throw new Error(\"Could not get canvas context\");\n }\n\n ctx.drawImage(video, 0, 0, canvas.width, canvas.height);\n\n // Convert canvas to blob\n const blob = await new Promise<Blob>((resolve, reject) => {\n canvas.toBlob(\n (blob) => {\n if (blob) {\n resolve(blob);\n } else {\n reject(new Error(\"Failed to create blob from canvas\"));\n }\n },\n \"image/jpeg\",\n 0.8,\n );\n });\n\n // Stop camera and close camera modal\n this.stopCamera(video);\n modal.remove();\n\n // Show review modal instead of immediately processing\n this.showReviewModal(blob, ww_access_token, ww_user_id, ww_product_id);\n } catch (error) {\n console.error(\"[WeWear VTO] Image capture error:\", error);\n this.showError(\"Failed to capture image. Please try again.\");\n }\n }\n\n /**\n * Shows the review modal for captured image\n * @param imageBlob - Captured image blob\n * @param ww_access_token - Access token for API\n * @param ww_user_id - User identifier\n * @param ww_product_id - Product identifier\n */\n private showReviewModal(\n imageBlob: Blob,\n ww_access_token: string | null,\n ww_user_id: string,\n ww_product_id: string,\n ): void {\n console.log(\"[WeWear VTO] Opening review modal...\");\n\n // Remove any existing modals first\n const existingModals = document.querySelectorAll(`.${CSS_CLASSES.MODAL}`);\n existingModals.forEach((modal) => {\n modal.remove();\n });\n\n // Create image URL for preview\n const imageUrl = URL.createObjectURL(imageBlob);\n\n // Create modal container (same as camera modal)\n const modal = document.createElement(\"div\");\n modal.className = CSS_CLASSES.MODAL;\n modal.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.95);\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n z-index: ${Z_INDEX.MODAL};\n padding: 20px;\n box-sizing: border-box;\n `;\n\n // Create review container (similar to camera container)\n const reviewContainer = document.createElement(\"div\");\n reviewContainer.style.cssText = `\n position: relative;\n width: 100%;\n max-width: 500px;\n height: 70vh;\n background-color: #000;\n border-radius: 12px;\n overflow: hidden;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n `;\n\n // Create image element (replaces video element)\n const image = document.createElement(\"img\");\n image.src = imageUrl;\n image.alt = \"Review your photo\";\n image.style.cssText = `\n width: 100%;\n height: 100%;\n object-fit: cover;\n border-radius: 12px;\n `;\n\n // Create close button (same as camera modal)\n const closeButton = document.createElement(\"button\");\n closeButton.innerHTML = \"×\";\n closeButton.style.cssText = `\n position: absolute;\n top: 15px;\n right: 15px;\n width: 40px;\n height: 40px;\n border: none;\n background-color: rgba(0, 0, 0, 0.7);\n color: white;\n font-size: 24px;\n font-weight: bold;\n cursor: pointer;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n `;\n\n // Create button container positioned at bottom (similar to capture button position)\n const buttonContainer = document.createElement(\"div\");\n buttonContainer.style.cssText = `\n position: absolute;\n bottom: 20px;\n left: 50%;\n transform: translateX(-50%);\n display: flex;\n gap: 15px;\n width: calc(100% - 40px);\n max-width: 300px;\n `;\n\n // Create retake button\n const retakeButton = document.createElement(\"button\");\n retakeButton.textContent = \"Retake\";\n retakeButton.style.cssText = `\n flex: 1;\n padding: 12px 24px;\n background-color: transparent;\n color: white;\n border: 2px solid white;\n border-radius: 8px;\n font-size: 16px;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.2s ease;\n `;\n\n // Create use photo button\n const usePhotoButton = document.createElement(\"button\");\n usePhotoButton.textContent = \"Use Photo\";\n usePhotoButton.style.cssText = `\n flex: 1;\n padding: 12px 24px;\n background-color: white;\n color: black;\n border: 2px solid white;\n border-radius: 8px;\n font-size: 16px;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.2s ease;\n `;\n\n // Add hover effects\n retakeButton.addEventListener(\"mouseenter\", () => {\n retakeButton.style.backgroundColor = \"white\";\n retakeButton.style.color = \"black\";\n });\n retakeButton.addEventListener(\"mouseleave\", () => {\n retakeButton.style.backgroundColor = \"transparent\";\n retakeButton.style.color = \"white\";\n });\n\n usePhotoButton.addEventListener(\"mouseenter\", () => {\n usePhotoButton.style.backgroundColor = \"rgba(255, 255, 255, 0.9)\";\n });\n usePhotoButton.addEventListener(\"mouseleave\", () => {\n usePhotoButton.style.backgroundColor = \"white\";\n });\n\n // Add event listeners\n closeButton.onclick = () => {\n URL.revokeObjectURL(imageUrl); // Clean up\n modal.remove();\n };\n\n retakeButton.onclick = () => {\n URL.revokeObjectURL(imageUrl); // Clean up\n modal.remove();\n // Reopen camera modal\n this.showCameraModal(ww_access_token, ww_user_id, ww_product_id);\n };\n\n usePhotoButton.onclick = async () => {\n URL.revokeObjectURL(imageUrl); // Clean up\n modal.remove();\n // Process the image\n await this.processAcceptedImage(\n imageBlob,\n ww_access_token,\n ww_user_id,\n ww_product_id,\n );\n };\n\n // Assemble the review modal (similar to camera modal)\n buttonContainer.appendChild(retakeButton);\n buttonContainer.appendChild(usePhotoButton);\n reviewContainer.appendChild(image);\n reviewContainer.appendChild(closeButton);\n reviewContainer.appendChild(buttonContainer);\n modal.appendChild(reviewContainer);\n\n document.body.appendChild(modal);\n console.log(\"[WeWear VTO] Review modal added to DOM\");\n }\n\n /**\n * Processes the accepted image by calling the API\n * @param imageBlob - Accepted image blob\n * @param ww_access_token - Access token for API\n * @param ww_user_id - User identifier\n * @param ww_product_id - Product identifier\n */\n private async processAcceptedImage(\n imageBlob: Blob,\n ww_access_token: string | null,\n ww_user_id: string,\n ww_product_id: string,\n ): Promise<void> {\n try {\n console.log(\"[WeWear VTO] Processing accepted image...\");\n\n // Call the API with the accepted image\n const result = await this.callVirtualTryOnApiWithImage(\n ww_access_token,\n ww_user_id,\n ww_product_id,\n imageBlob,\n );\n\n if (result?.imageUrl) {\n this.showImageModal(result.imageUrl);\n } else {\n console.error(\"[WeWear VTO] Invalid API response:\", result);\n }\n } catch (error) {\n console.error(\"[WeWear VTO] Error processing accepted image:\", error);\n this.showError(\"Failed to process image. Please try again.\");\n }\n }\n\n /**\n * Makes API call to virtual try-on service with captured image\n * @param ww_access_token - Optional authentication token\n * @param ww_user_id - User identifier\n * @param ww_product_id - Product identifier\n * @param imageBlob - Captured image blob\n * @returns Promise with virtual try-on result or null if failed\n */\n private async callVirtualTryOnApiWithImage(\n ww_access_token: string | null,\n ww_user_id: string,\n ww_product_id: string,\n imageBlob: Blob,\n ): Promise<VirtualTryOnResult | null> {\n try {\n // Create form data for multipart upload\n const formData = new FormData();\n formData.append(\"ww_user_id\", ww_user_id);\n formData.append(\"ww_product_id\", ww_product_id);\n formData.append(\"image\", imageBlob, \"captured-image.jpg\");\n\n if (ww_access_token) {\n formData.append(\"ww_access_token\", ww_access_token);\n }\n\n const response = await fetch(\n `${this.config.baseUrl}/api/virtual-try-on`,\n {\n method: \"POST\",\n body: formData,\n },\n );\n\n if (!response.ok) {\n console.error(\n \"[WeWear VTO] API request failed:\",\n response.status,\n response.statusText,\n );\n return null;\n }\n\n const result = await response.json();\n console.log(\"[WeWear VTO] API response:\", result);\n return result;\n } catch (error) {\n console.error(\"[WeWear VTO] API call failed:\", error);\n return null;\n }\n }\n\n /**\n * Destroys the widget and cleans up resources\n */\n public destroy(): void {\n try {\n // Remove all buttons\n const buttons = document.querySelectorAll(\n `.${CSS_CLASSES.BUTTON_CONTAINER}`,\n );\n buttons.forEach((button) => {\n button.remove();\n });\n\n // Remove all modals\n const modals = document.querySelectorAll(`.${CSS_CLASSES.MODAL}`);\n modals.forEach((modal) => {\n modal.remove();\n });\n\n console.log(\"[WeWear VTO] Widget destroyed successfully\");\n } catch (error) {\n console.error(\"[WeWear VTO] Error during widget destruction:\", error);\n }\n }\n}\n","/**\n * WeWear Virtual Try-On Widget Auto-Installer\n *\n * Provides automatic initialization and management of the virtual try-on widget.\n * Handles DOM ready states and widget lifecycle management.\n */\n\nimport type { VirtualTryOnConfig } from \"./index.js\";\nimport { VirtualTryOnWidget } from \"./widget.js\";\n\nlet widgetInstance: VirtualTryOnWidget | null = null;\n\n/**\n * Initializes the virtual try-on widget with optional configuration\n * @param config - Widget configuration options\n */\nexport function initVirtualTryOn(config?: VirtualTryOnConfig): void {\n try {\n // Clean up any existing instance\n if (widgetInstance) {\n widgetInstance.destroy();\n widgetInstance = null;\n }\n\n // Create and initialize new instance\n widgetInstance = new VirtualTryOnWidget(config);\n\n // Initialize immediately if DOM is ready, otherwise wait for it\n if (document.readyState === \"loading\") {\n document.addEventListener(\"DOMContentLoaded\", () => {\n widgetInstance?.init().catch((error) => {\n console.error(\n \"[WeWear VTO] Failed to initialize after DOM ready:\",\n error,\n );\n });\n });\n } else {\n widgetInstance.init().catch((error) => {\n console.error(\"[WeWear VTO] Failed to initialize:\", error);\n });\n }\n } catch (error) {\n console.error(\"[WeWear VTO] Initialization error:\", error);\n }\n}\n\n/**\n * Destroys the current widget instance and cleans up resources\n */\nexport function destroyVirtualTryOn(): void {\n try {\n if (widgetInstance) {\n widgetInstance.destroy();\n widgetInstance = null;\n console.log(\"[WeWear VTO] Widget instance destroyed\");\n }\n } catch (error) {\n console.error(\"[WeWear VTO] Error destroying widget:\", error);\n }\n}\n\n/**\n * Gets the current widget instance (for debugging purposes)\n * @returns Current widget instance or null\n */\nexport function getWidgetInstance(): VirtualTryOnWidget | null {\n return widgetInstance;\n}\n\n// Auto-initialize if window object exists (browser environment)\nif (typeof window !== \"undefined\") {\n initVirtualTryOn();\n}\n"],"names":[],"mappings":"AAAA;;;;;AAKG;AAIH;AACA,MAAM,cAAc,GAAG;AACrB,IAAA,QAAQ,EAAE,0CAA0C;AACpD,IAAA,qBAAqB,EAAE,WAAW;AAClC,IAAA,gBAAgB,EAAE,qCAAqC;AACvD,IAAA,YAAY,EAAE,MAAM;AACpB,IAAA,eAAe,EAAE,cAAuB;CAChC;AAE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