!function(){"use strict";const e=function(){const e=document.body.className;let t=e.match(/postid-(\d+)/);return t?parseInt(t[1],10):(t=e.match(/page-id-(\d+)/),t?parseInt(t[1],10):null)}();if(!e)return void console.error("[STW Block] Unable to detect post ID");console.log(`[STW Block] Detected post ID: ${e}`);const t=function(){const e=document.body.className||"";if(/\b(single-product|post-type-product|post_type_product)\b/.test(e))return!0;if(e.includes("single")&&e.includes("product"))return!0;try{if(document.querySelector(".product")&&/postid-\d+/.test(e))return!0;if(document.querySelector('[itemtype*="Product"]'))return!0}catch(e){}return!1}(),o=t?`/index.php?rest_route=/3d-scan-and-show/v1/iframe-url&product_id=${e}`:`/index.php?rest_route=/3d-scan-and-show/v1/page-iframe-url&page_id=${e}`;console.log("[STW Block] Page type: "+(t?"Product":"Page")),fetch(o).then(e=>e.json()).then(e=>{const t=document.querySelectorAll(".stw-embed-block");if(!e.success||!e.iframe_url)return console.log("[STW Block] No iframe URL found - page/product not linked to STW item"),void t.forEach(e=>{Array.from(e.attributes).map(e=>e.name).forEach(t=>e.removeAttribute(t)),e.innerHTML=""});t.forEach(t=>{const o=t.getAttribute("data-aspect-ratio")||"auto",r=document.createElement("iframe");r.src=e.iframe_url,r.frameBorder="0",r.allowFullscreen=!0,r.title="Scan the World 3D Model",r.style.border="none",r.style.borderRadius="4px","auto"===o?(r.style.position="absolute",r.style.top="0",r.style.left="0",r.style.width="100%",r.style.height="100%"):(r.style.width="100%",r.style.aspectRatio=o),t.appendChild(r)})}).catch(e=>{console.error("[STW Block] Error loading iframe:",e),document.querySelectorAll(".stw-embed-block").forEach(e=>{Array.from(e.attributes).map(e=>e.name).forEach(t=>e.removeAttribute(t)),e.innerHTML=""})})}();