import{_ as V,r as h,q as d,o as g,c as y,b as u,t as w,D as b,g as B,e as N,K as R,h as A,d as M,z as $,G as p}from"./index-DQXQiKd8.js";import{F as z,l as T,i as q,a as F}from"./es-C6Rdl88H.js";const E=["aria-expanded"],G={class:"month-pick__toggle-label"},H={class:"fc-wrap"},O={__name:"MonthPickCalendar",props:{modelValue:{type:String,default:""},highlightDates:{type:Array,default:()=>[]},badgeByDate:{type:Object,default:()=>({})},minDate:{type:String,default:""},collapsible:{type:Boolean,default:!0},defaultCollapsed:{type:Boolean,default:!1},title:{type:String,default:"Calendario"},aspectRatio:{type:Number,default:1.12},firstDay:{type:Number,default:1},variant:{type:String,default:"default"}},emits:["update:modelValue","range-change"],setup(i,{emit:D}){const a=i,n=h(a.defaultCollapsed),c=h(null);d(()=>a.defaultCollapsed,e=>{n.value=e});function r(){const e=c.value?.getApi();if(e){e.updateSize();try{e.render()}catch{}}}d(n,e=>{e||p(()=>{r(),requestAnimationFrame(()=>{r(),setTimeout(r,80)})})});const f=D;function s(e){const t=e.getFullYear(),l=String(e.getMonth()+1).padStart(2,"0"),o=String(e.getDate()).padStart(2,"0");return`${t}-${l}-${o}`}function C(){return new Set(a.highlightDates.map(e=>String(e).slice(0,10)))}function S(e){const t=s(e.start),l=s(new Date(e.end.getTime()-1));f("range-change",{from:t,to:l})}function v(e){const t=s(e.date);a.minDate&&t<a.minDate||f("update:modelValue",t)}function k(e){const t=s(e.date),l=[];return a.minDate&&t<a.minDate&&l.push("cal-day-past"),C().has(t)&&l.push("cal-day-has-slots"),a.modelValue&&t===a.modelValue.slice(0,10)&&l.push("cal-day-selected"),l}function x(e){if(e.el.querySelector(".cal-appt-badge"))return;const t=s(e.date),l=a.badgeByDate[t];if(l!=null&&Number(l)>0){e.el.setAttribute("title",`${l} cita(s)`);const o=document.createElement("span");o.className="cal-appt-badge",o.textContent=String(l);const m=e.el.querySelector(".fc-daygrid-day-top");m&&m.appendChild(o)}}const _=$(()=>({plugins:[q,F],initialView:"dayGridMonth",locale:T,firstDay:a.firstDay,aspectRatio:a.aspectRatio,headerToolbar:{left:"prev,next today",center:"title",right:""},buttonText:{today:"Hoy"},height:"auto",fixedWeekCount:!1,expandRows:!0,handleWindowResize:!0,stickyHeaderDates:!0,selectable:!1,dateClick:v,datesSet:S,dayCellClassNames:k,dayCellDidMount:x}));return d(()=>[a.modelValue,a.highlightDates,a.minDate,a.badgeByDate],()=>{p(()=>{c.value?.getApi()?.render()})},{deep:!0}),d(()=>a.modelValue,e=>{e&&p(()=>{const t=c.value?.getApi();t&&t.gotoDate(e)})}),(e,t)=>(g(),y("div",{class:b(["month-pick",{"month-pick--collapsible":i.collapsible,"month-pick--embed":i.variant==="embed"}])},[i.collapsible?(g(),y("button",{key:0,type:"button",class:"month-pick__toggle","aria-expanded":!n.value,onClick:t[0]||(t[0]=l=>n.value=!n.value)},[u("span",G,w(i.title),1),u("span",{class:b(["month-pick__chev",{"is-open":!n.value}]),"aria-hidden":"true"},"▾",2)],8,E)):B("",!0),N(u("div",H,[A(M(z),{ref_key:"fcRef",ref:c,options:_.value},null,8,["options"])],512),[[R,!i.collapsible||!n.value]])],2))}},Y=V(O,[["__scopeId","data-v-d00fe200"]]);export{Y as M};
