"use strict";var e=Object.defineProperty,n=Object.defineProperties,t=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,r=(n,t,l)=>t in n?e(n,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):n[t]=l;const u=require("../../../../common/vendor.js");if(!Array){u.resolveComponent("wd-loading")()}Math;const i=u.defineComponent((c=((e,n)=>{for(var t in n||(n={}))a.call(n,t)&&r(e,t,n[t]);if(l)for(var t of l(n))o.call(n,t)&&r(e,t,n[t]);return e})({},{name:"wd-picker-view",options:{virtualHost:!0,addGlobalClass:!0,styleIsolation:"shared"}}),s={props:u.pickerViewProps,emits:["change","pickstart","pickend","update:modelValue"],setup(e,{expose:n,emit:t}){const l=e,a=t,o=u.ref([]),r=u.ref(35),i=u.ref([]);u.watch([()=>l.modelValue,()=>l.columns],((e,n)=>{u.isEqual(n[1],e[1])||(o.value=u.formatArray(e[1],l.valueKey,l.labelKey)),!u.isEqual(n[0],e[0])&&u.isDef(e[0])&&function(e){if(0===o.value.length)return;(""===e||!u.isDef(e)||u.isArray(e)&&0===e.length)&&(e=o.value.map((e=>e[0][l.valueKey])));const n=u.getType(e);["string","number","boolean","array"].indexOf(n),e=(e=u.isArray(e)?e:[e]).slice(0,o.value.length);let t=u.deepClone(i.value);e.forEach(((e,n)=>{let a=o.value[n].findIndex((n=>n[l.valueKey].toString()===e.toString()));a=-1===a?0:a,t=s(n,a,t)})),i.value=t.slice(0,e.length)}(e[0])}),{deep:!0,immediate:!0});const{proxy:c}=u.getCurrentInstance();function s(e,n,t){const l=o.value[e];if(!l||!l[n])throw Error(`The value to select with Col:${e} Row:${n} is incorrect`);const a=u.deepClone(t);if(a[e]=n,l[n].disabled){const t=l.slice(0,n).reverse().findIndex((e=>!e.disabled)),o=l.slice(n+1).findIndex((e=>!e.disabled));-1!==t?a[e]=n-1-t:-1!==o?a[e]=n+1+o:void 0===a[e]&&(a[e]=0)}return a}function d({detail:{value:e}}){const n=function(e){e=e.slice(0,o.value.length);const n=u.deepClone(i.value);let t=u.deepClone(i.value);e.forEach(((e,l)=>{(e=u.range(e,0,o.value[l].length-1))!==n[l]&&(t=s(l,e,t))}));const l=function(e,n){if(!e||!n)return-1;const t=e.findIndex(((e,t)=>e!==n[t]));return t}(t,n);if(-1===l)return;const a=t[l];return 1===t.length?a:l}(e=e.map((e=>Number(e||0))));i.value=u.deepClone(e),u.nextTick$1((()=>{i.value=function(e){let n=u.deepClone(e);return e.forEach(((e,t)=>{e=u.range(e,0,o.value[t].length-1),n=s(t,e,n)})),n}(e),l.columnChange?l.columnChange.length<4?(l.columnChange(c.$.exposed,v(),n||0,(()=>{})),p(n||0)):l.columnChange(c.$.exposed,v(),n||0,(()=>{p(n||0)})):p(n||0)}))}function p(e){const n=f();u.isEqual(n,l.modelValue)||(a("update:modelValue",n),setTimeout((()=>{a("change",{picker:c.$.exposed,value:n,index:e})}),0))}function v(){const e=i.value.map(((e,n)=>o.value[n][e]));return 1===e.length?e[0]:e}function f(){const{valueKey:e}=l,n=i.value.map(((n,t)=>o.value[t][n][e]));return 1===n.length?n[0]:n}function m(){a("pickstart")}function g(){a("pickend")}return n({getSelects:v,getValues:f,setColumnData:function(e,n,t=0){o.value[e]=u.formatArray(n,l.valueKey,l.labelKey).reduce(((e,n)=>e.concat(n)),[]),i.value=s(e,t,i.value)},getColumnsData:function(){return u.deepClone(o.value)},getColumnData:function(e){return o.value[e]},getColumnIndex:function(e){return i.value[e]},getLabels:function(){const{labelKey:e}=l;return i.value.map(((n,t)=>o.value[t][n][e]))},getSelectedIndex:function(){return i.value}}),(e,n)=>u.e({a:e.loading},e.loading?{b:u.p({color:e.loadingColor})}:{},{c:u.f(o.value,((n,t,l)=>({a:u.f(n,((n,l,a)=>({a:u.t(n[e.labelKey]),b:l,c:u.n(`wd-picker-view-column__item ${n.disabled?"wd-picker-view-column__item--disabled":""} ${i.value[t]==l?"wd-picker-view-column__item--active":""}`)}))),b:t}))),d:u.s(`line-height: ${r.value}px;`),e:`height: ${r.value}px;`,f:u.s(`height: ${e.columnsHeight-20}px;`),g:i.value,h:e.immediateChange,i:u.o(d),j:u.o(m),k:u.o(g),l:u.s(`height: ${e.columnsHeight-20}px;`),m:u.n(`wd-picker-view ${e.customClass}`),n:u.s(e.customStyle)})}},n(c,t(s))));var c,s;const d=u._export_sfc(i,[["__scopeId","data-v-79ba07d7"]]);wx.createComponent(d);