"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("vue"),F=require("../_util/classNames.js"),P=require("../_util/hooks/useMergedState.js"),E=require("../config-provider/hooks/useConfigInject.js"),G=require("../locale/LocaleReceiver.js"),J=require("../vc-picker/PickerPanel.js");require("../vc-trigger/Trigger.js");require("../_util/vue-types/index.js");require("../_util/raf.js");require("../vc-picker/panels/DecadePanel/index.js");const K=require("./Header.js"),Q=require("../date-picker/locale/en_US.js"),W=require("./style/index.js");function X(t){function S(r,d){return r&&d&&t.getYear(r)===t.getYear(d)}function m(r,d){return S(r,d)&&t.getMonth(r)===t.getMonth(d)}function C(r,d){return m(r,d)&&t.getDate(r)===t.getDate(d)}const f=n.defineComponent({name:"ACalendar",inheritAttrs:!1,props:{prefixCls:String,locale:{type:Object,default:void 0},validRange:{type:Array,default:void 0},disabledDate:{type:Function,default:void 0},dateFullCellRender:{type:Function,default:void 0},dateCellRender:{type:Function,default:void 0},monthFullCellRender:{type:Function,default:void 0},monthCellRender:{type:Function,default:void 0},headerRender:{type:Function,default:void 0},value:{type:[Object,String],default:void 0},defaultValue:{type:[Object,String],default:void 0},mode:{type:String,default:void 0},fullscreen:{type:Boolean,default:void 0},onChange:{type:Function,default:void 0},"onUpdate:value":{type:Function,default:void 0},onPanelChange:{type:Function,default:void 0},onSelect:{type:Function,default:void 0},valueFormat:{type:String,default:void 0}},slots:Object,setup(r,{emit:d,slots:i,attrs:V}){const l=r,{prefixCls:s,direction:A}=E.default("picker",l),[I,O]=W.default(s),o=n.computed(()=>`${s.value}-calendar`),h=e=>l.valueFormat?t.toString(e,l.valueFormat):e,M=n.computed(()=>l.value?l.valueFormat?t.toDate(l.value,l.valueFormat):l.value:l.value===""?void 0:l.value),L=n.computed(()=>l.defaultValue?l.valueFormat?t.toDate(l.defaultValue,l.valueFormat):l.defaultValue:l.defaultValue===""?void 0:l.defaultValue),[c,k]=P.default(()=>M.value||t.getNow(),{defaultValue:L.value,value:M}),[p,T]=P.default("month",{value:n.toRef(l,"mode")}),v=n.computed(()=>p.value==="year"?"month":"date"),Y=n.computed(()=>e=>(l.validRange?t.isAfter(l.validRange[0],e)||t.isAfter(e,l.validRange[1]):!1)||!!l.disabledDate?.(e)),$=(e,u)=>{d("panelChange",h(e),u)},_=e=>{if(k(e),!C(e,c.value)){(v.value==="date"&&!m(e,c.value)||v.value==="month"&&!S(e,c.value))&&$(e,p.value);const u=h(e);d("update:value",u),d("change",u)}},q=e=>{T(e),$(c.value,e)},g=(e,u)=>{_(e),d("select",h(e),{source:u})},w=n.computed(()=>{const{locale:e}=l,u={...Q.default,...e};return u.lang={...u.lang,...(e||{}).lang},u}),[R]=G.useLocaleReceiver("Calendar",w);return()=>{const e=t.getNow(),{dateFullCellRender:u=i?.dateFullCellRender,dateCellRender:N=i?.dateCellRender,monthFullCellRender:b=i?.monthFullCellRender,monthCellRender:D=i?.monthCellRender,headerRender:j=i?.headerRender,fullscreen:y=!0,validRange:H}=l,U=({current:a})=>u?u({current:a}):n.createVNode("div",{class:F.default(`${s.value}-cell-inner`,`${o.value}-date`,{[`${o.value}-date-today`]:C(e,a)})},[n.createVNode("div",{class:`${o.value}-date-value`},[String(t.getDate(a)).padStart(2,"0")]),n.createVNode("div",{class:`${o.value}-date-content`},[N&&N({current:a})])]),z=({current:a},x)=>{if(b)return b({current:a});const B=x.shortMonths||t.locale.getShortMonths(x.locale);return n.createVNode("div",{class:F.default(`${s.value}-cell-inner`,`${o.value}-date`,{[`${o.value}-date-today`]:m(e,a)})},[n.createVNode("div",{class:`${o.value}-date-value`},[B[t.getMonth(a)]]),n.createVNode("div",{class:`${o.value}-date-content`},[D&&D({current:a})])])};return I(n.createVNode("div",{...V,class:F.default(o.value,{[`${o.value}-full`]:y,[`${o.value}-mini`]:!y,[`${o.value}-rtl`]:A.value==="rtl"},V.class,O.value)},[j?j({value:c.value,type:p.value,onChange:a=>{g(a,"customize")},onTypeChange:q}):n.createVNode(K.default,{prefixCls:o.value,value:c.value,generateConfig:t,mode:p.value,fullscreen:y,locale:R.value.lang,validRange:H,onChange:g,onModeChange:q},null),n.createVNode(J.default,{value:c.value,prefixCls:s.value,locale:R.value.lang,generateConfig:t,dateRender:U,monthCellRender:a=>z(a,R.value.lang),onSelect:a=>{g(a,v.value)},mode:v.value,picker:v.value,disabledDate:Y.value,hideHeader:!0},null)]))}}});return f.install=function(r){return r.component(f.name,f),r},f}exports.default=X;
