import{__decorate}from"tslib";import{SuperComponent,wxComponent}from"../common/src/index";import config from"../common/config";import props from"./props";import useCustomNavbar from"../mixins/using-custom-navbar";const{prefix:prefix}=config,name=`${prefix}-picker`;let Picker=class extends SuperComponent{constructor(){super(...arguments),this.behaviors=[useCustomNavbar],this.properties=props,this.externalClasses=[`${prefix}-class`,`${prefix}-class-confirm`,`${prefix}-class-cancel`,`${prefix}-class-title`],this.options={multipleSlots:!0},this.relations={"../picker-item/picker-item":{type:"child",linked(){this.updateChildren()}}},this.observers={"value, visible"(e,t){t&&(this.updateChildren(),this.updateIndicatorPosition())},"itemHeight, visibleItemCount"(){this.updateIndicatorPosition()}},this.data={prefix:prefix,classPrefix:name,defaultPopUpProps:{},defaultPopUpzIndex:11500,indicatorTop:72},this.methods={updateChildren(){const{value:e,defaultValue:t,itemHeight:i,visibleItemCount:s}=this.properties;this.$children.forEach((o,n)=>{var r,l;o.setData({value:null!==(l=null!==(r=null==e?void 0:e[n])&&void 0!==r?r:null==t?void 0:t[n])&&void 0!==l?l:"",columnIndex:n,itemHeight:i,visibleItemCount:s}),o.update()})},getSelectedValue(){return[this.$children.map(e=>e._selectedValue),this.$children.map(e=>e._selectedLabel)]},getColumnIndexes(){return this.$children.map((e,t)=>({column:t,index:e._selectedIndex}))},onConfirm(){const e=[],t=[],i=[];this.$children.forEach((s,o)=>{const n=s.getCurrentSelected();e.push(n.value),t.push(n.label),i.push({column:o,index:n.index})}),this.close("confirm-btn"),this.triggerEvent("confirm",{value:e,label:t,columns:i}),JSON.stringify(this.data.value)!==JSON.stringify(e)&&this.triggerEvent("change",{value:e,label:t,columns:i})},triggerColumnChange({column:e,index:t}){const[i,s]=this.getSelectedValue();this.triggerEvent("pick",{value:i,label:s,column:e,index:t})},onCancel(){this.close("cancel-btn"),this.triggerEvent("cancel")},onPopupChange(e){const{visible:t}=e.detail;this.close("overlay"),this.triggerEvent("visible-change",{visible:t})},close(e){this.data.autoClose&&this.setData({visible:!1}),this.triggerEvent("close",{trigger:e})},updateIndicatorPosition(){const{itemHeight:e,visibleItemCount:t}=this.properties,i=(t-1)/2*e;this.setData({indicatorTop:i})}}}ready(){this.$children.map((e,t)=>e.columnIndex=t),this.updateIndicatorPosition()}};Picker=__decorate([wxComponent()],Picker);export default Picker;