import{defineComponent as m,createVNode as d,resolveComponent as u}from"vue";import k from"../_util/BaseMixin.mjs";import h from"../_util/json2mq.mjs";import{getSlot as w}from"../_util/props-util/index.mjs";import{cloneElement as S}from"../_util/vnode.mjs";import v from"./default-props.mjs";import{canUseDOM as f}from"./utils/innerSliderUtils.mjs";const x=m({name:"Slider",mixins:[k],inheritAttrs:!1,props:{...v},data(){return this._responsiveMediaHandlers=[],{breakpoint:null}},mounted(){if(this.responsive){const e=this.responsive.map(i=>i.breakpoint);e.sort((i,r)=>i-r),e.forEach((i,r)=>{let l;r===0?l=h({minWidth:0,maxWidth:i}):l=h({minWidth:e[r-1]+1,maxWidth:i}),f()&&this.media(l,()=>{this.setState({breakpoint:i})})});const t=h({minWidth:e.slice(-1)[0]});f()&&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){const i=window.matchMedia(e),r=({matches:l})=>{l&&t()};i.addListener(r),r(i),this._responsiveMediaHandlers.push({mql:i,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 e,t;this.breakpoint?(t=this.responsive.filter(s=>s.breakpoint===this.breakpoint),e=t[0].settings==="unslick"?"unslick":{...this.$props,...t[0].settings}):e={...this.$props},e.centerMode&&(e.slidesToScroll>1,e.slidesToScroll=1),e.fade&&(e.slidesToShow>1,e.slidesToScroll>1,e.slidesToShow=1,e.slidesToScroll=1);let i=w(this)||[];i=i.filter(s=>typeof s=="string"?!!s.trim():!!s),e.variableWidth&&(e.rows>1||e.slidesPerRow>1)&&(console.warn("variableWidth is not supported in case of rows > 1 or slidesPerRow > 1"),e.variableWidth=!1);const r=[];let l=null;for(let s=0;s<i.length;s+=e.rows*e.slidesPerRow){const a=[];for(let n=s;n<s+e.rows*e.slidesPerRow;n+=e.slidesPerRow){const p=[];for(let o=n;o<n+e.slidesPerRow&&(e.variableWidth&&i[o].props?.style&&(l=i[o].props.style.width),!(o>=i.length));o+=1)p.push(S(i[o],{key:100*s+10*n+o,tabindex:-1,style:{width:`${100/e.slidesPerRow}%`,display:"inline-block"}}));a.push(d("div",{key:10*s+n},[p]))}e.variableWidth?r.push(d("div",{key:s,style:{width:l}},[a])):r.push(d("div",{key:s},[a]))}if(e==="unslick"){const s=`regular slider ${this.className||""}`;return d("div",{class:s},[i])}else r.length<=e.slidesToShow&&(e.unslick=!0);const c={...this.$attrs,...e,children:r,ref:this.innerSliderRefHandler};return d(u("InnerSlider"),{...c,__propsSymbol__:[]},this.$slots)}});export{x as default};
