1(()=>{"use strict";const CARD_SELECTOR=".m-product-card",DELIVERY_SELECTOR=["[data-tanatel-delivery]",".tanatel-card-delivery-compact",".product-delivery-time",".product-card-delivery",".tanatel-card-delivery",".tanatel-delivery-line"].join(",");function normalizeText(value){return String(value||"").replace(/\s+/g," ").replace(/:/g,"").trim().toLowerCase()}function looksLikeDelivery(node){const text=normalizeText(node.textContent);return text.includes("\u0627\u0644\u062A\u0633\u0644\u064A\u0645")||text.includes("delivery")||node.matches(DELIVERY_SELECTOR)}function cleanCard(card){if(!card)return;const preferred=card.querySelector("[data-tanatel-delivery]")||card.querySelector(".tanatel-card-delivery-compact");if(!preferred)return;Array.from(card.querySelectorAll(DELIVERY_SELECTOR)).forEach(node=>{node!==preferred&&(node.contains(preferred)||preferred.contains(node)||looksLikeDelivery(node)&&node.remove())});const info=preferred.closest(".m-product-card__info")||preferred.parentElement;info&&Array.from(info.children).forEach(child=>{if(child===preferred||child.classList.contains("tanatel-card-warranty")||child.classList.contains("gold-warranty"))return;const text=normalizeText(child.textContent);(text.includes("\u0627\u0644\u062A\u0633\u0644\u064A\u0645 \u062E\u0644\u0627\u0644")||text.includes("delivery in")||text.includes("delivery within"))&&!child.querySelector("[data-tanatel-delivery]")&&child.remove()});const warranties=Array.from(card.querySelectorAll(".gold-warranty, .tanatel-card-warranty"));if(warranties.length>1){const keep=warranties.find(node=>node.classList.contains("tanatel-card-warranty"))||warranties[0];warranties.forEach(node=>{node!==keep&&!keep.contains(node)&&node.remove()})}}function clean(root=document){root.matches?.(CARD_SELECTOR)&&cleanCard(root),root.querySelectorAll?.(CARD_SELECTOR).forEach(cleanCard)}const observer=new MutationObserver(records=>{for(const record of records)for(const node of record.addedNodes){if(!(node instanceof Element))continue;node.matches(CARD_SELECTOR)&&cleanCard(node),node.querySelectorAll?.(CARD_SELECTOR).forEach(cleanCard);const parentCard=node.closest?.(CARD_SELECTOR);parentCard&&cleanCard(parentCard)}}),boot=()=>{clean(document),observer.observe(document.body,{childList:!0,subtree:!0})};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",boot,{once:!0}):boot();const variantModalState={product:null,selected:[],trigger:null,dialog:null},escapeHtml=value=>String(value??"").replace(/[&<>"']/g,char=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[char]),money=cents=>{const themeMoneyFormat=window.MinimogSettings?.money_format;return typeof window.formatMoney=="function"&&themeMoneyFormat?window.formatMoney(Number(cents)||0,themeMoneyFormat):`${((Number(cents)||0)/100).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})} \u20C1`},getVariant=()=>{const{product,selected}=variantModalState;return product&&product.variants.find(variant=>variant.options.every((value,index)=>value===selected[index]))||null},closeVariantModal=()=>{const dialog=variantModalState.dialog;dialog&&(dialog.classList.remove("is-open"),document.documentElement.classList.remove("tanatel-variant-modal-open"),window.setTimeout(()=>{dialog.remove(),variantModalState.dialog=null,variantModalState.product=null,variantModalState.selected=[],variantModalState.trigger?.focus?.(),variantModalState.trigger=null},180))},updateVariantModal=()=>{const dialog=variantModalState.dialog,product=variantModalState.product;if(!dialog||!product)return;const variant=getVariant(),price=dialog.querySelector("[data-tanatel-variant-price]"),compare=dialog.querySelector("[data-tanatel-variant-compare]"),add=dialog.querySelector("[data-tanatel-variant-add]"),status=dialog.querySelector("[data-tanatel-variant-status]"),showCompare=!!(variant?.compare_at_price&&variant.compare_at_price>variant.price);price&&(price.innerHTML=variant?money(variant.price):"\u2014",price.style.color=showCompare?"rgb(var(--color-price-sale))":""),compare&&(compare.hidden=!showCompare,compare.innerHTML=showCompare?money(variant.compare_at_price):"");const available=!!variant?.available;add&&(add.disabled=!available,add.dataset.variantId=variant?.id||"",add.querySelector("span").textContent=available?document.documentElement.lang?.startsWith("ar")?"\u0623\u0636\u0641 \u0644\u0644\u0633\u0644\u0629":"Add to cart":document.documentElement.lang?.startsWith("ar")?"\u063A\u064A\u0631 \u0645\u062A\u0648\u0641\u0631":"Unavailable"),status&&(status.textContent=variant?available?document.documentElement.lang?.startsWith("ar")?"\u0645\u062A\u0648\u0641\u0631":"Available":document.documentElement.lang?.startsWith("ar")?"\u063A\u064A\u0631 \u0645\u062A\u0648\u0641\u0631":"Unavailable":document.documentElement.lang?.startsWith("ar")?"\u0627\u062E\u062A\u0631 \u062C\u0645\u064A\u0639 \u0627\u0644\u062E\u064A\u0627\u0631\u0627\u062A":"Select all options",status.dataset.available=available?"true":"false");const image=variant?.featured_image?.src||variant?.featured_image?.url||product.featured_image?.src||product.featured_image?.url||product.featured_image||"",imageNode=dialog.querySelector("[data-tanatel-variant-image]");imageNode&&image&&(imageNode.src=image)},renderVariantModal=product=>{const isAr=document.documentElement.lang?.toLowerCase().startsWith("ar"),optionDefs=(product.options||[]).map((option,optionIndex)=>
1{const name=typeof option=="string"?option:option?.name||`Option ${optionIndex+1}`,values=Array.isArray(option?.values)&&option.values.length?option.values:[...new Set((product.variants||[]).map(variant=>variant.options?.[optionIndex]).filter(Boolean))];return{name,values}}),initialVariant=(product.variants||[]).find(variant=>variant.available)||(product.variants||[])[0]||null,selected=optionDefs.map((option,index)=>initialVariant?.options?.[index]||option.values[0]||"");variantModalState.selected=selected;const optionMarkup=optionDefs.map((option,optionIndex)=>{const values=option.values;return` 2 <fieldset class="tanatel-variant-modal__option" data-option-index="${optionIndex}"> 3 <legend>${escapeHtml(option.name)}</legend> 4 <div class="tanatel-variant-modal__choices"> 5 ${values.map(value=>` 6 <button 7 type="button" 8 class="tanatel-variant-modal__choice${selected[optionIndex]===value?" is-selected":""}" 9 data-option-value="${escapeHtml(value)}" 10 aria-pressed="${selected[optionIndex]===value?"true":"false"}" 11 >${escapeHtml(value)}</button> 12 `).join("")} 13 </div> 14 </fieldset>`}).join(""),wrapper=document.createElement("div");wrapper.className="tanatel-variant-modal",wrapper.innerHTML=` 15 <div class="tanatel-variant-modal__backdrop" data-tanatel-variant-close></div> 16 <div class="tanatel-variant-modal__dialog" role="dialog" aria-modal="true" aria-label="${isAr?"\u062D\u062F\u062F \u062E\u064A\u0627\u0631\u0627\u062A \u0627\u0644\u0645\u0646\u062A\u062C":"Select product options"}"> 17 <button type="button" class="tanatel-variant-modal__close" data-tanatel-variant-close aria-label="${isAr?"\u0625\u063A\u0644\u0627\u0642":"Close"}">\xD7</button> 18 <div class="tanatel-variant-modal__media"> 19 <img 20 data-tanatel-variant-image 21 src="${escapeHtml(product.featured_image?.src||product.featured_image?.url||product.featured_image||"")}" 22 alt="${escapeHtml(product.title)}" 23 > 24 </div> 25 <div class="tanatel-variant-modal__content"> 26 <div class="tanatel-variant-modal__eyebrow">${isAr?"\u062D\u062F\u062F \u062E\u064A\u0627\u0631\u0627\u062A\u0643":"Choose your options"}</div> 27 <h2>${escapeHtml(product.title)}</h2> 28 <div class="tanatel-variant-modal__price"> 29 <span data-tanatel-variant-compare hidden></span> 30 <strong data-tanatel-variant-price></strong> 31 </div> 32 <div class="tanatel-variant-modal__options">${optionMarkup}</div> 33 <div class="tanatel-variant-modal__status" data-tanatel-variant-status></div> 34 <div class="tanatel-variant-modal__footer"> 35 <div class="tanatel-variant-modal__quantity"> 36 <button type="button" data-qty-minus aria-label="${isAr?"\u062A\u0642\u0644\u064A\u0644 \u0627\u0644\u0643\u0645\u064A\u0629":"Decrease quantity"}">\u2212</button> 37 <input type="number" min="1" value="1" inputmode="numeric" data-tanatel-variant-qty aria-label="${isAr?"\u0627\u0644\u0643\u0645\u064A\u0629":"Quantity"}"> 38 <button type="button" data-qty-plus aria-label="${isAr?"\u0632\u064A\u0627\u062F\u0629 \u0627\u0644\u0643\u0645\u064A\u0629":"Increase quantity"}">+</button> 39 </div> 40 <button type="button" class="m-button m-button--primary tanatel-variant-modal__add" data-tanatel-variant-add> 41 <span>${isAr?"\u0623\u0636\u0641 \u0644\u0644\u0633\u0644\u0629":"Add to cart"}</span> 42 </button> 43 </div> 44 <p class="tanatel-variant-modal__message" data-tanatel-variant-message aria-live="polite"></p> 45 </div> 46 </div>`,document.body.appendChild(wrapper),variantModalState.dialog=wrapper,document.documentElement.classList.add("tanatel-variant-modal-open"),requestAnimationFrame(()=>wrapper.classList.add("is-open")),wrapper.querySelectorAll("[data-tanatel-variant-close]").forEach(el=>el.addEventListener("click",closeVariantModal)),wrapper.querySelectorAll("[data-option-index]").forEach(fieldset=>{const optionIndex=Number(fieldset.dataset.optionIndex);fieldset.addEventListener("click",event=>{const button=event.target.closest("[data-option-value]");button&&(variantModalState.selected[optionIndex]=button.dataset.optionValue,fieldset.querySelectorAll("[data-option-value]").forEach(item=>{const active=item===button;item.classList.toggle("is-selected",active),item.setAttribute("aria-pressed",active?"true":"false")}
46),updateVariantModal())})});const qty=wrapper.querySelector("[data-tanatel-variant-qty]");wrapper.querySelector("[data-qty-minus]")?.addEventListener("click",()=>{qty.value=Math.max(1,Number(qty.value||1)-1)}),wrapper.querySelector("[data-qty-plus]")?.addEventListener("click",()=>{qty.value=Math.max(1,Number(qty.value||1)+1)}),wrapper.querySelector("[data-tanatel-variant-add]")?.addEventListener("click",async event=>{const button=event.currentTarget,variant=getVariant(),message=wrapper.querySelector("[data-tanatel-variant-message]");if(!(!variant?.available||button.disabled)){button.disabled=!0,button.classList.add("is-loading"),message&&(message.textContent="");try{const sections=[];document.documentElement.dispatchEvent(new CustomEvent("cart:grouped-sections",{bubbles:!0,detail:{sections}}));const response=await fetch(`${window.Shopify?.routes?.root||"/"}cart/add.js`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({items:[{id:variant.id,quantity:Math.max(1,Number(qty?.value||1))}],sections:[...new Set(sections)],sections_url:window.location.pathname})}),result=await response.json();if(!response.ok)throw new Error(result?.description||result?.message||"Cart error");message&&(message.textContent=isAr?"\u062A\u0645\u062A \u0627\u0644\u0625\u0636\u0627\u0641\u0629 \u0644\u0644\u0633\u0644\u0629 \u0628\u0646\u062C\u0627\u062D":"Added to cart successfully",message.dataset.success="true");const cartUpdate=window.EnfitahTheme?.pubSubEvents?.cartUpdate;if(!cartUpdate||!result?.sections)throw new Error("Cart sections were not returned");window.EnfitahEvents.emit(cartUpdate,{cart:result,productVariantId:String(variant.id),source:"tanatel-select-options"});const cartDrawer=document.querySelector("m-cart-drawer");cartDrawer&&window.EnfitahSettings?.enable_cart_drawer&&cartDrawer.open(button),window.setTimeout(closeVariantModal,700)}catch(error){message&&(message.textContent=error?.message||(isAr?"\u062A\u0639\u0630\u0631 \u0627\u0644\u0625\u0636\u0627\u0641\u0629 \u0644\u0644\u0633\u0644\u0629":"Could not add to cart"),message.dataset.success="false"),button.disabled=!1}finally{button.classList.remove("is-loading")}}}),wrapper.querySelector(".tanatel-variant-modal__close")?.focus(),updateVariantModal()},openVariantModal=async trigger=>{const handle=trigger?.dataset?.productHandle;if(handle){variantModalState.trigger=trigger,trigger.disabled=!0,trigger.classList.add("is-loading");try{const root=window.Shopify?.routes?.root||"/",response=await fetch(`${root}products/${encodeURIComponent(handle)}.js`,{headers:{Accept:"application/json"}});if(!response.ok)throw new Error(`Product request failed: ${response.status}`);const product=await response.json();variantModalState.product=product,renderVariantModal(product)}catch(error){console.error("[Tanatel Select Options]",error),window.location.assign(trigger.dataset.productUrl||`/products/${encodeURIComponent(handle)}`)}finally{trigger.disabled=!1,trigger.classList.remove("is-loading")}}};document.addEventListener("click",event=>{const trigger=event.target.closest("[data-tanatel-select-options]");trigger&&(event.preventDefault(),event.stopPropagation(),openVariantModal(trigger))}),document.addEventListener("keydown",event=>{event.key==="Escape"&&variantModalState.dialog&&closeVariantModal()})})(); 47//# sourceMappingURL=/cdn/shop/t/172/assets/tanatel-card-surface-sync.js.map?v=66080372916886807031788335888
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.