PageSourceSearch

https://kzmusicstore.com.br/cdn/shop/t/31/assets/comparador-br.js?v=22153301092738092891781302157

js kzmusicstore.com.br collected 2026-10-08 05:02:01 UTC 29,553 bytes, 2 lines download raw bytes

1var COMPARADOR_BASE=window.KZ_BACKENDS&&window.KZ_BACKENDS.comparador||"https://comparador-backend.vercel.app";document.addEventListener("DOMContentLoaded",function(){var modal=document.getElementById("modalComparador"),fecharBtn=document.getElementById("fecharModal"),steps=document.querySelectorAll(".step"),stepContents=document.querySelectorAll(".step-content"),currentStep=1,produtoA=document.getElementById("produtoA"),produtoB=document.getElementById("produtoB"),pesquisaA=document.getElementById("pesquisaA"),pesquisaB=document.getElementById("pesquisaB"),previewA=document.getElementById("previewA"),previewB=document.getElementById("previewB"),bodyDropdownA=document.getElementById("bodyDropdownA"),bodyDropdownB=document.getElementById("bodyDropdownB"),avancarStep1=document.getElementById("avancar-step-1"),voltarStep2=document.getElementById("voltar-step-2"),avancarStep2=document.getElementById("avancar-step-2"),voltarStep3=document.getElementById("voltar-step-3"),novaComparacao=document.getElementById("nova-comparacao"),comparadorConfig=readComparatorConfig(),sectionId=comparadorConfig.sectionId||"comparador-products-data",collectionHandles=comparadorConfig.collections||["fones-kz","fones-qkz","fones-cca","fones-bluetooth-kz","adaptadores-bluetooth","gamer"],currentProductData=comparadorConfig.currentProduct||null,allOptions=Array.from(produtoA.options),productById={},collectionStates={},collectionPromises={},selectedCategory="",debounceTimer=null,fetchController=null,lastFocusedBeforeOpen=null,loadingProductsText="Carregando produtos...";function readComparatorConfig(){var configEl=document.getElementById("comparador-config-data");if(!configEl)return{};try{return JSON.parse(configEl.textContent)||{}}catch(err){return{}}}function getShopifyRoot(){var root="/";return window.Shopify&&window.Shopify.routes&&window.Shopify.routes.root&&(root=window.Shopify.routes.root),root.charAt(root.length-1)==="/"?root:root+"/"}function normalizeProduct(rawProduct,collectionHandle){if(!rawProduct||rawProduct.id==null)return null;var handle=rawProduct.handle||"",productUrl=rawProduct.url||(handle?getShopifyRoot()+"products/"+handle:"#");return{id:String(rawProduct.id),title:rawProduct.title||"",handle:handle,description:rawProduct.description||"",image:rawProduct.image||rawProduct.featured_image||"",price:rawProduct.price||"",url:productUrl,category:rawProduct.category||rawProduct.collection||collectionHandle||""}}function findOption(selectEl,productId){if(!selectEl)return null;for(var i=0;i<selectEl.options.length;i++)if(selectEl.options[i].value===String(productId))return selectEl.options[i];return null}function setOptionData(option,product){option.value=product.id,option.textContent=product.title,option.setAttribute("data-description",product.description||""),option.setAttribute("data-image",product.image||""),option.setAttribute("data-price",product.price||""),option.setAttribute("data-product-url",product.url||"#"),option.setAttribute("data-category",product.category||""),option.setAttribute("data-handle",product.handle||"")}function syncProductOption(selectEl,product){if(!(!selectEl||!product||!product.id)){var option=findOption(selectEl,product.id);option||(option=document.createElement("option"),selectEl.appendChild(option)),setOptionData(option,product)}}function upsertProduct(product){if(!product||!product.id)return null;var existing=productById[product.id];return existing?(!existing.description&&product.description&&(existing.description=product.description),!existing.image&&product.image&&(existing.image=product.image),!existing.price&&product.price&&(existing.price=product.price),!existing.url&&product.url&&(existing.url=product.url),!existing.handle&&product.handle&&(existing.handle=product.handle),!existing.category&&product.category&&(existing.category=product.category),product=existing):productById[product.id]=product,syncProductOption(produtoA,product),syncProductOption(produtoB,product),allOptions=Array.from(produtoA.options),product}function getProductsForCollection(collectionHandle){var products=[];
1return Object.keys(productById).forEach(function(productId){var product=productById[productId];product.category===collectionHandle&&products.push(product)}),products}function getCollectionCacheKey(collectionHandle){return["kzComparadorProducts","v1",getShopifyRoot(),sectionId,collectionHandle].join(":")}function readCachedCollection(collectionHandle){try{var raw=window.sessionStorage&&sessionStorage.getItem(getCollectionCacheKey(collectionHandle));if(!raw)return null;var payload=JSON.parse(raw);return!payload||!Array.isArray(payload.products)?null:payload.products}catch(err){return null}}function writeCachedCollection(collectionHandle,products){try{if(!window.sessionStorage)return;sessionStorage.setItem(getCollectionCacheKey(collectionHandle),JSON.stringify({products:products||[]}))}catch(err){}}function parseCollectionPayload(html){var doc=new DOMParser().parseFromString(html,"text/html"),dataEl=doc.querySelector("[data-comparador-products-json]");if(!dataEl)throw new Error("Comparator product payload not found.");return JSON.parse(dataEl.textContent)}function fetchCollectionPage(collectionHandle,page){var url=getShopifyRoot()+"collections/"+encodeURIComponent(collectionHandle)+"?section_id="+encodeURIComponent(sectionId)+"&page="+encodeURIComponent(page);return fetch(url,{credentials:"same-origin"}).then(function(response){if(!response.ok)throw new Error("HTTP "+response.status);return response.text()}).then(parseCollectionPayload)}function loadCollection(collectionHandle){if(!collectionHandle)return Promise.resolve([]);if(collectionStates[collectionHandle]==="loaded")return Promise.resolve(getProductsForCollection(collectionHandle));if(collectionPromises[collectionHandle])return collectionPromises[collectionHandle];var cachedProducts=readCachedCollection(collectionHandle);return cachedProducts?(cachedProducts.forEach(function(product){upsertProduct(normalizeProduct(product,collectionHandle))}),collectionStates[collectionHandle]="loaded",Promise.resolve(cachedProducts)):(collectionStates[collectionHandle]="loading",collectionPromises[collectionHandle]=fetchCollectionPage(collectionHandle,1).then(function(firstPayload){for(var products=firstPayload.products||[],pages=parseInt(firstPayload.pages,10)||1,pageFetches=[],page=2;page<=pages;page++)pageFetches.push(fetchCollectionPage(collectionHandle,page));return Promise.all(pageFetches).then(function(payloads){return payloads.forEach(function(payload){products=products.concat(payload.products||[])}),products.forEach(function(product){upsertProduct(normalizeProduct(product,collectionHandle))}),collectionStates[collectionHandle]="loaded",writeCachedCollection(collectionHandle,products),products})}).catch(function(err){throw collectionStates[collectionHandle]="error",err}),collectionPromises[collectionHandle])}function getCollectionsForInput(input){return input===pesquisaB&&selectedCategory?[selectedCategory]:collectionHandles}function areCollectionsSettled(handles){for(var i=0;i<handles.length;i++)if(collectionStates[handles[i]]!=="loaded"&&collectionStates[handles[i]]!=="error")return!1;return!0}function ensureCollectionsLoaded(handles){return Promise.all(handles.map(function(collectionHandle){return loadCollection(collectionHandle).catch(function(){return null})}))}
1function renderSuggestionMessage(input,dropdownContainer,message){for(;dropdownContainer.firstChild;)dropdownContainer.removeChild(dropdownContainer.firstChild);var dropdown=document.createElement("div");dropdown.className="suggestions-dropdown";var item=document.createElement("div");item.className="suggestion-item",item.setAttribute("role","option"),item.setAttribute("aria-selected","false"),item.textContent=message,dropdown.appendChild(item),dropdownContainer.appendChild(dropdown),positionDropdown(input,dropdownContainer),dropdownContainer.style.display="block",input.setAttribute("aria-expanded","true")}function seedCurrentProduct(){var product=normalizeProduct(currentProductData,currentProductData&&currentProductData.category);if(!(!product||!product.category)){upsertProduct(product),produtoA.value=product.id,pesquisaA.value=product.title,selectedCategory=product.category;var changeEvent=new Event("change");produtoA.dispatchEvent(changeEvent),setButtonEnabled(avancarStep1,produtoA.value)}}function loadInitialCatalog(){selectedCategory&&ensureCollectionsLoaded([selectedCategory]),ensureCollectionsLoaded(collectionHandles)}function stripHtml(html){if(!html)return"";var div=document.createElement("div");return div.innerHTML=html,(div.textContent||div.innerText||"").trim()}function fetchProductDescription(option,signal){var currentDescription=option.getAttribute("data-description");if(currentDescription)return Promise.resolve(currentDescription);var handle=option.getAttribute("data-handle");if(!handle)return Promise.resolve("");var url=getShopifyRoot()+"products/"+encodeURIComponent(handle)+".js";return fetch(url,{credentials:"same-origin",signal:signal}).then(function(response){if(!response.ok)throw new Error("HTTP "+response.status);return response.json()}).then(function(product){var description=stripHtml(product.description||product.body_html||"");option.setAttribute("data-description",description);var productId=option.value;return productById[productId]&&(productById[productId].description=description),description})}function hideOnImageError(img){img&&(img.addEventListener("error",function(){this.style.visibility="hidden"}),img.addEventListener("load",function(){this.style.visibility=""}))}["imgA","imgB","summaryImgA","summaryImgB"].forEach(function(id){hideOnImageError(document.getElementById(id))});function setButtonEnabled(button,value){button.disabled=!value}var touchStartY=0;function getScrollable(target){var node=target.closest(".modal-corpo");return!node||node.scrollHeight<=node.clientHeight?null:node}
1function canScroll(node,deltaY){return node?deltaY<0?node.scrollTop>0:deltaY>0?node.scrollTop+node.clientHeight<node.scrollHeight-1:!0:!1}modal.addEventListener("wheel",function(event){modal.classList.contains("aberto")&&(canScroll(getScrollable(event.target),event.deltaY)||event.preventDefault())},{passive:!1}),modal.addEventListener("touchstart",function(event){event.touches&&event.touches.length&&(touchStartY=event.touches[0].clientY)},{passive:!0}),modal.addEventListener("touchmove",function(event){if(!(!modal.classList.contains("aberto")||!event.touches||!event.touches.length)){var deltaY=touchStartY-event.touches[0].clientY;canScroll(getScrollable(event.target),deltaY)||event.preventDefault()}},{passive:!1});function lockScroll(){document.body.classList.contains("modal-aberto")||(document.documentElement.classList.add("modal-aberto"),document.body.classList.add("modal-aberto"))}function unlockScroll(){document.body.classList.contains("modal-aberto")&&(document.documentElement.classList.remove("modal-aberto"),document.body.classList.remove("modal-aberto"))}function fecharModal(){if(modal.classList.remove("aberto"),unlockScroll(),bodyDropdownA.style.display="none",bodyDropdownB.style.display="none",pesquisaA.setAttribute("aria-expanded","false"),pesquisaB.setAttribute("aria-expanded","false"),pesquisaA.removeAttribute("aria-activedescendant"),pesquisaB.removeAttribute("aria-activedescendant"),fetchController&&(fetchController.abort(),fetchController=null),resetForm(),lastFocusedBeforeOpen&&typeof lastFocusedBeforeOpen.focus=="function")try{lastFocusedBeforeOpen.focus()}catch(e){}lastFocusedBeforeOpen=null}function goToStep(step){currentStep=step,steps.forEach(function(stepEl){var stepNum=parseInt(stepEl.dataset.step,10);stepEl.classList.remove("active","completed"),stepEl.removeAttribute("aria-current"),stepNum===currentStep?(stepEl.classList.add("active"),stepEl.setAttribute("aria-current","step")):stepNum<currentStep&&stepEl.classList.add("completed")}),document.querySelectorAll(".step-line").forEach(function(line,index){line.classList.toggle("completed",index<currentStep-1)}),stepContents.forEach(function(content){content.style.display="none"}),document.getElementById("step-"+currentStep).style.display="block",bodyDropdownA.style.display="none",bodyDropdownB.style.display="none",pesquisaA.setAttribute("aria-expanded","false"),pesquisaB.setAttribute("aria-expanded","false"),pesquisaA.removeAttribute("aria-activedescendant"),pesquisaB.removeAttribute("aria-activedescendant")}function resetForm(){produtoA.value="",produtoB.value="",pesquisaA.value="",pesquisaB.value="",previewA.style.display="none",previewB.style.display="none",document.getElementById("resultado").textContent="",avancarStep1.disabled=!0,avancarStep2.disabled=!0,bodyDropdownA.style.display="none",bodyDropdownB.style.display="none",pesquisaA.setAttribute("aria-expanded","false"),pesquisaB.setAttribute("aria-expanded","false"),pesquisaA.removeAttribute("aria-activedescendant"),pesquisaB.removeAttribute("aria-activedescendant"),selectedCategory=""}function positionDropdown(input,dropdown){var rect=input.getBoundingClientRect();dropdown.style.top=rect.bottom+"px",dropdown.style.left=rect.left+"px",dropdown.style.width=rect.width+"px";var availableHeight=window.innerHeight-rect.bottom-20;dropdown.style.maxHeight=Math.max(availableHeight,120)+"px",dropdown.style.overflowY="auto"}function hideDropdown(input,dropdownContainer){dropdownContainer.style.display="none",input.setAttribute("aria-expanded","false"),input.removeAttribute("aria-activedescendant")}function showSuggestions(input,dropdownContainer,excludeValue){var query=input.value.toLowerCase(),neededCollections=getCollectionsForInput(input);if(!areCollectionsSettled(neededCollections)){renderSuggestionMessage(input,dropdownContainer,loadingProductsText),ensureCollectionsLoaded(neededCollections).then(function(){showSuggestions(input,dropdownContainer,excludeValue)});return}for(;dropdownContainer.firstChild;)dropdownContainer.removeChild(dropdownContainer.firstChild);var dropdown=document.createElement("div");dropdown.className="suggestions-dropdown",dropdownContainer.appendChild(dropdown);var hasResults=!1,idPrefix=dropdownContainer.id+"_opt_",itemIndex=0,filteredOptions=input===pesquisaB&&selectedCategory?allOptions.filter(function(opt){return opt.getAttribute("data-category")===selectedCategory}):allOptions;filteredOptions.forEach(function(option){if(option.value&&option.value!==excludeValue&&(query.length===0||option.text.toLowerCase().includes(query))){hasResults=!0;var item=document.createElement("div");item.className="suggestion-item",item.id=idPrefix+itemIndex++,item.setAttribute("role","option"),item.setAttribute("aria-selected","false");var img=document.createElement("img");img.src=option.getAttribute("data-image"),img.alt=option.text,img.loading="lazy",hideOnImageError(img),item.appendChild(img);var textDiv=document.createElement("div");textDiv.className="suggestion-item-text",textDiv.textContent=option.text,item.appendChild(textDiv),item.dataset.value=option.value,item.dataset.image=option.getAttribute("data-image"),item.dataset.description=option.getAttribute("data-description"),item.dataset.text=option.text,item.dataset.price=option.getAttribute("data-price"),item.dataset.productUrl=option.getAttribute("data-product-url"),item.dataset.category=option.getAttribute("data-category"),item.addEventListener("click",function(){var selectEl=input===pesquisaA?produtoA:produtoB;selectEl.value=this.dataset.value,input.value=this.dataset.text,input===pesquisaA&&(selectedCategory=this.dataset.category,produtoB.value="",pesquisaB.value="",previewB.style.display="none",setButtonEnabled(avancarStep2,!1));
1var changeEvent=new Event("change");selectEl.dispatchEvent(changeEvent),input===pesquisaA?setButtonEnabled(avancarStep1,produtoA.value):setButtonEnabled(avancarStep2,produtoB.value),hideDropdown(pesquisaA,bodyDropdownA),hideDropdown(pesquisaB,bodyDropdownB)}),dropdown.appendChild(item)}}),hasResults?(positionDropdown(input,dropdownContainer),dropdownContainer.style.display="block",input.setAttribute("aria-expanded","true")):hideDropdown(input,dropdownContainer)}function moveActiveItem(input,dropdownContainer,direction){var dropdown=dropdownContainer.querySelector(".suggestions-dropdown");if(!dropdown)return null;var items=dropdown.querySelectorAll(".suggestion-item");if(!items.length)return null;var current=dropdown.querySelector(".suggestion-item--active"),idx=current?Array.prototype.indexOf.call(items,current):-1;direction>0?idx=idx<items.length-1?idx+1:0:idx=idx>0?idx-1:items.length-1;for(var i=0;i<items.length;i++){var on=i===idx;items[i].classList.toggle("suggestion-item--active",on),items[i].setAttribute("aria-selected",on?"true":"false")}var active=items[idx];return input.setAttribute("aria-activedescendant",active.id),active.scrollIntoView({block:"nearest"}),active}function makeSearchKeydownHandler(input,dropdownContainer,getExclude){return function(event){var isOpen=dropdownContainer.style.display==="block";switch(event.key){case"ArrowDown":event.preventDefault(),isOpen||showSuggestions(input,dropdownContainer,getExclude()),moveActiveItem(input,dropdownContainer,1);break;case"ArrowUp":if(!isOpen)return;event.preventDefault(),moveActiveItem(input,dropdownContainer,-1);break;case"Enter":if(!isOpen)return;var active=dropdownContainer.querySelector(".suggestion-item--active");active&&(event.preventDefault(),active.click());break;case"Escape":if(!isOpen)return;event.preventDefault(),hideDropdown(input,dropdownContainer);break}}}function debouncedShowSuggestions(input,dropdownContainer,excludeValue){clearTimeout(debounceTimer),debounceTimer=setTimeout(function(){showSuggestions(input,dropdownContainer,excludeValue)},150)}function abrirModal(){lastFocusedBeforeOpen=document.activeElement,lockScroll(),modal.classList.add("aberto"),goToStep(1),resetForm(),seedCurrentProduct(),loadInitialCatalog(),setTimeout(function(){pesquisaA.focus()},100)}document.addEventListener("click",function(e){var trigger=e.target.closest("[data-comparador-trigger]");trigger&&(e.preventDefault(),e.stopPropagation(),abrirModal())});function buildComparisonDOM(text){var container=document.createElement("div");if(container.className="comparison-text",!text)return container;for(var lines=text.split("\n"),currentItemDiv=null,currentContentDiv=null,i=0;i<lines.length;i++){var line=lines[i].trim();if(line){var headerMatch=line.match(/^###\s+(.*)$/);if(headerMatch){var h3=document.createElement("h3");h3.textContent=headerMatch[1],container.appendChild(h3);continue}var itemMatch=line.match(/^(\d+)\.\s+(.*?)(?:\s*:\s*(.*))?$/);if(itemMatch){currentItemDiv=document.createElement("div"),currentItemDiv.className="comparison-item";var numberSpan=document.createElement("span");numberSpan.className="item-number",numberSpan.textContent=itemMatch[1]+".",currentItemDiv.appendChild(numberSpan);var titleSpan=document.createElement("span");titleSpan.className="category-title",appendRichText(titleSpan,itemMatch[2]),currentItemDiv.appendChild(titleSpan),currentContentDiv=document.createElement("div"),currentContentDiv.className="comparison-content",itemMatch[3]&&appendRichText(currentContentDiv,itemMatch[3]),currentItemDiv.appendChild(currentContentDiv),container.appendChild(currentItemDiv);continue}if(line.startsWith("-")){var subItem=document.createElement("div");subItem.className="sublist-item",appendRichText(subItem,line.substring(1).trim()),currentContentDiv?currentContentDiv.appendChild(subItem):container.appendChild(subItem);continue}if(currentContentDiv)appendRichText(currentContentDiv," "+line);else{var p=document.createElement("p");appendRichText(p,line),container.appendChild(p)}}}return container}
1function appendRichText(parent,text){for(var parts=text.split(/(\*\*[^*]+\*\*|\*[^*]+\*)/g),i=0;i<parts.length;i++){var part=parts[i];if(part.length>=4&&part.startsWith("**")&&part.endsWith("**")){var strong=document.createElement("strong");strong.textContent=part.slice(2,-2),parent.appendChild(strong)}else if(part.length>=3&&part.startsWith("*")&&part.endsWith("*")){var em=document.createElement("em");em.textContent=part.slice(1,-1),parent.appendChild(em)}else parent.appendChild(document.createTextNode(part))}}function showModalError(message){var resultado=document.getElementById("resultado");resultado.textContent="";var errorDiv=document.createElement("div");errorDiv.className="error-message",errorDiv.setAttribute("role","alert"),errorDiv.textContent=message,resultado.appendChild(errorDiv)}function runComparison(){var optionA=produtoA.options[produtoA.selectedIndex],optionB=produtoB.options[produtoB.selectedIndex];if(!optionA||!optionB||!optionA.value||!optionB.value){showModalError("Por favor, selecione os dois produtos para comparar.");return}var resultado=document.getElementById("resultado");resultado.textContent="";var spinner=document.createElement("div");spinner.className="loading-spinner",resultado.appendChild(spinner);var loadingP=document.createElement("p");loadingP.textContent="Preparando compara\xE7\xE3o...",resultado.appendChild(loadingP);var loadingMessages=["Analisando produtos...","Finalizando compara\xE7\xE3o..."],messageIndex=0,loadingInterval=setInterval(function(){messageIndex=(messageIndex+1)%loadingMessages.length,loadingP.textContent=loadingMessages[messageIndex]},3e3);document.getElementById("summaryImgA").src=document.getElementById("imgA").src,document.getElementById("summaryImgB").src=document.getElementById("imgB").src,document.getElementById("summaryNameA").textContent=document.getElementById("nomeA").textContent,document.getElementById("summaryNameB").textContent=document.getElementById("nomeB").textContent,fetchController&&fetchController.abort(),fetchController=new AbortController;var activeController=fetchController,fetchTimeoutId=setTimeout(function(){activeController&&activeController.abort()},3e4);Promise.all([fetchProductDescription(optionA,activeController.signal),fetchProductDescription(optionB,activeController.signal)]).then(function(descriptions){var descA=descriptions[0],descB=descriptions[1];if(!descA||!descB)return clearTimeout(fetchTimeoutId),clearInterval(loadingInterval),showModalError("Um dos produtos n\xE3o possui descri\xE7\xE3o dispon\xEDvel para compara\xE7\xE3o."),null;var productAData={id:optionA.value,title:optionA.text,description:descA,image:optionA.getAttribute("data-image"),price:optionA.getAttribute("data-price"),category:optionA.getAttribute("data-category")},productBData={id:optionB.value,title:optionB.text,description:descB,image:optionB.getAttribute("data-image"),price:optionB.getAttribute("data-price"),category:optionB.getAttribute("data-category")};return fetch(COMPARADOR_BASE+"/api/compare",{method:"POST",headers:{"Content-Type":"application/json"},signal:activeController.signal,body:JSON.stringify({productA:productAData,productB:productBData,language:"pt-br",domain:window.location.hostname,path:window.location.pathname})})}).then(function(response){return response?response.ok?response.json():response.json().then(function(errorData){var err=new Error("HTTP "+response.status);throw err.status=response.status,err.backendMessage=errorData&&errorData.error,err},function(){var err=new Error("HTTP "+response.status);throw err.status=response.status,err}):null}).then(function(data){if(data){clearTimeout(fetchTimeoutId),clearInterval(loadingInterval),resultado.textContent="";var comparisonEl=buildComparisonDOM(data.comparison);resultado.appendChild(comparisonEl);var verMaisContainer=document.createElement("div");verMaisContainer.className="ver-mais-container";var titleDiv=document.createElement("div");titleDiv.className="ver-mais-title",titleDiv.textContent="Veja mais sobre estes produtos",verMaisContainer.appendChild(titleDiv);var buttonsDiv=document.createElement("div");buttonsDiv.className="ver-mais-buttons";var linkA=document.createElement("a");linkA.href=optionA.getAttribute("data-product-url"),linkA.className="btn-ver-mais",linkA.textContent="Ver "+optionA.text,buttonsDiv.appendChild(linkA);var linkB=document.createElement("a");linkB.href=optionB.getAttribute("data-product-url"),linkB.className="btn-ver-mais",linkB.textContent="Ver "+optionB.text,buttonsDiv.appendChild(linkB),verMaisContainer.appendChild(buttonsDiv),resultado.appendChild(verMaisContainer);var step3=document.querySelector('.step[data-step="3"]');step3&&(step3.classList.remove("active"),step3.classList.add("completed"),step3.removeAttribute("aria-current"));var stepLine2=document.querySelectorAll(".step-line")[1];stepLine2&&stepLine2.classList.add("completed"),resultado.scrollIntoView({behavior:"smooth",block:"start"})}}).catch(function(err){if(clearTimeout(fetchTimeoutId),clearInterval(loadingInterval),!(err&&err.name==="AbortError")){resultado.textContent="";var errorDiv=document.createElement("div");errorDiv.className="error-message",errorDiv.textContent=err&&err.backendMessage?err.backendMessage:"Ocorreu um erro ao comparar os produtos. Tente novamente.",resultado.appendChild(errorDiv)}})}fecharBtn&&fecharBtn.addEventListener("click",fecharModal);var backdrop=document.querySelector(".modal-backdrop");backdrop&&backdrop.addEventListener("click",fecharModal),avancarStep1&&avancarStep1.addEventListener("click",function(){goToStep(2),setTimeout(function(){pesquisaB.focus()},100)}),voltarStep2&&voltarStep2.addEventListener("click",function(){goToStep(1)}),avancarStep2&&avancarStep2.addEventListener("click",function(){goToStep(3),runComparison()}),voltarStep3&&voltarStep3.addEventListener("click",function(){goToStep(2)}),novaComparacao&&novaComparacao.addEventListener("click",function(){resetForm(),goToStep(1),setTimeout(function(){pesquisaA.focus()},100)}),produtoA&&produtoA.addEventListener("change",function(){var selected=this.options[this.selectedIndex];if(selected&&selected.value){var image=selected.getAttribute("data-image"),name=selected.text;if(selectedCategory=selected.getAttribute("data-category"),produtoB.value){var bOption=produtoB.options[produtoB.selectedIndex];bOption&&bOption.getAttribute("data-category")!==selectedCategory&&(produtoB.value="",pesquisaB.value="",previewB.style.display="none",setButtonEnabled(avancarStep2,!1))}document.getElementById("imgA").src=image,document.getElementById("nomeA").textContent=name,previewA.style.display="block"}else previewA.style.display="none",selectedCategory="";setButtonEnabled(avancarStep1,this.value)}),produtoB&&produtoB.addEventListener("change",function(){var selected=this.options[this.selectedIndex];if(selected&&selected.value){var image=selected.getAttribute("data-image"),name=selected.text;document.getElementById("imgB").src=image,document.getElementById("nomeB").textContent=name,previewB.style.display="block"}else previewB.style.display="none";setButtonEnabled(avancarStep2,this.value)}),pesquisaA&&(pesquisaA.addEventListener("input",function(){debouncedShowSuggestions(pesquisaA,bodyDropdownA,produtoB.value)}),pesquisaA.addEventListener("click",function(){showSuggestions(pesquisaA,bodyDropdownA,produtoB.value)}),pesquisaA.addEventListener("keydown",makeSearchKeydownHandler(pesquisaA,bodyDropdownA,function(){return produtoB.value}
1))),pesquisaB&&(pesquisaB.addEventListener("input",function(){debouncedShowSuggestions(pesquisaB,bodyDropdownB,produtoA.value)}),pesquisaB.addEventListener("click",function(){showSuggestions(pesquisaB,bodyDropdownB,produtoA.value)}),pesquisaB.addEventListener("keydown",makeSearchKeydownHandler(pesquisaB,bodyDropdownB,function(){return produtoA.value}))),document.addEventListener("click",function(event){pesquisaA&&pesquisaA.contains(event.target)||pesquisaB&&pesquisaB.contains(event.target)||bodyDropdownA&&bodyDropdownA.contains(event.target)||bodyDropdownB&&bodyDropdownB.contains(event.target)||(bodyDropdownA&&(bodyDropdownA.style.display="none"),bodyDropdownB&&(bodyDropdownB.style.display="none"))});var modalConteudo=document.querySelector(".modal-conteudo");modalConteudo&&modalConteudo.addEventListener("click",function(event){pesquisaA&&pesquisaA.contains(event.target)||pesquisaB&&pesquisaB.contains(event.target)||bodyDropdownA&&bodyDropdownA.contains(event.target)||bodyDropdownB&&bodyDropdownB.contains(event.target)||(pesquisaA&&bodyDropdownA&&hideDropdown(pesquisaA,bodyDropdownA),pesquisaB&&bodyDropdownB&&hideDropdown(pesquisaB,bodyDropdownB),event.stopPropagation())});function getFocusableInModal(){if(!modal)return[];for(var sel='button:not([disabled]), a[href], input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',nodes=modal.querySelectorAll(sel),visible=[],i=0;i<nodes.length;i++)nodes[i].offsetParent!==null&&visible.push(nodes[i]);return visible}document.addEventListener("keydown",function(event){if(!(!modal||!modal.classList.contains("aberto"))){if(event.key==="Escape"){fecharModal();return}if(event.key==="Tab"){var focusables=getFocusableInModal();if(focusables.length){var first=focusables[0],last=focusables[focusables.length-1],active=document.activeElement;event.shiftKey&&(active===first||!modal.contains(active))?(last.focus(),event.preventDefault()):!event.shiftKey&&(active===last||!modal.contains(active))&&(first.focus(),event.preventDefault())}}}}),window.addEventListener("resize",function(){bodyDropdownA&&bodyDropdownA.style.display==="block"&&positionDropdown(pesquisaA,bodyDropdownA),bodyDropdownB&&bodyDropdownB.style.display==="block"&&positionDropdown(pesquisaB,bodyDropdownB)},{passive:!0})});
2//# sourceMappingURL=/cdn/shop/t/31/assets/comparador-br.js.map?v=22153301092738092891781302157

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.