"use strict";const e=require("./props.js"),n=require("../../libs/mixin/mpMixin.js"),t=require("../../libs/mixin/mixin.js"),i=require("../../libs/function/index.js"),s=require("../../libs/function/test.js"),o=require("../../../../common/vendor.js"),l={name:"u-picker",mixins:[n.mpMixin,t.mixin,e.props],data:()=>({lastIndex:[],innerIndex:[],innerColumns:[],columnIndex:0}),watch:{defaultIndex:{immediate:!0,handler(e){this.setIndexs(e,!0)}},columns:{immediate:!0,deep:!0,handler(e){this.setColumns(e)}}},emits:["close","cancel","confirm","change"],methods:{addUnit:i.addUnit,testArray:s.test.array,getItemText(e){return s.test.object(e)?e[this.keyName]:e},closeHandler(){this.closeOnClickOverlay&&this.$emit("close")},cancel(){this.$emit("cancel")},confirm(){this.$emit("confirm",{indexs:this.innerIndex,value:this.innerColumns.map(((e,n)=>e[this.innerIndex[n]])),values:this.innerColumns})},changeHandler(e){const{value:n}=e.detail;let t=0,i=0;for(let o=0;o<n.length;o++){let e=n[o];if(e!==(this.lastIndex[o]||0)){i=o,t=e;break}}this.columnIndex=i;const s=this.innerColumns;this.setLastIndex(n),this.setIndexs(n),this.$emit("change",{value:this.innerColumns.map(((e,t)=>e[n[t]])),index:t,indexs:n,values:s,columnIndex:i})},setIndexs(e,n){this.innerIndex=i.deepClone(e),n&&this.setLastIndex(e)},setLastIndex(e){this.lastIndex=i.deepClone(e)},setColumnValues(e,n){this.innerColumns.splice(e,1,n),this.setLastIndex(this.innerIndex.slice(0,e));let t=i.deepClone(this.innerIndex);for(let i=0;i<this.innerColumns.length;i++)i>this.columnIndex&&(t[i]=0);this.setIndexs(t)},getColumnValues(e){return(async()=>{await i.sleep()})(),this.innerColumns[e]},setColumns(e){this.innerColumns=i.deepClone(e),0===this.innerIndex.length&&(this.innerIndex=new Array(e.length).fill(0))},getIndexs(){return this.innerIndex},getValues(){return(async()=>{await i.sleep()})(),this.innerColumns.map(((e,n)=>e[this.innerIndex[n]]))}}};if(!Array){(o.resolveComponent("u-toolbar")+o.resolveComponent("u-loading-icon")+o.resolveComponent("u-popup"))()}Math||((()=>"../u-toolbar/u-toolbar.js")+(()=>"../u-loading-icon/u-loading-icon.js")+(()=>"../u-popup/u-popup.js"))();const r=o._export_sfc(l,[["render",function(e,n,t,i,s,l){return o.e({a:e.showToolbar},e.showToolbar?{b:o.o(l.cancel),c:o.o(l.confirm),d:o.p({cancelColor:e.cancelColor,confirmColor:e.confirmColor,cancelText:e.cancelText,confirmText:e.confirmText,title:e.title})}:{},{e:o.f(s.innerColumns,((n,t,i)=>o.e({a:l.testArray(n)},l.testArray(n)?{b:o.f(n,((e,n,i)=>({a:o.t(l.getItemText(e)),b:n,c:n===s.innerIndex[t]?"bold":"normal"}))),c:l.addUnit(e.itemHeight),d:l.addUnit(e.itemHeight)}:{},{e:t}))),f:`height: ${l.addUnit(e.itemHeight)}`,g:s.innerIndex,h:e.immediateChange,i:`${l.addUnit(e.visibleItemCount*e.itemHeight)}`,j:o.o(((...e)=>l.changeHandler&&l.changeHandler(...e))),k:e.loading},e.loading?{l:o.p({mode:"circle"})}:{},{m:o.o(l.closeHandler),n:o.p({show:e.show,mode:e.popupMode})})}],["__scopeId","data-v-299ac2e6"]]);wx.createComponent(r);
