Point your camera at the QR code. Tap the banner that appears on your screen.",qrcodeJs="https://api.bear2b.com/media/161657956263da7db022a808.88828251.js";let selectedMaterial,selectedVariant,availableTexturesPerMaterial=[];class ModalManager{constructor(){this._m_build()}addScript(e,t){return new Promise(((i,n)=>{const a=document.createElement("script");t&&a.setAttribute("type",t),a.onload=()=>{i()},a.onerror=e=>{console.error(e),n()},document.head.appendChild(a),a.src=e}))}_m_build(){this.uriToShare=window.location.href,this.modalBackground=document.createElement("div"),document.body.appendChild(this.modalBackground),this.modalBackground.setAttribute("id","modalBackground"),this.modalBackground.setAttribute("style","pointer-events:none;width:100%;height:100%;display:none;position:fixed;top:0;left:0;flex-direction:column;align-content:center;align-items:center;justify-content:center;text-align:center;z-index:2;");const e=document.createElement("div");this.modalBackground.appendChild(e),e.setAttribute("id","modalContainer"),e.setAttribute("style","width:23rem;min-height:100px;border-radius:0.4rem;background-color:white;box-shadow:0 0 20px rgba(0,0,0, .15);cursor:initial;z-index:56!important;padding:20px;");const t=document.createElement("h2");e.appendChild(t),t.setAttribute("id","modalTitle"),t.setAttribute("style","font-weight: bold;");const i=document.createElement("div");e.appendChild(i),i.setAttribute("id","modalContent"),i.setAttribute("style","display:flex;flex-direction:column;align-items: center;");const n=document.createElement("div");n.addEventListener("click",this._m_hide.bind(this)),e.appendChild(n),n.setAttribute("id","closeBtn"),n.setAttribute("style","color:white;width:100%;background-color:#000C37;pointer-events:all;"),n.innerHTML="Close"}_m_setContent(e,t){document.getElementById("modalTitle").innerHTML=e,document.getElementById("modalContent").innerHTML=t}_m_show(){this._m_showHide(!0)}_m_hide(){this._m_showHide(!1)}_m_showShare4Mobile(){this.sharemgt=document.createElement("div"),document.body.appendChild(this.sharemgt),this.sharemgt.classList.add("icon"),this.sharemgt.setAttribute("id","sharemgt"),this.sharemgt.setAttribute("style","position: fixed; top: 10px;right: 10px;width: 44px;height: 44px;float: right;background-image: url('./ar.svg');"),this.sharemgt.addEventListener("click",(()=>{this._m_setContent(shareTitle,shareContent),this.setQRCodeImage(document.getElementById("qrCode"),this.uriToShare),this._m_show()}))}_m_showHide(e){this.modalBackground.style.display=e?"flex":"none",this.sharemgt&&(this.sharemgt.style.display=e?"none":"block")}setQRCodeImage(e,t){this.addScript(qrcodeJs).then((()=>{document.createElement("qrcode");new QRCode(e,{text:t,width:128,height:128,colorDark:"#000000",colorLight:"#ffffff",correctLevel:QRCode.CorrectLevel.H})}))}}class MaterialUtils{static resetSelects(){const e=document.querySelectorAll("select");M.FormSelect.init(e)}static resetTabs(){const e=document.querySelectorAll(".tabs");M.Tabs.init(e,{});MaterialUtils.tabInstance=M.Tabs.getInstance(e[0]),document.getElementById(uiIds.none).style.width="0",document.getElementById(uiIds.other).style.width="0",MaterialUtils.selectTab(uiIds.none),document.getElementById(uiIds.leftUiId).style.opacity="1"}static selectTab(e){MaterialUtils.tabInstance.select(uiIds.getTabIdFromShort(e))}}class UIManager{constructor(){this.camSelectRow=document.getElementById("camerasRow"),this.camSelect=document.getElementById("cameras"),this.textureSelectRow=document.getElementById("texturesRow"),this.textureSelect=document.getElementById("textures")}showHideUIPanel(e){const t=document.getElementById("ui"),i=e?"showLeft":"hideLeft",n=e?"hideLeft":"showLeft";t.classList.remove(n),t.classList.add(i)}initCamList(e){this.camSelectRow.style.display=e.length?"block":"none",this.camSelect.innerHTML="",e.forEach((e=>{const t=document.createElement("button");this.camSelect.appendChild(t),t.style.backgroundImage="url("+e.icon+")",t.className="buttonWithImage",t.addEventListener("click",(()=>{sendUpdate({type:"camera",cameraOrbit:e.orbit})}))}))}createOptionAndMaterialListContainer(e,t,i,n){const a=t,s=document.createElement("li");s.id=e,this.materialTabs.appendChild(s),s.className=i;const o=document.createElement("a");s.appendChild(o);const r=uiIds.getTabIdFromShort(a);o.href="#"+r,o.innerHTML=t;const d=document.createElement("div");if(d.setAttribute("id",r),d.className="col s12",n.length){const e=document.createElement("p");e.setAttribute("id",a+"_text"),d.appendChild(e),e.style.width="100%",e.innerHTML=n}const l=document.createElement("div");return l.setAttribute("id",a+"_list"),d.appendChild(l),d.style.backgroundColor="white",l.className="textureDiv",d}initOptionTabs(e){function t(e,t){const i=document.getElementById(e+"_list");i.innerHTML="";const n=availableTexturesPerMaterial.find((e=>e.name==t));e!=uiIds.none?n?n.textures.forEach((e=>{const n=document.createElement("button");i.appendChild(n),n.style.backgroundImage="url("+(e.mini||e.baseColorTexture)+")",n.className="buttonWithImage rounded",n.addEventListener("click",(()=>{sendUpdate({materialname:t,textures:e})}))})):i.innerHTML=texts.noOptionForMat:i.innerHTML=texts.noMatSelected}this.materialTabs=document.getElementById("materialTabs"),this.materialLists=document.getElementById("materialLists");const i=Math.floor(12/e.length),n="tab col s"+i+" l"+i+" m"+i;e.forEach((e=>{const i=this.createOptionAndMaterialListContainer(e.name,e.short,n,"Sélectionnez un matériaux");this.materialLists.appendChild(i),t(e.short,e.name)}));const a=this.createOptionAndMaterialListContainer(uiIds.other,uiIds.other,n,"");this.materialLists.appendChild(a),t(uiIds.other,"");const s=this.createOptionAndMaterialListContainer(uiIds.none,uiIds.none,n,"");materialLists.appendChild(s),t(uiIds.none,""),MaterialUtils.resetTabs()}}const uiManager=new UIManager,modalManager=new ModalManager;function sendUpdate(e){modelViewer.contentWindow.postMessage(e,"*")}"ontouchstart"in document.documentElement||modalManager._m_showShare4Mobile(),MaterialUtils.resetSelects(),window.addEventListener("message",(e=>{const t=e.data;if("model"==t.type)uiManager.initCamList(t.cameras),availableTexturesPerMaterial=t.options,uiManager.initOptionTabs(availableTexturesPerMaterial),uiManager.showHideUIPanel(!0);else if("material"==t.type){selectedMaterial=t.name;const e=availableTexturesPerMaterial.find((e=>e.name==selectedMaterial));e?MaterialUtils.selectTab(e.short):MaterialUtils.selectTab(uiIds.other)}}))