import{d as M,k as f,r as _,L as E,ai as $,o as k,c as A,a as i,H as S,u as d,I as h,U as R,K as w,D as x,T as I}from"./vue.1RczIYhx.js";import{_ as P}from"./_plugin-vue_export-helper.DlAUqK2U.js";const U={class:"number-range-container"},D=["id"],z={class:"to"},H=["id"],K=M({__name:"index",props:{modelValue:{type:Array,default:()=>[null,null]},minValue:{type:Number,default:null},maxValue:{type:Number,default:null},disabled:{type:Boolean,default:!1},to:{type:String,default:"至"},precision:{type:Number,default:0,validator(l){return l>=0&&l===parseInt(String(l),10)}},valueRange:{type:Array,default:()=>[],validator(l){if(l&&l.length>0){if(l.length!==2)throw new Error("请传入长度为2的Number数组");if(typeof l[0]!="number"||typeof l[1]!="number")throw new Error("取值范围只接受Number类型,请确认");if(l[1]<l[0])throw new Error("valueRange格式须为[最小值,最大值],请确认")}return!0}},slotStyle:{type:String,default:"default"}},emits:["update:modelValue","update:minValue","update:maxValue","change"],setup(l,{emit:F}){const n=l,t=F,s=f({get(){return n.minValue??n.modelValue[0]??null},set(e){t("update:minValue",e),t("update:modelValue",[e,o.value])}}),o=f({get(){return n.maxValue??n.modelValue[1]??null},set(e){t("update:maxValue",e),t("update:modelValue",[s.value,e])}}),B=e=>{if(e===""||e===null||isNaN(e)){t("update:minValue",null);return}if(o.value===""||o.value===null||isNaN(o.value)){t("update:minValue",e),t("update:maxValue",null);return}const a=y(e,n.precision);if(parseFloat(String(a))>parseFloat(String(o.value))){const{min:r,max:u}=m(Number(o.value),a);p(r,u)}else{const{min:r,max:u}=m(a,Number(o.value));p(r,u)}},C=e=>{if(e===""||e===null||isNaN(e)){t("update:maxValue",null);return}if(s.value===""||s.value===null||isNaN(s.value)){t("update:maxValue",e),t("update:minValue",null);return}console.log(e);const a=y(e,n.precision);if(parseFloat(String(a))<parseFloat(String(s.value))){const{min:r,max:u}=m(a,Number(s.value));p(r,u)}else{const{min:r,max:u}=m(Number(s.value),a);p(r,u)}},p=(e,a)=>{t("update:minValue",e),t("update:maxValue",a),t("update:modelValue",[e,a]),t("change",{min:e,max:a})},m=(e,a)=>(n.valueRange&&n.valueRange.length>0&&(e=e<n.valueRange[0]?n.valueRange[0]:e>n.valueRange[1]?n.valueRange[1]:e,a=a>n.valueRange[1]?n.valueRange[1]:a),{min:e,max:a}),g=_(),v=()=>{g.value=!0},N=()=>{g.value=!1},y=(e,a=0)=>parseFloat(String(Math.round(e*Math.pow(10,a))/Math.pow(10,a))),c=E(),V=f(()=>!!(c&&c.prepend)),b=f(()=>!!(c&&c.append));return(e,a)=>{const r=$("el-input-number");return k(),A("div",U,[i("div",{id:d(V)?"prepend":"",class:h({"slot-default":l.slotStyle==="default","slot-pend ":d(V)})},[S(e.$slots,"prepend",{},void 0,!0)],10,D),i("div",{class:h(["number-range",{"is-disabled":l.disabled,"is-focus":d(g),"number-range-left-border-radius-0":d(V),"number-range-right-border-radius-0":d(b)}])},[R(r,w({disabled:l.disabled,placeholder:"最小值",onBlur:N,onFocus:v,onChange:B,modelValue:d(s),"onUpdate:modelValue":a[0]||(a[0]=u=>x(s)?s.value=u:null)},e.$attrs,{controls:!1}),null,16,["disabled","modelValue"]),i("div",z,[i("span",null,I(l.to),1)]),R(r,w({disabled:l.disabled,placeholder:"最大值",onBlur:N,onFocus:v,onChange:C,modelValue:d(o),"onUpdate:modelValue":a[1]||(a[1]=u=>x(o)?o.value=u:null)},e.$attrs,{controls:!1}),null,16,["disabled","modelValue"])],2),i("div",{id:d(b)?"append":"",class:h({"slot-default":l.slotStyle==="default","slot-pend ":d(b)})},[S(e.$slots,"append",{},void 0,!0)],10,H)])}}}),j=P(K,[["__scopeId","data-v-6078c063"]]);export{j as n};
