import{t as O,N as E,aG as h,d as N,R as g,y as T,Z as y,a_ as m,c as I,E as R,am as S,D as _}from"./index.5f7ffb46.js";import{s as A,f as B,p as G,a as u,g as K}from"./utils.0f86fc1f.js";import{P as U}from"./index.de1f78a6.js";const x=new Date().getFullYear(),[Z]=O("date-picker"),$=E({},A,{columnsType:{type:Array,default:()=>["year","month","day"]},minDate:{type:Date,default:()=>new Date(x-10,0,1),validator:h},maxDate:{type:Date,default:()=>new Date(x+10,11,31),validator:h}});var b=N({name:Z,props:$,emits:["confirm","cancel","change","update:modelValue"],setup(a,{emit:r,slots:v}){const n=g(a.modelValue),l=g(!1),M=()=>{const e=a.minDate.getFullYear(),t=a.maxDate.getFullYear();return u(e,t,"year",a.formatter,a.filter)},i=e=>e===a.minDate.getFullYear(),d=e=>e===a.maxDate.getFullYear(),Y=e=>e===a.minDate.getMonth()+1,V=e=>e===a.maxDate.getMonth()+1,s=e=>{const{minDate:t,columnsType:o}=a,c=o.indexOf(e),f=l.value?a.modelValue[c]:n.value[c];if(f)return+f;switch(e){case"year":return t.getFullYear();case"month":return t.getMonth()+1;case"day":return t.getDate()}},P=()=>{const e=s("year"),t=i(e)?a.minDate.getMonth()+1:1,o=d(e)?a.maxDate.getMonth()+1:12;return u(t,o,"month",a.formatter,a.filter)},k=()=>{const e=s("year"),t=s("month"),o=i(e)&&Y(t)?a.minDate.getDate():1,c=d(e)&&V(t)?a.maxDate.getDate():K(e,t);return u(o,c,"day",a.formatter,a.filter)},D=T(()=>a.columnsType.map(e=>{switch(e){case"year":return M();case"month":return P();case"day":return k();default:throw new Error(`[Vant] DatePicker: unsupported columns type: ${e}`)}}));y(n,e=>{m(e,a.modelValue)||r("update:modelValue",e)}),y(()=>a.modelValue,(e,t)=>{l.value=m(t,n.value),e=B(e,D.value),m(e,n.value)||(n.value=e),l.value=!1},{immediate:!0});const C=(...e)=>r("change",...e),F=(...e)=>r("cancel",...e),w=(...e)=>r("confirm",...e);return()=>I(U,R({modelValue:n.value,"onUpdate:modelValue":e=>n.value=e,columns:D.value,onChange:C,onCancel:F,onConfirm:w},S(a,G)),v)}});const H=_(b);export{H as D};