"use strict";const uni_modules_uviewPlus_components_uPicker_props=require("./props.js");const uni_modules_uviewPlus_libs_mixin_mpMixin=require("../../libs/mixin/mpMixin.js");const uni_modules_uviewPlus_libs_mixin_mixin=require("../../libs/mixin/mixin.js");const uni_modules_uviewPlus_libs_function_index=require("../../libs/function/index.js");const uni_modules_uviewPlus_libs_function_test=require("../../libs/function/test.js");const common_vendor=require("../../../../common/vendor.js");const _sfc_main={name:"u-picker",mixins:[uni_modules_uviewPlus_libs_mixin_mpMixin.mpMixin,uni_modules_uviewPlus_libs_mixin_mixin.mixin,uni_modules_uviewPlus_components_uPicker_props.props],data(){return{lastIndex:[],innerIndex:[],innerColumns:[],columnIndex:0}},watch:{defaultIndex:{immediate:true,handler(n){this.setIndexs(n,true)}},columns:{immediate:true,deep:true,handler(n){this.setColumns(n)}}},emits:["close","cancel","confirm","change"],methods:{addUnit:uni_modules_uviewPlus_libs_function_index.addUnit,testArray:uni_modules_uviewPlus_libs_function_test.test.array,getItemText(item){if(uni_modules_uviewPlus_libs_function_test.test.object(item)){return item[this.keyName]}else{return item}},closeHandler(){if(this.closeOnClickOverlay){this.$emit("close")}},cancel(){this.$emit("cancel")},confirm(){this.$emit("confirm",{indexs:this.innerIndex,value:this.innerColumns.map(((item,index)=>item[this.innerIndex[index]])),values:this.innerColumns})},changeHandler(e){const{value:value}=e.detail;let index=0,columnIndex=0;for(let i=0;i<value.length;i++){let item=value[i];if(item!==(this.lastIndex[i]||0)){columnIndex=i;index=item;break}}this.columnIndex=columnIndex;const values=this.innerColumns;this.setLastIndex(value);this.setIndexs(value);this.$emit("change",{value:this.innerColumns.map(((item,index2)=>item[value[index2]])),index:index,indexs:value,values:values,columnIndex:columnIndex})},setIndexs(index,setLastIndex){this.innerIndex=uni_modules_uviewPlus_libs_function_index.deepClone(index);if(setLastIndex){this.setLastIndex(index)}},setLastIndex(index){this.lastIndex=uni_modules_uviewPlus_libs_function_index.deepClone(index)},setColumnValues(columnIndex,values){this.innerColumns.splice(columnIndex,1,values);this.setLastIndex(this.innerIndex.slice(0,columnIndex));let tmpIndex=uni_modules_uviewPlus_libs_function_index.deepClone(this.innerIndex);for(let i=0;i<this.innerColumns.length;i++){if(i>this.columnIndex){tmpIndex[i]=0}}this.setIndexs(tmpIndex)},getColumnValues(columnIndex){(async()=>{await uni_modules_uviewPlus_libs_function_index.sleep()})();return this.innerColumns[columnIndex]},setColumns(columns){this.innerColumns=uni_modules_uviewPlus_libs_function_index.deepClone(columns);if(this.innerIndex.length===0){this.innerIndex=new Array(columns.length).fill(0)}},getIndexs(){return this.innerIndex},getValues(){(async()=>{await uni_modules_uviewPlus_libs_function_index.sleep()})();return this.innerColumns.map(((item,index)=>item[this.innerIndex[index]]))}}};if(!Array){const _easycom_u_toolbar2=common_vendor.resolveComponent("u-toolbar");const _easycom_u_loading_icon2=common_vendor.resolveComponent("u-loading-icon");const _easycom_u_popup2=common_vendor.resolveComponent("u-popup");(_easycom_u_toolbar2+_easycom_u_loading_icon2+_easycom_u_popup2)()}const _easycom_u_toolbar=()=>"../u-toolbar/u-toolbar.js";const _easycom_u_loading_icon=()=>"../u-loading-icon/u-loading-icon.js";const _easycom_u_popup=()=>"../u-popup/u-popup.js";if(!Math){(_easycom_u_toolbar+_easycom_u_loading_icon+_easycom_u_popup)()}function _sfc_render(_ctx,_cache,$props,$setup,$data,$options){return common_vendor.e({a:_ctx.showToolbar},_ctx.showToolbar?{b:common_vendor.o($options.cancel),c:common_vendor.o($options.confirm),d:common_vendor.p({cancelColor:_ctx.cancelColor,confirmColor:_ctx.confirmColor,cancelText:_ctx.cancelText,confirmText:_ctx.confirmText,title:_ctx.title})}:{},{e:common_vendor.f($data.innerColumns,((item,index,i0)=>common_vendor.e({a:$options.testArray(item)},$options.testArray(item)?{b:common_vendor.f(item,((item1,index1,i1)=>({a:common_vendor.t($options.getItemText(item1)),b:index1,c:index1===$data.innerIndex[index]?"bold":"normal"}))),c:$options.addUnit(_ctx.itemHeight),d:$options.addUnit(_ctx.itemHeight)}:{},{e:index}))),f:`height: ${$options.addUnit(_ctx.itemHeight)}`,g:$data.innerIndex,h:_ctx.immediateChange,i:`${$options.addUnit(_ctx.visibleItemCount*_ctx.itemHeight)}`,j:common_vendor.o(((...args)=>$options.changeHandler&&$options.changeHandler(...args))),k:_ctx.loading},_ctx.loading?{l:common_vendor.p({mode:"circle"})}:{},{m:common_vendor.o($options.closeHandler),n:common_vendor.p({show:_ctx.show,mode:_ctx.popupMode})})}const Component=common_vendor._export_sfc(_sfc_main,[["render",_sfc_render],["__scopeId","data-v-b94a5722"]]);my.createComponent(Component);
