text: class BRSelect{constructor(e,t){this.name=e,this.component=t,this._setUpBrSelect()}_setUpBrSelect(){for(const e of this.component.querySelectorAll("select"))this.component.appendChild(this._buildSelectionField(e)),this.component.appendChild(this._buildOptionsList(e));this._setBehavior()}_buildSelectionField(e){const t=window.document.createElement("button");return t.setAttribute("class","select-selected unselected"),e.disabled&&t.setAttribute("disabled","disabled"),t.appendChild(this._buildOptionItem(e.options[e.selectedIndex].innerHTML)),t.appendChild(this._buildIcon()),t}_buildOptionItem(e){const t=window.document.createElement("span");return t.innerHTML=e,t}_buildIcon(){const e=window.document.createElement("i");return e.setAttribute("class","fas fa-chevron-down"),e}_buildOptionsList(e){const t=window.document.createElement("div");t.setAttribute("class","select-items select-hide");for(const s of e.options){const e=window.document.createElement("button");e.appendChild(this._buildOptionItem(s.innerHTML)),t.appendChild(e)}return t}_setBehavior(){for(const e of this.component.querySelectorAll(".select-selected"))e.addEventListener("click",t=>{t.stopPropagation(),e.nextElementSibling.classList.toggle("select-hide"),this._closeSelects(e),window.document.addEventListener("click",()=>{this._closeSelects()})});for(const e of this.component.querySelectorAll(".select-items button"))e.addEventListener("click",()=>{for(const t of this.component.querySelectorAll("select"))for(const[s,o]of Array.from(t.options).entries())if(o.innerHTML===e.firstChild.innerHTML){t.selectedIndex=s,t.dispatchEvent(new Event("change")),e.parentNode.previousSibling.firstChild.innerHTML=e.firstChild.innerHTML,e.parentNode.previousSibling.setAttribute("class","select-selected"),e.parentNode.classList.add("select-hide");for(const t of e.parentNode.querySelectorAll("button"))t===e?t.setAttribute("class","same-as-selected"):t.removeAttribute("class")}})}_closeSelects(e){for(const t of window.document.querySelectorAll(".br-select"))for(const s of t.querySelectorAll(".select-selected"))if(s!==e)for(const e of t.querySelectorAll(".select-items"))e.classList.add("select-hide"),window.document.removeEventListener("click",this._closeSelects)}_deleteSelect(){for(const e of this.component.querySelectorAll("button.select-selected"))e.remove();for(const e of this.component.querySelectorAll("div.select-items"))e.remove()}updateSelect(){this._deleteSelect(),this._setUpBrSelect()}}const selectList=[];for(const e of window.document.querySelectorAll(".br-select"))selectList.push(new BRSelect("br-select",e));export default BRSelect;
  //# sourceMappingURL=select.js.map