@tongziyang/uni-calendar-plugin
Version:
A comprehensive calendar plugin for uniapp with support for Gregorian and Lunar calendars, date selection, hotel booking, check-in functionality, and more.
2 lines (1 loc) • 49.5 kB
JavaScript
(function(P,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],a):(P=typeof globalThis<"u"?globalThis:P||self,a(P.UniCalendarPlugin={},P.Vue))})(this,function(P,a){"use strict";const O=[19416,19168,42352,21717,53856,55632,91476,22176,39632,21970,19168,42422,42192,53840,119381,46400,54944,44450,38320,84343,18800,42160,46261,27216,27968,109396,11104,38256,21234,18800,25958,54432,59984,28309,23248,11104,100067,37600,116951,51536,54432,120998,46416,22176,107956,9680,37584,53938,43344,46423,27808,46416,86869,19872,42416,83315,21168,43432,59728,27296,44710,43856,19296,43748,42352,21088,62051,55632,23383,22176,38608,19925,19152,42192,54484,53840,54616,46400,46752,103846,38320,18864,43380,42160,45690,27216,27968,44870,43872,38256,19189,18800,25776,29859,59984,27480,21952,43872,38613,37600,51552,55636,54432,55888,30034,22176,43959,9680,37584,51893,43344,46240,47780,44368,21977,19360,42416,86390,21168,43312,31060,27296,44368,23378,19296,42726,42208,53856,60005,54576,23200,30371,38608,19195,19152,42192,118966,53840,54560,56645,46496,22224,21938,18864,42359,42160,43600,111189,27936,44448,84835,37744,18936,18800,25776,92326,59984,27424,108228,43744,41696,53987,51552,54615,54432,55888,23893,22176,42704,21972,21200,43448,43344,46240,46758,44368,21920,43940,42416,21168,45683,26928,29495,27296,44368,84821,19296,42352,21732,53600,59752,54560,55968,92838,22224,19168,43476,41680,53584,62034],ae=["甲","乙","丙","丁","戊","己","庚","辛","壬","癸"],te=["子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥"],ne=["鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪"],z=["正月","二月","三月","四月","五月","六月","七月","八月","九月","十月","冬月","腊月"],le=["初一","初二","初三","初四","初五","初六","初七","初八","初九","初十","十一","十二","十三","十四","十五","十六","十七","十八","十九","二十","廿一","廿二","廿三","廿四","廿五","廿六","廿七","廿八","廿九","三十"],oe={正月初一:"春节",正月十五:"元宵节",二月初二:"龙抬头",五月初五:"端午节",七月初七:"七夕",七月十五:"中元节",八月十五:"中秋节",九月初九:"重阳节",腊月初八:"腊八节",腊月廿三:"小年",腊月三十:"除夕"},re={"01-01":"元旦","02-14":"情人节","03-08":"妇女节","03-12":"植树节","04-01":"愚人节","04-05":"清明节","05-01":"劳动节","05-04":"青年节","06-01":"儿童节","07-01":"建党节","08-01":"建军节","09-10":"教师节","10-01":"国庆节","12-24":"平安夜","12-25":"圣诞节"},se=["小寒","大寒","立春","雨水","惊蛰","春分","清明","谷雨","立夏","小满","芒种","夏至","小暑","大暑","立秋","处暑","白露","秋分","寒露","霜降","立冬","小雪","大雪","冬至"],ie=["0106","0120","0204","0219","0306","0321","0405","0420","0506","0521","0606","0621","0707","0723","0807","0823","0908","0923","1008","1023","1107","1122","1207","1222"];function de(e){e.getFullYear();const t=e.getMonth()+1,l=e.getDate(),i=`${t.toString().padStart(2,"0")}${l.toString().padStart(2,"0")}`,s=ie.findIndex(o=>o===i);return s!==-1&&Math.floor(s/2)+1===t?se[s]:""}function ce(e){let t=348;for(let l=32768;l>8;l>>=1)t+=O[e-1900]&l?1:0;return t+K(e)}function K(e){return Z(e)?O[e-1900]&65536?30:29:0}function Z(e){return O[e-1900]&15}function he(e,t){return O[e-1900]&65536>>t?30:29}function H(e){const t=e.getFullYear(),l=e.getMonth()+1,i=e.getDate();if(t<1900||t>2100)return{lunarYear:"",lunarMonth:"",lunarDay:""};const s=new Date(1900,0,31);let o=Math.floor((e.getTime()-s.getTime())/864e5),n=1900,r=0;for(let y=1900;y<2100&&o>0;y++)r=ce(y),o-=r,n++;o<0&&(o+=r,n--);let c=!1,h=1;const T=Z(n),$=[];let N=0;for(let y=1;y<=12;y++)$.push(he(n,y));T>0&&(N=K(n));let M=o+1,_=1,S=!1;for(let y=1;y<=12;y++){let V=$[y-1];if(M<=V){_=y;break}if(M-=V,y===T){if(M<=N){_=y,S=!0;break}M-=N}}h=_,c=S;const g=M,Y=(n-1900+36)%60,C=ae[Y%10]+te[Y%12];let b=z[h-1];c&&(b="闰"+z[h-1]);const B=le[g-1],f=`${z[h-1]}${B}`,p=oe[f],D=`${l.toString().padStart(2,"0")}-${i.toString().padStart(2,"0")}`,w=re[D],u=de(e);return{lunarYear:`${C}年 ${ne[(n-4)%12]}年`,lunarMonth:b,lunarDay:B,lunarFestival:p,solarFestival:w,solarTerm:u}}const ye=[{name:"春节",startDate:"2024-02-10",endDate:"2024-02-17",isRestDay:!0},{name:"清明节",startDate:"2024-04-04",endDate:"2024-04-06",isRestDay:!0},{name:"劳动节",startDate:"2024-05-01",endDate:"2024-05-05",isRestDay:!0},{name:"端午节",startDate:"2024-06-08",endDate:"2024-06-10",isRestDay:!0},{name:"中秋节",startDate:"2024-09-15",endDate:"2024-09-17",isRestDay:!0},{name:"国庆节",startDate:"2024-10-01",endDate:"2024-10-07",isRestDay:!0},{name:"春节调班",startDate:"2024-02-04",endDate:"2024-02-04",isRestDay:!1},{name:"春节调班",startDate:"2024-02-18",endDate:"2024-02-18",isRestDay:!1},{name:"清明调班",startDate:"2024-04-07",endDate:"2024-04-07",isRestDay:!1},{name:"劳动节调班",startDate:"2024-04-28",endDate:"2024-04-28",isRestDay:!1},{name:"劳动节调班",startDate:"2024-05-11",endDate:"2024-05-11",isRestDay:!1},{name:"中秋调班",startDate:"2024-09-14",endDate:"2024-09-14",isRestDay:!1},{name:"国庆调班",startDate:"2024-09-29",endDate:"2024-09-29",isRestDay:!1},{name:"国庆调班",startDate:"2024-10-12",endDate:"2024-10-12",isRestDay:!1},{name:"元旦",startDate:"2025-01-01",endDate:"2025-01-01",isRestDay:!0},{name:"春节",startDate:"2025-01-28",endDate:"2025-02-04",isRestDay:!0},{name:"清明节",startDate:"2025-04-04",endDate:"2025-04-06",isRestDay:!0},{name:"劳动节",startDate:"2025-05-01",endDate:"2025-05-05",isRestDay:!0},{name:"端午节",startDate:"2025-05-31",endDate:"2025-06-02",isRestDay:!0},{name:"中秋节、国庆节",startDate:"2025-10-01",endDate:"2025-10-08",isRestDay:!0},{name:"春节调班",startDate:"2025-01-26",endDate:"2025-01-26",isRestDay:!1},{name:"春节调班",startDate:"2025-02-08",endDate:"2025-02-08",isRestDay:!1},{name:"劳动节调班",startDate:"2025-04-27",endDate:"2025-04-27",isRestDay:!1},{name:"国庆、中秋调班",startDate:"2025-09-28",endDate:"2025-09-28",isRestDay:!1},{name:"国庆、中秋调班",startDate:"2025-10-11",endDate:"2025-10-11",isRestDay:!1}];function ue(e,t,l){const i=`${e.getFullYear()}-${(e.getMonth()+1).toString().padStart(2,"0")}-${e.getDate().toString().padStart(2,"0")}`;return i>=t&&i<=l}function De(){try{const e=localStorage.getItem("holidayPeriods");if(e)return JSON.parse(e)}catch(e){console.error("Failed to get holiday periods from cache:",e)}return ye}function W(e){e.getFullYear();const t=e.getMonth()+1,l=e.getDate(),i=e.getDay(),s=i===0||i===6;`${t.toString().padStart(2,"0")}${l.toString().padStart(2,"0")}`;const o=H(e),n=!!(o.lunarFestival||o.solarFestival||o.solarTerm),c=De().find(h=>ue(e,h.startDate,h.endDate));return c?c.name.includes("调班")?{name:c.name,isHoliday:!0,isRestDay:c.isRestDay,isHolidayPeriod:!0}:{name:"",isHoliday:!0,isRestDay:c.isRestDay,isHolidayPeriod:!0}:n?{name:o.lunarFestival||o.solarFestival||o.solarTerm,isHoliday:!0,isRestDay:s,isHolidayPeriod:!1}:{isHoliday:!1,isRestDay:s,isHolidayPeriod:!1}}function F(e,t="YYYY-MM-DD"){if(!e||!(e instanceof Date)||isNaN(e.getTime()))return console.warn("Invalid date provided to formatDate"),"";const l=e.getFullYear(),i=e.getMonth()+1,s=e.getDate(),o=e.getHours(),n=e.getMinutes(),r=e.getSeconds();return t.replace(/YYYY/g,l.toString()).replace(/YY/g,(l%100).toString().padStart(2,"0")).replace(/MM/g,i.toString().padStart(2,"0")).replace(/M/g,i.toString()).replace(/DD/g,s.toString().padStart(2,"0")).replace(/D/g,s.toString()).replace(/HH/g,o.toString().padStart(2,"0")).replace(/H/g,o.toString()).replace(/mm/g,n.toString().padStart(2,"0")).replace(/m/g,n.toString()).replace(/ss/g,r.toString().padStart(2,"0")).replace(/s/g,r.toString())}function E(e,t){return!e||!t||!(e instanceof Date)||!(t instanceof Date)||isNaN(e.getTime())||isNaN(t.getTime())?!1:e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function L(e,t,l){if(!e||!t||!l||!(e instanceof Date)||!(t instanceof Date)||!(l instanceof Date)||isNaN(e.getTime())||isNaN(t.getTime())||isNaN(l.getTime()))return!1;const i=new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime(),s=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),o=new Date(l.getFullYear(),l.getMonth(),l.getDate()).getTime();return i>=s&&i<=o}function me(e,t){return new Date(e,t,1)}function G(e,t){return new Date(e,t+1,0).getDate()}function fe(e=0,t=!0){const i=[...t?["日","一","二","三","四","五","六"]:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]];for(let s=0;s<e;s++)i.push(i.shift());return i}function ge(e,t={}){if(!e||!(e instanceof Date)||isNaN(e.getTime()))return console.warn("Invalid date provided to getDayInfo"),{};const{selectedDate:l=null,priceData:i={},checkInData:s={},disabledDate:o=null}=t,n=new Date,r=F(e,"YYYY-MM-DD"),c=H(e),h=W(e);return{date:e,day:e.getDate(),month:e.getMonth(),year:e.getFullYear(),isCurrentMonth:!0,isToday:E(e,n),isSelected:l?E(e,l):!1,isInRange:!1,isRangeStart:!1,isRangeEnd:!1,isWeekend:e.getDay()===0||e.getDay()===6,isHoliday:h.isHoliday!==void 0?h.isHoliday:!!h.name,isRestDay:!!h.isRestDay,isHolidayPeriod:!!h.isHolidayPeriod,isCheckedIn:!!s[r],isDisabled:o?o(e):!1,price:i[r],lunarDay:c==null?void 0:c.lunarDay,lunarMonth:c==null?void 0:c.lunarMonth,lunarYear:c==null?void 0:c.lunarYear,lunarFestival:c==null?void 0:c.lunarFestival,solarFestival:c==null?void 0:c.solarFestival,solarTerm:c==null?void 0:c.solarTerm}}function Q(e,t,l={}){const{firstDayOfWeek:i=0,selectedDate:s=null,rangeStart:o=null,rangeEnd:n=null,priceData:r={},checkInData:c={},disabledDate:h=null}=l,T=new Date,$=me(e,t),N=G(e,t);let M=$.getDay()-i;M<0&&(M+=7);const S=Math.ceil((N+M)/7)*7-N-M,g=t===0?11:t-1,Y=t===0?e-1:e,C=G(Y,g),b=t===11?0:t+1,B=t===11?e+1:e,f=[];for(let p=0;p<M;p++){const D=C-M+p+1,w=new Date(Y,g,D),u=F(w,"YYYY-MM-DD"),y=H(w),V=W(w);f.push({date:w,day:D,month:g,year:Y,isCurrentMonth:!1,isToday:E(w,T),isSelected:s?E(w,s):!1,isInRange:o&&n?L(w,o,n):!1,isRangeStart:o?E(w,o):!1,isRangeEnd:n?E(w,n):!1,isWeekend:w.getDay()===0||w.getDay()===6,isHoliday:V.isHoliday!==void 0?V.isHoliday:!!V.name,isRestDay:!!V.isRestDay,isHolidayPeriod:!!V.isHolidayPeriod,isCheckedIn:!!c[u],isDisabled:h?h(w):!1,price:r[u],lunarDay:y==null?void 0:y.lunarDay,lunarMonth:y==null?void 0:y.lunarMonth,lunarYear:y==null?void 0:y.lunarYear,lunarFestival:y==null?void 0:y.lunarFestival,solarFestival:y==null?void 0:y.solarFestival,solarTerm:y==null?void 0:y.solarTerm})}for(let p=1;p<=N;p++){const D=new Date(e,t,p),w=F(D,"YYYY-MM-DD"),u=H(D),y=W(D);f.push({date:D,day:p,month:t,year:e,isCurrentMonth:!0,isToday:E(D,T),isSelected:s?E(D,s):!1,isInRange:o&&n?L(D,o,n):!1,isRangeStart:o?E(D,o):!1,isRangeEnd:n?E(D,n):!1,isWeekend:D.getDay()===0||D.getDay()===6,isHoliday:y.isHoliday!==void 0?y.isHoliday:!!y.name,isRestDay:!!y.isRestDay,isHolidayPeriod:!!y.isHolidayPeriod,isCheckedIn:!!c[w],isDisabled:h?h(D):!1,price:r[w],lunarDay:u==null?void 0:u.lunarDay,lunarMonth:u==null?void 0:u.lunarMonth,lunarYear:u==null?void 0:u.lunarYear,lunarFestival:u==null?void 0:u.lunarFestival,solarFestival:u==null?void 0:u.solarFestival,solarTerm:u==null?void 0:u.solarTerm})}for(let p=1;p<=S;p++){const D=new Date(B,b,p),w=F(D,"YYYY-MM-DD"),u=H(D),y=W(D);f.push({date:D,day:p,month:b,year:B,isCurrentMonth:!1,isToday:E(D,T),isSelected:s?E(D,s):!1,isInRange:o&&n?L(D,o,n):!1,isRangeStart:o?E(D,o):!1,isRangeEnd:n?E(D,n):!1,isWeekend:D.getDay()===0||D.getDay()===6,isHoliday:y.isHoliday!==void 0?y.isHoliday:!!y.name,isRestDay:!!y.isRestDay,isHolidayPeriod:!!y.isHolidayPeriod,isCheckedIn:!!c[w],isDisabled:h?h(D):!1,price:r[w],lunarDay:u==null?void 0:u.lunarDay,lunarMonth:u==null?void 0:u.lunarMonth,lunarYear:u==null?void 0:u.lunarYear,lunarFestival:u==null?void 0:u.lunarFestival,solarFestival:u==null?void 0:u.solarFestival,solarTerm:u==null?void 0:u.solarTerm})}return f}function ke(e,t={}){if(!e||!(e instanceof Date)||isNaN(e.getTime()))return console.warn("Invalid date provided to getWeekDays"),[];const{firstDayOfWeek:l=0,selectedDate:i=null,rangeStart:s=null,rangeEnd:o=null,priceData:n={},checkInData:r={},disabledDate:c=null}=t,h=new Date,$=e.getDay()-l,N=$<0?$+7:$,M=new Date(e);M.setDate(e.getDate()-N);const _=[];for(let S=0;S<7;S++){const g=new Date(M);g.setDate(M.getDate()+S);const Y=g.getFullYear(),C=g.getMonth(),b=g.getDate(),B=F(g,"YYYY-MM-DD"),f=H(g),p=W(g);_.push({date:g,day:b,month:C,year:Y,isCurrentMonth:g.getMonth()===e.getMonth(),isToday:E(g,h),isSelected:i?E(g,i):!1,isInRange:s&&o?L(g,s,o):!1,isRangeStart:s?E(g,s):!1,isRangeEnd:o?E(g,o):!1,isWeekend:g.getDay()===0||g.getDay()===6,isHoliday:p.isHoliday!==void 0?p.isHoliday:!!p.name,isRestDay:!!p.isRestDay,isHolidayPeriod:!!p.isHolidayPeriod,isCheckedIn:!!r[B],isDisabled:c?c(g):!1,price:n[B],lunarDay:f==null?void 0:f.lunarDay,lunarMonth:f==null?void 0:f.lunarMonth,lunarYear:f==null?void 0:f.lunarYear,lunarFestival:f==null?void 0:f.lunarFestival,solarFestival:f==null?void 0:f.solarFestival,solarTerm:f==null?void 0:f.solarTerm})}return _}const pe=a.defineComponent({name:"CalendarHeader",props:{currentYear:{type:Number,required:!0},currentMonth:{type:Number,required:!0},mode:{type:String,default:"month"},showYearPicker:{type:Boolean,default:!1},showMonthPicker:{type:Boolean,default:!1}},emits:["prev","next","today","toggle-year-picker","toggle-month-picker"],setup(e,{emit:t}){return{handlePrev:()=>{t("prev")},handleNext:()=>{t("next")},goToToday:()=>{t("today")},toggleYearPicker:r=>{r.stopPropagation(),t("toggle-year-picker")},toggleMonthPicker:r=>{r.stopPropagation(),t("toggle-month-picker")}}}}),Ga="",v=(e,t)=>{const l=e.__vccOpts||e;for(const[i,s]of t)l[i]=s;return l},we={class:"uni-calendar__header"},_e={class:"uni-calendar__header-wrapper"},Ce={class:"uni-calendar__header-title"},Me={class:"uni-calendar__header-btns"};function Se(e,t,l,i,s,o){return a.openBlock(),a.createElementBlock("div",we,[a.createElementVNode("div",_e,[a.createElementVNode("div",Ce,[a.createElementVNode("div",{class:"uni-calendar__header-btn",onClick:t[0]||(t[0]=(...n)=>e.toggleYearPicker&&e.toggleYearPicker(...n))},[a.createTextVNode(a.toDisplayString(e.currentYear)+"年 ",1),a.createElementVNode("div",{class:a.normalizeClass(["uni-calendar__header-btn-icon",{"uni-calendar__header-btn-icon--active":e.showYearPicker}])},null,2)]),a.createElementVNode("div",{class:"uni-calendar__header-btn",onClick:t[1]||(t[1]=(...n)=>e.toggleMonthPicker&&e.toggleMonthPicker(...n))},[a.createTextVNode(a.toDisplayString(e.currentMonth+1)+"月 ",1),a.createElementVNode("div",{class:a.normalizeClass(["uni-calendar__header-btn-icon",{"uni-calendar__header-btn-icon--active":e.showMonthPicker}])},null,2)])]),a.createElementVNode("div",Me,[a.createElementVNode("div",{class:"uni-calendar__header-btn-arrow",onClick:t[2]||(t[2]=(...n)=>e.handlePrev&&e.handlePrev(...n))},t[5]||(t[5]=[a.createElementVNode("div",{class:"uni-calendar__header-btn-arrow-icon uni-calendar__header-btn-arrow-icon--left"},null,-1)])),a.createElementVNode("div",{class:"uni-calendar__header-btn-today",onClick:t[3]||(t[3]=(...n)=>e.goToToday&&e.goToToday(...n))},"今天"),a.createElementVNode("div",{class:"uni-calendar__header-btn-arrow",onClick:t[4]||(t[4]=(...n)=>e.handleNext&&e.handleNext(...n))},t[6]||(t[6]=[a.createElementVNode("div",{class:"uni-calendar__header-btn-arrow-icon uni-calendar__header-btn-arrow-icon--right"},null,-1)]))])])])}const Ee=v(pe,[["render",Se]]),Be=a.defineComponent({name:"YearPicker",props:{currentYear:{type:Number,required:!0},range:{type:[Number,Array],default:10}},emits:["year-select"],setup(e,{emit:t}){return{yearRange:a.computed(()=>{if(Array.isArray(e.range))return e.range;const s=e.currentYear,o=[];for(let n=s-e.range;n<=s+e.range;n++)o.push(n);return o}),handleYearSelect:s=>{t("year-select",s)}}}}),Qa="",$e=["onClick"];function be(e,t,l,i,s,o){return a.openBlock(),a.createElementBlock("div",{class:"uni-calendar__picker uni-calendar__year-picker",onClick:t[0]||(t[0]=a.withModifiers(()=>{},["stop"]))},[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(e.yearRange,n=>(a.openBlock(),a.createElementBlock("div",{key:n,class:a.normalizeClass(["uni-calendar__picker-item",{"uni-calendar__picker-item--active":n===e.currentYear}]),onClick:r=>e.handleYearSelect(n)},a.toDisplayString(n),11,$e))),128))])}const Ye=v(Be,[["render",be]]),Ne=a.defineComponent({name:"MonthPicker",props:{currentMonth:{type:Number,required:!0}},emits:["month-select"],setup(e,{emit:t}){return{handleMonthSelect:i=>{t("month-select",i)}}}}),xa="",Te=["onClick"];function ve(e,t,l,i,s,o){return a.openBlock(),a.createElementBlock("div",{class:"uni-calendar__picker uni-calendar__month-picker",onClick:t[0]||(t[0]=a.withModifiers(()=>{},["stop"]))},[(a.openBlock(),a.createElementBlock(a.Fragment,null,a.renderList(12,(n,r)=>a.createElementVNode("div",{key:r,class:a.normalizeClass(["uni-calendar__picker-item",{"uni-calendar__picker-item--active":r===e.currentMonth}]),onClick:c=>e.handleMonthSelect(r)},a.toDisplayString(n)+"月 ",11,Te)),64))])}const Re=v(Ne,[["render",ve]]),Ve=a.defineComponent({name:"WeekHeader",props:{firstDayOfWeek:{type:Number,default:0,validator:e=>[0,1].includes(e)},abbreviated:{type:Boolean,default:!1}},setup(e){return{weekDays:a.computed(()=>{const l=e.firstDayOfWeek===0?["日","一","二","三","四","五","六"]:["一","二","三","四","五","六","日"];return e.abbreviated?l.map(i=>i.charAt(0)):l})}}}),et="",Pe={class:"uni-calendar__week-header"};function Fe(e,t,l,i,s,o){return a.openBlock(),a.createElementBlock("div",Pe,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(e.weekDays,(n,r)=>(a.openBlock(),a.createElementBlock("div",{key:r,class:a.normalizeClass(["uni-calendar__week-day",{"uni-calendar__week-day--weekend":r===0||r===6}])},a.toDisplayString(n),3))),128))])}const x=v(Ve,[["render",Fe]]),He=a.defineComponent({name:"DayCell",props:{day:{type:Object,required:!0},showLunar:{type:Boolean,default:!1},showPrice:{type:Boolean,default:!1},disabledDate:{type:Function,default:()=>null},highlightWeekend:{type:Boolean,default:!0}},emits:{"day-click":(e,t)=>!0},setup(e,{emit:t}){return{dayClass:a.computed(()=>{const{day:n}=e;return{"uni-calendar__day--not-current-month":!n.isCurrentMonth,"uni-calendar__day--today":n.isToday,"uni-calendar__day--selected":n.isSelected,"uni-calendar__day--in-range":n.isInRange,"uni-calendar__day--range-start":n.isRangeStart,"uni-calendar__day--range-end":n.isRangeEnd,"uni-calendar__day--weekend":e.highlightWeekend&&n.isWeekend&&n.isCurrentMonth,"uni-calendar__day--holiday":n.isHoliday&&n.isCurrentMonth,"uni-calendar__day--rest-day":n.isHoliday&&n.isRestDay&&n.isCurrentMonth,"uni-calendar__day--work-day":n.isHoliday&&!n.isRestDay&&n.isCurrentMonth,"uni-calendar__day--checked-in":n.isCheckedIn,"uni-calendar__day--disabled":e.disabledDate&&e.disabledDate(n.date),"uni-calendar__day--lunar-first-day":n.lunarDay==="初一"&&n.isCurrentMonth,"uni-calendar__day--solar-term":n.solarTerm&&n.isCurrentMonth}}),handleClick:(n,r)=>{e.disabledDate&&e.disabledDate(r.date)||t("day-click",n,r)},handleTouchStart:n=>{if(e.disabledDate&&e.disabledDate(e.day.date))return;const r=n.currentTarget;r&&(r.classList.add("uni-calendar__day--touch-active"),n.type==="touchstart"&&n.preventDefault())},handleTouchEnd:n=>{if(e.disabledDate&&e.disabledDate(e.day.date))return;const r=n.currentTarget;r&&r.classList.remove("uni-calendar__day--touch-active")}}}}),at="",We={class:"uni-calendar__day-content"},Oe={class:"uni-calendar__day-text"},Le={key:0,class:"uni-calendar__day-lunar"},Ae={key:0},Ie={key:1},ze={key:1,class:"uni-calendar__day-price"},je={key:2,class:"uni-calendar__day-checked-in"},qe={key:3,class:"uni-calendar__day-holiday"},Xe={key:0,class:"uni-calendar__day-holiday-tag"},Ue={key:1,class:"uni-calendar__day-holiday-tag"};function Je(e,t,l,i,s,o){return a.openBlock(),a.createElementBlock("div",{class:a.normalizeClass([e.dayClass,"uni-calendar__day-wrapper"]),onClick:t[0]||(t[0]=n=>e.handleClick(n,e.day)),onTouchstart:t[1]||(t[1]=(...n)=>e.handleTouchStart&&e.handleTouchStart(...n)),onTouchend:t[2]||(t[2]=(...n)=>e.handleTouchEnd&&e.handleTouchEnd(...n)),onTouchcancel:t[3]||(t[3]=(...n)=>e.handleTouchEnd&&e.handleTouchEnd(...n)),onMousedown:t[4]||(t[4]=(...n)=>e.handleTouchStart&&e.handleTouchStart(...n)),onMouseup:t[5]||(t[5]=(...n)=>e.handleTouchEnd&&e.handleTouchEnd(...n)),onMouseleave:t[6]||(t[6]=(...n)=>e.handleTouchEnd&&e.handleTouchEnd(...n))},[a.createElementVNode("div",We,[a.createElementVNode("div",Oe,a.toDisplayString(e.day.day),1),e.showLunar&&e.day.lunarDay?(a.openBlock(),a.createElementBlock("div",Le,[e.day.lunarDay==="初一"?(a.openBlock(),a.createElementBlock("span",Ae,a.toDisplayString(e.day.lunarFestival||e.day.solarFestival||e.day.solarTerm||e.day.lunarMonth||e.day.lunarDay),1)):(a.openBlock(),a.createElementBlock("span",Ie,a.toDisplayString(e.day.lunarFestival||e.day.solarFestival||e.day.solarTerm||e.day.lunarDay),1))])):a.createCommentVNode("",!0),e.showPrice&&e.day.price!==void 0?(a.openBlock(),a.createElementBlock("div",ze," ¥"+a.toDisplayString(e.day.price),1)):a.createCommentVNode("",!0),e.day.isCheckedIn?(a.openBlock(),a.createElementBlock("div",je)):a.createCommentVNode("",!0),e.day.isHoliday?(a.openBlock(),a.createElementBlock("div",qe,[e.day.isHoliday&&e.day.isRestDay&&e.day.isHolidayPeriod?(a.openBlock(),a.createElementBlock("div",Xe,"休")):a.createCommentVNode("",!0),e.day.isHoliday&&!e.day.isRestDay&&e.day.isHolidayPeriod?(a.openBlock(),a.createElementBlock("div",Ue,"班")):a.createCommentVNode("",!0)])):a.createCommentVNode("",!0)])],34)}const j=v(He,[["render",Je]]),Ke=a.defineComponent({name:"MonthView",components:{WeekHeader:x,DayCell:j},props:{year:{type:Number,required:!0},month:{type:Number,required:!0},selectedDate:{type:Date,default:null},rangeStart:{type:Date,default:null},rangeEnd:{type:Date,default:null},firstDayOfWeek:{type:Number,default:0,validator:e=>e===0||e===1},showLunar:{type:Boolean,default:!1},showHoliday:{type:Boolean,default:!1},showPrice:{type:Boolean,default:!1},priceData:{type:Object,default:()=>({})},checkInData:{type:Object,default:()=>({})},disabledDate:{type:Function,default:()=>null},highlightWeekend:{type:Boolean,default:!0},rangeMode:{type:Boolean,default:!1},allowClickOtherMonthDay:{type:Boolean,default:!1}},emits:{"day-click":(e,t)=>!0},setup(e,{emit:t}){return{monthDays:a.computed(()=>Q(e.year,e.month,{firstDayOfWeek:e.firstDayOfWeek,selectedDate:e.selectedDate,rangeStart:e.rangeStart,rangeEnd:e.rangeEnd,priceData:e.priceData,checkInData:e.checkInData,disabledDate:e.disabledDate})),getDayClass:o=>{const n=["uni-calendar__day"];return o.isCurrentMonth||n.push("uni-calendar__day--not-current-month"),o.isToday&&n.push("uni-calendar__day--today"),o.isSelected&&n.push("uni-calendar__day--selected"),o.isInRange&&n.push("uni-calendar__day--in-range"),e.rangeMode&&e.rangeStart&&E(o.date,e.rangeStart)&&n.push("uni-calendar__day--range-start"),e.rangeMode&&e.rangeEnd&&E(o.date,e.rangeEnd)&&n.push("uni-calendar__day--range-end"),e.highlightWeekend&&(o.day===0||o.day===6)&&n.push("uni-calendar__day--weekend"),o.isDisabled&&n.push("uni-calendar__day--disabled"),n.join(" ")},handleDayClick:(o,n)=>{const r=n||o;!r.isCurrentMonth&&!e.allowClickOtherMonthDay||r.isDisabled||(n?t("day-click",o,r):t("day-click",new MouseEvent("click"),r))}}}}),tt="",Ze={class:"uni-calendar__month-view"},Ge={class:"uni-calendar__month-days"};function Qe(e,t,l,i,s,o){const n=a.resolveComponent("WeekHeader"),r=a.resolveComponent("DayCell");return a.openBlock(),a.createElementBlock("div",Ze,[a.createVNode(n,{"first-day-of-week":e.firstDayOfWeek},null,8,["first-day-of-week"]),a.createElementVNode("div",Ge,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(e.monthDays,(c,h)=>(a.openBlock(),a.createElementBlock("div",{key:h,class:a.normalizeClass(e.getDayClass(c))},[a.createVNode(r,{day:c,"show-lunar":e.showLunar,"show-holiday":e.showHoliday,"show-price":e.showPrice,"disabled-date":e.disabledDate,"highlight-weekend":e.highlightWeekend,onDayClick:e.handleDayClick},null,8,["day","show-lunar","show-holiday","show-price","disabled-date","highlight-weekend","onDayClick"])],2))),128))])])}const xe=v(Ke,[["render",Qe]]),ea=a.defineComponent({name:"WeekView",components:{WeekHeader:x,DayCell:j},props:{date:{type:Date,required:!0},selectedDate:{type:Date,default:null},rangeStart:{type:Date,default:null},rangeEnd:{type:Date,default:null},firstDayOfWeek:{type:Number,default:0,validator:e=>[0,1].includes(e)},showLunar:{type:Boolean,default:!1},showHoliday:{type:Boolean,default:!1},showPrice:{type:Boolean,default:!1},priceData:{type:Object,default:()=>({})},checkInData:{type:Object,default:()=>({})},disabledDate:{type:Function,default:null},highlightWeekend:{type:Boolean,default:!0},rangeMode:{type:Boolean,default:!1},allowClickOtherMonthDay:{type:Boolean,default:!1}},emits:["day-click"],setup(e,{emit:t}){return{weekDays:a.computed(()=>ke(e.date,{firstDayOfWeek:e.firstDayOfWeek,selectedDate:e.selectedDate,rangeStart:e.rangeStart,rangeEnd:e.rangeEnd,priceData:e.priceData,checkInData:e.checkInData,disabledDate:e.disabledDate})),getDayClass:o=>{const n=["uni-calendar__day"];return o.isCurrentMonth||n.push("uni-calendar__day--not-current-month"),o.isToday&&n.push("uni-calendar__day--today"),o.isSelected&&n.push("uni-calendar__day--selected"),o.isInRange&&n.push("uni-calendar__day--in-range"),e.rangeMode&&e.rangeStart&&E(o.date,e.rangeStart)&&n.push("uni-calendar__day--range-start"),e.rangeMode&&e.rangeEnd&&E(o.date,e.rangeEnd)&&n.push("uni-calendar__day--range-end"),e.highlightWeekend&&(o.day===0||o.day===6)&&n.push("uni-calendar__day--weekend"),o.isDisabled&&n.push("uni-calendar__day--disabled"),n.join(" ")},handleDayClick:(o,n)=>{const r=n||o;!r.isCurrentMonth&&!e.allowClickOtherMonthDay||r.isDisabled||(n?t("day-click",o,r):t("day-click",new MouseEvent("click"),r))}}}}),nt="",aa={class:"uni-calendar__week-view"},ta={class:"uni-calendar__week-days"};function na(e,t,l,i,s,o){const n=a.resolveComponent("WeekHeader"),r=a.resolveComponent("DayCell");return a.openBlock(),a.createElementBlock("div",aa,[a.createVNode(n,{"first-day-of-week":e.firstDayOfWeek},null,8,["first-day-of-week"]),a.createElementVNode("div",ta,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(e.weekDays,(c,h)=>(a.openBlock(),a.createElementBlock("div",{key:h,class:a.normalizeClass(e.getDayClass(c))},[a.createVNode(r,{day:c,"show-lunar":e.showLunar,"show-holiday":e.showHoliday,"show-price":e.showPrice,"disabled-date":e.disabledDate,"highlight-weekend":e.highlightWeekend,onDayClick:e.handleDayClick},null,8,["day","show-lunar","show-holiday","show-price","disabled-date","highlight-weekend","onDayClick"])],2))),128))])])}const la=v(ea,[["render",na]]),oa=a.defineComponent({name:"DayDetail",props:{date:{type:Date,required:!0},dayInfo:{type:Object,required:!0},showLunar:{type:Boolean,default:!1},showPrice:{type:Boolean,default:!1}},emits:["check-in"],setup(e,{emit:t}){return{formattedDate:a.computed(()=>F(e.date,"YYYY年MM月DD日")),handleCheckIn:()=>{t("check-in",e.date)}}}}),lt="",ra={class:"uni-calendar__day-detail"},sa={class:"uni-calendar__day-detail-header"},ia={class:"uni-calendar__day-detail-date"},da={key:0,class:"uni-calendar__day-detail-lunar"},ca={class:"uni-calendar__day-detail-content"},ha={key:0,class:"uni-calendar__day-detail-festival"},ya={class:"uni-calendar__day-detail-festival-item"},ua={key:1,class:"uni-calendar__day-detail-price"},Da={class:"uni-calendar__day-detail-price-value"},ma={class:"uni-calendar__day-detail-check-in"},fa={class:"uni-calendar__day-detail-check-in-status"};function ga(e,t,l,i,s,o){return a.openBlock(),a.createElementBlock("div",ra,[a.createElementVNode("div",sa,[a.createElementVNode("div",ia,a.toDisplayString(e.formattedDate),1),e.showLunar&&e.dayInfo.lunarDay?(a.openBlock(),a.createElementBlock("div",da,a.toDisplayString(e.dayInfo.lunarYear)+" "+a.toDisplayString(e.dayInfo.lunarMonth)+" "+a.toDisplayString(e.dayInfo.lunarDay),1)):a.createCommentVNode("",!0)]),a.createElementVNode("div",ca,[e.dayInfo.lunarFestival||e.dayInfo.solarFestival||e.dayInfo.solarTerm?(a.openBlock(),a.createElementBlock("div",ha,[a.createElementVNode("div",ya,a.toDisplayString(e.dayInfo.lunarFestival||e.dayInfo.solarFestival||(e.dayInfo.solarTerm?e.dayInfo.solarTerm+"节气":"")),1)])):a.createCommentVNode("",!0),e.showPrice&&e.dayInfo.price!==void 0?(a.openBlock(),a.createElementBlock("div",ua,[t[1]||(t[1]=a.createElementVNode("div",{class:"uni-calendar__day-detail-price-label"},"价格:",-1)),a.createElementVNode("div",Da,"¥"+a.toDisplayString(e.dayInfo.price),1)])):a.createCommentVNode("",!0),a.createElementVNode("div",ma,[a.createElementVNode("div",fa,a.toDisplayString(e.dayInfo.isCheckedIn?"已打卡":"未打卡"),1),e.dayInfo.isCheckedIn?a.createCommentVNode("",!0):(a.openBlock(),a.createElementBlock("div",{key:0,class:"uni-calendar__day-detail-check-in-btn",onClick:t[0]||(t[0]=(...n)=>e.handleCheckIn&&e.handleCheckIn(...n))}," 打卡 "))])])])}const ka=v(oa,[["render",ga]]),pa=a.defineComponent({name:"DayView",components:{DayCell:j,DayDetail:ka},props:{date:{type:Date,required:!0},selectedDate:{type:Date,default:null},firstDayOfWeek:{type:Number,default:0,validator:e=>e>=0&&e<=6},showLunar:{type:Boolean,default:!1},showHoliday:{type:Boolean,default:!1},showPrice:{type:Boolean,default:!1},priceData:{type:Object,default:()=>({})},checkInData:{type:Object,default:()=>({})},disabledDate:{type:Function,default:null},highlightWeekend:{type:Boolean,default:!0},allowClickOtherMonthDay:{type:Boolean,default:!1}},emits:["day-click","check-in"],setup(e,{emit:t}){const l=a.computed(()=>fe(e.firstDayOfWeek)),i=a.computed(()=>ge(e.date,{selectedDate:e.selectedDate,priceData:e.priceData,checkInData:e.checkInData,disabledDate:e.disabledDate}));return{weekDays:l,dayInfo:i,getDayClass:r=>{const c=["uni-calendar__day-view-day-cell"];return r.isToday&&c.push("uni-calendar__day-view-day-cell--today"),r.isSelected&&c.push("uni-calendar__day-view-day-cell--selected"),e.highlightWeekend&&(r.day===0||r.day===6)&&c.push("uni-calendar__day-view-day-cell--weekend"),r.isDisabled&&c.push("uni-calendar__day-view-day-cell--disabled"),c.join(" ")},handleDayClick:(r,c)=>{const h=c||r;!h.isCurrentMonth&&!e.allowClickOtherMonthDay||h.isDisabled||(c?t("day-click",r,h):t("day-click",new MouseEvent("click"),h))},handleCheckIn:r=>{t("check-in",r)}}}}),ot="",wa={class:"uni-calendar__day-view"},_a={class:"uni-calendar__day-view-header"},Ca={class:"uni-calendar__day-view-content"},Ma={class:"uni-calendar__day-view-day"};function Sa(e,t,l,i,s,o){const n=a.resolveComponent("DayCell"),r=a.resolveComponent("DayDetail");return a.openBlock(),a.createElementBlock("div",wa,[a.createElementVNode("div",_a,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(e.weekDays,(c,h)=>(a.openBlock(),a.createElementBlock("div",{key:h,class:a.normalizeClass({"uni-calendar__day-view-header-item":!0,"uni-calendar__day-view-header-item--weekend":e.highlightWeekend&&(h===0||h===6)})},a.toDisplayString(c),3))),128))]),a.createElementVNode("div",Ca,[a.createElementVNode("div",Ma,[a.createElementVNode("div",{class:a.normalizeClass(e.getDayClass(e.dayInfo))},[a.createVNode(n,{day:e.dayInfo,"show-lunar":e.showLunar,"show-holiday":e.showHoliday,"show-price":e.showPrice,"disabled-date":e.disabledDate,"highlight-weekend":e.highlightWeekend,onDayClick:e.handleDayClick},null,8,["day","show-lunar","show-holiday","show-price","disabled-date","highlight-weekend","onDayClick"])],2)]),e.dayInfo?(a.openBlock(),a.createBlock(r,{key:0,date:e.date,"day-info":e.dayInfo,"show-lunar":e.showLunar,"show-price":e.showPrice,onCheckIn:e.handleCheckIn},null,8,["date","day-info","show-lunar","show-price","onCheckIn"])):a.createCommentVNode("",!0)])])}const Ea=v(pa,[["render",Sa]]),Ba=a.defineComponent({name:"YearView",props:{year:{type:Number,required:!0},selectedMonth:{type:Number,default:-1}},emits:["month-click"],setup(e,{emit:t}){return{handleMonthClick:i=>{t("month-click",{year:e.year,month:i})}}}}),rt="",$a={class:"uni-calendar__year-view"},ba={class:"uni-calendar__year-months"},Ya=["onClick"];function Na(e,t,l,i,s,o){return a.openBlock(),a.createElementBlock("div",$a,[a.createElementVNode("div",ba,[(a.openBlock(),a.createElementBlock(a.Fragment,null,a.renderList(12,n=>a.createElementVNode("div",{key:n,class:a.normalizeClass(["uni-calendar__year-month",{"uni-calendar__year-month--selected":n-1===e.selectedMonth}]),onClick:r=>e.handleMonthClick(n-1)},a.toDisplayString(n)+"月 ",11,Ya)),64))])])}const Ta=v(Ba,[["render",Na]]),va=a.defineComponent({name:"CalendarSwiper",emits:["swipe-left","swipe-right"],setup(e,{emit:t}){const l=a.ref(null),i=a.ref(0),s=a.ref(0),o=a.ref(0),n=a.ref(0),r=a.ref(0),c=a.ref(!1),h=a.ref(null),T=C=>{i.value=C.touches[0].clientX,s.value=C.touches[0].clientY,c.value=!0,h.value!==null&&cancelAnimationFrame(h.value)},$=C=>{if(!c.value)return;const B=C.touches[0].clientX-i.value;o.value=B;const f=window.innerWidth*.5;let p=B;if(Math.abs(B)>f){const D=Math.abs(B)-f,w=.3;p=B>0?f+D*w:-f-D*w}n.value=r.value+p,M(),C.preventDefault()},N=()=>{if(!c.value)return;c.value=!1;const C=n.value-r.value,b=window.innerWidth*.08;C<-b?l.value?(l.value.style.transition="transform 0.25s cubic-bezier(0.19, 1, 0.22, 1)",l.value.style.transform=`translateX(${-window.innerWidth}px)`,setTimeout(()=>{t("swipe-left"),Y()},240)):t("swipe-left"):C>b?l.value?(l.value.style.transition="transform 0.25s cubic-bezier(0.19, 1, 0.22, 1)",l.value.style.transform=`translateX(${window.innerWidth}px)`,setTimeout(()=>{t("swipe-right"),Y()},240)):t("swipe-right"):l.value&&(l.value.style.transition="transform 0.25s cubic-bezier(0.19, 1, 0.22, 1)",l.value.style.transform="translateX(0)",setTimeout(()=>{l.value&&(l.value.style.transition="none")},250))},M=()=>{l.value&&(c.value&&(l.value.style.transition="none",l.value.style.willChange="transform"),l.value.style.transform=`translateX(${n.value}px)`)},_=C=>{i.value=C.clientX,s.value=C.clientY,c.value=!0,h.value!==null&&cancelAnimationFrame(h.value),document.addEventListener("mousemove",S),document.addEventListener("mouseup",g)},S=C=>{if(!c.value)return;const B=C.clientX-i.value;o.value=B;const f=window.innerWidth*.5;let p=B;if(Math.abs(B)>f){const D=Math.abs(B)-f,w=.3;p=B>0?f+D*w:-f-D*w}n.value=r.value+p,M(),C.preventDefault()},g=()=>{if(!c.value)return;c.value=!1;const C=n.value-r.value,b=window.innerWidth*.08;C<-b?l.value?(l.value.style.transition="transform 0.25s cubic-bezier(0.19, 1, 0.22, 1)",l.value.style.transform=`translateX(${-window.innerWidth}px)`,setTimeout(()=>{t("swipe-left"),Y()},240)):t("swipe-left"):C>b?l.value?(l.value.style.transition="transform 0.25s cubic-bezier(0.19, 1, 0.22, 1)",l.value.style.transform=`translateX(${window.innerWidth}px)`,setTimeout(()=>{t("swipe-right"),Y()},240)):t("swipe-right"):l.value&&(l.value.style.transition="transform 0.25s cubic-bezier(0.19, 1, 0.22, 1)",l.value.style.transform="translateX(0)",setTimeout(()=>{l.value&&(l.value.style.transition="none")},250)),document.removeEventListener("mousemove",S),document.removeEventListener("mouseup",g)},Y=()=>{l.value&&(l.value.style.transition="none",l.value.style.transform="translateX(0)",n.value=0,r.value=0)};return a.onUnmounted(()=>{document.removeEventListener("mousemove",S),document.removeEventListener("mouseup",g),h.value!==null&&cancelAnimationFrame(h.value)}),{swiperRef:l,touchStart:T,touchMove:$,touchEnd:N,mouseDown:_,resetSwiper:Y}}}),st="";function Ra(e,t,l,i,s,o){return a.openBlock(),a.createElementBlock("div",{class:"uni-calendar__swiper",ref:"swiperRef",onTouchstart:t[0]||(t[0]=(...n)=>e.touchStart&&e.touchStart(...n)),onTouchmove:t[1]||(t[1]=(...n)=>e.touchMove&&e.touchMove(...n)),onTouchend:t[2]||(t[2]=(...n)=>e.touchEnd&&e.touchEnd(...n)),onMousedown:t[3]||(t[3]=(...n)=>e.mouseDown&&e.mouseDown(...n))},[a.renderSlot(e.$slots,"default")],544)}const Va=v(va,[["render",Ra]]),Pa=a.defineComponent({name:"MonthMini",props:{year:{type:Number,required:!0},month:{type:Number,required:!0},selectedDate:{type:Date,default:null},rangeStart:{type:Date,default:null},rangeEnd:{type:Date,default:null},firstDayOfWeek:{type:Number,default:0}},setup(e){const t=a.computed(()=>(e.firstDayOfWeek===0?["日","一","二","三","四","五","六"]:["一","二","三","四","五","六","日"]).map(o=>o.charAt(0))),l=a.computed(()=>{const s=Q(e.year,e.month,{selectedDate:e.selectedDate,rangeStart:e.rangeStart,rangeEnd:e.rangeEnd,firstDayOfWeek:e.firstDayOfWeek}),o=[];for(let n=0;n<s.length;n+=7)o.push(s.slice(n,n+7));return o});return{weekDays:t,monthDays:l,getDayClass:s=>s?{"month-mini__day--not-current-month":!s.isCurrentMonth,"month-mini__day--today":s.isToday,"month-mini__day--selected":s.isSelected,"month-mini__day--in-range":s.isInRange,"month-mini__day--range-start":s.isRangeStart,"month-mini__day--range-end":s.isRangeEnd,"month-mini__day--weekend":s.isWeekend}:{}}}}),it="",Fa={class:"month-mini"},Ha={class:"month-mini__week-header"};function Wa(e,t,l,i,s,o){return a.openBlock(),a.createElementBlock("div",Fa,[a.createElementVNode("div",Ha,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(e.weekDays,(n,r)=>(a.openBlock(),a.createElementBlock("div",{key:r,class:a.normalizeClass(["month-mini__week-day",{"month-mini__week-day--weekend":r===0||r===6}])},a.toDisplayString(n),3))),128))]),(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(e.monthDays,(n,r)=>(a.openBlock(),a.createElementBlock("div",{key:r,class:"month-mini__week"},[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(n,(c,h)=>(a.openBlock(),a.createElementBlock("div",{key:h,class:a.normalizeClass(["month-mini__day",e.getDayClass(c)])},a.toDisplayString(c==null?void 0:c.day),3))),128))]))),128))])}const Oa=v(Pa,[["render",Wa]]),La=a.defineComponent({name:"Calendar",components:{CalendarHeader:Ee,YearPicker:Ye,MonthPicker:Re,MonthView:xe,WeekView:la,DayView:Ea,YearView:Ta,CalendarSwiper:Va,MonthMini:Oa},props:{modelValue:{type:[Date,Array],default:()=>new Date},mode:{type:String,default:"month",validator:e=>["year","month","week","day"].includes(e)},allowClickOtherMonthDay:{type:Boolean,default:!1,description:"是否允许点击非当月灰色格子"},showLunar:{type:Boolean,default:!1},showHoliday:{type:Boolean,default:!0},showPrice:{type:Boolean,default:!1},priceData:{type:Object,default:()=>({})},checkInData:{type:Object,default:()=>({})},rangeMode:{type:Boolean,default:!1},firstDayOfWeek:{type:Number,default:0,validator:e=>e===0||e===1},disabledDate:{type:Function,default:()=>null},highlightWeekend:{type:Boolean,default:!0},autoHeight:{type:Boolean,default:!0}},emits:{"update:modelValue":e=>!0,"date-click":e=>!0,"range-change":e=>!0,"month-change":e=>!0,"check-in":e=>!0},setup(e,{emit:t}){const l=a.ref(new Date),i=a.computed(()=>l.value.getFullYear()),s=a.computed(()=>l.value.getMonth()),o=a.ref(!1),n=a.ref(!1),r=a.computed(()=>{const d=i.value,m=[];for(let k=d-10;k<=d+10;k++)m.push(k);return m}),c=a.computed(()=>Array.isArray(e.modelValue)?e.modelValue[0]:e.modelValue),h=a.computed(()=>{if(e.rangeMode&&Array.isArray(e.modelValue))return e.modelValue[0]}),T=a.computed(()=>{if(e.rangeMode&&Array.isArray(e.modelValue))return e.modelValue[1]||void 0}),$=a.ref(1),N=a.ref(null),M=a.ref(null),_=a.ref(null),S=a.computed(()=>{const d=l.value.getFullYear(),m=l.value.getMonth(),k=l.value.getDate();let R=d,A=m-1;A<0&&(R-=1,A=11);const Ua=new Date(R,A+1,0).getDate(),Ja=Math.min(k,Ua),q=new Date(R,A,Ja),X=new Date(d,m,k);let U=d,I=m+1;I>11&&(U+=1,I=0);const Ka=new Date(U,I+1,0).getDate(),Za=Math.min(k,Ka),J=new Date(U,I,Za);return[{date:q,year:q.getFullYear(),month:q.getMonth()},{date:X,year:X.getFullYear(),month:X.getMonth()},{date:J,year:J.getFullYear(),month:J.getMonth()}]}),g=a.computed(()=>{const d=new Date(l.value);d.setDate(d.getDate()-7);const m=new Date(l.value);return m.setDate(m.getDate()+7),[{date:d},{date:l.value},{date:m}]}),Y=a.computed(()=>{const d=new Date(l.value);d.setDate(d.getDate()-1);const m=new Date(l.value);return m.setDate(m.getDate()+1),[{date:d},{date:l.value},{date:m}]}),C=(d,m)=>{if(e.disabledDate&&e.disabledDate(m.date))return;const k=new Date(m.date);if(!m.isCurrentMonth){if(!e.allowClickOtherMonthDay)return;l.value=new Date(k.getFullYear(),k.getMonth(),k.getDate()),a.nextTick(()=>{$.value=1}),t("month-change",l.value)}if(e.rangeMode?b(k):(t("update:modelValue",k),t("date-click",k)),e.mode==="day"){const R=new Date(l.value);R.setDate(m.date.getDate()),l.value=R}},b=d=>{if(!h.value)t("update:modelValue",[d,null]);else if(T.value)t("update:modelValue",[d,null]);else{const m=new Date(h.value),k=new Date(d);m>k?(t("update:modelValue",[k,m]),t("range-change",[k,m])):(t("update:modelValue",[m,k]),t("range-change",[m,k]))}},B=d=>{const m=l.value.getDate(),k=new Date(d,s.value+1,0).getDate(),R=Math.min(m,k);l.value=new Date(d,s.value,R),o.value=!1,t("month-change",l.value)},f=d=>{const m=l.value.getDate(),k=new Date(i.value,d+1,0).getDate(),R=Math.min(m,k);l.value=new Date(i.value,d,R),n.value=!1,t("month-change",l.value)},p=d=>{const m=l.value.getDate(),k=new Date(i.value,d+1,0).getDate(),R=Math.min(m,k);l.value=new Date(i.value,d,R),t("month-change",l.value)},D=()=>{if(e.mode==="year")l.value=new Date(i.value-1,0,1);else if(e.mode==="month"){const d=l.value.getDate(),m=new Date(i.value,s.value,0).getDate(),k=Math.min(d,m);l.value=new Date(i.value,s.value-1,k)}else if(e.mode==="week"){const d=new Date(l.value);d.setDate(d.getDate()-7),l.value=d}else if(e.mode==="day"){const d=new Date(l.value);d.setDate(d.getDate()-1),l.value=d}t("month-change",l.value)},w=()=>{if(e.mode==="year")l.value=new Date(i.value+1,0,1);else if(e.mode==="month"){const d=l.value.getDate(),m=new Date(i.value,s.value+2,0).getDate(),k=Math.min(d,m);l.value=new Date(i.value,s.value+1,k)}else if(e.mode==="week"){const d=new Date(l.value);d.setDate(d.getDate()+7),l.value=d}else if(e.mode==="day"){const d=new Date(l.value);d.setDate(d.getDate()+1),l.value=d}t("month-change",l.value)},u=()=>{const d=new Date,m=new Date(d.getFullYear(),d.getMonth(),d.getDate());l.value=new Date(m),t("update:modelValue",new Date(m)),t("month-change",l.value)},y=d=>{l.value=new Date(d),t("month-change",l.value)},V=d=>{F(d,"YYYY-MM-DD"),t("check-in",d)};return a.watch(()=>e.modelValue,d=>{Array.isArray(d)?d[0]&&(l.value=new Date(d[0])):l.value=new Date(d)},{immediate:!0}),a.onMounted(()=>{if(Array.isArray(e.modelValue))e.modelValue[0]&&(l.value=new Date(e.modelValue[0]));else{const d=new Date(e.modelValue);l.value=d}}),{currentDate:l,currentYear:i,currentMonth:s,showYearPicker:o,showMonthPicker:n,yearRange:r,innerValue:c,rangeStart:h,rangeEnd:T,formatDate:F,handleDayClick:C,handleYearSelect:B,handleMonthSelect:f,handleYeardivMonthClick:p,handlePrev:D,handleNext:w,goToToday:u,goToDate:y,handleCheckIn:V,handleOutsideClick:()=>{o.value=!1,n.value=!1},toggleYearPicker:d=>{d&&d.stopPropagation(),o.value=!o.value,n.value=!1},toggleMonthPicker:d=>{d&&d.stopPropagation(),n.value=!n.value,o.value=!1},swiperRef:N,weekSwiperRef:M,daySwiperRef:_,swiperCurrent:$,swiperMonths:S,swiperWeeks:g,swiperDays:Y,handleSwiperChange:d=>{o.value||n.value||(d==="prev"?D():d==="next"&&w(),a.nextTick(()=>{$.value=1}))}}}}),dt="",Aa={class:"uni-calendar__header"},Ia={key:4,class:"uni-calendar__body uni-calendar__month-div"},za={key:5,class:"uni-calendar__body uni-calendar__week-div"},ja={key:6,class:"uni-calendar__body uni-calendar__day-div"},qa={class:"uni-calendar__footer"};function Xa(e,t,l,i,s,o){const n=a.resolveComponent("calendar-header"),r=a.resolveComponent("year-picker"),c=a.resolveComponent("month-picker"),h=a.resolveComponent("year-view"),T=a.resolveComponent("month-view"),$=a.resolveComponent("calendar-swiper"),N=a.resolveComponent("week-view"),M=a.resolveComponent("day-view");return a.openBlock(),a.createElementBlock("div",{class:a.normalizeClass(["uni-calendar",[`uni-calendar--${e.mode}`,{"uni-calendar--auto-height":e.autoHeight}]])},[a.createElementVNode("div",Aa,[a.renderSlot(e.$slots,"header",{},()=>[a.createVNode(n,{"current-year":e.currentYear,"current-month":e.currentMonth,mode:e.mode,"show-year-picker":e.showYearPicker,"show-month-picker":e.showMonthPicker,onPrev:e.handlePrev,onNext:e.handleNext,onToday:e.goToToday,onToggleYearPicker:e.toggleYearPicker,onToggleMonthPicker:e.toggleMonthPicker},null,8,["current-year","current-month","mode","show-year-picker","show-month-picker","onPrev","onNext","onToday","onToggleYearPicker","onToggleMonthPicker"])])]),e.showYearPicker||e.showMonthPicker?(a.openBlock(),a.createElementBlock("div",{key:0,class:"uni-calendar__mask",onClick:t[0]||(t[0]=(..._)=>e.handleOutsideClick&&e.handleOutsideClick(..._))})):a.createCommentVNode("",!0),e.showYearPicker?(a.openBlock(),a.createBlock(r,{key:1,"current-year":e.currentYear,range:e.yearRange,onYearSelect:e.handleYearSelect},null,8,["current-year","range","onYearSelect"])):a.createCommentVNode("",!0),e.showMonthPicker?(a.openBlock(),a.createBlock(c,{key:2,"current-month":e.currentMonth,onMonthSelect:e.handleMonthSelect},null,8,["current-month","onMonthSelect"])):a.createCommentVNode("",!0),e.mode==="year"?(a.openBlock(),a.createBlock(h,{key:3,year:e.currentYear,"selected-month":e.currentMonth,onMonthClick:e.handleYeardivMonthClick},null,8,["year","selected-month","onMonthClick"])):e.mode==="month"?(a.openBlock(),a.createElementBlock("div",Ia,[a.createVNode($,{ref:"swiperRef",onSwipeLeft:t[1]||(t[1]=_=>e.handleSwiperChange("next")),onSwipeRight:t[2]||(t[2]=_=>e.handleSwiperChange("prev"))},{default:a.withCtx(()=>[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(e.swiperMonths,(_,S)=>(a.openBlock(),a.createElementBlock("div",{key:S,class:a.normalizeClass(["uni-calendar__swiper-item",{active:S===e.swiperCurrent}])},[a.createVNode(T,{year:_.year,month:_.month,"selected-date":e.innerValue,"range-start":e.rangeStart,"range-end":e.rangeEnd,"first-day-of-week":e.firstDayOfWeek,"show-lunar":e.showLunar,"show-holiday":e.showHoliday,"show-price":e.showPrice,"price-data":e.priceData,"check-in-data":e.checkInData,"disabled-date":e.disabledDate,"highlight-weekend":e.highlightWeekend,"range-mode":e.rangeMode,"allow-click-other-month-day":e.allowClickOtherMonthDay,onDayClick:e.handleDayClick},{"date-cell":a.withCtx(({day:g})=>[a.renderSlot(e.$slots,"date-cell",{day:g})]),_:2},1032,["year","month","selected-date","range-start","range-end","first-day-of-week","show-lunar","show-holiday","show-price","price-data","check-in-data","disabled-date","highlight-weekend","range-mode","allow-click-other-month-day","onDayClick"])],2))),128))]),_:3},512)])):e.mode==="week"?(a.openBlock(),a.createElementBlock("div",za,[a.createVNode($,{ref:"weekSwiperRef",onSwipeLeft:t[3]||(t[3]=_=>e.handleSwiperChange("next")),onSwipeRight:t[4]||(t[4]=_=>e.handleSwiperChange("prev"))},{default:a.withCtx(()=>[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(e.swiperWeeks,(_,S)=>(a.openBlock(),a.createElementBlock("div",{key:S,class:a.normalizeClass(["uni-calendar__swiper-item",{active:S===e.swiperCurrent}])},[a.createVNode(N,{date:_.date,"selected-date":e.innerValue,"range-start":e.rangeStart,"range-end":e.rangeEnd,"first-day-of-week":e.firstDayOfWeek,"show-lunar":e.showLunar,"show-holiday":e.showHoliday,"show-price":e.showPrice,"price-data":e.priceData,"check-in-data":e.checkInData,"disabled-date":e.disabledDate,"highlight-weekend":e.highlightWeekend,"range-mode":e.rangeMode,"allow-click-other-month-day":e.allowClickOtherMonthDay,onDayClick:e.handleDayClick},{"date-cell":a.withCtx(({day:g})=>[a.renderSlot(e.$slots,"date-cell",{day:g})]),_:2},1032,["date","selected-date","range-start","range-end","first-day-of-week","show-lunar","show-holiday","show-price","price-data","check-in-data","disabled-date","highlight-weekend","range-mode","allow-click-other-month-day","onDayClick"])],2))),128))]),_:3},512)])):e.mode==="day"?(a.openBlock(),a.createElementBlock("div",ja,[a.createVNode($,{ref:"daySwiperRef",onSwipeLeft:t[5]||(t[5]=_=>e.handleSwiperChange("next")),onSwipeRight:t[6]||(t[6]=_=>e.handleSwiperChange("prev"))},{default:a.withCtx(()=>[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(e.swiperDays,(_,S)=>(a.openBlock(),a.createElementBlock("div",{key:S,class:a.normalizeClass(["uni-calendar__swiper-item",{active:S===e.swiperCurrent}])},[a.createVNode(M,{date:_.date,"selected-date":e.innerValue,"first-day-of-week":e.firstDayOfWeek,"show-lunar":e.showLunar,"show-holiday":e.showHoliday,"show-price":e.showPrice,"price-data":e.priceData,"check-in-data":e.checkInData,"disabled-date":e.disabledDate,"highlight-weekend":e.highlightWeekend,"allow-click-other-month-day":e.allowClickOtherMonthDay,onDayClick:e.handleDayClick,onCheckIn:e.handleCheckIn},null,8,["date","selected-date","first-day-of-week","show-lunar","show-holiday","show-price","price-data","check-in-data","disabled-date","highlight-weekend","allow-click-other-month-day","onDayClick","onCheckIn"])],2))),128))]),_:1},512)])):a.createCommentVNode("",!0),a.createElementVNode("div",qa,[a.renderSlot(e.$slots,"footer")])],2)}const ee=v(La,[["render",Xa]]);P.Calendar=ee,P.default=ee,Object.defineProperties(P,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});