"use strict";const t=require("../../../../common/vendor.js"),e={name:"u-number-box",mixins:[t.mpMixin,t.mixin,t.props$3],data:()=>({currentValue:"",longPressTimer:null}),watch:{watchChange(t){this.check()},modelValue:{handler:function(t,e){t!==this.currentValue&&(this.currentValue=this.format(this.modelValue))},immediate:!0}},computed:{getCursorSpacing(){return t.getPx(this.cursorSpacing)},buttonStyle(){return e=>{const i={backgroundColor:this.bgColor,height:t.addUnit(this.buttonSize),color:this.color};return this.isDisabled(e)&&(i.backgroundColor="#f7f8fa"),i}},inputStyle(){this.disabled||this.disabledInput;return{color:this.color,backgroundColor:this.bgColor,height:t.addUnit(this.buttonSize),width:t.addUnit(this.inputWidth)}},watchChange(){return[this.integer,this.decimalLength,this.min,this.max]},isDisabled(){return t=>"plus"===t?this.disabled||this.disablePlus||this.currentValue>=this.max:this.disabled||this.disableMinus||this.currentValue<=this.min}},mounted(){this.init()},emits:["update:modelValue","focus","blur","overlimit","change","plus","minus"],methods:{init(){this.currentValue=this.format(this.modelValue)},format(t){return t=""===(t=this.filter(t))?0:+t,t=Math.max(Math.min(this.max,t),this.min),null!==this.decimalLength&&(t=t.toFixed(this.decimalLength)),t},filter(t){return t=String(t).replace(/[^0-9.-]/g,""),this.integer&&-1!==t.indexOf(".")&&(t=t.split(".")[0]),t},check(){const t=this.format(this.currentValue);t!==this.currentValue&&(this.currentValue=t,this.emitChange(t))},onFocus(t){this.$emit("focus",{...t.detail,name:this.name})},onBlur(t){this.format(t.detail.value),this.$emit("blur",{...t.detail,name:this.name})},onInput(t){const{value:e=""}=t.detail||{};if(""===e)return;let i=this.filter(e);if(null!==this.decimalLength&&-1!==i.indexOf(".")){const t=i.split(".");i=`${t[0]}.${t[1].slice(0,this.decimalLength)}`}return i=this.format(i),this.emitChange(i),i},emitChange(t){this.asyncChange||this.$nextTick((()=>{this.$emit("update:modelValue",t),this.currentValue=t,this.$forceUpdate()})),this.$emit("change",{value:t,name:this.name})},onChange(){const{type:t}=this;if(this.isDisabled(t))return this.$emit("overlimit",t);const e="minus"===t?-this.step:+this.step,i=this.format(this.add(+this.currentValue,e));this.emitChange(i),this.$emit(t)},add(t,e){const i=Math.pow(10,10);return Math.round((t+e)*i)/i},clickHandler(t){this.type=t,this.onChange()},longPressStep(){this.clearTimeout(),this.longPressTimer=setTimeout((()=>{this.onChange(),this.longPressStep()}),250)},onTouchStart(t){this.longPress&&(this.clearTimeout(),this.type=t,this.longPressTimer=setTimeout((()=>{this.onChange(),this.longPressStep()}),600))},onTouchEnd(){this.longPress&&this.clearTimeout()},clearTimeout(){clearTimeout(this.longPressTimer),this.longPressTimer=null}}};if(!Array){t.resolveComponent("u-icon")()}Math;const i=t._export_sfc(e,[["render",function(e,i,s,n,o,l){return t.e({a:e.showMinus&&e.$slots.minus},e.showMinus&&e.$slots.minus?{b:t.o((t=>l.clickHandler("minus"))),c:t.o((t=>l.onTouchStart("minus"))),d:t.o(((...t)=>l.clearTimeout&&l.clearTimeout(...t)))}:e.showMinus?{f:t.p({name:"minus",color:l.isDisabled("minus")?"#c8c9cc":"#323233",size:"15",bold:!0,customStyle:e.iconStyle}),g:t.o((t=>l.clickHandler("minus"))),h:t.o((t=>l.onTouchStart("minus"))),i:t.o(((...t)=>l.clearTimeout&&l.clearTimeout(...t))),j:l.isDisabled("minus")?1:"",k:t.s(l.buttonStyle("minus"))}:{},{e:e.showMinus,l:e.disabledInput||e.disabled,m:l.getCursorSpacing,n:e.disabled||e.disabledInput?1:"",o:o.currentValue,p:t.o(((...t)=>l.onBlur&&l.onBlur(...t))),q:t.o(((...t)=>l.onFocus&&l.onFocus(...t))),r:t.o(((...t)=>l.onInput&&l.onInput(...t))),s:t.s(l.inputStyle),t:e.showPlus&&e.$slots.plus},e.showPlus&&e.$slots.plus?{v:t.o((t=>l.clickHandler("plus"))),w:t.o((t=>l.onTouchStart("plus"))),x:t.o(((...t)=>l.clearTimeout&&l.clearTimeout(...t)))}:e.showPlus?{z:t.p({name:"plus",color:l.isDisabled("plus")?"#c8c9cc":"#323233",size:"15",bold:!0,customStyle:e.iconStyle}),A:t.o((t=>l.clickHandler("plus"))),B:t.o((t=>l.onTouchStart("plus"))),C:t.o(((...t)=>l.clearTimeout&&l.clearTimeout(...t))),D:l.isDisabled("plus")?1:"",E:t.s(l.buttonStyle("plus"))}:{},{y:e.showPlus})}],["__scopeId","data-v-ecdcf10d"]]);wx.createComponent(i);
