"use strict";var loadedtdel=!1;const onGSModelInteraction=()=>{if(!0===loadedtdel||(loadedtdel=!0,null!==document.getElementById("gsmodelviewerscript")))return;let e=document.createElement("script");e.type="module",e.id="gsmodelviewerscript",e.src=gspb_model_params.pluginURL+"libs/modelviewer/model-viewer.min.js",document.body.appendChild(e)},onGSModelProgress=e=>{let t=e.target.querySelector(".progress-bar"),o=e.target.querySelector(".update-bar");o.style.width=`${100*e.detail.totalProgress}%`,1==e.detail.totalProgress&&t.classList.add("hide")};document.body.addEventListener("mouseover",onGSModelInteraction,{once:!0}),document.body.addEventListener("touchmove",onGSModelInteraction,{once:!0}),window.addEventListener("scroll",onGSModelInteraction,{once:!0}),document.body.addEventListener("keydown",onGSModelInteraction,{once:!0});var requestIdleCallback=window.requestIdleCallback||function(e){let t=Date.now();return setTimeout(function(){e({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(Date.now()-t))}})},1)},gsmodel=document.getElementsByClassName("gspb_modelBox");for(let i=0;i<gsmodel.length;i++){let e=gsmodel[i];(()=>{let t=e.querySelector(".gsmodelviewer");t.addEventListener("progress",onGSModelProgress),performance.now();let o=t.getAttribute("data-rx"),n=t.getAttribute("data-ry"),r=t.getAttribute("data-rz"),d=t.getAttribute("data-scale"),a=t.getAttribute("data-camera"),l=t.getAttribute("data-variants"),s=t.getAttribute("data-mousemove"),c=t.getAttribute("data-loaditer");d&&(d=parseFloat(d)),c||requestIdleCallback(function(){onGSModelInteraction()},{timeout:2500});let u=0,$=0,g=window.innerWidth/2,m=window.innerHeight/2;if(document.addEventListener("mousemove",function(e){u=e.clientX-g,$=e.clientY-m}),d&&(t.scale=`${d} ${d} ${d}`),l){let v=e.querySelector(".gsvariantselect");t.addEventListener("load",()=>{let e=t.availableVariants;if(void 0!==e&&e.length>0)for(let o of(v.classList.remove("rhhidden"),e)){let n=document.createElement("option");n.value=o,n.textContent=o,v.appendChild(n)}}),v.addEventListener("input",e=>{t.variantName=e.target.value})}if(o||n||r||s){let b=e=>{if(requestAnimationFrame(b),void 0!==t.orientation){let d=t.orientation.split(" ");void 0===o&&(o=0),void 0===n&&(n=0),void 0===r&&(r=0);let l=parseFloat(d[0])+o/50,c=parseFloat(d[1])+n/50,g=parseFloat(d[2])+r/50;s&&(g+=.05*(u*s/1e3-g),c+=.05*($*s/1e3-c)),t.orientation=`${l}deg ${c}deg ${g}deg`,a||t.updateFraming()}};b()}})()}