import{b5 as a,aL as e,aK as t}from"./vendor-element-plus.js?ver=3.1.10";import{W as i,Y as n,aQ as r,X as s,Z as o,aa as g,ab as p,a5 as l,J as c,az as h,a0 as u,a8 as _}from"./vendor.js?ver=3.1.10";import{_ as d}from"./fc-bits-ui.js?ver=3.1.10";const m={name:"PaginationBar",components:{Pagination:d({name:"Pagination",emits:["fetch","per_page_change"],props:{pagination:{required:!0,type:Object},extra_sizes:{required:!1,type:Array,default:()=>[]},hide_on_single:{required:!1,type:Boolean,default:()=>!1},layout:{required:!1,type:String,default:()=>"total, sizes, prev, pager, next"}},computed:{page_sizes(){const a=[];this.pagination.per_page<10&&a.push(this.pagination.per_page);return[...a,10,20,50,80,100,120,150,...this.extra_sizes]}},methods:{changePage(a){this.pagination.current_page=a,this.$emit("fetch")},changeSize(a){this.pagination.per_page=a,this.$emit("per_page_change",a),this.$emit("fetch")}}},[["render",function(e,t,r,s,o,g){const p=a;return i(),n(p,{class:"fcrm_pagination",background:!1,layout:r.layout,onCurrentChange:g.changePage,onSizeChange:g.changeSize,"hide-on-single-page":r.hide_on_single,"current-page":r.pagination.current_page,"onUpdate:currentPage":t[0]||(t[0]=a=>r.pagination.current_page=a),"page-sizes":g.page_sizes,"page-size":r.pagination.per_page,total:r.pagination.total},null,8,["layout","onCurrentChange","onSizeChange","hide-on-single-page","current-page","page-sizes","page-size","total"])}]])},emits:["fetch"],props:{pagination:{type:Object,required:!0},hide_on_single:{type:Boolean,default:!1},page_sizes:{type:Array,default:()=>[]},extra_sizes:{type:Array,default:()=>[]},wrapperClass:{type:[String,Array,Object],default:""}},computed:{currentPage(){var a;return Number(null==(a=this.pagination)?void 0:a.current_page)||1},totalPages(){var a,e;const t=Number(null==(a=this.pagination)?void 0:a.per_page)||10,i=Number(null==(e=this.pagination)?void 0:e.total)||0;return Math.max(1,Math.ceil(i/t))},pageSizes(){var a;const e=[],t=parseInt(null==(a=this.pagination)?void 0:a.per_page,10)||10;t<10&&e.push(t);const i=this.page_sizes.length?this.page_sizes:[10,20,50,80,100,120,150];return[...e,...i,...this.extra_sizes]}},methods:{onPerPageChange(a){a&&(this.pagination.per_page=a,this.pagination.current_page=1,this.$emit("fetch"))},goFirst(){this.currentPage<=1||(this.pagination.current_page=1,this.$emit("fetch"))},goLast(){this.currentPage>=this.totalPages||(this.pagination.current_page=this.totalPages,this.$emit("fetch"))}}},f={class:"fcrm-pagination-bar__left"},b={class:"fcrm-pagination-bar__page-info"},v={class:"fcrm-pagination-bar__page-info"},L={class:"fcrm-pagination-bar__right"},y=["disabled","aria-label"],z=["disabled","aria-label"];const P=d(m,[["render",function(a,d,m,P,w,x){const $=e,C=t,S=r("pagination");return!m.hide_on_single||x.totalPages>1?(i(),s("div",{key:0,class:u(["fcrm-pagination-bar",m.wrapperClass])},[o("div",f,[o("div",b,g(a.$t("Page"))+" "+g(m.pagination.current_page)+" "+g(a.$t("of"))+" "+g(x.totalPages),1),p(C,{"model-value":m.pagination.per_page,size:"small",class:"fcrm-pagination-bar__sizes fcrm_background_select","onUpdate:modelValue":x.onPerPageChange},{default:l(()=>[(i(!0),s(c,null,h(x.pageSizes,e=>(i(),n($,{key:e,label:e+" / "+a.$t("page"),value:e},null,8,["label","value"]))),128))],void 0),_:1},8,["model-value","onUpdate:modelValue"]),o("div",v,g(a.$t("Total"))+" "+g(m.pagination.total),1)]),o("div",L,[o("button",{type:"button",class:"fcrm-pagination-bar__nav fcrm-pagination-bar__nav--first",disabled:x.currentPage<=1,"aria-label":a.$t("First page"),onClick:d[0]||(d[0]=(...a)=>x.goFirst&&x.goFirst(...a))},[...d[3]||(d[3]=[o("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none"},[o("path",{d:"M14.9752 10.0004L10.6647 5.68994L9.68266 6.67203L13.0111 10.0004L9.68266 13.3288L10.6647 14.3109L14.9752 10.0004ZM11.0517 10.0004L6.74118 5.68994L5.75909 6.67203L9.08752 10.0004L5.75909 13.3288L6.74118 14.3109L11.0517 10.0004Z",fill:"var(--fc-secondary-text)"})],-1)])],8,y),p(S,{class:"fcrm-pagination-bar__right-inner",layout:"prev, pager, next",pagination:m.pagination,hide_on_single:m.hide_on_single,onFetch:d[1]||(d[1]=e=>a.$emit("fetch"))},null,8,["pagination","hide_on_single"]),o("button",{type:"button",class:"fcrm-pagination-bar__nav fcrm-pagination-bar__nav--last",disabled:x.currentPage>=x.totalPages,"aria-label":a.$t("Last page"),onClick:d[2]||(d[2]=(...a)=>x.goLast&&x.goLast(...a))},[...d[4]||(d[4]=[o("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none"},[o("path",{d:"M14.9752 10.0004L10.6647 5.68994L9.68266 6.67203L13.0111 10.0004L9.68266 13.3288L10.6647 14.3109L14.9752 10.0004ZM11.0517 10.0004L6.74118 5.68994L5.75909 6.67203L9.08752 10.0004L5.75909 13.3288L6.74118 14.3109L11.0517 10.0004Z",fill:"var(--fc-secondary-text)"})],-1)])],8,z)])],2)):_("",!0)}]]);export{P};
