const e=require("../../_util/props-util/index.js"),t=require("../../_util/vue-types/index.js"),n=require("../../_util/BaseMixin.js"),r=require("./common/Track.js"),i=require("./utils.js"),a=require("./common/createSlider.js");let o=require("vue");var s=(0,o.defineComponent)({compatConfig:{MODE:3},name:`Slider`,mixins:[n.default],inheritAttrs:!1,props:{defaultValue:Number,value:Number,disabled:{type:Boolean,default:void 0},autofocus:{type:Boolean,default:void 0},tabindex:t.default.oneOfType([t.default.number,t.default.string]),reverse:{type:Boolean,default:void 0},min:Number,max:Number,ariaLabelForHandle:String,ariaLabelledByForHandle:String,ariaValueTextFormatterForHandle:String,startPoint:Number},emits:[`beforeChange`,`afterChange`,`change`],data(){let e=this.defaultValue===void 0?this.min:this.defaultValue,t=this.value===void 0?e:this.value;return{sValue:this.trimAlignValue(t),dragging:!1}},watch:{value:{handler(e){this.setChangeValue(e)},deep:!0},min(){let{sValue:e}=this;this.setChangeValue(e)},max(){let{sValue:e}=this;this.setChangeValue(e)}},methods:{setChangeValue(e){let t=e===void 0?this.sValue:e,n=this.trimAlignValue(t,this.$props);n!==this.sValue&&(this.setState({sValue:n}),i.isValueOutOfRange(t,this.$props)&&this.$emit(`change`,n))},onChange(t){let n=!e.default(this,`value`),r=t.sValue>this.max?{...t,sValue:this.max}:t;n&&this.setState(r);let i=r.sValue;this.$emit(`change`,i)},onStart(e){this.setState({dragging:!0});let{sValue:t}=this;this.$emit(`beforeChange`,t);let n=this.calcValueByPos(e);this.startValue=n,this.startPosition=e,n!==t&&(this.prevMovedHandleIndex=0,this.onChange({sValue:n}))},onEnd(e){let{dragging:t}=this;this.removeDocumentEvents(),(t||e)&&this.$emit(`afterChange`,this.sValue),this.setState({dragging:!1})},onMove(e,t){i.pauseEvent(e);let{sValue:n}=this,r=this.calcValueByPos(t);r!==n&&this.onChange({sValue:r})},onKeyboard(e){let{reverse:t,vertical:n}=this.$props,r=i.getKeyboardValueMutator(e,n,t);if(r){i.pauseEvent(e);let{sValue:t}=this,n=r(t,this.$props),a=this.trimAlignValue(n);if(a===t)return;this.onChange({sValue:a}),this.$emit(`afterChange`,a),this.onEnd()}},getLowerBound(){let e=this.$props.startPoint||this.$props.min;return this.$data.sValue>e?e:this.$data.sValue},getUpperBound(){return this.$data.sValue<this.$props.startPoint?this.$props.startPoint:this.$data.sValue},trimAlignValue(e,t={}){if(e===null)return null;let n={...this.$props,...t},r=i.ensureValueInRange(e,n);return i.ensureValuePrecision(r,n)},getTrack({prefixCls:e,reverse:t,vertical:n,included:i,minimumTrackStyle:a,mergedTrackStyle:s,length:c,offset:l}){return(0,o.createVNode)(r.default,{class:`${e}-track`,vertical:n,included:i,offset:l,reverse:t,length:c,style:{...a,...s}},null)},renderSlider(){let{prefixCls:e,vertical:t,included:n,disabled:r,minimumTrackStyle:i,trackStyle:a,handleStyle:o,tabindex:s,ariaLabelForHandle:c,ariaLabelledByForHandle:l,ariaValueTextFormatterForHandle:u,min:d,max:f,startPoint:p,reverse:m,handle:h,defaultHandle:g}=this,_=h||g,{sValue:v,dragging:y}=this,b=this.calcOffset(v),x=_({class:`${e}-handle`,prefixCls:e,vertical:t,offset:b,value:v,dragging:y,disabled:r,min:d,max:f,reverse:m,index:0,tabindex:s,ariaLabel:c,ariaLabelledBy:l,ariaValueTextFormatter:u,style:o[0]||o,ref:e=>this.saveHandle(0,e),onFocus:this.onFocus,onBlur:this.onBlur}),S=p===void 0?0:this.calcOffset(p),C=a[0]||a;return{tracks:this.getTrack({prefixCls:e,reverse:m,vertical:t,included:n,offset:S,minimumTrackStyle:i,mergedTrackStyle:C,length:b-S}),handles:x}}}}),c=a.default(s);exports.default=c;