import{r as s,c as t,h as i,H as h,g as a}from"./p-93b809e8.js";import{g as o}from"./p-feb3bd38.js";const e=class{constructor(i){s(this,i),this.bdsPaginationChange=t(this,"bdsPaginationChange",7),this.previewPage=s=>{this.value>1&&(s.preventDefault(),this.value=this.value-1)},this.nextPage=s=>{this.value<this.pages&&(s.preventDefault(),this.value=this.value+1)},this.firstPage=s=>{this.value>1&&(s.preventDefault(),this.value=this.paginationNumbers[0])},this.lastPage=s=>{this.value<this.pages&&(s.preventDefault(),this.value=this.pages)},this.openOptions=()=>{this.openSelect=!this.openSelect},this.onBlur=()=>{this.openSelect=!1},this.value=this.startedPage,this.openSelect=void 0,this.paginationNumbers=[],this.intoView=null,this.pages=void 0,this.startedPage=void 0,this.optionsPosition="auto",this.dtButtonInitial=null,this.dtButtonPrev=null,this.dtSelectNumber=null,this.dtButtonNext=null,this.dtButtonEnd=null}componentWillLoad(){this.countPage(),this.intoView=o(this.el)}pagesChanged(){this.countPage()}valueChanged(){this.bdsPaginationChange.emit(this.value)}countPage(){if(0!==this.paginationNumbers.length&&(this.paginationNumbers=[]),0===this.paginationNumbers.length){for(let s=1;s<=this.pages;s++)this.paginationNumbers.push(s);this.value=this.startedPage&&this.startedPage<this.pages?this.startedPage:this.paginationNumbers[0]}}optionSelected(s){this.value=s,this.openOptions()}render(){return i(h,null,i("div",{class:"actions"},i("bds-button-icon",{onBdsClick:s=>this.firstPage(s),size:"short",variant:"secondary",icon:"arrow-first",dataTest:this.dtButtonInitial}),i("bds-button-icon",{onBdsClick:s=>this.previewPage(s),size:"short",variant:"secondary",icon:"arrow-left",dataTest:this.dtButtonPrev}),i("bds-select",{class:"actions_select",value:this.value,"options-position":this.optionsPosition},this.paginationNumbers.map(((s,t)=>i("bds-select-option",{key:t,value:s,onClick:()=>this.optionSelected(s)},s)))),i("bds-button-icon",{onBdsClick:s=>this.nextPage(s),size:"short",variant:"secondary",icon:"arrow-right",dataTest:this.dtButtonNext}),i("bds-button-icon",{onBdsClick:s=>this.lastPage(s),size:"short",variant:"secondary",icon:"arrow-last",dataTest:this.dtButtonEnd})))}get el(){return a(this)}static get watchers(){return{pages:["pagesChanged"],startedPage:["pagesChanged"],value:["valueChanged"]}}};e.style=":host{display:block}:host .actions{display:-ms-flexbox;display:flex;gap:8px}:host .actions_select{width:74px}";export{e as bds_pagination}