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