class a{constructor(s){this.labelsList=s.querySelector('[data-partner-filter="labels-list"]'),this.labels=s.querySelectorAll("[data-partner-label-id]"),this.cards=s.querySelectorAll("[data-partner-card-id]"),this._showMobileQty=8,this._showMoreBtn=s.querySelector('[data-partners-filter="show-more-btn"]'),this._setActiveLabel=this._setActiveLabel.bind(this),this._listClickHandler=this._listClickHandler.bind(this),this._setActiveCards=this._setActiveCards.bind(this),this._showMoreHandler=this._showMoreHandler.bind(this)}init(){this.labelsList.addEventListener("click",this._listClickHandler),this._setActiveLabel(this.labels[0]),this._showMoreBtn.addEventListener("click",this._showMoreHandler)}_listClickHandler(s){s.target.closest('[data-partner-label = "item"]')&&(this._showMobileQty=8,this._setActiveLabel(s.target.closest("button")))}_setActiveLabel(s){this.labels.forEach(t=>{s===t?t.classList.add("is-active"):t.classList.remove("is-active")}),this._setActiveCards(s.dataset.partnerLabelId)}_setActiveCards(s){if(s==="all"){this.cards.forEach(t=>{t.classList.add("is-show")}),this._setStateMobile();return}this.cards.forEach(t=>{s===t.dataset.partnerCardId?t.classList.add("is-show"):(t.classList.remove("is-show"),t.classList.remove("is-show-mobile"))}),this._setStateMobile()}_showMoreHandler(){this._showMobileQty=this._showMobileQty+8,this._setStateMobile()}_setStateMobile(){const s=document.querySelectorAll("[data-partner-card-id].is-show");s.forEach((t,e)=>{e+1<=this._showMobileQty?t.classList.add("is-show-mobile"):t.classList.remove("is-show-mobile")}),document.querySelectorAll("[data-partner-card-id].is-show-mobile"),s.length<=this._showMobileQty?this._showMoreBtn.classList.add("is-hidden"):this._showMoreBtn.classList.remove("is-hidden")}}export{a as PartnersFilter};
