@wewear/virtual-try-on 1.4.4 → 1.4.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.
- package/dist/index.esm.js +54 -20
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +54 -20
- package/dist/index.js.map +1 -1
- package/dist/widget.d.ts +7 -0
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -444,6 +444,7 @@ class VirtualTryOnWidget {
|
|
|
444
444
|
constructor(config) {
|
|
445
445
|
this.virtualTryOnImageUrl = null;
|
|
446
446
|
this.originalProductImageUrl = null;
|
|
447
|
+
this.originalProductImages = []; // Store all original product images
|
|
447
448
|
this.isShowingVirtualTryOn = false;
|
|
448
449
|
this.lastModelImage = null;
|
|
449
450
|
this.cameraButton = null;
|
|
@@ -501,31 +502,54 @@ class VirtualTryOnWidget {
|
|
|
501
502
|
async handleTryOnClick() {
|
|
502
503
|
console.log("[WeWear VTO] Button clicked, starting try-on process...");
|
|
503
504
|
try {
|
|
504
|
-
//
|
|
505
|
-
if (
|
|
506
|
-
|
|
507
|
-
this.
|
|
508
|
-
(productImageElement === null || productImageElement === void 0 ? void 0 : productImageElement.src) ||
|
|
509
|
-
(productImageElement === null || productImageElement === void 0 ? void 0 : productImageElement.getAttribute("data-src")) ||
|
|
510
|
-
"";
|
|
505
|
+
// Store original images on first click if not already stored
|
|
506
|
+
if (this.originalProductImages.length === 0) {
|
|
507
|
+
this.originalProductImages = this.getAllProductImages();
|
|
508
|
+
console.log("[WeWear VTO] Stored original product images:", this.originalProductImages);
|
|
511
509
|
}
|
|
512
|
-
const ww_product_image = this.originalProductImageUrl;
|
|
513
510
|
console.log("[WeWear VTO] Retrieved data:", {
|
|
514
|
-
|
|
511
|
+
productImages: this.originalProductImages,
|
|
515
512
|
});
|
|
516
|
-
if (
|
|
517
|
-
console.warn("[WeWear VTO] Product
|
|
513
|
+
if (this.originalProductImages.length === 0) {
|
|
514
|
+
console.warn("[WeWear VTO] Product images not found:", this.config.productImageSelector);
|
|
518
515
|
return;
|
|
519
516
|
}
|
|
517
|
+
// Store the first image as the original
|
|
518
|
+
if (!this.originalProductImageUrl) {
|
|
519
|
+
this.originalProductImageUrl = this.originalProductImages[0];
|
|
520
|
+
}
|
|
520
521
|
// Open the photo upload page in a modal
|
|
521
522
|
const photoUploadUrl = new URL(`${this.config.baseUrl}`);
|
|
522
|
-
|
|
523
|
+
// Pass all product images as a comma-separated string
|
|
524
|
+
photoUploadUrl.searchParams.append("ww_product_images", this.originalProductImages.join(","));
|
|
523
525
|
this.showPhotoUploadModal(photoUploadUrl.toString());
|
|
524
526
|
}
|
|
525
527
|
catch (error) {
|
|
526
528
|
console.error("[WeWear VTO] Try-on request failed:", error);
|
|
527
529
|
}
|
|
528
530
|
}
|
|
531
|
+
/**
|
|
532
|
+
* Gets all product images from the gallery
|
|
533
|
+
* @private
|
|
534
|
+
* @returns Array of product image URLs
|
|
535
|
+
*/
|
|
536
|
+
getAllProductImages() {
|
|
537
|
+
const productImageElements = document.querySelectorAll(this.config.productImageSelector);
|
|
538
|
+
const images = [];
|
|
539
|
+
productImageElements.forEach((img) => {
|
|
540
|
+
const imageUrl = img.src ||
|
|
541
|
+
img.getAttribute("data-src") ||
|
|
542
|
+
img.getAttribute("data-large_image") ||
|
|
543
|
+
"";
|
|
544
|
+
// Only include http/https URLs, exclude blob URLs and data URLs
|
|
545
|
+
if (imageUrl &&
|
|
546
|
+
(imageUrl.startsWith("http://") || imageUrl.startsWith("https://")) &&
|
|
547
|
+
!images.includes(imageUrl)) {
|
|
548
|
+
images.push(imageUrl);
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
return images;
|
|
552
|
+
}
|
|
529
553
|
/**
|
|
530
554
|
* Shows a modal with an iframe for the photo upload page
|
|
531
555
|
* @private
|
|
@@ -539,15 +563,15 @@ class VirtualTryOnWidget {
|
|
|
539
563
|
position: fixed;
|
|
540
564
|
top: 0;
|
|
541
565
|
left: 0;
|
|
566
|
+
right: 0;
|
|
567
|
+
bottom: 0;
|
|
542
568
|
width: 100%;
|
|
543
569
|
height: 100%;
|
|
544
|
-
background: rgba(0, 0, 0, 0.8);
|
|
545
|
-
backdrop-filter: blur(8px);
|
|
546
|
-
-webkit-backdrop-filter: blur(8px);
|
|
570
|
+
background-color: rgba(0, 0, 0, 0.8);
|
|
547
571
|
display: flex;
|
|
548
572
|
justify-content: center;
|
|
549
573
|
align-items: center;
|
|
550
|
-
z-index:
|
|
574
|
+
z-index: 999999999;
|
|
551
575
|
animation: ww-modal-fade-in 0.3s ease;
|
|
552
576
|
`;
|
|
553
577
|
// Add fade-in animation
|
|
@@ -671,10 +695,18 @@ class VirtualTryOnWidget {
|
|
|
671
695
|
if (isRefresh) {
|
|
672
696
|
console.log("[WeWear VTO] Refreshing virtual try-on with previous parameters...");
|
|
673
697
|
}
|
|
674
|
-
if (!this.lastModelImage
|
|
698
|
+
if (!this.lastModelImage) {
|
|
675
699
|
console.warn("[WeWear VTO] Missing required data to start virtual try-on.");
|
|
676
700
|
return;
|
|
677
701
|
}
|
|
702
|
+
// Use stored original images, or get them if not stored yet
|
|
703
|
+
if (this.originalProductImages.length === 0) {
|
|
704
|
+
this.originalProductImages = this.getAllProductImages();
|
|
705
|
+
}
|
|
706
|
+
if (this.originalProductImages.length === 0) {
|
|
707
|
+
console.warn("[WeWear VTO] No product images found.");
|
|
708
|
+
return;
|
|
709
|
+
}
|
|
678
710
|
// Hide the modal and show loading indicator
|
|
679
711
|
const modal = document.querySelector(`.${CSS_CLASSES.MODAL}`);
|
|
680
712
|
if (modal && modal instanceof HTMLElement) {
|
|
@@ -685,7 +717,7 @@ class VirtualTryOnWidget {
|
|
|
685
717
|
showProductLoading(container, "Generating your virtual try-on...");
|
|
686
718
|
}
|
|
687
719
|
try {
|
|
688
|
-
const submitResponse = await this.callVtoApi(this.lastModelImage, this.
|
|
720
|
+
const submitResponse = await this.callVtoApi(this.lastModelImage, this.originalProductImages);
|
|
689
721
|
let status = await this.fetchJobStatus(submitResponse.job_id);
|
|
690
722
|
const previews = [];
|
|
691
723
|
while (status.status !== "COMPLETED" && status.status !== "FAILED") {
|
|
@@ -737,10 +769,11 @@ class VirtualTryOnWidget {
|
|
|
737
769
|
removeElements(`.${CSS_CLASSES.MODAL}`);
|
|
738
770
|
}
|
|
739
771
|
}
|
|
740
|
-
async callVtoApi(modelImage,
|
|
772
|
+
async callVtoApi(modelImage, productImages) {
|
|
741
773
|
const formData = new FormData();
|
|
742
774
|
formData.append("model_image", modelImage, "model_image.png");
|
|
743
|
-
|
|
775
|
+
// Send all product images as a JSON array
|
|
776
|
+
formData.append("product_image_urls", JSON.stringify(productImages));
|
|
744
777
|
const res = await fetch(`${this.config.baseUrl}/api/vto`, {
|
|
745
778
|
method: "POST",
|
|
746
779
|
body: formData,
|
|
@@ -944,6 +977,7 @@ class VirtualTryOnWidget {
|
|
|
944
977
|
this.isShowingVirtualTryOn = false;
|
|
945
978
|
this.lastModelImage = null;
|
|
946
979
|
this.originalProductImageUrl = null;
|
|
980
|
+
this.originalProductImages = [];
|
|
947
981
|
if (this.previewBadge) {
|
|
948
982
|
this.previewBadge.remove();
|
|
949
983
|
this.previewBadge = null;
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/constants.ts","../src/components/badge.ts","../src/utils.ts","../src/components/button.ts","../src/components/loading-overlay.ts","../src/components/alert-overlay.ts","../src/widget.ts","../src/installer.ts"],"sourcesContent":["/** CSS class names for consistent styling */\nexport const CSS_CLASSES = {\n\tBUTTON_CONTAINER: \"wewear-vto-button-container\",\n\tBUTTON: \"wewear-vto-button\",\n\tMODAL: \"wewear-vto-modal\",\n\tPREVIEW_BADGE: \"ww-vto-preview-badge\",\n} as const;\n\n/** Z-index values for proper layering */\nexport const Z_INDEX = {\n\tBUTTON: 10,\n\tMODAL: 99999,\n} as const;\n","import { CSS_CLASSES } from \"../constants.js\";\r\n\r\nexport function createPreviewBadge(): HTMLElement {\r\n\tconst badge = document.createElement(\"div\");\r\n\tbadge.className = CSS_CLASSES.PREVIEW_BADGE;\r\n\tbadge.innerText = \"PREVIEW\";\r\n\r\n\tconst styleId = \"ww-vto-badge-styles\";\r\n\tif (!document.getElementById(styleId)) {\r\n\t\tconst styles = document.createElement(\"style\");\r\n\t\tstyles.id = styleId;\r\n\t\tstyles.innerHTML = `\r\n .${CSS_CLASSES.PREVIEW_BADGE} {\r\n position: absolute;\r\n top: 20px;\r\n right: 20px;\r\n background: rgba(31, 41, 55, 0.9);\r\n backdrop-filter: blur(4px);\r\n -webkit-backdrop-filter: blur(4px);\r\n color: white;\r\n padding: 6px 14px;\r\n border-radius: 6px;\r\n font-size: 12px;\r\n font-weight: 600;\r\n letter-spacing: 0.5px;\r\n z-index: 10;\r\n pointer-events: none;\r\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif;\r\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);\r\n animation: ww-vto-pulse 2s ease-in-out infinite;\r\n }\r\n\r\n @keyframes ww-vto-pulse {\r\n 0%, 100% {\r\n opacity: 0.9;\r\n }\r\n 50% {\r\n opacity: 1;\r\n }\r\n }\r\n `;\r\n\t\tdocument.head.appendChild(styles);\r\n\t}\r\n\r\n\treturn badge;\r\n}\r\n","export function getPositionStyles(position: string): string {\n\tswitch (position) {\n\t\tcase \"bottom-left\":\n\t\t\treturn \"left: 20px; bottom: 20px;\";\n\t\tcase \"top-right\":\n\t\t\treturn \"right: 20px; top: 20px;\";\n\t\tcase \"top-left\":\n\t\t\treturn \"left: 20px; top: 20px;\";\n\t\tdefault:\n\t\t\treturn \"right: 20px; bottom: 20px;\";\n\t}\n}\n\nexport function removeElements(selector: string): void {\n\tconst elements = document.querySelectorAll(selector);\n\telements.forEach((element) => {\n\t\telement.remove();\n\t});\n}\n","import { CSS_CLASSES, Z_INDEX } from \"../constants.js\";\r\nimport { getPositionStyles } from \"../utils.js\";\r\n\r\nexport function createButtonContainer(\r\n\tbuttonPosition: string,\r\n\thasVirtualTryOn: boolean = false,\r\n\tonCameraClick: () => void,\r\n\tonRefreshClick?: () => void,\r\n\tonToggleClick?: () => void,\r\n\tisShowingVirtualTryOn: boolean = false,\r\n): HTMLElement {\r\n\tconst container = document.createElement(\"div\");\r\n\tcontainer.className = `${CSS_CLASSES.BUTTON_CONTAINER} ww-button-group`;\r\n\r\n\tconst positionStyles = getPositionStyles(buttonPosition);\r\n\tcontainer.style.cssText = `\r\n position: absolute;\r\n ${positionStyles}\r\n display: flex;\r\n gap: 4px;\r\n border-radius: 100px;\r\n background: white;\r\n padding: 4px;\r\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\r\n z-index: ${Z_INDEX.BUTTON};\r\n transition: all 0.2s ease;\r\n `;\r\n\r\n\t// Camera button\r\n\tconst cameraButton = document.createElement(\"button\");\r\n\tcameraButton.type = \"button\";\r\n\tcameraButton.className = `${CSS_CLASSES.BUTTON} ww-camera-btn`;\r\n\tcameraButton.setAttribute(\"aria-label\", \"Virtual Try-On\");\r\n\tcameraButton.style.cssText = `\r\n display: flex;\r\n width: 40px;\r\n height: 40px;\r\n cursor: pointer;\r\n align-items: center;\r\n justify-content: center;\r\n border-radius: 100px;\r\n padding: 0;\r\n border: none;\r\n background: white;\r\n color: #000000;\r\n transition: all 0.2s ease;\r\n flex-shrink: 0;\r\n `;\r\n\r\n\tcameraButton.innerHTML = `\r\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"display: block;\">\r\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>\r\n <circle cx=\"12\" cy=\"13\" r=\"3\"></circle>\r\n </svg>\r\n `;\r\n\r\n\tcameraButton.onclick = onCameraClick;\r\n\tcontainer.appendChild(cameraButton);\r\n\r\n\t// Add refresh and toggle buttons if we have a virtual try-on\r\n\tif (hasVirtualTryOn) {\r\n\t\t// Refresh button - calls API again\r\n\t\tif (onRefreshClick) {\r\n\t\t\tconst refreshButton = document.createElement(\"button\");\r\n\t\t\trefreshButton.type = \"button\";\r\n\t\t\trefreshButton.className = \"ww-refresh-btn\";\r\n\t\t\trefreshButton.setAttribute(\"aria-label\", \"Refresh virtual try-on\");\r\n\t\t\trefreshButton.style.cssText = `\r\n display: flex;\r\n width: 40px;\r\n height: 40px;\r\n cursor: pointer;\r\n align-items: center;\r\n justify-content: center;\r\n border-radius: 100px;\r\n padding: 0;\r\n border: none;\r\n background: white;\r\n color: #333333;\r\n transition: all 0.2s ease;\r\n flex-shrink: 0;\r\n `;\r\n\r\n\t\t\trefreshButton.innerHTML = `\r\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"display: block;\">\r\n <path d=\"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8\"></path>\r\n <path d=\"M3 3v5h5\"></path>\r\n <path d=\"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16\"></path>\r\n <path d=\"M16 16h5v5\"></path>\r\n </svg>\r\n `;\r\n\r\n\t\t\trefreshButton.onclick = onRefreshClick;\r\n\r\n\t\t\trefreshButton.onclick = onRefreshClick;\r\n\t\t\tcontainer.appendChild(refreshButton);\r\n\t\t}\r\n\r\n\t\t// Toggle button (scan-face) - switches between original and virtual try-on\r\n\t\tif (onToggleClick) {\r\n\t\t\tconst toggleButton = document.createElement(\"button\");\r\n\t\t\ttoggleButton.type = \"button\";\r\n\t\t\ttoggleButton.className = \"ww-toggle-btn\";\r\n\t\t\ttoggleButton.setAttribute(\r\n\t\t\t\t\"aria-label\",\r\n\t\t\t\tisShowingVirtualTryOn ? \"Show Original Image\" : \"Show Virtual Try-On\",\r\n\t\t\t);\r\n\t\t\ttoggleButton.style.cssText = `\r\n display: flex;\r\n width: 40px;\r\n height: 40px;\r\n cursor: pointer;\r\n align-items: center;\r\n justify-content: center;\r\n border-radius: 100px;\r\n padding: 0;\r\n border: none;\r\n background: ${isShowingVirtualTryOn ? \"#333333\" : \"#e5e7eb\"};\r\n color: ${isShowingVirtualTryOn ? \"white\" : \"#333333\"};\r\n transition: all 0.2s ease;\r\n flex-shrink: 0;\r\n `;\r\n\r\n\t\t\ttoggleButton.innerHTML = `\r\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"display: block;\">\r\n <path d=\"M3 7V5a2 2 0 0 1 2-2h2\"></path>\r\n <path d=\"M17 3h2a2 2 0 0 1 2 2v2\"></path>\r\n <path d=\"M21 17v2a2 2 0 0 1-2 2h-2\"></path>\r\n <path d=\"M7 21H5a2 2 0 0 1-2-2v-2\"></path>\r\n <path d=\"M8 14s1.5 2 4 2 4-2 4-2\"></path>\r\n <path d=\"M9 9h.01\"></path>\r\n <path d=\"M15 9h.01\"></path>\r\n </svg>\r\n `;\r\n\r\n\t\t\ttoggleButton.onmouseover = () => {\r\n\t\t\t\tif (isShowingVirtualTryOn) {\r\n\t\t\t\t\ttoggleButton.style.background = \"#4a4a4a\";\r\n\t\t\t\t} else {\r\n\t\t\t\t\ttoggleButton.style.background = \"#d1d5db\";\r\n\t\t\t\t}\r\n\t\t\t};\r\n\t\t\ttoggleButton.onmouseout = () => {\r\n\t\t\t\tif (isShowingVirtualTryOn) {\r\n\t\t\t\t\ttoggleButton.style.background = \"#333333\";\r\n\t\t\t\t} else {\r\n\t\t\t\t\ttoggleButton.style.background = \"#e5e7eb\";\r\n\t\t\t\t}\r\n\t\t\t};\r\n\r\n\t\t\ttoggleButton.onclick = onToggleClick;\r\n\t\t\tcontainer.appendChild(toggleButton);\r\n\t\t}\r\n\t}\r\n\r\n\treturn container;\r\n}\r\n\r\nexport function createButton(\r\n\tbuttonPosition: string,\r\n\tonClick: () => void,\r\n\tdisabled: boolean = false,\r\n): HTMLElement {\r\n\tconst container = createButtonContainer(buttonPosition, false, onClick);\r\n\tconst cameraButton = container.querySelector(\r\n\t\t\".ww-camera-btn\",\r\n\t) as HTMLButtonElement;\r\n\tif (cameraButton) {\r\n\t\tcameraButton.disabled = disabled;\r\n\t\tif (disabled) {\r\n\t\t\tcameraButton.style.opacity = \"0.5\";\r\n\t\t\tcameraButton.style.cursor = \"not-allowed\";\r\n\t\t\tcameraButton.title = \"Find your ideal size first\";\r\n\t\t}\r\n\t}\r\n\treturn container;\r\n}\r\n","import { Z_INDEX } from \"../constants.js\";\r\n\r\n/**\r\n * Creates a loading overlay that can be shown in different containers\r\n */\r\nexport function createLoadingOverlay(\r\n\ttext: string = \"Processing...\",\r\n): HTMLElement {\r\n\tconst overlay = document.createElement(\"div\");\r\n\toverlay.className = \"ww-loading-overlay\";\r\n\toverlay.style.cssText = `\r\n position: absolute;\r\n top: 0;\r\n left: 0;\r\n width: 100%;\r\n height: 100%;\r\n background: linear-gradient(135deg, rgba(0, 0, 0, 0.92) 0%, rgba(0, 0, 0, 0.88) 100%);\r\n backdrop-filter: blur(8px);\r\n -webkit-backdrop-filter: blur(8px);\r\n display: flex;\r\n flex-direction: column;\r\n align-items: center;\r\n justify-content: center;\r\n z-index: ${Z_INDEX.MODAL + 1};\r\n border-radius: inherit;\r\n animation: ww-fade-in 0.3s ease;\r\n `;\r\n\r\n\t// Add CSS animation to the document if not already added\r\n\tif (!document.getElementById(\"ww-loading-animation\")) {\r\n\t\tconst style = document.createElement(\"style\");\r\n\t\tstyle.id = \"ww-loading-animation\";\r\n\t\tstyle.textContent = `\r\n @keyframes ww-fade-in {\r\n from { opacity: 0; }\r\n to { opacity: 1; }\r\n }\r\n \r\n @keyframes ww-pulse-logo {\r\n 0%, 100% { \r\n opacity: 0.8; \r\n transform: scale(1);\r\n }\r\n 50% { \r\n opacity: 1; \r\n transform: scale(1.05);\r\n }\r\n }\r\n \r\n @keyframes ww-spinner-rotate {\r\n 0% { transform: rotate(0deg); }\r\n 100% { transform: rotate(360deg); }\r\n }\r\n \r\n @keyframes ww-dot-bounce {\r\n 0%, 80%, 100% { \r\n transform: scale(0);\r\n opacity: 0.5;\r\n }\r\n 40% { \r\n transform: scale(1);\r\n opacity: 1;\r\n }\r\n }\r\n \r\n .ww-loading-logo {\r\n animation: ww-pulse-logo 2s ease-in-out infinite;\r\n }\r\n \r\n .ww-loading-spinner {\r\n animation: ww-spinner-rotate 1s linear infinite;\r\n }\r\n `;\r\n\t\tdocument.head.appendChild(style);\r\n\t}\r\n\r\n\toverlay.innerHTML = `\r\n <div style=\"display: flex; flex-direction: column; align-items: center; gap: 32px;\">\r\n <div style=\"position: relative; width: 120px; height: 120px; display: flex; align-items: center; justify-content: center;\">\r\n <!-- Outer spinning circle -->\r\n <div class=\"ww-loading-spinner\" style=\"\r\n position: absolute;\r\n width: 120px;\r\n height: 120px;\r\n border: 3px solid transparent;\r\n border-top: 3px solid #333333;\r\n border-right: 3px solid #333333;\r\n border-radius: 50%;\r\n \"></div>\r\n \r\n <!-- Logo -->\r\n <svg class=\"ww-loading-logo\" width=\"80\" height=\"50\" viewBox=\"0 0 214 135\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <path d=\"M102.906 74.8679C102.906 77.9717 101.574 80.7453 98.9104 83.1887C96.6871 85.1918 93.9025 86.6997 90.5566 87.7123C87.695 88.5708 84.6462 89 81.4104 89C73.8821 89 68.0047 87.0189 63.7783 83.0566C59.5519 87.0189 53.6855 89 46.1792 89C42.9434 89 39.9057 88.5708 37.066 87.7123C33.7201 86.6997 30.9245 85.1918 28.6792 83.1887C26.0157 80.7453 24.684 77.9717 24.684 74.8679V41.6509H32.3774V74.8679C32.3774 76.2547 33.489 77.5645 35.7123 78.7972C37.3632 79.7217 39.0692 80.3711 40.8302 80.7453C42.5252 81.1195 44.3082 81.3066 46.1792 81.3066C48.0063 81.3066 49.7673 81.1195 51.4623 80.7453C53.2453 80.3711 54.9623 79.7217 56.6132 78.7972C58.8585 77.5645 59.9811 76.2547 59.9811 74.8679V41.6509H67.6085V74.8679C67.6085 76.2547 68.7311 77.5645 70.9764 78.7972C72.6274 79.7217 74.3443 80.3711 76.1274 80.7453C77.8223 81.1195 79.5833 81.3066 81.4104 81.3066C83.2814 81.3066 85.0755 81.1195 86.7925 80.7453C88.5314 80.3711 90.2264 79.7217 91.8774 78.7972C94.1006 77.5645 95.2123 76.2547 95.2123 74.8679V41.6509H102.906V74.8679ZM189.283 74.8679C189.283 77.9717 187.951 80.7453 185.288 83.1887C183.064 85.1918 180.28 86.6997 176.934 87.7123C174.072 88.5708 171.024 89 167.788 89C160.259 89 154.382 87.0189 150.156 83.0566C145.929 87.0189 140.063 89 132.557 89C129.321 89 126.283 88.5708 123.443 87.7123C120.097 86.6997 117.302 85.1918 115.057 83.1887C112.393 80.7453 111.061 77.9717 111.061 74.8679V41.6509H118.755V74.8679C118.755 76.2547 119.866 77.5645 122.09 78.7972C123.741 79.7217 125.447 80.3711 127.208 80.7453C128.903 81.1195 130.686 81.3066 132.557 81.3066C134.384 81.3066 136.145 81.1195 137.84 80.7453C139.623 80.3711 141.34 79.7217 142.991 78.7972C145.236 77.5645 146.358 76.2547 146.358 74.8679V41.6509H153.986V74.8679C153.986 76.2547 155.108 77.5645 157.354 78.7972C159.005 79.7217 160.722 80.3711 162.505 80.7453C164.2 81.1195 165.961 81.3066 167.788 81.3066C169.659 81.3066 171.453 81.1195 173.17 80.7453C174.909 80.3711 176.604 79.7217 178.255 78.7972C180.478 77.5645 181.59 76.2547 181.59 74.8679V41.6509H189.283V74.8679Z\" fill=\"white\"/>\r\n </svg>\r\n </div>\r\n \r\n <div style=\"font-size: 17px; font-weight: 500; text-align: center; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; color: white; letter-spacing: 0.5px; max-width: 280px;\">${text}</div>\r\n \r\n <div style=\"display: flex; gap: 10px; margin-top: 4px;\">\r\n <div style=\"width: 10px; height: 10px; border-radius: 50%; background: #333333; animation: ww-dot-bounce 1.4s ease-in-out infinite;\"></div>\r\n <div style=\"width: 10px; height: 10px; border-radius: 50%; background: #333333; animation: ww-dot-bounce 1.4s ease-in-out 0.2s infinite;\"></div>\r\n <div style=\"width: 10px; height: 10px; border-radius: 50%; background: #333333; animation: ww-dot-bounce 1.4s ease-in-out 0.4s infinite;\"></div>\r\n </div>\r\n </div>\r\n `;\r\n\r\n\treturn overlay;\r\n}\r\n\r\n/**\r\n * Shows a loading overlay in the product gallery container\r\n */\r\nexport function showProductLoading(\r\n\tcontainer: HTMLElement,\r\n\ttext: string = \"Generating virtual try-on...\",\r\n): void {\r\n\t// Remove any existing loading overlays\r\n\tremoveProductLoading(container);\r\n\r\n\t// Make container relative if it's not already positioned\r\n\tconst computedStyle = window.getComputedStyle(container);\r\n\tif (computedStyle.position === \"static\") {\r\n\t\tcontainer.style.position = \"relative\";\r\n\t}\r\n\r\n\tconst loadingOverlay = createLoadingOverlay(text);\r\n\tcontainer.appendChild(loadingOverlay);\r\n}\r\n\r\n/**\r\n * Removes loading overlay from product container\r\n */\r\nexport function removeProductLoading(container: HTMLElement): void {\r\n\tconst existingOverlay = container.querySelector(\".ww-loading-overlay\");\r\n\tif (existingOverlay) {\r\n\t\texistingOverlay.remove();\r\n\t}\r\n}\r\n","export function showAlert(\r\n\tcontainer: HTMLElement,\r\n\tmessage: string,\r\n\ttype: \"error\" | \"warning\",\r\n) {\r\n\tremoveAlert(container); // Remove any existing alert\r\n\r\n\tconst alertDiv = document.createElement(\"div\");\r\n\talertDiv.className = `ww-alert ww-alert-${type}`;\r\n\talertDiv.setAttribute(\"role\", type === \"error\" ? \"alert\" : \"status\");\r\n\talertDiv.setAttribute(\"aria-live\", \"assertive\");\r\n\r\n\tconst bgColor =\r\n\t\ttype === \"error\"\r\n\t\t\t? \"linear-gradient(135deg, #fee2e2 0%, #fecaca 100%)\"\r\n\t\t\t: \"linear-gradient(135deg, #fef9c3 0%, #fde68a 100%)\";\r\n\tconst textColor = type === \"error\" ? \"#991b1b\" : \"#78350f\";\r\n\tconst borderColor = type === \"error\" ? \"#f87171\" : \"#fbbf24\";\r\n\tconst iconColor = type === \"error\" ? \"#dc2626\" : \"#d97706\";\r\n\r\n\talertDiv.style.cssText = `\r\n position: absolute;\r\n top: 24px;\r\n left: 50%;\r\n transform: translateX(-50%) translateY(-20px);\r\n background: ${bgColor};\r\n color: ${textColor};\r\n border: 1px solid ${borderColor};\r\n border-radius: 12px;\r\n padding: 16px 20px;\r\n z-index: 9999;\r\n font-size: 15px;\r\n font-weight: 500;\r\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);\r\n backdrop-filter: blur(8px);\r\n -webkit-backdrop-filter: blur(8px);\r\n display: flex;\r\n align-items: center;\r\n gap: 12px;\r\n min-width: 280px;\r\n max-width: 90%;\r\n opacity: 0;\r\n transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);\r\n `;\r\n\r\n\tconst icon =\r\n\t\ttype === \"error\"\r\n\t\t\t? `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"${iconColor}\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\r\n\t\t\t<circle cx=\"12\" cy=\"12\" r=\"10\"/><line x1=\"12\" y1=\"8\" x2=\"12\" y2=\"12\"/><line x1=\"12\" y1=\"16\" x2=\"12.01\" y2=\"16\"/>\r\n\t\t</svg>`\r\n\t\t\t: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"${iconColor}\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\r\n\t\t\t<path d=\"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z\"/><line x1=\"12\" y1=\"9\" x2=\"12\" y2=\"13\"/><line x1=\"12\" y1=\"17\" x2=\"12.01\" y2=\"17\"/>\r\n\t\t</svg>`;\r\n\r\n\talertDiv.innerHTML = `\r\n ${icon}\r\n <span style=\"flex: 1; line-height: 1.5;\">${message}</span>\r\n <button type=\"button\" aria-label=\"Close alert\"\r\n style=\"\r\n background: none;\r\n border: none;\r\n font-size: 22px;\r\n color: ${textColor};\r\n cursor: pointer;\r\n padding: 0;\r\n line-height: 1;\r\n opacity: 0.7;\r\n transition: opacity 0.2s ease;\r\n width: 24px;\r\n height: 24px;\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n \"\r\n onmouseover=\"this.style.opacity='1'\"\r\n onmouseout=\"this.style.opacity='0.7'\">\r\n ×\r\n </button>\r\n `;\r\n\r\n\t// Close on button click\r\n\talertDiv.querySelector(\"button\")?.addEventListener(\"click\", () => {\r\n\t\tfadeOutAndRemove(alertDiv);\r\n\t});\r\n\r\n\tcontainer.appendChild(alertDiv);\r\n\r\n\t// Animate in\r\n\trequestAnimationFrame(() => {\r\n\t\talertDiv.style.opacity = \"1\";\r\n\t\talertDiv.style.transform = \"translateX(-50%) translateY(0)\";\r\n\t});\r\n\r\n\t// Auto-dismiss after 8 seconds\r\n\tsetTimeout(() => {\r\n\t\tif (alertDiv.parentElement) {\r\n\t\t\tfadeOutAndRemove(alertDiv);\r\n\t\t}\r\n\t}, 8000);\r\n}\r\n\r\nfunction fadeOutAndRemove(element: HTMLElement) {\r\n\telement.style.opacity = \"0\";\r\n\telement.style.transform = \"translateX(-50%) translateY(-20px)\";\r\n\tsetTimeout(() => {\r\n\t\telement.remove();\r\n\t}, 300);\r\n}\r\n\r\nexport function removeAlert(container: HTMLElement) {\r\n\tconst alert = container.querySelector(\".ww-alert\") as HTMLElement;\r\n\tif (alert) fadeOutAndRemove(alert);\r\n}\r\n","import { CSS_CLASSES, Z_INDEX } from \"./constants.js\";\r\nimport {\r\n\tcreateButton,\r\n\tcreateButtonContainer,\r\n\tremoveProductLoading,\r\n\tshowProductLoading,\r\n\tcreatePreviewBadge,\r\n} from \"./components/index.js\";\r\nimport type { VirtualTryOnConfig } from \"./index.js\";\r\nimport { removeElements } from \"./utils.js\";\r\nimport { showAlert } from \"./components/alert-overlay.js\";\r\n\r\n/**\r\n * Job status type\r\n */\r\ntype JobStatus = \"PENDING\" | \"PREVIEW_AVAILABLE\" | \"COMPLETED\" | \"FAILED\";\r\n\r\n/**\r\n * Response from the job status endpoint\r\n */\r\ninterface JobStatusResponse {\r\n\tstatus: JobStatus;\r\n\tpreviews_available: number;\r\n\tmessage: string;\r\n}\r\n\r\nexport class VirtualTryOnWidget {\r\n\tprivate readonly config: Required<VirtualTryOnConfig>;\r\n\tprivate virtualTryOnImageUrl: string | null = null;\r\n\tprivate originalProductImageUrl: string | null = null;\r\n\tprivate isShowingVirtualTryOn: boolean = false;\r\n\tprivate lastModelImage: Blob | null = null;\r\n\tprivate cameraButton: HTMLButtonElement | null = null;\r\n\tprivate iframeMessageListener: ((event: MessageEvent) => void) | null = null;\r\n\tprivate previewBadge: HTMLElement | null = null;\r\n\r\n\tconstructor(config: VirtualTryOnConfig) {\r\n\t\tthis.config = {\r\n\t\t\tbaseUrl: config.baseUrl,\r\n\t\t\tproductPageSelector: config.productPageSelector,\r\n\t\t\tgallerySelector: config.gallerySelector,\r\n\t\t\tproductImageSelector: config.productImageSelector,\r\n\t\t\tbuttonPosition: config.buttonPosition,\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Initializes the virtual try-on widget on the current page\r\n\t * @returns Promise that resolves when initialization is complete\r\n\t */\r\n\tpublic async init(): Promise<void> {\r\n\t\ttry {\r\n\t\t\t// Check if we're on a product page\r\n\t\t\tif (!window.location.pathname.includes(this.config.productPageSelector)) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t// Find the gallery container\r\n\t\t\tconst container = document.querySelector(this.config.gallerySelector);\r\n\t\t\tif (!container || !(container instanceof HTMLElement)) {\r\n\t\t\t\tconsole.warn(\r\n\t\t\t\t\t\"[WeWear VTO] Gallery container not found:\",\r\n\t\t\t\t\tthis.config.gallerySelector,\r\n\t\t\t\t);\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t// Ensure container has relative positioning for button placement\r\n\t\t\tif (getComputedStyle(container).position === \"static\") {\r\n\t\t\t\tcontainer.style.position = \"relative\";\r\n\t\t\t}\r\n\r\n\t\t\t// Create and add the virtual try-on button\r\n\t\t\tconst button = createButton(this.config.buttonPosition, async () => {\r\n\t\t\t\tif (this.cameraButton && !this.cameraButton.disabled) {\r\n\t\t\t\t\tawait this.handleTryOnClick();\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n\t\t\t// Store reference to camera button for dynamic enable/disable\r\n\t\t\tthis.cameraButton = button.querySelector(\".ww-camera-btn\");\r\n\t\t\tcontainer.appendChild(button);\r\n\t\t\tconsole.log(\"[WeWear VTO] Widget initialized successfully\");\r\n\r\n\t\t\t// Listen for messages from the photo upload page\r\n\t\t\tthis.setupIframeListener();\r\n\t\t} catch (error) {\r\n\t\t\tconsole.error(\"[WeWear VTO] Initialization failed:\", error);\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Handles virtual try-on button click\r\n\t * @private\r\n\t */\r\n\tprivate async handleTryOnClick(): Promise<void> {\r\n\t\tconsole.log(\"[WeWear VTO] Button clicked, starting try-on process...\");\r\n\r\n\t\ttry {\r\n\t\t\t// Get required data\r\n\t\t\tif (!this.originalProductImageUrl) {\r\n\t\t\t\tconst productImageElement = document.querySelector(\r\n\t\t\t\t\tthis.config.productImageSelector,\r\n\t\t\t\t) as HTMLImageElement;\r\n\t\t\t\tthis.originalProductImageUrl =\r\n\t\t\t\t\tproductImageElement?.src ||\r\n\t\t\t\t\tproductImageElement?.getAttribute(\"data-src\") ||\r\n\t\t\t\t\t\"\";\r\n\t\t\t}\r\n\r\n\t\t\tconst ww_product_image = this.originalProductImageUrl;\r\n\r\n\t\t\tconsole.log(\"[WeWear VTO] Retrieved data:\", {\r\n\t\t\t\tww_product_image,\r\n\t\t\t});\r\n\r\n\t\t\tif (!ww_product_image) {\r\n\t\t\t\tconsole.warn(\r\n\t\t\t\t\t\"[WeWear VTO] Product image not found:\",\r\n\t\t\t\t\tthis.config.productImageSelector,\r\n\t\t\t\t);\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t// Open the photo upload page in a modal\r\n\t\t\tconst photoUploadUrl = new URL(`${this.config.baseUrl}`);\r\n\t\t\tphotoUploadUrl.searchParams.append(\"ww_product_image\", ww_product_image);\r\n\r\n\t\t\tthis.showPhotoUploadModal(photoUploadUrl.toString());\r\n\t\t} catch (error) {\r\n\t\t\tconsole.error(\"[WeWear VTO] Try-on request failed:\", error);\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Shows a modal with an iframe for the photo upload page\r\n\t * @private\r\n\t */\r\n\tprivate showPhotoUploadModal(url: string): void {\r\n\t\t// Remove existing modals\r\n\t\tremoveElements(`.${CSS_CLASSES.MODAL}`);\r\n\r\n\t\tconst modal = document.createElement(\"div\");\r\n\t\tmodal.className = CSS_CLASSES.MODAL;\r\n\t\tmodal.style.cssText = `\r\n position: fixed;\r\n top: 0;\r\n left: 0;\r\n width: 100%;\r\n height: 100%;\r\n background: rgba(0, 0, 0, 0.8);\r\n backdrop-filter: blur(8px);\r\n -webkit-backdrop-filter: blur(8px);\r\n display: flex;\r\n justify-content: center;\r\n align-items: center;\r\n z-index: ${Z_INDEX.MODAL};\r\n animation: ww-modal-fade-in 0.3s ease;\r\n `;\r\n\r\n\t\t// Add fade-in animation\r\n\t\tif (!document.getElementById(\"ww-modal-animation\")) {\r\n\t\t\tconst style = document.createElement(\"style\");\r\n\t\t\tstyle.id = \"ww-modal-animation\";\r\n\t\t\tstyle.textContent = `\r\n\t\t\t\t@keyframes ww-modal-fade-in {\r\n\t\t\t\t\tfrom { opacity: 0; }\r\n\t\t\t\t\tto { opacity: 1; }\r\n\t\t\t\t}\r\n\t\t\t\t@keyframes ww-modal-scale-in {\r\n\t\t\t\t\tfrom { transform: scale(0.95); opacity: 0; }\r\n\t\t\t\t\tto { transform: scale(1); opacity: 1; }\r\n\t\t\t\t}\r\n\t\t\t`;\r\n\t\t\tdocument.head.appendChild(style);\r\n\t\t}\r\n\r\n\t\tconst iframeContainer = document.createElement(\"div\");\r\n\t\tiframeContainer.style.cssText = `\r\n\t\t\tposition: relative;\r\n\t\t\twidth: 90%;\r\n\t\t\theight: 90%;\r\n\t\t\tmax-width: 480px;\r\n\t\t\tmax-height: 720px;\r\n\t\t\tborder-radius: 20px;\r\n\t\t\toverflow: hidden;\r\n\t\t\tbox-shadow: 0 24px 48px rgba(0, 0, 0, 0.3), 0 12px 24px rgba(0, 0, 0, 0.2);\r\n\t\t\tanimation: ww-modal-scale-in 0.3s cubic-bezier(0.4, 0, 0.2, 1);\r\n\t\t\tbackground: white;\r\n\t\t`;\r\n\r\n\t\tconst iframe = document.createElement(\"iframe\");\r\n\t\tiframe.src = url;\r\n\t\tiframe.style.cssText = `\r\n width: 100%;\r\n height: 100%;\r\n border: none;\r\n `;\r\n\r\n\t\tconst closeButton = document.createElement(\"button\");\r\n\t\tcloseButton.innerHTML = `\r\n\t\t\t<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\r\n\t\t\t\t<line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"></line>\r\n\t\t\t\t<line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"></line>\r\n\t\t\t</svg>\r\n\t\t`;\r\n\t\tcloseButton.setAttribute(\"aria-label\", \"Close modal\");\r\n\t\tcloseButton.style.cssText = `\r\n position: absolute;\r\n top: -48px;\r\n right: 0;\r\n background: rgba(255, 255, 255, 0.95);\r\n backdrop-filter: blur(8px);\r\n -webkit-backdrop-filter: blur(8px);\r\n border: none;\r\n border-radius: 50%;\r\n width: 40px;\r\n height: 40px;\r\n cursor: pointer;\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n color: #1f2937;\r\n transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);\r\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);\r\n `;\r\n\t\tcloseButton.onmouseover = () => {\r\n\t\t\tcloseButton.style.transform = \"scale(1.1) rotate(90deg)\";\r\n\t\t\tcloseButton.style.background = \"#ef4444\";\r\n\t\t\tcloseButton.style.color = \"white\";\r\n\t\t};\r\n\t\tcloseButton.onmouseout = () => {\r\n\t\t\tcloseButton.style.transform = \"scale(1) rotate(0deg)\";\r\n\t\t\tcloseButton.style.background = \"rgba(255, 255, 255, 0.95)\";\r\n\t\t\tcloseButton.style.color = \"#1f2937\";\r\n\t\t};\r\n\t\tcloseButton.onclick = () => {\r\n\t\t\tmodal.style.opacity = \"0\";\r\n\t\t\tiframeContainer.style.transform = \"scale(0.95)\";\r\n\t\t\tiframeContainer.style.opacity = \"0\";\r\n\t\t\tsetTimeout(() => modal.remove(), 300);\r\n\t\t};\r\n\r\n\t\tiframeContainer.appendChild(iframe);\r\n\t\tiframeContainer.appendChild(closeButton);\r\n\t\tmodal.appendChild(iframeContainer);\r\n\t\tdocument.body.appendChild(modal);\r\n\r\n\t\t// Close on backdrop click\r\n\t\tmodal.onclick = (e) => {\r\n\t\t\tif (e.target === modal) {\r\n\t\t\t\tcloseButton.click();\r\n\t\t\t}\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Sets up listener for messages from the iframe\r\n\t * @private\r\n\t */\r\n\tprivate setupIframeListener(): void {\r\n\t\t// Remove existing listener if any\r\n\t\tif (this.iframeMessageListener) {\r\n\t\t\twindow.removeEventListener(\"message\", this.iframeMessageListener);\r\n\t\t}\r\n\r\n\t\tthis.iframeMessageListener = (event: MessageEvent) => {\r\n\t\t\tif (event.origin !== new URL(this.config.baseUrl).origin) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tswitch (event.data.type) {\r\n\t\t\t\tcase \"VTO_IMAGE_SELECTED\":\r\n\t\t\t\t\tif (event.data.image) {\r\n\t\t\t\t\t\tthis.lastModelImage = event.data.image;\r\n\t\t\t\t\t\tthis.startVirtualTryOn();\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase \"CLOSE_MODAL\":\r\n\t\t\t\t\tremoveElements(`.${CSS_CLASSES.MODAL}`);\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t};\r\n\r\n\t\twindow.addEventListener(\"message\", this.iframeMessageListener);\r\n\t}\r\n\r\n\tprivate async startVirtualTryOn(isRefresh = false): Promise<void> {\r\n\t\tif (isRefresh) {\r\n\t\t\tconsole.log(\r\n\t\t\t\t\"[WeWear VTO] Refreshing virtual try-on with previous parameters...\",\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\tif (!this.lastModelImage || !this.originalProductImageUrl) {\r\n\t\t\tconsole.warn(\r\n\t\t\t\t\"[WeWear VTO] Missing required data to start virtual try-on.\",\r\n\t\t\t);\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Hide the modal and show loading indicator\r\n\t\tconst modal = document.querySelector(`.${CSS_CLASSES.MODAL}`);\r\n\t\tif (modal && modal instanceof HTMLElement) {\r\n\t\t\tmodal.style.display = \"none\";\r\n\t\t}\r\n\t\tconst container = document.querySelector(this.config.gallerySelector);\r\n\t\tif (container instanceof HTMLElement) {\r\n\t\t\tshowProductLoading(container, \"Generating your virtual try-on...\");\r\n\t\t}\r\n\r\n\t\ttry {\r\n\t\t\tconst submitResponse = await this.callVtoApi(\r\n\t\t\t\tthis.lastModelImage,\r\n\t\t\t\tthis.originalProductImageUrl,\r\n\t\t\t);\r\n\r\n\t\t\tlet status = await this.fetchJobStatus(submitResponse.job_id);\r\n\t\t\tconst previews: string[] = [];\r\n\r\n\t\t\twhile (status.status !== \"COMPLETED\" && status.status !== \"FAILED\") {\r\n\t\t\t\tawait new Promise((r) => setTimeout(r, 3000));\r\n\t\t\t\tstatus = await this.fetchJobStatus(submitResponse.job_id);\r\n\r\n\t\t\t\tfor (let i = previews.length; i < status.previews_available; i++) {\r\n\t\t\t\t\ttry {\r\n\t\t\t\t\t\tconst previewUrl = await this.fetchJobImage(\r\n\t\t\t\t\t\t\tsubmitResponse.job_id,\r\n\t\t\t\t\t\t\ti,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tpreviews.push(previewUrl);\r\n\t\t\t\t\t\tthis.replaceProductImage(previewUrl);\r\n\r\n\t\t\t\t\t\tif (!this.previewBadge && container instanceof HTMLElement) {\r\n\t\t\t\t\t\t\tthis.previewBadge = createPreviewBadge();\r\n\t\t\t\t\t\t\tcontainer.appendChild(this.previewBadge);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t} catch (e) {\r\n\t\t\t\t\t\tif (!(e instanceof Error && e.message === \"202_PROCESSING\"))\r\n\t\t\t\t\t\t\tthrow e;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (status.status === \"COMPLETED\") {\r\n\t\t\t\tconst finalImage = await this.fetchJobImage(submitResponse.job_id);\r\n\t\t\t\tif (finalImage) {\r\n\t\t\t\t\tthis.replaceProductImage(finalImage);\r\n\t\t\t\t}\r\n\t\t\t\tif (this.previewBadge) {\r\n\t\t\t\t\tthis.previewBadge.remove();\r\n\t\t\t\t\tthis.previewBadge = null;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (status.status === \"FAILED\") {\r\n\t\t\t\tconsole.error(\"[WeWear VTO] VTO process failed:\", status.message);\r\n\t\t\t\tif (container instanceof HTMLElement) {\r\n\t\t\t\t\tshowAlert(container, status.message, \"error\");\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t} catch (error) {\r\n\t\t\tconsole.error(\"[WeWear VTO] Error during virtual try-on process:\", error);\r\n\t\t\tif (container instanceof HTMLElement) {\r\n\t\t\t\tshowAlert(container, \"An unexpected error occurred.\", \"error\");\r\n\t\t\t}\r\n\t\t} finally {\r\n\t\t\tif (container instanceof HTMLElement) {\r\n\t\t\t\tremoveProductLoading(container);\r\n\t\t\t}\r\n\t\t\tremoveElements(`.${CSS_CLASSES.MODAL}`);\r\n\t\t}\r\n\t}\r\n\r\n\tprivate async callVtoApi(\r\n\t\tmodelImage: Blob,\r\n\t\tproductImage: string,\r\n\t): Promise<{ job_id: string }> {\r\n\t\tconst formData = new FormData();\r\n\t\tformData.append(\"model_image\", modelImage, \"model_image.png\");\r\n\t\tformData.append(\"ww_product_image\", productImage);\r\n\r\n\t\tconst res = await fetch(`${this.config.baseUrl}/api/vto`, {\r\n\t\t\tmethod: \"POST\",\r\n\t\t\tbody: formData,\r\n\t\t});\r\n\t\tif (!res.ok) {\r\n\t\t\tconst errorText = await res.text();\r\n\t\t\tconsole.error(\r\n\t\t\t\t\"[WeWear VTO] API submission failed:\",\r\n\t\t\t\tres.status,\r\n\t\t\t\terrorText,\r\n\t\t\t);\r\n\t\t\tthrow new Error(`API submission failed: ${res.status}`);\r\n\t\t}\r\n\t\treturn res.json();\r\n\t}\r\n\r\n\tprivate async fetchJobStatus(jobId: string): Promise<JobStatusResponse> {\r\n\t\tconst res = await fetch(\r\n\t\t\t`${this.config.baseUrl}/api/vto/status?job_id=${jobId}`,\r\n\t\t);\r\n\t\tif (!res.ok) throw new Error(`Status check failed: ${res.status}`);\r\n\t\treturn res.json();\r\n\t}\r\n\r\n\tprivate async fetchJobImage(\r\n\t\tjobId: string,\r\n\t\tpreviewIndex?: number,\r\n\t): Promise<string> {\r\n\t\tlet url = `${this.config.baseUrl}/api/vto/image?job_id=${jobId}`;\r\n\t\tif (previewIndex !== undefined) url += `&preview_index=${previewIndex}`;\r\n\r\n\t\tconst res = await fetch(url);\r\n\t\tif (res.status === 202) throw new Error(\"202_PROCESSING\");\r\n\t\tif (!res.ok) throw new Error(`Image fetch failed: ${res.status}`);\r\n\r\n\t\tconst blob = await res.blob();\r\n\t\treturn URL.createObjectURL(blob);\r\n\t}\r\n\r\n\tprivate async refreshVirtualTryOn(): Promise<void> {\r\n\t\tawait this.startVirtualTryOn(true);\r\n\t}\r\n\r\n\t/**\r\n\t * Replaces the product image in the gallery with the virtual try-on result\r\n\t * @private\r\n\t */\r\n\tprivate replaceProductImage(imageUrl: string): void {\r\n\t\ttry {\r\n\t\t\t// Store the virtual try-on image URL\r\n\t\t\tthis.virtualTryOnImageUrl = imageUrl;\r\n\r\n\t\t\t// Find the gallery container\r\n\t\t\tconst container = document.querySelector(this.config.gallerySelector);\r\n\t\t\tif (!container || !(container instanceof HTMLElement)) {\r\n\t\t\t\tconsole.warn(\r\n\t\t\t\t\t\"[WeWear VTO] Gallery container not found for image replacement:\",\r\n\t\t\t\t\tthis.config.gallerySelector,\r\n\t\t\t\t);\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t// Store the original content if not already stored\r\n\t\t\tif (!container.hasAttribute(\"data-ww-original-content\")) {\r\n\t\t\t\tcontainer.setAttribute(\"data-ww-original-content\", container.innerHTML);\r\n\t\t\t}\r\n\r\n\t\t\t// Capture and lock container dimensions before replacement to prevent layout shift\r\n\t\t\tif (!container.hasAttribute(\"data-ww-container-locked\")) {\r\n\t\t\t\tconst containerRect = container.getBoundingClientRect();\r\n\r\n\t\t\t\t// Store original dimensions\r\n\t\t\t\tcontainer.setAttribute(\r\n\t\t\t\t\t\"data-ww-container-width\",\r\n\t\t\t\t\tcontainerRect.width.toString(),\r\n\t\t\t\t);\r\n\t\t\t\tcontainer.setAttribute(\r\n\t\t\t\t\t\"data-ww-container-height\",\r\n\t\t\t\t\tcontainerRect.height.toString(),\r\n\t\t\t\t);\r\n\r\n\t\t\t\t// Lock the container dimensions\r\n\t\t\t\tcontainer.style.width = `${containerRect.width}px`;\r\n\t\t\t\tcontainer.style.height = `${containerRect.height}px`;\r\n\t\t\t\tcontainer.style.minWidth = `${containerRect.width}px`;\r\n\t\t\t\tcontainer.style.minHeight = `${containerRect.height}px`;\r\n\r\n\t\t\t\tcontainer.setAttribute(\"data-ww-container-locked\", \"true\");\r\n\t\t\t}\r\n\r\n\t\t\t// Capture original image dimensions before replacement to prevent layout shift\r\n\t\t\tconst originalImg = container.querySelector(\"img\");\r\n\t\t\tif (\r\n\t\t\t\toriginalImg &&\r\n\t\t\t\t!container.hasAttribute(\"data-ww-original-dimensions\")\r\n\t\t\t) {\r\n\t\t\t\tconst computedStyle = window.getComputedStyle(originalImg);\r\n\t\t\t\tconst rect = originalImg.getBoundingClientRect();\r\n\t\t\t\tcontainer.setAttribute(\"data-ww-original-width\", computedStyle.width);\r\n\t\t\t\tcontainer.setAttribute(\"data-ww-original-height\", computedStyle.height);\r\n\t\t\t\tcontainer.setAttribute(\r\n\t\t\t\t\t\"data-ww-original-rect-width\",\r\n\t\t\t\t\trect.width.toString(),\r\n\t\t\t\t);\r\n\t\t\t\tcontainer.setAttribute(\r\n\t\t\t\t\t\"data-ww-original-rect-height\",\r\n\t\t\t\t\trect.height.toString(),\r\n\t\t\t\t);\r\n\t\t\t\tcontainer.setAttribute(\"data-ww-original-dimensions\", \"true\");\r\n\t\t\t}\r\n\r\n\t\t\t// Show the virtual try-on image initially\r\n\t\t\tthis.showVirtualTryOnImage(container);\r\n\r\n\t\t\t// Replace the button container with the new multi-button version\r\n\t\t\tthis.updateButtonContainer(container);\r\n\r\n\t\t\tconsole.log(\r\n\t\t\t\t\"[WeWear VTO] Product image replaced with virtual try-on result\",\r\n\t\t\t);\r\n\t\t} catch (error) {\r\n\t\t\tconsole.error(\"[WeWear VTO] Error replacing product image:\", error);\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Updates the button container to show all available buttons\r\n\t * @private\r\n\t */\r\n\tprivate updateButtonContainer(container: HTMLElement): void {\r\n\t\t// Remove existing button containers\r\n\t\tconst existingButtons = container.querySelectorAll(\r\n\t\t\t`.${CSS_CLASSES.BUTTON_CONTAINER}`,\r\n\t\t);\r\n\t\texistingButtons.forEach((btn) => {\r\n\t\t\tbtn.remove();\r\n\t\t});\r\n\r\n\t\t// Create new button container with all buttons\r\n\t\tconst buttonContainer = createButtonContainer(\r\n\t\t\tthis.config.buttonPosition,\r\n\t\t\tthis.virtualTryOnImageUrl !== null,\r\n\t\t\tasync () => {\r\n\t\t\t\tawait this.handleTryOnClick();\r\n\t\t\t},\r\n\t\t\tasync () => {\r\n\t\t\t\tawait this.refreshVirtualTryOn();\r\n\t\t\t},\r\n\t\t\t() => {\r\n\t\t\t\tif (this.isShowingVirtualTryOn) {\r\n\t\t\t\t\tthis.showOriginalImage(container);\r\n\t\t\t\t} else {\r\n\t\t\t\t\tthis.showVirtualTryOnImage(container);\r\n\t\t\t\t}\r\n\t\t\t\tremoveProductLoading(container);\r\n\t\t\t\tthis.updateButtonContainer(container);\r\n\t\t\t},\r\n\t\t\tthis.isShowingVirtualTryOn,\r\n\t\t);\r\n\r\n\t\tcontainer.appendChild(buttonContainer);\r\n\t}\r\n\r\n\t/**\r\n\t * Shows the virtual try-on image in the container\r\n\t * @private\r\n\t */\r\n\tprivate showVirtualTryOnImage(container: HTMLElement): void {\r\n\t\tif (!this.virtualTryOnImageUrl) {\r\n\t\t\tconsole.warn(\"[WeWear VTO] No virtual try-on image URL available\");\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Remove all direct children except for the button container\r\n\t\tArray.from(container.children).forEach((child) => {\r\n\t\t\tif (!child.classList.contains(CSS_CLASSES.BUTTON_CONTAINER)) {\r\n\t\t\t\tchild.remove();\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\t// Get stored original dimensions to prevent layout shift\r\n\t\tconst originalWidth =\r\n\t\t\tcontainer.getAttribute(\"data-ww-original-width\") || \"\";\r\n\t\tconst originalHeight =\r\n\t\t\tcontainer.getAttribute(\"data-ww-original-height\") || \"\";\r\n\t\tconst originalRectWidth =\r\n\t\t\tcontainer.getAttribute(\"data-ww-original-rect-width\") || \"\";\r\n\t\tconst originalRectHeight =\r\n\t\t\tcontainer.getAttribute(\"data-ww-original-rect-height\") || \"\";\r\n\r\n\t\tconst image = document.createElement(\"img\");\r\n\t\timage.src = this.virtualTryOnImageUrl;\r\n\t\timage.alt = \"Virtual Try-On Result\";\r\n\r\n\t\t// Use original dimensions to prevent layout shift\r\n\t\tlet widthStyle = \"100%\";\r\n\t\tlet heightStyle = \"100%\";\r\n\r\n\t\t// Prefer computed style dimensions, fallback to bounding rect, then container fill\r\n\t\tif (originalWidth && originalWidth !== \"auto\" && originalWidth !== \"0px\") {\r\n\t\t\twidthStyle = originalWidth;\r\n\t\t} else if (originalRectWidth && originalRectWidth !== \"0\") {\r\n\t\t\twidthStyle = `${originalRectWidth}px`;\r\n\t\t}\r\n\r\n\t\tif (\r\n\t\t\toriginalHeight &&\r\n\t\t\toriginalHeight !== \"auto\" &&\r\n\t\t\toriginalHeight !== \"0px\"\r\n\t\t) {\r\n\t\t\theightStyle = originalHeight;\r\n\t\t} else if (originalRectHeight && originalRectHeight !== \"0\") {\r\n\t\t\theightStyle = `${originalRectHeight}px`;\r\n\t\t}\r\n\r\n\t\timage.style.cssText = `\r\n width: ${widthStyle};\r\n height: ${heightStyle};\r\n object-fit: contain;\r\n `;\r\n\r\n\t\t// Prepend the image to ensure buttons are rendered on top\r\n\t\tcontainer.prepend(image);\r\n\r\n\t\tthis.isShowingVirtualTryOn = true;\r\n\t}\r\n\r\n\t/**\r\n\t * Shows the original product image in the container\r\n\t * @private\r\n\t */\r\n\tprivate showOriginalImage(container: HTMLElement): void {\r\n\t\tconst originalContentHTML = container.getAttribute(\r\n\t\t\t\"data-ww-original-content\",\r\n\t\t);\r\n\t\tif (originalContentHTML) {\r\n\t\t\t// Remove all direct children except for the button container\r\n\t\t\tArray.from(container.children).forEach((child) => {\r\n\t\t\t\tif (!child.classList.contains(CSS_CLASSES.BUTTON_CONTAINER)) {\r\n\t\t\t\t\tchild.remove();\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n\t\t\t// Parse the original content and prepend it\r\n\t\t\tconst tempDiv = document.createElement(\"div\");\r\n\t\t\ttempDiv.innerHTML = originalContentHTML;\r\n\t\t\tcontainer.prepend(...Array.from(tempDiv.children));\r\n\t\t}\r\n\r\n\t\tthis.isShowingVirtualTryOn = false;\r\n\t}\r\n\r\n\t/**\r\n\t * Destroys the widget and cleans up resources\r\n\t */\r\n\tpublic destroy(): void {\r\n\t\ttry {\r\n\t\t\t// Remove all buttons\r\n\t\t\tremoveElements(`.${CSS_CLASSES.BUTTON_CONTAINER}`);\r\n\r\n\t\t\t// Remove all modals\r\n\t\t\tremoveElements(`.${CSS_CLASSES.MODAL}`);\r\n\r\n\t\t\t// Clear references\r\n\t\t\tthis.cameraButton = null;\r\n\r\n\t\t\t// Remove message listener\r\n\t\t\tif (this.iframeMessageListener) {\r\n\t\t\t\twindow.removeEventListener(\"message\", this.iframeMessageListener);\r\n\t\t\t\tthis.iframeMessageListener = null;\r\n\t\t\t}\r\n\r\n\t\t\t// Reset state\r\n\t\t\tthis.virtualTryOnImageUrl = null;\r\n\t\t\tthis.isShowingVirtualTryOn = false;\r\n\t\t\tthis.lastModelImage = null;\r\n\t\t\tthis.originalProductImageUrl = null;\r\n\t\t\tif (this.previewBadge) {\r\n\t\t\t\tthis.previewBadge.remove();\r\n\t\t\t\tthis.previewBadge = null;\r\n\t\t\t}\r\n\r\n\t\t\tconsole.log(\"[WeWear VTO] Widget destroyed successfully\");\r\n\t\t} catch (error) {\r\n\t\t\tconsole.error(\"[WeWear VTO] Error during widget destruction:\", error);\r\n\t\t}\r\n\t}\r\n}\r\n","import type { VirtualTryOnConfig } from \"./index.js\";\nimport { VirtualTryOnWidget } from \"./widget.js\";\n\nlet widgetInstance: VirtualTryOnWidget | null = null;\n\nexport function initVirtualTryOn(config?: VirtualTryOnConfig): void {\n\ttry {\n\t\t// Clean up any existing instance\n\t\tif (widgetInstance) {\n\t\t\twidgetInstance.destroy();\n\t\t\twidgetInstance = null;\n\t\t}\n\n\t\t// Early return if config is missing\n\t\tif (!config) {\n\t\t\tconsole.log(\n\t\t\t\t\"[WeWear VTO] Missing configuration. Widget not initialized.\",\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\t// Create and initialize new instance\n\t\twidgetInstance = new VirtualTryOnWidget(config);\n\n\t\t// Initialize immediately if DOM is ready, otherwise wait for it\n\t\tif (document.readyState === \"loading\") {\n\t\t\tdocument.addEventListener(\"DOMContentLoaded\", () => {\n\t\t\t\twidgetInstance?.init().catch((error) => {\n\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\"[WeWear VTO] Failed to initialize after DOM ready:\",\n\t\t\t\t\t\terror,\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t\t});\n\t\t} else {\n\t\t\twidgetInstance.init().catch((error) => {\n\t\t\t\tconsole.error(\"[WeWear VTO] Failed to initialize:\", error);\n\t\t\t});\n\t\t}\n\t} catch (error) {\n\t\tconsole.error(\"[WeWear VTO] Initialization error:\", error);\n\t}\n}\n\nexport function getWidgetInstance(): VirtualTryOnWidget | null {\n\treturn widgetInstance;\n}\n\nif (typeof window !== \"undefined\") {\n\tinitVirtualTryOn();\n}\n"],"names":[],"mappings":"AAAA;AACO,MAAM,WAAW,GAAG;AAC1B,IAAA,gBAAgB,EAAE,6BAA6B;AAC/C,IAAA,MAAM,EAAE,mBAAmB;AAC3B,IAAA,KAAK,EAAE,kBAAkB;AACzB,IAAA,aAAa,EAAE,sBAAsB;CAC5B;AAEV;AACO,MAAM,OAAO,GAAG;AACtB,IAAA,MAAM,EAAE,EAAE;AACV,IAAA,KAAK,E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C;;AAG/C,QAAA,IAAI,QAAQ,CAAC,UAAU,KAAK,SAAS,EAAE;AACtC,YAAA,QAAQ,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,MAAK;AAClD,gBAAA,cAAc,KAAA,IAAA,IAAd,cAAc,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAd,cAAc,CAAE,IAAI,EAAA,CAAG,KAAK,CAAC,CAAC,KAAK,KAAI;AACtC,oBAAA,OAAO,CAAC,KAAK,CACZ,oDAAoD,EACpD,KAAK,CACL;AACF,gBAAA,CAAC,CAAC;AACH,YAAA,CAAC,CAAC;QACH;aAAO;YACN,cAAc,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,KAAI;AACrC,gBAAA,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,KAAK,CAAC;AAC3D,YAAA,CAAC,CAAC;QACH;IACD;IAAE,OAAO,KAAK,EAAE;AACf,QAAA,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,KAAK,CAAC;IAC3D;AACD;SAEgB,iBAAiB,GAAA;AAChC,IAAA,OAAO,cAAc;AACtB;AAEA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AAClC,IAAA,gBAAgB,EAAE;AACnB;;;;"}
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/constants.ts","../src/components/badge.ts","../src/utils.ts","../src/components/button.ts","../src/components/loading-overlay.ts","../src/components/alert-overlay.ts","../src/widget.ts","../src/installer.ts"],"sourcesContent":["/** CSS class names for consistent styling */\nexport const CSS_CLASSES = {\n\tBUTTON_CONTAINER: \"wewear-vto-button-container\",\n\tBUTTON: \"wewear-vto-button\",\n\tMODAL: \"wewear-vto-modal\",\n\tPREVIEW_BADGE: \"ww-vto-preview-badge\",\n} as const;\n\n/** Z-index values for proper layering */\nexport const Z_INDEX = {\n\tBUTTON: 10,\n\tMODAL: 99999,\n} as const;\n","import { CSS_CLASSES } from \"../constants.js\";\r\n\r\nexport function createPreviewBadge(): HTMLElement {\r\n\tconst badge = document.createElement(\"div\");\r\n\tbadge.className = CSS_CLASSES.PREVIEW_BADGE;\r\n\tbadge.innerText = \"PREVIEW\";\r\n\r\n\tconst styleId = \"ww-vto-badge-styles\";\r\n\tif (!document.getElementById(styleId)) {\r\n\t\tconst styles = document.createElement(\"style\");\r\n\t\tstyles.id = styleId;\r\n\t\tstyles.innerHTML = `\r\n .${CSS_CLASSES.PREVIEW_BADGE} {\r\n position: absolute;\r\n top: 20px;\r\n right: 20px;\r\n background: rgba(31, 41, 55, 0.9);\r\n backdrop-filter: blur(4px);\r\n -webkit-backdrop-filter: blur(4px);\r\n color: white;\r\n padding: 6px 14px;\r\n border-radius: 6px;\r\n font-size: 12px;\r\n font-weight: 600;\r\n letter-spacing: 0.5px;\r\n z-index: 10;\r\n pointer-events: none;\r\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif;\r\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);\r\n animation: ww-vto-pulse 2s ease-in-out infinite;\r\n }\r\n\r\n @keyframes ww-vto-pulse {\r\n 0%, 100% {\r\n opacity: 0.9;\r\n }\r\n 50% {\r\n opacity: 1;\r\n }\r\n }\r\n `;\r\n\t\tdocument.head.appendChild(styles);\r\n\t}\r\n\r\n\treturn badge;\r\n}\r\n","export function getPositionStyles(position: string): string {\n\tswitch (position) {\n\t\tcase \"bottom-left\":\n\t\t\treturn \"left: 20px; bottom: 20px;\";\n\t\tcase \"top-right\":\n\t\t\treturn \"right: 20px; top: 20px;\";\n\t\tcase \"top-left\":\n\t\t\treturn \"left: 20px; top: 20px;\";\n\t\tdefault:\n\t\t\treturn \"right: 20px; bottom: 20px;\";\n\t}\n}\n\nexport function removeElements(selector: string): void {\n\tconst elements = document.querySelectorAll(selector);\n\telements.forEach((element) => {\n\t\telement.remove();\n\t});\n}\n","import { CSS_CLASSES, Z_INDEX } from \"../constants.js\";\r\nimport { getPositionStyles } from \"../utils.js\";\r\n\r\nexport function createButtonContainer(\r\n\tbuttonPosition: string,\r\n\thasVirtualTryOn: boolean = false,\r\n\tonCameraClick: () => void,\r\n\tonRefreshClick?: () => void,\r\n\tonToggleClick?: () => void,\r\n\tisShowingVirtualTryOn: boolean = false,\r\n): HTMLElement {\r\n\tconst container = document.createElement(\"div\");\r\n\tcontainer.className = `${CSS_CLASSES.BUTTON_CONTAINER} ww-button-group`;\r\n\r\n\tconst positionStyles = getPositionStyles(buttonPosition);\r\n\tcontainer.style.cssText = `\r\n position: absolute;\r\n ${positionStyles}\r\n display: flex;\r\n gap: 4px;\r\n border-radius: 100px;\r\n background: white;\r\n padding: 4px;\r\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\r\n z-index: ${Z_INDEX.BUTTON};\r\n transition: all 0.2s ease;\r\n `;\r\n\r\n\t// Camera button\r\n\tconst cameraButton = document.createElement(\"button\");\r\n\tcameraButton.type = \"button\";\r\n\tcameraButton.className = `${CSS_CLASSES.BUTTON} ww-camera-btn`;\r\n\tcameraButton.setAttribute(\"aria-label\", \"Virtual Try-On\");\r\n\tcameraButton.style.cssText = `\r\n display: flex;\r\n width: 40px;\r\n height: 40px;\r\n cursor: pointer;\r\n align-items: center;\r\n justify-content: center;\r\n border-radius: 100px;\r\n padding: 0;\r\n border: none;\r\n background: white;\r\n color: #000000;\r\n transition: all 0.2s ease;\r\n flex-shrink: 0;\r\n `;\r\n\r\n\tcameraButton.innerHTML = `\r\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"display: block;\">\r\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>\r\n <circle cx=\"12\" cy=\"13\" r=\"3\"></circle>\r\n </svg>\r\n `;\r\n\r\n\tcameraButton.onclick = onCameraClick;\r\n\tcontainer.appendChild(cameraButton);\r\n\r\n\t// Add refresh and toggle buttons if we have a virtual try-on\r\n\tif (hasVirtualTryOn) {\r\n\t\t// Refresh button - calls API again\r\n\t\tif (onRefreshClick) {\r\n\t\t\tconst refreshButton = document.createElement(\"button\");\r\n\t\t\trefreshButton.type = \"button\";\r\n\t\t\trefreshButton.className = \"ww-refresh-btn\";\r\n\t\t\trefreshButton.setAttribute(\"aria-label\", \"Refresh virtual try-on\");\r\n\t\t\trefreshButton.style.cssText = `\r\n display: flex;\r\n width: 40px;\r\n height: 40px;\r\n cursor: pointer;\r\n align-items: center;\r\n justify-content: center;\r\n border-radius: 100px;\r\n padding: 0;\r\n border: none;\r\n background: white;\r\n color: #333333;\r\n transition: all 0.2s ease;\r\n flex-shrink: 0;\r\n `;\r\n\r\n\t\t\trefreshButton.innerHTML = `\r\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"display: block;\">\r\n <path d=\"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8\"></path>\r\n <path d=\"M3 3v5h5\"></path>\r\n <path d=\"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16\"></path>\r\n <path d=\"M16 16h5v5\"></path>\r\n </svg>\r\n `;\r\n\r\n\t\t\trefreshButton.onclick = onRefreshClick;\r\n\r\n\t\t\trefreshButton.onclick = onRefreshClick;\r\n\t\t\tcontainer.appendChild(refreshButton);\r\n\t\t}\r\n\r\n\t\t// Toggle button (scan-face) - switches between original and virtual try-on\r\n\t\tif (onToggleClick) {\r\n\t\t\tconst toggleButton = document.createElement(\"button\");\r\n\t\t\ttoggleButton.type = \"button\";\r\n\t\t\ttoggleButton.className = \"ww-toggle-btn\";\r\n\t\t\ttoggleButton.setAttribute(\r\n\t\t\t\t\"aria-label\",\r\n\t\t\t\tisShowingVirtualTryOn ? \"Show Original Image\" : \"Show Virtual Try-On\",\r\n\t\t\t);\r\n\t\t\ttoggleButton.style.cssText = `\r\n display: flex;\r\n width: 40px;\r\n height: 40px;\r\n cursor: pointer;\r\n align-items: center;\r\n justify-content: center;\r\n border-radius: 100px;\r\n padding: 0;\r\n border: none;\r\n background: ${isShowingVirtualTryOn ? \"#333333\" : \"#e5e7eb\"};\r\n color: ${isShowingVirtualTryOn ? \"white\" : \"#333333\"};\r\n transition: all 0.2s ease;\r\n flex-shrink: 0;\r\n `;\r\n\r\n\t\t\ttoggleButton.innerHTML = `\r\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"display: block;\">\r\n <path d=\"M3 7V5a2 2 0 0 1 2-2h2\"></path>\r\n <path d=\"M17 3h2a2 2 0 0 1 2 2v2\"></path>\r\n <path d=\"M21 17v2a2 2 0 0 1-2 2h-2\"></path>\r\n <path d=\"M7 21H5a2 2 0 0 1-2-2v-2\"></path>\r\n <path d=\"M8 14s1.5 2 4 2 4-2 4-2\"></path>\r\n <path d=\"M9 9h.01\"></path>\r\n <path d=\"M15 9h.01\"></path>\r\n </svg>\r\n `;\r\n\r\n\t\t\ttoggleButton.onmouseover = () => {\r\n\t\t\t\tif (isShowingVirtualTryOn) {\r\n\t\t\t\t\ttoggleButton.style.background = \"#4a4a4a\";\r\n\t\t\t\t} else {\r\n\t\t\t\t\ttoggleButton.style.background = \"#d1d5db\";\r\n\t\t\t\t}\r\n\t\t\t};\r\n\t\t\ttoggleButton.onmouseout = () => {\r\n\t\t\t\tif (isShowingVirtualTryOn) {\r\n\t\t\t\t\ttoggleButton.style.background = \"#333333\";\r\n\t\t\t\t} else {\r\n\t\t\t\t\ttoggleButton.style.background = \"#e5e7eb\";\r\n\t\t\t\t}\r\n\t\t\t};\r\n\r\n\t\t\ttoggleButton.onclick = onToggleClick;\r\n\t\t\tcontainer.appendChild(toggleButton);\r\n\t\t}\r\n\t}\r\n\r\n\treturn container;\r\n}\r\n\r\nexport function createButton(\r\n\tbuttonPosition: string,\r\n\tonClick: () => void,\r\n\tdisabled: boolean = false,\r\n): HTMLElement {\r\n\tconst container = createButtonContainer(buttonPosition, false, onClick);\r\n\tconst cameraButton = container.querySelector(\r\n\t\t\".ww-camera-btn\",\r\n\t) as HTMLButtonElement;\r\n\tif (cameraButton) {\r\n\t\tcameraButton.disabled = disabled;\r\n\t\tif (disabled) {\r\n\t\t\tcameraButton.style.opacity = \"0.5\";\r\n\t\t\tcameraButton.style.cursor = \"not-allowed\";\r\n\t\t\tcameraButton.title = \"Find your ideal size first\";\r\n\t\t}\r\n\t}\r\n\treturn container;\r\n}\r\n","import { Z_INDEX } from \"../constants.js\";\r\n\r\n/**\r\n * Creates a loading overlay that can be shown in different containers\r\n */\r\nexport function createLoadingOverlay(\r\n\ttext: string = \"Processing...\",\r\n): HTMLElement {\r\n\tconst overlay = document.createElement(\"div\");\r\n\toverlay.className = \"ww-loading-overlay\";\r\n\toverlay.style.cssText = `\r\n position: absolute;\r\n top: 0;\r\n left: 0;\r\n width: 100%;\r\n height: 100%;\r\n background: linear-gradient(135deg, rgba(0, 0, 0, 0.92) 0%, rgba(0, 0, 0, 0.88) 100%);\r\n backdrop-filter: blur(8px);\r\n -webkit-backdrop-filter: blur(8px);\r\n display: flex;\r\n flex-direction: column;\r\n align-items: center;\r\n justify-content: center;\r\n z-index: ${Z_INDEX.MODAL + 1};\r\n border-radius: inherit;\r\n animation: ww-fade-in 0.3s ease;\r\n `;\r\n\r\n\t// Add CSS animation to the document if not already added\r\n\tif (!document.getElementById(\"ww-loading-animation\")) {\r\n\t\tconst style = document.createElement(\"style\");\r\n\t\tstyle.id = \"ww-loading-animation\";\r\n\t\tstyle.textContent = `\r\n @keyframes ww-fade-in {\r\n from { opacity: 0; }\r\n to { opacity: 1; }\r\n }\r\n \r\n @keyframes ww-pulse-logo {\r\n 0%, 100% { \r\n opacity: 0.8; \r\n transform: scale(1);\r\n }\r\n 50% { \r\n opacity: 1; \r\n transform: scale(1.05);\r\n }\r\n }\r\n \r\n @keyframes ww-spinner-rotate {\r\n 0% { transform: rotate(0deg); }\r\n 100% { transform: rotate(360deg); }\r\n }\r\n \r\n @keyframes ww-dot-bounce {\r\n 0%, 80%, 100% { \r\n transform: scale(0);\r\n opacity: 0.5;\r\n }\r\n 40% { \r\n transform: scale(1);\r\n opacity: 1;\r\n }\r\n }\r\n \r\n .ww-loading-logo {\r\n animation: ww-pulse-logo 2s ease-in-out infinite;\r\n }\r\n \r\n .ww-loading-spinner {\r\n animation: ww-spinner-rotate 1s linear infinite;\r\n }\r\n `;\r\n\t\tdocument.head.appendChild(style);\r\n\t}\r\n\r\n\toverlay.innerHTML = `\r\n <div style=\"display: flex; flex-direction: column; align-items: center; gap: 32px;\">\r\n <div style=\"position: relative; width: 120px; height: 120px; display: flex; align-items: center; justify-content: center;\">\r\n <!-- Outer spinning circle -->\r\n <div class=\"ww-loading-spinner\" style=\"\r\n position: absolute;\r\n width: 120px;\r\n height: 120px;\r\n border: 3px solid transparent;\r\n border-top: 3px solid #333333;\r\n border-right: 3px solid #333333;\r\n border-radius: 50%;\r\n \"></div>\r\n \r\n <!-- Logo -->\r\n <svg class=\"ww-loading-logo\" width=\"80\" height=\"50\" viewBox=\"0 0 214 135\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <path d=\"M102.906 74.8679C102.906 77.9717 101.574 80.7453 98.9104 83.1887C96.6871 85.1918 93.9025 86.6997 90.5566 87.7123C87.695 88.5708 84.6462 89 81.4104 89C73.8821 89 68.0047 87.0189 63.7783 83.0566C59.5519 87.0189 53.6855 89 46.1792 89C42.9434 89 39.9057 88.5708 37.066 87.7123C33.7201 86.6997 30.9245 85.1918 28.6792 83.1887C26.0157 80.7453 24.684 77.9717 24.684 74.8679V41.6509H32.3774V74.8679C32.3774 76.2547 33.489 77.5645 35.7123 78.7972C37.3632 79.7217 39.0692 80.3711 40.8302 80.7453C42.5252 81.1195 44.3082 81.3066 46.1792 81.3066C48.0063 81.3066 49.7673 81.1195 51.4623 80.7453C53.2453 80.3711 54.9623 79.7217 56.6132 78.7972C58.8585 77.5645 59.9811 76.2547 59.9811 74.8679V41.6509H67.6085V74.8679C67.6085 76.2547 68.7311 77.5645 70.9764 78.7972C72.6274 79.7217 74.3443 80.3711 76.1274 80.7453C77.8223 81.1195 79.5833 81.3066 81.4104 81.3066C83.2814 81.3066 85.0755 81.1195 86.7925 80.7453C88.5314 80.3711 90.2264 79.7217 91.8774 78.7972C94.1006 77.5645 95.2123 76.2547 95.2123 74.8679V41.6509H102.906V74.8679ZM189.283 74.8679C189.283 77.9717 187.951 80.7453 185.288 83.1887C183.064 85.1918 180.28 86.6997 176.934 87.7123C174.072 88.5708 171.024 89 167.788 89C160.259 89 154.382 87.0189 150.156 83.0566C145.929 87.0189 140.063 89 132.557 89C129.321 89 126.283 88.5708 123.443 87.7123C120.097 86.6997 117.302 85.1918 115.057 83.1887C112.393 80.7453 111.061 77.9717 111.061 74.8679V41.6509H118.755V74.8679C118.755 76.2547 119.866 77.5645 122.09 78.7972C123.741 79.7217 125.447 80.3711 127.208 80.7453C128.903 81.1195 130.686 81.3066 132.557 81.3066C134.384 81.3066 136.145 81.1195 137.84 80.7453C139.623 80.3711 141.34 79.7217 142.991 78.7972C145.236 77.5645 146.358 76.2547 146.358 74.8679V41.6509H153.986V74.8679C153.986 76.2547 155.108 77.5645 157.354 78.7972C159.005 79.7217 160.722 80.3711 162.505 80.7453C164.2 81.1195 165.961 81.3066 167.788 81.3066C169.659 81.3066 171.453 81.1195 173.17 80.7453C174.909 80.3711 176.604 79.7217 178.255 78.7972C180.478 77.5645 181.59 76.2547 181.59 74.8679V41.6509H189.283V74.8679Z\" fill=\"white\"/>\r\n </svg>\r\n </div>\r\n \r\n <div style=\"font-size: 17px; font-weight: 500; text-align: center; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; color: white; letter-spacing: 0.5px; max-width: 280px;\">${text}</div>\r\n \r\n <div style=\"display: flex; gap: 10px; margin-top: 4px;\">\r\n <div style=\"width: 10px; height: 10px; border-radius: 50%; background: #333333; animation: ww-dot-bounce 1.4s ease-in-out infinite;\"></div>\r\n <div style=\"width: 10px; height: 10px; border-radius: 50%; background: #333333; animation: ww-dot-bounce 1.4s ease-in-out 0.2s infinite;\"></div>\r\n <div style=\"width: 10px; height: 10px; border-radius: 50%; background: #333333; animation: ww-dot-bounce 1.4s ease-in-out 0.4s infinite;\"></div>\r\n </div>\r\n </div>\r\n `;\r\n\r\n\treturn overlay;\r\n}\r\n\r\n/**\r\n * Shows a loading overlay in the product gallery container\r\n */\r\nexport function showProductLoading(\r\n\tcontainer: HTMLElement,\r\n\ttext: string = \"Generating virtual try-on...\",\r\n): void {\r\n\t// Remove any existing loading overlays\r\n\tremoveProductLoading(container);\r\n\r\n\t// Make container relative if it's not already positioned\r\n\tconst computedStyle = window.getComputedStyle(container);\r\n\tif (computedStyle.position === \"static\") {\r\n\t\tcontainer.style.position = \"relative\";\r\n\t}\r\n\r\n\tconst loadingOverlay = createLoadingOverlay(text);\r\n\tcontainer.appendChild(loadingOverlay);\r\n}\r\n\r\n/**\r\n * Removes loading overlay from product container\r\n */\r\nexport function removeProductLoading(container: HTMLElement): void {\r\n\tconst existingOverlay = container.querySelector(\".ww-loading-overlay\");\r\n\tif (existingOverlay) {\r\n\t\texistingOverlay.remove();\r\n\t}\r\n}\r\n","export function showAlert(\r\n\tcontainer: HTMLElement,\r\n\tmessage: string,\r\n\ttype: \"error\" | \"warning\",\r\n) {\r\n\tremoveAlert(container); // Remove any existing alert\r\n\r\n\tconst alertDiv = document.createElement(\"div\");\r\n\talertDiv.className = `ww-alert ww-alert-${type}`;\r\n\talertDiv.setAttribute(\"role\", type === \"error\" ? \"alert\" : \"status\");\r\n\talertDiv.setAttribute(\"aria-live\", \"assertive\");\r\n\r\n\tconst bgColor =\r\n\t\ttype === \"error\"\r\n\t\t\t? \"linear-gradient(135deg, #fee2e2 0%, #fecaca 100%)\"\r\n\t\t\t: \"linear-gradient(135deg, #fef9c3 0%, #fde68a 100%)\";\r\n\tconst textColor = type === \"error\" ? \"#991b1b\" : \"#78350f\";\r\n\tconst borderColor = type === \"error\" ? \"#f87171\" : \"#fbbf24\";\r\n\tconst iconColor = type === \"error\" ? \"#dc2626\" : \"#d97706\";\r\n\r\n\talertDiv.style.cssText = `\r\n position: absolute;\r\n top: 24px;\r\n left: 50%;\r\n transform: translateX(-50%) translateY(-20px);\r\n background: ${bgColor};\r\n color: ${textColor};\r\n border: 1px solid ${borderColor};\r\n border-radius: 12px;\r\n padding: 16px 20px;\r\n z-index: 9999;\r\n font-size: 15px;\r\n font-weight: 500;\r\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);\r\n backdrop-filter: blur(8px);\r\n -webkit-backdrop-filter: blur(8px);\r\n display: flex;\r\n align-items: center;\r\n gap: 12px;\r\n min-width: 280px;\r\n max-width: 90%;\r\n opacity: 0;\r\n transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);\r\n `;\r\n\r\n\tconst icon =\r\n\t\ttype === \"error\"\r\n\t\t\t? `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"${iconColor}\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\r\n\t\t\t<circle cx=\"12\" cy=\"12\" r=\"10\"/><line x1=\"12\" y1=\"8\" x2=\"12\" y2=\"12\"/><line x1=\"12\" y1=\"16\" x2=\"12.01\" y2=\"16\"/>\r\n\t\t</svg>`\r\n\t\t\t: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"${iconColor}\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\r\n\t\t\t<path d=\"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z\"/><line x1=\"12\" y1=\"9\" x2=\"12\" y2=\"13\"/><line x1=\"12\" y1=\"17\" x2=\"12.01\" y2=\"17\"/>\r\n\t\t</svg>`;\r\n\r\n\talertDiv.innerHTML = `\r\n ${icon}\r\n <span style=\"flex: 1; line-height: 1.5;\">${message}</span>\r\n <button type=\"button\" aria-label=\"Close alert\"\r\n style=\"\r\n background: none;\r\n border: none;\r\n font-size: 22px;\r\n color: ${textColor};\r\n cursor: pointer;\r\n padding: 0;\r\n line-height: 1;\r\n opacity: 0.7;\r\n transition: opacity 0.2s ease;\r\n width: 24px;\r\n height: 24px;\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n \"\r\n onmouseover=\"this.style.opacity='1'\"\r\n onmouseout=\"this.style.opacity='0.7'\">\r\n ×\r\n </button>\r\n `;\r\n\r\n\t// Close on button click\r\n\talertDiv.querySelector(\"button\")?.addEventListener(\"click\", () => {\r\n\t\tfadeOutAndRemove(alertDiv);\r\n\t});\r\n\r\n\tcontainer.appendChild(alertDiv);\r\n\r\n\t// Animate in\r\n\trequestAnimationFrame(() => {\r\n\t\talertDiv.style.opacity = \"1\";\r\n\t\talertDiv.style.transform = \"translateX(-50%) translateY(0)\";\r\n\t});\r\n\r\n\t// Auto-dismiss after 8 seconds\r\n\tsetTimeout(() => {\r\n\t\tif (alertDiv.parentElement) {\r\n\t\t\tfadeOutAndRemove(alertDiv);\r\n\t\t}\r\n\t}, 8000);\r\n}\r\n\r\nfunction fadeOutAndRemove(element: HTMLElement) {\r\n\telement.style.opacity = \"0\";\r\n\telement.style.transform = \"translateX(-50%) translateY(-20px)\";\r\n\tsetTimeout(() => {\r\n\t\telement.remove();\r\n\t}, 300);\r\n}\r\n\r\nexport function removeAlert(container: HTMLElement) {\r\n\tconst alert = container.querySelector(\".ww-alert\") as HTMLElement;\r\n\tif (alert) fadeOutAndRemove(alert);\r\n}\r\n","import { CSS_CLASSES } from \"./constants.js\";\r\nimport {\r\n\tcreateButton,\r\n\tcreateButtonContainer,\r\n\tremoveProductLoading,\r\n\tshowProductLoading,\r\n\tcreatePreviewBadge,\r\n} from \"./components/index.js\";\r\nimport type { VirtualTryOnConfig } from \"./index.js\";\r\nimport { removeElements } from \"./utils.js\";\r\nimport { showAlert } from \"./components/alert-overlay.js\";\r\n\r\n/**\r\n * Job status type\r\n */\r\ntype JobStatus = \"PENDING\" | \"PREVIEW_AVAILABLE\" | \"COMPLETED\" | \"FAILED\";\r\n\r\n/**\r\n * Response from the job status endpoint\r\n */\r\ninterface JobStatusResponse {\r\n\tstatus: JobStatus;\r\n\tpreviews_available: number;\r\n\tmessage: string;\r\n}\r\n\r\nexport class VirtualTryOnWidget {\r\n\tprivate readonly config: Required<VirtualTryOnConfig>;\r\n\tprivate virtualTryOnImageUrl: string | null = null;\r\n\tprivate originalProductImageUrl: string | null = null;\r\n\tprivate originalProductImages: string[] = []; // Store all original product images\r\n\tprivate isShowingVirtualTryOn: boolean = false;\r\n\tprivate lastModelImage: Blob | null = null;\r\n\tprivate cameraButton: HTMLButtonElement | null = null;\r\n\tprivate iframeMessageListener: ((event: MessageEvent) => void) | null = null;\r\n\tprivate previewBadge: HTMLElement | null = null;\r\n\r\n\tconstructor(config: VirtualTryOnConfig) {\r\n\t\tthis.config = {\r\n\t\t\tbaseUrl: config.baseUrl,\r\n\t\t\tproductPageSelector: config.productPageSelector,\r\n\t\t\tgallerySelector: config.gallerySelector,\r\n\t\t\tproductImageSelector: config.productImageSelector,\r\n\t\t\tbuttonPosition: config.buttonPosition,\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Initializes the virtual try-on widget on the current page\r\n\t * @returns Promise that resolves when initialization is complete\r\n\t */\r\n\tpublic async init(): Promise<void> {\r\n\t\ttry {\r\n\t\t\t// Check if we're on a product page\r\n\t\t\tif (!window.location.pathname.includes(this.config.productPageSelector)) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t// Find the gallery container\r\n\t\t\tconst container = document.querySelector(this.config.gallerySelector);\r\n\t\t\tif (!container || !(container instanceof HTMLElement)) {\r\n\t\t\t\tconsole.warn(\r\n\t\t\t\t\t\"[WeWear VTO] Gallery container not found:\",\r\n\t\t\t\t\tthis.config.gallerySelector,\r\n\t\t\t\t);\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t// Ensure container has relative positioning for button placement\r\n\t\t\tif (getComputedStyle(container).position === \"static\") {\r\n\t\t\t\tcontainer.style.position = \"relative\";\r\n\t\t\t}\r\n\r\n\t\t\t// Create and add the virtual try-on button\r\n\t\t\tconst button = createButton(this.config.buttonPosition, async () => {\r\n\t\t\t\tif (this.cameraButton && !this.cameraButton.disabled) {\r\n\t\t\t\t\tawait this.handleTryOnClick();\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n\t\t\t// Store reference to camera button for dynamic enable/disable\r\n\t\t\tthis.cameraButton = button.querySelector(\".ww-camera-btn\");\r\n\t\t\tcontainer.appendChild(button);\r\n\t\t\tconsole.log(\"[WeWear VTO] Widget initialized successfully\");\r\n\r\n\t\t\t// Listen for messages from the photo upload page\r\n\t\t\tthis.setupIframeListener();\r\n\t\t} catch (error) {\r\n\t\t\tconsole.error(\"[WeWear VTO] Initialization failed:\", error);\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Handles virtual try-on button click\r\n\t * @private\r\n\t */\r\n\tprivate async handleTryOnClick(): Promise<void> {\r\n\t\tconsole.log(\"[WeWear VTO] Button clicked, starting try-on process...\");\r\n\r\n\t\ttry {\r\n\t\t\t// Store original images on first click if not already stored\r\n\t\t\tif (this.originalProductImages.length === 0) {\r\n\t\t\t\tthis.originalProductImages = this.getAllProductImages();\r\n\t\t\t\tconsole.log(\r\n\t\t\t\t\t\"[WeWear VTO] Stored original product images:\",\r\n\t\t\t\t\tthis.originalProductImages,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\r\n\t\t\tconsole.log(\"[WeWear VTO] Retrieved data:\", {\r\n\t\t\t\tproductImages: this.originalProductImages,\r\n\t\t\t});\r\n\r\n\t\t\tif (this.originalProductImages.length === 0) {\r\n\t\t\t\tconsole.warn(\r\n\t\t\t\t\t\"[WeWear VTO] Product images not found:\",\r\n\t\t\t\t\tthis.config.productImageSelector,\r\n\t\t\t\t);\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t// Store the first image as the original\r\n\t\t\tif (!this.originalProductImageUrl) {\r\n\t\t\t\tthis.originalProductImageUrl = this.originalProductImages[0];\r\n\t\t\t}\r\n\r\n\t\t\t// Open the photo upload page in a modal\r\n\t\t\tconst photoUploadUrl = new URL(`${this.config.baseUrl}`);\r\n\t\t\t// Pass all product images as a comma-separated string\r\n\t\t\tphotoUploadUrl.searchParams.append(\r\n\t\t\t\t\"ww_product_images\",\r\n\t\t\t\tthis.originalProductImages.join(\",\"),\r\n\t\t\t);\r\n\r\n\t\t\tthis.showPhotoUploadModal(photoUploadUrl.toString());\r\n\t\t} catch (error) {\r\n\t\t\tconsole.error(\"[WeWear VTO] Try-on request failed:\", error);\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Gets all product images from the gallery\r\n\t * @private\r\n\t * @returns Array of product image URLs\r\n\t */\r\n\tprivate getAllProductImages(): string[] {\r\n\t\tconst productImageElements = document.querySelectorAll(\r\n\t\t\tthis.config.productImageSelector,\r\n\t\t) as NodeListOf<HTMLImageElement>;\r\n\r\n\t\tconst images: string[] = [];\r\n\r\n\t\tproductImageElements.forEach((img) => {\r\n\t\t\tconst imageUrl =\r\n\t\t\t\timg.src ||\r\n\t\t\t\timg.getAttribute(\"data-src\") ||\r\n\t\t\t\timg.getAttribute(\"data-large_image\") ||\r\n\t\t\t\t\"\";\r\n\r\n\t\t\t// Only include http/https URLs, exclude blob URLs and data URLs\r\n\t\t\tif (\r\n\t\t\t\timageUrl &&\r\n\t\t\t\t(imageUrl.startsWith(\"http://\") || imageUrl.startsWith(\"https://\")) &&\r\n\t\t\t\t!images.includes(imageUrl)\r\n\t\t\t) {\r\n\t\t\t\timages.push(imageUrl);\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\treturn images;\r\n\t}\r\n\r\n\t/**\r\n\t * Shows a modal with an iframe for the photo upload page\r\n\t * @private\r\n\t */\r\n\tprivate showPhotoUploadModal(url: string): void {\r\n\t\t// Remove existing modals\r\n\t\tremoveElements(`.${CSS_CLASSES.MODAL}`);\r\n\r\n\t\tconst modal = document.createElement(\"div\");\r\n\t\tmodal.className = CSS_CLASSES.MODAL;\r\n\t\tmodal.style.cssText = `\r\n position: fixed;\r\n top: 0;\r\n left: 0;\r\n right: 0;\r\n bottom: 0;\r\n width: 100%;\r\n height: 100%;\r\n background-color: rgba(0, 0, 0, 0.8);\r\n display: flex;\r\n justify-content: center;\r\n align-items: center;\r\n z-index: 999999999;\r\n animation: ww-modal-fade-in 0.3s ease;\r\n `;\r\n\r\n\t\t// Add fade-in animation\r\n\t\tif (!document.getElementById(\"ww-modal-animation\")) {\r\n\t\t\tconst style = document.createElement(\"style\");\r\n\t\t\tstyle.id = \"ww-modal-animation\";\r\n\t\t\tstyle.textContent = `\r\n\t\t\t\t@keyframes ww-modal-fade-in {\r\n\t\t\t\t\tfrom { opacity: 0; }\r\n\t\t\t\t\tto { opacity: 1; }\r\n\t\t\t\t}\r\n\t\t\t\t@keyframes ww-modal-scale-in {\r\n\t\t\t\t\tfrom { transform: scale(0.95); opacity: 0; }\r\n\t\t\t\t\tto { transform: scale(1); opacity: 1; }\r\n\t\t\t\t}\r\n\t\t\t`;\r\n\t\t\tdocument.head.appendChild(style);\r\n\t\t}\r\n\r\n\t\tconst iframeContainer = document.createElement(\"div\");\r\n\t\tiframeContainer.style.cssText = `\r\n\t\t\tposition: relative;\r\n\t\t\twidth: 90%;\r\n\t\t\theight: 90%;\r\n\t\t\tmax-width: 480px;\r\n\t\t\tmax-height: 720px;\r\n\t\t\tborder-radius: 20px;\r\n\t\t\toverflow: hidden;\r\n\t\t\tbox-shadow: 0 24px 48px rgba(0, 0, 0, 0.3), 0 12px 24px rgba(0, 0, 0, 0.2);\r\n\t\t\tanimation: ww-modal-scale-in 0.3s cubic-bezier(0.4, 0, 0.2, 1);\r\n\t\t\tbackground: white;\r\n\t\t`;\r\n\r\n\t\tconst iframe = document.createElement(\"iframe\");\r\n\t\tiframe.src = url;\r\n\t\tiframe.style.cssText = `\r\n width: 100%;\r\n height: 100%;\r\n border: none;\r\n `;\r\n\r\n\t\tconst closeButton = document.createElement(\"button\");\r\n\t\tcloseButton.innerHTML = `\r\n\t\t\t<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\r\n\t\t\t\t<line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"></line>\r\n\t\t\t\t<line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"></line>\r\n\t\t\t</svg>\r\n\t\t`;\r\n\t\tcloseButton.setAttribute(\"aria-label\", \"Close modal\");\r\n\t\tcloseButton.style.cssText = `\r\n position: absolute;\r\n top: -48px;\r\n right: 0;\r\n background: rgba(255, 255, 255, 0.95);\r\n backdrop-filter: blur(8px);\r\n -webkit-backdrop-filter: blur(8px);\r\n border: none;\r\n border-radius: 50%;\r\n width: 40px;\r\n height: 40px;\r\n cursor: pointer;\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n color: #1f2937;\r\n transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);\r\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);\r\n `;\r\n\t\tcloseButton.onmouseover = () => {\r\n\t\t\tcloseButton.style.transform = \"scale(1.1) rotate(90deg)\";\r\n\t\t\tcloseButton.style.background = \"#ef4444\";\r\n\t\t\tcloseButton.style.color = \"white\";\r\n\t\t};\r\n\t\tcloseButton.onmouseout = () => {\r\n\t\t\tcloseButton.style.transform = \"scale(1) rotate(0deg)\";\r\n\t\t\tcloseButton.style.background = \"rgba(255, 255, 255, 0.95)\";\r\n\t\t\tcloseButton.style.color = \"#1f2937\";\r\n\t\t};\r\n\t\tcloseButton.onclick = () => {\r\n\t\t\tmodal.style.opacity = \"0\";\r\n\t\t\tiframeContainer.style.transform = \"scale(0.95)\";\r\n\t\t\tiframeContainer.style.opacity = \"0\";\r\n\t\t\tsetTimeout(() => modal.remove(), 300);\r\n\t\t};\r\n\r\n\t\tiframeContainer.appendChild(iframe);\r\n\t\tiframeContainer.appendChild(closeButton);\r\n\t\tmodal.appendChild(iframeContainer);\r\n\t\tdocument.body.appendChild(modal);\r\n\r\n\t\t// Close on backdrop click\r\n\t\tmodal.onclick = (e) => {\r\n\t\t\tif (e.target === modal) {\r\n\t\t\t\tcloseButton.click();\r\n\t\t\t}\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Sets up listener for messages from the iframe\r\n\t * @private\r\n\t */\r\n\tprivate setupIframeListener(): void {\r\n\t\t// Remove existing listener if any\r\n\t\tif (this.iframeMessageListener) {\r\n\t\t\twindow.removeEventListener(\"message\", this.iframeMessageListener);\r\n\t\t}\r\n\r\n\t\tthis.iframeMessageListener = (event: MessageEvent) => {\r\n\t\t\tif (event.origin !== new URL(this.config.baseUrl).origin) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tswitch (event.data.type) {\r\n\t\t\t\tcase \"VTO_IMAGE_SELECTED\":\r\n\t\t\t\t\tif (event.data.image) {\r\n\t\t\t\t\t\tthis.lastModelImage = event.data.image;\r\n\t\t\t\t\t\tthis.startVirtualTryOn();\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase \"CLOSE_MODAL\":\r\n\t\t\t\t\tremoveElements(`.${CSS_CLASSES.MODAL}`);\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t};\r\n\r\n\t\twindow.addEventListener(\"message\", this.iframeMessageListener);\r\n\t}\r\n\r\n\tprivate async startVirtualTryOn(isRefresh = false): Promise<void> {\r\n\t\tif (isRefresh) {\r\n\t\t\tconsole.log(\r\n\t\t\t\t\"[WeWear VTO] Refreshing virtual try-on with previous parameters...\",\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\tif (!this.lastModelImage) {\r\n\t\t\tconsole.warn(\r\n\t\t\t\t\"[WeWear VTO] Missing required data to start virtual try-on.\",\r\n\t\t\t);\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Use stored original images, or get them if not stored yet\r\n\t\tif (this.originalProductImages.length === 0) {\r\n\t\t\tthis.originalProductImages = this.getAllProductImages();\r\n\t\t}\r\n\r\n\t\tif (this.originalProductImages.length === 0) {\r\n\t\t\tconsole.warn(\"[WeWear VTO] No product images found.\");\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Hide the modal and show loading indicator\r\n\t\tconst modal = document.querySelector(`.${CSS_CLASSES.MODAL}`);\r\n\t\tif (modal && modal instanceof HTMLElement) {\r\n\t\t\tmodal.style.display = \"none\";\r\n\t\t}\r\n\t\tconst container = document.querySelector(this.config.gallerySelector);\r\n\t\tif (container instanceof HTMLElement) {\r\n\t\t\tshowProductLoading(container, \"Generating your virtual try-on...\");\r\n\t\t}\r\n\r\n\t\ttry {\r\n\t\t\tconst submitResponse = await this.callVtoApi(\r\n\t\t\t\tthis.lastModelImage,\r\n\t\t\t\tthis.originalProductImages,\r\n\t\t\t);\r\n\r\n\t\t\tlet status = await this.fetchJobStatus(submitResponse.job_id);\r\n\t\t\tconst previews: string[] = [];\r\n\r\n\t\t\twhile (status.status !== \"COMPLETED\" && status.status !== \"FAILED\") {\r\n\t\t\t\tawait new Promise((r) => setTimeout(r, 3000));\r\n\t\t\t\tstatus = await this.fetchJobStatus(submitResponse.job_id);\r\n\r\n\t\t\t\tfor (let i = previews.length; i < status.previews_available; i++) {\r\n\t\t\t\t\ttry {\r\n\t\t\t\t\t\tconst previewUrl = await this.fetchJobImage(\r\n\t\t\t\t\t\t\tsubmitResponse.job_id,\r\n\t\t\t\t\t\t\ti,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tpreviews.push(previewUrl);\r\n\t\t\t\t\t\tthis.replaceProductImage(previewUrl);\r\n\r\n\t\t\t\t\t\tif (!this.previewBadge && container instanceof HTMLElement) {\r\n\t\t\t\t\t\t\tthis.previewBadge = createPreviewBadge();\r\n\t\t\t\t\t\t\tcontainer.appendChild(this.previewBadge);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t} catch (e) {\r\n\t\t\t\t\t\tif (!(e instanceof Error && e.message === \"202_PROCESSING\"))\r\n\t\t\t\t\t\t\tthrow e;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (status.status === \"COMPLETED\") {\r\n\t\t\t\tconst finalImage = await this.fetchJobImage(submitResponse.job_id);\r\n\t\t\t\tif (finalImage) {\r\n\t\t\t\t\tthis.replaceProductImage(finalImage);\r\n\t\t\t\t}\r\n\t\t\t\tif (this.previewBadge) {\r\n\t\t\t\t\tthis.previewBadge.remove();\r\n\t\t\t\t\tthis.previewBadge = null;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (status.status === \"FAILED\") {\r\n\t\t\t\tconsole.error(\"[WeWear VTO] VTO process failed:\", status.message);\r\n\t\t\t\tif (container instanceof HTMLElement) {\r\n\t\t\t\t\tshowAlert(container, status.message, \"error\");\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t} catch (error) {\r\n\t\t\tconsole.error(\"[WeWear VTO] Error during virtual try-on process:\", error);\r\n\t\t\tif (container instanceof HTMLElement) {\r\n\t\t\t\tshowAlert(container, \"An unexpected error occurred.\", \"error\");\r\n\t\t\t}\r\n\t\t} finally {\r\n\t\t\tif (container instanceof HTMLElement) {\r\n\t\t\t\tremoveProductLoading(container);\r\n\t\t\t}\r\n\t\t\tremoveElements(`.${CSS_CLASSES.MODAL}`);\r\n\t\t}\r\n\t}\r\n\r\n\tprivate async callVtoApi(\r\n\t\tmodelImage: Blob,\r\n\t\tproductImages: string[],\r\n\t): Promise<{ job_id: string }> {\r\n\t\tconst formData = new FormData();\r\n\t\tformData.append(\"model_image\", modelImage, \"model_image.png\");\r\n\r\n\t\t// Send all product images as a JSON array\r\n\t\tformData.append(\"product_image_urls\", JSON.stringify(productImages));\r\n\r\n\t\tconst res = await fetch(`${this.config.baseUrl}/api/vto`, {\r\n\t\t\tmethod: \"POST\",\r\n\t\t\tbody: formData,\r\n\t\t});\r\n\t\tif (!res.ok) {\r\n\t\t\tconst errorText = await res.text();\r\n\t\t\tconsole.error(\r\n\t\t\t\t\"[WeWear VTO] API submission failed:\",\r\n\t\t\t\tres.status,\r\n\t\t\t\terrorText,\r\n\t\t\t);\r\n\t\t\tthrow new Error(`API submission failed: ${res.status}`);\r\n\t\t}\r\n\t\treturn res.json();\r\n\t}\r\n\r\n\tprivate async fetchJobStatus(jobId: string): Promise<JobStatusResponse> {\r\n\t\tconst res = await fetch(\r\n\t\t\t`${this.config.baseUrl}/api/vto/status?job_id=${jobId}`,\r\n\t\t);\r\n\t\tif (!res.ok) throw new Error(`Status check failed: ${res.status}`);\r\n\t\treturn res.json();\r\n\t}\r\n\r\n\tprivate async fetchJobImage(\r\n\t\tjobId: string,\r\n\t\tpreviewIndex?: number,\r\n\t): Promise<string> {\r\n\t\tlet url = `${this.config.baseUrl}/api/vto/image?job_id=${jobId}`;\r\n\t\tif (previewIndex !== undefined) url += `&preview_index=${previewIndex}`;\r\n\r\n\t\tconst res = await fetch(url);\r\n\t\tif (res.status === 202) throw new Error(\"202_PROCESSING\");\r\n\t\tif (!res.ok) throw new Error(`Image fetch failed: ${res.status}`);\r\n\r\n\t\tconst blob = await res.blob();\r\n\t\treturn URL.createObjectURL(blob);\r\n\t}\r\n\r\n\tprivate async refreshVirtualTryOn(): Promise<void> {\r\n\t\tawait this.startVirtualTryOn(true);\r\n\t}\r\n\r\n\t/**\r\n\t * Replaces the product image in the gallery with the virtual try-on result\r\n\t * @private\r\n\t */\r\n\tprivate replaceProductImage(imageUrl: string): void {\r\n\t\ttry {\r\n\t\t\t// Store the virtual try-on image URL\r\n\t\t\tthis.virtualTryOnImageUrl = imageUrl;\r\n\r\n\t\t\t// Find the gallery container\r\n\t\t\tconst container = document.querySelector(this.config.gallerySelector);\r\n\t\t\tif (!container || !(container instanceof HTMLElement)) {\r\n\t\t\t\tconsole.warn(\r\n\t\t\t\t\t\"[WeWear VTO] Gallery container not found for image replacement:\",\r\n\t\t\t\t\tthis.config.gallerySelector,\r\n\t\t\t\t);\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t// Store the original content if not already stored\r\n\t\t\tif (!container.hasAttribute(\"data-ww-original-content\")) {\r\n\t\t\t\tcontainer.setAttribute(\"data-ww-original-content\", container.innerHTML);\r\n\t\t\t}\r\n\r\n\t\t\t// Capture and lock container dimensions before replacement to prevent layout shift\r\n\t\t\tif (!container.hasAttribute(\"data-ww-container-locked\")) {\r\n\t\t\t\tconst containerRect = container.getBoundingClientRect();\r\n\r\n\t\t\t\t// Store original dimensions\r\n\t\t\t\tcontainer.setAttribute(\r\n\t\t\t\t\t\"data-ww-container-width\",\r\n\t\t\t\t\tcontainerRect.width.toString(),\r\n\t\t\t\t);\r\n\t\t\t\tcontainer.setAttribute(\r\n\t\t\t\t\t\"data-ww-container-height\",\r\n\t\t\t\t\tcontainerRect.height.toString(),\r\n\t\t\t\t);\r\n\r\n\t\t\t\t// Lock the container dimensions\r\n\t\t\t\tcontainer.style.width = `${containerRect.width}px`;\r\n\t\t\t\tcontainer.style.height = `${containerRect.height}px`;\r\n\t\t\t\tcontainer.style.minWidth = `${containerRect.width}px`;\r\n\t\t\t\tcontainer.style.minHeight = `${containerRect.height}px`;\r\n\r\n\t\t\t\tcontainer.setAttribute(\"data-ww-container-locked\", \"true\");\r\n\t\t\t}\r\n\r\n\t\t\t// Capture original image dimensions before replacement to prevent layout shift\r\n\t\t\tconst originalImg = container.querySelector(\"img\");\r\n\t\t\tif (\r\n\t\t\t\toriginalImg &&\r\n\t\t\t\t!container.hasAttribute(\"data-ww-original-dimensions\")\r\n\t\t\t) {\r\n\t\t\t\tconst computedStyle = window.getComputedStyle(originalImg);\r\n\t\t\t\tconst rect = originalImg.getBoundingClientRect();\r\n\t\t\t\tcontainer.setAttribute(\"data-ww-original-width\", computedStyle.width);\r\n\t\t\t\tcontainer.setAttribute(\"data-ww-original-height\", computedStyle.height);\r\n\t\t\t\tcontainer.setAttribute(\r\n\t\t\t\t\t\"data-ww-original-rect-width\",\r\n\t\t\t\t\trect.width.toString(),\r\n\t\t\t\t);\r\n\t\t\t\tcontainer.setAttribute(\r\n\t\t\t\t\t\"data-ww-original-rect-height\",\r\n\t\t\t\t\trect.height.toString(),\r\n\t\t\t\t);\r\n\t\t\t\tcontainer.setAttribute(\"data-ww-original-dimensions\", \"true\");\r\n\t\t\t}\r\n\r\n\t\t\t// Show the virtual try-on image initially\r\n\t\t\tthis.showVirtualTryOnImage(container);\r\n\r\n\t\t\t// Replace the button container with the new multi-button version\r\n\t\t\tthis.updateButtonContainer(container);\r\n\r\n\t\t\tconsole.log(\r\n\t\t\t\t\"[WeWear VTO] Product image replaced with virtual try-on result\",\r\n\t\t\t);\r\n\t\t} catch (error) {\r\n\t\t\tconsole.error(\"[WeWear VTO] Error replacing product image:\", error);\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Updates the button container to show all available buttons\r\n\t * @private\r\n\t */\r\n\tprivate updateButtonContainer(container: HTMLElement): void {\r\n\t\t// Remove existing button containers\r\n\t\tconst existingButtons = container.querySelectorAll(\r\n\t\t\t`.${CSS_CLASSES.BUTTON_CONTAINER}`,\r\n\t\t);\r\n\t\texistingButtons.forEach((btn) => {\r\n\t\t\tbtn.remove();\r\n\t\t});\r\n\r\n\t\t// Create new button container with all buttons\r\n\t\tconst buttonContainer = createButtonContainer(\r\n\t\t\tthis.config.buttonPosition,\r\n\t\t\tthis.virtualTryOnImageUrl !== null,\r\n\t\t\tasync () => {\r\n\t\t\t\tawait this.handleTryOnClick();\r\n\t\t\t},\r\n\t\t\tasync () => {\r\n\t\t\t\tawait this.refreshVirtualTryOn();\r\n\t\t\t},\r\n\t\t\t() => {\r\n\t\t\t\tif (this.isShowingVirtualTryOn) {\r\n\t\t\t\t\tthis.showOriginalImage(container);\r\n\t\t\t\t} else {\r\n\t\t\t\t\tthis.showVirtualTryOnImage(container);\r\n\t\t\t\t}\r\n\t\t\t\tremoveProductLoading(container);\r\n\t\t\t\tthis.updateButtonContainer(container);\r\n\t\t\t},\r\n\t\t\tthis.isShowingVirtualTryOn,\r\n\t\t);\r\n\r\n\t\tcontainer.appendChild(buttonContainer);\r\n\t}\r\n\r\n\t/**\r\n\t * Shows the virtual try-on image in the container\r\n\t * @private\r\n\t */\r\n\tprivate showVirtualTryOnImage(container: HTMLElement): void {\r\n\t\tif (!this.virtualTryOnImageUrl) {\r\n\t\t\tconsole.warn(\"[WeWear VTO] No virtual try-on image URL available\");\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Remove all direct children except for the button container\r\n\t\tArray.from(container.children).forEach((child) => {\r\n\t\t\tif (!child.classList.contains(CSS_CLASSES.BUTTON_CONTAINER)) {\r\n\t\t\t\tchild.remove();\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\t// Get stored original dimensions to prevent layout shift\r\n\t\tconst originalWidth =\r\n\t\t\tcontainer.getAttribute(\"data-ww-original-width\") || \"\";\r\n\t\tconst originalHeight =\r\n\t\t\tcontainer.getAttribute(\"data-ww-original-height\") || \"\";\r\n\t\tconst originalRectWidth =\r\n\t\t\tcontainer.getAttribute(\"data-ww-original-rect-width\") || \"\";\r\n\t\tconst originalRectHeight =\r\n\t\t\tcontainer.getAttribute(\"data-ww-original-rect-height\") || \"\";\r\n\r\n\t\tconst image = document.createElement(\"img\");\r\n\t\timage.src = this.virtualTryOnImageUrl;\r\n\t\timage.alt = \"Virtual Try-On Result\";\r\n\r\n\t\t// Use original dimensions to prevent layout shift\r\n\t\tlet widthStyle = \"100%\";\r\n\t\tlet heightStyle = \"100%\";\r\n\r\n\t\t// Prefer computed style dimensions, fallback to bounding rect, then container fill\r\n\t\tif (originalWidth && originalWidth !== \"auto\" && originalWidth !== \"0px\") {\r\n\t\t\twidthStyle = originalWidth;\r\n\t\t} else if (originalRectWidth && originalRectWidth !== \"0\") {\r\n\t\t\twidthStyle = `${originalRectWidth}px`;\r\n\t\t}\r\n\r\n\t\tif (\r\n\t\t\toriginalHeight &&\r\n\t\t\toriginalHeight !== \"auto\" &&\r\n\t\t\toriginalHeight !== \"0px\"\r\n\t\t) {\r\n\t\t\theightStyle = originalHeight;\r\n\t\t} else if (originalRectHeight && originalRectHeight !== \"0\") {\r\n\t\t\theightStyle = `${originalRectHeight}px`;\r\n\t\t}\r\n\r\n\t\timage.style.cssText = `\r\n width: ${widthStyle};\r\n height: ${heightStyle};\r\n object-fit: contain;\r\n `;\r\n\r\n\t\t// Prepend the image to ensure buttons are rendered on top\r\n\t\tcontainer.prepend(image);\r\n\r\n\t\tthis.isShowingVirtualTryOn = true;\r\n\t}\r\n\r\n\t/**\r\n\t * Shows the original product image in the container\r\n\t * @private\r\n\t */\r\n\tprivate showOriginalImage(container: HTMLElement): void {\r\n\t\tconst originalContentHTML = container.getAttribute(\r\n\t\t\t\"data-ww-original-content\",\r\n\t\t);\r\n\t\tif (originalContentHTML) {\r\n\t\t\t// Remove all direct children except for the button container\r\n\t\t\tArray.from(container.children).forEach((child) => {\r\n\t\t\t\tif (!child.classList.contains(CSS_CLASSES.BUTTON_CONTAINER)) {\r\n\t\t\t\t\tchild.remove();\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n\t\t\t// Parse the original content and prepend it\r\n\t\t\tconst tempDiv = document.createElement(\"div\");\r\n\t\t\ttempDiv.innerHTML = originalContentHTML;\r\n\t\t\tcontainer.prepend(...Array.from(tempDiv.children));\r\n\t\t}\r\n\r\n\t\tthis.isShowingVirtualTryOn = false;\r\n\t}\r\n\r\n\t/**\r\n\t * Destroys the widget and cleans up resources\r\n\t */\r\n\tpublic destroy(): void {\r\n\t\ttry {\r\n\t\t\t// Remove all buttons\r\n\t\t\tremoveElements(`.${CSS_CLASSES.BUTTON_CONTAINER}`);\r\n\r\n\t\t\t// Remove all modals\r\n\t\t\tremoveElements(`.${CSS_CLASSES.MODAL}`);\r\n\r\n\t\t\t// Clear references\r\n\t\t\tthis.cameraButton = null;\r\n\r\n\t\t\t// Remove message listener\r\n\t\t\tif (this.iframeMessageListener) {\r\n\t\t\t\twindow.removeEventListener(\"message\", this.iframeMessageListener);\r\n\t\t\t\tthis.iframeMessageListener = null;\r\n\t\t\t}\r\n\r\n\t\t\t// Reset state\r\n\t\t\tthis.virtualTryOnImageUrl = null;\r\n\t\t\tthis.isShowingVirtualTryOn = false;\r\n\t\t\tthis.lastModelImage = null;\r\n\t\t\tthis.originalProductImageUrl = null;\r\n\t\t\tthis.originalProductImages = [];\r\n\t\t\tif (this.previewBadge) {\r\n\t\t\t\tthis.previewBadge.remove();\r\n\t\t\t\tthis.previewBadge = null;\r\n\t\t\t}\r\n\r\n\t\t\tconsole.log(\"[WeWear VTO] Widget destroyed successfully\");\r\n\t\t} catch (error) {\r\n\t\t\tconsole.error(\"[WeWear VTO] Error during widget destruction:\", error);\r\n\t\t}\r\n\t}\r\n}\r\n","import type { VirtualTryOnConfig } from \"./index.js\";\nimport { VirtualTryOnWidget } from \"./widget.js\";\n\nlet widgetInstance: VirtualTryOnWidget | null = null;\n\nexport function initVirtualTryOn(config?: VirtualTryOnConfig): void {\n\ttry {\n\t\t// Clean up any existing instance\n\t\tif (widgetInstance) {\n\t\t\twidgetInstance.destroy();\n\t\t\twidgetInstance = null;\n\t\t}\n\n\t\t// Early return if config is missing\n\t\tif (!config) {\n\t\t\tconsole.log(\n\t\t\t\t\"[WeWear VTO] Missing configuration. Widget not initialized.\",\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\t// Create and initialize new instance\n\t\twidgetInstance = new VirtualTryOnWidget(config);\n\n\t\t// Initialize immediately if DOM is ready, otherwise wait for it\n\t\tif (document.readyState === \"loading\") {\n\t\t\tdocument.addEventListener(\"DOMContentLoaded\", () => {\n\t\t\t\twidgetInstance?.init().catch((error) => {\n\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\"[WeWear VTO] Failed to initialize after DOM ready:\",\n\t\t\t\t\t\terror,\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t\t});\n\t\t} else {\n\t\t\twidgetInstance.init().catch((error) => {\n\t\t\t\tconsole.error(\"[WeWear VTO] Failed to initialize:\", error);\n\t\t\t});\n\t\t}\n\t} catch (error) {\n\t\tconsole.error(\"[WeWear VTO] Initialization error:\", error);\n\t}\n}\n\nexport function getWidgetInstance(): VirtualTryOnWidget | null {\n\treturn widgetInstance;\n}\n\nif (typeof window !== \"undefined\") {\n\tinitVirtualTryOn();\n}\n"],"names":[],"mappings":"AAAA;AACO,MAAM,WAAW,GAAG;AAC1B,IAAA,gBAAgB,EAAE,6BAA6B;AAC/C,IAAA,MAAM,EAAE,mBAAmB;AAC3B,IAAA,KAAK,EAAE,kBAAkB;AACzB,IAAA,aAAa,EAAE,sBAAsB;CAC5B;AAEV;AACO,MAAM,OAAO,GAAG;AACtB,IAAA,MAAM,EAAE,EAAE;AACV,IAAA,KAAK,EAAE,KAAK;CACH;;SCVM,kBAAkB,GAAA;IACjC,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC;AAC3C,IAAA,KAAK,CAAC,SAAS,GAAG,WAAW,CAAC,aAAa;AAC3C,IAAA,KAAK,CAAC,SAAS,GAAG,SAAS;IAE3B,MAAM,OAAO,GAAG,qBAAqB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CAAC,CAAC;QACH;IACD;IAAE,OAAO,KAAK,EAAE;AACf,QAAA,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,KAAK,CAAC;IAC3D;AACD;SAEgB,iBAAiB,GAAA;AAChC,IAAA,OAAO,cAAc;AACtB;AAEA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AAClC,IAAA,gBAAgB,EAAE;AACnB;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -450,6 +450,7 @@
|
|
|
450
450
|
constructor(config) {
|
|
451
451
|
this.virtualTryOnImageUrl = null;
|
|
452
452
|
this.originalProductImageUrl = null;
|
|
453
|
+
this.originalProductImages = []; // Store all original product images
|
|
453
454
|
this.isShowingVirtualTryOn = false;
|
|
454
455
|
this.lastModelImage = null;
|
|
455
456
|
this.cameraButton = null;
|
|
@@ -507,31 +508,54 @@
|
|
|
507
508
|
async handleTryOnClick() {
|
|
508
509
|
console.log("[WeWear VTO] Button clicked, starting try-on process...");
|
|
509
510
|
try {
|
|
510
|
-
//
|
|
511
|
-
if (
|
|
512
|
-
|
|
513
|
-
this.
|
|
514
|
-
(productImageElement === null || productImageElement === void 0 ? void 0 : productImageElement.src) ||
|
|
515
|
-
(productImageElement === null || productImageElement === void 0 ? void 0 : productImageElement.getAttribute("data-src")) ||
|
|
516
|
-
"";
|
|
511
|
+
// Store original images on first click if not already stored
|
|
512
|
+
if (this.originalProductImages.length === 0) {
|
|
513
|
+
this.originalProductImages = this.getAllProductImages();
|
|
514
|
+
console.log("[WeWear VTO] Stored original product images:", this.originalProductImages);
|
|
517
515
|
}
|
|
518
|
-
const ww_product_image = this.originalProductImageUrl;
|
|
519
516
|
console.log("[WeWear VTO] Retrieved data:", {
|
|
520
|
-
|
|
517
|
+
productImages: this.originalProductImages,
|
|
521
518
|
});
|
|
522
|
-
if (
|
|
523
|
-
console.warn("[WeWear VTO] Product
|
|
519
|
+
if (this.originalProductImages.length === 0) {
|
|
520
|
+
console.warn("[WeWear VTO] Product images not found:", this.config.productImageSelector);
|
|
524
521
|
return;
|
|
525
522
|
}
|
|
523
|
+
// Store the first image as the original
|
|
524
|
+
if (!this.originalProductImageUrl) {
|
|
525
|
+
this.originalProductImageUrl = this.originalProductImages[0];
|
|
526
|
+
}
|
|
526
527
|
// Open the photo upload page in a modal
|
|
527
528
|
const photoUploadUrl = new URL(`${this.config.baseUrl}`);
|
|
528
|
-
|
|
529
|
+
// Pass all product images as a comma-separated string
|
|
530
|
+
photoUploadUrl.searchParams.append("ww_product_images", this.originalProductImages.join(","));
|
|
529
531
|
this.showPhotoUploadModal(photoUploadUrl.toString());
|
|
530
532
|
}
|
|
531
533
|
catch (error) {
|
|
532
534
|
console.error("[WeWear VTO] Try-on request failed:", error);
|
|
533
535
|
}
|
|
534
536
|
}
|
|
537
|
+
/**
|
|
538
|
+
* Gets all product images from the gallery
|
|
539
|
+
* @private
|
|
540
|
+
* @returns Array of product image URLs
|
|
541
|
+
*/
|
|
542
|
+
getAllProductImages() {
|
|
543
|
+
const productImageElements = document.querySelectorAll(this.config.productImageSelector);
|
|
544
|
+
const images = [];
|
|
545
|
+
productImageElements.forEach((img) => {
|
|
546
|
+
const imageUrl = img.src ||
|
|
547
|
+
img.getAttribute("data-src") ||
|
|
548
|
+
img.getAttribute("data-large_image") ||
|
|
549
|
+
"";
|
|
550
|
+
// Only include http/https URLs, exclude blob URLs and data URLs
|
|
551
|
+
if (imageUrl &&
|
|
552
|
+
(imageUrl.startsWith("http://") || imageUrl.startsWith("https://")) &&
|
|
553
|
+
!images.includes(imageUrl)) {
|
|
554
|
+
images.push(imageUrl);
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
return images;
|
|
558
|
+
}
|
|
535
559
|
/**
|
|
536
560
|
* Shows a modal with an iframe for the photo upload page
|
|
537
561
|
* @private
|
|
@@ -545,15 +569,15 @@
|
|
|
545
569
|
position: fixed;
|
|
546
570
|
top: 0;
|
|
547
571
|
left: 0;
|
|
572
|
+
right: 0;
|
|
573
|
+
bottom: 0;
|
|
548
574
|
width: 100%;
|
|
549
575
|
height: 100%;
|
|
550
|
-
background: rgba(0, 0, 0, 0.8);
|
|
551
|
-
backdrop-filter: blur(8px);
|
|
552
|
-
-webkit-backdrop-filter: blur(8px);
|
|
576
|
+
background-color: rgba(0, 0, 0, 0.8);
|
|
553
577
|
display: flex;
|
|
554
578
|
justify-content: center;
|
|
555
579
|
align-items: center;
|
|
556
|
-
z-index:
|
|
580
|
+
z-index: 999999999;
|
|
557
581
|
animation: ww-modal-fade-in 0.3s ease;
|
|
558
582
|
`;
|
|
559
583
|
// Add fade-in animation
|
|
@@ -677,10 +701,18 @@
|
|
|
677
701
|
if (isRefresh) {
|
|
678
702
|
console.log("[WeWear VTO] Refreshing virtual try-on with previous parameters...");
|
|
679
703
|
}
|
|
680
|
-
if (!this.lastModelImage
|
|
704
|
+
if (!this.lastModelImage) {
|
|
681
705
|
console.warn("[WeWear VTO] Missing required data to start virtual try-on.");
|
|
682
706
|
return;
|
|
683
707
|
}
|
|
708
|
+
// Use stored original images, or get them if not stored yet
|
|
709
|
+
if (this.originalProductImages.length === 0) {
|
|
710
|
+
this.originalProductImages = this.getAllProductImages();
|
|
711
|
+
}
|
|
712
|
+
if (this.originalProductImages.length === 0) {
|
|
713
|
+
console.warn("[WeWear VTO] No product images found.");
|
|
714
|
+
return;
|
|
715
|
+
}
|
|
684
716
|
// Hide the modal and show loading indicator
|
|
685
717
|
const modal = document.querySelector(`.${CSS_CLASSES.MODAL}`);
|
|
686
718
|
if (modal && modal instanceof HTMLElement) {
|
|
@@ -691,7 +723,7 @@
|
|
|
691
723
|
showProductLoading(container, "Generating your virtual try-on...");
|
|
692
724
|
}
|
|
693
725
|
try {
|
|
694
|
-
const submitResponse = await this.callVtoApi(this.lastModelImage, this.
|
|
726
|
+
const submitResponse = await this.callVtoApi(this.lastModelImage, this.originalProductImages);
|
|
695
727
|
let status = await this.fetchJobStatus(submitResponse.job_id);
|
|
696
728
|
const previews = [];
|
|
697
729
|
while (status.status !== "COMPLETED" && status.status !== "FAILED") {
|
|
@@ -743,10 +775,11 @@
|
|
|
743
775
|
removeElements(`.${CSS_CLASSES.MODAL}`);
|
|
744
776
|
}
|
|
745
777
|
}
|
|
746
|
-
async callVtoApi(modelImage,
|
|
778
|
+
async callVtoApi(modelImage, productImages) {
|
|
747
779
|
const formData = new FormData();
|
|
748
780
|
formData.append("model_image", modelImage, "model_image.png");
|
|
749
|
-
|
|
781
|
+
// Send all product images as a JSON array
|
|
782
|
+
formData.append("product_image_urls", JSON.stringify(productImages));
|
|
750
783
|
const res = await fetch(`${this.config.baseUrl}/api/vto`, {
|
|
751
784
|
method: "POST",
|
|
752
785
|
body: formData,
|
|
@@ -950,6 +983,7 @@
|
|
|
950
983
|
this.isShowingVirtualTryOn = false;
|
|
951
984
|
this.lastModelImage = null;
|
|
952
985
|
this.originalProductImageUrl = null;
|
|
986
|
+
this.originalProductImages = [];
|
|
953
987
|
if (this.previewBadge) {
|
|
954
988
|
this.previewBadge.remove();
|
|
955
989
|
this.previewBadge = null;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/constants.ts","../src/components/badge.ts","../src/utils.ts","../src/components/button.ts","../src/components/loading-overlay.ts","../src/components/alert-overlay.ts","../src/widget.ts","../src/installer.ts"],"sourcesContent":["/** CSS class names for consistent styling */\nexport const CSS_CLASSES = {\n\tBUTTON_CONTAINER: \"wewear-vto-button-container\",\n\tBUTTON: \"wewear-vto-button\",\n\tMODAL: \"wewear-vto-modal\",\n\tPREVIEW_BADGE: \"ww-vto-preview-badge\",\n} as const;\n\n/** Z-index values for proper layering */\nexport const Z_INDEX = {\n\tBUTTON: 10,\n\tMODAL: 99999,\n} as const;\n","import { CSS_CLASSES } from \"../constants.js\";\r\n\r\nexport function createPreviewBadge(): HTMLElement {\r\n\tconst badge = document.createElement(\"div\");\r\n\tbadge.className = CSS_CLASSES.PREVIEW_BADGE;\r\n\tbadge.innerText = \"PREVIEW\";\r\n\r\n\tconst styleId = \"ww-vto-badge-styles\";\r\n\tif (!document.getElementById(styleId)) {\r\n\t\tconst styles = document.createElement(\"style\");\r\n\t\tstyles.id = styleId;\r\n\t\tstyles.innerHTML = `\r\n .${CSS_CLASSES.PREVIEW_BADGE} {\r\n position: absolute;\r\n top: 20px;\r\n right: 20px;\r\n background: rgba(31, 41, 55, 0.9);\r\n backdrop-filter: blur(4px);\r\n -webkit-backdrop-filter: blur(4px);\r\n color: white;\r\n padding: 6px 14px;\r\n border-radius: 6px;\r\n font-size: 12px;\r\n font-weight: 600;\r\n letter-spacing: 0.5px;\r\n z-index: 10;\r\n pointer-events: none;\r\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif;\r\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);\r\n animation: ww-vto-pulse 2s ease-in-out infinite;\r\n }\r\n\r\n @keyframes ww-vto-pulse {\r\n 0%, 100% {\r\n opacity: 0.9;\r\n }\r\n 50% {\r\n opacity: 1;\r\n }\r\n }\r\n `;\r\n\t\tdocument.head.appendChild(styles);\r\n\t}\r\n\r\n\treturn badge;\r\n}\r\n","export function getPositionStyles(position: string): string {\n\tswitch (position) {\n\t\tcase \"bottom-left\":\n\t\t\treturn \"left: 20px; bottom: 20px;\";\n\t\tcase \"top-right\":\n\t\t\treturn \"right: 20px; top: 20px;\";\n\t\tcase \"top-left\":\n\t\t\treturn \"left: 20px; top: 20px;\";\n\t\tdefault:\n\t\t\treturn \"right: 20px; bottom: 20px;\";\n\t}\n}\n\nexport function removeElements(selector: string): void {\n\tconst elements = document.querySelectorAll(selector);\n\telements.forEach((element) => {\n\t\telement.remove();\n\t});\n}\n","import { CSS_CLASSES, Z_INDEX } from \"../constants.js\";\r\nimport { getPositionStyles } from \"../utils.js\";\r\n\r\nexport function createButtonContainer(\r\n\tbuttonPosition: string,\r\n\thasVirtualTryOn: boolean = false,\r\n\tonCameraClick: () => void,\r\n\tonRefreshClick?: () => void,\r\n\tonToggleClick?: () => void,\r\n\tisShowingVirtualTryOn: boolean = false,\r\n): HTMLElement {\r\n\tconst container = document.createElement(\"div\");\r\n\tcontainer.className = `${CSS_CLASSES.BUTTON_CONTAINER} ww-button-group`;\r\n\r\n\tconst positionStyles = getPositionStyles(buttonPosition);\r\n\tcontainer.style.cssText = `\r\n position: absolute;\r\n ${positionStyles}\r\n display: flex;\r\n gap: 4px;\r\n border-radius: 100px;\r\n background: white;\r\n padding: 4px;\r\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\r\n z-index: ${Z_INDEX.BUTTON};\r\n transition: all 0.2s ease;\r\n `;\r\n\r\n\t// Camera button\r\n\tconst cameraButton = document.createElement(\"button\");\r\n\tcameraButton.type = \"button\";\r\n\tcameraButton.className = `${CSS_CLASSES.BUTTON} ww-camera-btn`;\r\n\tcameraButton.setAttribute(\"aria-label\", \"Virtual Try-On\");\r\n\tcameraButton.style.cssText = `\r\n display: flex;\r\n width: 40px;\r\n height: 40px;\r\n cursor: pointer;\r\n align-items: center;\r\n justify-content: center;\r\n border-radius: 100px;\r\n padding: 0;\r\n border: none;\r\n background: white;\r\n color: #000000;\r\n transition: all 0.2s ease;\r\n flex-shrink: 0;\r\n `;\r\n\r\n\tcameraButton.innerHTML = `\r\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"display: block;\">\r\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>\r\n <circle cx=\"12\" cy=\"13\" r=\"3\"></circle>\r\n </svg>\r\n `;\r\n\r\n\tcameraButton.onclick = onCameraClick;\r\n\tcontainer.appendChild(cameraButton);\r\n\r\n\t// Add refresh and toggle buttons if we have a virtual try-on\r\n\tif (hasVirtualTryOn) {\r\n\t\t// Refresh button - calls API again\r\n\t\tif (onRefreshClick) {\r\n\t\t\tconst refreshButton = document.createElement(\"button\");\r\n\t\t\trefreshButton.type = \"button\";\r\n\t\t\trefreshButton.className = \"ww-refresh-btn\";\r\n\t\t\trefreshButton.setAttribute(\"aria-label\", \"Refresh virtual try-on\");\r\n\t\t\trefreshButton.style.cssText = `\r\n display: flex;\r\n width: 40px;\r\n height: 40px;\r\n cursor: pointer;\r\n align-items: center;\r\n justify-content: center;\r\n border-radius: 100px;\r\n padding: 0;\r\n border: none;\r\n background: white;\r\n color: #333333;\r\n transition: all 0.2s ease;\r\n flex-shrink: 0;\r\n `;\r\n\r\n\t\t\trefreshButton.innerHTML = `\r\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"display: block;\">\r\n <path d=\"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8\"></path>\r\n <path d=\"M3 3v5h5\"></path>\r\n <path d=\"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16\"></path>\r\n <path d=\"M16 16h5v5\"></path>\r\n </svg>\r\n `;\r\n\r\n\t\t\trefreshButton.onclick = onRefreshClick;\r\n\r\n\t\t\trefreshButton.onclick = onRefreshClick;\r\n\t\t\tcontainer.appendChild(refreshButton);\r\n\t\t}\r\n\r\n\t\t// Toggle button (scan-face) - switches between original and virtual try-on\r\n\t\tif (onToggleClick) {\r\n\t\t\tconst toggleButton = document.createElement(\"button\");\r\n\t\t\ttoggleButton.type = \"button\";\r\n\t\t\ttoggleButton.className = \"ww-toggle-btn\";\r\n\t\t\ttoggleButton.setAttribute(\r\n\t\t\t\t\"aria-label\",\r\n\t\t\t\tisShowingVirtualTryOn ? \"Show Original Image\" : \"Show Virtual Try-On\",\r\n\t\t\t);\r\n\t\t\ttoggleButton.style.cssText = `\r\n display: flex;\r\n width: 40px;\r\n height: 40px;\r\n cursor: pointer;\r\n align-items: center;\r\n justify-content: center;\r\n border-radius: 100px;\r\n padding: 0;\r\n border: none;\r\n background: ${isShowingVirtualTryOn ? \"#333333\" : \"#e5e7eb\"};\r\n color: ${isShowingVirtualTryOn ? \"white\" : \"#333333\"};\r\n transition: all 0.2s ease;\r\n flex-shrink: 0;\r\n `;\r\n\r\n\t\t\ttoggleButton.innerHTML = `\r\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"display: block;\">\r\n <path d=\"M3 7V5a2 2 0 0 1 2-2h2\"></path>\r\n <path d=\"M17 3h2a2 2 0 0 1 2 2v2\"></path>\r\n <path d=\"M21 17v2a2 2 0 0 1-2 2h-2\"></path>\r\n <path d=\"M7 21H5a2 2 0 0 1-2-2v-2\"></path>\r\n <path d=\"M8 14s1.5 2 4 2 4-2 4-2\"></path>\r\n <path d=\"M9 9h.01\"></path>\r\n <path d=\"M15 9h.01\"></path>\r\n </svg>\r\n `;\r\n\r\n\t\t\ttoggleButton.onmouseover = () => {\r\n\t\t\t\tif (isShowingVirtualTryOn) {\r\n\t\t\t\t\ttoggleButton.style.background = \"#4a4a4a\";\r\n\t\t\t\t} else {\r\n\t\t\t\t\ttoggleButton.style.background = \"#d1d5db\";\r\n\t\t\t\t}\r\n\t\t\t};\r\n\t\t\ttoggleButton.onmouseout = () => {\r\n\t\t\t\tif (isShowingVirtualTryOn) {\r\n\t\t\t\t\ttoggleButton.style.background = \"#333333\";\r\n\t\t\t\t} else {\r\n\t\t\t\t\ttoggleButton.style.background = \"#e5e7eb\";\r\n\t\t\t\t}\r\n\t\t\t};\r\n\r\n\t\t\ttoggleButton.onclick = onToggleClick;\r\n\t\t\tcontainer.appendChild(toggleButton);\r\n\t\t}\r\n\t}\r\n\r\n\treturn container;\r\n}\r\n\r\nexport function createButton(\r\n\tbuttonPosition: string,\r\n\tonClick: () => void,\r\n\tdisabled: boolean = false,\r\n): HTMLElement {\r\n\tconst container = createButtonContainer(buttonPosition, false, onClick);\r\n\tconst cameraButton = container.querySelector(\r\n\t\t\".ww-camera-btn\",\r\n\t) as HTMLButtonElement;\r\n\tif (cameraButton) {\r\n\t\tcameraButton.disabled = disabled;\r\n\t\tif (disabled) {\r\n\t\t\tcameraButton.style.opacity = \"0.5\";\r\n\t\t\tcameraButton.style.cursor = \"not-allowed\";\r\n\t\t\tcameraButton.title = \"Find your ideal size first\";\r\n\t\t}\r\n\t}\r\n\treturn container;\r\n}\r\n","import { Z_INDEX } from \"../constants.js\";\r\n\r\n/**\r\n * Creates a loading overlay that can be shown in different containers\r\n */\r\nexport function createLoadingOverlay(\r\n\ttext: string = \"Processing...\",\r\n): HTMLElement {\r\n\tconst overlay = document.createElement(\"div\");\r\n\toverlay.className = \"ww-loading-overlay\";\r\n\toverlay.style.cssText = `\r\n position: absolute;\r\n top: 0;\r\n left: 0;\r\n width: 100%;\r\n height: 100%;\r\n background: linear-gradient(135deg, rgba(0, 0, 0, 0.92) 0%, rgba(0, 0, 0, 0.88) 100%);\r\n backdrop-filter: blur(8px);\r\n -webkit-backdrop-filter: blur(8px);\r\n display: flex;\r\n flex-direction: column;\r\n align-items: center;\r\n justify-content: center;\r\n z-index: ${Z_INDEX.MODAL + 1};\r\n border-radius: inherit;\r\n animation: ww-fade-in 0.3s ease;\r\n `;\r\n\r\n\t// Add CSS animation to the document if not already added\r\n\tif (!document.getElementById(\"ww-loading-animation\")) {\r\n\t\tconst style = document.createElement(\"style\");\r\n\t\tstyle.id = \"ww-loading-animation\";\r\n\t\tstyle.textContent = `\r\n @keyframes ww-fade-in {\r\n from { opacity: 0; }\r\n to { opacity: 1; }\r\n }\r\n \r\n @keyframes ww-pulse-logo {\r\n 0%, 100% { \r\n opacity: 0.8; \r\n transform: scale(1);\r\n }\r\n 50% { \r\n opacity: 1; \r\n transform: scale(1.05);\r\n }\r\n }\r\n \r\n @keyframes ww-spinner-rotate {\r\n 0% { transform: rotate(0deg); }\r\n 100% { transform: rotate(360deg); }\r\n }\r\n \r\n @keyframes ww-dot-bounce {\r\n 0%, 80%, 100% { \r\n transform: scale(0);\r\n opacity: 0.5;\r\n }\r\n 40% { \r\n transform: scale(1);\r\n opacity: 1;\r\n }\r\n }\r\n \r\n .ww-loading-logo {\r\n animation: ww-pulse-logo 2s ease-in-out infinite;\r\n }\r\n \r\n .ww-loading-spinner {\r\n animation: ww-spinner-rotate 1s linear infinite;\r\n }\r\n `;\r\n\t\tdocument.head.appendChild(style);\r\n\t}\r\n\r\n\toverlay.innerHTML = `\r\n <div style=\"display: flex; flex-direction: column; align-items: center; gap: 32px;\">\r\n <div style=\"position: relative; width: 120px; height: 120px; display: flex; align-items: center; justify-content: center;\">\r\n <!-- Outer spinning circle -->\r\n <div class=\"ww-loading-spinner\" style=\"\r\n position: absolute;\r\n width: 120px;\r\n height: 120px;\r\n border: 3px solid transparent;\r\n border-top: 3px solid #333333;\r\n border-right: 3px solid #333333;\r\n border-radius: 50%;\r\n \"></div>\r\n \r\n <!-- Logo -->\r\n <svg class=\"ww-loading-logo\" width=\"80\" height=\"50\" viewBox=\"0 0 214 135\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <path d=\"M102.906 74.8679C102.906 77.9717 101.574 80.7453 98.9104 83.1887C96.6871 85.1918 93.9025 86.6997 90.5566 87.7123C87.695 88.5708 84.6462 89 81.4104 89C73.8821 89 68.0047 87.0189 63.7783 83.0566C59.5519 87.0189 53.6855 89 46.1792 89C42.9434 89 39.9057 88.5708 37.066 87.7123C33.7201 86.6997 30.9245 85.1918 28.6792 83.1887C26.0157 80.7453 24.684 77.9717 24.684 74.8679V41.6509H32.3774V74.8679C32.3774 76.2547 33.489 77.5645 35.7123 78.7972C37.3632 79.7217 39.0692 80.3711 40.8302 80.7453C42.5252 81.1195 44.3082 81.3066 46.1792 81.3066C48.0063 81.3066 49.7673 81.1195 51.4623 80.7453C53.2453 80.3711 54.9623 79.7217 56.6132 78.7972C58.8585 77.5645 59.9811 76.2547 59.9811 74.8679V41.6509H67.6085V74.8679C67.6085 76.2547 68.7311 77.5645 70.9764 78.7972C72.6274 79.7217 74.3443 80.3711 76.1274 80.7453C77.8223 81.1195 79.5833 81.3066 81.4104 81.3066C83.2814 81.3066 85.0755 81.1195 86.7925 80.7453C88.5314 80.3711 90.2264 79.7217 91.8774 78.7972C94.1006 77.5645 95.2123 76.2547 95.2123 74.8679V41.6509H102.906V74.8679ZM189.283 74.8679C189.283 77.9717 187.951 80.7453 185.288 83.1887C183.064 85.1918 180.28 86.6997 176.934 87.7123C174.072 88.5708 171.024 89 167.788 89C160.259 89 154.382 87.0189 150.156 83.0566C145.929 87.0189 140.063 89 132.557 89C129.321 89 126.283 88.5708 123.443 87.7123C120.097 86.6997 117.302 85.1918 115.057 83.1887C112.393 80.7453 111.061 77.9717 111.061 74.8679V41.6509H118.755V74.8679C118.755 76.2547 119.866 77.5645 122.09 78.7972C123.741 79.7217 125.447 80.3711 127.208 80.7453C128.903 81.1195 130.686 81.3066 132.557 81.3066C134.384 81.3066 136.145 81.1195 137.84 80.7453C139.623 80.3711 141.34 79.7217 142.991 78.7972C145.236 77.5645 146.358 76.2547 146.358 74.8679V41.6509H153.986V74.8679C153.986 76.2547 155.108 77.5645 157.354 78.7972C159.005 79.7217 160.722 80.3711 162.505 80.7453C164.2 81.1195 165.961 81.3066 167.788 81.3066C169.659 81.3066 171.453 81.1195 173.17 80.7453C174.909 80.3711 176.604 79.7217 178.255 78.7972C180.478 77.5645 181.59 76.2547 181.59 74.8679V41.6509H189.283V74.8679Z\" fill=\"white\"/>\r\n </svg>\r\n </div>\r\n \r\n <div style=\"font-size: 17px; font-weight: 500; text-align: center; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; color: white; letter-spacing: 0.5px; max-width: 280px;\">${text}</div>\r\n \r\n <div style=\"display: flex; gap: 10px; margin-top: 4px;\">\r\n <div style=\"width: 10px; height: 10px; border-radius: 50%; background: #333333; animation: ww-dot-bounce 1.4s ease-in-out infinite;\"></div>\r\n <div style=\"width: 10px; height: 10px; border-radius: 50%; background: #333333; animation: ww-dot-bounce 1.4s ease-in-out 0.2s infinite;\"></div>\r\n <div style=\"width: 10px; height: 10px; border-radius: 50%; background: #333333; animation: ww-dot-bounce 1.4s ease-in-out 0.4s infinite;\"></div>\r\n </div>\r\n </div>\r\n `;\r\n\r\n\treturn overlay;\r\n}\r\n\r\n/**\r\n * Shows a loading overlay in the product gallery container\r\n */\r\nexport function showProductLoading(\r\n\tcontainer: HTMLElement,\r\n\ttext: string = \"Generating virtual try-on...\",\r\n): void {\r\n\t// Remove any existing loading overlays\r\n\tremoveProductLoading(container);\r\n\r\n\t// Make container relative if it's not already positioned\r\n\tconst computedStyle = window.getComputedStyle(container);\r\n\tif (computedStyle.position === \"static\") {\r\n\t\tcontainer.style.position = \"relative\";\r\n\t}\r\n\r\n\tconst loadingOverlay = createLoadingOverlay(text);\r\n\tcontainer.appendChild(loadingOverlay);\r\n}\r\n\r\n/**\r\n * Removes loading overlay from product container\r\n */\r\nexport function removeProductLoading(container: HTMLElement): void {\r\n\tconst existingOverlay = container.querySelector(\".ww-loading-overlay\");\r\n\tif (existingOverlay) {\r\n\t\texistingOverlay.remove();\r\n\t}\r\n}\r\n","export function showAlert(\r\n\tcontainer: HTMLElement,\r\n\tmessage: string,\r\n\ttype: \"error\" | \"warning\",\r\n) {\r\n\tremoveAlert(container); // Remove any existing alert\r\n\r\n\tconst alertDiv = document.createElement(\"div\");\r\n\talertDiv.className = `ww-alert ww-alert-${type}`;\r\n\talertDiv.setAttribute(\"role\", type === \"error\" ? \"alert\" : \"status\");\r\n\talertDiv.setAttribute(\"aria-live\", \"assertive\");\r\n\r\n\tconst bgColor =\r\n\t\ttype === \"error\"\r\n\t\t\t? \"linear-gradient(135deg, #fee2e2 0%, #fecaca 100%)\"\r\n\t\t\t: \"linear-gradient(135deg, #fef9c3 0%, #fde68a 100%)\";\r\n\tconst textColor = type === \"error\" ? \"#991b1b\" : \"#78350f\";\r\n\tconst borderColor = type === \"error\" ? \"#f87171\" : \"#fbbf24\";\r\n\tconst iconColor = type === \"error\" ? \"#dc2626\" : \"#d97706\";\r\n\r\n\talertDiv.style.cssText = `\r\n position: absolute;\r\n top: 24px;\r\n left: 50%;\r\n transform: translateX(-50%) translateY(-20px);\r\n background: ${bgColor};\r\n color: ${textColor};\r\n border: 1px solid ${borderColor};\r\n border-radius: 12px;\r\n padding: 16px 20px;\r\n z-index: 9999;\r\n font-size: 15px;\r\n font-weight: 500;\r\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);\r\n backdrop-filter: blur(8px);\r\n -webkit-backdrop-filter: blur(8px);\r\n display: flex;\r\n align-items: center;\r\n gap: 12px;\r\n min-width: 280px;\r\n max-width: 90%;\r\n opacity: 0;\r\n transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);\r\n `;\r\n\r\n\tconst icon =\r\n\t\ttype === \"error\"\r\n\t\t\t? `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"${iconColor}\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\r\n\t\t\t<circle cx=\"12\" cy=\"12\" r=\"10\"/><line x1=\"12\" y1=\"8\" x2=\"12\" y2=\"12\"/><line x1=\"12\" y1=\"16\" x2=\"12.01\" y2=\"16\"/>\r\n\t\t</svg>`\r\n\t\t\t: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"${iconColor}\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\r\n\t\t\t<path d=\"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z\"/><line x1=\"12\" y1=\"9\" x2=\"12\" y2=\"13\"/><line x1=\"12\" y1=\"17\" x2=\"12.01\" y2=\"17\"/>\r\n\t\t</svg>`;\r\n\r\n\talertDiv.innerHTML = `\r\n ${icon}\r\n <span style=\"flex: 1; line-height: 1.5;\">${message}</span>\r\n <button type=\"button\" aria-label=\"Close alert\"\r\n style=\"\r\n background: none;\r\n border: none;\r\n font-size: 22px;\r\n color: ${textColor};\r\n cursor: pointer;\r\n padding: 0;\r\n line-height: 1;\r\n opacity: 0.7;\r\n transition: opacity 0.2s ease;\r\n width: 24px;\r\n height: 24px;\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n \"\r\n onmouseover=\"this.style.opacity='1'\"\r\n onmouseout=\"this.style.opacity='0.7'\">\r\n ×\r\n </button>\r\n `;\r\n\r\n\t// Close on button click\r\n\talertDiv.querySelector(\"button\")?.addEventListener(\"click\", () => {\r\n\t\tfadeOutAndRemove(alertDiv);\r\n\t});\r\n\r\n\tcontainer.appendChild(alertDiv);\r\n\r\n\t// Animate in\r\n\trequestAnimationFrame(() => {\r\n\t\talertDiv.style.opacity = \"1\";\r\n\t\talertDiv.style.transform = \"translateX(-50%) translateY(0)\";\r\n\t});\r\n\r\n\t// Auto-dismiss after 8 seconds\r\n\tsetTimeout(() => {\r\n\t\tif (alertDiv.parentElement) {\r\n\t\t\tfadeOutAndRemove(alertDiv);\r\n\t\t}\r\n\t}, 8000);\r\n}\r\n\r\nfunction fadeOutAndRemove(element: HTMLElement) {\r\n\telement.style.opacity = \"0\";\r\n\telement.style.transform = \"translateX(-50%) translateY(-20px)\";\r\n\tsetTimeout(() => {\r\n\t\telement.remove();\r\n\t}, 300);\r\n}\r\n\r\nexport function removeAlert(container: HTMLElement) {\r\n\tconst alert = container.querySelector(\".ww-alert\") as HTMLElement;\r\n\tif (alert) fadeOutAndRemove(alert);\r\n}\r\n","import { CSS_CLASSES, Z_INDEX } from \"./constants.js\";\r\nimport {\r\n\tcreateButton,\r\n\tcreateButtonContainer,\r\n\tremoveProductLoading,\r\n\tshowProductLoading,\r\n\tcreatePreviewBadge,\r\n} from \"./components/index.js\";\r\nimport type { VirtualTryOnConfig } from \"./index.js\";\r\nimport { removeElements } from \"./utils.js\";\r\nimport { showAlert } from \"./components/alert-overlay.js\";\r\n\r\n/**\r\n * Job status type\r\n */\r\ntype JobStatus = \"PENDING\" | \"PREVIEW_AVAILABLE\" | \"COMPLETED\" | \"FAILED\";\r\n\r\n/**\r\n * Response from the job status endpoint\r\n */\r\ninterface JobStatusResponse {\r\n\tstatus: JobStatus;\r\n\tpreviews_available: number;\r\n\tmessage: string;\r\n}\r\n\r\nexport class VirtualTryOnWidget {\r\n\tprivate readonly config: Required<VirtualTryOnConfig>;\r\n\tprivate virtualTryOnImageUrl: string | null = null;\r\n\tprivate originalProductImageUrl: string | null = null;\r\n\tprivate isShowingVirtualTryOn: boolean = false;\r\n\tprivate lastModelImage: Blob | null = null;\r\n\tprivate cameraButton: HTMLButtonElement | null = null;\r\n\tprivate iframeMessageListener: ((event: MessageEvent) => void) | null = null;\r\n\tprivate previewBadge: HTMLElement | null = null;\r\n\r\n\tconstructor(config: VirtualTryOnConfig) {\r\n\t\tthis.config = {\r\n\t\t\tbaseUrl: config.baseUrl,\r\n\t\t\tproductPageSelector: config.productPageSelector,\r\n\t\t\tgallerySelector: config.gallerySelector,\r\n\t\t\tproductImageSelector: config.productImageSelector,\r\n\t\t\tbuttonPosition: config.buttonPosition,\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Initializes the virtual try-on widget on the current page\r\n\t * @returns Promise that resolves when initialization is complete\r\n\t */\r\n\tpublic async init(): Promise<void> {\r\n\t\ttry {\r\n\t\t\t// Check if we're on a product page\r\n\t\t\tif (!window.location.pathname.includes(this.config.productPageSelector)) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t// Find the gallery container\r\n\t\t\tconst container = document.querySelector(this.config.gallerySelector);\r\n\t\t\tif (!container || !(container instanceof HTMLElement)) {\r\n\t\t\t\tconsole.warn(\r\n\t\t\t\t\t\"[WeWear VTO] Gallery container not found:\",\r\n\t\t\t\t\tthis.config.gallerySelector,\r\n\t\t\t\t);\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t// Ensure container has relative positioning for button placement\r\n\t\t\tif (getComputedStyle(container).position === \"static\") {\r\n\t\t\t\tcontainer.style.position = \"relative\";\r\n\t\t\t}\r\n\r\n\t\t\t// Create and add the virtual try-on button\r\n\t\t\tconst button = createButton(this.config.buttonPosition, async () => {\r\n\t\t\t\tif (this.cameraButton && !this.cameraButton.disabled) {\r\n\t\t\t\t\tawait this.handleTryOnClick();\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n\t\t\t// Store reference to camera button for dynamic enable/disable\r\n\t\t\tthis.cameraButton = button.querySelector(\".ww-camera-btn\");\r\n\t\t\tcontainer.appendChild(button);\r\n\t\t\tconsole.log(\"[WeWear VTO] Widget initialized successfully\");\r\n\r\n\t\t\t// Listen for messages from the photo upload page\r\n\t\t\tthis.setupIframeListener();\r\n\t\t} catch (error) {\r\n\t\t\tconsole.error(\"[WeWear VTO] Initialization failed:\", error);\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Handles virtual try-on button click\r\n\t * @private\r\n\t */\r\n\tprivate async handleTryOnClick(): Promise<void> {\r\n\t\tconsole.log(\"[WeWear VTO] Button clicked, starting try-on process...\");\r\n\r\n\t\ttry {\r\n\t\t\t// Get required data\r\n\t\t\tif (!this.originalProductImageUrl) {\r\n\t\t\t\tconst productImageElement = document.querySelector(\r\n\t\t\t\t\tthis.config.productImageSelector,\r\n\t\t\t\t) as HTMLImageElement;\r\n\t\t\t\tthis.originalProductImageUrl =\r\n\t\t\t\t\tproductImageElement?.src ||\r\n\t\t\t\t\tproductImageElement?.getAttribute(\"data-src\") ||\r\n\t\t\t\t\t\"\";\r\n\t\t\t}\r\n\r\n\t\t\tconst ww_product_image = this.originalProductImageUrl;\r\n\r\n\t\t\tconsole.log(\"[WeWear VTO] Retrieved data:\", {\r\n\t\t\t\tww_product_image,\r\n\t\t\t});\r\n\r\n\t\t\tif (!ww_product_image) {\r\n\t\t\t\tconsole.warn(\r\n\t\t\t\t\t\"[WeWear VTO] Product image not found:\",\r\n\t\t\t\t\tthis.config.productImageSelector,\r\n\t\t\t\t);\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t// Open the photo upload page in a modal\r\n\t\t\tconst photoUploadUrl = new URL(`${this.config.baseUrl}`);\r\n\t\t\tphotoUploadUrl.searchParams.append(\"ww_product_image\", ww_product_image);\r\n\r\n\t\t\tthis.showPhotoUploadModal(photoUploadUrl.toString());\r\n\t\t} catch (error) {\r\n\t\t\tconsole.error(\"[WeWear VTO] Try-on request failed:\", error);\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Shows a modal with an iframe for the photo upload page\r\n\t * @private\r\n\t */\r\n\tprivate showPhotoUploadModal(url: string): void {\r\n\t\t// Remove existing modals\r\n\t\tremoveElements(`.${CSS_CLASSES.MODAL}`);\r\n\r\n\t\tconst modal = document.createElement(\"div\");\r\n\t\tmodal.className = CSS_CLASSES.MODAL;\r\n\t\tmodal.style.cssText = `\r\n position: fixed;\r\n top: 0;\r\n left: 0;\r\n width: 100%;\r\n height: 100%;\r\n background: rgba(0, 0, 0, 0.8);\r\n backdrop-filter: blur(8px);\r\n -webkit-backdrop-filter: blur(8px);\r\n display: flex;\r\n justify-content: center;\r\n align-items: center;\r\n z-index: ${Z_INDEX.MODAL};\r\n animation: ww-modal-fade-in 0.3s ease;\r\n `;\r\n\r\n\t\t// Add fade-in animation\r\n\t\tif (!document.getElementById(\"ww-modal-animation\")) {\r\n\t\t\tconst style = document.createElement(\"style\");\r\n\t\t\tstyle.id = \"ww-modal-animation\";\r\n\t\t\tstyle.textContent = `\r\n\t\t\t\t@keyframes ww-modal-fade-in {\r\n\t\t\t\t\tfrom { opacity: 0; }\r\n\t\t\t\t\tto { opacity: 1; }\r\n\t\t\t\t}\r\n\t\t\t\t@keyframes ww-modal-scale-in {\r\n\t\t\t\t\tfrom { transform: scale(0.95); opacity: 0; }\r\n\t\t\t\t\tto { transform: scale(1); opacity: 1; }\r\n\t\t\t\t}\r\n\t\t\t`;\r\n\t\t\tdocument.head.appendChild(style);\r\n\t\t}\r\n\r\n\t\tconst iframeContainer = document.createElement(\"div\");\r\n\t\tiframeContainer.style.cssText = `\r\n\t\t\tposition: relative;\r\n\t\t\twidth: 90%;\r\n\t\t\theight: 90%;\r\n\t\t\tmax-width: 480px;\r\n\t\t\tmax-height: 720px;\r\n\t\t\tborder-radius: 20px;\r\n\t\t\toverflow: hidden;\r\n\t\t\tbox-shadow: 0 24px 48px rgba(0, 0, 0, 0.3), 0 12px 24px rgba(0, 0, 0, 0.2);\r\n\t\t\tanimation: ww-modal-scale-in 0.3s cubic-bezier(0.4, 0, 0.2, 1);\r\n\t\t\tbackground: white;\r\n\t\t`;\r\n\r\n\t\tconst iframe = document.createElement(\"iframe\");\r\n\t\tiframe.src = url;\r\n\t\tiframe.style.cssText = `\r\n width: 100%;\r\n height: 100%;\r\n border: none;\r\n `;\r\n\r\n\t\tconst closeButton = document.createElement(\"button\");\r\n\t\tcloseButton.innerHTML = `\r\n\t\t\t<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\r\n\t\t\t\t<line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"></line>\r\n\t\t\t\t<line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"></line>\r\n\t\t\t</svg>\r\n\t\t`;\r\n\t\tcloseButton.setAttribute(\"aria-label\", \"Close modal\");\r\n\t\tcloseButton.style.cssText = `\r\n position: absolute;\r\n top: -48px;\r\n right: 0;\r\n background: rgba(255, 255, 255, 0.95);\r\n backdrop-filter: blur(8px);\r\n -webkit-backdrop-filter: blur(8px);\r\n border: none;\r\n border-radius: 50%;\r\n width: 40px;\r\n height: 40px;\r\n cursor: pointer;\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n color: #1f2937;\r\n transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);\r\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);\r\n `;\r\n\t\tcloseButton.onmouseover = () => {\r\n\t\t\tcloseButton.style.transform = \"scale(1.1) rotate(90deg)\";\r\n\t\t\tcloseButton.style.background = \"#ef4444\";\r\n\t\t\tcloseButton.style.color = \"white\";\r\n\t\t};\r\n\t\tcloseButton.onmouseout = () => {\r\n\t\t\tcloseButton.style.transform = \"scale(1) rotate(0deg)\";\r\n\t\t\tcloseButton.style.background = \"rgba(255, 255, 255, 0.95)\";\r\n\t\t\tcloseButton.style.color = \"#1f2937\";\r\n\t\t};\r\n\t\tcloseButton.onclick = () => {\r\n\t\t\tmodal.style.opacity = \"0\";\r\n\t\t\tiframeContainer.style.transform = \"scale(0.95)\";\r\n\t\t\tiframeContainer.style.opacity = \"0\";\r\n\t\t\tsetTimeout(() => modal.remove(), 300);\r\n\t\t};\r\n\r\n\t\tiframeContainer.appendChild(iframe);\r\n\t\tiframeContainer.appendChild(closeButton);\r\n\t\tmodal.appendChild(iframeContainer);\r\n\t\tdocument.body.appendChild(modal);\r\n\r\n\t\t// Close on backdrop click\r\n\t\tmodal.onclick = (e) => {\r\n\t\t\tif (e.target === modal) {\r\n\t\t\t\tcloseButton.click();\r\n\t\t\t}\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Sets up listener for messages from the iframe\r\n\t * @private\r\n\t */\r\n\tprivate setupIframeListener(): void {\r\n\t\t// Remove existing listener if any\r\n\t\tif (this.iframeMessageListener) {\r\n\t\t\twindow.removeEventListener(\"message\", this.iframeMessageListener);\r\n\t\t}\r\n\r\n\t\tthis.iframeMessageListener = (event: MessageEvent) => {\r\n\t\t\tif (event.origin !== new URL(this.config.baseUrl).origin) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tswitch (event.data.type) {\r\n\t\t\t\tcase \"VTO_IMAGE_SELECTED\":\r\n\t\t\t\t\tif (event.data.image) {\r\n\t\t\t\t\t\tthis.lastModelImage = event.data.image;\r\n\t\t\t\t\t\tthis.startVirtualTryOn();\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase \"CLOSE_MODAL\":\r\n\t\t\t\t\tremoveElements(`.${CSS_CLASSES.MODAL}`);\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t};\r\n\r\n\t\twindow.addEventListener(\"message\", this.iframeMessageListener);\r\n\t}\r\n\r\n\tprivate async startVirtualTryOn(isRefresh = false): Promise<void> {\r\n\t\tif (isRefresh) {\r\n\t\t\tconsole.log(\r\n\t\t\t\t\"[WeWear VTO] Refreshing virtual try-on with previous parameters...\",\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\tif (!this.lastModelImage || !this.originalProductImageUrl) {\r\n\t\t\tconsole.warn(\r\n\t\t\t\t\"[WeWear VTO] Missing required data to start virtual try-on.\",\r\n\t\t\t);\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Hide the modal and show loading indicator\r\n\t\tconst modal = document.querySelector(`.${CSS_CLASSES.MODAL}`);\r\n\t\tif (modal && modal instanceof HTMLElement) {\r\n\t\t\tmodal.style.display = \"none\";\r\n\t\t}\r\n\t\tconst container = document.querySelector(this.config.gallerySelector);\r\n\t\tif (container instanceof HTMLElement) {\r\n\t\t\tshowProductLoading(container, \"Generating your virtual try-on...\");\r\n\t\t}\r\n\r\n\t\ttry {\r\n\t\t\tconst submitResponse = await this.callVtoApi(\r\n\t\t\t\tthis.lastModelImage,\r\n\t\t\t\tthis.originalProductImageUrl,\r\n\t\t\t);\r\n\r\n\t\t\tlet status = await this.fetchJobStatus(submitResponse.job_id);\r\n\t\t\tconst previews: string[] = [];\r\n\r\n\t\t\twhile (status.status !== \"COMPLETED\" && status.status !== \"FAILED\") {\r\n\t\t\t\tawait new Promise((r) => setTimeout(r, 3000));\r\n\t\t\t\tstatus = await this.fetchJobStatus(submitResponse.job_id);\r\n\r\n\t\t\t\tfor (let i = previews.length; i < status.previews_available; i++) {\r\n\t\t\t\t\ttry {\r\n\t\t\t\t\t\tconst previewUrl = await this.fetchJobImage(\r\n\t\t\t\t\t\t\tsubmitResponse.job_id,\r\n\t\t\t\t\t\t\ti,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tpreviews.push(previewUrl);\r\n\t\t\t\t\t\tthis.replaceProductImage(previewUrl);\r\n\r\n\t\t\t\t\t\tif (!this.previewBadge && container instanceof HTMLElement) {\r\n\t\t\t\t\t\t\tthis.previewBadge = createPreviewBadge();\r\n\t\t\t\t\t\t\tcontainer.appendChild(this.previewBadge);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t} catch (e) {\r\n\t\t\t\t\t\tif (!(e instanceof Error && e.message === \"202_PROCESSING\"))\r\n\t\t\t\t\t\t\tthrow e;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (status.status === \"COMPLETED\") {\r\n\t\t\t\tconst finalImage = await this.fetchJobImage(submitResponse.job_id);\r\n\t\t\t\tif (finalImage) {\r\n\t\t\t\t\tthis.replaceProductImage(finalImage);\r\n\t\t\t\t}\r\n\t\t\t\tif (this.previewBadge) {\r\n\t\t\t\t\tthis.previewBadge.remove();\r\n\t\t\t\t\tthis.previewBadge = null;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (status.status === \"FAILED\") {\r\n\t\t\t\tconsole.error(\"[WeWear VTO] VTO process failed:\", status.message);\r\n\t\t\t\tif (container instanceof HTMLElement) {\r\n\t\t\t\t\tshowAlert(container, status.message, \"error\");\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t} catch (error) {\r\n\t\t\tconsole.error(\"[WeWear VTO] Error during virtual try-on process:\", error);\r\n\t\t\tif (container instanceof HTMLElement) {\r\n\t\t\t\tshowAlert(container, \"An unexpected error occurred.\", \"error\");\r\n\t\t\t}\r\n\t\t} finally {\r\n\t\t\tif (container instanceof HTMLElement) {\r\n\t\t\t\tremoveProductLoading(container);\r\n\t\t\t}\r\n\t\t\tremoveElements(`.${CSS_CLASSES.MODAL}`);\r\n\t\t}\r\n\t}\r\n\r\n\tprivate async callVtoApi(\r\n\t\tmodelImage: Blob,\r\n\t\tproductImage: string,\r\n\t): Promise<{ job_id: string }> {\r\n\t\tconst formData = new FormData();\r\n\t\tformData.append(\"model_image\", modelImage, \"model_image.png\");\r\n\t\tformData.append(\"ww_product_image\", productImage);\r\n\r\n\t\tconst res = await fetch(`${this.config.baseUrl}/api/vto`, {\r\n\t\t\tmethod: \"POST\",\r\n\t\t\tbody: formData,\r\n\t\t});\r\n\t\tif (!res.ok) {\r\n\t\t\tconst errorText = await res.text();\r\n\t\t\tconsole.error(\r\n\t\t\t\t\"[WeWear VTO] API submission failed:\",\r\n\t\t\t\tres.status,\r\n\t\t\t\terrorText,\r\n\t\t\t);\r\n\t\t\tthrow new Error(`API submission failed: ${res.status}`);\r\n\t\t}\r\n\t\treturn res.json();\r\n\t}\r\n\r\n\tprivate async fetchJobStatus(jobId: string): Promise<JobStatusResponse> {\r\n\t\tconst res = await fetch(\r\n\t\t\t`${this.config.baseUrl}/api/vto/status?job_id=${jobId}`,\r\n\t\t);\r\n\t\tif (!res.ok) throw new Error(`Status check failed: ${res.status}`);\r\n\t\treturn res.json();\r\n\t}\r\n\r\n\tprivate async fetchJobImage(\r\n\t\tjobId: string,\r\n\t\tpreviewIndex?: number,\r\n\t): Promise<string> {\r\n\t\tlet url = `${this.config.baseUrl}/api/vto/image?job_id=${jobId}`;\r\n\t\tif (previewIndex !== undefined) url += `&preview_index=${previewIndex}`;\r\n\r\n\t\tconst res = await fetch(url);\r\n\t\tif (res.status === 202) throw new Error(\"202_PROCESSING\");\r\n\t\tif (!res.ok) throw new Error(`Image fetch failed: ${res.status}`);\r\n\r\n\t\tconst blob = await res.blob();\r\n\t\treturn URL.createObjectURL(blob);\r\n\t}\r\n\r\n\tprivate async refreshVirtualTryOn(): Promise<void> {\r\n\t\tawait this.startVirtualTryOn(true);\r\n\t}\r\n\r\n\t/**\r\n\t * Replaces the product image in the gallery with the virtual try-on result\r\n\t * @private\r\n\t */\r\n\tprivate replaceProductImage(imageUrl: string): void {\r\n\t\ttry {\r\n\t\t\t// Store the virtual try-on image URL\r\n\t\t\tthis.virtualTryOnImageUrl = imageUrl;\r\n\r\n\t\t\t// Find the gallery container\r\n\t\t\tconst container = document.querySelector(this.config.gallerySelector);\r\n\t\t\tif (!container || !(container instanceof HTMLElement)) {\r\n\t\t\t\tconsole.warn(\r\n\t\t\t\t\t\"[WeWear VTO] Gallery container not found for image replacement:\",\r\n\t\t\t\t\tthis.config.gallerySelector,\r\n\t\t\t\t);\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t// Store the original content if not already stored\r\n\t\t\tif (!container.hasAttribute(\"data-ww-original-content\")) {\r\n\t\t\t\tcontainer.setAttribute(\"data-ww-original-content\", container.innerHTML);\r\n\t\t\t}\r\n\r\n\t\t\t// Capture and lock container dimensions before replacement to prevent layout shift\r\n\t\t\tif (!container.hasAttribute(\"data-ww-container-locked\")) {\r\n\t\t\t\tconst containerRect = container.getBoundingClientRect();\r\n\r\n\t\t\t\t// Store original dimensions\r\n\t\t\t\tcontainer.setAttribute(\r\n\t\t\t\t\t\"data-ww-container-width\",\r\n\t\t\t\t\tcontainerRect.width.toString(),\r\n\t\t\t\t);\r\n\t\t\t\tcontainer.setAttribute(\r\n\t\t\t\t\t\"data-ww-container-height\",\r\n\t\t\t\t\tcontainerRect.height.toString(),\r\n\t\t\t\t);\r\n\r\n\t\t\t\t// Lock the container dimensions\r\n\t\t\t\tcontainer.style.width = `${containerRect.width}px`;\r\n\t\t\t\tcontainer.style.height = `${containerRect.height}px`;\r\n\t\t\t\tcontainer.style.minWidth = `${containerRect.width}px`;\r\n\t\t\t\tcontainer.style.minHeight = `${containerRect.height}px`;\r\n\r\n\t\t\t\tcontainer.setAttribute(\"data-ww-container-locked\", \"true\");\r\n\t\t\t}\r\n\r\n\t\t\t// Capture original image dimensions before replacement to prevent layout shift\r\n\t\t\tconst originalImg = container.querySelector(\"img\");\r\n\t\t\tif (\r\n\t\t\t\toriginalImg &&\r\n\t\t\t\t!container.hasAttribute(\"data-ww-original-dimensions\")\r\n\t\t\t) {\r\n\t\t\t\tconst computedStyle = window.getComputedStyle(originalImg);\r\n\t\t\t\tconst rect = originalImg.getBoundingClientRect();\r\n\t\t\t\tcontainer.setAttribute(\"data-ww-original-width\", computedStyle.width);\r\n\t\t\t\tcontainer.setAttribute(\"data-ww-original-height\", computedStyle.height);\r\n\t\t\t\tcontainer.setAttribute(\r\n\t\t\t\t\t\"data-ww-original-rect-width\",\r\n\t\t\t\t\trect.width.toString(),\r\n\t\t\t\t);\r\n\t\t\t\tcontainer.setAttribute(\r\n\t\t\t\t\t\"data-ww-original-rect-height\",\r\n\t\t\t\t\trect.height.toString(),\r\n\t\t\t\t);\r\n\t\t\t\tcontainer.setAttribute(\"data-ww-original-dimensions\", \"true\");\r\n\t\t\t}\r\n\r\n\t\t\t// Show the virtual try-on image initially\r\n\t\t\tthis.showVirtualTryOnImage(container);\r\n\r\n\t\t\t// Replace the button container with the new multi-button version\r\n\t\t\tthis.updateButtonContainer(container);\r\n\r\n\t\t\tconsole.log(\r\n\t\t\t\t\"[WeWear VTO] Product image replaced with virtual try-on result\",\r\n\t\t\t);\r\n\t\t} catch (error) {\r\n\t\t\tconsole.error(\"[WeWear VTO] Error replacing product image:\", error);\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Updates the button container to show all available buttons\r\n\t * @private\r\n\t */\r\n\tprivate updateButtonContainer(container: HTMLElement): void {\r\n\t\t// Remove existing button containers\r\n\t\tconst existingButtons = container.querySelectorAll(\r\n\t\t\t`.${CSS_CLASSES.BUTTON_CONTAINER}`,\r\n\t\t);\r\n\t\texistingButtons.forEach((btn) => {\r\n\t\t\tbtn.remove();\r\n\t\t});\r\n\r\n\t\t// Create new button container with all buttons\r\n\t\tconst buttonContainer = createButtonContainer(\r\n\t\t\tthis.config.buttonPosition,\r\n\t\t\tthis.virtualTryOnImageUrl !== null,\r\n\t\t\tasync () => {\r\n\t\t\t\tawait this.handleTryOnClick();\r\n\t\t\t},\r\n\t\t\tasync () => {\r\n\t\t\t\tawait this.refreshVirtualTryOn();\r\n\t\t\t},\r\n\t\t\t() => {\r\n\t\t\t\tif (this.isShowingVirtualTryOn) {\r\n\t\t\t\t\tthis.showOriginalImage(container);\r\n\t\t\t\t} else {\r\n\t\t\t\t\tthis.showVirtualTryOnImage(container);\r\n\t\t\t\t}\r\n\t\t\t\tremoveProductLoading(container);\r\n\t\t\t\tthis.updateButtonContainer(container);\r\n\t\t\t},\r\n\t\t\tthis.isShowingVirtualTryOn,\r\n\t\t);\r\n\r\n\t\tcontainer.appendChild(buttonContainer);\r\n\t}\r\n\r\n\t/**\r\n\t * Shows the virtual try-on image in the container\r\n\t * @private\r\n\t */\r\n\tprivate showVirtualTryOnImage(container: HTMLElement): void {\r\n\t\tif (!this.virtualTryOnImageUrl) {\r\n\t\t\tconsole.warn(\"[WeWear VTO] No virtual try-on image URL available\");\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Remove all direct children except for the button container\r\n\t\tArray.from(container.children).forEach((child) => {\r\n\t\t\tif (!child.classList.contains(CSS_CLASSES.BUTTON_CONTAINER)) {\r\n\t\t\t\tchild.remove();\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\t// Get stored original dimensions to prevent layout shift\r\n\t\tconst originalWidth =\r\n\t\t\tcontainer.getAttribute(\"data-ww-original-width\") || \"\";\r\n\t\tconst originalHeight =\r\n\t\t\tcontainer.getAttribute(\"data-ww-original-height\") || \"\";\r\n\t\tconst originalRectWidth =\r\n\t\t\tcontainer.getAttribute(\"data-ww-original-rect-width\") || \"\";\r\n\t\tconst originalRectHeight =\r\n\t\t\tcontainer.getAttribute(\"data-ww-original-rect-height\") || \"\";\r\n\r\n\t\tconst image = document.createElement(\"img\");\r\n\t\timage.src = this.virtualTryOnImageUrl;\r\n\t\timage.alt = \"Virtual Try-On Result\";\r\n\r\n\t\t// Use original dimensions to prevent layout shift\r\n\t\tlet widthStyle = \"100%\";\r\n\t\tlet heightStyle = \"100%\";\r\n\r\n\t\t// Prefer computed style dimensions, fallback to bounding rect, then container fill\r\n\t\tif (originalWidth && originalWidth !== \"auto\" && originalWidth !== \"0px\") {\r\n\t\t\twidthStyle = originalWidth;\r\n\t\t} else if (originalRectWidth && originalRectWidth !== \"0\") {\r\n\t\t\twidthStyle = `${originalRectWidth}px`;\r\n\t\t}\r\n\r\n\t\tif (\r\n\t\t\toriginalHeight &&\r\n\t\t\toriginalHeight !== \"auto\" &&\r\n\t\t\toriginalHeight !== \"0px\"\r\n\t\t) {\r\n\t\t\theightStyle = originalHeight;\r\n\t\t} else if (originalRectHeight && originalRectHeight !== \"0\") {\r\n\t\t\theightStyle = `${originalRectHeight}px`;\r\n\t\t}\r\n\r\n\t\timage.style.cssText = `\r\n width: ${widthStyle};\r\n height: ${heightStyle};\r\n object-fit: contain;\r\n `;\r\n\r\n\t\t// Prepend the image to ensure buttons are rendered on top\r\n\t\tcontainer.prepend(image);\r\n\r\n\t\tthis.isShowingVirtualTryOn = true;\r\n\t}\r\n\r\n\t/**\r\n\t * Shows the original product image in the container\r\n\t * @private\r\n\t */\r\n\tprivate showOriginalImage(container: HTMLElement): void {\r\n\t\tconst originalContentHTML = container.getAttribute(\r\n\t\t\t\"data-ww-original-content\",\r\n\t\t);\r\n\t\tif (originalContentHTML) {\r\n\t\t\t// Remove all direct children except for the button container\r\n\t\t\tArray.from(container.children).forEach((child) => {\r\n\t\t\t\tif (!child.classList.contains(CSS_CLASSES.BUTTON_CONTAINER)) {\r\n\t\t\t\t\tchild.remove();\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n\t\t\t// Parse the original content and prepend it\r\n\t\t\tconst tempDiv = document.createElement(\"div\");\r\n\t\t\ttempDiv.innerHTML = originalContentHTML;\r\n\t\t\tcontainer.prepend(...Array.from(tempDiv.children));\r\n\t\t}\r\n\r\n\t\tthis.isShowingVirtualTryOn = false;\r\n\t}\r\n\r\n\t/**\r\n\t * Destroys the widget and cleans up resources\r\n\t */\r\n\tpublic destroy(): void {\r\n\t\ttry {\r\n\t\t\t// Remove all buttons\r\n\t\t\tremoveElements(`.${CSS_CLASSES.BUTTON_CONTAINER}`);\r\n\r\n\t\t\t// Remove all modals\r\n\t\t\tremoveElements(`.${CSS_CLASSES.MODAL}`);\r\n\r\n\t\t\t// Clear references\r\n\t\t\tthis.cameraButton = null;\r\n\r\n\t\t\t// Remove message listener\r\n\t\t\tif (this.iframeMessageListener) {\r\n\t\t\t\twindow.removeEventListener(\"message\", this.iframeMessageListener);\r\n\t\t\t\tthis.iframeMessageListener = null;\r\n\t\t\t}\r\n\r\n\t\t\t// Reset state\r\n\t\t\tthis.virtualTryOnImageUrl = null;\r\n\t\t\tthis.isShowingVirtualTryOn = false;\r\n\t\t\tthis.lastModelImage = null;\r\n\t\t\tthis.originalProductImageUrl = null;\r\n\t\t\tif (this.previewBadge) {\r\n\t\t\t\tthis.previewBadge.remove();\r\n\t\t\t\tthis.previewBadge = null;\r\n\t\t\t}\r\n\r\n\t\t\tconsole.log(\"[WeWear VTO] Widget destroyed successfully\");\r\n\t\t} catch (error) {\r\n\t\t\tconsole.error(\"[WeWear VTO] Error during widget destruction:\", error);\r\n\t\t}\r\n\t}\r\n}\r\n","import type { VirtualTryOnConfig } from \"./index.js\";\nimport { VirtualTryOnWidget } from \"./widget.js\";\n\nlet widgetInstance: VirtualTryOnWidget | null = null;\n\nexport function initVirtualTryOn(config?: VirtualTryOnConfig): void {\n\ttry {\n\t\t// Clean up any existing instance\n\t\tif (widgetInstance) {\n\t\t\twidgetInstance.destroy();\n\t\t\twidgetInstance = null;\n\t\t}\n\n\t\t// Early return if config is missing\n\t\tif (!config) {\n\t\t\tconsole.log(\n\t\t\t\t\"[WeWear VTO] Missing configuration. Widget not initialized.\",\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\t// Create and initialize new instance\n\t\twidgetInstance = new VirtualTryOnWidget(config);\n\n\t\t// Initialize immediately if DOM is ready, otherwise wait for it\n\t\tif (document.readyState === \"loading\") {\n\t\t\tdocument.addEventListener(\"DOMContentLoaded\", () => {\n\t\t\t\twidgetInstance?.init().catch((error) => {\n\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\"[WeWear VTO] Failed to initialize after DOM ready:\",\n\t\t\t\t\t\terror,\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t\t});\n\t\t} else {\n\t\t\twidgetInstance.init().catch((error) => {\n\t\t\t\tconsole.error(\"[WeWear VTO] Failed to initialize:\", error);\n\t\t\t});\n\t\t}\n\t} catch (error) {\n\t\tconsole.error(\"[WeWear VTO] Initialization error:\", error);\n\t}\n}\n\nexport function getWidgetInstance(): VirtualTryOnWidget | null {\n\treturn widgetInstance;\n}\n\nif (typeof window !== \"undefined\") {\n\tinitVirtualTryOn();\n}\n"],"names":[],"mappings":";;;;;;IAAA;IACO,MAAM,WAAW,GAAG;IAC1B,IAAA,gBAAgB,EAAE,6BAA6B;IAC/C,IAAA,MAAM,EAAE,mBAAmB;IAC3B,IAAA,KAAK,EAAE,kBAAkB;IACzB,IAAA,aAAa,EAAE,sBAAsB;KAC5B;IAEV;IACO,MAAM,OAAO,GAAG;IACtB,IAAA,MAAM,EAAE,EAAE;IACV,IAAA,KAAK,EAAE,KAAK;KACH;;aCVM,kBAAkB,GAAA;QACjC,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC;IAC3C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,CAAC,UAAU,KAAK,SAAS,EAAE;IACtC,YAAA,QAAQ,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,MAAK;IAClD,gBAAA,cAAc,KAAA,IAAA,IAAd,cAAc,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAd,cAAc,CAAE,IAAI,EAAA,CAAG,KAAK,CAAC,CAAC,KAAK,KAAI;IACtC,oBAAA,OAAO,CAAC,KAAK,CACZ,oDAAoD,EACpD,KAAK,CACL;IACF,gBAAA,CAAC,CAAC;IACH,YAAA,CAAC,CAAC;YACH;iBAAO;gBACN,cAAc,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,KAAI;IACrC,gBAAA,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,KAAK,CAAC;IAC3D,YAAA,CAAC,CAAC;YACH;QACD;QAAE,OAAO,KAAK,EAAE;IACf,QAAA,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,KAAK,CAAC;QAC3D;IACD;aAEgB,iBAAiB,GAAA;IAChC,IAAA,OAAO,cAAc;IACtB;IAEA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;IAClC,IAAA,gBAAgB,EAAE;IACnB;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/constants.ts","../src/components/badge.ts","../src/utils.ts","../src/components/button.ts","../src/components/loading-overlay.ts","../src/components/alert-overlay.ts","../src/widget.ts","../src/installer.ts"],"sourcesContent":["/** CSS class names for consistent styling */\nexport const CSS_CLASSES = {\n\tBUTTON_CONTAINER: \"wewear-vto-button-container\",\n\tBUTTON: \"wewear-vto-button\",\n\tMODAL: \"wewear-vto-modal\",\n\tPREVIEW_BADGE: \"ww-vto-preview-badge\",\n} as const;\n\n/** Z-index values for proper layering */\nexport const Z_INDEX = {\n\tBUTTON: 10,\n\tMODAL: 99999,\n} as const;\n","import { CSS_CLASSES } from \"../constants.js\";\r\n\r\nexport function createPreviewBadge(): HTMLElement {\r\n\tconst badge = document.createElement(\"div\");\r\n\tbadge.className = CSS_CLASSES.PREVIEW_BADGE;\r\n\tbadge.innerText = \"PREVIEW\";\r\n\r\n\tconst styleId = \"ww-vto-badge-styles\";\r\n\tif (!document.getElementById(styleId)) {\r\n\t\tconst styles = document.createElement(\"style\");\r\n\t\tstyles.id = styleId;\r\n\t\tstyles.innerHTML = `\r\n .${CSS_CLASSES.PREVIEW_BADGE} {\r\n position: absolute;\r\n top: 20px;\r\n right: 20px;\r\n background: rgba(31, 41, 55, 0.9);\r\n backdrop-filter: blur(4px);\r\n -webkit-backdrop-filter: blur(4px);\r\n color: white;\r\n padding: 6px 14px;\r\n border-radius: 6px;\r\n font-size: 12px;\r\n font-weight: 600;\r\n letter-spacing: 0.5px;\r\n z-index: 10;\r\n pointer-events: none;\r\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif;\r\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);\r\n animation: ww-vto-pulse 2s ease-in-out infinite;\r\n }\r\n\r\n @keyframes ww-vto-pulse {\r\n 0%, 100% {\r\n opacity: 0.9;\r\n }\r\n 50% {\r\n opacity: 1;\r\n }\r\n }\r\n `;\r\n\t\tdocument.head.appendChild(styles);\r\n\t}\r\n\r\n\treturn badge;\r\n}\r\n","export function getPositionStyles(position: string): string {\n\tswitch (position) {\n\t\tcase \"bottom-left\":\n\t\t\treturn \"left: 20px; bottom: 20px;\";\n\t\tcase \"top-right\":\n\t\t\treturn \"right: 20px; top: 20px;\";\n\t\tcase \"top-left\":\n\t\t\treturn \"left: 20px; top: 20px;\";\n\t\tdefault:\n\t\t\treturn \"right: 20px; bottom: 20px;\";\n\t}\n}\n\nexport function removeElements(selector: string): void {\n\tconst elements = document.querySelectorAll(selector);\n\telements.forEach((element) => {\n\t\telement.remove();\n\t});\n}\n","import { CSS_CLASSES, Z_INDEX } from \"../constants.js\";\r\nimport { getPositionStyles } from \"../utils.js\";\r\n\r\nexport function createButtonContainer(\r\n\tbuttonPosition: string,\r\n\thasVirtualTryOn: boolean = false,\r\n\tonCameraClick: () => void,\r\n\tonRefreshClick?: () => void,\r\n\tonToggleClick?: () => void,\r\n\tisShowingVirtualTryOn: boolean = false,\r\n): HTMLElement {\r\n\tconst container = document.createElement(\"div\");\r\n\tcontainer.className = `${CSS_CLASSES.BUTTON_CONTAINER} ww-button-group`;\r\n\r\n\tconst positionStyles = getPositionStyles(buttonPosition);\r\n\tcontainer.style.cssText = `\r\n position: absolute;\r\n ${positionStyles}\r\n display: flex;\r\n gap: 4px;\r\n border-radius: 100px;\r\n background: white;\r\n padding: 4px;\r\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\r\n z-index: ${Z_INDEX.BUTTON};\r\n transition: all 0.2s ease;\r\n `;\r\n\r\n\t// Camera button\r\n\tconst cameraButton = document.createElement(\"button\");\r\n\tcameraButton.type = \"button\";\r\n\tcameraButton.className = `${CSS_CLASSES.BUTTON} ww-camera-btn`;\r\n\tcameraButton.setAttribute(\"aria-label\", \"Virtual Try-On\");\r\n\tcameraButton.style.cssText = `\r\n display: flex;\r\n width: 40px;\r\n height: 40px;\r\n cursor: pointer;\r\n align-items: center;\r\n justify-content: center;\r\n border-radius: 100px;\r\n padding: 0;\r\n border: none;\r\n background: white;\r\n color: #000000;\r\n transition: all 0.2s ease;\r\n flex-shrink: 0;\r\n `;\r\n\r\n\tcameraButton.innerHTML = `\r\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"display: block;\">\r\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>\r\n <circle cx=\"12\" cy=\"13\" r=\"3\"></circle>\r\n </svg>\r\n `;\r\n\r\n\tcameraButton.onclick = onCameraClick;\r\n\tcontainer.appendChild(cameraButton);\r\n\r\n\t// Add refresh and toggle buttons if we have a virtual try-on\r\n\tif (hasVirtualTryOn) {\r\n\t\t// Refresh button - calls API again\r\n\t\tif (onRefreshClick) {\r\n\t\t\tconst refreshButton = document.createElement(\"button\");\r\n\t\t\trefreshButton.type = \"button\";\r\n\t\t\trefreshButton.className = \"ww-refresh-btn\";\r\n\t\t\trefreshButton.setAttribute(\"aria-label\", \"Refresh virtual try-on\");\r\n\t\t\trefreshButton.style.cssText = `\r\n display: flex;\r\n width: 40px;\r\n height: 40px;\r\n cursor: pointer;\r\n align-items: center;\r\n justify-content: center;\r\n border-radius: 100px;\r\n padding: 0;\r\n border: none;\r\n background: white;\r\n color: #333333;\r\n transition: all 0.2s ease;\r\n flex-shrink: 0;\r\n `;\r\n\r\n\t\t\trefreshButton.innerHTML = `\r\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"display: block;\">\r\n <path d=\"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8\"></path>\r\n <path d=\"M3 3v5h5\"></path>\r\n <path d=\"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16\"></path>\r\n <path d=\"M16 16h5v5\"></path>\r\n </svg>\r\n `;\r\n\r\n\t\t\trefreshButton.onclick = onRefreshClick;\r\n\r\n\t\t\trefreshButton.onclick = onRefreshClick;\r\n\t\t\tcontainer.appendChild(refreshButton);\r\n\t\t}\r\n\r\n\t\t// Toggle button (scan-face) - switches between original and virtual try-on\r\n\t\tif (onToggleClick) {\r\n\t\t\tconst toggleButton = document.createElement(\"button\");\r\n\t\t\ttoggleButton.type = \"button\";\r\n\t\t\ttoggleButton.className = \"ww-toggle-btn\";\r\n\t\t\ttoggleButton.setAttribute(\r\n\t\t\t\t\"aria-label\",\r\n\t\t\t\tisShowingVirtualTryOn ? \"Show Original Image\" : \"Show Virtual Try-On\",\r\n\t\t\t);\r\n\t\t\ttoggleButton.style.cssText = `\r\n display: flex;\r\n width: 40px;\r\n height: 40px;\r\n cursor: pointer;\r\n align-items: center;\r\n justify-content: center;\r\n border-radius: 100px;\r\n padding: 0;\r\n border: none;\r\n background: ${isShowingVirtualTryOn ? \"#333333\" : \"#e5e7eb\"};\r\n color: ${isShowingVirtualTryOn ? \"white\" : \"#333333\"};\r\n transition: all 0.2s ease;\r\n flex-shrink: 0;\r\n `;\r\n\r\n\t\t\ttoggleButton.innerHTML = `\r\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"display: block;\">\r\n <path d=\"M3 7V5a2 2 0 0 1 2-2h2\"></path>\r\n <path d=\"M17 3h2a2 2 0 0 1 2 2v2\"></path>\r\n <path d=\"M21 17v2a2 2 0 0 1-2 2h-2\"></path>\r\n <path d=\"M7 21H5a2 2 0 0 1-2-2v-2\"></path>\r\n <path d=\"M8 14s1.5 2 4 2 4-2 4-2\"></path>\r\n <path d=\"M9 9h.01\"></path>\r\n <path d=\"M15 9h.01\"></path>\r\n </svg>\r\n `;\r\n\r\n\t\t\ttoggleButton.onmouseover = () => {\r\n\t\t\t\tif (isShowingVirtualTryOn) {\r\n\t\t\t\t\ttoggleButton.style.background = \"#4a4a4a\";\r\n\t\t\t\t} else {\r\n\t\t\t\t\ttoggleButton.style.background = \"#d1d5db\";\r\n\t\t\t\t}\r\n\t\t\t};\r\n\t\t\ttoggleButton.onmouseout = () => {\r\n\t\t\t\tif (isShowingVirtualTryOn) {\r\n\t\t\t\t\ttoggleButton.style.background = \"#333333\";\r\n\t\t\t\t} else {\r\n\t\t\t\t\ttoggleButton.style.background = \"#e5e7eb\";\r\n\t\t\t\t}\r\n\t\t\t};\r\n\r\n\t\t\ttoggleButton.onclick = onToggleClick;\r\n\t\t\tcontainer.appendChild(toggleButton);\r\n\t\t}\r\n\t}\r\n\r\n\treturn container;\r\n}\r\n\r\nexport function createButton(\r\n\tbuttonPosition: string,\r\n\tonClick: () => void,\r\n\tdisabled: boolean = false,\r\n): HTMLElement {\r\n\tconst container = createButtonContainer(buttonPosition, false, onClick);\r\n\tconst cameraButton = container.querySelector(\r\n\t\t\".ww-camera-btn\",\r\n\t) as HTMLButtonElement;\r\n\tif (cameraButton) {\r\n\t\tcameraButton.disabled = disabled;\r\n\t\tif (disabled) {\r\n\t\t\tcameraButton.style.opacity = \"0.5\";\r\n\t\t\tcameraButton.style.cursor = \"not-allowed\";\r\n\t\t\tcameraButton.title = \"Find your ideal size first\";\r\n\t\t}\r\n\t}\r\n\treturn container;\r\n}\r\n","import { Z_INDEX } from \"../constants.js\";\r\n\r\n/**\r\n * Creates a loading overlay that can be shown in different containers\r\n */\r\nexport function createLoadingOverlay(\r\n\ttext: string = \"Processing...\",\r\n): HTMLElement {\r\n\tconst overlay = document.createElement(\"div\");\r\n\toverlay.className = \"ww-loading-overlay\";\r\n\toverlay.style.cssText = `\r\n position: absolute;\r\n top: 0;\r\n left: 0;\r\n width: 100%;\r\n height: 100%;\r\n background: linear-gradient(135deg, rgba(0, 0, 0, 0.92) 0%, rgba(0, 0, 0, 0.88) 100%);\r\n backdrop-filter: blur(8px);\r\n -webkit-backdrop-filter: blur(8px);\r\n display: flex;\r\n flex-direction: column;\r\n align-items: center;\r\n justify-content: center;\r\n z-index: ${Z_INDEX.MODAL + 1};\r\n border-radius: inherit;\r\n animation: ww-fade-in 0.3s ease;\r\n `;\r\n\r\n\t// Add CSS animation to the document if not already added\r\n\tif (!document.getElementById(\"ww-loading-animation\")) {\r\n\t\tconst style = document.createElement(\"style\");\r\n\t\tstyle.id = \"ww-loading-animation\";\r\n\t\tstyle.textContent = `\r\n @keyframes ww-fade-in {\r\n from { opacity: 0; }\r\n to { opacity: 1; }\r\n }\r\n \r\n @keyframes ww-pulse-logo {\r\n 0%, 100% { \r\n opacity: 0.8; \r\n transform: scale(1);\r\n }\r\n 50% { \r\n opacity: 1; \r\n transform: scale(1.05);\r\n }\r\n }\r\n \r\n @keyframes ww-spinner-rotate {\r\n 0% { transform: rotate(0deg); }\r\n 100% { transform: rotate(360deg); }\r\n }\r\n \r\n @keyframes ww-dot-bounce {\r\n 0%, 80%, 100% { \r\n transform: scale(0);\r\n opacity: 0.5;\r\n }\r\n 40% { \r\n transform: scale(1);\r\n opacity: 1;\r\n }\r\n }\r\n \r\n .ww-loading-logo {\r\n animation: ww-pulse-logo 2s ease-in-out infinite;\r\n }\r\n \r\n .ww-loading-spinner {\r\n animation: ww-spinner-rotate 1s linear infinite;\r\n }\r\n `;\r\n\t\tdocument.head.appendChild(style);\r\n\t}\r\n\r\n\toverlay.innerHTML = `\r\n <div style=\"display: flex; flex-direction: column; align-items: center; gap: 32px;\">\r\n <div style=\"position: relative; width: 120px; height: 120px; display: flex; align-items: center; justify-content: center;\">\r\n <!-- Outer spinning circle -->\r\n <div class=\"ww-loading-spinner\" style=\"\r\n position: absolute;\r\n width: 120px;\r\n height: 120px;\r\n border: 3px solid transparent;\r\n border-top: 3px solid #333333;\r\n border-right: 3px solid #333333;\r\n border-radius: 50%;\r\n \"></div>\r\n \r\n <!-- Logo -->\r\n <svg class=\"ww-loading-logo\" width=\"80\" height=\"50\" viewBox=\"0 0 214 135\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <path d=\"M102.906 74.8679C102.906 77.9717 101.574 80.7453 98.9104 83.1887C96.6871 85.1918 93.9025 86.6997 90.5566 87.7123C87.695 88.5708 84.6462 89 81.4104 89C73.8821 89 68.0047 87.0189 63.7783 83.0566C59.5519 87.0189 53.6855 89 46.1792 89C42.9434 89 39.9057 88.5708 37.066 87.7123C33.7201 86.6997 30.9245 85.1918 28.6792 83.1887C26.0157 80.7453 24.684 77.9717 24.684 74.8679V41.6509H32.3774V74.8679C32.3774 76.2547 33.489 77.5645 35.7123 78.7972C37.3632 79.7217 39.0692 80.3711 40.8302 80.7453C42.5252 81.1195 44.3082 81.3066 46.1792 81.3066C48.0063 81.3066 49.7673 81.1195 51.4623 80.7453C53.2453 80.3711 54.9623 79.7217 56.6132 78.7972C58.8585 77.5645 59.9811 76.2547 59.9811 74.8679V41.6509H67.6085V74.8679C67.6085 76.2547 68.7311 77.5645 70.9764 78.7972C72.6274 79.7217 74.3443 80.3711 76.1274 80.7453C77.8223 81.1195 79.5833 81.3066 81.4104 81.3066C83.2814 81.3066 85.0755 81.1195 86.7925 80.7453C88.5314 80.3711 90.2264 79.7217 91.8774 78.7972C94.1006 77.5645 95.2123 76.2547 95.2123 74.8679V41.6509H102.906V74.8679ZM189.283 74.8679C189.283 77.9717 187.951 80.7453 185.288 83.1887C183.064 85.1918 180.28 86.6997 176.934 87.7123C174.072 88.5708 171.024 89 167.788 89C160.259 89 154.382 87.0189 150.156 83.0566C145.929 87.0189 140.063 89 132.557 89C129.321 89 126.283 88.5708 123.443 87.7123C120.097 86.6997 117.302 85.1918 115.057 83.1887C112.393 80.7453 111.061 77.9717 111.061 74.8679V41.6509H118.755V74.8679C118.755 76.2547 119.866 77.5645 122.09 78.7972C123.741 79.7217 125.447 80.3711 127.208 80.7453C128.903 81.1195 130.686 81.3066 132.557 81.3066C134.384 81.3066 136.145 81.1195 137.84 80.7453C139.623 80.3711 141.34 79.7217 142.991 78.7972C145.236 77.5645 146.358 76.2547 146.358 74.8679V41.6509H153.986V74.8679C153.986 76.2547 155.108 77.5645 157.354 78.7972C159.005 79.7217 160.722 80.3711 162.505 80.7453C164.2 81.1195 165.961 81.3066 167.788 81.3066C169.659 81.3066 171.453 81.1195 173.17 80.7453C174.909 80.3711 176.604 79.7217 178.255 78.7972C180.478 77.5645 181.59 76.2547 181.59 74.8679V41.6509H189.283V74.8679Z\" fill=\"white\"/>\r\n </svg>\r\n </div>\r\n \r\n <div style=\"font-size: 17px; font-weight: 500; text-align: center; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; color: white; letter-spacing: 0.5px; max-width: 280px;\">${text}</div>\r\n \r\n <div style=\"display: flex; gap: 10px; margin-top: 4px;\">\r\n <div style=\"width: 10px; height: 10px; border-radius: 50%; background: #333333; animation: ww-dot-bounce 1.4s ease-in-out infinite;\"></div>\r\n <div style=\"width: 10px; height: 10px; border-radius: 50%; background: #333333; animation: ww-dot-bounce 1.4s ease-in-out 0.2s infinite;\"></div>\r\n <div style=\"width: 10px; height: 10px; border-radius: 50%; background: #333333; animation: ww-dot-bounce 1.4s ease-in-out 0.4s infinite;\"></div>\r\n </div>\r\n </div>\r\n `;\r\n\r\n\treturn overlay;\r\n}\r\n\r\n/**\r\n * Shows a loading overlay in the product gallery container\r\n */\r\nexport function showProductLoading(\r\n\tcontainer: HTMLElement,\r\n\ttext: string = \"Generating virtual try-on...\",\r\n): void {\r\n\t// Remove any existing loading overlays\r\n\tremoveProductLoading(container);\r\n\r\n\t// Make container relative if it's not already positioned\r\n\tconst computedStyle = window.getComputedStyle(container);\r\n\tif (computedStyle.position === \"static\") {\r\n\t\tcontainer.style.position = \"relative\";\r\n\t}\r\n\r\n\tconst loadingOverlay = createLoadingOverlay(text);\r\n\tcontainer.appendChild(loadingOverlay);\r\n}\r\n\r\n/**\r\n * Removes loading overlay from product container\r\n */\r\nexport function removeProductLoading(container: HTMLElement): void {\r\n\tconst existingOverlay = container.querySelector(\".ww-loading-overlay\");\r\n\tif (existingOverlay) {\r\n\t\texistingOverlay.remove();\r\n\t}\r\n}\r\n","export function showAlert(\r\n\tcontainer: HTMLElement,\r\n\tmessage: string,\r\n\ttype: \"error\" | \"warning\",\r\n) {\r\n\tremoveAlert(container); // Remove any existing alert\r\n\r\n\tconst alertDiv = document.createElement(\"div\");\r\n\talertDiv.className = `ww-alert ww-alert-${type}`;\r\n\talertDiv.setAttribute(\"role\", type === \"error\" ? \"alert\" : \"status\");\r\n\talertDiv.setAttribute(\"aria-live\", \"assertive\");\r\n\r\n\tconst bgColor =\r\n\t\ttype === \"error\"\r\n\t\t\t? \"linear-gradient(135deg, #fee2e2 0%, #fecaca 100%)\"\r\n\t\t\t: \"linear-gradient(135deg, #fef9c3 0%, #fde68a 100%)\";\r\n\tconst textColor = type === \"error\" ? \"#991b1b\" : \"#78350f\";\r\n\tconst borderColor = type === \"error\" ? \"#f87171\" : \"#fbbf24\";\r\n\tconst iconColor = type === \"error\" ? \"#dc2626\" : \"#d97706\";\r\n\r\n\talertDiv.style.cssText = `\r\n position: absolute;\r\n top: 24px;\r\n left: 50%;\r\n transform: translateX(-50%) translateY(-20px);\r\n background: ${bgColor};\r\n color: ${textColor};\r\n border: 1px solid ${borderColor};\r\n border-radius: 12px;\r\n padding: 16px 20px;\r\n z-index: 9999;\r\n font-size: 15px;\r\n font-weight: 500;\r\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);\r\n backdrop-filter: blur(8px);\r\n -webkit-backdrop-filter: blur(8px);\r\n display: flex;\r\n align-items: center;\r\n gap: 12px;\r\n min-width: 280px;\r\n max-width: 90%;\r\n opacity: 0;\r\n transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);\r\n `;\r\n\r\n\tconst icon =\r\n\t\ttype === \"error\"\r\n\t\t\t? `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"${iconColor}\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\r\n\t\t\t<circle cx=\"12\" cy=\"12\" r=\"10\"/><line x1=\"12\" y1=\"8\" x2=\"12\" y2=\"12\"/><line x1=\"12\" y1=\"16\" x2=\"12.01\" y2=\"16\"/>\r\n\t\t</svg>`\r\n\t\t\t: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"${iconColor}\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\r\n\t\t\t<path d=\"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z\"/><line x1=\"12\" y1=\"9\" x2=\"12\" y2=\"13\"/><line x1=\"12\" y1=\"17\" x2=\"12.01\" y2=\"17\"/>\r\n\t\t</svg>`;\r\n\r\n\talertDiv.innerHTML = `\r\n ${icon}\r\n <span style=\"flex: 1; line-height: 1.5;\">${message}</span>\r\n <button type=\"button\" aria-label=\"Close alert\"\r\n style=\"\r\n background: none;\r\n border: none;\r\n font-size: 22px;\r\n color: ${textColor};\r\n cursor: pointer;\r\n padding: 0;\r\n line-height: 1;\r\n opacity: 0.7;\r\n transition: opacity 0.2s ease;\r\n width: 24px;\r\n height: 24px;\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n \"\r\n onmouseover=\"this.style.opacity='1'\"\r\n onmouseout=\"this.style.opacity='0.7'\">\r\n ×\r\n </button>\r\n `;\r\n\r\n\t// Close on button click\r\n\talertDiv.querySelector(\"button\")?.addEventListener(\"click\", () => {\r\n\t\tfadeOutAndRemove(alertDiv);\r\n\t});\r\n\r\n\tcontainer.appendChild(alertDiv);\r\n\r\n\t// Animate in\r\n\trequestAnimationFrame(() => {\r\n\t\talertDiv.style.opacity = \"1\";\r\n\t\talertDiv.style.transform = \"translateX(-50%) translateY(0)\";\r\n\t});\r\n\r\n\t// Auto-dismiss after 8 seconds\r\n\tsetTimeout(() => {\r\n\t\tif (alertDiv.parentElement) {\r\n\t\t\tfadeOutAndRemove(alertDiv);\r\n\t\t}\r\n\t}, 8000);\r\n}\r\n\r\nfunction fadeOutAndRemove(element: HTMLElement) {\r\n\telement.style.opacity = \"0\";\r\n\telement.style.transform = \"translateX(-50%) translateY(-20px)\";\r\n\tsetTimeout(() => {\r\n\t\telement.remove();\r\n\t}, 300);\r\n}\r\n\r\nexport function removeAlert(container: HTMLElement) {\r\n\tconst alert = container.querySelector(\".ww-alert\") as HTMLElement;\r\n\tif (alert) fadeOutAndRemove(alert);\r\n}\r\n","import { CSS_CLASSES } from \"./constants.js\";\r\nimport {\r\n\tcreateButton,\r\n\tcreateButtonContainer,\r\n\tremoveProductLoading,\r\n\tshowProductLoading,\r\n\tcreatePreviewBadge,\r\n} from \"./components/index.js\";\r\nimport type { VirtualTryOnConfig } from \"./index.js\";\r\nimport { removeElements } from \"./utils.js\";\r\nimport { showAlert } from \"./components/alert-overlay.js\";\r\n\r\n/**\r\n * Job status type\r\n */\r\ntype JobStatus = \"PENDING\" | \"PREVIEW_AVAILABLE\" | \"COMPLETED\" | \"FAILED\";\r\n\r\n/**\r\n * Response from the job status endpoint\r\n */\r\ninterface JobStatusResponse {\r\n\tstatus: JobStatus;\r\n\tpreviews_available: number;\r\n\tmessage: string;\r\n}\r\n\r\nexport class VirtualTryOnWidget {\r\n\tprivate readonly config: Required<VirtualTryOnConfig>;\r\n\tprivate virtualTryOnImageUrl: string | null = null;\r\n\tprivate originalProductImageUrl: string | null = null;\r\n\tprivate originalProductImages: string[] = []; // Store all original product images\r\n\tprivate isShowingVirtualTryOn: boolean = false;\r\n\tprivate lastModelImage: Blob | null = null;\r\n\tprivate cameraButton: HTMLButtonElement | null = null;\r\n\tprivate iframeMessageListener: ((event: MessageEvent) => void) | null = null;\r\n\tprivate previewBadge: HTMLElement | null = null;\r\n\r\n\tconstructor(config: VirtualTryOnConfig) {\r\n\t\tthis.config = {\r\n\t\t\tbaseUrl: config.baseUrl,\r\n\t\t\tproductPageSelector: config.productPageSelector,\r\n\t\t\tgallerySelector: config.gallerySelector,\r\n\t\t\tproductImageSelector: config.productImageSelector,\r\n\t\t\tbuttonPosition: config.buttonPosition,\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Initializes the virtual try-on widget on the current page\r\n\t * @returns Promise that resolves when initialization is complete\r\n\t */\r\n\tpublic async init(): Promise<void> {\r\n\t\ttry {\r\n\t\t\t// Check if we're on a product page\r\n\t\t\tif (!window.location.pathname.includes(this.config.productPageSelector)) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t// Find the gallery container\r\n\t\t\tconst container = document.querySelector(this.config.gallerySelector);\r\n\t\t\tif (!container || !(container instanceof HTMLElement)) {\r\n\t\t\t\tconsole.warn(\r\n\t\t\t\t\t\"[WeWear VTO] Gallery container not found:\",\r\n\t\t\t\t\tthis.config.gallerySelector,\r\n\t\t\t\t);\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t// Ensure container has relative positioning for button placement\r\n\t\t\tif (getComputedStyle(container).position === \"static\") {\r\n\t\t\t\tcontainer.style.position = \"relative\";\r\n\t\t\t}\r\n\r\n\t\t\t// Create and add the virtual try-on button\r\n\t\t\tconst button = createButton(this.config.buttonPosition, async () => {\r\n\t\t\t\tif (this.cameraButton && !this.cameraButton.disabled) {\r\n\t\t\t\t\tawait this.handleTryOnClick();\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n\t\t\t// Store reference to camera button for dynamic enable/disable\r\n\t\t\tthis.cameraButton = button.querySelector(\".ww-camera-btn\");\r\n\t\t\tcontainer.appendChild(button);\r\n\t\t\tconsole.log(\"[WeWear VTO] Widget initialized successfully\");\r\n\r\n\t\t\t// Listen for messages from the photo upload page\r\n\t\t\tthis.setupIframeListener();\r\n\t\t} catch (error) {\r\n\t\t\tconsole.error(\"[WeWear VTO] Initialization failed:\", error);\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Handles virtual try-on button click\r\n\t * @private\r\n\t */\r\n\tprivate async handleTryOnClick(): Promise<void> {\r\n\t\tconsole.log(\"[WeWear VTO] Button clicked, starting try-on process...\");\r\n\r\n\t\ttry {\r\n\t\t\t// Store original images on first click if not already stored\r\n\t\t\tif (this.originalProductImages.length === 0) {\r\n\t\t\t\tthis.originalProductImages = this.getAllProductImages();\r\n\t\t\t\tconsole.log(\r\n\t\t\t\t\t\"[WeWear VTO] Stored original product images:\",\r\n\t\t\t\t\tthis.originalProductImages,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\r\n\t\t\tconsole.log(\"[WeWear VTO] Retrieved data:\", {\r\n\t\t\t\tproductImages: this.originalProductImages,\r\n\t\t\t});\r\n\r\n\t\t\tif (this.originalProductImages.length === 0) {\r\n\t\t\t\tconsole.warn(\r\n\t\t\t\t\t\"[WeWear VTO] Product images not found:\",\r\n\t\t\t\t\tthis.config.productImageSelector,\r\n\t\t\t\t);\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t// Store the first image as the original\r\n\t\t\tif (!this.originalProductImageUrl) {\r\n\t\t\t\tthis.originalProductImageUrl = this.originalProductImages[0];\r\n\t\t\t}\r\n\r\n\t\t\t// Open the photo upload page in a modal\r\n\t\t\tconst photoUploadUrl = new URL(`${this.config.baseUrl}`);\r\n\t\t\t// Pass all product images as a comma-separated string\r\n\t\t\tphotoUploadUrl.searchParams.append(\r\n\t\t\t\t\"ww_product_images\",\r\n\t\t\t\tthis.originalProductImages.join(\",\"),\r\n\t\t\t);\r\n\r\n\t\t\tthis.showPhotoUploadModal(photoUploadUrl.toString());\r\n\t\t} catch (error) {\r\n\t\t\tconsole.error(\"[WeWear VTO] Try-on request failed:\", error);\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Gets all product images from the gallery\r\n\t * @private\r\n\t * @returns Array of product image URLs\r\n\t */\r\n\tprivate getAllProductImages(): string[] {\r\n\t\tconst productImageElements = document.querySelectorAll(\r\n\t\t\tthis.config.productImageSelector,\r\n\t\t) as NodeListOf<HTMLImageElement>;\r\n\r\n\t\tconst images: string[] = [];\r\n\r\n\t\tproductImageElements.forEach((img) => {\r\n\t\t\tconst imageUrl =\r\n\t\t\t\timg.src ||\r\n\t\t\t\timg.getAttribute(\"data-src\") ||\r\n\t\t\t\timg.getAttribute(\"data-large_image\") ||\r\n\t\t\t\t\"\";\r\n\r\n\t\t\t// Only include http/https URLs, exclude blob URLs and data URLs\r\n\t\t\tif (\r\n\t\t\t\timageUrl &&\r\n\t\t\t\t(imageUrl.startsWith(\"http://\") || imageUrl.startsWith(\"https://\")) &&\r\n\t\t\t\t!images.includes(imageUrl)\r\n\t\t\t) {\r\n\t\t\t\timages.push(imageUrl);\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\treturn images;\r\n\t}\r\n\r\n\t/**\r\n\t * Shows a modal with an iframe for the photo upload page\r\n\t * @private\r\n\t */\r\n\tprivate showPhotoUploadModal(url: string): void {\r\n\t\t// Remove existing modals\r\n\t\tremoveElements(`.${CSS_CLASSES.MODAL}`);\r\n\r\n\t\tconst modal = document.createElement(\"div\");\r\n\t\tmodal.className = CSS_CLASSES.MODAL;\r\n\t\tmodal.style.cssText = `\r\n position: fixed;\r\n top: 0;\r\n left: 0;\r\n right: 0;\r\n bottom: 0;\r\n width: 100%;\r\n height: 100%;\r\n background-color: rgba(0, 0, 0, 0.8);\r\n display: flex;\r\n justify-content: center;\r\n align-items: center;\r\n z-index: 999999999;\r\n animation: ww-modal-fade-in 0.3s ease;\r\n `;\r\n\r\n\t\t// Add fade-in animation\r\n\t\tif (!document.getElementById(\"ww-modal-animation\")) {\r\n\t\t\tconst style = document.createElement(\"style\");\r\n\t\t\tstyle.id = \"ww-modal-animation\";\r\n\t\t\tstyle.textContent = `\r\n\t\t\t\t@keyframes ww-modal-fade-in {\r\n\t\t\t\t\tfrom { opacity: 0; }\r\n\t\t\t\t\tto { opacity: 1; }\r\n\t\t\t\t}\r\n\t\t\t\t@keyframes ww-modal-scale-in {\r\n\t\t\t\t\tfrom { transform: scale(0.95); opacity: 0; }\r\n\t\t\t\t\tto { transform: scale(1); opacity: 1; }\r\n\t\t\t\t}\r\n\t\t\t`;\r\n\t\t\tdocument.head.appendChild(style);\r\n\t\t}\r\n\r\n\t\tconst iframeContainer = document.createElement(\"div\");\r\n\t\tiframeContainer.style.cssText = `\r\n\t\t\tposition: relative;\r\n\t\t\twidth: 90%;\r\n\t\t\theight: 90%;\r\n\t\t\tmax-width: 480px;\r\n\t\t\tmax-height: 720px;\r\n\t\t\tborder-radius: 20px;\r\n\t\t\toverflow: hidden;\r\n\t\t\tbox-shadow: 0 24px 48px rgba(0, 0, 0, 0.3), 0 12px 24px rgba(0, 0, 0, 0.2);\r\n\t\t\tanimation: ww-modal-scale-in 0.3s cubic-bezier(0.4, 0, 0.2, 1);\r\n\t\t\tbackground: white;\r\n\t\t`;\r\n\r\n\t\tconst iframe = document.createElement(\"iframe\");\r\n\t\tiframe.src = url;\r\n\t\tiframe.style.cssText = `\r\n width: 100%;\r\n height: 100%;\r\n border: none;\r\n `;\r\n\r\n\t\tconst closeButton = document.createElement(\"button\");\r\n\t\tcloseButton.innerHTML = `\r\n\t\t\t<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\r\n\t\t\t\t<line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"></line>\r\n\t\t\t\t<line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"></line>\r\n\t\t\t</svg>\r\n\t\t`;\r\n\t\tcloseButton.setAttribute(\"aria-label\", \"Close modal\");\r\n\t\tcloseButton.style.cssText = `\r\n position: absolute;\r\n top: -48px;\r\n right: 0;\r\n background: rgba(255, 255, 255, 0.95);\r\n backdrop-filter: blur(8px);\r\n -webkit-backdrop-filter: blur(8px);\r\n border: none;\r\n border-radius: 50%;\r\n width: 40px;\r\n height: 40px;\r\n cursor: pointer;\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n color: #1f2937;\r\n transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);\r\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);\r\n `;\r\n\t\tcloseButton.onmouseover = () => {\r\n\t\t\tcloseButton.style.transform = \"scale(1.1) rotate(90deg)\";\r\n\t\t\tcloseButton.style.background = \"#ef4444\";\r\n\t\t\tcloseButton.style.color = \"white\";\r\n\t\t};\r\n\t\tcloseButton.onmouseout = () => {\r\n\t\t\tcloseButton.style.transform = \"scale(1) rotate(0deg)\";\r\n\t\t\tcloseButton.style.background = \"rgba(255, 255, 255, 0.95)\";\r\n\t\t\tcloseButton.style.color = \"#1f2937\";\r\n\t\t};\r\n\t\tcloseButton.onclick = () => {\r\n\t\t\tmodal.style.opacity = \"0\";\r\n\t\t\tiframeContainer.style.transform = \"scale(0.95)\";\r\n\t\t\tiframeContainer.style.opacity = \"0\";\r\n\t\t\tsetTimeout(() => modal.remove(), 300);\r\n\t\t};\r\n\r\n\t\tiframeContainer.appendChild(iframe);\r\n\t\tiframeContainer.appendChild(closeButton);\r\n\t\tmodal.appendChild(iframeContainer);\r\n\t\tdocument.body.appendChild(modal);\r\n\r\n\t\t// Close on backdrop click\r\n\t\tmodal.onclick = (e) => {\r\n\t\t\tif (e.target === modal) {\r\n\t\t\t\tcloseButton.click();\r\n\t\t\t}\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Sets up listener for messages from the iframe\r\n\t * @private\r\n\t */\r\n\tprivate setupIframeListener(): void {\r\n\t\t// Remove existing listener if any\r\n\t\tif (this.iframeMessageListener) {\r\n\t\t\twindow.removeEventListener(\"message\", this.iframeMessageListener);\r\n\t\t}\r\n\r\n\t\tthis.iframeMessageListener = (event: MessageEvent) => {\r\n\t\t\tif (event.origin !== new URL(this.config.baseUrl).origin) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tswitch (event.data.type) {\r\n\t\t\t\tcase \"VTO_IMAGE_SELECTED\":\r\n\t\t\t\t\tif (event.data.image) {\r\n\t\t\t\t\t\tthis.lastModelImage = event.data.image;\r\n\t\t\t\t\t\tthis.startVirtualTryOn();\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase \"CLOSE_MODAL\":\r\n\t\t\t\t\tremoveElements(`.${CSS_CLASSES.MODAL}`);\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t};\r\n\r\n\t\twindow.addEventListener(\"message\", this.iframeMessageListener);\r\n\t}\r\n\r\n\tprivate async startVirtualTryOn(isRefresh = false): Promise<void> {\r\n\t\tif (isRefresh) {\r\n\t\t\tconsole.log(\r\n\t\t\t\t\"[WeWear VTO] Refreshing virtual try-on with previous parameters...\",\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\tif (!this.lastModelImage) {\r\n\t\t\tconsole.warn(\r\n\t\t\t\t\"[WeWear VTO] Missing required data to start virtual try-on.\",\r\n\t\t\t);\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Use stored original images, or get them if not stored yet\r\n\t\tif (this.originalProductImages.length === 0) {\r\n\t\t\tthis.originalProductImages = this.getAllProductImages();\r\n\t\t}\r\n\r\n\t\tif (this.originalProductImages.length === 0) {\r\n\t\t\tconsole.warn(\"[WeWear VTO] No product images found.\");\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Hide the modal and show loading indicator\r\n\t\tconst modal = document.querySelector(`.${CSS_CLASSES.MODAL}`);\r\n\t\tif (modal && modal instanceof HTMLElement) {\r\n\t\t\tmodal.style.display = \"none\";\r\n\t\t}\r\n\t\tconst container = document.querySelector(this.config.gallerySelector);\r\n\t\tif (container instanceof HTMLElement) {\r\n\t\t\tshowProductLoading(container, \"Generating your virtual try-on...\");\r\n\t\t}\r\n\r\n\t\ttry {\r\n\t\t\tconst submitResponse = await this.callVtoApi(\r\n\t\t\t\tthis.lastModelImage,\r\n\t\t\t\tthis.originalProductImages,\r\n\t\t\t);\r\n\r\n\t\t\tlet status = await this.fetchJobStatus(submitResponse.job_id);\r\n\t\t\tconst previews: string[] = [];\r\n\r\n\t\t\twhile (status.status !== \"COMPLETED\" && status.status !== \"FAILED\") {\r\n\t\t\t\tawait new Promise((r) => setTimeout(r, 3000));\r\n\t\t\t\tstatus = await this.fetchJobStatus(submitResponse.job_id);\r\n\r\n\t\t\t\tfor (let i = previews.length; i < status.previews_available; i++) {\r\n\t\t\t\t\ttry {\r\n\t\t\t\t\t\tconst previewUrl = await this.fetchJobImage(\r\n\t\t\t\t\t\t\tsubmitResponse.job_id,\r\n\t\t\t\t\t\t\ti,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tpreviews.push(previewUrl);\r\n\t\t\t\t\t\tthis.replaceProductImage(previewUrl);\r\n\r\n\t\t\t\t\t\tif (!this.previewBadge && container instanceof HTMLElement) {\r\n\t\t\t\t\t\t\tthis.previewBadge = createPreviewBadge();\r\n\t\t\t\t\t\t\tcontainer.appendChild(this.previewBadge);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t} catch (e) {\r\n\t\t\t\t\t\tif (!(e instanceof Error && e.message === \"202_PROCESSING\"))\r\n\t\t\t\t\t\t\tthrow e;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (status.status === \"COMPLETED\") {\r\n\t\t\t\tconst finalImage = await this.fetchJobImage(submitResponse.job_id);\r\n\t\t\t\tif (finalImage) {\r\n\t\t\t\t\tthis.replaceProductImage(finalImage);\r\n\t\t\t\t}\r\n\t\t\t\tif (this.previewBadge) {\r\n\t\t\t\t\tthis.previewBadge.remove();\r\n\t\t\t\t\tthis.previewBadge = null;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (status.status === \"FAILED\") {\r\n\t\t\t\tconsole.error(\"[WeWear VTO] VTO process failed:\", status.message);\r\n\t\t\t\tif (container instanceof HTMLElement) {\r\n\t\t\t\t\tshowAlert(container, status.message, \"error\");\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t} catch (error) {\r\n\t\t\tconsole.error(\"[WeWear VTO] Error during virtual try-on process:\", error);\r\n\t\t\tif (container instanceof HTMLElement) {\r\n\t\t\t\tshowAlert(container, \"An unexpected error occurred.\", \"error\");\r\n\t\t\t}\r\n\t\t} finally {\r\n\t\t\tif (container instanceof HTMLElement) {\r\n\t\t\t\tremoveProductLoading(container);\r\n\t\t\t}\r\n\t\t\tremoveElements(`.${CSS_CLASSES.MODAL}`);\r\n\t\t}\r\n\t}\r\n\r\n\tprivate async callVtoApi(\r\n\t\tmodelImage: Blob,\r\n\t\tproductImages: string[],\r\n\t): Promise<{ job_id: string }> {\r\n\t\tconst formData = new FormData();\r\n\t\tformData.append(\"model_image\", modelImage, \"model_image.png\");\r\n\r\n\t\t// Send all product images as a JSON array\r\n\t\tformData.append(\"product_image_urls\", JSON.stringify(productImages));\r\n\r\n\t\tconst res = await fetch(`${this.config.baseUrl}/api/vto`, {\r\n\t\t\tmethod: \"POST\",\r\n\t\t\tbody: formData,\r\n\t\t});\r\n\t\tif (!res.ok) {\r\n\t\t\tconst errorText = await res.text();\r\n\t\t\tconsole.error(\r\n\t\t\t\t\"[WeWear VTO] API submission failed:\",\r\n\t\t\t\tres.status,\r\n\t\t\t\terrorText,\r\n\t\t\t);\r\n\t\t\tthrow new Error(`API submission failed: ${res.status}`);\r\n\t\t}\r\n\t\treturn res.json();\r\n\t}\r\n\r\n\tprivate async fetchJobStatus(jobId: string): Promise<JobStatusResponse> {\r\n\t\tconst res = await fetch(\r\n\t\t\t`${this.config.baseUrl}/api/vto/status?job_id=${jobId}`,\r\n\t\t);\r\n\t\tif (!res.ok) throw new Error(`Status check failed: ${res.status}`);\r\n\t\treturn res.json();\r\n\t}\r\n\r\n\tprivate async fetchJobImage(\r\n\t\tjobId: string,\r\n\t\tpreviewIndex?: number,\r\n\t): Promise<string> {\r\n\t\tlet url = `${this.config.baseUrl}/api/vto/image?job_id=${jobId}`;\r\n\t\tif (previewIndex !== undefined) url += `&preview_index=${previewIndex}`;\r\n\r\n\t\tconst res = await fetch(url);\r\n\t\tif (res.status === 202) throw new Error(\"202_PROCESSING\");\r\n\t\tif (!res.ok) throw new Error(`Image fetch failed: ${res.status}`);\r\n\r\n\t\tconst blob = await res.blob();\r\n\t\treturn URL.createObjectURL(blob);\r\n\t}\r\n\r\n\tprivate async refreshVirtualTryOn(): Promise<void> {\r\n\t\tawait this.startVirtualTryOn(true);\r\n\t}\r\n\r\n\t/**\r\n\t * Replaces the product image in the gallery with the virtual try-on result\r\n\t * @private\r\n\t */\r\n\tprivate replaceProductImage(imageUrl: string): void {\r\n\t\ttry {\r\n\t\t\t// Store the virtual try-on image URL\r\n\t\t\tthis.virtualTryOnImageUrl = imageUrl;\r\n\r\n\t\t\t// Find the gallery container\r\n\t\t\tconst container = document.querySelector(this.config.gallerySelector);\r\n\t\t\tif (!container || !(container instanceof HTMLElement)) {\r\n\t\t\t\tconsole.warn(\r\n\t\t\t\t\t\"[WeWear VTO] Gallery container not found for image replacement:\",\r\n\t\t\t\t\tthis.config.gallerySelector,\r\n\t\t\t\t);\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t// Store the original content if not already stored\r\n\t\t\tif (!container.hasAttribute(\"data-ww-original-content\")) {\r\n\t\t\t\tcontainer.setAttribute(\"data-ww-original-content\", container.innerHTML);\r\n\t\t\t}\r\n\r\n\t\t\t// Capture and lock container dimensions before replacement to prevent layout shift\r\n\t\t\tif (!container.hasAttribute(\"data-ww-container-locked\")) {\r\n\t\t\t\tconst containerRect = container.getBoundingClientRect();\r\n\r\n\t\t\t\t// Store original dimensions\r\n\t\t\t\tcontainer.setAttribute(\r\n\t\t\t\t\t\"data-ww-container-width\",\r\n\t\t\t\t\tcontainerRect.width.toString(),\r\n\t\t\t\t);\r\n\t\t\t\tcontainer.setAttribute(\r\n\t\t\t\t\t\"data-ww-container-height\",\r\n\t\t\t\t\tcontainerRect.height.toString(),\r\n\t\t\t\t);\r\n\r\n\t\t\t\t// Lock the container dimensions\r\n\t\t\t\tcontainer.style.width = `${containerRect.width}px`;\r\n\t\t\t\tcontainer.style.height = `${containerRect.height}px`;\r\n\t\t\t\tcontainer.style.minWidth = `${containerRect.width}px`;\r\n\t\t\t\tcontainer.style.minHeight = `${containerRect.height}px`;\r\n\r\n\t\t\t\tcontainer.setAttribute(\"data-ww-container-locked\", \"true\");\r\n\t\t\t}\r\n\r\n\t\t\t// Capture original image dimensions before replacement to prevent layout shift\r\n\t\t\tconst originalImg = container.querySelector(\"img\");\r\n\t\t\tif (\r\n\t\t\t\toriginalImg &&\r\n\t\t\t\t!container.hasAttribute(\"data-ww-original-dimensions\")\r\n\t\t\t) {\r\n\t\t\t\tconst computedStyle = window.getComputedStyle(originalImg);\r\n\t\t\t\tconst rect = originalImg.getBoundingClientRect();\r\n\t\t\t\tcontainer.setAttribute(\"data-ww-original-width\", computedStyle.width);\r\n\t\t\t\tcontainer.setAttribute(\"data-ww-original-height\", computedStyle.height);\r\n\t\t\t\tcontainer.setAttribute(\r\n\t\t\t\t\t\"data-ww-original-rect-width\",\r\n\t\t\t\t\trect.width.toString(),\r\n\t\t\t\t);\r\n\t\t\t\tcontainer.setAttribute(\r\n\t\t\t\t\t\"data-ww-original-rect-height\",\r\n\t\t\t\t\trect.height.toString(),\r\n\t\t\t\t);\r\n\t\t\t\tcontainer.setAttribute(\"data-ww-original-dimensions\", \"true\");\r\n\t\t\t}\r\n\r\n\t\t\t// Show the virtual try-on image initially\r\n\t\t\tthis.showVirtualTryOnImage(container);\r\n\r\n\t\t\t// Replace the button container with the new multi-button version\r\n\t\t\tthis.updateButtonContainer(container);\r\n\r\n\t\t\tconsole.log(\r\n\t\t\t\t\"[WeWear VTO] Product image replaced with virtual try-on result\",\r\n\t\t\t);\r\n\t\t} catch (error) {\r\n\t\t\tconsole.error(\"[WeWear VTO] Error replacing product image:\", error);\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Updates the button container to show all available buttons\r\n\t * @private\r\n\t */\r\n\tprivate updateButtonContainer(container: HTMLElement): void {\r\n\t\t// Remove existing button containers\r\n\t\tconst existingButtons = container.querySelectorAll(\r\n\t\t\t`.${CSS_CLASSES.BUTTON_CONTAINER}`,\r\n\t\t);\r\n\t\texistingButtons.forEach((btn) => {\r\n\t\t\tbtn.remove();\r\n\t\t});\r\n\r\n\t\t// Create new button container with all buttons\r\n\t\tconst buttonContainer = createButtonContainer(\r\n\t\t\tthis.config.buttonPosition,\r\n\t\t\tthis.virtualTryOnImageUrl !== null,\r\n\t\t\tasync () => {\r\n\t\t\t\tawait this.handleTryOnClick();\r\n\t\t\t},\r\n\t\t\tasync () => {\r\n\t\t\t\tawait this.refreshVirtualTryOn();\r\n\t\t\t},\r\n\t\t\t() => {\r\n\t\t\t\tif (this.isShowingVirtualTryOn) {\r\n\t\t\t\t\tthis.showOriginalImage(container);\r\n\t\t\t\t} else {\r\n\t\t\t\t\tthis.showVirtualTryOnImage(container);\r\n\t\t\t\t}\r\n\t\t\t\tremoveProductLoading(container);\r\n\t\t\t\tthis.updateButtonContainer(container);\r\n\t\t\t},\r\n\t\t\tthis.isShowingVirtualTryOn,\r\n\t\t);\r\n\r\n\t\tcontainer.appendChild(buttonContainer);\r\n\t}\r\n\r\n\t/**\r\n\t * Shows the virtual try-on image in the container\r\n\t * @private\r\n\t */\r\n\tprivate showVirtualTryOnImage(container: HTMLElement): void {\r\n\t\tif (!this.virtualTryOnImageUrl) {\r\n\t\t\tconsole.warn(\"[WeWear VTO] No virtual try-on image URL available\");\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Remove all direct children except for the button container\r\n\t\tArray.from(container.children).forEach((child) => {\r\n\t\t\tif (!child.classList.contains(CSS_CLASSES.BUTTON_CONTAINER)) {\r\n\t\t\t\tchild.remove();\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\t// Get stored original dimensions to prevent layout shift\r\n\t\tconst originalWidth =\r\n\t\t\tcontainer.getAttribute(\"data-ww-original-width\") || \"\";\r\n\t\tconst originalHeight =\r\n\t\t\tcontainer.getAttribute(\"data-ww-original-height\") || \"\";\r\n\t\tconst originalRectWidth =\r\n\t\t\tcontainer.getAttribute(\"data-ww-original-rect-width\") || \"\";\r\n\t\tconst originalRectHeight =\r\n\t\t\tcontainer.getAttribute(\"data-ww-original-rect-height\") || \"\";\r\n\r\n\t\tconst image = document.createElement(\"img\");\r\n\t\timage.src = this.virtualTryOnImageUrl;\r\n\t\timage.alt = \"Virtual Try-On Result\";\r\n\r\n\t\t// Use original dimensions to prevent layout shift\r\n\t\tlet widthStyle = \"100%\";\r\n\t\tlet heightStyle = \"100%\";\r\n\r\n\t\t// Prefer computed style dimensions, fallback to bounding rect, then container fill\r\n\t\tif (originalWidth && originalWidth !== \"auto\" && originalWidth !== \"0px\") {\r\n\t\t\twidthStyle = originalWidth;\r\n\t\t} else if (originalRectWidth && originalRectWidth !== \"0\") {\r\n\t\t\twidthStyle = `${originalRectWidth}px`;\r\n\t\t}\r\n\r\n\t\tif (\r\n\t\t\toriginalHeight &&\r\n\t\t\toriginalHeight !== \"auto\" &&\r\n\t\t\toriginalHeight !== \"0px\"\r\n\t\t) {\r\n\t\t\theightStyle = originalHeight;\r\n\t\t} else if (originalRectHeight && originalRectHeight !== \"0\") {\r\n\t\t\theightStyle = `${originalRectHeight}px`;\r\n\t\t}\r\n\r\n\t\timage.style.cssText = `\r\n width: ${widthStyle};\r\n height: ${heightStyle};\r\n object-fit: contain;\r\n `;\r\n\r\n\t\t// Prepend the image to ensure buttons are rendered on top\r\n\t\tcontainer.prepend(image);\r\n\r\n\t\tthis.isShowingVirtualTryOn = true;\r\n\t}\r\n\r\n\t/**\r\n\t * Shows the original product image in the container\r\n\t * @private\r\n\t */\r\n\tprivate showOriginalImage(container: HTMLElement): void {\r\n\t\tconst originalContentHTML = container.getAttribute(\r\n\t\t\t\"data-ww-original-content\",\r\n\t\t);\r\n\t\tif (originalContentHTML) {\r\n\t\t\t// Remove all direct children except for the button container\r\n\t\t\tArray.from(container.children).forEach((child) => {\r\n\t\t\t\tif (!child.classList.contains(CSS_CLASSES.BUTTON_CONTAINER)) {\r\n\t\t\t\t\tchild.remove();\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n\t\t\t// Parse the original content and prepend it\r\n\t\t\tconst tempDiv = document.createElement(\"div\");\r\n\t\t\ttempDiv.innerHTML = originalContentHTML;\r\n\t\t\tcontainer.prepend(...Array.from(tempDiv.children));\r\n\t\t}\r\n\r\n\t\tthis.isShowingVirtualTryOn = false;\r\n\t}\r\n\r\n\t/**\r\n\t * Destroys the widget and cleans up resources\r\n\t */\r\n\tpublic destroy(): void {\r\n\t\ttry {\r\n\t\t\t// Remove all buttons\r\n\t\t\tremoveElements(`.${CSS_CLASSES.BUTTON_CONTAINER}`);\r\n\r\n\t\t\t// Remove all modals\r\n\t\t\tremoveElements(`.${CSS_CLASSES.MODAL}`);\r\n\r\n\t\t\t// Clear references\r\n\t\t\tthis.cameraButton = null;\r\n\r\n\t\t\t// Remove message listener\r\n\t\t\tif (this.iframeMessageListener) {\r\n\t\t\t\twindow.removeEventListener(\"message\", this.iframeMessageListener);\r\n\t\t\t\tthis.iframeMessageListener = null;\r\n\t\t\t}\r\n\r\n\t\t\t// Reset state\r\n\t\t\tthis.virtualTryOnImageUrl = null;\r\n\t\t\tthis.isShowingVirtualTryOn = false;\r\n\t\t\tthis.lastModelImage = null;\r\n\t\t\tthis.originalProductImageUrl = null;\r\n\t\t\tthis.originalProductImages = [];\r\n\t\t\tif (this.previewBadge) {\r\n\t\t\t\tthis.previewBadge.remove();\r\n\t\t\t\tthis.previewBadge = null;\r\n\t\t\t}\r\n\r\n\t\t\tconsole.log(\"[WeWear VTO] Widget destroyed successfully\");\r\n\t\t} catch (error) {\r\n\t\t\tconsole.error(\"[WeWear VTO] Error during widget destruction:\", error);\r\n\t\t}\r\n\t}\r\n}\r\n","import type { VirtualTryOnConfig } from \"./index.js\";\nimport { VirtualTryOnWidget } from \"./widget.js\";\n\nlet widgetInstance: VirtualTryOnWidget | null = null;\n\nexport function initVirtualTryOn(config?: VirtualTryOnConfig): void {\n\ttry {\n\t\t// Clean up any existing instance\n\t\tif (widgetInstance) {\n\t\t\twidgetInstance.destroy();\n\t\t\twidgetInstance = null;\n\t\t}\n\n\t\t// Early return if config is missing\n\t\tif (!config) {\n\t\t\tconsole.log(\n\t\t\t\t\"[WeWear VTO] Missing configuration. Widget not initialized.\",\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\t// Create and initialize new instance\n\t\twidgetInstance = new VirtualTryOnWidget(config);\n\n\t\t// Initialize immediately if DOM is ready, otherwise wait for it\n\t\tif (document.readyState === \"loading\") {\n\t\t\tdocument.addEventListener(\"DOMContentLoaded\", () => {\n\t\t\t\twidgetInstance?.init().catch((error) => {\n\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\"[WeWear VTO] Failed to initialize after DOM ready:\",\n\t\t\t\t\t\terror,\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t\t});\n\t\t} else {\n\t\t\twidgetInstance.init().catch((error) => {\n\t\t\t\tconsole.error(\"[WeWear VTO] Failed to initialize:\", error);\n\t\t\t});\n\t\t}\n\t} catch (error) {\n\t\tconsole.error(\"[WeWear VTO] Initialization error:\", error);\n\t}\n}\n\nexport function getWidgetInstance(): VirtualTryOnWidget | null {\n\treturn widgetInstance;\n}\n\nif (typeof window !== \"undefined\") {\n\tinitVirtualTryOn();\n}\n"],"names":[],"mappings":";;;;;;IAAA;IACO,MAAM,WAAW,GAAG;IAC1B,IAAA,gBAAgB,EAAE,6BAA6B;IAC/C,IAAA,MAAM,EAAE,mBAAmB;IAC3B,IAAA,KAAK,EAAE,kBAAkB;IACzB,IAAA,aAAa,EAAE,sBAAsB;KAC5B;IAEV;IACO,MAAM,OAAO,GAAG;IACtB,IAAA,MAAM,EAAE,EAAE;IACV,IAAA,KAAK,EAAE,KAAK;KACH;;aCVM,kBAAkB,GAAA;QACjC,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC;IAC3C,IAAA,KAAK,CAAC,SAAS,GAAG,WAAW,CAAC,aAAa;IAC3C,IAAA,KAAK,CAAC,SAAS,GAAG,SAAS;QAE3B,MAAM,OAAO,GAAG,qBAAqB;QACrC,IAAI,CAA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,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,KAAK,CAAC;IAC3D,YAAA,CAAC,CAAC;YACH;QACD;QAAE,OAAO,KAAK,EAAE;IACf,QAAA,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,KAAK,CAAC;QAC3D;IACD;aAEgB,iBAAiB,GAAA;IAChC,IAAA,OAAO,cAAc;IACtB;IAEA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;IAClC,IAAA,gBAAgB,EAAE;IACnB;;;;;;;;;;"}
|
package/dist/widget.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export declare class VirtualTryOnWidget {
|
|
|
3
3
|
private readonly config;
|
|
4
4
|
private virtualTryOnImageUrl;
|
|
5
5
|
private originalProductImageUrl;
|
|
6
|
+
private originalProductImages;
|
|
6
7
|
private isShowingVirtualTryOn;
|
|
7
8
|
private lastModelImage;
|
|
8
9
|
private cameraButton;
|
|
@@ -19,6 +20,12 @@ export declare class VirtualTryOnWidget {
|
|
|
19
20
|
* @private
|
|
20
21
|
*/
|
|
21
22
|
private handleTryOnClick;
|
|
23
|
+
/**
|
|
24
|
+
* Gets all product images from the gallery
|
|
25
|
+
* @private
|
|
26
|
+
* @returns Array of product image URLs
|
|
27
|
+
*/
|
|
28
|
+
private getAllProductImages;
|
|
22
29
|
/**
|
|
23
30
|
* Shows a modal with an iframe for the photo upload page
|
|
24
31
|
* @private
|