drill.define(async e=>{await e("./p-input.css"),$.register({tag:"p-input",data:{value:null,colorInputValue:null,mainInputValue:null,selectValue:null,rangeValue:null,min:null,max:null,type:null,step:1,maxlength:null,placeholder:""},props:["min","max","type","value","step","maxlength"],attrs:["placeholder"],temp:'\n        <div class="range_con">\n            <div class="range_line">\n                <div class="range_line_inner" xv-tar="rangeLine" style="width:50%;">\n                    <div class="range_mark" xv-tar="rangeMark"></div>\n                </div>\n            </div>\n        </div>\n        <div class="input_con"><input type="text" xv-tar="mainInput" xv-module="mainInputValue" /></div>\n        <div class="p_input_jiao">▾</div>\n        <select xv-content xv-module="selectValue"></select>\n        <div class="colorMarkBg">\n            <div class="color_mark" xv-tar="colorMark">\n                <input type="color" xv-tar="colorInput" />\n            </div>\n        </div>\n        <div class="p-input-mask"></div>\n        ',watch:{placeholder(e,t){this.$mainInput.attr("placeholder",t)},value(e){let{val:t}=e;switch(this.type){case"select":this.selectValue=t;break;case"color":this.colorInputValue=t,this.mainInputValue=t;break;case"range":this.rangeValue=t,this.mainInputValue=t;break;default:this.mainInputValue=t}},mainInputValue(e){let{val:t}=e;if(null!==t)switch(this.type){case"select":break;default:this.value=t}},colorInputValue(e){let{val:t}=e;null!==t&&(/#.{6}/.test(t)&&(this.$colorInput.ele.value=t),this.$colorMark.style["background-color"]=t,"color"==this.type&&(this.value=t))},selectValue(e){let{val:t}=e;if(null===t)return;this.value=t;let a=this.ele.querySelector(`option[value="${t}"]`);this.mainInputValue=a?a.innerText:t},rangeValue(e){let{val:t}=e;if(null!==t&&(0==(t=parseFloat(t))||t)){let e=this.max-this.min,a=(t-this.min)/e*100;a>100?a=100:a<0&&(a=0),this.$rangeLine.style.width=a+"%",this.value=t}},maxlength(e,t){t&&this.$mainInput.attr("maxlength",t)}},inited(){switch(this.type){case"range":let e,t,a,l=this.max-this.min,n=n=>{let i=n.originalEvent.clientX-e,s=t+l*(i/a);(s-=s%parseFloat(this.step))<this.min?s=this.min:s>this.max&&(s=this.max),this.rangeValue=s},i=t=>{this.$rangeMark.class.remove("bigit"),this.$rangeMark.off("mousemove",n),this.$rangeMark.off("mouseup",i),a=e=0};this.$rangeMark.on("mousedown",s=>{t=this.$rangeLine.width/this.$rangeLine.parent.width*l+parseFloat(this.min),t-=t%parseFloat(this.step),e=s.originalEvent.clientX,a=this.$rangeLine.parent.width,this.$rangeMark.class.add("bigit"),this.$rangeMark.on("mousemove",n),this.$rangeMark.on("mouseup",i)});break;case"color":this.$colorInput.on("change",e=>{this.colorInputValue=this.$colorInput.ele.value})}}})});