System.register(["./index-legacy.eb062188.js","./index-legacy.ac7c51db.js","./utils-legacy.6e8de97c.js"],(function(e){"use strict";var t,a,o,l,r,n,i,s,u,c,d,f,m,v,p,h,g,y,D,w,b,k,S,x,T,O,M,A,B,R;return{setters:[function(e){t=e.t,a=e.d,o=e.aB,l=e.aC,r=e.y,n=e.c,i=e.aD,s=e.R,u=e.aE,c=e.U,d=e.W,f=e.z,m=e.an,v=e.aF,p=e.am,h=e.u,g=e.v,y=e.w,D=e.aG,w=e.Z,b=e.aH,k=e.P,S=e.aI,x=e.ar,T=e.E,O=e.o,M=e.B,A=e.D},function(e){B=e.u},function(e){R=e.g}],execute:function(){const[C,H,P]=t("calendar");function W(e,t){const a=e.getFullYear(),o=t.getFullYear();if(a===o){const a=e.getMonth(),o=t.getMonth();return a===o?0:a>o?1:-1}return a>o?1:-1}function I(e,t){const a=W(e,t);if(0===a){const a=e.getDate(),o=t.getDate();return a===o?0:a>o?1:-1}return a}const F=e=>new Date(e),Y=e=>Array.isArray(e)?e.map(F):F(e);function j(e,t){const a=F(e);return a.setDate(a.getDate()+t),a}const z=e=>j(e,-1),N=e=>j(e,1),E=()=>{const e=new Date;return e.setHours(0,0,0,0),e},[U]=t("calendar-day");var V=a({name:U,props:{item:o(Object),color:String,index:Number,offset:l(0),rowHeight:String},emits:["click"],setup(e,{emit:t,slots:a}){const o=r((()=>{var t;const{item:a,index:o,color:l,offset:r,rowHeight:n}=e,i={height:n};if("placeholder"===a.type)return i.width="100%",i;if(0===o&&(i.marginLeft=100*r/7+"%"),l)switch(a.type){case"end":case"start":case"start-end":case"multiple-middle":case"multiple-selected":i.background=l;break;case"middle":i.color=l}return r+((null==(t=a.date)?void 0:t.getDate())||1)>28&&(i.marginBottom=0),i})),l=()=>{"disabled"!==e.item.type&&t("click",e.item)},i=()=>{const{topInfo:t}=e.item;if(t||a["top-info"])return n("div",{class:H("top-info")},[a["top-info"]?a["top-info"](e.item):t])},s=()=>{const{bottomInfo:t}=e.item;if(t||a["bottom-info"])return n("div",{class:H("bottom-info")},[a["bottom-info"]?a["bottom-info"](e.item):t])},u=()=>{const{item:t,color:a,rowHeight:o}=e,{type:l,text:r}=t,u=[i(),r,s()];return"selected"===l?n("div",{class:H("selected-day"),style:{width:o,height:o,background:a}},[u]):u};return()=>{const{type:t,className:a}=e.item;return"placeholder"===t?n("div",{class:H("day"),style:o.value},null):n("div",{role:"gridcell",style:o.value,class:[H("day",t),a],tabindex:"disabled"===t?void 0:-1,onClick:l},[u()])}}});const[$]=t("calendar-month"),G={date:o(Date),type:String,color:String,minDate:o(Date),maxDate:o(Date),showMark:Boolean,rowHeight:f,formatter:Function,lazyRender:Boolean,currentDate:[Date,Array],allowSameDay:Boolean,showSubtitle:Boolean,showMonthTitle:Boolean,firstDayOfWeek:Number};var L=a({name:$,props:G,emits:["click"],setup(e,{emit:t,slots:a}){const[o,l]=i(),f=s(),h=s(),g=u(h),y=r((()=>{return t=e.date,P("monthTitle",t.getFullYear(),t.getMonth()+1);var t})),D=r((()=>c(e.rowHeight))),w=r((()=>{const t=e.date.getDay();return e.firstDayOfWeek?(t+7-e.firstDayOfWeek)%7:t})),b=r((()=>R(e.date.getFullYear(),e.date.getMonth()+1))),k=r((()=>o.value||!e.lazyRender)),S=t=>{const{type:a,minDate:o,maxDate:l,currentDate:r}=e;if(I(t,o)<0||I(t,l)>0)return"disabled";if(null===r)return"";if(Array.isArray(r)){if("multiple"===a)return(t=>{const a=t=>e.currentDate.some((e=>0===I(e,t)));if(a(t)){const e=z(t),o=N(t),l=a(e),r=a(o);return l&&r?"multiple-middle":l?"end":r?"start":"multiple-selected"}return""})(t);if("range"===a)return(t=>{const[a,o]=e.currentDate;if(!a)return"";const l=I(t,a);if(!o)return 0===l?"start":"";const r=I(t,o);return e.allowSameDay&&0===l&&0===r?"start-end":0===l?"start":0===r?"end":l>0&&r<0?"middle":""})(t)}else if("single"===a)return 0===I(t,r)?"selected":"";return""},x=t=>{if("range"===e.type){if("start"===t||"end"===t)return P(t);if("start-end"===t)return`${P("start")}/${P("end")}`}},T=()=>{if(e.showMonthTitle)return n("div",{class:H("month-title")},[a["month-title"]?a["month-title"]({date:e.date,text:y.value}):y.value])},O=()=>{if(e.showMark&&k.value)return n("div",{class:H("month-mark")},[e.date.getMonth()+1])},M=r((()=>{const e=Math.ceil((b.value+w.value)/7);return Array(e).fill({type:"placeholder"})})),A=r((()=>{const t=[],a=e.date.getFullYear(),o=e.date.getMonth();for(let l=1;l<=b.value;l++){const r=new Date(a,o,l),n=S(r);let i={date:r,type:n,text:l,bottomInfo:x(n)};e.formatter&&(i=e.formatter(i)),t.push(i)}return t})),B=r((()=>A.value.filter((e=>"disabled"===e.type)))),C=(o,l)=>n(V,{item:o,index:l,color:e.color,offset:w.value,rowHeight:D.value,onClick:e=>t("click",e)},p(a,["top-info","bottom-info"]));return d({getTitle:()=>y.value,getHeight:()=>g.value,setVisible:l,scrollToDate:(e,t)=>{if(f.value){const a=m(f.value),o=M.value.length,l=(Math.ceil((t.getDate()+w.value)/7)-1)*a.height/o;v(e,a.top+l+e.scrollTop-m(e).top)}},disabledDays:B}),()=>n("div",{class:H("month"),ref:h},[T(),n("div",{ref:f,role:"grid",class:H("days")},[O(),(k.value?A:M).value.map(C)])])}});const[Z]=t("calendar-header");var q=a({name:Z,props:{date:Date,title:String,subtitle:String,showTitle:Boolean,showSubtitle:Boolean,firstDayOfWeek:Number},emits:["clickSubtitle"],setup(e,{slots:t,emit:a}){const o=()=>{if(e.showTitle){const a=e.title||P("title"),o=t.title?t.title():a;return n("div",{class:H("header-title")},[o])}},l=e=>a("clickSubtitle",e),r=()=>{if(e.showSubtitle){const a=t.subtitle?t.subtitle({date:e.date,text:e.subtitle}):e.subtitle;return n("div",{class:H("header-subtitle"),onClick:l},[a])}},i=()=>{const{firstDayOfWeek:t}=e,a=P("weekdays"),o=[...a.slice(t,7),...a.slice(0,t)];return n("div",{class:H("weekdays")},[o.map((e=>n("span",{class:H("weekday")},[e])))])};return()=>n("div",{class:H("header")},[o(),r(),i()])}});const J={show:Boolean,type:h("single"),title:String,color:String,round:g,readonly:Boolean,poppable:g,maxRange:y(null),position:h("bottom"),teleport:[String,Object],showMark:g,showTitle:g,formatter:Function,rowHeight:f,confirmText:String,rangePrompt:String,lazyRender:g,showConfirm:g,defaultDate:[Date,Array],allowSameDay:Boolean,showSubtitle:g,closeOnPopstate:g,showRangePrompt:g,confirmDisabledText:String,closeOnClickOverlay:g,safeAreaInsetTop:Boolean,safeAreaInsetBottom:g,minDate:{type:Date,validator:D,default:E},maxDate:{type:Date,validator:D,default:()=>{const e=E();return new Date(e.getFullYear(),e.getMonth()+6,e.getDate())}},firstDayOfWeek:{type:f,default:0,validator:e=>e>=0&&e<=6}};var K=a({name:C,props:J,emits:["select","confirm","unselect","monthShow","overRange","update:show","clickSubtitle"],setup(e,{emit:t,slots:a}){const o=(t,a=e.minDate,o=e.maxDate)=>-1===I(t,a)?a:1===I(t,o)?o:t,l=(t=e.defaultDate)=>{const{type:a,minDate:l,maxDate:r,allowSameDay:n}=e;if(null===t)return t;const i=E();return"range"===a?(Array.isArray(t)||(t=[]),[o(t[0]||i,l,n?r:z(r)),o(t[1]||i,n?l:N(l))]):"multiple"===a?Array.isArray(t)?t.map((e=>o(e))):[o(i)]:(t&&!Array.isArray(t)||(t=i),o(t))};let i;const u=s(),c=s({text:"",date:void 0}),f=s(l()),[v,h]=B(),g=r((()=>e.firstDayOfWeek?+e.firstDayOfWeek%7:0)),y=r((()=>{const t=[],a=new Date(e.minDate);a.setDate(1);do{t.push(new Date(a)),a.setMonth(a.getMonth()+1)}while(1!==W(a,e.maxDate));return t})),A=r((()=>{if(f.value){if("range"===e.type)return!f.value[0]||!f.value[1];if("multiple"===e.type)return!f.value.length}return!f.value})),R=()=>{const e=x(u.value),a=e+i,o=y.value.map(((e,t)=>v.value[t].getHeight()));if(a>o.reduce(((e,t)=>e+t),0)&&e>0)return;let l,r=0;const n=[-1,-1];for(let i=0;i=e&&(n[1]=i,l||(l=s,n[0]=i),v.value[i].showed||(v.value[i].showed=!0,t("monthShow",{date:s.date,title:s.getTitle()}))),r+=o[i]}y.value.forEach(((e,t)=>{const a=t>=n[0]-1&&t<=n[1]+1;v.value[t].setVisible(a)})),l&&(c.value={text:l.getTitle(),date:l.date})},C=e=>{S((()=>{y.value.some(((t,a)=>0===W(t,e)&&(u.value&&v.value[a].scrollToDate(u.value,e),!0))),R()}))},U=()=>{if(!e.poppable||e.show)if(f.value){const t="single"===e.type?f.value:f.value[0];D(t)&&C(t)}else S(R)},V=()=>{e.poppable&&!e.show||(S((()=>{i=Math.floor(m(u).height)})),U())},$=(e=l())=>{f.value=e,U()},G=()=>{var e;return t("confirm",null!=(e=f.value)?e:Y(f.value))},Z=(a,o)=>{const l=e=>{f.value=e,t("select",Y(e))};if(o&&"range"===e.type){const o=(a=>{const{maxRange:o,rangePrompt:l,showRangePrompt:r}=e;return!(o&&function(e){const t=e[0].getTime();return(e[1].getTime()-t)/864e5+1}(a)>+o&&(r&&O(l||P("rangePrompt",o)),t("overRange"),1))})(a);if(!o)return void l([a[0],j(a[0],+e.maxRange-1)])}l(a),o&&!e.showConfirm&&G()},J=r((()=>v.value.reduce(((e,t)=>{var a,o;return e.push(...null!=(o=null==(a=t.disabledDays)?void 0:a.value)?o:[]),e}),[]))),K=a=>{if(e.readonly||!a.date)return;const{date:o}=a,{type:l}=e;if("range"===l){if(!f.value)return void Z([o]);const[t,a]=f.value;if(t&&!a){const a=I(o,t);if(1===a){const e=((e,t,a)=>{var o;return null==(o=e.find((e=>-1===I(t,e.date)&&-1===I(e.date,a))))?void 0:o.date})(J.value,t,o);if(e){const a=z(e);-1===I(t,a)?Z([t,a]):Z([o])}else Z([t,o],!0)}else-1===a?Z([o]):e.allowSameDay&&Z([o,o],!0)}else Z([o])}else if("multiple"===l){if(!f.value)return void Z([o]);const a=f.value,l=a.findIndex((e=>0===I(e,o)));if(-1!==l){const[e]=a.splice(l,1);t("unselect",F(e))}else e.maxRange&&a.length>=+e.maxRange?O(e.rangePrompt||P("rangePrompt",e.maxRange)):Z([...a,o])}else Z(o,!0)},Q=e=>t("update:show",e),X=(t,o)=>{const l=0!==o||!e.showSubtitle;return n(L,T({ref:h(o),date:t,currentDate:f.value,showMonthTitle:l,firstDayOfWeek:g.value},p(e,["type","color","minDate","maxDate","showMark","formatter","rowHeight","lazyRender","showSubtitle","allowSameDay"]),{onClick:K}),p(a,["top-info","bottom-info","month-title"]))},_=()=>{if(a.footer)return a.footer();if(e.showConfirm){const t=a["confirm-text"],o=A.value,l=o?e.confirmDisabledText:e.confirmText;return n(M,{round:!0,block:!0,type:"primary",color:e.color,class:H("confirm"),disabled:o,nativeType:"button",onClick:G},{default:()=>[t?t({disabled:o}):l||P("confirm")]})}},ee=()=>n("div",{class:H()},[n(q,{date:c.value.date,title:e.title,subtitle:c.value.text,showTitle:e.showTitle,showSubtitle:e.showSubtitle,firstDayOfWeek:g.value,onClickSubtitle:e=>t("clickSubtitle",e)},p(a,["title","subtitle"])),n("div",{ref:u,class:H("body"),onScroll:R},[y.value.map(X)]),n("div",{class:[H("footer"),{"van-safe-area-bottom":e.safeAreaInsetBottom}]},[_()])]);return w((()=>e.show),V),w((()=>[e.type,e.minDate,e.maxDate]),(()=>$(l(f.value)))),w((()=>e.defaultDate),((e=null)=>{f.value=e,U()})),d({reset:$,scrollToDate:C,getSelectedDate:()=>f.value}),b(V),()=>e.poppable?n(k,{show:e.show,class:H("popup"),round:e.round,position:e.position,closeable:e.showTitle||e.showSubtitle,teleport:e.teleport,closeOnPopstate:e.closeOnPopstate,safeAreaInsetTop:e.safeAreaInsetTop,closeOnClickOverlay:e.closeOnClickOverlay,"onUpdate:show":Q},{default:ee}):ee()}});e("C",A(K))}}}));