1customElements.get("subscription-select")||customElements.define("subscription-select",class extends HTMLElement{connectedCallback(){this.nativeSelect=this.querySelector(".subscription-select-native"),this.custom=this.querySelector(".subscription-select-custom"),this.trigger=this.querySelector(".subscription-select-trigger"),this.triggerLabel=this.querySelector(".subscription-select-trigger__label"),this.triggerDesc=this.querySelector(".subscription-select-trigger__description"),this.optionsList=this.querySelector(".subscription-select-options"),!(!this.nativeSelect||!this.custom||!this.trigger||!this.optionsList)&&(this._onSyncDisplay=()=>this.syncDisplayFromNative(),this._onDocumentClick=e=>{this.contains(e.target)||this.closeDropdown()},this.addEventListener("subscription-select-sync",this._onSyncDisplay),this.syncOptionsFromNative(),this.syncDisplayFromNative(),this.nativeSelect.addEventListener("change",()=>{this.syncOptionsFromNative(),this.syncDisplayFromNative()}),this.trigger.addEventListener("click",()=>{this.custom.classList.contains("is-open")?this.closeDropdown():this.openDropdown()}),this.trigger.addEventListener("keydown",e=>{e.key==="ArrowDown"||e.key==="Enter"||e.key===" "?(e.preventDefault(),this.openDropdown()):e.key==="Escape"&&this.closeDropdown()}),this.optionsList.addEventListener("keydown",e=>{const items=Array.from(this.optionsList.querySelectorAll(".subscription-select-option")),index=items.indexOf(document.activeElement);e.key==="ArrowDown"?(e.preventDefault(),(items[index+1]||items[0]).focus()):e.key==="ArrowUp"?(e.preventDefault(),(items[index-1]||items[items.length-1]).focus()):e.key==="Escape"?(this.closeDropdown(),this.trigger.focus()):e.key==="Tab"&&this.closeDropdown()}),document.addEventListener("click",this._onDocumentClick))}disconnectedCallback(){this.removeEventListener("subscription-select-sync",this._onSyncDisplay),document.removeEventListener("click",this._onDocumentClick)}syncDisplayFromNative(){if(!this.nativeSelect)return;this.syncOptionsFromNative();const cur=this.getCurrentOption();cur&&this.updateTrigger(cur),this.renderOptions()}getCurrentOption(){return this.options.find(o=>o.value===this.nativeSelect.value)||this.options.find(o=>o.selected)||this.options[0]}syncOptionsFromNative(){this.options=Array.from(this.nativeSelect.options).map(opt=>{const description=opt.getAttribute("data-description")??opt.dataset.description??"";return{value:opt.value,label:opt.getAttribute("data-label")||opt.dataset.label||opt.text.trim(),description,selected:opt.selected}})}renderOptions(){!this.nativeSelect||!this.optionsList||(this.syncOptionsFromNative(),this.optionsList.innerHTML="",this.options.forEach(option=>{if(option.value===""&&!this.hasAttribute("data-show-onetime"))return;const selected=option.value===this.nativeSelect.value,li=document.createElement("li");li.className="subscription-select-option"+(selected?" is-selected":""),li.setAttribute("role","option"),li.setAttribute("aria-selected",String(selected)),li.setAttribute("tabindex","0"),li.dataset.value=option.value;const label=document.createElement("span");if(label.className="subscription-select-option__label",label.textContent=option.label,li.appendChild(label),option.description){const desc=document.createElement("span");desc.className="subscription-select-option__description",desc.textContent=option.description,li.appendChild(desc)}li.addEventListener("click",()=>this.selectOption(option)),li.addEventListener("keydown",e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this.selectOption(option))}),this.optionsList.appendChild(li)}))}updateTrigger(option){this.triggerLabel.textContent=option.label,this.triggerDesc&&(this.triggerDesc.textContent=option.description||"",this.triggerDesc.style.display=option.description?"":"none")}selectOption(option){window.CART_DEBUG&&console.warn("[cart] subscription-select selectOption",{value:option.value,label:option.label}),this.nativeSelect.value=option.value,this.updateTrigger(option),this.renderOptions(),this.closeDropdown(),this.nativeSelect.dispatchEvent(new Event("change",{bubbles:!0}))}openDropdown(){this.custom.classList.add("is-open"),this.trigger.setAttribute("aria-expanded","true"),this.custom.setAttribute("aria-expanded","true");const selected=this.optionsList.querySelector(".is-selected")||this.optionsList.querySelector("li");selected&&selected.focus()}closeDropdown(){this.custom.classList.remove("is-open"),this.trigger.setAttribute("aria-expanded","fal
1se"),this.custom.setAttribute("aria-expanded","false")}}); 2//# sourceMappingURL=/cdn/shop/t/135/assets/recharge-subscriptions.js.map?v=148040132204611508001789470204
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.