import{getSlot as e}from"../_util/props-util/index.mjs";import{cloneElement as t}from"../_util/vnode.mjs";import n from"../_util/BaseMixin.mjs";import r from"../_util/json2mq.mjs";import i from"./default-props.mjs";import{canUseDOM as a}from"./utils/innerSliderUtils.mjs";import{createVNode as o,defineComponent as s,resolveComponent as c}from"vue";var l=s({name:`Slider`,mixins:[n],inheritAttrs:!1,props:{...i},data(){return this._responsiveMediaHandlers=[],{breakpoint:null}},mounted(){if(this.responsive){let e=this.responsive.map(e=>e.breakpoint);e.sort((e,t)=>e-t),e.forEach((t,n)=>{let i;i=r(n===0?{minWidth:0,maxWidth:t}:{minWidth:e[n-1]+1,maxWidth:t}),a()&&this.media(i,()=>{this.setState({breakpoint:t})})});let t=r({minWidth:e.slice(-1)[0]});a()&&this.media(t,()=>{this.setState({breakpoint:null})})}},beforeUnmount(){this._responsiveMediaHandlers.forEach(e=>{e.mql.removeListener(e.listener)})},methods:{innerSliderRefHandler(e){this.innerSlider=e},media(e,t){let n=window.matchMedia(e),r=({matches:e})=>{e&&t()};n.addListener(r),r(n),this._responsiveMediaHandlers.push({mql:n,query:e,listener:r})},slickPrev(){this.innerSlider?.slickPrev()},slickNext(){this.innerSlider?.slickNext()},slickGoTo(e,t=!1){this.innerSlider?.slickGoTo(e,t)},slickPause(){this.innerSlider?.pause(`paused`)},slickPlay(){this.innerSlider?.handleAutoPlay(`play`)}},render(){let n,r;this.breakpoint?(r=this.responsive.filter(e=>e.breakpoint===this.breakpoint),n=r[0].settings===`unslick`?`unslick`:{...this.$props,...r[0].settings}):n={...this.$props},n.centerMode&&(n.slidesToScroll,n.slidesToScroll=1),n.fade&&(n.slidesToShow,n.slidesToScroll,n.slidesToShow=1,n.slidesToScroll=1);let i=e(this)||[];i=i.filter(e=>typeof e==`string`?!!e.trim():!!e),n.variableWidth&&(n.rows>1||n.slidesPerRow>1)&&(console.warn(`variableWidth is not supported in case of rows > 1 or slidesPerRow > 1`),n.variableWidth=!1);let a=[],s=null;for(let e=0;e<i.length;e+=n.rows*n.slidesPerRow){let r=[];for(let a=e;a<e+n.rows*n.slidesPerRow;a+=n.slidesPerRow){let c=[];for(let r=a;r<a+n.slidesPerRow&&(n.variableWidth&&i[r].props?.style&&(s=i[r].props.style.width),!(r>=i.length));r+=1)c.push(t(i[r],{key:100*e+10*a+r,tabindex:-1,style:{width:`${100/n.slidesPerRow}%`,display:`inline-block`}}));r.push(o(`div`,{key:10*e+a},[c]))}n.variableWidth?a.push(o(`div`,{key:e,style:{width:s}},[r])):a.push(o(`div`,{key:e},[r]))}if(n===`unslick`)return o(`div`,{class:`regular slider ${this.className||``}`},[i]);a.length<=n.slidesToShow&&(n.unslick=!0);let l={...this.$attrs,...n,children:a,ref:this.innerSliderRefHandler};return o(c(`InnerSlider`),{...l,__propsSymbol__:[]},this.$slots)}});export{l as default};