"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("vue"),x=require("../form/FormItemContext.js");require("../radio/index.js");const I=require("../select/index.js"),y=require("../radio/Group.js"),N=require("../radio/RadioButton.js"),R=10,q=20;function S(i){const{fullscreen:d,validRange:o,generateConfig:e,locale:a,prefixCls:n,value:u,onChange:m,divRef:f}=i,g=e.getYear(u||e.getNow());let l=g-R,c=l+q;o&&(l=e.getYear(o[0]),c=e.getYear(o[1])+1);const C=a&&a.year==="年"?"年":"",p=[];for(let t=l;t<c;t++)p.push({label:`${t}${C}`,value:t});return r.createVNode(I.default,{size:d?void 0:"small",options:p,value:g,class:`${n}-year-select`,onChange:t=>{let s=e.setYear(u,t);if(o){const[h,v]=o,M=e.getYear(s),Y=e.getMonth(s);M===e.getYear(v)&&Y>e.getMonth(v)&&(s=e.setMonth(s,e.getMonth(v))),M===e.getYear(h)&&Y<e.getMonth(h)&&(s=e.setMonth(s,e.getMonth(h)))}m(s)},getPopupContainer:()=>f.value},null)}S.inheritAttrs=!1;function V(i){const{prefixCls:d,fullscreen:o,validRange:e,value:a,generateConfig:n,locale:u,onChange:m,divRef:f}=i,g=n.getMonth(a||n.getNow());let l=0,c=11;if(e){const[t,s]=e,h=n.getYear(a);n.getYear(s)===h&&(c=n.getMonth(s)),n.getYear(t)===h&&(l=n.getMonth(t))}const C=u.shortMonths||n.locale.getShortMonths(u.locale),p=[];for(let t=l;t<=c;t+=1)p.push({label:C[t],value:t});return r.createVNode(I.default,{size:o?void 0:"small",class:`${d}-month-select`,value:g,options:p,onChange:t=>{m(n.setMonth(a,t))},getPopupContainer:()=>f.value},null)}V.inheritAttrs=!1;function w(i){const{prefixCls:d,locale:o,mode:e,fullscreen:a,onModeChange:n}=i;return r.createVNode(y.default,{onChange:({target:{value:u}})=>{n(u)},value:e,size:a?void 0:"small",class:`${d}-mode-switch`},{default:()=>[r.createVNode(N.default,{value:"month"},{default:()=>[o.month]}),r.createVNode(N.default,{value:"year"},{default:()=>[o.year]})]})}w.inheritAttrs=!1;const $=r.defineComponent({name:"CalendarHeader",inheritAttrs:!1,props:["mode","prefixCls","value","validRange","generateConfig","locale","mode","fullscreen"],setup(i,{attrs:d}){const o=r.ref(null),e=x.FormItemInputContext.useInject();return x.FormItemInputContext.useProvide(e,{isFormItemInput:!1}),()=>{const a={...i,...d},{prefixCls:n,fullscreen:u,mode:m,onChange:f,onModeChange:g}=a,l={...a,fullscreen:u,divRef:o};return r.createVNode("div",{class:`${n}-header`,ref:o},[r.createVNode(S,{...l,onChange:c=>{f(c,"year")}},null),m==="month"&&r.createVNode(V,{...l,onChange:c=>{f(c,"month")}},null),r.createVNode(w,{...l,onModeChange:g},null)])}}});exports.default=$;
