1if(!customElements.get("side-panel-links")){class ProductSidePanelLinks extends HTMLElement{constructor(){super(),this.links=document.querySelectorAll(".side-panel-links--link"),this.drawer=document.getElementById("Product-Information-Drawer"),this.loftDrawer=document.getElementById("Product-Availability-Drawer"),this.stockContainer=document.getElementById("loft-stock"),this.panels=this.drawer.querySelectorAll(".side-panel-content--tab-panel"),this.body=document.body}connectedCallback(){console.log("\u2705 ProductSidePanelLinks est instanci\xE9 !"),this.setupObservers(),this.preloadStockData()}preloadStockData(){console.log("\u{1F680} Pr\xE9chargement du stock en arri\xE8re-plan..."),this.fetchStockData()}setupObservers(){this.links.forEach((item,i)=>{item.addEventListener("click",async e=>{if(e.preventDefault(),console.log("\u{1F6D1} Bouton cliqu\xE9 :",item),item.classList.contains("availability-button")){console.log("\u{1F3EC} Affichage du panneau 'Disponibilit\xE9 au Loft'"),this.drawer.classList.remove("active"),this.body.classList.add("open-cc"),this.loftDrawer.classList.add("active"),console.log("\u{1F4E1} Appel API pour r\xE9cup\xE9rer le stock..."),await this.fetchStockData();return}this.body.classList.add("open-cc"),this.drawer.classList.add("active");const targetId=item.getAttribute("data-target");if(targetId){console.log("\u{1F50D} Ouverture via data-target :",targetId),this.panels.forEach(panel=>panel.classList.remove("tab-active"));const targetPanel=document.getElementById(targetId);targetPanel?(console.log("\u2705 Panneau trouv\xE9 :",targetPanel),targetPanel.classList.add("tab-active")):console.log("\u274C Panneau non trouv\xE9 !")}else console.log("\u{1F504} Ouverture via l\u2019index :",i),this.panels.forEach(panel=>panel.classList.remove("tab-active")),this.panels[i]&&this.panels[i].classList.add("tab-active")})})}async fetchStockData(){const productElement=document.querySelector("[data-product-id]");if(!productElement){console.warn("\u26A0\uFE0F \xC9l\xE9ment data-product-id non trouv\xE9.");return}const productId=productElement.getAttribute("data-product-id");if(!productId){console.warn("\u26A0\uFE0F Aucun ID produit trouv\xE9.");return}console.log("\u{1F194} ID du produit d\xE9tect\xE9 :",productId);try{const response=await fetch(`https://bylouise.fly.dev/api/stock/${productId}`);if(!response.ok)throw new Error(`Erreur API Stock: ${response.status}`);const stockData=await response.json();if(console.log("\u{1F4E6} R\xE9ponse API Stock :",stockData),!stockData||!Array.isArray(stockData.stock)){console.error("\u274C Erreur: API ne retourne pas un tableau valide !",stockData),this.stockContainer.innerHTML="<p>Erreur de r\xE9cup\xE9ration du stock</p>";return}this.displayStock(stockData.stock)}catch(error){console.error("\u274C Erreur lors de la r\xE9cup\xE9ration des stocks:",error),this.stockContainer.innerHTML="<p>Impossible de r\xE9cup\xE9rer les stocks</p>"}}displayStock(stockArray){if(!this.stockContainer){console.warn("\u26A0\uFE0F Conteneur stock non trouv\xE9.");return}const loftDescription=document.querySelector(".loft-description"),hasStock=stockArray.some(item=>item.stock>0);
1loftDescription&&(loftDescription.textContent=hasStock?"Voici les tailles disponibles pour cette pi\xE8ce au Loft.":"Aucune taille disponible actuellement pour cette pi\xE8ce.");let stockHTML='<div class="loft-stock-container">';stockArray.forEach(item=>{const stockClass=item.stock>0?"size-available":"size-unavailable";stockHTML+=`<span class="${stockClass}">${item.title}</span>`}),stockHTML+="</div>",this.stockContainer.innerHTML=stockHTML}}customElements.define("side-panel-links",ProductSidePanelLinks)} 2//# sourceMappingURL=/cdn/shop/t/258/assets/side-panel-links.js.map?v=116002355379596387791787854073
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.