import{ac as Y,ab as E,bJ as k,a0 as S,c as T,bK as x,d as I,r as v,e as K,w as M,bG as f,a as N,h as j,ae as B,k as G}from"./index-521a9826.js";import{p as P,P as J}from"./index-673d3e97.js";const R=Y({},P,{modelValue:E(),filter:Function,formatter:{type:Function,default:(t,n)=>n}}),U=Object.keys(P);function Z(t,n){if(t<0)return[];const c=Array(t);let a=-1;for(;++a32-new Date(t,n-1,32).getDate(),D=(t,n,c,a,r,s)=>{const l=Z(n-t+1,m=>{const i=k(t+m);return a(c,{text:i,value:i})});return r?r(c,l,s):l},$=(t,n)=>t.map((c,a)=>{const r=n[a];if(r.length){const s=+r[0].value,l=+r[r.length-1].value;return k(S(+c,s,l))}return c}),V=new Date().getFullYear(),[q]=T("date-picker"),z=Y({},R,{columnsType:{type:Array,default:()=>["year","month","day"]},minDate:{type:Date,default:()=>new Date(V-10,0,1),validator:x},maxDate:{type:Date,default:()=>new Date(V+10,11,31),validator:x}});var H=I({name:q,props:z,emits:["confirm","cancel","change","update:modelValue"],setup(t,{emit:n,slots:c}){const a=v(t.modelValue),r=v(!1),s=()=>{const e=t.minDate.getFullYear(),o=t.maxDate.getFullYear();return D(e,o,"year",t.formatter,t.filter)},l=e=>e===t.minDate.getFullYear(),m=e=>e===t.maxDate.getFullYear(),i=e=>e===t.minDate.getMonth()+1,w=e=>e===t.maxDate.getMonth()+1,h=e=>{const{minDate:o,columnsType:u}=t,d=u.indexOf(e),y=r.value?t.modelValue[d]:a.value[d];if(y)return+y;switch(e){case"year":return o.getFullYear();case"month":return o.getMonth()+1;case"day":return o.getDate()}},F=()=>{const e=h("year"),o=l(e)?t.minDate.getMonth()+1:1,u=m(e)?t.maxDate.getMonth()+1:12;return D(o,u,"month",t.formatter,t.filter)},C=()=>{const e=h("year"),o=h("month"),u=l(e)&&i(o)?t.minDate.getDate():1,d=m(e)&&w(o)?t.maxDate.getDate():_(e,o);return D(u,d,"day",t.formatter,t.filter)},g=K(()=>t.columnsType.map(e=>{switch(e){case"year":return s();case"month":return F();case"day":return C();default:throw new Error(`[Vant] DatePicker: unsupported columns type: ${e}`)}}));M(a,e=>{f(e,t.modelValue)||n("update:modelValue",e)}),M(()=>t.modelValue,(e,o)=>{r.value=f(o,a.value),e=$(e,g.value),f(e,a.value)||(a.value=e),r.value=!1},{immediate:!0});const O=(...e)=>n("change",...e),b=(...e)=>n("cancel",...e),A=(...e)=>n("confirm",...e);return()=>N(J,j({modelValue:a.value,"onUpdate:modelValue":e=>a.value=e,columns:g.value,onChange:O,onCancel:b,onConfirm:A},B(t,U)),c)}});const W=G(H);export{W as D};