@dayflow/core 3.1.2 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -13
- package/dist/index.d.ts +480 -294
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/styles.css +89 -1
- package/package.json +43 -42
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Temporal as e}from"temporal-polyfill";import{createContext as t,options as n,Fragment as r,h as a,render as o,isValidElement as l,cloneElement as i}from"preact";import{useState as s,useRef as d,useEffect as c,useContext as u,useMemo as h,useCallback as g,useLayoutEffect as m}from"preact/hooks";import{createPortal as v,memo as f,forwardRef as p}from"preact/compat";export{createPortal}from"preact/compat";import{__awaiter as y,__rest as b}from"tslib";import{BlossomColorPicker as w,hexToHsl as D,lightnessToSliderValue as x,DEFAULT_COLORS as E,hslToHex as C}from"@dayflow/blossom-color-picker";var k;!function(e){e.DAY="day",e.WEEK="week",e.MONTH="month",e.YEAR="year"}(k||(k={}));const T={INDENT_STEP:2,MIN_WIDTH:25,MARGIN_BETWEEN:2,CONTAINER_WIDTH:320,OVERLAP_THRESHOLD:.25,EDGE_MARGIN:3,MAX_LOAD_IMBALANCE:0,REBALANCE_THRESHOLD:2},N={OVERSCAN:6,BUFFER_SIZE:100,MIN_YEAR:1900,MAX_YEAR:2200,SCROLL_THROTTLE:8,SCROLL_DEBOUNCE:150,CACHE_CLEANUP_THRESHOLD:200,MOBILE_WEEK_HEIGHT:80,TABLET_WEEK_HEIGHT:90,WEEK_HEIGHT:119};class S{constructor(e=N.BUFFER_SIZE){this.cache=new Map,this.accessOrder=[],this.maxSize=e}getKey(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}get(e){const t=this.getKey(e),n=this.cache.get(t);if(n)return this.updateAccessOrder(t),n}set(e,t){const n=this.getKey(e);if(this.cache.size>=this.maxSize){const e=this.accessOrder.shift();void 0!==e&&this.cache.delete(e)}this.cache.set(n,t),this.updateAccessOrder(n)}updateAccessOrder(e){const t=this.accessOrder.indexOf(e);t>-1&&this.accessOrder.splice(t,1),this.accessOrder.push(e)}getSize(){return this.cache.size}clear(){this.cache.clear(),this.accessOrder=[]}}const M=[{id:"blue",name:"Blue",isDefault:!0,colors:{eventColor:"#eff6ff",eventSelectedColor:"rgba(59, 130, 246)",lineColor:"#3b82f6",textColor:"#1e3a8a"},darkColors:{eventColor:"rgba(30, 64, 175, 0.8)",eventSelectedColor:"rgba(30, 58, 138, 1)",lineColor:"#3b82f6",textColor:"#dbeafe"}},{id:"green",name:"Green",isDefault:!0,colors:{eventColor:"#f0fdf4",eventSelectedColor:"rgba(16, 185, 129, 1)",lineColor:"#10b981",textColor:"#064e3b"},darkColors:{eventColor:"rgba(4, 120, 87, 0.8)",eventSelectedColor:"rgba(6, 78, 59, 1)",lineColor:"#10b981",textColor:"#d1fae5"}},{id:"purple",name:"Purple",isDefault:!0,colors:{eventColor:"#faf5ff",eventSelectedColor:"rgba(139, 92, 246, 1)",lineColor:"#8b5cf6",textColor:"#5b21b6"},darkColors:{eventColor:"rgba(109, 40, 217, 0.8)",eventSelectedColor:"rgba(91, 33, 182, 1)",lineColor:"#8b5cf6",textColor:"#ede9fe"}},{id:"yellow",name:"Yellow",isDefault:!0,colors:{eventColor:"#fefce8",eventSelectedColor:"rgba(245, 158, 11, 1)",lineColor:"#f59e0b",textColor:"#78350f"},darkColors:{eventColor:"rgba(180, 83, 9, 0.8)",eventSelectedColor:"rgba(120, 53, 15, 1)",lineColor:"#f59e0b",textColor:"#fef3c7"}},{id:"red",name:"Red",isDefault:!0,colors:{eventColor:"#fef2f2",eventSelectedColor:"rgba(239, 68, 68, 1)",lineColor:"#ef4444",textColor:"#7f1d1d"},darkColors:{eventColor:"rgba(185, 28, 28, 0.8)",eventSelectedColor:"rgba(127, 29, 29, 1)",lineColor:"#ef4444",textColor:"#fee2e2"}},{id:"orange",name:"Orange",isDefault:!0,colors:{eventColor:"#fff7edb3",eventSelectedColor:"rgba(249, 115, 22, 1)",lineColor:"#f97316",textColor:"#7c2d12"},darkColors:{eventColor:"rgba(194, 65, 12, 0.8)",eventSelectedColor:"rgba(124, 45, 18, 1)",lineColor:"#f97316",textColor:"#fed7aa"}},{id:"pink",name:"Pink",isDefault:!0,colors:{eventColor:"#fdf2f8",eventSelectedColor:"rgba(236, 72, 153, 1)",lineColor:"#ec4899",textColor:"#831843"},darkColors:{eventColor:"rgba(190, 24, 93, 0.8)",eventSelectedColor:"rgba(131, 24, 67, 1)",lineColor:"#ec4899",textColor:"#fce7f3"}},{id:"teal",name:"Teal",isDefault:!0,colors:{eventColor:"#f0fdfa",eventSelectedColor:"rgba(20, 184, 166, 1)",lineColor:"#14b8a6",textColor:"#134e4a"},darkColors:{eventColor:"rgba(15, 118, 110, 0.8)",eventSelectedColor:"rgba(19, 78, 74, 1)",lineColor:"#14b8a6",textColor:"#ccfbf1"}},{id:"indigo",name:"Indigo",isDefault:!0,colors:{eventColor:"#eef2ffb3",eventSelectedColor:"rgba(99, 102, 241, 1)",lineColor:"#6366f1",textColor:"#312e81"},darkColors:{eventColor:"rgba(67, 56, 202, 0.8)",eventSelectedColor:"rgba(49, 46, 129, 1)",lineColor:"#6366f1",textColor:"#e0e7ff"}},{id:"gray",name:"Gray",isDefault:!0,colors:{eventColor:"#f9fafbb3",eventSelectedColor:"rgba(107, 114, 128, 1)",lineColor:"#6b7280",textColor:"#1f2937"},darkColors:{eventColor:"rgba(75, 85, 99, 0.8)",eventSelectedColor:"rgba(31, 41, 55, 1)",lineColor:"#6b7280",textColor:"#f3f4f6"}}];class I{constructor(e,t,n="light"){this.calendars=new Map,this.defaultCalendarId=t||"blue",this.currentTheme=n;const r=e&&e.length>0;e?e.forEach(e=>{this.calendars.set(e.id,e)}):M.forEach(e=>{this.calendars.set(e.id,Object.assign(Object.assign({},e),{isVisible:!r&&e.isVisible}))})}register(e){this.calendars.set(e.id,e)}unregister(e){return this.calendars.delete(e)}get(e){return this.calendars.get(e)}getAll(){return Array.from(this.calendars.values())}getVisible(){return this.getAll().filter(e=>!1!==e.isVisible)}has(e){return this.calendars.has(e)}reorder(e,t){const n=Array.from(this.calendars.entries());if(e<0||e>=n.length||t<0||t>=n.length)return;const[r]=n.splice(e,1);n.splice(t,0,r),this.calendars.clear(),n.forEach(([e,t])=>{this.calendars.set(e,t)})}setVisibility(e,t){const n=this.calendars.get(e);n&&this.calendars.set(e,Object.assign(Object.assign({},n),{isVisible:t}))}setAllVisibility(e){this.calendars.forEach((t,n)=>{this.calendars.set(n,Object.assign(Object.assign({},t),{isVisible:e}))})}updateCalendar(e,t){const n=this.calendars.get(e);n&&this.calendars.set(e,Object.assign(Object.assign({},n),t))}setDefaultCalendar(e){if(!this.has(e))throw new Error(`Calendar type '${e}' does not exist`);this.defaultCalendarId=e}getDefaultCalendarId(){return this.defaultCalendarId}getDefaultCalendar(){const e=this.get(this.defaultCalendarId);return e||this.getAll()[0]}setTheme(e){this.currentTheme=e}getTheme(){return this.currentTheme}resolveColors(e,t){const n=t||this.currentTheme,r=this.isDarkTheme(n);let a;return e&&(a=this.get(e)),a||(a=this.getDefaultCalendar()),r&&a.darkColors?a.darkColors:a.colors}getSelectedBgColor(e,t){return this.resolveColors(e,t).eventSelectedColor}getLineColor(e,t){return this.resolveColors(e,t).lineColor}getTextColor(e,t){return this.resolveColors(e,t).textColor}isDarkTheme(e){return"dark"===e||"light"!==e&&(!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-color-scheme: dark)").matches)}validate(e){const t=[];return e.id||t.push("Calendar type must have an id"),e.name||t.push("Calendar type must have a name"),e.colors?(e.colors.eventColor||t.push("Calendar colors must include eventColor"),e.colors.eventSelectedColor||t.push("Calendar colors must include eventSelectedColor"),e.colors.lineColor||t.push("Calendar colors must include lineColor"),e.colors.textColor||t.push("Calendar colors must include textColor")):t.push("Calendar type must have colors configuration"),t}}let H=new I;function R(){return H}function O(e){const t=M.find(t=>t.colors.lineColor.toLowerCase()===e.toLowerCase());return t?{colors:t.colors,darkColors:t.darkColors}:{colors:{eventColor:e+"1A",eventSelectedColor:e,lineColor:e,textColor:e},darkColors:{eventColor:e+"CC",eventSelectedColor:e,lineColor:e,textColor:"#ffffff"}}}class P{constructor(e=[]){this.events=new Map,this.isInTransaction=!1,this.pendingChanges=[],e.forEach(e=>this.events.set(e.id,e))}beginTransaction(){this.isInTransaction?console.warn("Transaction already in progress. Nested transactions are not supported."):(this.isInTransaction=!0,this.pendingChanges=[])}endTransaction(){var e;if(!this.isInTransaction)return;const t=P.normalizeChanges(this.pendingChanges);this.isInTransaction=!1,this.pendingChanges=[],t.length>0&&(null===(e=this.onEventBatchChange)||void 0===e||e.call(this,t))}createEvent(e){if(this.events.has(e.id))throw new Error(`Event with ID ${e.id} already exists.`);this.events.set(e.id,e),this.emitChange({type:"create",event:e})}updateEvent(e,t){const n=this.events.get(e);if(!n)throw new Error(`Event with id ${e} not found`);const r=Object.assign(Object.assign({},n),t);this.events.set(e,r),this.emitChange({type:"update",before:n,after:r})}deleteEvent(e){const t=this.events.get(e);t&&(this.events.delete(e),this.emitChange({type:"delete",event:t}))}getEvent(e){return this.events.get(e)}getAllEvents(){return Array.from(this.events.values())}emitChange(e){var t;this.isInTransaction?this.pendingChanges.push(e):null===(t=this.onEventChange)||void 0===t||t.call(this,e)}static normalizeChanges(e){const t=new Map;for(const n of e){const e="delete"===n.type?n.event.id:"update"===n.type?n.after.id:n.event.id,r=t.get(e);r?"create"===r.type?"update"===n.type?t.set(e,{type:"create",event:n.after}):"delete"===n.type&&t.delete(e):"update"===r.type?"update"===n.type?t.set(e,{type:"update",before:r.before,after:n.after}):"delete"===n.type&&t.set(e,{type:"delete",event:r.before}):"delete"===r.type&&"create"===n.type&&t.set(e,{type:"update",before:r.event,after:n.event}):t.set(e,n)}return Array.from(t.values())}}const L=new class{constructor(){var e,t;this.isDevelopment="production"!==(null===(t=null===(e=globalThis.process)||void 0===e?void 0:e.env)||void 0===t?void 0:t.NODE_ENV)}formatMessage(e,t,...n){if(!this.isDevelopment)return;const r=(new Date).toISOString(),a=`[DayFlow ${e.toUpperCase()}] ${r}:`;switch(e){case"log":console.log(a,t,...n);break;case"warn":console.warn(a,t,...n);break;case"error":console.error(a,t,...n);break;case"debug":console.debug(a,t,...n)}}log(e,...t){this.formatMessage("log",e,...t)}warn(e,...t){this.formatMessage("warn",e,...t)}error(e,...t){this.formatMessage("error",e,...t)}debug(e,...t){this.formatMessage("debug",e,...t)}},A={code:"en-US",messages:{allDay:"All day",noEvents:"No events for this day",more:"more",eventTitle:"Event Title",dateRange:"Date Range",timeRange:"Time Range",note:"Note",addNotePlaceholder:"Add a note...",setAsAllDay:"Set as All-day",setAsTimed:"Set as Timed Event",delete:"Delete",confirm:"Confirm",cancel:"Cancel",today:"Today",day:"Day",week:"Week",month:"Month",year:"Year",newEvent:"New Event",newAllDayEvent:"New All-day Event",newCalendarEvent:"New {calendarName} Event",newAllDayCalendarEvent:"New {calendarName} All-day Event",save:"Save",deleteCalendar:'Delete "{calendarName}"?',deleteCalendarMessage:'Do you want to delete "{calendarName}" or merge its events into another existing calendar?',merge:"Merge",confirmDeleteTitle:'Are you sure you want to delete the calendar "{calendarName}"?',confirmDeleteMessage:"If you delete this calendar, all events associated with the calendar will also be deleted.",mergeConfirmTitle:'Merge "{sourceName}" with "{targetName}"?',mergeConfirmMessage:'Are you sure you want to merge "{sourceName}" with "{targetName}"? Doing so will move all the events from "{sourceName}" to "{targetName}" and "{sourceName}" will be deleted. This cannot be undone.',expandSidebar:"Expand calendar sidebar",collapseSidebar:"Collapse calendar sidebar",calendars:"Calendars",createCalendar:"Create New Calendar",calendarNamePlaceholder:"e.g. Work",customColor:"Custom Color...",create:"Create",calendarOptions:"Calendar Options",untitled:"Untitled",search:"Search",noResults:"No results found",calendar:"Calendar",starts:"Starts",ends:"Ends",notes:"Notes",titlePlaceholder:"Title",notesPlaceholder:"Notes",editEvent:"Edit Event",viewEvent:"View Event",done:"Done",quickCreateEvent:"Quick Create Event",quickCreatePlaceholder:"Movie at 7pm on Friday",noSuggestions:"Type to create",newCalendar:"New Calendar",refreshAll:"Refresh All",tomorrow:"Tomorrow",importCalendar:"Import Calendar",exportCalendar:"Export Calendar",addSchedule:"Add Schedule",importCalendarMessage:"This calendar contains new events. Please select a target calendar.",ok:"OK",cut:"Cut",copy:"Copy",pasteHere:"Paste Here",eventSummary:"Summary"}},$={en:A};function j(e){const t=e.code.split("-")[0].toLowerCase();$[t]=e}function Y(e){const t=e.split("-")[0].toLowerCase();return t in $?t:"en"}function F(e){try{return new Intl.DateTimeFormat(e),!0}catch(e){return!1}}function z(t){var n;return!(!t||"object"!=typeof t)&&(!(t instanceof Date)&&(t instanceof e.PlainDate||("PlainDate"===(null===(n=null==t?void 0:t.constructor)||void 0===n?void 0:n.name)||!("hour"in t)&&!("timeZone"in t)&&"year"in t&&"month"in t&&"day"in t)))}function _(e){return e instanceof Date}function Z(t,n=e.Now.timeZoneId()){return e.Instant.fromEpochMilliseconds(t.getTime()).toZonedDateTimeISO(n)}function W(e){return"number"==typeof e.epochMilliseconds?new Date(e.epochMilliseconds):new Date(e.year,e.month-1,e.day,e.hour,e.minute)}function U(t,n){if(t instanceof Date)return t;if(z(t))return function(t,n=e.Now.timeZoneId()){if("function"==typeof t.toZonedDateTime)try{return W(t.toZonedDateTime({timeZone:n,plainTime:e.PlainTime.from({hour:0,minute:0})}))}catch(e){}return new Date(t.year,t.month-1,t.day)}(t,n);if(t&&"object"==typeof t&&"hour"in t&&!("timeZone"in t)){const e=t;return new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second||0,e.millisecond||0)}return t&&"object"==typeof t&&"year"in t?W(t):new Date(t)}function B(t,n){const r=Math.floor(n),a=Math.round(60*(n-r));return z(t)?e.PlainDateTime.from({year:t.year,month:t.month,day:t.day,hour:r,minute:a}):"function"==typeof t.with?t.with({hour:r,minute:a,second:0,millisecond:0}):e.PlainDateTime.from({year:t.year,month:t.month,day:t.day,hour:r,minute:a})}function V(t,n){if(t instanceof Date&&n instanceof Date)return t.toDateString()===n.toDateString();const r=t=>{return t instanceof Date?(n=t,e.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()})):z(t)?t:"function"==typeof t.toPlainDate?t.toPlainDate():e.PlainDate.from({year:t.year,month:t.month,day:t.day});var n},a=r(t),o=r(n);return 0===e.PlainDate.compare(a,o)}function q(e,t){return!V(e,t)}function G(t,n=e.Now.timeZoneId()){if("function"==typeof t.toZonedDateTime){return(z(t)?t:t.toPlainDate()).toZonedDateTime({timeZone:n,plainTime:e.PlainTime.from({hour:0,minute:0})})}return(z(t)?t:e.PlainDate.from({year:t.year,month:t.month,day:t.day})).toZonedDateTime({timeZone:n,plainTime:e.PlainTime.from({hour:0,minute:0})})}function K(t,n=e.Now.timeZoneId()){if("function"==typeof t.toZonedDateTime){return(z(t)?t:t.toPlainDate()).toZonedDateTime({timeZone:n,plainTime:e.PlainTime.from({hour:23,minute:59,second:59,millisecond:999})})}return(z(t)?t:e.PlainDate.from({year:t.year,month:t.month,day:t.day})).toZonedDateTime({timeZone:n,plainTime:e.PlainTime.from({hour:23,minute:59,second:59,millisecond:999})})}function X(t,n){const r=t=>z(t)?t:"function"==typeof t.toPlainDate?t.toPlainDate():e.PlainDate.from({year:t.year,month:t.month,day:t.day}),a=r(t),o=r(n);return a.until(o).days}function J(e,t){const n=new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=new Date(t.getFullYear(),t.getMonth(),t.getDate());return Math.round((r.getTime()-n.getTime())/864e5)}function Q(e,t){const n=new Date(e);return n.setDate(n.getDate()+t),n}function ee(t=e.Now.timeZoneId()){return e.Now.zonedDateTimeISO(t)}function te(t=e.Now.timeZoneId()){return e.Now.plainDateISO(t)}const ne=e=>{if(e instanceof Date){return e.getHours()+e.getMinutes()/60}return(t=e)instanceof Date?t.getHours()+t.getMinutes()/60:z(t)?0:null!==t&&"object"==typeof t&&"hour"in t&&void 0!==t.hour?t.hour+(null!==(n=t.minute)&&void 0!==n?n:0)/60:0;var t,n},re=(e,t)=>{if(e instanceof Date){const n=new Date(e),r=Math.floor(t),a=Math.round(60*(t-r));return n.setHours(r,a,0,0),n}return B(e,t)},ae=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(0,0,0,0),t}return G(e)},oe=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(23,59,59,999),t}return K(e)},le=(t,n)=>{if(t instanceof Date&&n instanceof Date)return t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate();return V(t instanceof Date?e.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}):z(t)?t:t.toPlainDate(),n instanceof Date?e.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()}):z(n)?n:n.toPlainDate())},ie=(e,t)=>!le(e,t),se=(e,t)=>(t||R()).resolveColors(e).eventColor,de=(e,t)=>(t||R()).resolveColors(e).textColor,ce=(e,t)=>(t||R()).resolveColors(e).eventSelectedColor,ue=(e,t)=>(t||R()).resolveColors(e).lineColor,he=.25,ge=(e,t=0)=>{const n=Math.floor(e),r=t||Math.round(60*(e-n));return`${n.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`},me=e=>{const t=ne(e.start),n=fe(e);return`${ge(t)} - ${ge(n)}`},ve=e=>.25*Math.round(e/.25),fe=e=>{if(!e.end)return 0;const t=ne(e.end);if(e.allDay||!e.start)return t;const n=U(e.start),r=U(e.end);if(!(n.getFullYear()!==r.getFullYear()||n.getMonth()!==r.getMonth()||n.getDate()!==r.getDate()))return t;if(0===t&&0===r.getMinutes()&&0===r.getSeconds()&&0===r.getMilliseconds()){const e=r.getTime()-n.getTime();if(e>0&&e<864e5)return 24}return t},pe=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],ye=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],be=["January","February","March","April","May","June","July","August","September","October","November","December"],we=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],De=e=>{const t=e.getDay(),n=e.getDate()-t+(0===t?-6:1),r=new Date(e);r.setDate(n),r.setHours(0,0,0,0);const a=new Date(r);return a.setDate(r.getDate()+6),a.setHours(23,59,59,999),{monday:r,sunday:a}},xe=()=>{const e=new Date,t=new Date,n=e.getDay(),r=e.getDate()-n+(0===n?-6:1);return pe.map((n,a)=>{const o=new Date(e);return o.setDate(r+a),{date:o.getDate(),month:o.toLocaleString("default",{month:"short"}),isToday:o.getDate()===t.getDate()&&o.getMonth()===t.getMonth()&&o.getFullYear()===t.getFullYear()}})},Ee=e=>{const t=new Date(e),n=t.getDate(),r=t.getMonth(),a=t.getFullYear(),o=new Date;return{date:t,day:n,month:r,year:a,monthName:be[r],shortMonthName:we[r],isToday:o.getDate()===n&&o.getMonth()===r&&o.getFullYear()===a}},Ce=e=>{const t=[],n=new Date(e);for(let e=0;e<7;e++){const e=new Date(n);t.push(Ee(e)),n.setDate(n.getDate()+1)}return{days:t,startDate:new Date(e),monthYear:ke(t)}},ke=e=>{const t={};e.forEach(e=>{const n=`${e.month}-${e.year}`;t[n]=(t[n]||0)+1});let n=0,r="";Object.entries(t).forEach(([e,t])=>{t>n&&(n=t,r=e)});const[a,o]=r.split("-").map(Number);return{month:be[a],monthIndex:a,year:o}},Te=(e,t=3)=>{const n=5*t,{monday:r}=De(e),a=[],o=Math.floor(n/2),l=new Date(r);l.setDate(l.getDate()-7*o);for(let e=0;e<n;e++){const t=new Date(l);t.setDate(t.getDate()+7*e),a.push(Ce(t))}return a};function Ne(e,t){const n=[],r=Math.floor(t/2),a=new Date(e),o=e.getDay(),l=0===o?6:o-1;a.setDate(e.getDate()-l),a.setHours(0,0,0,0);const i=new Date(a);i.setDate(i.getDate()-7*r);for(let e=0;e<t;e++){const t=new Date(i);t.setDate(t.getDate()+7*e),n.push(Ce(t))}return n}const Se=(e,t)=>t.filter(t=>t.day===e&&!t.allDay),Me=(e,t,n)=>t.filter(t=>{if(!t.allDay)return!1;if(!n)return t.day===e;const r=new Date(n);r.setDate(n.getDate()+e),r.setHours(0,0,0,0);const a=U(t.start);a.setHours(0,0,0,0);const o=U(t.end);return o.setHours(0,0,0,0),r>=a&&r<=o}),Ie=(e,t)=>{const n=new Date(e);return n.setDate(e.getDate()+t),n},He=(t,n,r)=>{const a=Ie(r,n);return Object.assign(Object.assign({},t),{day:n,start:t.allDay?e.PlainDate.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate()}):e.ZonedDateTime.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate(),hour:a.getHours(),minute:a.getMinutes(),timeZone:e.Now.timeZoneId()}),end:t.allDay?e.PlainDate.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate()}):e.ZonedDateTime.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate(),hour:a.getHours(),minute:a.getMinutes(),timeZone:e.Now.timeZoneId()})})},Re=(t,n)=>n?e.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}):e.ZonedDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:t.getHours(),minute:t.getMinutes(),second:t.getSeconds(),millisecond:t.getMilliseconds(),timeZone:e.Now.timeZoneId()}),Oe=(e,t)=>{var n,r;const a=Ie(t,null!==(n=e.day)&&void 0!==n?n:0),o=null!==(r=e.allDay)&&void 0!==r&&r;return Object.assign(Object.assign({},e),{start:Re(a,o),end:Re(a,o)})},Pe=(e,t)=>{const n=new Date(e);n.setHours(0,0,0,0);const r=new Date(t);r.setHours(0,0,0,0);const a=n.getTime()-r.getTime();return Math.floor(a/864e5)},Le=(e,t)=>{const n=Pe(e,t);return n>=0&&n<=6},Ae=(e,t)=>e.map(e=>{const n=U(e.start),r=Pe(n,t);return Object.assign(Object.assign({},e),{day:r})}),$e=(e,t)=>{const n=new Date(e);n.setHours(0,0,0,0);const r=new Date(t);r.setHours(0,0,0,0);const a=r.getTime()-n.getTime();return Math.floor(a/864e5)},je=(e,t)=>{const n=new Date(t);return n.setDate(t.getDate()+6),n.setHours(23,59,59,999),e.filter(e=>{const r=U(e.start);return r>=t&&r<=n}).map(e=>{const n=Pe(U(e.start),t);return Object.assign(Object.assign({},e),{day:n})})},Ye=(e,t)=>{var n,r;const a=new Date(t);a.setDate(t.getDate()+(null!==(n=e.day)&&void 0!==n?n:0));const o=null!==(r=e.allDay)&&void 0!==r&&r;return Object.assign(Object.assign({},e),{start:Re(a,o),end:Re(a,o)})},Fe=(e,t,n)=>{var r;const a=new Date(n);a.setDate(n.getDate()+t);const o=null!==(r=e.allDay)&&void 0!==r&&r;return Object.assign(Object.assign({},e),{day:t,start:Re(a,o),end:Re(a,o)})},ze=(e,t)=>e===t||!(!e||!t)&&(e.title===t.title&&e.calendarId===t.calendarId&&(e.description||"")===(t.description||"")&&!!e.allDay==!!t.allDay&&e.start.toString()===t.start.toString()&&e.end.toString()===t.end.toString());function _e(){const t=new Date,n=t.getDay(),r=new Date(t),a=0===n?-6:1-n;r.setDate(t.getDate()+a),r.setHours(0,0,0,0);return[{id:"15",title:"C-早开始",day:3,startHour:8.5,endHour:10,calendarId:"teal"},{id:"16",title:"D-晚开始",day:3,startHour:9,endHour:10.5,calendarId:"red"},{id:"21",title:"A",day:0,startHour:14,endHour:16,calendarId:"blue"},{id:"22",title:"B",day:0,startHour:14.5,endHour:16,calendarId:"green"},{id:"23",title:"C",day:0,startHour:14.5,endHour:16,calendarId:"purple"},{id:"24",title:"D",day:0,startHour:15,endHour:16,calendarId:"yellow"},{id:"25",title:"E",day:0,startHour:15,endHour:16,calendarId:"red"},{id:"26",title:"F",day:0,startHour:15.5,endHour:16,calendarId:"orange"},{id:"27",title:"G",day:0,startHour:15,endHour:16,calendarId:"pink"},{id:"28",title:"H",day:0,startHour:15.5,endHour:16,calendarId:"teal"},{id:"29",title:"L",day:0,startHour:15.5,endHour:16,calendarId:"teal"},{id:"30",title:"I",day:0,startHour:15.5,endHour:16,calendarId:"blue"},{id:"99",title:"X",day:0,startHour:15.5,endHour:16,calendarId:"blue"},{id:"6",title:"假日",day:0,startHour:0,endHour:0,calendarId:"blue",allDay:!0},{id:"7",title:"研讨会",day:2,startHour:0,endHour:0,calendarId:"green",allDay:!0},{id:"8",title:"团队建设",day:4,startHour:0,endHour:0,calendarId:"purple",allDay:!0},{id:"41",title:"A",day:3,startHour:16,endHour:18.25,calendarId:"blue"},{id:"42",title:"B",day:3,startHour:16.5,endHour:18,calendarId:"green"},{id:"43",title:"C",day:3,startHour:16.75,endHour:17.75,calendarId:"purple"},{id:"44",title:"D",day:3,startHour:17,endHour:19,calendarId:"yellow"},{id:"45",title:"E",day:3,startHour:17.75,endHour:18.75,calendarId:"red"},{id:"46",title:"X",day:2,startHour:15,endHour:15.75,calendarId:"orange"},{id:"47",title:"Y",day:2,startHour:15.5,endHour:19.5,calendarId:"pink"},{id:"48",title:"Z",day:2,startHour:15,endHour:15.75,calendarId:"teal"},{id:"59",title:"Q",day:2,startHour:17,endHour:18,calendarId:"teal"},{id:"60",title:"W",day:2,startHour:15.5,endHour:18,calendarId:"teal"},{id:"31",title:"A",day:6,startHour:14,endHour:16,calendarId:"blue"},{id:"32",title:"B",day:6,startHour:14.5,endHour:16,calendarId:"green"},{id:"33",title:"C",day:6,startHour:14.5,endHour:16,calendarId:"purple"},{id:"34",title:"D",day:6,startHour:15,endHour:16,calendarId:"yellow"},{id:"35",title:"E",day:6,startHour:15.5,endHour:16.5,calendarId:"red"},{id:"36",title:"F",day:6,startHour:16.25,endHour:16.75,calendarId:"orange"},{id:"37",title:"G",day:6,startHour:16,endHour:17.25,calendarId:"pink"},{id:"51",title:"下周会议1",day:1,startHour:9,endHour:10,calendarId:"blue"},{id:"52",title:"下周会议2",day:3,startHour:14,endHour:15,calendarId:"green"},{id:"81",title:"A",day:5,startHour:14,endHour:16,calendarId:"blue"},{id:"82",title:"B",day:5,startHour:14.5,endHour:16,calendarId:"green"},{id:"83",title:"C",day:5,startHour:14.5,endHour:16,calendarId:"purple"},{id:"84",title:"D",day:5,startHour:15,endHour:16,calendarId:"yellow"},{id:"85",title:"E",day:5,startHour:15,endHour:16,calendarId:"red"},{id:"86",title:"F",day:5,startHour:15.75,endHour:17,calendarId:"orange"},{id:"87",title:"G",day:5,startHour:14.75,endHour:17.5,calendarId:"pink"}].map(t=>{const n=new Date(r);if(n.setDate(r.getDate()+t.day),t.allDay)return{id:t.id,title:t.title,start:e.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()}),end:e.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()}),allDay:!0,calendarId:t.calendarId,day:t.day};const a=Math.floor(t.startHour),o=Math.round(60*(t.startHour-a)),l=Math.floor(t.endHour),i=Math.round(60*(t.endHour-l));return{id:t.id,title:t.title,start:e.ZonedDateTime.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate(),hour:a,minute:o,timeZone:e.Now.timeZoneId()}),end:e.ZonedDateTime.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate(),hour:l,minute:i,timeZone:e.Now.timeZoneId()}),allDay:!1,calendarId:t.calendarId,day:t.day}})}function Ze(){return Date.now().toString(36)+Math.random().toString(36).substring(2,8)}function We(e,t){if(e===t)return!0;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const a of n)if(!r.includes(a)||!We(e[a],t[a]))return!1;return!0}class Ue{constructor(e){var t,n,r,a,o;this.undoStack=[],this.pendingSnapshot=null,this.MAX_UNDO_STACK=50,this.subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e)),this.notify=()=>{this.listeners.forEach(e=>e(this))},this.pushToUndo=e=>{this.undoStack.push({type:"events_snapshot",data:e||[...this.state.events]}),this.undoStack.length>this.MAX_UNDO_STACK&&this.undoStack.shift()},this.undo=()=>{if(0===this.undoStack.length)return;const e=this.undoStack.pop();"events_snapshot"===(null==e?void 0:e.type)&&(this.state.events=e.data,this.store=new P(this.state.events),this.setupStoreListeners(),this.triggerRender(),this.notify())},this.getReadOnlyConfig=()=>{var e,t;const n=this.state.readOnly;return!0===n?{draggable:!1,viewable:!1}:!1===n?{draggable:!0,viewable:!0}:{draggable:null!==(e=n.draggable)&&void 0!==e&&e,viewable:null!==(t=n.viewable)&&void 0!==t&&t}},this.isInternalEditable=()=>!0!==this.state.readOnly&&"object"!=typeof this.state.readOnly,this.changeView=e=>{var t,n;if(!this.state.views.has(e))throw new Error(`View ${e} is not registered`);this.state.currentView=e,this.state.highlightedEventId=null,null===(n=(t=this.callbacks).onViewChange)||void 0===n||n.call(t,e),this.handleVisibleRangeChange("viewChange"),this.notify()},this.getCurrentView=()=>{const e=this.state.views.get(this.state.currentView);if(!e)throw new Error(`Current view ${this.state.currentView} is not registered`);return e},this.emitVisibleRange=(e,t,n="navigation")=>{var r,a;null===(a=(r=this.callbacks).onVisibleRangeChange)||void 0===a||a.call(r,new Date(e),new Date(t),n)},this.handleVisibleRangeChange=e=>{const t=this.state.views.get(this.state.currentView);switch(null==t?void 0:t.type){case k.DAY:{const t=new Date(this.state.currentDate);t.setHours(0,0,0,0);const n=new Date(t);n.setDate(n.getDate()+1),this.emitVisibleRange(t,n,e);break}case k.WEEK:{const{monday:t}=De(this.state.currentDate),n=new Date(t),r=new Date(t);r.setDate(r.getDate()+7),this.emitVisibleRange(n,r,e);break}case k.MONTH:{if("navigation"===e)break;const t=new Date(this.state.currentDate.getFullYear(),this.state.currentDate.getMonth(),1),{monday:n}=De(t),r=new Date(n),a=new Date(n);a.setDate(a.getDate()+42),this.emitVisibleRange(r,a,e);break}case k.YEAR:{const t=new Date(this.state.currentDate.getFullYear(),0,1);t.setHours(0,0,0,0);const n=new Date(this.state.currentDate.getFullYear(),11,31);n.setDate(n.getDate()+1),this.emitVisibleRange(t,n,e);break}}},this.setCurrentDate=e=>{var t,n;this.state.currentDate=new Date(e),null===(n=(t=this.callbacks).onDateChange)||void 0===n||n.call(t,this.state.currentDate),this.setVisibleMonth(this.state.currentDate),this.handleVisibleRangeChange("navigation"),this.notify()},this.getCurrentDate=()=>new Date(this.state.currentDate),this.setVisibleMonth=e=>{var t,n;const r=new Date(e.getFullYear(),e.getMonth(),1);this.visibleMonth.getFullYear()===r.getFullYear()&&this.visibleMonth.getMonth()===r.getMonth()||(this.visibleMonth=r,null===(n=(t=this.callbacks).onVisibleMonthChange)||void 0===n||n.call(t,new Date(this.visibleMonth)),this.notify())},this.getVisibleMonth=()=>new Date(this.visibleMonth),this.goToToday=()=>{this.setCurrentDate(new Date)},this.goToPrevious=()=>{const e=new Date(this.state.currentDate);switch(this.state.currentView){case k.DAY:e.setDate(e.getDate()-1);break;case k.WEEK:e.setDate(e.getDate()-7);break;case k.MONTH:e.setMonth(e.getMonth()-1);break;case k.YEAR:e.setFullYear(e.getFullYear()-1)}this.setCurrentDate(e)},this.goToNext=()=>{const e=new Date(this.state.currentDate);switch(this.state.currentView){case k.DAY:e.setDate(e.getDate()+1);break;case k.WEEK:e.setDate(e.getDate()+7);break;case k.MONTH:e.setMonth(e.getMonth()+1);break;case k.YEAR:e.setFullYear(e.getFullYear()+1)}this.setCurrentDate(e)},this.selectDate=e=>{var t,n;this.setCurrentDate(e),null===(n=(t=this.callbacks).onDateChange)||void 0===n||n.call(t,new Date(e))},this.applyEventsChanges=(e,t)=>{if(this.isInternalEditable()||t){if(t?this.pendingSnapshot||(this.pendingSnapshot=[...this.state.events]):this.pendingSnapshot?(this.pushToUndo(this.pendingSnapshot),this.pendingSnapshot=null):this.pushToUndo(),t){let t=[...this.state.events];if(e.delete){const n=new Set(e.delete);t=t.filter(e=>!n.has(e.id))}return e.update&&e.update.forEach(({id:e,updates:n})=>{const r=t.findIndex(t=>t.id===e);-1!==r&&(t[r]=Object.assign(Object.assign({},t[r]),n))}),e.add&&(t=[...t,...e.add]),this.state.events=t,void this.notify()}this.store.beginTransaction(),e.delete&&e.delete.forEach(e=>this.store.deleteEvent(e)),e.update&&e.update.forEach(({id:e,updates:t})=>{try{this.store.updateEvent(e,t)}catch(t){console.warn(`Failed to update event ${e}:`,t)}}),e.add&&e.add.forEach(e=>{try{this.store.createEvent(e)}catch(t){console.warn(`Failed to create event ${e.id}:`,t)}}),this.store.endTransaction()}},this.addEvent=e=>{this.isInternalEditable()?(this.pendingSnapshot=null,this.pushToUndo(),this.store.createEvent(e)):L.warn("Cannot add event in read-only mode")},this.updateEvent=(e,t,n)=>{if(this.isInternalEditable()||n){if(this.isInternalEditable()){if(n?this.pendingSnapshot||(this.pendingSnapshot=[...this.state.events]):this.pendingSnapshot?(this.pushToUndo(this.pendingSnapshot),this.pendingSnapshot=null):this.pushToUndo(),n){const n=this.state.events.findIndex(t=>t.id===e);if(-1===n)throw new Error(`Event with id ${e} not found`);const r=Object.assign(Object.assign({},this.state.events[n]),t);return this.state.events=[...this.state.events.slice(0,n),r,...this.state.events.slice(n+1)],void this.notify()}this.store.updateEvent(e,t)}}else L.warn("Cannot update event in read-only mode")},this.deleteEvent=e=>{this.isInternalEditable()?(this.pendingSnapshot=null,this.pushToUndo(),this.store.deleteEvent(e)):L.warn("Cannot delete event in read-only mode")},this.getAllEvents=()=>[...this.state.events],this.onEventClick=e=>{var t,n;null===(n=(t=this.callbacks).onEventClick)||void 0===n||n.call(t,e)},this.onMoreEventsClick=e=>{var t,n;null===(n=(t=this.callbacks).onMoreEventsClick)||void 0===n||n.call(t,e)},this.highlightEvent=e=>{var t,n;this.state.highlightedEventId!==e&&(this.state.highlightedEventId=e,null===(n=(t=this.callbacks).onRender)||void 0===n||n.call(t),this.notify())},this.selectEvent=e=>{var t,n;this.state.selectedEventId!==e&&(this.state.selectedEventId=e,null===(n=(t=this.callbacks).onRender)||void 0===n||n.call(t),this.notify())},this.dismissUI=()=>{var e,t;null===(t=(e=this.callbacks).onDismissUI)||void 0===t||t.call(e),this.notify()},this.getEvents=()=>{const e=this.getAllEvents(),t=new Set(this.calendarRegistry.getAll().filter(e=>!1!==e.isVisible).map(e=>e.id));return e.filter(e=>!e.calendarId||(!this.calendarRegistry.has(e.calendarId)||t.has(e.calendarId)))},this.getCalendars=()=>this.calendarRegistry.getAll(),this.reorderCalendars=(e,t)=>{var n,r;this.calendarRegistry.reorder(e,t),null===(r=(n=this.callbacks).onRender)||void 0===r||r.call(n),this.notify()},this.setCalendarVisibility=(e,t)=>{var n,r;this.calendarRegistry.setVisibility(e,t),null===(r=(n=this.callbacks).onRender)||void 0===r||r.call(n),this.notify()},this.setAllCalendarsVisibility=e=>{var t,n;this.calendarRegistry.setAllVisibility(e),null===(n=(t=this.callbacks).onRender)||void 0===n||n.call(t),this.notify()},this.updateCalendar=(e,t,n)=>{var r,a,o,l;if(this.calendarRegistry.updateCalendar(e,t),n)return void this.notify();const i=this.calendarRegistry.get(e);i&&(null===(a=(r=this.callbacks).onCalendarUpdate)||void 0===a||a.call(r,i)),null===(l=(o=this.callbacks).onRender)||void 0===l||l.call(o),this.notify()},this.createCalendar=e=>{var t,n,r,a;this.calendarRegistry.register(e),null===(n=(t=this.callbacks).onCalendarCreate)||void 0===n||n.call(t,e),null===(a=(r=this.callbacks).onRender)||void 0===a||a.call(r),this.notify()},this.deleteCalendar=e=>{var t,n,r,a;this.calendarRegistry.unregister(e),null===(n=(t=this.callbacks).onCalendarDelete)||void 0===n||n.call(t,e),null===(a=(r=this.callbacks).onRender)||void 0===a||a.call(r),this.notify()},this.mergeCalendars=(e,t)=>{var n,r;const a=this.store.getAllEvents().filter(t=>t.calendarId===e);this.pushToUndo(),this.store.beginTransaction(),a.forEach(e=>{this.store.updateEvent(e.id,{calendarId:t})}),this.store.endTransaction(),this.deleteCalendar(e),null===(r=(n=this.callbacks).onCalendarMerge)||void 0===r||r.call(n,e,t)},this.getCalendarHeaderConfig=()=>this.useCalendarHeader,this.installPlugin=e=>{this.state.plugins.has(e.name)?L.warn(`Plugin ${e.name} is already installed`):(this.state.plugins.set(e.name,e),e.install(this))},this.getPlugin=e=>{const t=this.state.plugins.get(e);return null==t?void 0:t.api},this.hasPlugin=e=>this.state.plugins.has(e),this.getPluginConfig=e=>{const t=this.state.plugins.get(e);return(null==t?void 0:t.config)||{}},this.updatePluginConfig=(e,t)=>{const n=this.state.plugins.get(e);n&&(n.config=Object.assign(Object.assign({},n.config),t),this.notify())},this.getViewConfig=e=>{const t=this.state.views.get(e);return(null==t?void 0:t.config)||{}},this.triggerRender=()=>{var e,t;null===(t=(e=this.callbacks).onRender)||void 0===t||t.call(e),this.notify()},this.getCalendarRegistry=()=>this.calendarRegistry,this.getUseEventDetailDialog=()=>this.useEventDetailDialog,this.getCustomMobileEventRenderer=()=>this.customMobileEventRenderer,this.updateConfig=e=>{var t;let n=!1;if(void 0!==e.customMobileEventRenderer&&e.customMobileEventRenderer!==this.customMobileEventRenderer&&(this.customMobileEventRenderer=e.customMobileEventRenderer,n=!0),void 0!==e.useEventDetailDialog&&e.useEventDetailDialog!==this.useEventDetailDialog&&(this.useEventDetailDialog=e.useEventDetailDialog,n=!0),void 0!==e.useCalendarHeader&&e.useCalendarHeader!==this.useCalendarHeader&&(this.useCalendarHeader=e.useCalendarHeader,n=!0),void 0===e.readOnly||We(e.readOnly,this.state.readOnly)||(this.state.readOnly=e.readOnly,n=!0),e.callbacks&&(this.callbacks=Object.assign(Object.assign({},this.callbacks),e.callbacks)),void 0!==(null===(t=e.theme)||void 0===t?void 0:t.mode)&&e.theme.mode!==this.getTheme()&&this.setTheme(e.theme.mode),void 0!==e.switcherMode&&e.switcherMode!==this.state.switcherMode&&(this.state.switcherMode=e.switcherMode,n=!0),void 0!==e.locale){const t=this.resolveLocale(e.locale);We(t,this.state.locale)||(this.state.locale=t,n=!0)}n&&(this.triggerRender(),this.notify())},this.setTheme=e=>{var t,n;this.calendarRegistry.setTheme(e),this.themeChangeListeners.forEach(t=>{t(e)}),null===(n=(t=this.callbacks).onRender)||void 0===n||n.call(t),this.notify()},this.getTheme=()=>this.calendarRegistry.getTheme(),this.subscribeThemeChange=e=>(this.themeChangeListeners.add(e),()=>{this.unsubscribeThemeChange(e)}),this.unsubscribeThemeChange=e=>{this.themeChangeListeners.delete(e)},this.state={currentView:e.defaultView||k.WEEK,currentDate:e.initialDate||new Date,events:e.events||[],switcherMode:e.switcherMode||"buttons",plugins:new Map,views:new Map,locale:this.resolveLocale(e.locale),highlightedEventId:null,selectedEventId:null,readOnly:e.readOnly||!1},this.callbacks=e.callbacks||{},this.themeChangeListeners=new Set,this.listeners=new Set,this.store=new P(this.state.events),this.setupStoreListeners(),this.calendarRegistry=new I(e.calendars,e.defaultCalendar,(null===(t=e.theme)||void 0===t?void 0:t.mode)||"light"),o=this.calendarRegistry,H=o;const l=this.state.currentDate;this.visibleMonth=new Date(l.getFullYear(),l.getMonth(),1),this.useEventDetailDialog=null!==(n=e.useEventDetailDialog)&&void 0!==n&&n,this.useCalendarHeader=null===(r=e.useCalendarHeader)||void 0===r||r,this.customMobileEventRenderer=e.customMobileEventRenderer,e.views.forEach(e=>{this.state.views.set(e.type,e)}),null===(a=e.plugins)||void 0===a||a.forEach(e=>{this.installPlugin(e)}),this.handleVisibleRangeChange("initial")}setupStoreListeners(){this.store.onEventChange=e=>{var t,n,r,a,o,l;this.state.events=this.store.getAllEvents(),"create"===e.type?null===(n=(t=this.callbacks).onEventCreate)||void 0===n||n.call(t,e.event):"update"===e.type?null===(a=(r=this.callbacks).onEventUpdate)||void 0===a||a.call(r,e.after):"delete"===e.type&&(null===(l=(o=this.callbacks).onEventDelete)||void 0===l||l.call(o,e.event.id)),this.triggerRender(),this.notify()},this.store.onEventBatchChange=e=>{var t,n;this.state.events=this.store.getAllEvents(),null===(n=(t=this.callbacks).onEventBatchChange)||void 0===n||n.call(t,e),this.triggerRender(),this.notify()}}resolveLocale(e){return e?"string"==typeof e?F(e)?e:"en-US":e&&"object"==typeof e&&!F(e.code)?Object.assign(Object.assign({},e),{code:"en-US"}):e:"en-US"}}class Be{constructor(e){this.renderings=new Map,this.overrides=new Set,this.listeners=new Set,e&&e.length>0&&(this.overrides=new Set(e))}register(e){this.renderings.set(e.id,e),this.notify()}unregister(e){this.renderings.delete(e)&&this.notify()}setOverrides(e){this.overrides=new Set(e),this.notify()}isOverridden(e){return this.overrides.has(e)}subscribe(e){return this.listeners.add(e),e(this.renderings),()=>{this.listeners.delete(e)}}notify(){this.listeners.forEach(e=>e(this.renderings))}}const Ve=t(null);var qe=0;function Ge(e,t,r,a,o,l){t||(t={});var i,s,d=t;if("ref"in d)for(s in d={},t)"ref"==s?i=t[s]:d[s]=t[s];var c={type:e,props:d,key:r,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--qe,__i:-1,__u:0,__source:o,__self:l};if("function"==typeof e&&(i=e.defaultProps))for(s in i)void 0===d[s]&&(d[s]=i[s]);return n.vnode&&n.vnode(c),c}const Ke=({className:e,width:t=24,height:n=24})=>Ge("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:Ge("path",{d:"m15 18-6-6 6-6"})}),Xe=({className:e,width:t=24,height:n=24})=>Ge("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:Ge("path",{d:"m9 18 6-6-6-6"})}),Je=({className:e,width:t=24,height:n=24})=>Ge("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[Ge("path",{d:"m11 17-5-5 5-5"}),Ge("path",{d:"m18 17-5-5 5-5"})]}),Qe=({className:e,width:t=24,height:n=24})=>Ge("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[Ge("path",{d:"m6 17 5-5-5-5"}),Ge("path",{d:"m13 17 5-5-5-5"})]}),et=({className:e,width:t=24,height:n=24})=>Ge("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:Ge("path",{d:"m6 9 6 6 6-6"})}),tt=({className:e,width:t=24,height:n=24})=>Ge("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[Ge("path",{d:"M5 12h14"}),Ge("path",{d:"M12 5v14"})]}),nt=({className:e,width:t=24,height:n=24})=>Ge("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[Ge("circle",{cx:"11",cy:"11",r:"8"}),Ge("path",{d:"m21 21-4.3-4.3"})]}),rt=({className:e,width:t=24,height:n=24})=>Ge("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:Ge("path",{d:"M20 6 9 17l-5-5"})}),at=({className:e,width:t=24,height:n=24})=>Ge("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[Ge("path",{d:"m7 15 5 5 5-5"}),Ge("path",{d:"m7 9 5-5 5 5"})]}),ot=({className:e,width:t=24,height:n=24})=>Ge("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[Ge("path",{d:"M18 6 6 18"}),Ge("path",{d:"m6 6 12 12"})]}),lt=({className:e,width:t=24,height:n=24})=>Ge("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[Ge("path",{d:"M8 2v4"}),Ge("path",{d:"M16 2v4"}),Ge("rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}),Ge("path",{d:"M3 10h18"}),Ge("path",{d:"M8 14h.01"}),Ge("path",{d:"M12 14h.01"}),Ge("path",{d:"M16 14h.01"}),Ge("path",{d:"M8 18h.01"}),Ge("path",{d:"M12 18h.01"}),Ge("path",{d:"M16 18h.01"})]}),it=({className:e,width:t=24,height:n=24})=>Ge("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[Ge("path",{d:"M18 8L22 12L18 16"}),Ge("path",{d:"M2 12H22"})]}),st=({className:e,width:t=24,height:n=24})=>Ge("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:Ge("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),dt=({className:e,width:t=24,height:n=24})=>Ge("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[Ge("rect",{width:"18",height:"14",x:"3",y:"8",rx:"2"}),Ge("path",{d:"M12 5a3 3 0 1 0-3 3"}),Ge("path",{d:"M12 5a3 3 0 1 1 3 3"}),Ge("path",{d:"M3 12h18"}),Ge("path",{d:"M12 22V8"})]}),ct=({className:e,width:t=24,height:n=24})=>Ge("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:Ge("path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z"})}),ut=({className:e,width:t=24,height:n=24})=>Ge("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[Ge("path",{d:"M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z"}),Ge("circle",{cx:"12",cy:"10",r:"3"})]}),ht=({className:e,width:t=24,height:n=24})=>Ge("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:Ge("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),gt=({className:e,width:t=24,height:n=24})=>Ge("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[Ge("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),Ge("path",{d:"M15 3v18"}),Ge("path",{d:"m8 9 3 3-3 3"})]}),mt=({className:e,width:t=24,height:n=24})=>Ge("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[Ge("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),Ge("path",{d:"M15 3v18"}),Ge("path",{d:"m10 15-3-3 3-3"})]}),vt=({className:e,width:t=24,height:n=24})=>Ge("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[Ge("path",{d:"m12 19-7-7 7-7"}),Ge("path",{d:"M19 12H5"})]}),ft="df-month-view h-full flex flex-col bg-white dark:bg-gray-900 select-none",pt="p-2 flex justify-between",yt="text-2xl font-bold text-gray-900 dark:text-gray-100",bt="rounded-md bg-background border border-border px-3 py-2 text-xs font-medium text-gray-700 dark:text-gray-300 hover:bg-(--hover)",wt="df-date-number inline-flex items-center justify-center h-6 w-6 rounded-full text-sm mt-1 select-none",Dt="flex-1 overflow-auto will-change-scroll",xt="scrollbar-hide",Et="df-time-slot relative h-[4.5rem] flex",Ct="df-time-label absolute top-0 -translate-y-1/2 right-2 text-[12px] text-gray-500 dark:text-gray-400 select-none",kt="df-time-grid-row h-[4.5rem] border-t border-gray-200 dark:border-gray-700 flex",Tt="df-current-time-line absolute left-0 top-0 w-full flex pointer-events-none",Nt="df-current-time-label ml-2 text-primary-foreground text-xs font-bold px-1.5 bg-primary rounded-sm",St="df-all-day-row flex items-center border-b border-gray-200 dark:border-gray-700 sticky",Mt="rounded-xl my-0.5",It="rounded-sm",Ht="df-event-title font-medium text-xs truncate pr-1",Rt="df-month-event-color-bar inline-block w-0.75 h-3 mr-1 shrink-0 rounded-full",Ot="h-3 w-3 mr-1",Pt="resize-handle absolute right-0 top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20",Lt="bg-primary rounded-full text-primary-foreground",At="df-nav-button calendar-nav-button group relative inline-flex items-center justify-center w-7 h-7 rounded-md border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 hover:border-gray-300 dark:hover:border-gray-500 active:bg-gray-100 dark:active:bg-gray-600 transition-all duration-150 shadow-sm hover:shadow focus:outline-none",$t="h-4 w-4 transition-transform group-hover:scale-110",jt="df-event-detail-panel fixed bg-white dark:bg-gray-800 shadow-lg border border-gray-200 dark:border-gray-700 rounded-lg",Yt="bg-white dark:bg-gray-800 rounded-md shadow-lg border border-gray-200 dark:border-gray-700 overflow-hidden transition-all duration-200 origin-top-right animate-in fade-in zoom-in-95",Ft="h-3 border-t border-gray-200 dark:border-gray-700 relative",zt="absolute top-0 -translate-y-1/2 text-[12px] text-gray-500 dark:text-gray-400",_t="df-sidebar flex h-full flex-col border-r border-gray-200 dark:border-gray-700 bg-white dark:bg-slate-900",Zt="df-sidebar-header flex items-center px-2 py-1",Wt="df-sidebar-header-toggle flex h-8 w-8 items-center justify-center rounded hover:bg-gray-100 dark:hover:bg-slate-800",Ut="df-sidebar-header-title text-sm font-semibold text-gray-700 dark:text-gray-200",Bt="flex h-7 w-7 items-center justify-center rounded hover:bg-gray-100 dark:hover:bg-slate-800 transition-colors",Vt="text-gray-500 dark:text-gray-400",qt="text-gray-600 dark:text-gray-300",Gt="text-xs",Kt="text-sm",Xt="flex flex-col",Jt="mr-1",Qt=(...e)=>e.filter(Boolean).join(" "),en=({options:e,value:t,onChange:n,registry:r,variant:a="desktop",disabled:o=!1})=>{const[l,i]=s(!1),[u,h]=s({}),g=d(null),m=d(null),f=()=>{if(m.current){const e=m.current.getBoundingClientRect(),t="mobile"===a,n={position:"fixed",zIndex:10001,minWidth:t?"12rem":`${e.width}px`,top:`${e.bottom+4}px`};t?n.right=window.innerWidth-e.right+"px":n.left=`${e.left}px`,h(n)}};c(()=>{const e=e=>{!g.current||g.current.contains(e.target)||e.target.closest("[data-calendar-picker-dropdown]")||i(!1)};return l&&(f(),window.addEventListener("mousedown",e),window.addEventListener("scroll",f,!0),window.addEventListener("resize",f)),()=>{window.removeEventListener("mousedown",e),window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)}},[l]);const p=e=>(r||R()).resolveColors(e).lineColor,y=(e,t)=>{e.stopPropagation(),n(t),i(!1)},b=e.find(e=>e.value===t),w=()=>l&&"undefined"!=typeof window?v("mobile"===a?Ge("div",{"data-calendar-picker-dropdown":"true",style:u,className:Yt,children:e.map(e=>Ge("div",{className:"flex items-center px-4 py-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700 "+(e.value===t?"bg-gray-50 dark:bg-gray-700/50":""),onClick:t=>y(t,e.value),children:[Ge("div",{className:"flex items-center flex-1 min-w-0 mr-3",children:[Ge("div",{className:"w-5 flex justify-center mr-2",children:e.value===t&&Ge(rt,{className:"w-4 h-4 text-primary"})}),Ge("span",{className:"text-sm text-gray-700 dark:text-gray-200 truncate",children:e.label})]}),Ge("span",{className:"w-3 h-3 rounded-full shrink-0",style:{backgroundColor:p(e.value)}})]},e.value))}):Ge("ul",{"data-calendar-picker-dropdown":"true",style:u,className:"bg-white dark:bg-gray-700 rounded-md shadow-lg dark:shadow-gray-900/50 overflow-hidden border border-gray-200 dark:border-gray-600 transition-all duration-200 origin-top-left animate-in fade-in zoom-in-95",children:e.map(e=>Ge("li",{className:"flex items-center px-2 py-1 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-600 transition-colors "+(t===e.value?"font-semibold":""),onClick:t=>y(t,e.value),children:[t===e.value?Ge("span",{className:"mr-2 text-sm text-primary",children:Ge(rt,{width:12,height:12})}):Ge("div",{className:"mr-2 text-sm w-3 h-3",children:" "}),Ge("span",{className:"w-3 h-3 mr-2 rounded-sm shrink-0",style:{backgroundColor:p(e.value)}}),Ge("span",{className:"text-sm whitespace-nowrap text-gray-700 dark:text-gray-200",children:e.label})]},e.value))}),document.body):null;return Ge("div","mobile"===a?{className:"relative inline-block",ref:g,children:[Ge("button",{ref:m,disabled:o,onClick:e=>{e.stopPropagation(),o||i(!l)},className:"flex items-center space-x-2 bg-gray-100 dark:bg-gray-700 rounded-md px-3 py-1.5 transition-colors "+(o?"opacity-50 cursor-default":""),children:[Ge("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:p(t)}}),Ge("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-200",children:(null==b?void 0:b.label)||t}),Ge(at,{className:"w-4 h-4 text-gray-400"})]}),w()]}:{className:"relative inline-block",ref:g,children:[Ge("button",{ref:m,type:"button",onClick:e=>{e.stopPropagation(),i(!l)},className:"flex items-center space-x-2 bg-gray-100 dark:bg-gray-700 rounded-md px-2 py-1 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors h-8",children:[Ge("span",{className:"w-4 h-4 rounded-sm shrink-0",style:{backgroundColor:p(t)}}),Ge(at,{className:"w-4 h-4 text-gray-600 dark:text-gray-300"})]}),w()]})};function tn(e){return null!==e&&"object"==typeof e&&!("hour"in e)&&"year"in e&&"month"in e&&"day"in e&&!(e instanceof Date)}function nn(e){return null!==e&&"object"==typeof e&&"hour"in e&&!("timeZone"in e)&&"year"in e&&!(e instanceof Date)}function rn(e){return null!==e&&"object"==typeof e&&"timeZone"in e&&"year"in e&&!(e instanceof Date)}function an(e){if(e instanceof Date)return e;if(tn(e))return new Date(e.year,e.month-1,e.day);if(nn(e))return new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second||0,e.millisecond||0);if(rn(e))try{if("function"==typeof e.toInstant){const t=e.toInstant();return new Date(t.epochMilliseconds)}return new Date(e.year,e.month-1,e.day,e.hour,e.minute)}catch(t){return new Date(e.year,e.month-1,e.day,e.hour,e.minute)}return new Date(e)}function on(t){return e.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()})}function ln(t){return e.PlainDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:t.getHours(),minute:t.getMinutes(),second:t.getSeconds(),millisecond:t.getMilliseconds()})}function sn(t,n=e.Now.timeZoneId()){return e.ZonedDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:t.getHours(),minute:t.getMinutes(),second:t.getSeconds(),millisecond:t.getMilliseconds(),timeZone:n})}function dn(e){return new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second||0,e.millisecond||0)}function cn(e){return new Date(e.year,e.month-1,e.day)}function un(e){if(e instanceof Date)return e.getHours()+e.getMinutes()/60;if(tn(e))return 0;return e.hour+e.minute/60}function hn(e,t){const n=Math.floor(t),r=Math.round(60*(t-n));return rn(e),e.with({hour:n,minute:r,second:0,millisecond:0})}function gn(e,t){if(e instanceof Date&&t instanceof Date)return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate();const n=mn(e),r=mn(t);return n.equals(r)}function mn(e){return e instanceof Date?on(e):tn(e)?e:(nn(e),e.toPlainDate())}const vn=/(YYYY|YY|MM|DD|HH|mm)/g,fn=e=>e.toString().padStart(2,"0"),pn=(e,t)=>{const n=(null!=t?t:"").trim(),r=/[Hhms]/.test(e)||!n?e:`${e} ${n}`.trim();return r.replace(/(H{1,2}):MM/g,(e,t)=>`${t}:mm`)},yn=e=>e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),bn=e=>{let t,n=0,r="^";for(;null!==(t=vn.exec(e));){r+=yn(e.slice(n,t.index));const a=t[0];r+=`(?<${a}>\\d{${"YYYY"===a?4:2}})`,n=t.index+a.length}return r+=yn(e.slice(n))+"$",new RegExp(r)},wn=(t,n,r,a)=>{const o=t.trim();if(!o)return null;const l=o.match(n),i=null==l?void 0:l.groups;if(!i)return null;const s=i.YYYY?Number(i.YYYY):i.YY?Number(i.YY)+2e3:r.year,d=i.MM?Number(i.MM):r.month,c=i.DD?Number(i.DD):r.day,u=i.HH?Number(i.HH):r.hour,h=i.mm?Number(i.mm):r.minute;try{return e.ZonedDateTime.from({timeZone:a,year:s,month:d,day:c,hour:u,minute:h,second:r.second,millisecond:r.millisecond,microsecond:r.microsecond,nanosecond:r.nanosecond})}catch(e){return null}},Dn=t=>{const n=t;if(n.timeZoneId&&"string"==typeof n.timeZoneId)return n.timeZoneId;if("timeZoneId"in t&&"string"==typeof t.timeZoneId)return t.timeZoneId;const r=t.timeZone;return r&&"string"==typeof r.id?r.id:"string"==typeof n.timeZone?n.timeZone:e.Now.timeZoneId()},xn=(t,n,r)=>{var a,o,l,i,s,d,c,u,h,g,m,v,f,p,y,b,w,D,x,E,C,k,T,N;if(!t){const t=null!=n?n:r?Dn(r):e.Now.timeZoneId();return null!=r?r:e.Now.zonedDateTimeISO(t)}if(tn(t)){const r=null!=n?n:e.Now.timeZoneId(),a=`${t.year}-${fn(t.month)}-${fn(t.day)}T00:00:00[${r}]`;return e.ZonedDateTime.from(a)}if("hour"in t&&!("timeZone"in t)){const r=null!=n?n:e.Now.timeZoneId();if("function"==typeof t.toZonedDateTime)try{return t.toZonedDateTime(r)}catch(e){}return e.ZonedDateTime.from({timeZone:r,year:t.year,month:t.month,day:t.day,hour:t.hour,minute:t.minute,second:null!==(a=t.second)&&void 0!==a?a:0,millisecond:null!==(o=t.millisecond)&&void 0!==o?o:0,microsecond:null!==(l=t.microsecond)&&void 0!==l?l:0,nanosecond:null!==(i=t.nanosecond)&&void 0!==i?i:0})}try{return e.ZonedDateTime.from(t)}catch(a){const o=t,l=null!==(h=null!==(u=null!==(c=null!==(d="string"==typeof(null==o?void 0:o.timeZone)?o.timeZone:null===(s=null==o?void 0:o.timeZone)||void 0===s?void 0:s.id)&&void 0!==d?d:null==o?void 0:o.timeZoneId)&&void 0!==c?c:n)&&void 0!==u?u:r?Dn(r):void 0)&&void 0!==h?h:e.Now.timeZoneId();if("function"==typeof(null==o?void 0:o.toZonedDateTime))try{return o.toZonedDateTime({timeZone:l})}catch(e){}const i=null!=r?r:e.Now.zonedDateTimeISO(l);return e.ZonedDateTime.from({timeZone:l,year:null!==(g=null==o?void 0:o.year)&&void 0!==g?g:i.year,month:null!==(m=null==o?void 0:o.month)&&void 0!==m?m:i.month,day:null!==(v=null==o?void 0:o.day)&&void 0!==v?v:i.day,hour:null!==(p=null!==(f=null==o?void 0:o.hour)&&void 0!==f?f:null==r?void 0:r.hour)&&void 0!==p?p:0,minute:null!==(b=null!==(y=null==o?void 0:o.minute)&&void 0!==y?y:null==r?void 0:r.minute)&&void 0!==b?b:0,second:null!==(D=null!==(w=null==o?void 0:o.second)&&void 0!==w?w:null==r?void 0:r.second)&&void 0!==D?D:0,millisecond:null!==(E=null!==(x=null==o?void 0:o.millisecond)&&void 0!==x?x:null==r?void 0:r.millisecond)&&void 0!==E?E:0,microsecond:null!==(k=null!==(C=null==o?void 0:o.microsecond)&&void 0!==C?C:null==r?void 0:r.microsecond)&&void 0!==k?k:0,nanosecond:null!==(N=null!==(T=null==o?void 0:o.nanosecond)&&void 0!==T?T:null==r?void 0:r.nanosecond)&&void 0!==N?N:0})}},En=(e,t,n)=>{const r=pn(t,n),a={YYYY:e.year.toString(),YY:fn(e.year%100),MM:fn(e.month),DD:fn(e.day),HH:fn(e.hour),mm:fn(e.minute)};return r.replace(vn,e=>{var t;return null!==(t=a[e])&&void 0!==t?t:e})};function Cn(e,t){var n,r,a,o,l;try{if("today"===e){return null!==(r=null===(n=new Intl.RelativeTimeFormat(t,{numeric:"auto"}).formatToParts(0,"day").find(e=>"literal"===e.type))||void 0===n?void 0:n.value)&&void 0!==r?r:null}if("week"===e){return null!==(o=null===(a=new Intl.RelativeTimeFormat(t,{numeric:"always"}).formatToParts(1,"week").find(e=>"unit"===e.type))||void 0===a?void 0:a.value)&&void 0!==o?o:null}return null!==(l=new Intl.DisplayNames(t,{type:"dateTimeField"}).of(e))&&void 0!==l?l:null}catch(e){return null}}function kn(e){return e.charAt(0).toUpperCase()+e.slice(1)}const Tn=(e,t="short")=>{const n=[],r=new Date(2024,0,1);for(let a=0;a<7;a++){const o=new Date(r);o.setDate(r.getDate()+a);try{n.push(o.toLocaleDateString(e,{weekday:t}))}catch(e){n.push(o.toLocaleDateString("en-US",{weekday:t}))}}return n},Nn=(e,t="long")=>{const n=[];for(let r=0;r<12;r++){const a=new Date(2024,r,1);try{n.push(a.toLocaleDateString(e,{month:t}))}catch(e){n.push(a.toLocaleDateString("en-US",{month:t}))}}return n};function Sn(e,t="en-US"){var n;if(["today","day","week","month","year"].includes(e)){const n=Cn(e,t);if(n)return kn(n)}const r=Y(t),a=$[r],o=null===(n=null==a?void 0:a.messages)||void 0===n?void 0:n[e];if(o)return o;const l=$.en.messages;return(null==l?void 0:l[e])||e}const Mn=t({locale:"en-US",t:e=>e,getWeekDaysLabels:()=>[],getMonthLabels:()=>[],isDefault:!0});function In(){return u(Mn)}const Hn=({locale:e="en-US",messages:t,children:n})=>{const r=h(()=>{if("string"==typeof e){return{code:F(e)?e:"en-US",messages:void 0}}return e&&"string"!=typeof e&&!F(e.code)?Object.assign(Object.assign({},e),{code:"en-US"}):e||{code:"en-US"}},[e]),a=h(()=>{const e=r.code;return{locale:e,t:(n,a)=>{var o,l,i;let s=null!==(i=null!==(o=null==t?void 0:t[n])&&void 0!==o?o:null===(l=r.messages)||void 0===l?void 0:l[n])&&void 0!==i?i:Sn(n,e);return a&&Object.entries(a).forEach(([e,t])=>{s=s.replace(new RegExp(`{${e}}`,"g"),t)}),s},getWeekDaysLabels:Tn,getMonthLabels:Nn,isDefault:!1}},[r,t]);return Ge(Mn.Provider,{value:a,children:n})},Rn=Array.from({length:24},(e,t)=>t),On=Array.from({length:60},(e,t)=>t),Pn=({visibleMonth:e,monthLabels:t,disabled:n,onMonthChange:r,onYearChange:a})=>Ge("div",{className:"flex items-center justify-between border-b border-slate-100 dark:border-gray-600 px-3 py-2 text-sm font-medium text-slate-700 dark:text-gray-300",children:[Ge("div",{className:"flex items-center gap-1",children:[Ge("button",{type:"button",disabled:n,onClick:()=>a(-1),className:"rounded-md px-2 py-1 text-slate-400 dark:text-gray-400 transition hover:text-slate-600 dark:hover:text-gray-200 disabled:opacity-40",children:Ge(Je,{width:14,height:12})}),Ge("button",{type:"button",disabled:n,onClick:()=>r(-1),className:"rounded-md px-2 py-1 text-slate-400 dark:text-gray-400 transition hover:text-slate-600 dark:hover:text-gray-200 disabled:opacity-40",children:Ge(Ke,{width:14,height:12})})]}),Ge("div",{className:"text-sm font-semibold text-slate-700 dark:text-gray-300",children:[t[e.month-1]," ",e.year]}),Ge("div",{className:"flex items-center gap-1",children:[Ge("button",{type:"button",disabled:n,onClick:()=>r(1),className:"rounded-md px-2 py-1 text-slate-400 dark:text-gray-400 transition hover:text-slate-600 dark:hover:text-gray-200 disabled:opacity-40",children:Ge(Xe,{width:14,height:12})}),Ge("button",{type:"button",disabled:n,onClick:()=>a(1),className:"rounded-md px-2 py-1 text-slate-400 dark:text-gray-400 transition hover:text-slate-600 dark:hover:text-gray-200 disabled:opacity-40",children:Ge(Qe,{width:14,height:12})})]})]}),Ln=(t,n)=>e.PlainDate.compare(t,n),An=({calendarDays:e,visibleMonth:t,startDate:n,endDate:a,weekDayLabels:o,disabled:l,onDaySelect:i})=>Ge(r,{children:[Ge("div",{className:"grid grid-cols-7 gap-1 px-1 pb-3 pt-2 text-center text-[12px] uppercase tracking-wide text-slate-400 dark:text-gray-500",children:o.map((e,t)=>Ge("span",{children:e},t))}),Ge("div",{className:"grid grid-cols-7 gap-1 px-1 ",children:e.map(e=>{const r=e.month!==t.month,o=0===Ln(e,n),s=0===Ln(e,a),d=Ln(e,n)>=0&&Ln(e,a)<=0;return Ge("button",{type:"button",disabled:l,onClick:()=>i(e),className:`flex h-9 w-9 items-center justify-center rounded-md text-sm transition ${o||s?"bg-primary text-primary-foreground font-semibold":d?"bg-primary/10 text-primary":r?"text-slate-300 dark:text-gray-600":"text-slate-700 dark:text-gray-300 hover:bg-primary/10 hover:text-primary"}`,children:e.day},e.toString())})})]}),$n=({focusedField:e,draftRange:t,disabled:n,onHourSelect:r,onMinuteSelect:a,timeListRefs:o})=>{const l=e,i=t["start"===l?0:1],s=i.minute,d=On.includes(s)?On:[...On,s].sort((e,t)=>e-t);return Ge("div",{className:"flex flex-col rounded-xl border border-slate-200 dark:border-gray-600 bg-white dark:bg-gray-800 shadow-sm sm:w-28",children:[Ge("div",{className:"flex border-b border-slate-100 dark:border-gray-600 justify-center",children:Ge("div",{className:"text-base py-1.5 text-slate-700 dark:text-gray-300",children:[i.hour.toString().padStart(2,"0"),":",i.minute.toString().padStart(2,"0")]})}),Ge("div",{className:"flex p-1",children:[Ge("div",{className:"w-14",children:Ge("div",{className:`h-72 overflow-y-auto ${xt} rounded-md border border-slate-100 dark:border-gray-600 bg-white dark:bg-gray-700`,role:"listbox","aria-label":"Hour",ref:e=>{o.current&&o.current[l]&&(o.current[l].hour=e)},children:Rn.map(e=>{const t=e===i.hour;return Ge("button",{type:"button",role:"option","aria-selected":t,disabled:n,onClick:()=>r(l,e),className:"flex h-8 w-full items-center justify-center text-sm transition "+(t?"bg-primary text-primary-foreground font-semibold":"text-slate-600 dark:text-gray-300 hover:bg-primary/10 hover:text-primary"),"data-active":t?"true":void 0,children:fn(e)},e)})})}),Ge("div",{className:"w-14",children:Ge("div",{className:`h-72 overflow-y-auto ${xt} rounded-md border border-slate-100 dark:border-gray-600 bg-white dark:bg-gray-700`,role:"listbox","aria-label":"Minute",ref:e=>{o.current&&o.current[l]&&(o.current[l].minute=e)},children:d.map(e=>{const t=e===s;return Ge("button",{type:"button",role:"option","aria-selected":t,disabled:n,onClick:()=>a(l,e),className:"flex h-8 w-full items-center justify-center text-sm transition "+(t?"bg-primary text-primary-foreground font-semibold":"text-slate-600 dark:text-gray-300 hover:bg-primary/10 hover:text-primary"),"data-active":t?"true":void 0,children:fn(e)},e)})})})]})]})},jn=({visibleMonth:e,monthLabels:t,weekDayLabels:n,calendarDays:r,draftRange:a,focusedField:o,isTimeEnabled:l,disabled:i,matchTriggerWidth:s,popupRef:d,timeListRefs:c,onMonthChange:u,onYearChange:h,onDaySelect:g,onHourSelect:m,onMinuteSelect:v,onOk:f,getPopupStyle:p})=>{const y=a[0].toPlainDate(),b=a[1].toPlainDate();return Ge("div",{ref:d,style:p(),"data-range-picker-popup":"true",children:Ge("div",{className:"space-y-3 rounded-xl border border-slate-200 dark:border-gray-600 bg-white dark:bg-gray-800 p-3",style:{boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",width:s?"100%":void 0},children:[Ge("div",{className:"flex gap-1",children:[Ge("div",{className:"flex-3 rounded-xl border border-slate-200 dark:border-gray-600 bg-white dark:bg-gray-800 shadow-sm w-full",children:[Ge(Pn,{visibleMonth:e,monthLabels:t,disabled:i,onMonthChange:u,onYearChange:h}),Ge(An,{calendarDays:r,visibleMonth:e,startDate:y,endDate:b,weekDayLabels:n,disabled:i,onDaySelect:g})]}),l&&Ge("div",{className:"flex flex-1 justify-end sm:w-32",children:Ge($n,{focusedField:o,draftRange:a,disabled:i,onHourSelect:m,onMinuteSelect:v,timeListRefs:c})})]}),Ge("div",{className:"flex justify-end",children:Ge("button",{type:"button",onClick:f,disabled:i,className:"inline-flex items-center rounded-full bg-primary px-4 py-1.5 text-sm font-semibold text-primary-foreground shadow-sm transition hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-50",children:"OK"})})]})})},Yn=({value:t,format:n="YYYY-MM-DD HH:mm",showTimeFormat:r="HH:mm",showTime:a=!0,onChange:o,onOk:l,timeZone:i,disabled:u=!1,placement:m="bottomLeft",autoAdjustOverflow:f=!0,getPopupContainer:p,matchTriggerWidth:y=!1,locale:b="en-US"})=>{const w=h(()=>"string"==typeof b?b:(null==b?void 0:b.code)||"en-US",[b]),D=h(()=>void 0===a||("object"==typeof a||Boolean(a)),[a]),x=h(()=>Nn(w,"short"),[w]),E=h(()=>Tn(w,"narrow"),[w]),C=h(()=>D?"object"==typeof a&&(null==a?void 0:a.format)?a.format:r:"",[D,a,r]),k=h(()=>pn(n,C),[n,C]),T=h(()=>bn(k),[k]),N=h(()=>{const n=null!=i?i:z(t[0])?z(t[1])?e.Now.timeZoneId():Dn(t[1]):Dn(t[0]),r=xn(t[0],n);return[r,xn(t[1],n,r)]},[t,i]),[S,M]=s(N),I=d(N),[H,R]=s("start"),[O,P]=s([En(N[0],n,C),En(N[1],n,C)]),L=d([En(N[0],n,C),En(N[1],n,C)]),A=d(N),[$,j]=s(N[0].toPlainDate().with({day:1})),[Y,F]=s(!1),_=g(e=>{F(e)},[]),[Z,W]=s(m),U=d(m),B=d(null),V=d(null),q=d({start:{hour:null,minute:null},end:{hour:null,minute:null}}),G=d(!1),K=d(!1);c(()=>{L.current=O},[O]),c(()=>{A.current=S},[S]),c(()=>{const t=I.current,n=0!==e.ZonedDateTime.compare(t[0],N[0]),r=0!==e.ZonedDateTime.compare(t[1],N[1]);(n||r)&&M(N),I.current=N},[N]),c(()=>{j(N[0].toPlainDate().with({day:1}))},[N[0]]);const X=g((e,t,n=0)=>{var r;if(!e||!t)return;const a=e.getBoundingClientRect(),o=t.getBoundingClientRect().top-a.top+e.scrollTop-n,l=(null===(r=window.matchMedia)||void 0===r?void 0:r.call(window,"(prefers-reduced-motion: reduce)").matches)?"auto":"smooth";Math.abs(e.scrollTop-o)>1&&e.scrollTo({top:o,behavior:l})},[]),J=g(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=q.current[e];["hour","minute"].forEach(e=>{const n=t[e];if(!n)return;const r=n.querySelector('[data-active="true"]');r&&X(n,r,0)})})})},[X]);c(()=>{Y&&D&&J(H)},[H,Y,J,D]);const Q=S[0].epochMilliseconds,ee=S[0].offsetNanoseconds,te=S[1].epochMilliseconds,ne=S[1].offsetNanoseconds;c(()=>{if(K.current)return;const[e,t]=A.current,r=En(e,n,C),a=En(t,n,C),[o,l]=L.current;o===r&&l===a||(L.current=[r,a],P([r,a]))},[Q,ee,te,ne,n,C]),c(()=>{if(!Y)return;const e=e=>{var t,n;const r=e.target;if(null===(t=B.current)||void 0===t?void 0:t.contains(r))return;if(null===(n=V.current)||void 0===n?void 0:n.contains(r))return;r.closest("[data-range-picker-popup]")||_(!1)},t=setTimeout(()=>{document.addEventListener("mousedown",e)},100);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[Y]),c(()=>{Y||(R("start"),G.current||M(N),G.current=!1)},[Y,N]);const re=g(e=>{o&&o(e,[En(e[0],n,C),En(e[1],n,C)])},[C,n,o]),ae=g(e=>{l&&l(e,[En(e[0],n,C),En(e[1],n,C)])},[C,n,l]),oe=g((t,n)=>{M(r=>{const a=[...r];if("start"===t){const t=xn(a[1],Dn(n),n),r=e.ZonedDateTime.compare(n,t)>0?n:t;return[n,r]}const o=xn(a[0],Dn(n),n);return[e.ZonedDateTime.compare(o,n)>0?n:o,n]})},[]),le=t=>{if(u)return;const n=(t,n)=>{var r,a,o,l;const i=Dn(t);return e.ZonedDateTime.from({timeZone:i,year:n.year,month:n.month,day:n.day,hour:t.hour,minute:t.minute,second:null!==(r=t.second)&&void 0!==r?r:0,millisecond:null!==(a=t.millisecond)&&void 0!==a?a:0,microsecond:null!==(o=t.microsecond)&&void 0!==o?o:0,nanosecond:null!==(l=t.nanosecond)&&void 0!==l?l:0})};if("start"===H){const e=n(S[0],t),r=S[1].epochMilliseconds-S[0].epochMilliseconds,a=e.add({milliseconds:r});return void M([e,a])}const r=n(S[1],t),a=S[1].epochMilliseconds-S[0].epochMilliseconds;if(e.ZonedDateTime.compare(r,S[0])<0){const e=n(S[0],t),r=e.add({milliseconds:a});return void M([e,r])}const o=[S[0],r];M(o),j(r.toPlainDate().with({day:1}))},ie=g((t,n)=>{if(u)return;const r="start"===t?0:1;M(a=>{const o=a[r],l=o.with({hour:n,minute:o.minute,second:0,millisecond:0,microsecond:0,nanosecond:0});if("start"===t){const t=xn(a[1],Dn(l),l);return[l,e.ZonedDateTime.compare(l,t)>0?l:t]}const i=xn(a[0],Dn(l),l);return[e.ZonedDateTime.compare(i,l)>0?l:i,l]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const e=q.current[t].hour;if(!e)return;const n=e.querySelector('[data-active="true"]');n&&X(e,n,0)})})},[u]),se=g((t,n)=>{if(u)return;const r="start"===t?0:1;M(a=>{const o=a[r].with({minute:n,second:0,millisecond:0,microsecond:0,nanosecond:0});if("start"===t){const t=xn(a[1],Dn(o),o);return[o,e.ZonedDateTime.compare(o,t)>0?o:t]}const l=xn(a[0],Dn(o),o);return[e.ZonedDateTime.compare(l,o)>0?o:l,o]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const e=q.current[t].minute;if(!e)return;const n=e.querySelector('[data-active="true"]');n&&X(e,n,0)})})},[u]),de=g((e,t)=>{const n="start"===e?0:1;P(e=>{const r=[...e];return r[n]=t,r})},[]),ce=g((e,t)=>{const r="start"===e?0:1,a=S[r],o=Dn(a),l=wn(t,T,a,o);if(l){oe(e,l);const t=l.toPlainDate().with({day:1});return j(t),"start"===e&&R("end"),!0}return P(e=>{const t=[...e];return t[r]=En(S[r],n,C),t}),!1},[S,C,n,T,oe]),ue=g(e=>t=>{const n=t.target.value;K.current=!0,de(e,n);const r="start"===e?0:1,a=A.current[r],o=Dn(a),l=wn(n,T,a,o);if(l){oe(e,l);const t=l.toPlainDate().with({day:1});j(t),J(e)}},[de,T,oe,J]),he=g(e=>t=>{var r;if(u)return;if(K.current=!1,Y){const t="start"===e?0:1,r=En(A.current[t],n,C);return void P(e=>{const n=[...e];return n[t]=r,n})}const a=t.relatedTarget;a&&(null===(r=B.current)||void 0===r?void 0:r.contains(a))||ce(e,t.target.value)},[ce,u,Y,n,C]),ge=g(e=>t=>{"Enter"===t.key&&(t.preventDefault(),K.current=!1,ce(e,t.currentTarget.value)),"Escape"===t.key&&t.currentTarget.blur()},[ce]),me=()=>{G.current=!0,re(S),ae(S),_(!1)},ve=e=>{j(t=>t.add({months:e}).with({day:1}))},fe=e=>{j(t=>t.add({years:e}).with({day:1}))},pe=h(()=>{const e=$,t=e.dayOfWeek%7,n=e.subtract({days:t});return Array.from({length:42},(e,t)=>n.add({days:t}))},[$]),ye=g((e=m)=>{if(!f||!B.current)return e;const t=B.current.getBoundingClientRect(),n=y?t.width:480,r=window.innerHeight-t.bottom,a=t.top,o=window.innerWidth-t.left,l=t.right;let i=e;return i.startsWith("bottom")&&r<500&&a>r?i=i.replace("bottom","top"):i.startsWith("top")&&a<500&&r>a&&(i=i.replace("top","bottom")),i.endsWith("Left")&&o<n&&l>o?i=i.replace("Left","Right"):i.endsWith("Right")&&l<n&&o>l&&(i=i.replace("Right","Left")),i},[f,y,m]),be=g(()=>{const e=ye();U.current!==e&&(U.current=e,W(e))},[ye]),we=e=>{if(u)return;R(e);const t=S["start"===e?0:1].toPlainDate().with({day:1});j(t);const n=ye();U.current!==n&&(U.current=n,W(n)),_(!0)};c(()=>{if(!Y)return;be();const e=()=>be();return window.addEventListener("resize",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e,!0)}},[Y,be]);const De=()=>{if(!B.current)return{};const e=B.current.getBoundingClientRect(),t=U.current,n={position:"fixed",zIndex:9999};return t.startsWith("bottom")?n.top=e.bottom+8:n.bottom=window.innerHeight-e.top+8,t.endsWith("Left")?n.left=e.left:n.right=window.innerWidth-e.right,y&&(n.width=`${e.width}px`),n};return Ge("div",{className:"relative max-w-100",ref:B,children:[Ge("div",{className:"flex items-center gap-2 rounded-lg border text-sm shadow-sm transition "+(u?"cursor-not-allowed border-slate-200 dark:border-gray-600 bg-slate-50 dark:bg-gray-800 text-slate-400 dark:text-gray-500":Y?"border-primary bg-white dark:bg-gray-700 shadow-md":"border-slate-200 dark:border-gray-600 bg-white dark:bg-gray-700"),children:[Ge("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:Ge("input",{type:"text",name:"range-start",value:O[0],onChange:ue("start"),onFocus:()=>we("start"),onClick:()=>we("start"),onBlur:he("start"),onKeyDown:ge("start"),className:"w-full rounded-md border px-2 py-1.5 text-sm font-medium transition focus:outline-none focus:ring-2 "+(u?"cursor-not-allowed border-transparent bg-transparent text-slate-400 dark:text-gray-500":"start"===H&&Y?" bg-white dark:bg-gray-700 text-primary":"border-transparent bg-transparent text-slate-700 dark:text-gray-300"),placeholder:k,autoComplete:"off",disabled:u})}),Ge(it,{className:"text-slate-400 dark:text-gray-500"}),Ge("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:Ge("input",{type:"text",name:"range-end",value:O[1],onChange:ue("end"),onFocus:()=>we("end"),onClick:()=>we("end"),onBlur:he("end"),onKeyDown:ge("end"),className:"w-full rounded-md border px-2 py-1.5 text-sm font-medium transition focus:outline-none focus:ring-2 "+(u?"cursor-not-allowed border-transparent bg-transparent text-slate-400 dark:text-gray-500":"end"===H&&Y?"bg-white dark:bg-gray-700 text-primary":"border-transparent bg-transparent text-slate-700 dark:text-gray-300"),placeholder:k,autoComplete:"off",disabled:u})})]}),Y&&v(Ge(jn,{visibleMonth:$,monthLabels:x,weekDayLabels:E,calendarDays:pe,draftRange:S,focusedField:H,isTimeEnabled:!!D,disabled:u,matchTriggerWidth:y,popupRef:V,timeListRefs:q,onMonthChange:ve,onYearChange:fe,onDaySelect:le,onHourSelect:ie,onMinuteSelect:se,onOk:me,getPopupStyle:De}),p?p():document.body)]})},Fn=({event:t,isOpen:n,isAllDay:r,onEventUpdate:a,onEventDelete:o,onClose:l,app:i})=>{var d;const[u,g]=s(t),{t:m}=In();c(()=>{g(t)},[t]);const f=h(()=>(i?i.getCalendarRegistry():R()).getVisible().map(e=>({label:e.name,value:e.id})),[i,null==i?void 0:i.getCalendars()]),p=h(()=>!ze(t,u),[t,u]),y=h(()=>z(u.start)?u.end&&!z(u.end)&&(u.end.timeZoneId||u.end.timeZoneId)||e.Now.timeZoneId():u.start.timeZoneId||u.start.timeZoneId||e.Now.timeZoneId(),[u.end,u.start]),b=e=>{const[t,n]=e;g(Object.assign(Object.assign({},u),{start:t.toPlainDate(),end:n.toPlainDate()}))},w=!(null==i?void 0:i.state.readOnly),D=!1!==(null==i?void 0:i.getReadOnlyConfig().viewable);if(!n||!D)return null;if("undefined"==typeof window||"undefined"==typeof document)return null;const x=Ge("div",{className:"fixed inset-0 flex items-center justify-center",style:{pointerEvents:"auto",zIndex:9998},"data-event-detail-dialog":"true",children:[Ge("div",{className:"absolute inset-0 bg-black/60 dark:bg-black/80",onClick:e=>{const t=e.target;t.closest("[data-range-picker-popup]")||t===e.currentTarget&&l()}}),Ge("div",{className:"df-dialog-container relative bg-white dark:bg-gray-800 shadow-2xl border border-gray-200 dark:border-gray-700 rounded-lg p-6 max-w-md w-full mx-4",children:[Ge("button",{onClick:l,className:"absolute top-4 right-4 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-200 transition","aria-label":"Close",children:Ge("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:Ge("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),Ge("div",{children:[Ge("span",{className:"block text-xs text-gray-600 dark:text-gray-300 mb-1",children:m("eventTitle")}),Ge("div",{className:"flex items-center justify-between gap-3 mb-4",children:[Ge("div",{className:"flex-1",children:Ge("input",{id:`event-dialog-title-${u.id}`,name:"title",type:"text",value:u.title,readOnly:!w,disabled:!w,onChange:e=>{g(Object.assign(Object.assign({},u),{title:e.target.value}))},className:"w-full border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-1.5 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary transition"})}),w&&Ge(en,{options:f,value:u.calendarId||"blue",onChange:e=>{g(Object.assign(Object.assign({},u),{calendarId:e}))},registry:null==i?void 0:i.getCalendarRegistry()})]}),u.allDay?Ge("div",{className:"mb-4",children:[Ge("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-1",children:m("dateRange")}),Ge(Yn,{value:[u.start,u.end],format:"YYYY-MM-DD",showTime:!1,timeZone:y,matchTriggerWidth:!0,disabled:!w,onChange:b,onOk:b,locale:null==i?void 0:i.state.locale})]}):Ge("div",{className:"mb-4",children:[Ge("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-1",children:m("timeRange")}),Ge(Yn,{value:[u.start,u.end],timeZone:y,disabled:!w,onChange:e=>{const[t,n]=e;g(Object.assign(Object.assign({},u),{start:t,end:n}))},onOk:e=>{const[t,n]=e;g(Object.assign(Object.assign({},u),{start:t,end:n}))},locale:null==i?void 0:i.state.locale})]}),Ge("div",{className:"mb-4",children:[Ge("span",{className:"block text-xs text-gray-600 dark:text-gray-300 mb-1",children:m("note")}),Ge("textarea",{id:`event-dialog-note-${u.id}`,name:"note",value:null!==(d=u.description)&&void 0!==d?d:"",readOnly:!w,disabled:!w,onChange:e=>g(Object.assign(Object.assign({},u),{description:e.target.value})),rows:4,className:"w-full border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary transition resize-none",placeholder:m("addNotePlaceholder")})]}),w&&Ge("div",{className:"flex space-x-2",children:[u.allDay?Ge("button",{className:"px-3 py-2 bg-secondary/10 text-secondary rounded-lg hover:bg-secondary/20 text-xs font-medium transition",onClick:()=>{const t=z(u.start)?u.start:u.start.toPlainDate(),n=e.ZonedDateTime.from({year:t.year,month:t.month,day:t.day,hour:9,minute:0,timeZone:e.Now.timeZoneId()}),r=e.ZonedDateTime.from({year:t.year,month:t.month,day:t.day,hour:10,minute:0,timeZone:e.Now.timeZoneId()});g(Object.assign(Object.assign({},u),{allDay:!1,start:n,end:r}))},children:m("setAsTimed")}):Ge("button",{className:"px-3 py-2 bg-secondary/10 text-secondary rounded-lg hover:bg-secondary/20 text-xs font-medium transition",onClick:()=>{const e=z(u.start)?u.start:u.start.toPlainDate();g(Object.assign(Object.assign({},u),{allDay:!0,start:e,end:e}))},children:m("setAsAllDay")}),Ge("button",{className:"px-3 py-2 bg-destructive border border-border text-destructive-foreground rounded-lg hover:bg-destructive/90 text-xs font-medium transition",onClick:()=>{o(t.id),l()},children:m("delete")}),Ge("button",{className:"px-3 py-2 bg-primary text-primary-foreground rounded-lg text-xs font-medium transition ml-auto "+(p?"hover:bg-primary/90 shadow-lg shadow-primary/20":"opacity-50 cursor-not-allowed grayscale-[0.5]"),onClick:()=>{a(u),l()},disabled:!p,children:m("save")})]})]})]})]}),E=document.body;return E?v(x,E):null},zn=({calendar:e,mode:t="buttons"})=>{const[n,r]=s(!1),a=d(null),{t:o}=In(),l=Array.from(e.state.views.keys()),i=e.state.currentView;return l.length<=1?null:(c(()=>{const e=e=>{a.current&&!a.current.contains(e.target)&&r(!1)};if(n)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[n]),Ge("div","select"===t?{className:"relative inline-block",ref:a,children:[Ge("button",{onClick:()=>r(!n),className:"flex items-center gap-2 px-3 h-7 text-sm font-medium border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none transition-all duration-200 shadow-sm min-w-30 justify-between","aria-expanded":n,"aria-haspopup":"listbox",children:[Ge("span",{className:"text-gray-900 dark:text-gray-100",children:o(i)}),Ge("span",{className:`${Vt} transition-transform duration-200 ${n?"rotate-180":""}`,children:Ge(et,{width:16,height:16})})]}),n&&Ge("div",{className:"absolute top-full mt-1 left-0 z-50 w-full min-w-30 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-600 rounded-lg shadow-lg dark:shadow-gray-900/50 overflow-hidden animate-in",children:Ge("div",{className:"p-1",role:"listbox",children:l.map(t=>Ge("button",{onClick:()=>{e.changeView(t),r(!1),e.triggerRender&&e.triggerRender()},className:"w-full text-left px-3 py-0.5 rounded text-sm transition-colors duration-150 focus:outline-none "+(i===t?"bg-primary/10 text-primary font-medium":"text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700"),role:"option","aria-selected":i===t,children:o(t)},t))})}),Ge("style",{children:"\n @keyframes slideIn {\n from {\n opacity: 0;\n transform: translateY(-4px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n .animate-in {\n animation: slideIn 0.15s ease-out;\n }\n "})]}:{className:"inline-flex items-center gap-1 p-0.5 mb-1 bg-gray-100 dark:bg-gray-800 rounded-lg",children:l.map(t=>Ge("button",{className:"px-4 h-6 text-sm font-medium rounded-md transition-all duration-200 focus:outline-none "+(i===t?"bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-100 hover:bg-gray-50 dark:hover:bg-gray-700"),onClick:()=>{e.changeView(t),e.triggerRender&&e.triggerRender()},children:o(t)},t))}))},_n=t=>{if(!t)return"";let n,r,a;t instanceof Date?(n=t.getFullYear(),r=t.getMonth()+1,a=t.getDate()):z(t)?(n=t.year,r=t.month,a=t.day):(!function(t){!t||"object"!=typeof t||t instanceof Date||e.ZonedDateTime}(t),n=t.year,r=t.month,a=t.day);const o=String(r).padStart(2,"0");return`${String(a).padStart(2,"0")}/${o}/${n}`},Zn=e=>`${["January","February","March","April","May","June","July","August","September","October","November","December"][e.getMonth()]} ${e.getFullYear()}`,Wn=e=>{const t=e.year,n=e.month;return`${e.day} ${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][n-1]} ${t}`};function Un(e,t="240px"){return"number"==typeof e?`${e}px`:"string"==typeof e&&e.trim().length>0?e:t}function Bn(){if("undefined"==typeof document)return!1;const e=document.createElement("style");e.textContent=".df-calendar-container .__df_measure__::-webkit-scrollbar { display: block !important; }",document.head.appendChild(e);const t=document.createElement("div");t.className="df-calendar-container",t.style.cssText="position:absolute;top:-9999px;width:100px;height:100px;overflow:hidden";const n=document.createElement("div");n.className="__df_measure__",n.style.cssText="width:100px;height:100px;overflow:scroll",t.appendChild(n),document.body.appendChild(t);const r=n.offsetWidth-n.clientWidth>0;return document.body.removeChild(t),document.head.removeChild(e),r}const Vn=(e,t,n)=>`${e} ${t} ${n.split(" ").filter(Boolean).map(e=>`dark:${e}`).join(" ")}`.trim(),qn={container:"bg-white dark:bg-gray-900",card:"bg-white dark:bg-gray-800",sidebar:"bg-gray-50 dark:bg-gray-900",text:"text-gray-900 dark:text-gray-100",textMuted:"text-gray-500 dark:text-gray-400",textSubtle:"text-gray-600 dark:text-gray-300",textEmphasis:"text-gray-900 dark:text-white",border:"border-gray-200 dark:border-gray-700",borderLight:"border-gray-100 dark:border-gray-800",borderStrong:"border-gray-300 dark:border-gray-600",bgPrimary:"bg-white dark:bg-gray-900",bgSecondary:"bg-gray-50 dark:bg-gray-800",bgTertiary:"bg-gray-100 dark:bg-gray-700",bgMuted:"bg-gray-100 dark:bg-gray-800",hover:"hover:bg-gray-100 dark:hover:bg-gray-800",hoverSubtle:"hover:bg-gray-50 dark:hover:bg-gray-900",active:"bg-gray-200 dark:bg-gray-700",focus:"focus:ring-primary",input:"bg-white dark:bg-gray-700 border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100",inputFocus:"focus:border-primary focus:ring-primary",buttonPrimary:"bg-primary text-primary-foreground hover:bg-primary/90",buttonSecondary:"bg-gray-200 dark:bg-gray-700 text-gray-900 dark:text-gray-100 hover:bg-gray-300 dark:hover:bg-gray-600",buttonDanger:"bg-destructive text-destructive-foreground hover:bg-destructive/90",buttonSuccess:"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-200 hover:bg-blue-200 dark:hover:bg-blue-800",shadow:"shadow-sm dark:shadow-gray-900/50",shadowMd:"shadow-md dark:shadow-gray-900/50",shadowLg:"shadow-lg dark:shadow-gray-900/50",divider:"border-gray-200 dark:border-gray-700"},Gn=(e,t,n)=>e?t:n,Kn=(...e)=>e.filter(Boolean).join(" "),Xn=e=>{if("undefined"==typeof document)return e;const t=document.documentElement,n=[t.getAttribute("data-dayflow-theme-override"),t.getAttribute("data-theme-override"),t.getAttribute("data-theme")];for(const e of n)if("light"===e||"dark"===e)return e;return t.classList.contains("dark")?"dark":t.classList.contains("light")?"light":e};function Jn(t,n=!1){if(t instanceof e.PlainDate||t instanceof e.PlainDateTime)return t;if(t instanceof Date)return n?on(t):ln(t);throw new Error("Invalid time type: "+typeof t)}function Qn(t,n){if(t instanceof e.ZonedDateTime)return t;if(t instanceof Date)return sn(t,n);throw new Error("Invalid time type: "+typeof t)}function er(e){var t;const n=Jn(e.start,e.allDay),r=Jn(e.end,e.allDay);return{id:e.id,title:e.title,description:e.description,start:n,end:r,allDay:null!==(t=e.allDay)&&void 0!==t&&t,calendarId:e.calendarId,meta:e.meta}}function tr(e){const t=Qn(e.start,e.timeZone),n=Qn(e.end,e.timeZone);return{id:e.id,title:e.title,description:e.description,start:t,end:n,allDay:!1,calendarId:e.calendarId,meta:e.meta}}function nr(e){return e.map(e=>er(e))}function rr(e){return e.map(e=>tr(e))}function ar(e,t,n,r){return er(Object.assign({id:e,title:t,start:n,end:n,allDay:!0},r))}function or(e,t,n,r,a){return er(Object.assign({id:e,title:t,start:n,end:r},a))}function lr(e,t,n,r,a=!1,o){return er(Object.assign({id:e,title:t,start:n,end:r,allDay:a},o))}function ir(e,t,n,r,a,o){return tr(Object.assign({id:e,title:t,start:n,end:r,timeZone:a},o))}const sr=e=>{try{return e instanceof Date?e:"string"==typeof e?new Date(e):U(e)}catch(e){return new Date}},dr=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},cr=(e,t,n,r)=>{const a=e.getTime()-t.getTime(),o=Math.round(a/864e5);let l="",i="text-gray-500 dark:text-gray-400";if(0===o)l=r("today")||"Today",i="text-primary";else if(1===o||2===o)try{const e=new Intl.RelativeTimeFormat(n,{numeric:"auto"}).format(o,"day");l=e.charAt(0).toUpperCase()+e.slice(1),i="text-black dark:text-white"}catch(t){l=e.toLocaleDateString(n,{weekday:"long"})}else l=e.toLocaleDateString(n,{year:"numeric",month:"long",day:"numeric",weekday:"long"});return{title:l,colorClass:i}},ur=(e,t)=>{const n=new Map;e.forEach(e=>{var t;const r=sr(e.start),a=dr(r),o=a.getTime();n.has(o)||n.set(o,{date:a,events:[]}),null===(t=n.get(o))||void 0===t||t.events.push(e)});const r=t.getTime();n.has(r)||n.set(r,{date:t,events:[]});return Array.from(n.values()).sort((e,t)=>e.date.getTime()-t.date.getTime())};const hr=new class{constructor(){this.lastCopiedEvent=null}setEvent(e){this.lastCopiedEvent=e}getEvent(){return this.lastCopiedEvent}hasEvent(){return null!==this.lastCopiedEvent}clear(){this.lastCopiedEvent=null}},gr=/^(\d{4})(\d{2})(\d{2})$/,mr=/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})$/,vr=/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z$/;function fr(t,n,r){const a=t.trim();if("DATE"===(null==n?void 0:n.value)||gr.test(a)){const t=a.match(gr);if(t)return e.PlainDate.from({year:parseInt(t[1],10),month:parseInt(t[2],10),day:parseInt(t[3],10)})}if(vr.test(a)){const t=a.match(vr);if(t){const n=e.Instant.from(`${t[1]}-${t[2]}-${t[3]}T${t[4]}:${t[5]}:${t[6]}Z`),a=r||e.Now.timeZoneId();return n.toZonedDateTimeISO(a)}}const o=a.match(mr);if(o){const t={year:parseInt(o[1],10),month:parseInt(o[2],10),day:parseInt(o[3],10),hour:parseInt(o[4],10),minute:parseInt(o[5],10),second:parseInt(o[6],10)};return(null==n?void 0:n.tzid)?e.ZonedDateTime.from(Object.assign(Object.assign({},t),{timeZone:n.tzid})):e.PlainDateTime.from(t)}throw new Error(`Invalid ICS date format: ${t}`)}function pr(e,t=!1){if(t||tn(e)){const t=tn(e)?e:e.toPlainDate();return{value:`${t.year}${br(t.month)}${br(t.day)}`,params:{VALUE:"DATE"}}}if(rn(e)){const t=e.toInstant().toZonedDateTimeISO("UTC");return{value:`${t.year}${br(t.month)}${br(t.day)}T${br(t.hour)}${br(t.minute)}${br(t.second)}Z`}}if(nn(e))return{value:`${e.year}${br(e.month)}${br(e.day)}T${br(e.hour)}${br(e.minute)}${br(e.second)}`};throw new Error("Unsupported Temporal type")}function yr(e){return`${e.getUTCFullYear()}${br(e.getUTCMonth()+1)}${br(e.getUTCDate())}T${br(e.getUTCHours())}${br(e.getUTCMinutes())}${br(e.getUTCSeconds())}Z`}function br(e){return String(e).padStart(2,"0")}function wr(t,n={}){const r={success:!1,events:[],errors:[],totalParsed:0,totalImported:0};try{const a=t.replace(/(\r\n|\n|\r)[ \t]/g,""),o=function(e){const t=[];let n=null,r=!1;for(const a of e){const e=a.trim().toUpperCase();e.startsWith("BEGIN:VEVENT")?(r=!0,n=[]):e.startsWith("END:VEVENT")?(r&&n&&t.push(n),r=!1,n=null):r&&n&&n.push(a)}return t}(a.split(/\r\n|\n|\r/));r.totalParsed=o.length,o.forEach((t,a)=>{try{const a=function(e){const t={};for(const n of e){const e=n.indexOf(":");if(-1===e)continue;const r=n.substring(0,e),a=n.substring(e+1),[o,...l]=r.split(";"),i=o.trim().toUpperCase(),s={};switch(l.forEach(e=>{const[t,n]=e.split("=");t&&n&&(s[t.trim().toUpperCase()]=n.trim())}),i){case"UID":t.uid=a.trim();break;case"SUMMARY":t.summary=Dr(a);break;case"DESCRIPTION":t.description=Dr(a);break;case"LOCATION":t.location=Dr(a);break;case"DTSTART":t.dtstart=a.trim(),t.dtstartParams={value:s.VALUE,tzid:s.TZID};break;case"DTEND":t.dtend=a.trim(),t.dtendParams={value:s.VALUE,tzid:s.TZID};break;case"CATEGORIES":t.categories=a.split(",").map(e=>Dr(e.trim()))}}if(!t.dtstart)throw new Error("Missing DTSTART in VEVENT");t.uid||(t.uid=Ze());return t}(t),o=function(t,n){var r;const{calendarId:a="default",generateNewIds:o=!0,idPrefix:l="ics-",defaultTimeZone:i}=n,s=o?`${l}${Ze()}`:t.uid,d=fr(t.dtstart,t.dtstartParams,i);let c;c=t.dtend?fr(t.dtend,t.dtendParams,i):tn(d)?d.add({days:1}):d.add({hours:1});const u="DATE"===(null===(r=t.dtstartParams)||void 0===r?void 0:r.value)||tn(d),h=i||e.Now.timeZoneId();let g,m;if(tn(d))g=d.toZonedDateTime({timeZone:h,plainTime:"00:00:00"});else if(nn(d))try{if("function"!=typeof d.toZonedDateTime)throw new Error("toZonedDateTime missing");g=d.toZonedDateTime(h)}catch(t){g=e.ZonedDateTime.from({year:d.year,month:d.month,day:d.day,hour:d.hour,minute:d.minute,second:d.second,millisecond:d.millisecond,timeZone:h})}else g=d;if(tn(c))m=c.toZonedDateTime({timeZone:h,plainTime:"00:00:00"});else if(nn(c))try{if("function"!=typeof c.toZonedDateTime)throw new Error("toZonedDateTime missing");m=c.toZonedDateTime(h)}catch(t){m=e.ZonedDateTime.from({year:c.year,month:c.month,day:c.day,hour:c.hour,minute:c.minute,second:c.second,millisecond:c.millisecond,timeZone:h})}else m=c;return{id:s,calendarId:a,title:t.summary||"(No Title)",description:t.description,start:g,end:m,allDay:u,meta:{location:t.location,originalUid:t.uid,categories:t.categories}}}(a,n);r.events.push(o)}catch(e){r.errors.push({line:0,message:e.message||"Unknown parsing error",eventUid:`index-${a}`})}}),r.success=0===r.errors.length,r.totalImported=r.events.length}catch(e){r.errors.push({message:`Fatal parsing error: ${e.message}`})}return r}function Dr(e){return e.replace(/\\,/g,",").replace(/\\;/g,";").replace(/\\[nN]/g,"\n").replace(/\\\\/g,"\\")}function xr(e,t={}){const{calendarName:n="DayFlow Calendar",productId:r="-//DayFlow//DayFlow Calendar//EN",includeTimezone:a=!0}=t,o=[];return o.push("BEGIN:VCALENDAR"),o.push("VERSION:2.0"),o.push(`PRODID:${r}`),o.push("CALSCALE:GREGORIAN"),o.push("METHOD:PUBLISH"),o.push(`X-WR-CALNAME:${kr(n)}`),e.forEach(e=>{o.push(...function(e){var t,n,r;const a=[];a.push("BEGIN:VEVENT");const o=null===(t=e.meta)||void 0===t?void 0:t.originalUid,l=o||`${e.id}@dayflow`;a.push(`UID:${l}`),a.push(`DTSTAMP:${yr(new Date)}`);const i=pr(e.start,e.allDay),s=pr(e.end,e.allDay);a.push(Cr("DTSTART",i.value,i.params)),a.push(Cr("DTEND",s.value,s.params)),a.push(Cr("SUMMARY",kr(e.title))),e.description&&a.push(Cr("DESCRIPTION",kr(e.description)));const d=null===(n=e.meta)||void 0===n?void 0:n.location;d&&a.push(Cr("LOCATION",kr(d)));const c=null===(r=e.meta)||void 0===r?void 0:r.categories;if(c&&Array.isArray(c)){const e=c.map(kr).join(",");a.push(Cr("CATEGORIES",e))}return a.push("END:VEVENT"),a}(e))}),o.push("END:VCALENDAR"),o.join("\r\n")}function Er(e,t={}){const n=xr(e,t),r=`${t.filename||"calendar"}.ics`,a=new Blob([n],{type:"text/calendar;charset=utf-8"}),o=URL.createObjectURL(a),l=document.createElement("a");l.href=o,l.setAttribute("download",r),document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(o)}function Cr(e,t,n){let r=e;return n&&Object.entries(n).forEach(([e,t])=>{r+=`;${e}=${t}`}),r+=`:${t}`,function(e){if(e.length<=75)return e;const t=[];let n=e;t.push(n.slice(0,75)),n=n.slice(75);for(;n.length>0;)t.push(" "+n.slice(0,74)),n=n.slice(74);return t.join("\r\n")}(r)}function kr(e){return e?e.replace(/\\/g,"\\\\").replace(/;/g,"\\;").replace(/,/g,"\\,").replace(/\n/g,"\\n"):""}function Tr(e,t){return y(this,void 0,void 0,function*(){return new Promise((n,r)=>{const a=new FileReader;a.onload=e=>{var r;try{const a=null===(r=e.target)||void 0===r?void 0:r.result;if(!a)throw new Error("File content is empty");const o=wr(a,t);n(o)}catch(e){n({success:!1,events:[],errors:[{message:e.message||"Failed to read file"}],totalParsed:0,totalImported:0})}},a.onerror=()=>{n({success:!1,events:[],errors:[{message:"File read error"}],totalParsed:0,totalImported:0})},a.readAsText(e)})})}let Nr=null;const Sr=()=>{const[e,t]=s(()=>Nr||{weekHeight:N.WEEK_HEIGHT,screenSize:"desktop",weeksPerView:6});return c(()=>{const e=()=>{const e=window.innerWidth,n=window.innerHeight-150,r=Math.max(80,Math.floor(n/6)),a=e<768?{weekHeight:Math.max(N.MOBILE_WEEK_HEIGHT,r),screenSize:"mobile",weeksPerView:6}:e<1024?{weekHeight:Math.max(N.TABLET_WEEK_HEIGHT,r),screenSize:"tablet",weeksPerView:6}:{weekHeight:Math.max(N.WEEK_HEIGHT,r),screenSize:"desktop",weeksPerView:6};Nr=a,t(e=>e.screenSize===a.screenSize&&e.weekHeight===a.weekHeight&&e.weeksPerView===a.weeksPerView?e:a)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e};let Mr=0;function Ir({generatorName:e,generatorArgs:t,defaultContent:n,store:r}){const a=d(null),o=u(Ve),l=r||o,i=d(null),[,h]=s(0);i.current||(i.current="df-slot-"+Mr++),c(()=>{if(!a.current||!l)return;const n=i.current;l.register({id:n,containerEl:a.current,generatorName:e,generatorArgs:t});const r=l.subscribe(()=>{h(e=>e+1)});return()=>{l.unregister(n),r()}},[l]),c(()=>{if(!l||!i.current)return;const n=i.current;l.register({id:n,containerEl:a.current,generatorName:e,generatorArgs:t})},[e,t]);const g="eventContent"===e,m="sidebar"===e,v=null==l?void 0:l.isOverridden(e);return Ge("div",{ref:a,className:"df-content-slot "+(g||m?"flex-1 flex flex-col h-full":""),children:!v&&n})}const Hr=({calendar:e,switcherMode:t="buttons",onAddCalendar:n,onSearchChange:r,onSearchClick:a,searchValue:o="",isSearchOpen:l=!1,isEditable:i=!0,safeAreaLeft:s})=>{const d=u(Ve),c="buttons"===t,m=e.state.currentView===k.DAY,{screenSize:v}=Sr(),f="mobile"===v,{t:p}=In(),y=g(e=>{const t=e.target.value;t!==o&&(null==r||r(t))},[r,o]);return Ge(Ir,{store:d,generatorName:"headerContent",generatorArgs:h(()=>({calendar:e,switcherMode:t,onAddCalendar:n,onSearchChange:r,onSearchClick:a,searchValue:o,isSearchOpen:l,isEditable:i,safeAreaLeft:s}),[e,t,n,r,a,o,l,i,s]),defaultContent:Ge("div",{className:"df-header flex items-center justify-between pr-2 pt-1 bg-white dark:bg-gray-900 transition-colors duration-200 shrink-0 border-b "+(m||l?"border-gray-200 dark:border-gray-700":"border-transparent"),style:{paddingLeft:s||8,transition:"padding-left 160ms ease-in-out"},onContextMenu:e=>e.preventDefault(),children:[Ge("div",{className:"df-header-left flex items-center mb-1",children:n&&i&&Ge("button",{id:"dayflow-add-event-btn",onClick:n,className:Bt,title:f?p("newEvent")||"New Event":p("createCalendar")||"Add Calendar",children:Ge(tt,{className:`h-4 w-4 ${Vt}`})})}),Ge("div",{className:"df-header-mid flex-1 flex justify-center",children:c&&Ge(zn,{mode:t,calendar:e})}),Ge("div",{className:"df-header-right flex items-center justify-end gap-3 mb-1 pb-1",children:[!c&&Ge(zn,{mode:t,calendar:e}),Ge("button",{onClick:a,className:`md:hidden ${Bt}`,title:p("search")||"Search",children:Ge(nt,{width:16,height:16})}),Ge("div",{className:"relative hidden md:block group",children:[Ge("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:Ge("span",{className:"text-gray-400 group-focus-within:text-primary transition-colors",children:Ge(nt,{width:16,height:16})})}),Ge("input",{id:"dayflow-search-input",type:"text",placeholder:p("search")||"Search",value:o,onChange:y,className:"pl-9 pr-8 py-1 h-7 text-sm border border-slate-200 dark:border-gray-600 rounded-lg text-gray-900 dark:text-gray-100 placeholder-gray-500 dark:placeholder-gray-400 focus:outline-none focus:ring-1 focus:ring-primary focus:border-primary transition resize-none w-48"}),o&&Ge("button",{onClick:()=>{null==r||r("")},className:"absolute inset-y-0 right-0 pr-2 flex items-center text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",children:Ge("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[Ge("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),Ge("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]})]})})},Rr=({loading:e,results:t,keyword:n,onResultClick:r,emptyText:a})=>{const{t:o,locale:l}=In(),i=h(()=>dr(new Date),[]),s=h(()=>ur(t,i),[t,i]),d=e=>sr(e);return e?Ge("div",{className:"flex flex-col items-center justify-center h-40 text-gray-500",children:[Ge(st,{className:"w-8 h-8 animate-spin mb-2"}),Ge("span",{children:"Loading..."})]}):0===t.length?n?Ge("div",{className:"flex flex-col items-center justify-center h-40 text-gray-500",children:[Ge(Or,{}),Ge("span",{className:"mt-2 text-sm",children:"string"==typeof a?a:a&&"object"==typeof a?a[l]||a.en||"No results found":o("noResults")||"No results found"})]}):null:Ge("div",{className:"space-y-6",children:s.map(e=>{const{title:t,colorClass:n}=cr(e.date,i,l,o);return Ge("div",{children:[Ge("h3",{className:`px-2 text-sm font-medium mb-4 sticky top-0 bg-white dark:bg-gray-900 py-1 z-10 ${n} border-b border-gray-200 dark:border-gray-700`,children:t}),Ge("div",{className:"flex flex-col",children:e.events.map(e=>{const t=d(e.start),n=d(e.end),a={hour:"2-digit",minute:"2-digit"},i=e.allDay?o("allDay")||"All Day":t.toLocaleTimeString(l,a),s=e.allDay?"":n.toLocaleTimeString(l,a);return Ge("div",{children:[Ge("div",{className:"p-2 mx-2 mb-1 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-800 cursor-pointer transition-colors group",onClick:()=>null==r?void 0:r(e),children:Ge("div",{className:"flex items-stretch gap-3",children:[Ge("div",{className:"w-1 rounded-full shrink-0",style:{backgroundColor:e.color||"#3b82f6"}}),Ge("div",{className:"flex-1 min-w-0 flex justify-between items-start",children:[Ge("div",{className:"font-medium text-black dark:text-white truncate pr-2 text-sm",children:e.title}),Ge("div",{className:"text-xs flex flex-col items-end shrink-0 leading-tight",children:[Ge("div",{className:"text-black dark:text-white",children:i}),s&&Ge("div",{className:"text-gray-500 dark:text-gray-400",children:s})]})]})]})}),Ge("div",{className:"mx-2 border-b border-gray-200 dark:border-gray-700"})]},e.id)})})]},e.date.getTime())})})},Or=()=>Ge("svg",{className:"w-12 h-12 text-gray-300 dark:text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Ge("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),Pr=({isOpen:e,onClose:t,loading:n,results:r,keyword:a,onResultClick:o,emptyText:l})=>Ge("div",{className:"hidden md:flex relative h-full bg-white dark:bg-gray-900 transition-all duration-300 ease-in-out flex-col border-l border-gray-200 dark:border-gray-700 overflow-hidden select-none "+(e?"w-64":"w-0 border-l-0"),children:Ge("div",{className:"flex-1 overflow-y-auto min-w-64",children:Ge(Rr,{loading:n,results:r,keyword:a,onResultClick:o,emptyText:l})})}),Lr=({isOpen:e,onClose:t,keyword:n,onSearchChange:r,results:a,loading:o,onResultClick:l,emptyText:i})=>{const s=d(null),{t:u}=In();return c(()=>(e?(setTimeout(()=>{var e;null===(e=s.current)||void 0===e||e.focus()},100),document.body.style.overflow="hidden"):document.body.style.overflow="",()=>{document.body.style.overflow=""}),[e]),e&&"undefined"!=typeof window?v(Ge("div",{className:"fixed inset-0 z-9999 bg-white dark:bg-gray-900 flex flex-col",children:[Ge("div",{className:"flex items-center p-2 border-b border-gray-200 dark:border-gray-700 gap-2",children:[Ge("button",{onClick:t,className:"p-2 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:Ge(vt,{className:"w-6 h-6"})}),Ge("div",{className:"flex-1 relative",children:[Ge("input",{ref:s,type:"text",placeholder:u("search")||"Search",value:n,onChange:e=>{const t=e.target.value;t!==n&&r(t)},className:"w-full pl-3 pr-10 py-2 bg-gray-100 dark:bg-gray-800 border-none rounded-full text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-primary focus:outline-none"}),n&&Ge("button",{onClick:()=>{""!==n&&r("")},className:"absolute inset-y-0 right-0 pr-3 flex items-center text-gray-400",children:Ge(ot,{className:"w-4 h-4"})})]})]}),Ge("div",{className:"flex-1 overflow-y-auto p-2 select-none",children:Ge(Rr,{loading:o,results:a,keyword:n,onResultClick:e=>{null==l||l(e)},emptyText:i})})]}),document.body):null},Ar=({app:e,anchorRef:t,onClose:n,isOpen:r})=>{const{t:a}=In(),[o,l]=s(""),[i,u]=s(0),[g,f]=s(!1),p=d(null),y=d(null);c(()=>{r||f(!1)},[r]),c(()=>{r&&(setTimeout(()=>{var e;return null===(e=p.current)||void 0===e?void 0:e.focus()},50),l(""),u(0))},[r]),c(()=>{const e=e=>{r&&y.current&&!y.current.contains(e.target)&&t.current&&!t.current.contains(e.target)&&n()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[r,n,t]);const[b,w]=s({top:0,left:0}),[D,x]=s("top"),[E,C]=s(0),k=h(()=>{const e=new Date,t=new Date(e);t.setHours(t.getHours()+1,0,0,0);const n=new Date(t);return n.setHours(n.getHours()+1),{start:t,end:n}},[r]),T=h(()=>{if(!o.trim())return[];const t=[],n=e.getCalendars(),r=e.getAllEvents(),a=o.toLowerCase(),l=r.find(e=>e.title.toLowerCase()===a);let i=null==l?void 0:l.calendarId;if(!i){const e=n.filter(e=>!1!==e.isVisible);if(e.length>0){const t=Math.floor(Math.random()*e.length);i=e[t].id}else n.length>0&&(i=n[0].id)}const s=n.find(e=>e.id===i),d=(null==s?void 0:s.colors.lineColor)||"#3b82f6";t.push({type:"new",title:o,calendarId:i||"",color:d,start:k.start,end:k.end});const c=new Set;c.add(o.toLowerCase());return r.filter(e=>e.title.toLowerCase().includes(a)&&!c.has(e.title.toLowerCase())).slice(0,5).forEach(e=>{c.add(e.title.toLowerCase());const r=n.find(t=>t.id===e.calendarId);t.push({type:"history",title:e.title,calendarId:e.calendarId||"",color:(null==r?void 0:r.colors.lineColor)||"#9ca3af",start:k.start,end:k.end})}),t},[o,e,k]);m(()=>{if(r&&t.current&&y.current){const e=t.current.getBoundingClientRect(),n=y.current.offsetHeight,r=340;let a=e.left+e.width/2-r/2;const o=12,l=window.innerWidth;a<o?a=o:a+r>l-o&&(a=l-r-o);const i=e.left+e.width/2;C(i-a);let s=0,d="top";e.top<n+20?(d="bottom",s=e.bottom+12):(d="top",s=e.top-12-n),x(d),w({top:s,left:a}),f(!0)}},[r,t,T]);const N=t=>{if(!t.calendarId)return;const r=Ze(),a={id:r,title:t.title,start:Z(t.start),end:Z(t.end),calendarId:t.calendarId,allDay:!1};e.addEvent(a),e.setCurrentDate(t.start),e.highlightEvent(r),n()};c(()=>{if(!r)return;const e=e=>{"ArrowDown"===e.key?(e.preventDefault(),u(e=>(e+1)%T.length)):"ArrowUp"===e.key?(e.preventDefault(),u(e=>(e-1+T.length)%T.length)):"Enter"===e.key&&(e.preventDefault(),T[i]&&N(T[i]))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[r,T,i]);const S=(e,t)=>{const n=e=>e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1});return`${n(e)} - ${n(t)}`};return r?v(Ge("div",{ref:y,className:"fixed z-1000 w-85 flex flex-col bg-white dark:bg-slate-800 rounded-xl shadow-2xl border border-gray-200 dark:border-slate-700 "+(g?"animate-in fade-in zoom-in-95 duration-100":""),style:{top:b.top,left:b.left,visibility:g?"visible":"hidden"},children:[Ge("div",{className:"p-4 pb-2",children:[Ge("div",{className:"mb-2 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:a("quickCreateEvent")||"Quick Create Event"}),Ge("div",{className:"relative",children:Ge("input",{ref:p,type:"text",className:"w-full border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-1.5 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary transition",placeholder:a("quickCreatePlaceholder")||"Enter title (e.g. Code review)",value:o,onChange:e=>l(e.target.value)})})]}),Ge("div",{className:"flex-1 overflow-y-auto max-h-75 py-1 px-2",children:[0===T.length&&o&&Ge("div",{className:"px-4 py-3 text-sm text-gray-400 text-center",children:a("noSuggestions")||"Type to create"}),T.map((e,t)=>Ge("div",{className:"flex items-center px-4 py-2 cursor-pointer transition-colors rounded-lg "+(t===i?"bg-primary/10 dark:bg-primary/20 ring-1 ring-inset ring-primary/20":"hover:bg-gray-50 dark:hover:bg-slate-700/50"),onClick:()=>N(e),onMouseEnter:()=>u(t),children:[Ge("div",{className:"w-1 h-8 rounded-full mr-3 shrink-0",style:{backgroundColor:e.color}}),Ge("div",{className:"flex-1 min-w-0 flex flex-col gap-0.5",children:[Ge("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 truncate",children:e.title}),Ge("div",{className:"flex",children:Ge("span",{className:"font-semibold text-[10px] px-1 bg-gray-100 dark:bg-slate-700 rounded text-gray-500 dark:text-gray-400",children:"new"===e.type?a("today"):a("tomorrow")})}),Ge("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:S(e.start,e.end)})]})]},`${e.type}-${t}`))]}),Ge("div",{className:"absolute w-3 h-3 bg-white dark:bg-slate-800 border-gray-200 dark:border-slate-700 rotate-45 -translate-x-1/2 "+("top"===D?"-bottom-1.5 border-b border-r":"-top-1.5 border-t border-l"),style:{left:E}})]}),document.body):null},$r=e=>{const t=d(null),n=d(null);return c(()=>{if(t.current){const{className:r}=e,a=b(e,["className"]);n.current=new w(t.current,a),a.initialExpanded&&n.current.expand()}return()=>{n.current&&(n.current.destroy(),n.current=null)}},[]),c(()=>{if(n.current){const{className:t}=e,r=b(e,["className"]);n.current.setOptions(r)}},[e]),Ge("div",{ref:t,className:e.className})},jr=({color:e,onChange:t,onClose:n})=>{const r=h(()=>{const{h:t,s:n,l:r}=D(e);return{hue:t,saturation:x(r),lightness:r,alpha:100,layer:"outer"}},[e]);return Ge("div",{className:"flex justify-center",children:Ge($r,{defaultValue:r,coreSize:36,petalSize:32,initialExpanded:!0,openOnHover:!1,onChange:e=>t({hex:e.hex},!0),onCollapse:n})})},Yr=t(void 0),Fr=({children:e,initialTheme:t="light",onThemeChange:n})=>{const[r,a]=s(t),[o,l]=s("light"),i="auto"===r?o:r;c(()=>{a(t)},[t]);const d=g(e=>{a(e)},[]);c(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-color-scheme: dark)"),t=e=>{const t=e.matches?"dark":"light";l(t)},n=e.matches?"dark":"light";return l(n),e.addEventListener?e.addEventListener("change",t):e.addListener&&e.addListener(t),()=>{e.removeEventListener?e.removeEventListener("change",t):e.removeListener&&e.removeListener(t)}},[]),c(()=>{if("undefined"==typeof document)return;const e=document.documentElement,t=Xn(i),n="auto"===r?t:i;e.classList.remove("light","dark"),e.classList.add(n),"auto"===r?e.removeAttribute("data-dayflow-theme-override"):e.setAttribute("data-dayflow-theme-override",n),e.setAttribute("data-theme",n)},[i,r,o]),c(()=>{n&&n(r,i)},[r,i,n]);const u={theme:r,effectiveTheme:i,setTheme:d};return Ge(Yr.Provider,{value:u,children:e})},zr=()=>{const e=u(Yr);if(void 0===e)throw new Error("useTheme must be used within a ThemeProvider");return e},_r=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],Zr=({onClose:e,onCreate:t,colorPickerMode:n="default"})=>{const{t:a}=In(),{effectiveTheme:o}=zr(),[l,i]=s(""),[d,c]=s(_r[Math.floor(Math.random()*_r.length)]),[u,g]=s(!1),[m,f]=s(""),p=h(()=>{const e=E[Math.floor(Math.random()*E.length)],t=e.layer||"outer",n=x(e.l);return{hue:e.h,saturation:n,lightness:e.l,alpha:100,layer:t}},[]),[y,b]=s(null),w=e=>{c(e.hex)},D="dark"===o,k={default:{picker:{background:D?"#1e293b":"#ffffff",boxShadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",borderRadius:"0.5rem",border:D?"1px solid #4b5563":"1px solid #e5e7eb"},head:{background:D?"#1e293b":"#ffffff",borderBottom:D?"1px solid #4b5563":"1px solid #e5e7eb",boxShadow:"none"},body:{background:D?"#1e293b":"#ffffff"},controls:{border:D?"1px solid #4b5563":"1px solid #e5e7eb"},input:{background:D?"#374151":"#ffffff",color:D?"#f3f4f6":"#1f2937",border:D?"1px solid #4b5563":"1px solid #e5e7eb",boxShadow:"none"},previews:{border:D?"1px solid #4b5563":"1px solid #e5e7eb"},actions:{borderTop:D?"1px solid #4b5563":"1px solid #e5e7eb"}}};return"undefined"==typeof window?null:v(Ge("div",{className:"fixed inset-0 z-10000 flex items-center justify-center bg-black/50",children:Ge("div",{className:"w-full max-w-sm rounded-lg p-6 shadow-xl bg-white dark:bg-slate-900 animate-in fade-in zoom-in-95",onClick:e=>e.stopPropagation(),children:[Ge("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white "+("default"===n?"mb-6":"mb-4"),children:a("createCalendar")}),Ge("form",{onSubmit:r=>{var a;if(r.preventDefault(),!l.trim())return;let o;o="default"===n?null!==(a=null==y?void 0:y.hex)&&void 0!==a?a:C(p.hue,p.saturation,p.lightness):d;const{colors:i,darkColors:s}=O(o),c={id:Ze(),name:l.trim(),colors:i,darkColors:s,isVisible:!0,isDefault:!1};t(c),e()},children:["default"===n?Ge("div",{className:"mb-8 flex items-center gap-4",children:[Ge("div",{className:"flex-1",children:Ge("input",{id:"blossom-calendar-name",name:"calendar-name",type:"text",value:l,onChange:e=>i(e.target.value),className:"w-full border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-1.5 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary transition",placeholder:a("calendarNamePlaceholder"),autoFocus:!0})}),Ge("div",{className:"w-9 h-9 relative shrink-0",children:Ge("div",{className:"absolute inset-0 flex items-center justify-center",children:Ge($r,{defaultValue:p,coreSize:36,petalSize:32,openOnHover:!1,onChange:e=>b(e),onCollapse:e=>b(e),className:"z-50"})})})]}):Ge(r,{children:[Ge("div",{className:"mb-4",children:Ge("div",{className:"flex items-center gap-3",children:[Ge("div",{className:"h-9 w-9 rounded-md border border-gray-200 shadow-sm dark:border-gray-600",style:{backgroundColor:d}}),Ge("input",{id:"custom-calendar-name",name:"calendar-name",type:"text",value:l,onChange:e=>i(e.target.value),className:"w-full flex-1 border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-1.5 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary transition",placeholder:a("calendarNamePlaceholder"),autoFocus:!0})]})}),Ge("div",{className:"mb-6",children:[Ge("div",{className:"grid grid-cols-7 gap-6",children:_r.map(e=>Ge("button",{type:"button",className:"h-6 w-6 rounded-full border border-gray-200 focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 dark:border-gray-600 dark:focus:ring-offset-slate-800 "+(d===e?"ring-2 ring-primary ring-offset-2 dark:ring-offset-slate-800":""),style:{backgroundColor:e},onClick:()=>c(e)},e))}),Ge("div",{className:"mt-2 relative",children:[Ge("button",{type:"button",onClick:()=>{f(d),g(!0)},className:"flex w-full cursor-pointer items-center rounded-sm px-2 py-1.5 text-sm text-slate-700 hover:bg-slate-100 dark:text-slate-200 dark:hover:bg-slate-800 transition-colors focus:outline-none focus:bg-slate-100 dark:focus:bg-slate-800",children:a("customColor")}),u&&Ge("div",{className:"absolute left-0 top-full z-10001 mt-2",children:Ge(Ir,{generatorName:"colorPickerWrapper",generatorArgs:{variant:"photoshop",color:d,onChange:w,onAccept:()=>{g(!1)},onCancel:()=>{c(m),g(!1)},styles:k},defaultContent:Ge("div",{children:Ge(jr,{color:d,onChange:w})})})})]})]})]}),Ge("div",{className:"flex justify-end space-x-2",children:[Ge("button",{type:"button",onClick:e,className:"px-2 py-1 border border-slate-200 dark:border-gray-600 text-gray-700 dark:text-gray-300 rounded hover:bg-gray-50 dark:hover:bg-gray-800 text-xs font-medium transition",children:a("cancel")}),Ge("button",{type:"submit",disabled:!l.trim(),className:"px-2 py-1 bg-primary text-primary-foreground rounded hover:bg-primary/90 text-xs font-medium transition disabled:opacity-50",children:a("create")})]})]})]})}),document.body)},Wr=({visibleMonth:e,currentDate:t,showHeader:n=!1,onMonthChange:r,onDateSelect:a})=>{const{locale:o}=In(),l=h(()=>(new Date).toDateString(),[]),i=t.toDateString(),s=h(()=>Tn(o,"narrow"),[o]),d=h(()=>e.toLocaleDateString(o,{month:"long",year:"numeric"}),[e,o]),c=h(()=>{const t=e.getFullYear(),n=e.getMonth(),r=(new Date(t,n,1).getDay()+6)%7,a=[];for(let e=0;e<42;e++){const o=new Date(t,n,e-r+1),s=o.toDateString();a.push({date:o.getDate(),fullDate:o,isCurrentMonth:o.getMonth()===n,isToday:s===l,isSelected:s===i})}return a},[e,i,l]);return Ge("div",{className:"px-3 py-3",children:[n?Ge("div",{className:"mb-3 flex items-center justify-between",children:[Ge("button",{type:"button",className:"flex h-7 w-7 items-center justify-center rounded-full text-gray-500 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-slate-800",onClick:()=>r(-1),"aria-label":"Previous month",children:Ge(Ke,{className:"h-4 w-4"})}),Ge("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:d}),Ge("button",{type:"button",className:"flex h-7 w-7 items-center justify-center rounded-full text-gray-500 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-slate-800",onClick:()=>r(1),"aria-label":"Next month",children:Ge(Xe,{className:"h-4 w-4"})})]}):"",Ge("div",{className:"df-mini-calendar-grid grid grid-cols-7 gap-1 text-xs justify-items-center",children:[s.map((e,t)=>Ge("div",{className:"df-mini-calendar-header text-center text-gray-500 dark:text-gray-400 font-medium py-1 h-6 w-6 text-gray-500 dark:text-gray-400",children:e},`weekday-${t}`)),c.map(e=>Ge("button",{type:"button",className:`\n df-mini-calendar-day text-center py-1 rounded text-xs h-6 w-6\n ${e.isToday?Lt:e.isCurrentMonth?"text-gray-900 dark:text-gray-100":"text-gray-400 dark:text-gray-600"}\n ${e.isSelected&&!e.isToday?"bg-secondary text-secondary-foreground rounded-full font-medium":""}\n `,onClick:()=>a(e.fullDate),children:e.date},e.fullDate.getTime()))]})]})},Ur=({checked:e,onChange:t,disabled:n})=>Ge("div",{className:`w-12 h-7 flex items-center rounded-full p-1 transition-colors ${n?"cursor-default opacity-50":"cursor-pointer"} ${e?"bg-green-500":"bg-gray-300"}`,onClick:()=>!n&&t(!e),children:Ge("div",{className:"bg-white w-5 h-5 rounded-full shadow-md transform transition-transform "+(e?"translate-x-5":"")})}),Br=({date:e,onChange:t})=>{const n=Array.from({length:24},(e,t)=>t),r=Array.from({length:12},(e,t)=>5*t),a=[...n,...n,...n],o=[...r,...r,...r],l=32,i=e.getHours(),u=5*Math.round(e.getMinutes()/5),h=(24+i)*l,g=(12+u/5)*l,[m,v]=s(h),[f,p]=s(g),y=d(null),b=d(null),w=d(null);c(()=>{y.current&&(y.current.scrollTop=h,v(h)),b.current&&(b.current.scrollTop=g,p(g))},[h,g]);const D=(n,r)=>{const i=n.currentTarget;let s=i.scrollTop;if("hour"===r){const e=768;s<320?(s+=e,i.scrollTop=s):s>1600&&(s-=e,i.scrollTop=s),v(s)}else{const e=384;s<160?(s+=e,i.scrollTop=s):s>800&&(s-=e,i.scrollTop=s),p(s)}w.current&&clearTimeout(w.current),w.current=setTimeout(()=>{((n,r)=>{const i=Math.round(r/l);if("hour"===n){const n=a[i];if(void 0!==n&&n!==e.getHours()){const r=new Date(e);r.setHours(n),t(r)}}else{const n=o[i];if(void 0!==n&&5*Math.round(e.getMinutes()/5)!==n){const r=new Date(e);r.setMinutes(n),t(r)}}})(r,s)},150)},x=(e,t)=>{const n=96+e*l+16-(t+112),r=Math.min(Math.abs(n)/112,1);return{transform:`perspective(500px) rotateX(${-(n/112*80)}deg) scale(${1-.4*r})`,opacity:1-.7*r,transition:"transform 0.1s ease-out, opacity 0.1s ease-out"}};return Ge("div",{className:"flex h-56 overflow-hidden rounded-lg mt-2 relative ",children:[Ge("style",{dangerouslySetInnerHTML:{__html:"\n .no-scrollbar::-webkit-scrollbar { display: none; }\n .no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }\n "}}),Ge("div",{ref:y,className:"flex-1 overflow-y-auto snap-y snap-mandatory no-scrollbar",style:{touchAction:"pan-y"},onScroll:e=>D(e,"hour"),children:[Ge("div",{style:{height:96}}),a.map((n,r)=>Ge("div",{className:"h-8 flex items-center justify-end pr-5 snap-center cursor-pointer",onClick:()=>{var a;const o=new Date(e);o.setHours(n),t(o),null===(a=y.current)||void 0===a||a.scrollTo({top:r*l,behavior:"smooth"})},children:Ge("div",{className:"w-10 text-center text-xl transition-colors duration-200 "+(n===i?"font-bold text-black dark:text-white":"text-gray-400 dark:text-gray-500"),style:x(r,m),children:n.toString().padStart(2,"0")})},r)),Ge("div",{style:{height:96}})]}),Ge("div",{ref:b,className:"flex-1 overflow-y-auto snap-y snap-mandatory no-scrollbar",style:{touchAction:"pan-y"},onScroll:e=>D(e,"minute"),children:[Ge("div",{style:{height:96}}),o.map((n,r)=>Ge("div",{className:"h-8 flex items-center justify-start pl-5 snap-center cursor-pointer",onClick:()=>{var a;const o=new Date(e);o.setMinutes(n),t(o),null===(a=b.current)||void 0===a||a.scrollTo({top:r*l,behavior:"smooth"})},children:Ge("div",{className:"w-10 text-center text-xl transition-colors duration-200 "+(n===u?"font-bold text-black dark:text-white":"text-gray-400 dark:text-gray-500"),style:x(r,f),children:n.toString().padStart(2,"0")})},r)),Ge("div",{style:{height:96}})]}),Ge("div",{className:"absolute top-24 left-2 right-2 h-8 bg-gray-300/20 dark:bg-gray-500/20 pointer-events-none border border-gray-300 dark:border-gray-600 rounded-lg"})]})},Vr=({isOpen:e,onClose:t,onSave:n,onEventDelete:r,draftEvent:a,app:o})=>{const{locale:l,t:i}=In(),d=o.getReadOnlyConfig(),u=!o.state.readOnly,g=!1!==d.viewable,[m,f]=s(""),[p,y]=s(""),[b,w]=s(!1),[D,x]=s(new Date),[E,C]=s(new Date),[k,T]=s(""),[N,S]=s(new Date),[M,I]=s(new Date),[H,R]=s(null),[O,P]=s(e),[L,A]=s(!1),[$,j]=s(!1);c(()=>{if(!e){A(!0);const e=setTimeout(()=>{P(!1),A(!1)},300);return()=>clearTimeout(e)}P(!0),A(!1)},[e]),c(()=>{if(e&&a){const e=o.getEvents().some(e=>e.id===a.id);j(e)}},[e,a,o]);const Y=o.getCalendars(),F=Y.map(e=>({label:e.name,value:e.id}));c(()=>{if(e&&Y.length>0){Y.some(e=>e.id===p)||"blue"!==p&&""!==p||y(Y[0].id)}},[Y,e,p]),c(()=>(e?(document.body.style.overflow="hidden",document.documentElement.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%"):(document.body.style.overflow="",document.documentElement.style.overflow="",document.body.style.position="",document.body.style.width=""),()=>{document.body.style.overflow="",document.documentElement.style.overflow="",document.body.style.position="",document.body.style.width=""}),[e]),c(()=>{var t,n;if(e&&a){if(f(a.title||""),y(a.calendarId||(null===(t=Y[0])||void 0===t?void 0:t.id)||"blue"),w(a.allDay||!1),a.start)try{const e=U(a.start);x(e),S(e)}catch(e){console.error("Failed to parse start date",e);const t=new Date;x(t),S(t)}if(a.end)try{const e=U(a.end);C(e),I(e)}catch(e){console.error("Failed to parse end date",e);const t=new Date;C(t),I(t)}}else if(e&&!a){y((null===(n=Y[0])||void 0===n?void 0:n.id)||"blue");const e=new Date;e.setMinutes(0,0,0),x(e),S(e),C(new Date(e.getTime()+36e5)),I(e)}},[e,a]);const z=h(()=>{if(!e||!a)return!1;let t=new Date(D),n=new Date(E);b&&(t.setHours(0,0,0,0),n.setHours(0,0,0,0));const r=Object.assign(Object.assign({},a),{title:m,calendarId:p,allDay:b,description:k,start:Z(t),end:Z(n)});return!ze(a,r)},[e,a,m,p,b,D,E,k]);if(!O||!g)return null;const _=e=>{R(t=>t===e?null:e)},W=e=>e.toLocaleDateString(l,{day:"numeric",month:"short",year:"numeric"}),B=(e,t)=>{if("start"===e){const e=new Date(t);e.setHours(D.getHours(),D.getMinutes());const n=e.getTime()-D.getTime();x(e);const r=new Date(E.getTime()+n);C(r)}else{const e=new Date(t);e.setHours(E.getHours(),E.getMinutes()),C(e)}},V=(e,t)=>{"start"===e?S(e=>{const n=new Date(e);return n.setMonth(e.getMonth()+t),n}):I(e=>{const n=new Date(e);return n.setMonth(e.getMonth()+t),n})};return v(Ge("div",{className:"fixed inset-0 z-10000 flex items-end pointer-events-none",children:[Ge("div",{className:"absolute inset-0 bg-black/30 pointer-events-auto transition-opacity duration-300 "+(L?"opacity-0":"opacity-100"),style:{touchAction:"none"},onClick:t}),Ge("div",{className:"relative w-full bg-gray-100 dark:bg-gray-800 rounded-t-2xl shadow-xl h-[85vh] flex flex-col pointer-events-auto overflow-hidden "+(L?"animate-slide-down":"animate-slide-up"),onClick:e=>e.stopPropagation(),children:[Ge("div",{className:"flex justify-between items-center p-4 bg-white dark:bg-gray-900 border-b border-gray-200 dark:border-gray-700",children:[Ge("button",{onClick:t,className:"text-gray-500 hover:text-gray-700 px-2 py-1",children:i("cancel")}),Ge("span",{className:"font-semibold text-lg",children:i(!u&&$?"viewEvent":$?"editEvent":"newEvent")}),u&&Ge("button",{onClick:()=>{if(!a)return;let e=new Date(D),t=new Date(E);b&&(e.setHours(0,0,0,0),t.setHours(0,0,0,0));const r=Object.assign(Object.assign({},a),{title:m,calendarId:p,allDay:b,start:Z(e),end:Z(t)});n(r)},disabled:!z,className:"font-bold px-2 py-1 transition-colors "+(z?"text-primary":"text-gray-400 cursor-not-allowed opacity-50"),children:i($?"done":"create")}),!u&&Ge("span",{className:"w-12"})]}),Ge("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[Ge("div",{className:"bg-white dark:bg-gray-900 rounded-lg px-4 py-3",children:Ge("input",{type:"text",placeholder:i("titlePlaceholder"),value:m,onChange:e=>u&&f(e.target.value),readOnly:!u,className:"w-full bg-transparent text-xl font-medium placeholder-gray-400 focus:outline-none",autoFocus:u})}),Y.length>0&&Ge("div",{className:"bg-white dark:bg-gray-900 rounded-lg px-4 py-3 flex justify-between items-center relative",children:[Ge("span",{className:"text-gray-700 dark:text-gray-300",children:i("calendar")}),Ge(en,{options:F,value:p,onChange:u?y:()=>{},registry:o.getCalendarRegistry(),variant:"mobile",disabled:!u})]}),Ge("div",{className:"bg-white dark:bg-gray-900 rounded-lg px-4 py-3 flex justify-between items-center",children:[Ge("span",{className:"text-gray-700 dark:text-gray-300",children:i("allDay")}),Ge(Ur,{checked:b,onChange:u?w:()=>{},disabled:!u})]}),Ge("div",{className:"bg-white dark:bg-gray-900 rounded-lg overflow-hidden",children:[Ge("div",{className:"flex justify-between items-center px-4 py-3 border-b border-gray-100 dark:border-gray-800 last:border-0",children:[Ge("span",{className:"text-gray-700 dark:text-gray-300",children:i("starts")}),Ge("div",{className:"flex space-x-2",children:[Ge("button",{className:"px-3 py-1 rounded-md transition-colors "+("start-date"===H?"bg-gray-200 dark:bg-gray-700 text-primary dark:text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300"),onClick:()=>u&&_("start-date"),disabled:!u,children:W(D)}),!b&&Ge("button",{className:"px-3 py-1 rounded-md transition-colors "+("start-time"===H?"bg-gray-200 dark:bg-gray-700 text-primary dark:text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300"),onClick:()=>u&&_("start-time"),disabled:!u,children:ge(D.getHours()+D.getMinutes()/60)})]})]}),Ge("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("start-date"===H?"max-h-100":"max-h-0"),children:Ge("div",{className:"",children:Ge(Wr,{currentDate:D,visibleMonth:N,onDateSelect:e=>B("start",e),onMonthChange:e=>V("start",e),showHeader:!0})})}),Ge("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("start-time"===H?"max-h-75":"max-h-0"),children:Ge("div",{className:"",children:Ge(Br,{date:D,onChange:e=>{const t=E.getTime()-D.getTime();x(e),C(new Date(e.getTime()+t))}})})})]}),Ge("div",{className:"bg-white dark:bg-gray-900 rounded-lg overflow-hidden",children:[Ge("div",{className:"flex justify-between items-center px-4 py-3 border-b border-gray-100 dark:border-gray-800 last:border-0",children:[Ge("span",{className:"text-gray-700 dark:text-gray-300",children:i("ends")}),Ge("div",{className:"flex space-x-2",children:[Ge("button",{className:"px-3 py-1 rounded-md transition-colors "+("end-date"===H?"bg-gray-200 dark:bg-gray-700 text-primary dark:text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300"),onClick:()=>u&&_("end-date"),disabled:!u,children:W(E)}),!b&&Ge("button",{className:"px-3 py-1 rounded-md transition-colors "+("end-time"===H?"bg-gray-200 dark:bg-gray-700 text-primary dark:text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300"),onClick:()=>u&&_("end-time"),disabled:!u,children:ge(E.getHours()+E.getMinutes()/60)})]})]}),Ge("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("end-date"===H?"max-h-100":"max-h-0"),children:Ge("div",{className:"",children:Ge(Wr,{currentDate:E,visibleMonth:M,onDateSelect:e=>B("end",e),onMonthChange:e=>V("end",e),showHeader:!0})})}),Ge("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("end-time"===H?"max-h-75":"max-h-0"),children:Ge("div",{className:"",children:Ge(Br,{date:E,onChange:e=>{if(e<D){const t=E.getTime()-D.getTime();C(e),x(new Date(e.getTime()-t))}else C(e)}})})})]}),Ge("div",{className:"bg-white dark:bg-gray-900 rounded-lg px-4 py-3",children:Ge("textarea",{placeholder:i("notesPlaceholder"),value:k,onChange:e=>u&&T(e.target.value),readOnly:!u,className:"w-full bg-transparent text-base placeholder-gray-400 focus:outline-none min-h-20"})}),u&&$&&r&&a&&Ge("button",{onClick:()=>r(a.id),className:"w-full bg-white dark:bg-gray-900 rounded-lg px-4 py-3 text-red-500 font-medium text-left",children:i("delete")})]})]})]}),document.body)};let qr=null;function Gr(e){qr=e}const Kr={enabled:!1,width:"0px",isCollapsed:!1,toggleCollapsed:()=>{},miniWidth:"0px",content:null,extraContent:null,safeAreaLeft:0};function Xr(e){return qr&&e.hasPlugin("sidebar")?qr(e):Kr}const Jr=({locale:e,messages:t,children:n})=>In().isDefault?Ge(Hn,{locale:e,messages:t,children:n}):Ge(r,{children:n}),Qr=({app:e,customDetailPanelContent:t,customEventDetailDialog:n,meta:r,customMessages:o,search:l,titleBarSlot:i,collapsedSafeAreaLeft:m})=>{const f=u(Ve),{tick:p,selectedEventId:b}=function(e){const[t,n]=s(0),[r,a]=s(null);return c(()=>e.subscribe(e=>{n(e=>e+1),a(t=>{var n;const r=null!==(n=e.state.selectedEventId)&&void 0!==n?n:null;return t!==r?r:t})}),[e]),{tick:t,selectedEventId:r}}(e),{isMobile:w}=function(){const[e,t]=s(!1);return c(()=>{const e=()=>{t(window.matchMedia("(max-width: 768px)").matches)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),{isMobile:e}}(),D=function(e,t){const[n,r]=s(""),[a,o]=s(!1),[l,i]=s(!1),[d,u]=s(!1),[h,m]=s([]);c(()=>{e.state.highlightedEventId&&e.selectEvent(e.state.highlightedEventId)},[e.state.highlightedEventId,e]),c(()=>{a||null===e.state.highlightedEventId||e.highlightEvent(null)},[a,e]),c(()=>{var r;if(!n.trim())return o(!1),m([]),void(null!==e.state.highlightedEventId&&e.highlightEvent(null));const a=null!==(r=null==t?void 0:t.debounceDelay)&&void 0!==r?r:300,l=setTimeout(()=>y(this,void 0,void 0,function*(){var r;u(!0),o(!0);try{let a=[];if(null==t?void 0:t.customSearch){const r=e.getEvents().map(t=>{var n;return Object.assign(Object.assign({},t),{color:(null===(n=e.getCalendarRegistry().get(t.calendarId||""))||void 0===n?void 0:n.colors.lineColor)||e.getCalendarRegistry().resolveColors().lineColor})});a=t.customSearch({keyword:n,events:r})}else if(null==t?void 0:t.onSearch)a=yield t.onSearch(n);else{const t=n.toLowerCase();a=e.getEvents().filter(e=>e.title.toLowerCase().includes(t)||e.description&&e.description.toLowerCase().includes(t)).map(t=>{var n;return Object.assign(Object.assign({},t),{color:(null===(n=e.getCalendarRegistry().get(t.calendarId||""))||void 0===n?void 0:n.colors.lineColor)||e.getCalendarRegistry().resolveColors().lineColor})})}m(a),null===(r=null==t?void 0:t.onSearchStateChange)||void 0===r||r.call(t,{keyword:n,loading:!1,results:a})}catch(e){console.error("Search failed",e),m([])}finally{u(!1)}}),a);return()=>clearTimeout(l)},[n,t,e]);const v=g(t=>{let n;n=t.start instanceof Date?t.start:"string"==typeof t.start?new Date(t.start):U(t.start),e.setCurrentDate(n),e.highlightEvent(t.id),l&&i(!1)},[e,l]),f=g(()=>{r(""),i(!0)},[]),p=g(()=>{o(!1),r(""),e.highlightEvent(null)},[e]),b=g(()=>{i(!1),r(""),e.highlightEvent(null)},[e]);return{searchKeyword:n,setSearchKeyword:r,isSearchOpen:a,setIsSearchOpen:o,isMobileSearchOpen:l,setIsMobileSearchOpen:i,searchLoading:d,searchResults:h,handleSearchResultClick:v,handleSearchClick:f,handleSearchClose:p,handleMobileSearchClose:b}}(e,l),x=n||(e.getUseEventDetailDialog()?Fn:void 0),E=function(e,t,n){const[r,a]=s(null);c(()=>{a(null)},[e]);const o=g(()=>{a(null),e.selectEvent(null)},[e]),l=g(t=>e.updateEvent(t.id,t),[e]),i=g(t=>{e.deleteEvent(t),a(null),e.selectEvent(null)},[e]),d=h(()=>{if(!t||!r)return null;const n=r.split("::")[0],a=e.getEvents().find(e=>e.id===n);return a?{event:a,isOpen:!0,isAllDay:z(a.start),onEventUpdate:l,onEventDelete:i,onClose:o,app:e}:null},[n,r,t,o,l,i,e]);return{detailPanelEventId:r,setDetailPanelEventId:a,dialogProps:d}}(e,x,p),C=Xr(e),k=function(e,t,n){const[r,a]=s(!1),o=d(null),[l,i]=s(!1),[c,u]=s(null),[h,m]=s(!1),v=g(()=>{m(!0)},[]),f=g(l=>{var s,d;if(!e.state.readOnly){if(t){const t=new Date;t.setMinutes(0,0,0),t.setHours(t.getHours()+1);const n=new Date(t);n.setHours(n.getHours()+1);const r={id:Ze(),title:"",start:Z(t),end:Z(n),calendarId:(null===(s=e.getCalendars().find(e=>!1!==e.isVisible))||void 0===s?void 0:s.id)||(null===(d=e.getCalendars()[0])||void 0===d?void 0:d.id)};return u(r),void i(!0)}n?r?a(!1):(o.current=l.currentTarget,a(!0)):v()}},[t,r,e,n,v]);return{isQuickCreateOpen:r,setIsQuickCreateOpen:a,quickCreateAnchorRef:o,isMobileDrawerOpen:l,setIsMobileDrawerOpen:i,mobileDraftEvent:c,setMobileDraftEvent:u,handleAddButtonClick:f,isCreateCalendarOpen:h,setIsCreateCalendarOpen:m}}(e,w,C.enabled),[T,N]=s(()=>e.getTheme());c(()=>e.subscribeThemeChange(e=>N(e)),[e]);const S=g(t=>e.setTheme(t),[e]);c(()=>{const t=e.callbacks,n=t.onDismissUI;return t.onDismissUI=()=>{E.detailPanelEventId&&E.setDetailPanelEventId(null),k.isMobileDrawerOpen&&k.setIsMobileDrawerOpen(!1),null==n||n()},()=>{t.onDismissUI=n}},[e,E,k]),c(()=>{if(!w||!E.detailPanelEventId)return;const t=E.detailPanelEventId.split("::")[0],n=e.getEvents().find(e=>e.id===t);n&&(k.setMobileDraftEvent(n),k.setIsMobileDrawerOpen(!0)),E.setDetailPanelEventId(null)},[E.detailPanelEventId,w]);const M=g(t=>{e.setCurrentDate(t),e.selectEvent(null)},[e]),I=g(t=>e.selectEvent(t),[e]),H=d(null),R={app:e,config:e.getCurrentView().config||{},customDetailPanelContent:t,customEventDetailDialog:x,switcherMode:e.state.switcherMode,calendarRef:H,meta:r,selectedEventId:b,onEventSelect:I,onDateChange:M,detailPanelEventId:E.detailPanelEventId,onDetailPanelToggle:E.setDetailPanelEventId},O=h(()=>({isCollapsed:C.isCollapsed,toggleCollapsed:C.toggleCollapsed}),[C.isCollapsed,C.toggleCollapsed]),P=null!=m?"0px":C.miniWidth,L=null!=m&&C.isCollapsed?m:C.safeAreaLeft,A=e.getCalendarHeaderConfig(),$=Object.assign({calendar:e,switcherMode:e.state.switcherMode,onAddCalendar:k.handleAddButtonClick,onSearchChange:D.setSearchKeyword,onSearchClick:D.handleSearchClick,searchValue:D.searchKeyword,isSearchOpen:D.isSearchOpen,isEditable:!e.state.readOnly},L>0?{safeAreaLeft:L}:{}),j=e.getCurrentView().component,Y=e.getCustomMobileEventRenderer()||Vr;return Ge(Fr,{initialTheme:T,onThemeChange:S,children:Ge(Jr,{locale:e.state.locale,messages:o,children:Ge("div",{className:"df-calendar-container relative flex flex-row overflow-hidden select-none",children:[Ge(Ir,{store:f,generatorName:"titleBarSlot",generatorArgs:O,defaultContent:i&&("function"==typeof i?i(O):i)}),C.enabled&&Ge("aside",{className:"absolute top-0 bottom-0 left-0 z-0 h-full",style:{width:C.width},children:C.content}),Ge("div",{className:"flex flex-col flex-1 h-full overflow-hidden relative z-10 bg-white dark:bg-gray-900 transition-all duration-250 ease-in-out border-l "+(C.isCollapsed?"border-gray-200 dark:border-gray-700 shadow-xl":"border-transparent"),style:{marginLeft:C.enabled?C.isCollapsed?P:C.width:0},children:[!1===A?null:"function"==typeof A?A($):a(Hr,$),Ge("div",{className:"flex-1 overflow-hidden relative",ref:H,children:[Ge("div",{className:"calendar-renderer h-full relative flex flex-row",children:[Ge("div",{className:"flex-1 h-full overflow-hidden",children:Ge(j,Object.assign({},R))}),Ge(Pr,{isOpen:D.isSearchOpen,onClose:D.handleSearchClose,loading:D.searchLoading,results:D.searchResults,keyword:D.searchKeyword,onResultClick:D.handleSearchResultClick,emptyText:null==l?void 0:l.emptyText})]}),Ge(Lr,{isOpen:D.isMobileSearchOpen,onClose:D.handleMobileSearchClose,keyword:D.searchKeyword,onSearchChange:D.setSearchKeyword,results:D.searchResults,loading:D.searchLoading,onResultClick:D.handleSearchResultClick,emptyText:null==l?void 0:l.emptyText})]})]}),Ge(Ar,{app:e,anchorRef:k.quickCreateAnchorRef,isOpen:k.isQuickCreateOpen,onClose:()=>k.setIsQuickCreateOpen(!1)}),Ge(Y,{isOpen:k.isMobileDrawerOpen,onClose:()=>{k.setIsMobileDrawerOpen(!1),k.setMobileDraftEvent(null)},onSave:t=>{e.getEvents().some(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),k.setIsMobileDrawerOpen(!1),k.setMobileDraftEvent(null)},onEventDelete:t=>{e.deleteEvent(t),k.setIsMobileDrawerOpen(!1),k.setMobileDraftEvent(null)},draftEvent:k.mobileDraftEvent,app:e}),C.extraContent,k.isCreateCalendarOpen&&Ge(Zr,{onClose:()=>k.setIsCreateCalendarOpen(!1),onCreate:t=>{e.createCalendar(t),k.setIsCreateCalendarOpen(!1)}}),(()=>{if(!E.dialogProps)return null;const e=x,t="undefined"!=typeof document?document.body:null;if(!t)return null;const n=null==f?void 0:f.isOverridden("eventDetailDialog");return Ge(Ir,{store:f,generatorName:"eventDetailDialog",generatorArgs:E.dialogProps,defaultContent:n?null:v(a(e,E.dialogProps),t)})})()]})})})};class ea{constructor(e,t){this.app=e,this.container=null,this.unsubscribe=null,this.renderRequested=!1,this.extraProps={},this.customRenderingStore=new Be(t),this.unsubscribe=e.subscribe(()=>this.requestRender())}setProps(e){We(this.extraProps,e)||(this.extraProps=e,this.requestRender())}requestRender(){this.renderRequested||(this.renderRequested=!0,requestAnimationFrame(()=>{this.render(),this.renderRequested=!1}))}mount(e){this.container=e,this.requestRender()}unmount(){this.container&&(o(null,this.container),this.container=null),this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null)}getCustomRenderingStore(){return this.customRenderingStore}render(){this.container&&o(a(Ve.Provider,{value:this.customRenderingStore},a(Qr,Object.assign({app:this.app},this.extraProps))),this.container)}}const ta=({originalComponent:e,app:t,config:n,customDetailPanelContent:r,customEventDetailDialog:a,calendarRef:o,switcherMode:l,meta:i,selectedEventId:s,detailPanelEventId:d,onEventSelect:c,onDateChange:u,onDetailPanelToggle:m})=>{const v=t.getPlugin("events"),f=n.enableDrag?t.getPlugin("drag"):void 0,p=t.getCurrentDate(),y=t.state.currentView,w=t.getEvents(),D=g(e=>{v?v.update(e.id,e):t.updateEvent(e.id,e)},[v,t]),x=g(e=>{v?v.delete(e):t.deleteEvent(e)},[v,t]),E=g(e=>{v?v.add(e):t.addEvent(e)},[v,t]),C=g(e=>{u?u(e):t.setCurrentDate(e)},[t,u]),T=g(e=>{t.changeView(e)},[t]),N=h(()=>{const{dragConfig:e,eventsConfig:t,virtualScrollConfig:r}=n,a=b(n,["dragConfig","eventsConfig","virtualScrollConfig"]),o=Object.assign({},a);return f&&Object.assign(o,e||{}),v&&Object.assign(o,t||{}),o},[n,f,v]),S=h(()=>({app:t,currentDate:p,currentView:y,events:w,onEventUpdate:D,onEventDelete:x,onEventCreate:E,onDateChange:C,onViewChange:T,config:N,customDetailPanelContent:r,customEventDetailDialog:a,calendarRef:o,switcherMode:l,meta:i,selectedEventId:s,detailPanelEventId:d,onEventSelect:c,onDetailPanelToggle:m}),[t,p,y,w,D,x,E,C,T,N,r,a,o,l,i,s,d,c,m]),M=h(()=>{const e={currentDate:p,events:w,setEvents:e=>{w.forEach(e=>x(e.id)),e.forEach(e=>E(e))},updateEvent:D,deleteEvent:x,addEvent:E,goToPrevious:()=>{const e=new Date(p);switch(y){case k.DAY:e.setDate(e.getDate()-1);break;case k.WEEK:e.setDate(e.getDate()-7);break;case k.MONTH:e.setMonth(e.getMonth()-1)}C(e)},goToNext:()=>{const e=new Date(p);switch(y){case k.DAY:e.setDate(e.getDate()+1);break;case k.WEEK:e.setDate(e.getDate()+7);break;case k.MONTH:e.setMonth(e.getMonth()+1)}C(e)},goToToday:()=>{C(new Date)},changeView:T,selectDate:C};return Object.assign(Object.assign({calendar:e},S),{eventsService:v,dragService:f})},[p,w,y,D,x,E,C,T,S,v,f]);return Ge(e,Object.assign({},M))},na={PARALLEL_THRESHOLD:.25,NESTED_THRESHOLD:.5,INDENT_STEP_PERCENT:2.5,MIN_WIDTH:25,MARGIN_BETWEEN:1,EDGE_MARGIN_PERCENT:.9};function ra(e){return Object.assign(Object.assign({},e),{parentId:void 0,children:[],_startHour:e.allDay?0:ne(e.start),_endHour:e.allDay?0:fe(e)})}function aa(e){var t;return null!==(t=e._startHour)&&void 0!==t?t:ne(e.start)}function oa(e){var t;return null!==(t=e._endHour)&&void 0!==t?t:fe(e)}function la(e,t){return e.day===t.day&&!e.allDay&&!t.allDay&&(aa(e)<oa(t)&&aa(t)<oa(e))}function ia(e,t){const n=oa(e)-aa(e);if(n<1.25)return!1;const r=aa(e)+.4*n,a=aa(t)>=r,o=la(e,t);return a&&o}function sa(e,t,n=na){if(!la(e,t))return!1;const r=Math.abs(aa(e)-aa(t));return r<=n.PARALLEL_THRESHOLD||(r>n.PARALLEL_THRESHOLD&&r<n.NESTED_THRESHOLD||function(e,t){return!(!la(e,t)||!ia(e,t)&&!ia(t,e))}(e,t))}function da(e,t){const n=aa(e)<=aa(t)&&oa(e)>=oa(t),r=aa(e)<=aa(t)&&aa(t)<oa(e)&&la(e,t);return n||r}function ca(e){const t=[],n=new Set;for(const r of e){if(n.has(r.id))continue;const a=[r];n.add(r.id);for(const t of e){if(n.has(t.id))continue;Math.abs(aa(r)-aa(t))<=na.PARALLEL_THRESHOLD&&(a.push(t),n.add(t.id))}a.sort((e,t)=>aa(e)-aa(t));const o={events:a,startHour:Math.min(...a.map(e=>aa(e))),endHour:Math.max(...a.map(e=>oa(e)))};t.push(o)}return t.sort((e,t)=>e.startHour-t.startHour),t}function ua(e,t){var n,r;const a=null===(r=null===(n=e[0])||void 0===n?void 0:n.parent)||void 0===r?void 0:r.depth;return void 0===a?[]:t.filter(e=>e.depth===a).map(e=>({node:e,load:ha(e)})).sort((e,t)=>t.load-e.load)}function ha(e){let t=0;for(const n of e.children)t+=1+ha(n);return t}function ga(e){return!(e.length<2)&&e[0].load-e[e.length-1].load>=2}function ma(e){let t=0;for(;t<5;){e.sort((e,t)=>t.load-e.load);const n=e[0],r=e[e.length-1];if(n.load-r.load<2)break;const a=va(n.node,r.node);if(!a)break;pa(a,r.node),n.load--,r.load++,t++}}function va(e,t){const n=[];return fa(e,n),n.find(e=>da(t.event,e.event))||n[0]||null}function fa(e,t){0===e.children.length?t.push(e):e.children.forEach(e=>fa(e,t))}function pa(e,t){e.parent&&(e.parent.children=e.parent.children.filter(t=>t!==e));const n=t.children.find(t=>da(t.event,e.event));n?(e.parent=n,e.depth=n.depth+1,n.children.push(e),ya(n.event,e.event)):(e.parent=t,e.depth=t.depth+1,t.children.push(e),ya(t.event,e.event))}function ya(e,t){t.parentId=e.id,e.children.includes(t.id)||e.children.push(t.id)}function ba(e,t){const n=[],r=new Map,a=new Map;t.forEach(e=>a.set(e.id,e));for(const t of e)for(const e of t.events){const t={event:a.get(e.id),children:[],parent:null,depth:0,isProcessed:!1};n.push(t),r.set(e.id,t)}for(let n=0;n<e.length;n++){const o=e[n],l=o.events.map(e=>a.get(e.id));let i=!1;for(let s=n-1;s>=0&&!i;s--){const n=e[s],d={events:n.events.map(e=>a.get(e.id)),startHour:n.startHour,endHour:n.endHour};if(wa(d,{events:l,startHour:o.startHour,endHour:o.endHour})){const e=Da(l,d,t);for(const t of e){const e=r.get(t.child.id),n=r.get(t.parent.id);e.parent=n,e.depth=n.depth+1,n.children.push(e)}i=!0}}}const o=n.filter(e=>null===e.parent);return o.forEach(e=>{e.depth=0}),function(e,t){for(let n=e.length-1;n>=1;n--){const r=ua(e[n].events.map(e=>t.find(t=>t.event.id===e.id)),t);ga(r)&&ma(r)}}(e,n),o}function wa(e,t){const n=t.startHour-e.startHour;if(function(e,t){for(const n of e.events)for(const e of t.events){if(!la(n,e))continue;if(Math.abs(aa(e)-aa(n))<na.NESTED_THRESHOLD)return!0}return!1}(e,t))return!1;if(n<na.NESTED_THRESHOLD)return!1;for(const n of e.events)for(const e of t.events)if(da(n,e))return!0;return!1}function Da(e,t,n){const r=[],a=(e,t)=>{t.parentId=e.id,e.children.includes(t.id)||e.children.push(t.id)};if(1===e.length){const o=Ea(e[0],t,n);return o&&(r.push({child:e[0],parent:o}),a(o,e[0])),r}const o=t.events.filter(t=>e.every(e=>da(t,e)));if(0===o.length){for(const o of e){const e=Ea(o,t,n);e&&(r.push({child:o,parent:e}),a(e,o))}return r}const l=[...e].sort((e,t)=>oa(t)-aa(t)-(oa(e)-aa(e)));if(l.length%o.length===0){const e=l.length/o.length;for(let t=0;t<o.length;t++){const n=o[t],i=l.slice(t*e,(t+1)*e);for(const e of i)r.push({child:e,parent:n}),a(n,e)}}else for(const e of l){const t=xa(e,o,l);t&&(r.push({child:e,parent:t}),a(t,e))}return r}function xa(e,t,n){if(0===t.length)return null;let r=1/0,a=[];for(const e of t){const t=e.children.length;t<r?(r=t,a=[e]):t===r&&a.push(e)}const o=oa(e)-aa(e),l=a.map(e=>e.children).flat();return o>Math.max(...l.map(e=>{const t=n.find(t=>t.id===e);return t?oa(t)-aa(t):0}),0)?a[0]:a[a.length-1]}function Ea(e,t,n){const r=t.events.filter(t=>da(t,e));if(0===r.length)return null;if(1===r.length)return r[0];const a=r.map(t=>({parent:t,load:t.children.length,hasParallelSibling:t.children.some(t=>{const r=n.find(e=>e.id===t);return r&&sa(e,r,na)})}));return a.sort((t,n)=>t.load!==n.load?t.load-n.load:t.hasParallelSibling!==n.hasParallelSibling?t.hasParallelSibling?-1:1:Math.abs(aa(e)-aa(t.parent))-Math.abs(aa(e)-aa(n.parent))),a[0].parent}function Ca(e,t,n={}){const r=100-("day"===n.viewType?0:na.EDGE_MARGIN_PERCENT);if(1===e.length)Ta(e[0],0,r,t,n);else if(e.length>1){const a=e.length,o=(r-na.MARGIN_BETWEEN*(a-1))/a;e.forEach((e,r)=>{Ta(e,r*(o+na.MARGIN_BETWEEN),Math.max(o,na.MIN_WIDTH),t,n)})}}function ka(e){return"day"===e?.5:2.5}function Ta(e,t,n,r,a={}){const o=ka(a.viewType);let l=e.depth*o;if(e.isProcessed){const t=function(e,t){let n=e;for(;n.parent&&n.parent.depth>0;)n=n.parent;return 1===n.depth?n.depth*ka(t):null}(e,a.viewType);null!==t&&(l=t)}const i="day"===a.viewType;let s=0;1===e.depth?s=i?.5:1.5:2===e.depth?s=i?-.01:-1:e.depth>=3&&(s=i?.55:-3.5);const d=t+l+s;let c=n-(l+s);if(d+c>t+n&&(c=t+n-d),r.set(e.event.id,{id:e.event.id,left:d,width:c,zIndex:e.depth,level:e.depth,isPrimary:0===e.depth,indentOffset:l*(a.containerWidth||320)/100,importance:Ma(e.event)}),0===e.children.length)return;const u=[...e.children].sort((e,t)=>oa(t.event)-aa(t.event)-(oa(e.event)-aa(e.event)));1===u.length?Ta(u[0],d,c,r,a):Sa(u.map(e=>e.event))?Na(u,d,c,r,a):u.forEach(e=>Ta(e,d,c,r,a))}function Na(e,t,n,r,a={}){const o=e.length,l=e[0].depth,i=l*ka(a.viewType),s="day"===a.viewType;let d=1===l?s?.5:1.5:2===l?s?-.01:-1:s?.55:-3.5;const c=t+i+d,u=n-(i+d);if(u<=0)return void e.forEach(e=>Ta(e,t,n,r,a));let h=na.MARGIN_BETWEEN*(1===l?s?.15:.3:s?.1:.2);const g=(u-h*(o-1))/o;e.forEach((e,t)=>{const n=c+t*(g+h);if(r.set(e.event.id,{id:e.event.id,left:n,width:g,zIndex:e.depth,level:e.depth,isPrimary:0===e.depth,indentOffset:i*(a.containerWidth||320)/100,importance:Ma(e.event)}),e.children.length>0){const t=[...e.children].sort((e,t)=>oa(t.event)-aa(t.event)-(oa(e.event)-aa(e.event)));1===t.length?Ta(t[0],n,g,r,a):Sa(t.map(e=>e.event))?Na(t,n,g,r,a):t.forEach(e=>Ta(e,n,g,r,a))}})}function Sa(e){if(e.length<2)return!1;for(let t=0;t<e.length;t++)for(let n=t+1;n<e.length;n++)if(sa(e[t],e[n],na))return!0;return!1}function Ma(e){const t=oa(e)-aa(e);return Math.max(.1,Math.min(1,t/4))}class Ia{static calculateDayEventLayouts(e,t={}){const n=e.map(ra);for(const e of n)e.parentId=void 0,e.children=[];const r=new Map,a=n.filter(e=>!e.allDay);if(0===a.length)return r;const o=function(e){const t=[],n=new Set;for(const r of e){if(n.has(r.id))continue;const a=[r],o=[r];for(n.add(r.id);o.length>0;){const t=o.shift();for(const r of e)n.has(r.id)||la(t,r)&&(a.push(r),o.push(r),n.add(r.id))}t.push(a)}return t}(a);for(const e of o)if(1===e.length){const n="day"===t.viewType?0:na.EDGE_MARGIN_PERCENT;r.set(e[0].id,{id:e[0].id,left:0,width:100-n,zIndex:0,level:0,isPrimary:!0,indentOffset:0,importance:Math.max(.1,Math.min(1,(e[0]._endHour-e[0]._startHour)/4))})}else{Ca(ba(ca([...e].sort((e,t)=>e._startHour!==t._startHour?e._startHour-t._startHour:t._endHour-t._startHour-(e._endHour-e._startHour))),e),r,t)}return r}}let Ha=null;function Ra(e){Ha=e}const Oa={handleMoveStart:()=>{},handleCreateStart:()=>{},handleResizeStart:void 0,handleCreateAllDayEvent:()=>{},dragState:{active:!1,mode:null,eventId:null,targetDate:null,startDate:null,endDate:null},isDragging:!1};function Pa(e,t){return Ha?Ha(e,t):Oa}const La={HOUR_HEIGHT:72,FIRST_HOUR:0,LAST_HOUR:24,ALL_DAY_HEIGHT:28};function Aa(t){const{app:n,onEventCreated:r}=t,{t:a}=In(),o=g(e=>{e.dataTransfer.types.includes("application/x-dayflow-calendar")&&(e.preventDefault(),e.dataTransfer.dropEffect="copy")},[]);return{handleDrop:g((t,o,l,i)=>{t.preventDefault();const s=t.dataTransfer.getData("application/x-dayflow-calendar");if(!s)return null;try{const t=JSON.parse(s);let d,c,u=!1;i?(d=e.PlainDateTime.from({year:o.getFullYear(),month:o.getMonth()+1,day:o.getDate(),hour:0,minute:0}),c=e.PlainDateTime.from({year:o.getFullYear(),month:o.getMonth()+1,day:o.getDate(),hour:23,minute:59,second:59}),u=!0):void 0!==l?(d=e.PlainDateTime.from({year:o.getFullYear(),month:o.getMonth()+1,day:o.getDate(),hour:l,minute:0}),c=d.add({hours:1})):(d=e.PlainDateTime.from({year:o.getFullYear(),month:o.getMonth()+1,day:o.getDate(),hour:9,minute:0}),c=d.add({hours:1}));const h={id:`event-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,title:a(u?"newAllDayCalendarEvent":"newCalendarEvent",{calendarName:t.calendarName}),description:"",start:d,end:c,calendarId:t.calendarId,allDay:u};return n.addEvent(h),null==r||r(h),h}catch(e){return console.error("Error creating event from calendar drop:",e),null}},[n,r]),handleDragOver:o}}const $a=({handlePreviousMonth:e,handleToday:t,handleNextMonth:n})=>{const{t:r}=In();return Ge("div",{className:"df-navigation flex items-center gap-1",children:[Ge("button",{className:At,onClick:e,"aria-label":"Previous month",children:Ge(Ke,{className:$t})}),Ge("button",{className:"df-today-button calendar-today-button inline-flex items-center justify-center px-4 h-7 text-sm font-medium rounded-md border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 hover:bg-gray-50 dark:hover:bg-gray-700 hover:border-gray-300 dark:hover:border-gray-500 active:bg-gray-100 dark:active:bg-gray-600 transition-all duration-150 shadow-sm hover:shadow focus:outline-none",onClick:t,children:r("today")}),Ge("button",{className:At,onClick:n,"aria-label":"Next month",children:Ge(Xe,{className:$t})})]})},ja=({app:e,currentDate:t,visibleMonth:n,currentDayEvents:r,selectedEvent:a,setSelectedEvent:o,handleMonthChange:l,handleDateSelect:i,switcherMode:s})=>{const{t:d,locale:c}=In(),u=[...r].sort((e,t)=>e.allDay&&!t.allDay?-1:!e.allDay&&t.allDay?1:0);return Ge("div",{className:"df-right-panel hidden md:block flex-none w-[30%] bg-white dark:bg-gray-900",onContextMenu:e=>e.preventDefault(),children:Ge("div",{className:`${Xt} h-full`,children:[Ge("div",{className:"df-mini-calendar px-2 border-b border-gray-200 dark:border-gray-700",children:Ge("div",{children:[Ge("div",{className:"flex items-center justify-end gap-2",children:[Ge("div",{className:pt,style:{position:"relative"},children:Ge("div",{children:Ge("h1",{className:yt,children:" "})})}),Ge($a,{handlePreviousMonth:()=>e.goToPrevious(),handleNextMonth:()=>e.goToNext(),handleToday:()=>e.goToToday()})]}),Ge(Wr,{visibleMonth:n,currentDate:t,showHeader:!0,onMonthChange:l,onDateSelect:i})]})}),Ge("div",{className:"flex-1 overflow-y-auto",children:Ge("div",{className:"p-4",children:[Ge("h3",{className:"text-lg font-semibold mb-3 sticky top-0 bg-white dark:bg-gray-900 z-10 py-2",children:t.toLocaleDateString(c,{weekday:"long",month:"long",day:"numeric"})}),0===u.length?Ge("p",{className:`${Vt} ${Kt}`,children:d("noEvents")}):Ge("div",{className:"space-y-2",children:u.map(t=>Ge("div",{className:`\n p-2 rounded border-l-4 cursor-pointer transition-colors\n ${(null==a?void 0:a.id)===t.id?"bg-primary/10 border-primary":"bg-gray-50 dark:bg-gray-800 border-gray-300 dark:border-gray-600"}\n hover:bg-gray-100 dark:hover:bg-gray-700\n `,style:{borderLeftColor:ue(t.calendarId||"blue")},onClick:()=>{o(t),e.onEventClick(t)},children:[Ge("div",{className:`font-medium ${Kt}`,children:t.title}),!t.allDay&&Ge("div",{className:`${Gt} ${qt}`,children:[ge(ne(t.start))," -"," ",ge(fe(t))]}),t.allDay&&Ge("div",{className:`${Gt} ${qt}`,children:d("allDay")})]},t.id))})]})})]})})},Ya=({viewType:e,currentDate:t,onPrevious:n,onNext:r,onToday:a,customTitle:o,customSubtitle:l,showTodayBox:i,stickyYear:s,stickyYearOffset:d=0,nextYear:c,nextYearOffset:u=0})=>{const{locale:h}=In(),g=void 0===i||i,m=o||(()=>{switch(e){case"day":return t.toLocaleDateString(h,{day:"numeric",month:"long",year:"numeric"});case"week":case"month":return t.toLocaleDateString(h,{month:"long",year:"numeric"});case"year":return t.getFullYear().toString();default:return""}})(),v="day"===e?l||("day"===e?t.toLocaleDateString(h,{weekday:"long"}):null):null;return Ge("div",{className:pt,style:{position:"relative"},onContextMenu:e=>e.preventDefault(),children:[Ge("div",{className:"flex-1",children:Ge("div","year"===e&&s?{style:{position:"relative",overflow:"hidden",height:"1.5em"},children:[Ge("h1",{className:yt,style:{position:"absolute",top:0,left:0,transform:`translateY(-${d}px)`,willChange:"transform"},children:s}),c&&Ge("h1",{className:yt,style:{position:"absolute",top:0,left:0,transform:`translateY(${u}px)`,willChange:"transform"},children:c})]}:{children:[Ge("div",{className:`${yt} text-gray-900 dark:text-white`,children:m}),v&&Ge("div",{className:"mt-3 text-gray-600 dark:text-gray-400",children:v})]})}),g&&n&&r&&a&&Ge("div",{className:"flex items-center gap-2",children:Ge($a,{handlePreviousMonth:n,handleNextMonth:r,handleToday:a})})]})},Fa=e=>{if(!1===e.icon)return null;if(void 0!==e.icon&&"boolean"!=typeof e.icon)return e.icon;const t=e.title.toLowerCase();return t.includes("holiday")||t.includes("vacation")||t.includes("假期")?Ge(dt,{className:"h-3 w-3"}):t.includes("birthday")||t.includes("anniversary")||t.includes("生日")?Ge(ct,{className:"h-3 w-3"}):t.includes("conference")||t.includes("meeting")||t.includes("会议")||t.includes("研讨")?Ge(ht,{className:"h-3 w-3"}):t.includes("trip")||t.includes("travel")||t.includes("旅行")?Ge(ut,{className:"h-3 w-3"}):Ge(lt,{className:"h-3 w-3"})},za=(e,t)=>{const n=[],r=new Date(t);return r.setDate(t.getDate()+6),r.setHours(23,59,59,999),e.forEach(e=>{const a=U(e.start),o=U(e.end),l=new Date(a);l.setHours(0,0,0,0);const i=new Date(o);i.setHours(0,0,0,0);let s=new Date(i);if(!e.allDay){if(!(0!==o.getHours()||0!==o.getMinutes()||0!==o.getSeconds())){const e=o.getTime()-a.getTime();e>0&&e<864e5&&(s=new Date(i),s.setDate(s.getDate()-1))}}const d=J(l,s)>0;if(!d&&e.allDay){if(l<t||l>r)return;const a=Math.floor((l.getTime()-t.getTime())/864e5);return void(a>=0&&a<=6&&n.push({id:`${e.id}-week-${t.getTime()}`,originalEventId:e.id,event:e,startDayIndex:a,endDayIndex:a,segmentType:"single",totalDays:1,segmentIndex:0,isFirstSegment:!0,isLastSegment:!0}))}if(!d)return;const c=l;let u;if(e.allDay)u=new Date(i),u.setHours(23,59,59,999);else{0!==o.getHours()||0!==o.getMinutes()||0!==o.getSeconds()?(u=new Date(i),u.setHours(23,59,59,999)):(u=new Date(i),u.setTime(u.getTime()-1))}if(u<t||c>r)return;const h=c<t?t:c,g=u>r?r:u,m=Math.max(0,Math.floor((h.getTime()-t.getTime())/864e5)),v=Math.min(6,Math.floor((g.getTime()-t.getTime())/864e5)),f=c>=t,p=u<=r,y=0===m||6===v;let b;b=f&&p?"single":f?y&&6===v?"start-week-end":"start":p?y&&0===m?"end-week-start":"end":"middle";const w=J(c,u)+1;n.push({id:`${e.id}-week-${t.getTime()}`,originalEventId:e.id,event:e,startDayIndex:m,endDayIndex:v,segmentType:b,totalDays:w,segmentIndex:0,isFirstSegment:f,isLastSegment:p})}),n},_a=(e,t)=>{if(e.allDay)return[];const n=U(e.start),r=U(e.end),a=new Date(n);a.setHours(0,0,0,0);const o=new Date(r);o.setHours(0,0,0,0);const l=J(a,o);if(0===l)return[];const i=0!==r.getHours()||0!==r.getMinutes()||0!==r.getSeconds()||0!==r.getMilliseconds(),s=r.getTime()-n.getTime();if(!e.allDay&&1===l&&!i&&s<864e5)return[];const d=i?l:Math.max(0,l-1),c=[];for(let e=0;e<=d;e++){const o=new Date(a);o.setDate(a.getDate()+e);const l=Math.floor((o.getTime()-t.getTime())/864e5);if(l<0||l>6)continue;const s=0===e,u=e===d,h=s?n.getHours()+n.getMinutes()/60:0,g=u&&i?r.getHours()+r.getMinutes()/60:24;c.push({dayIndex:l,startHour:h,endHour:g,isFirst:s,isLast:u})}return c},Za=f(({segment:e,segmentIndex:t,isDragging:n,isResizing:a=!1,isSelected:o=!1,onMoveStart:l,onResizeStart:i,onEventLongPress:c,isMobile:u=!1,isDraggable:h=!0,isEditable:g=!0,viewable:m=!0,isPopping:v})=>{const[f,p]=s(!1),y=17*t,b=`calc(${e.startDayIndex/7*100}% + 2px)`,w=`calc(${(e.endDayIndex-e.startDayIndex+1)/7*100}% - 4px)`,D=d(null),x=d(null),E=t=>{const n="left"===t;return(n?e.isFirstSegment:e.isLastSegment)&&i&&g?Ge("div",{className:`resize-handle absolute ${n?"left-0":"right-0"} top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20`,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),i(t,e.event,n?"left":"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}):null},C=e.event.calendarId||"blue",k=e.endDayIndex-e.startDayIndex+1;return Ge("div",{className:"absolute px-1 text-xs select-none flex items-center transition-all duration-200 hover:shadow-sm dark:hover:shadow-lg dark:hover:shadow-black/20 group",style:Object.assign(Object.assign({left:b,width:w,top:`${y}px`,height:"16px",borderRadius:(T=e.segmentType,{single:"0.25rem",start:"0.25rem 0 0 0.25rem","start-week-end":"0.25rem 0 0 0.25rem",end:"0 0.25rem 0.25rem 0","end-week-start":"0 0.25rem 0.25rem 0",middle:"0"}[T]),pointerEvents:"auto",zIndex:10,transform:v?"scale(1.02)":"scale(1)",transition:"transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)",willChange:"transform"},o||n||f?{backgroundColor:ce(C),color:"#fff"}:{backgroundColor:se(C),color:de(C)}),{cursor:h||m?"pointer":"default"}),"data-segment-days":k,onMouseDown:t=>{if(!h&&!m)return;t.preventDefault(),t.stopPropagation(),p(!0);!t.target.closest(".resize-handle")&&h&&l(t,e.event)},onMouseUp:()=>{p(!1)},onMouseLeave:()=>{p(!1)},onTouchStart:t=>{if(!l||!u||!h&&!m)return;t.stopPropagation(),p(!0);const n=t.touches[0],r=n.clientX,a=n.clientY,o=t.currentTarget;x.current={x:r,y:a},D.current=setTimeout(()=>{c&&c(e.event.id);h&&l({preventDefault:()=>{},stopPropagation:()=>{},currentTarget:o,touches:[{clientX:r,clientY:a}],cancelable:!1},e.event),D.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},onTouchMove:e=>{if(D.current&&x.current){const t=Math.abs(e.touches[0].clientX-x.current.x),n=Math.abs(e.touches[0].clientY-x.current.y);(t>10||n>10)&&(clearTimeout(D.current),D.current=null,x.current=null,p(!1))}},onTouchEnd:()=>{p(!1),D.current&&(clearTimeout(D.current),D.current=null),x.current=null},title:`${e.event.title} (${_n(e.event.start)} - ${_n(e.event.end)})`,children:[u&&o&&g&&Ge(r,{children:[e.isFirstSegment&&Ge("div",{className:"absolute left-5 top-1/2 -translate-y-1/2 w-2.5 h-2.5 bg-white border-2 rounded-full z-50 pointer-events-none",style:{borderColor:ue(C)}}),e.isLastSegment&&Ge("div",{className:"absolute right-5 top-1/2 -translate-y-1/2 w-2.5 h-2.5 bg-white border-2 rounded-full z-50 pointer-events-none",style:{borderColor:ue(C)}})]}),E("left"),Ge("div",{className:"flex-1 min-w-0",style:{cursor:a?"ew-resize":"pointer"},children:(()=>{const t=e.event.allDay,n=e.event.calendarId||"blue",r=ne(e.event.start),a=fe(e.event),o=ge(r),l=ge(a);if(t){const t=()=>e.isFirstSegment?e.event.title:"middle"===e.segmentType||e.isLastSegment&&e.totalDays>1?"···":e.event.title;return Ge("div",{className:"flex items-center min-w-0 w-full pointer-events-auto",children:[e.isFirstSegment&&Fa(e.event)&&Ge("div",{className:"shrink-0 mr-1",children:Ge("div",{className:"rounded-full p-0.5 text-white flex items-center justify-center",style:{backgroundColor:ue(n),width:"12px",height:"12px"},children:Fa(e.event)})}),Ge("div",{className:"flex-1 min-w-0",children:Ge("div",{className:"truncate text-xs",children:t()})}),e.isLastSegment&&"single"!==e.segmentType&&Ge("div",{className:"shrink-0 ml-1 text-white/80 dark:text-white/90",children:Ge("div",{className:"w-1.5 h-1.5 rounded-full bg-white/60 dark:bg-white/80"})})]})}const i=e.isFirstSegment||e.isLastSegment?e.event.title:"···",s=e.endDayIndex-e.startDayIndex+1,d=s>1?{position:"absolute",right:`calc(${s>1?(s-1)/s*100:0}% + 2px)`,top:"50%",transform:"translateY(-50%)"}:void 0;return Ge("div",{className:"relative flex items-center min-w-0 w-full pointer-events-auto",children:[Ge("div",{className:Rt,style:{backgroundColor:ue(n)}}),Ge("div",{className:"flex items-center min-w-0 flex-1",children:Ge("span",{className:`whitespace-nowrap overflow-hidden block ${u?"mobile-mask-fade":"truncate"} font-medium text-xs`,children:i})}),e.isFirstSegment&&!u&&Ge("span",{className:"text-xs font-medium whitespace-nowrap "+(1===s?"ml-2":""),style:d,children:o}),e.isLastSegment&&!e.event.allDay&&24!==a&&!u&&Ge("span",{className:"text-xs font-medium whitespace-nowrap ml-auto",children:`ends ${l}`})]})})()}),E("right")]});var T});Za.displayName="MultiDayEvent";const Wa=({event:t,position:n,panelRef:r,isAllDay:a,eventVisibility:o,calendarRef:l,selectedEventElementRef:i,onEventUpdate:d,onEventDelete:u,app:g})=>{var m;const{effectiveTheme:f}=zr(),p=Xn(f),{t:y}=In(),[b,w]=s(t.title),[D,x]=s(null!==(m=t.description)&&void 0!==m?m:"");c(()=>{w(t.title)},[t.title]),c(()=>{var e;x(null!==(e=t.description)&&void 0!==e?e:"")},[t.description]),c(()=>{const e=setTimeout(()=>{b!==t.title&&d(Object.assign(Object.assign({},t),{title:b}))},500);return()=>clearTimeout(e)},[b,t]),c(()=>{const e=setTimeout(()=>{var e;const n=null!==(e=t.description)&&void 0!==e?e:"";D!==n&&d(Object.assign(Object.assign({},t),{description:D}))},500);return()=>clearTimeout(e)},[D,t]);const E="dark"===p||"undefined"!=typeof document&&document.documentElement.classList.contains("dark"),C=!(null==g?void 0:g.state.readOnly);if(!(!1!==(null==g?void 0:g.getReadOnlyConfig().viewable)))return null;const k=E?"#1f2937":"white",T=E?"rgb(55, 65, 81)":"rgb(229, 231, 235)",N=h(()=>(g?g.getCalendarRegistry():R()).getVisible().map(e=>({label:e.name,value:e.id})),[g,null==g?void 0:g.getCalendars()]),S=h(()=>z(t.start)?t.end&&!z(t.end)&&(t.end.timeZoneId||t.end.timeZoneId)||e.Now.timeZoneId():t.start.timeZoneId||t.start.timeZoneId||e.Now.timeZoneId(),[t.end,t.start]),M=(()=>{var e;let t={};if("sticky-top"===o){const r=null===(e=l.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(r){const e=r.getBoundingClientRect().top+3-n.top;t=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:k,transform:"rotate(45deg)",transformOrigin:"center",top:e-6+"px",borderRight:""+(n.isSunday?`1px solid ${T}`:"none"),borderTop:""+(n.isSunday?`1px solid ${T}`:"none"),borderLeft:""+(n.isSunday?"none":`1px solid ${T}`),borderBottom:""+(n.isSunday?"none":`1px solid ${T}`)},n.isSunday?{right:"-6px"}:{left:"-6px"})}}else if("sticky-bottom"===o){const e=r.current;let a=200;if(e){const t=e.getBoundingClientRect(),n=window.getComputedStyle(e),r=parseInt(n.paddingBottom,10)||0,o=parseInt(n.borderBottomWidth,10)||0;a=t.height-r-o-6+11}t={position:"absolute",width:"12px",height:"12px",backgroundColor:k,transform:"rotate(45deg)",transformOrigin:"center",top:`${a}px`,left:n.isSunday?void 0:"-6px",right:n.isSunday?"-6px":void 0,borderRight:""+(n.isSunday?`1px solid ${T}`:"none"),borderTop:""+(n.isSunday?`1px solid ${T}`:"none"),borderLeft:""+(n.isSunday?"none":`1px solid ${T}`),borderBottom:""+(n.isSunday?"none":`1px solid ${T}`)}}else if(n&&i.current&&l.current){const e=i.current.getBoundingClientRect(),a=l.current.querySelector(".calendar-content");if(a){const o=a.getBoundingClientRect(),l=Math.max(e.top,o.top),i=Math.min(e.bottom,o.bottom),s=Math.max(0,i-l);let d;d=s===e.height?e.top+e.height/2:s>0?l+s/2:e.top+e.height/2;const c=d-n.top,u=r.current;let h=228;if(u){const e=u.getBoundingClientRect(),t=window.getComputedStyle(u),n=parseInt(t.paddingBottom,10)||0,r=parseInt(t.borderBottomWidth,10)||0;h=e.height-n-r+11}const g=12,m=Math.max(g,Math.min(h,c));t=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:k,transform:"rotate(45deg)",transformOrigin:"center",top:m-6+"px",borderRight:""+(n.isSunday?`1px solid ${T}`:"none"),borderTop:""+(n.isSunday?`1px solid ${T}`:"none"),borderLeft:""+(n.isSunday?"none":`1px solid ${T}`),borderBottom:""+(n.isSunday?"none":`1px solid ${T}`)},n.isSunday?{right:"-6px"}:{left:"-6px"})}}return t})(),I=Ge("div",{ref:r,className:`${jt} p-4`,"data-event-detail-panel":"true","data-event-id":t.id,style:{top:`${n.top}px`,left:`${n.left}px`,zIndex:9999,pointerEvents:"auto"},children:[Ge("div",{style:M}),Ge("span",{className:"block text-xs text-gray-600 dark:text-gray-300 mb-1",children:y("eventTitle")}),Ge("div",{className:"flex items-center justify-between gap-3 mb-3",children:[Ge("div",{className:"flex-1",children:Ge("input",{id:`event-title-${t.id}`,name:"title",type:"text",value:b,readOnly:!C,disabled:!C,onChange:e=>w(e.target.value),onInput:e=>w(e.target.value),className:"w-full border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-1.5 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary transition"})}),C&&Ge(en,{options:N,value:t.calendarId||"blue",onChange:e=>{d(Object.assign(Object.assign({},t),{calendarId:e}))},registry:null==g?void 0:g.getCalendarRegistry()})]}),Ge("div",a?{className:"mb-3",children:[Ge("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-1",children:y("dateRange")}),Ge(Yn,{value:[t.start,t.end],format:"YYYY-MM-DD",showTime:!1,timeZone:S,matchTriggerWidth:!0,disabled:!C,onChange:e=>{const[n,r]=e;d(Object.assign(Object.assign({},t),{start:n.toPlainDate(),end:r.toPlainDate()}))},locale:null==g?void 0:g.state.locale})]}:{className:"mb-3",children:[Ge("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-1",children:y("timeRange")}),Ge(Yn,{value:[t.start,t.end],timeZone:S,disabled:!C,onChange:e=>{const[n,r]=e;d(Object.assign(Object.assign({},t),{start:n,end:r}))},locale:null==g?void 0:g.state.locale})]}),Ge("div",{className:"mb-3",children:[Ge("span",{className:"block text-xs text-gray-600 dark:text-gray-300 mb-1",children:y("note")}),Ge("textarea",{id:`event-note-${t.id}`,name:"note",value:D,readOnly:!C,disabled:!C,onChange:e=>x(e.target.value),onInput:e=>x(e.target.value),rows:3,className:"w-full border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary transition resize-none",placeholder:y("addNotePlaceholder")})]}),C&&Ge("div",{className:"flex space-x-2",children:[Ge("button",a?{className:"px-2 py-1 bg-primary text-primary-foreground rounded hover:bg-primary text-xs font-medium transition",onClick:()=>{const n=z(t.start)?t.start:t.start.toPlainDate(),r=e.ZonedDateTime.from({year:n.year,month:n.month,day:n.day,hour:9,minute:0,timeZone:e.Now.timeZoneId()}),a=e.ZonedDateTime.from({year:n.year,month:n.month,day:n.day,hour:10,minute:0,timeZone:e.Now.timeZoneId()});d(Object.assign(Object.assign({},t),{allDay:!1,start:r,end:a}))},children:y("setAsTimed")}:{className:"px-2 py-1 bg-primary text-primary-foreground rounded hover:bg-primary text-xs font-medium transition",onClick:()=>{const e=z(t.start)?t.start:t.start.toPlainDate();d(Object.assign(Object.assign({},t),{allDay:!0,start:e,end:e}))},children:y("setAsAllDay")}),Ge("button",{className:"px-2 py-1 bg-destructive text-destructive-foreground rounded hover:bg-destructive/90 text-xs font-medium transition",onClick:()=>u(t.id),children:y("delete")})]})]});if("undefined"==typeof window||"undefined"==typeof document)return null;const H=document.body;return H?v(I,H):null},Ua=({event:e,position:t,panelRef:n,isAllDay:r,eventVisibility:a,calendarRef:o,selectedEventElementRef:l,onEventUpdate:i,onEventDelete:s,onClose:d,contentRenderer:c})=>{const{effectiveTheme:u}=zr(),h=Xn(u),g="dark"===h?"#1f2937":"white",m="dark"===h?"rgb(55, 65, 81)":"rgb(229, 231, 235)",f=(()=>{var e;let r={};if("sticky-top"===a){const n=null===(e=o.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(n){const e=n.getBoundingClientRect().top+3-t.top;r=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:g,transform:"rotate(45deg)",transformOrigin:"center",top:e-6+"px",borderRight:""+(t.isSunday?`1px solid ${m}`:"none"),borderTop:""+(t.isSunday?`1px solid ${m}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${m}`),borderBottom:""+(t.isSunday?"none":`1px solid ${m}`)},t.isSunday?{right:"-6px"}:{left:"-6px"})}}else if("sticky-bottom"===a){const e=n.current;let a=200;if(e){const t=e.getBoundingClientRect(),n=window.getComputedStyle(e),r=parseInt(n.paddingBottom,10)||0,o=parseInt(n.borderBottomWidth,10)||0;a=t.height-r-o-6+11}r={position:"absolute",width:"12px",height:"12px",backgroundColor:g,transform:"rotate(45deg)",transformOrigin:"center",top:`${a}px`,left:t.isSunday?void 0:"-6px",right:t.isSunday?"-6px":void 0,borderRight:""+(t.isSunday?`1px solid ${m}`:"none"),borderTop:""+(t.isSunday?`1px solid ${m}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${m}`),borderBottom:""+(t.isSunday?"none":`1px solid ${m}`)}}else if(t&&l.current&&o.current){const e=l.current.getBoundingClientRect(),a=o.current.querySelector(".calendar-content");if(a){const o=a.getBoundingClientRect(),l=Math.max(e.top,o.top),i=Math.min(e.bottom,o.bottom),s=Math.max(0,i-l);let d;d=s===e.height?e.top+e.height/2:s>0?l+s/2:e.top+e.height/2;const c=d-t.top,u=n.current;let h=228;if(u){const e=u.getBoundingClientRect(),t=window.getComputedStyle(u),n=parseInt(t.paddingBottom,10)||0,r=parseInt(t.borderBottomWidth,10)||0;h=e.height-n-r+11}const v=12,f=Math.max(v,Math.min(h,c));r=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:g,transform:"rotate(45deg)",transformOrigin:"center",top:f-6+"px",borderRight:""+(t.isSunday?`1px solid ${m}`:"none"),borderTop:""+(t.isSunday?`1px solid ${m}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${m}`),borderBottom:""+(t.isSunday?"none":`1px solid ${m}`)},t.isSunday?{right:"-6px"}:{left:"-6px"})}}return r})(),p=Ge("div",{ref:n,className:`${jt} p-3`,"data-event-detail-panel":"true","data-event-id":e.id,style:{top:`${t.top}px`,left:`${t.left}px`,zIndex:9999,pointerEvents:"auto",backgroundColor:"dark"===h?"#1f2937":"#ffffff"},children:[Ge("div",{style:f}),Ge(c,{event:e,isAllDay:r,onEventUpdate:i,onEventDelete:s,onClose:d})]});return v(p,document.body)},Ba=({event:e,app:t,isEventSelected:n,hideTime:r,isMobile:a})=>{const o=`${Math.floor(ne(e.start)).toString().padStart(2,"0")}:${Math.round(ne(e.start)%1*60).toString().padStart(2,"0")}`;return Ge("div",{className:"text-xs cursor-pointer flex items-center justify-between",children:[Ge("div",{className:"flex items-center flex-1 min-w-0",children:[Ge("div",{style:{backgroundColor:ue(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())},className:Rt}),Ge("span",{className:`whitespace-nowrap overflow-hidden block ${a?"mobile-mask-fade":"truncate"} ${n?"text-white":""}`,children:e.title})]}),!r&&!a&&Ge("span",{className:`${Gt} ml-1 shrink-0 ${n?"text-white":""}`,style:n?void 0:{opacity:.8},children:o})]})},Va=({event:e,isEventSelected:t})=>{const n=!1!==e.icon,r="boolean"!=typeof e.icon?e.icon:null;return Ge("div",{className:"text-xs px-1 rounded truncate cursor-pointer flex items-center",children:[n&&(r?Ge("div",{className:`${Jt} shrink-0`,children:r}):e.title.toLowerCase().includes("easter")||e.title.toLowerCase().includes("holiday")?Ge("span",{className:`inline-block ${Jt} shrink-0 ${t?"text-yellow-200":"text-yellow-600"}`,children:"⭐"}):Ge(lt,{className:`${Ot} ${t?"text-white":""}`})),Ge("span",{className:"truncate "+(t?"text-white":""),children:e.title})]})},qa=({event:e,isEditable:t,onResizeStart:n})=>{const r=!1!==e.icon,a="boolean"!=typeof e.icon?e.icon:null;return Ge("div",{className:"h-full flex items-center overflow-hidden pl-3 px-1 py-0 relative group",children:[n&&t&&Ge("div",{className:"resize-handle absolute left-0 top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20",onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),n(t,e,"left")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}),r&&(a?Ge("div",{className:"mr-1 shrink-0",children:a}):Ge(lt,{className:Ot})),Ge("div",{className:`${Ht} pr-1`,style:{lineHeight:"1.2"},children:e.title}),n&&t&&Ge("div",{className:Pt,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),n(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]})},Ga=({event:e,app:t,multiDaySegmentInfo:n,isEditable:a,isTouchEnabled:o,isEventSelected:l,onResizeStart:i})=>{const s=n?n.startHour:ne(e.start),d=n?n.endHour:fe(e),c=d-s,u=!n||n.isFirst,h=!n||n.isLast,g=e.calendarId||"blue";return Ge(r,{children:[Ge("div",{className:"df-event-color-bar absolute left-1 top-1 bottom-1 w-[3px] rounded-full",style:{backgroundColor:ue(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())}}),Ge("div",{className:"h-full flex flex-col overflow-hidden pl-3 "+(fe(e)-ne(e.start)<=.25?"px-1 py-0":"p-1"),children:[Ge("div",{className:`${Ht} pr-1`,style:{lineHeight:c<=.25?"1.2":"normal"},children:e.title}),c>.5&&Ge("div",{className:"df-event-time text-xs opacity-80 truncate",children:n?`${ge(s)} - ${ge(d)}`:me(e)})]}),i&&a&&Ge(r,{children:[u&&Ge("div",{className:"absolute top-0 left-0 w-full h-1.5 cursor-ns-resize z-10 rounded-t-sm",onMouseDown:t=>i(t,e,"top")}),h&&Ge("div",{className:"absolute bottom-0 left-0 w-full h-1.5 cursor-ns-resize z-10 rounded-b-sm",onMouseDown:t=>i(t,e,"bottom")}),!u&&h&&n&&Ge("div",{className:Pt,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),i(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]}),o&&l&&i&&a&&Ge(r,{children:[Ge("div",{className:"absolute -top-1.5 right-5 w-2.5 h-2.5 bg-white border-2 rounded-full z-50",style:{borderColor:ue(g,null==t?void 0:t.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),i(t,e,"top")}}),Ge("div",{className:"absolute -bottom-1.5 left-5 w-2.5 h-2.5 bg-white border-2 rounded-full z-50",style:{borderColor:ue(g,null==t?void 0:t.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),i(t,e,"bottom")}})]})]})},Ka=p(({x:e,y:t,onClose:n,children:r,className:a},o)=>{const l=d(null);c(()=>{const e=()=>n(),t=e=>{if(l.current&&!l.current.contains(e.target)){if(e.target.closest("[data-submenu-content]"))return;n()}};window.dispatchEvent(new CustomEvent("dayflow-close-all-menus")),window.addEventListener("dayflow-close-all-menus",e),document.body.addEventListener("mousedown",t,{capture:!0}),document.body.addEventListener("contextmenu",t,{capture:!0});const r=e=>{"Escape"===e.key&&n()};window.addEventListener("keydown",r);const a=()=>n();return window.addEventListener("scroll",a,!0),window.addEventListener("resize",a),()=>{window.removeEventListener("dayflow-close-all-menus",e),document.body.removeEventListener("mousedown",t,{capture:!0}),document.body.removeEventListener("contextmenu",t,{capture:!0}),window.removeEventListener("keydown",r),window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",a)}},[n]);return v(Ge("div",{ref:e=>{l.current=e,"function"==typeof o?o(e):o&&(o.current=e)},className:`fixed z-50 min-w-32 overflow-visible rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md dark:border-slate-800 dark:bg-slate-950 dark:text-slate-50 animate-in fade-in-0 zoom-in-95 duration-100 ease-out ${a||""}`,style:{top:t,left:e},onContextMenu:e=>e.preventDefault(),"data-context-menu-root":"true",children:r}),document.body)});Ka.displayName="ContextMenu";const Xa=({onClick:e,children:t,icon:n,danger:r,disabled:a})=>Ge("div",{className:`relative flex cursor-default select-none items-center rounded-sm px-3 py-0.5 text-[12px] outline-none transition-colors group\n ${a?"pointer-events-none opacity-50":"focus:bg-primary focus:text-white hover:bg-primary hover:text-white dark:focus:bg-primary dark:focus:text-white dark:hover:bg-primary dark:hover:text-white"}\n ${r?"text-destructive focus:text-destructive-foreground focus:bg-destructive hover:bg-destructive hover:text-destructive-foreground":"text-slate-900 dark:text-slate-50"}`,onClick:t=>{t.stopPropagation(),a||e()},"data-disabled":a,children:[n&&Ge("span",{className:"mr-2 h-4 w-4",children:n}),t]}),Ja=()=>Ge("div",{className:"-mx-1 my-1 h-px bg-slate-200 dark:bg-slate-800"}),Qa=({children:e})=>Ge("div",{className:"px-3 py-0.5 text-[12px] font-semibold text-slate-950 dark:text-slate-50",children:e}),eo=({children:e})=>{const[t,n]=s(!1),r=d(null);return c(()=>()=>{r.current&&clearTimeout(r.current)},[]),Ge("div",{className:"relative",onMouseEnter:()=>{r.current&&(clearTimeout(r.current),r.current=null),n(!0)},onMouseLeave:()=>{r.current=setTimeout(()=>{n(!1)},100)},children:(Array.isArray(e)?e:[e]).map(e=>l(e)?i(e,{isOpen:t}):e)})},to=({children:e,icon:t,isOpen:n})=>Ge("div",{className:"relative flex cursor-default select-none items-center rounded-sm px-3 py-0.5 text-[12px] outline-none transition-colors focus:bg-primary focus:text-white hover:bg-primary hover:text-white dark:focus:bg-primary dark:focus:text-white dark:hover:bg-primary dark:hover:text-white "+(n?"bg-primary text-white":""),children:[t&&Ge("span",{className:"mr-2 h-4 w-4",children:t}),Ge("span",{className:"grow text-left",children:e}),Ge(Xe,{className:"ml-auto h-4 w-4 "+(n?"text-white opacity-100":"opacity-60")})]}),no=({children:e,isOpen:t})=>{const n=d(null),[r,a]=s("right");return c(()=>{var e;if(t&&n.current){const t=n.current.getBoundingClientRect(),r=null===(e=n.current.parentElement)||void 0===e?void 0:e.getBoundingClientRect();r&&(r.right+t.width>window.innerWidth?a("left"):a("right"))}},[t]),t?Ge("div",{ref:n,className:"absolute top-0 z-50 min-w-32 whitespace-nowrap overflow-hidden rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md dark:border-slate-800 dark:bg-slate-950 dark:text-slate-50 animate-in fade-in-0 zoom-in-95 duration-100 ease-out",style:{left:"right"===r?"100%":"auto",right:"left"===r?"100%":"auto",marginLeft:"right"===r?"0.25rem":0,marginRight:"left"===r?"0.25rem":0},"data-submenu-content":"true",children:e}):null},ro=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],ao=({selectedColor:e,onSelect:t,onCustomColor:n})=>{const{t:r}=In();return Ge("div",{children:[Ge("div",{className:"grid grid-cols-7 gap-2 p-1 px-3",children:ro.map(n=>Ge("button",{type:"button",className:"h-5 w-5 rounded-full border border-gray-200 dark:border-gray-600 hover:scale-110 transition-transform focus:outline-none focus:ring-2 focus:ring-offset-1 focus:ring-primary dark:focus:ring-offset-slate-800 "+((null==e?void 0:e.toLowerCase())===n.toLowerCase()?"ring-2 ring-offset-1 ring-primary dark:ring-offset-slate-800":""),style:{backgroundColor:n},onClick:e=>{e.stopPropagation(),t(n)},title:n},n))}),n&&Ge("div",{className:"mt-1 flex cursor-pointer items-center rounded-sm px-3 py-0.5 text-[12px] text-slate-700 hover:bg-primary hover:text-white dark:text-slate-200 dark:hover:bg-primary dark:hover:text-white transition-colors",onClick:e=>{e.stopPropagation(),n()},children:r("customColor")})]})},oo=({x:t,y:n,date:r,onClose:a,app:o,onCreateEvent:l,viewType:i})=>{const{t:s}=In(),d=hr.hasEvent();return Ge(Ka,{x:t,y:n,onClose:a,children:[Ge(Xa,{onClick:()=>{l(),a()},children:s("newEvent")||"New Event"}),Ge(Xa,{onClick:()=>y(void 0,void 0,void 0,function*(){yield((t,n,r)=>y(void 0,void 0,void 0,function*(){if(hr.hasEvent())try{let a=hr.getEvent();if(!a){const e=yield navigator.clipboard.readText();e&&(a=JSON.parse(e))}if(a&&"object"==typeof a&&a.title){const o=an(a.start),l=an(a.end).getTime()-o.getTime(),i=a,{_segmentInfo:s}=i,d=b(i,["_segmentInfo"]),c=new Date(n),u=r===k.MONTH||r===k.YEAR,h=0===c.getHours()&&0===c.getMinutes(),g=0!==o.getHours()||0!==o.getMinutes();!a.allDay&&(u||h&&g)&&c.setHours(o.getHours(),o.getMinutes(),o.getSeconds(),o.getMilliseconds());const m=new Date(c.getTime()+(l>0?l:36e5)),v=Object.assign(Object.assign({},d),{id:Ze(),start:a.allDay?on(c):sn(c,e.Now.timeZoneId()),end:a.allDay?on(m):sn(m,e.Now.timeZoneId()),calendarId:a.calendarId&&t.getCalendarRegistry().has(a.calendarId)?a.calendarId:t.getCalendarRegistry().getDefaultCalendarId()||"default"});t.addEvent(v)}}catch(e){console.error("Failed to paste event:",e)}}))(o,r,i),a()}),disabled:!d,children:s("pasteHere")||"Paste Here"})]})},lo=({event:e,x:t,y:n,onClose:a,app:o})=>{var l,i;const{t:s}=In(),d=o.getCalendars(),c=null===(i=null===(l=o.callbacks)||void 0===l?void 0:l.renderEventContextMenu)||void 0===i?void 0:i.call(l,e,a);return Ge(Ka,{x:t,y:n,onClose:a,children:[Ge(eo,{children:[Ge(to,{children:s("calendars")||"Calendars"}),Ge(no,{children:d.map(t=>{const n=t.id===e.calendarId;return Ge(Xa,{onClick:()=>{return n=t.id,o.updateEvent(e.id,{calendarId:n}),void a();var n},children:Ge("div",{className:"flex items-center w-full",children:[Ge("div",{className:"w-4 shrink-0",children:n&&Ge(rt,{className:"w-3 h-3 text-primary"})}),Ge("div",{className:"flex items-center gap-1.5 min-w-0",children:[Ge("div",{className:"w-3 h-3 rounded-sm shrink-0",style:{backgroundColor:t.colors.lineColor}}),Ge("span",{className:"truncate "+(n?"font-semibold":""),children:t.name})]})]})},t.id)})})]}),Ge(Ja,{}),Ge(Xa,{onClick:()=>{o.deleteEvent(e.id),a()},danger:!0,children:s("delete")||"Delete"}),Ge(Xa,{onClick:()=>y(void 0,void 0,void 0,function*(){try{const t=JSON.stringify(e,null,2);yield navigator.clipboard.writeText(t),hr.setEvent(e),o.deleteEvent(e.id)}catch(e){console.error("Failed to cut event: ",e)}a()}),children:s("cut")||"Cut"}),Ge(Xa,{onClick:()=>y(void 0,void 0,void 0,function*(){try{const t=JSON.stringify(e,null,2);yield navigator.clipboard.writeText(t),hr.setEvent(e)}catch(e){console.error("Failed to copy event: ",e)}a()}),children:s("copy")||"Copy"}),c&&Ge(r,{children:[Ge(Ja,{}),c]})]})},io=(e,t,n,r,a)=>{let o="df-event calendar-event select-none pointer-events-auto px-0.5";t?o+=" df-day-event flex flex-col":e||(o+=" df-week-event flex flex-col");const l=()=>{if(r&&a){const{segmentType:e}=a;if("single"===e||"start"===e)return Mt;if("start-week-end"===e)return"rounded-l-xl rounded-r-none my-0.5";if("end"===e||"end-week-start"===e)return"rounded-r-xl rounded-l-none my-0.5";if("middle"===e)return"rounded-none my-0.5"}return Mt};if(e){let e=`\n ${o}\n ${n?l():It}\n `;return r||(e+=" mb-[2px]"),e}return`\n ${o}\n shadow-sm\n ${n?l():It}\n `},so=({event:e,layout:t,isAllDay:n=!1,allDayHeight:a=28,calendarRef:o,isBeingDragged:l=!1,isBeingResized:i=!1,isDayView:m=!1,isMonthView:v=!1,isMultiDay:f=!1,segment:p,segmentIndex:y=0,hourHeight:b,firstHour:w,selectedEventId:D,detailPanelEventId:x,onMoveStart:E,onResizeStart:C,onEventUpdate:k,onEventDelete:T,newlyCreatedEventId:N,onDetailPanelOpen:S,onEventSelect:M,onEventLongPress:I,onDetailPanelToggle:H,customDetailPanelContent:R,customEventDetailDialog:O,multiDaySegmentInfo:P,app:L,isMobile:A=!1,enableTouch:$,hideTime:j})=>{const Y=u(Ve),F=null!=$?$:A,[z,_]=s(null),[Z,W]=s(!1),[U,B]=s(null),V=d(null),q=d(null),G=d(null),K=d(null),X=f&&p?`${e.id}::${p.id}`:void 0!==(null==P?void 0:P.dayIndex)?`${e.id}::day-${P.dayIndex}`:e.id,J=x===X,Q=J&&!O,ee=null==L?void 0:L.getReadOnlyConfig(),te=!(null==L?void 0:L.state.readOnly),re=!1!==(null==ee?void 0:ee.viewable),ae=!1!==(null==ee?void 0:ee.draggable),{isSelected:oe,setIsSelected:le,isPressed:ie,setIsPressed:ue,handleTouchStart:he,handleTouchMove:ge,handleTouchEnd:me}=(({event:e,isTouchEnabled:t,onMoveStart:n,onEventLongPress:r,onEventSelect:a,onDetailPanelToggle:o,canOpenDetail:l,app:i,multiDaySegmentInfo:c,isMultiDay:u,segment:h,detailPanelKey:g})=>{const[m,v]=s(!1),[f,p]=s(!1),y=d(null),b=d(null);return{isSelected:m,setIsSelected:v,isPressed:f,setIsPressed:p,handleTouchStart:a=>{if(!n||!t)return;a.stopPropagation(),p(!0);const o=a.touches[0],l=o.clientX,i=o.clientY,s=a.currentTarget;b.current={x:l,y:i},y.current=setTimeout(()=>{var t;r?r(e.id):v(!0);const a={preventDefault:()=>{},stopPropagation:()=>{},currentTarget:s,touches:[{clientX:l,clientY:i}],cancelable:!1};if(c){const r=Object.assign(Object.assign({},e),{day:null!==(t=c.dayIndex)&&void 0!==t?t:e.day,_segmentInfo:c});n(a,r)}else if(u&&h){const t=Object.assign(Object.assign({},e),{day:h.startDayIndex,_segmentInfo:{dayIndex:h.startDayIndex,isFirst:h.isFirstSegment,isLast:h.isLastSegment}});n(a,t)}else n(a,e);y.current=null,b.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},handleTouchMove:e=>{if(y.current&&b.current){const t=Math.abs(e.touches[0].clientX-b.current.x),n=Math.abs(e.touches[0].clientY-b.current.y);(t>10||n>10)&&(clearTimeout(y.current),y.current=null,b.current=null,p(!1))}},handleTouchEnd:n=>{p(!1),y.current&&(clearTimeout(y.current),y.current=null),t&&b.current&&(n.preventDefault(),n.stopPropagation(),a?a(e.id):l&&v(!0),i&&i.onEventClick(e),l?null==o||o(g):null==o||o(null)),b.current=null}}})({event:e,isTouchEnabled:F,onMoveStart:E,onEventLongPress:I,onEventSelect:M,onDetailPanelToggle:H,canOpenDetail:re,app:L,multiDaySegmentInfo:P,isMultiDay:f,segment:p,detailPanelKey:X}),ve=(void 0!==D?D===e.id:oe)||ie||l,[pe,ye]=s("visible"),be=e=>{K.current=e},we=()=>((e,t,n,r,a,o)=>{var l;if(null!==r)return r;if(t===n){const e=n.split("::"),t=e[e.length-1];if(t.startsWith("day-")){const e=Number(t.replace("day-",""));if(!Number.isNaN(e))return e}}return void 0!==(null==a?void 0:a.dayIndex)?a.dayIndex:o?o.startDayIndex:null!==(l=e.day)&&void 0!==l?l:0})(e,x||void 0,X,K.current,P,p),De=e=>((e,t,n,r,a)=>{if(!t.current)return null;const o=t.current.getBoundingClientRect();if(n){const t=o.width/7,n=e-o.left,r=Math.floor(n/t);return Number.isFinite(r)?Math.max(0,Math.min(6,r)):null}const l=a?48:80,i=r?1:7,s=(o.width-l)/i,d=e-o.left-l,c=Math.floor(d/s);return Number.isFinite(c)?Math.max(0,Math.min(i-1,c)):null})(e,o,v,m,A),xe=e=>((e,t,n,r,a)=>{if(!t.current)return null;const o=t.current.getBoundingClientRect();if(n){const t=o.width/7;return{left:o.left+e*t,width:t}}const l=a?48:80;if(r){const e=o.width-l;return{left:o.left+l,width:e}}const i=(o.width-l)/7;return{left:o.left+l+e*i,width:i}})(e,o,v,m,A),Ee=g(()=>{if(!G.current||!o.current||!q.current)return;const t=o.current.getBoundingClientRect(),n=we(),r=xe(n);let a,l;if(r)a=r.left,l=r.width;else if(v)l=t.width/7,a=t.left+n*l;else{const e=A?48:80;l=(t.width-e)/7,a=t.left+e+n*l}const i=Math.min(window.innerWidth,t.right),s=Math.min(window.innerHeight,t.bottom);requestAnimationFrame(()=>{var r,l,d,c;if(!q.current)return;if(!G.current)return;const u=q.current.getBoundingClientRect(),h=u.width,g=u.height;let y,D,x;if("sticky-top"===pe||"sticky-bottom"===pe){const t=null===(r=o.current)||void 0===r?void 0:r.querySelector(".calendar-content");if(!t)return;const n=P?P.startHour:ne(e.start),a=P?P.endHour:fe(e),i=(n-w)*b,s=Math.max((a-n)*b,b/4),d=t.getBoundingClientRect(),c=t.scrollTop,u=d.top+i-c,h=null===(l=V.current)||void 0===l?void 0:l.getBoundingClientRect();if(!h)return;x={top:u,bottom:u+s,left:h.left,right:h.right,width:h.width,height:s,x:h.x,y:u,toJSON:()=>({})}}else x=G.current.getBoundingClientRect();if(v&&f&&p){const e=xe(n),r=null!==(d=null==e?void 0:e.width)&&void 0!==d?d:t.width/7,a=null!==(c=null==e?void 0:e.left)&&void 0!==c?c:t.left+n*r,o=a+r;x={top:x.top,bottom:x.bottom,left:a,right:o,width:o-a,height:x.height,x:a,y:x.top,toJSON:()=>({})}}if(("sticky-top"===pe||"sticky-bottom"===pe)&&!v){const e=we(),n=xe(e),r=A?48:80,a=n?n.left:t.left+r+e*(t.width-r)/(m?1:7),o=n?n.width:(t.width-r)/(m?1:7),l=Math.max(0,m?x.width:o-3),i=m?x.left:a;x=Object.assign(Object.assign({},x),{left:i,right:i+l,width:l})}const E=i-x.right,C=x.left-t.left;y=E>=h+20?x.right+10:C>=h+20?x.left-h-10:E>C?Math.max(t.left+10,i-h-10):t.left+10;const k=x.top-g/2+x.height/2,T=Math.max(10,t.top+10),N=s-10;D=k<T?T:k+g>N?N-g:k,B(e=>e?Object.assign(Object.assign({},e),{top:D,left:y,isSunday:y<a}):null)})},[o,e.day,e.start,e.end,pe,v,w,b,f,p,P,x,X,A,m]);(({event:e,isEventSelected:t,showDetailPanel:n,eventRef:r,calendarRef:a,isAllDay:o,isMonthView:l,multiDaySegmentInfo:i,firstHour:s,hourHeight:d,updatePanelPosition:u,setEventVisibility:h})=>{const m=g(()=>{if(!t||!n||!r.current||!a.current||o||l)return;const c=a.current.querySelector(".calendar-content");if(!c)return;const g=i?i.startHour:ne(e.start),m=i?i.endHour:fe(e),v=(g-s)*d,f=v+Math.max((m-g)*d,d/4),p=c.getBoundingClientRect(),y=c.scrollTop;let b=f<y+6,w=v>y+p.height-6;const D=p.bottom<0,x=p.top>window.innerHeight;D?b=!0:x&&(w=!0),h(b?"sticky-top":w?"sticky-bottom":"visible"),u()},[t,n,a,o,l,e.start,e.end,s,d,u,i]);c(()=>{var e,r;if(!t||!n||o)return;const l=null===(e=a.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(!l)return;const i=()=>m(),s=()=>{m(),u()},d=[l];let c=null===(r=a.current)||void 0===r?void 0:r.parentElement;for(;c;){const e=window.getComputedStyle(c);"auto"!==e.overflowY&&"scroll"!==e.overflowY&&"auto"!==e.overflowX&&"scroll"!==e.overflowX||d.push(c),c=c.parentElement}d.forEach(e=>{e.addEventListener("scroll",i)}),window.addEventListener("scroll",i,!0),window.addEventListener("resize",s);let h=null;return a.current&&(h=new ResizeObserver(()=>{s()}),h.observe(a.current)),m(),()=>{d.forEach(e=>{e.removeEventListener("scroll",i)}),window.removeEventListener("scroll",i,!0),window.removeEventListener("resize",s),h&&h.disconnect()}},[t,n,o,m,u,a])})({event:e,isEventSelected:ve,showDetailPanel:J,eventRef:V,calendarRef:o,isAllDay:n,isMonthView:v,multiDaySegmentInfo:P,firstHour:w,hourHeight:b,updatePanelPosition:Ee,setEventVisibility:ye});const Ce=J&&!!O;(({eventRef:e,detailPanelRef:t,eventId:n,isEventSelected:r,showDetailPanel:a,onEventSelect:o,onDetailPanelToggle:l,setIsSelected:i,setActiveDayIndex:s})=>{c(()=>{if(!r&&!a)return;const d=d=>{var c,u;const h=d.target,g=null===(c=e.current)||void 0===c?void 0:c.contains(h),m=null!==h.closest(`[data-event-id="${n}"]`),v=null===(u=t.current)||void 0===u?void 0:u.contains(h),f=h.closest("[data-event-detail-dialog]"),p=h.closest("[data-range-picker-popup]"),y=h.closest("[data-calendar-picker-dropdown]");a?g||m||v||f||p||y||(null==o||o(null),s(null),i(!1),null==l||l(null)):!r||g||m||f||p||y||(null==o||o(null),s(null),i(!1),null==l||l(null))};return document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d)}},[r,a,o,l,n])})({eventRef:V,detailPanelRef:q,eventId:e.id,isEventSelected:!Ce&&ve,showDetailPanel:Q,onEventSelect:M,onDetailPanelToggle:H,setIsSelected:le,setActiveDayIndex:be});const ke=g(()=>{M&&M(null),K.current=null,le(!1),null==H||H(null)},[M,H]),Te=h(()=>({event:e,isAllDay:n,onEventUpdate:k,onEventDelete:T,onClose:ke}),[e,n,k,T,ke]),Ne=h(()=>({event:e,isAllDay:n,isMobile:A,isMonthView:v,segment:p,layout:t}),[e,n,A,v,p,t]),Se=g(()=>Ge(Ir,{store:Y,generatorName:"eventDetailContent",generatorArgs:Te}),[Y,Te]);c(()=>{!J||U||A||(B({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>Ee()))},[J,U,Ee,A]),c(()=>{if((null==L?void 0:L.state.highlightedEventId)===e.id){W(!0);const e=setTimeout(()=>{W(!1)},300);return()=>{clearTimeout(e),W(!1)}}},[null==L?void 0:L.state.highlightedEventId,e.id]);const Me=e.calendarId||"blue",Ie=null==L?void 0:L.getCalendarRegistry();return Ge(r,{children:[Ge("div",{ref:V,"data-event-id":e.id,className:io(v,m,n,f,p),style:Object.assign(Object.assign({},(()=>{var r,l,i,s,d,c,u,h;if(v)return f&&p?{opacity:1,zIndex:ve||J?1e3:1,cursor:ae||re?"pointer":"default"}:{opacity:1,zIndex:ve||J?1e3:1,transform:Z?"scale(1.05)":"scale(1)",transition:"transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)",cursor:ae||re?"pointer":"default"};if(n){const e={height:a-4+"px",opacity:1,zIndex:ve||J?1e3:1,transform:Z?"scale(1.05)":"scale(1)",transition:"transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)",cursor:ae||re?"pointer":"default"},t=y*a;if(Object.assign(e,{top:`${t}px`}),m)Object.assign(e,{width:"100%",left:"0px",right:"2px",position:"absolute"});else if(f&&p){const t=(p.endDayIndex-p.startDayIndex+1)/7*100,n=p.startDayIndex/7*100,r=2,a=p.isFirstSegment?r:0,o=a+(p.isLastSegment?r:0);Object.assign(e,{width:o>0?`calc(${t}% - ${o}px)`:`${t}%`,left:a>0?`calc(${n}% + ${a}px)`:`${n}%`,position:"absolute",pointerEvents:"auto"})}else Object.assign(e,{width:"100%",left:"0px",position:"relative"});return e}const g=P?P.startHour:ne(e.start),D=P?P.endHour:fe(e),x={top:`${(g-w)*b+3}px`,height:Math.max((D-g)*b,b/4)-4+"px",position:"absolute",opacity:1,zIndex:ve||J?1e3:null!==(r=null==t?void 0:t.zIndex)&&void 0!==r?r:1,transform:Z?"scale(1.05)":"scale(1)",transition:"transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)",cursor:ae||re?"pointer":"default"};if(ve&&J&&("sticky-top"===pe||"sticky-bottom"===pe)){const e=null===(l=o.current)||void 0===l?void 0:l.getBoundingClientRect();if(e){const n=we(),r=A?48:80,a=m?1:7;let l=(e.width-r)/a,g=e.left+r+(m?0:n*l);v&&(l=e.width/7,g=e.left+n*l);const f=xe(n);f&&(g=f.left,l=f.width);let p=null===(i=o.current)||void 0===i?void 0:i.querySelector(".calendar-content");p||(p=null===(s=o.current)||void 0===s?void 0:s.querySelector(".calendar-renderer"));const y=null==p?void 0:p.getBoundingClientRect(),b=null===(c=null===(d=V.current)||void 0===d?void 0:d.parentElement)||void 0===c?void 0:c.getBoundingClientRect();let w,D;if(b&&b.width>0)t?(w=b.left+t.left/100*b.width,D=m?t.width/100*b.width:(t.width-1)/100*b.width):(w=b.left,D=m?b.width:b.width-3);else{const e=xe(n),r=null!==(u=null==e?void 0:e.left)&&void 0!==u?u:g,a=null!==(h=null==e?void 0:e.width)&&void 0!==h?h:l;w=r,D=a-3,t&&(w=r+t.left/100*a,D=m?t.width/100*a:(t.width-1)/100*a)}if("sticky-top"===pe){let t=y?y.top:e.top;return t=Math.max(t,0),t=Math.max(t,e.top),t=Math.min(t,e.bottom-6),t=Math.min(t,window.innerHeight-6),{position:"fixed",top:`${t}px`,left:`${w}px`,width:`${D}px`,height:"6px",zIndex:1e3,overflow:"hidden"}}let x=y?y.bottom:e.bottom;return x=Math.min(x,window.innerHeight),x=Math.min(x,e.bottom),x=Math.max(x,e.top+6),x=Math.max(x,6),{position:"fixed",top:x-6+"px",left:`${w}px`,width:`${D}px`,height:"6px",zIndex:1e3,overflow:"hidden"}}}if(t&&!n){const e=m?`${t.width}%`:t.width-1+"%";return Object.assign(Object.assign({},x),{left:`${t.left}%`,width:e,right:"auto"})}return Object.assign(Object.assign({},x),{left:"0px",right:m?"0px":"3px"})})()),{backgroundColor:ve?ce(Me,Ie):se(Me,Ie),color:ve?"#fff":de(Me,Ie)}),onClick:F?void 0:t=>{var n,r,a;if(t.preventDefault(),t.stopPropagation(),f){const a=De(t.clientX);be(null!==a?p?Math.min(Math.max(a,p.startDayIndex),p.endDayIndex):a:null!==(r=null!==(n=null==P?void 0:P.dayIndex)&&void 0!==n?n:e.day)&&void 0!==r?r:null)}else be(null!==(a=e.day)&&void 0!==a?a:null);L&&L.onEventClick(e),M?M(e.id):re&&le(!0),null==H||H(null),B(null)},onContextMenu:F?void 0:t=>{t.preventDefault(),t.stopPropagation(),M&&M(e.id),_({x:t.clientX,y:t.clientY})},onDblClick:F?void 0:t=>{var r,a,l,i,s;if(!re)return;t.preventDefault(),t.stopPropagation();let d=t.currentTarget;if(f){const e=d.querySelector("div");e&&(d=e)}if(G.current=d,f){const n=De(t.clientX);be(null!==n?Math.min(Math.max(n,null!==(r=null==p?void 0:p.startDayIndex)&&void 0!==r?r:0),null!==(a=null==p?void 0:p.endDayIndex)&&void 0!==a?a:6):null!==(i=null!==(l=null==p?void 0:p.startDayIndex)&&void 0!==l?l:e.day)&&void 0!==i?i:0)}else be(null!==(s=e.day)&&void 0!==s?s:null);new Promise(t=>{if(!o.current||n||v)return void t();const r=o.current.querySelector(".calendar-content");if(!r)return void t();const a=P?P.startHour:ne(e.start),l=P?P.endHour:fe(e),i=(a-w)*b,s=i+Math.max((l-a)*b,b/4),d=r.scrollTop,c=r.clientHeight;if(i>=d&&s<=d+c)return void t();const u=((a+l)/2-w)*b-c/2,h=r.scrollHeight-c;r.scrollTo({top:Math.max(0,Math.min(h,u)),behavior:"smooth"}),setTimeout(()=>t(),300)}).then(()=>{le(!0),A||(null==H||H(X),B({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>Ee()))})},onMouseDown:t=>{var n;F||ue(!0),E&&E(t,P?Object.assign(Object.assign({},e),{day:null!==(n=P.dayIndex)&&void 0!==n?n:e.day,_segmentInfo:P}):f&&p?Object.assign(Object.assign({},e),{day:p.startDayIndex,_segmentInfo:{dayIndex:p.startDayIndex,isFirst:p.isFirstSegment,isLast:p.isLastSegment}}):e)},onMouseUp:()=>!F&&ue(!1),onMouseLeave:()=>!F&&ue(!1),onTouchStart:he,onTouchMove:ge,onTouchEnd:me,children:(()=>{let t;return t=v?f&&p?Ge(Za,{segment:p,segmentIndex:null!=y?y:0,isDragging:l||ve,isResizing:i,isSelected:ve,onMoveStart:E||(()=>{}),onResizeStart:C,isMobile:A,isDraggable:ae,isEditable:te,viewable:re,isPopping:Z}):e.allDay?Ge(Va,{event:e,isEventSelected:ve}):Ge(Ba,{event:e,app:L,isEventSelected:ve,hideTime:j,isMobile:A}):e.allDay?Ge(qa,{event:e,isEditable:te,onResizeStart:C}):Ge(Ga,{event:e,app:L,multiDaySegmentInfo:P,isEditable:te,isTouchEnabled:F,isEventSelected:ve,onResizeStart:C}),Ge(Ir,{store:Y,generatorName:"eventContent",generatorArgs:Ne,defaultContent:t})})()}),J&&!O&&Ge("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:9998,pointerEvents:"none"}}),(()=>{if(!J)return null;if(O)return null;if(!U)return null;const t={event:e,position:U,panelRef:q,isAllDay:n,eventVisibility:pe,calendarRef:o,selectedEventElementRef:G,onEventUpdate:k,onEventDelete:T,onClose:ke};return(null==Y?void 0:Y.isOverridden("eventDetailContent"))?Ge(Ua,Object.assign({},t,{contentRenderer:Se})):R?Ge(Ua,Object.assign({},t,{contentRenderer:R})):Ge(Wa,Object.assign({},t,{app:L}))})(),z&&L&&Ge(lo,{event:e,x:z.x,y:z.y,onClose:()=>_(null),app:L,onDetailPanelToggle:H,detailPanelKey:X})]})},co=({app:e,currentDate:t,currentWeekStart:n,events:r,currentDayEvents:a,organizedAllDayEvents:o,allDayAreaHeight:l,timeSlots:i,eventLayouts:c,isToday:u,currentTime:h,selectedEventId:g,setSelectedEventId:m,newlyCreatedEventId:v,setNewlyCreatedEventId:f,detailPanelEventId:p,setDetailPanelEventId:y,dragState:b,isDragging:w,handleMoveStart:D,handleResizeStart:x,handleCreateStart:E,handleCreateAllDayEvent:C,handleTouchStart:T,handleTouchEnd:N,handleTouchMove:S,handleDragOver:M,handleDrop:I,handleEventUpdate:H,handleEventDelete:R,onDateChange:O,customDetailPanelContent:P,customEventDetailDialog:L,calendarRef:A,allDayRowRef:$,switcherMode:j,isMobile:Y,isTouch:F,setDraftEvent:z,setIsDrawerOpen:_,ALL_DAY_HEIGHT:Z,HOUR_HEIGHT:W,FIRST_HOUR:U,LAST_HOUR:B,showAllDay:V,showStartOfDayLabel:q})=>{const{t:G,locale:K}=In(),X=d(e.state.highlightedEventId),[J,Q]=s(null),ee=Bn(),te=()=>{var e;const t=null===(e=A.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(!t)return 0;const n=t.querySelector(".df-time-grid-row");return n?n.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop:0},ne=(e,n)=>{var r,a,o,l;if(e.preventDefault(),Y)return;const i=new Date(t);if(n)i.setHours(0,0,0,0);else{const t=null===(a=null===(r=A.current)||void 0===r?void 0:r.querySelector(".calendar-content"))||void 0===a?void 0:a.getBoundingClientRect();if(t){const n=(null===(l=null===(o=A.current)||void 0===o?void 0:o.querySelector(".calendar-content"))||void 0===l?void 0:l.scrollTop)||0,r=te(),a=(e.clientY-t.top+n-r)/W+U,s=Math.floor(a),d=Math.floor(60*(a-s)),c=15*Math.round(d/15),u=60===c?s+1:s,h=60===c?0:c;i.setHours(u,h,0,0)}}Q({x:e.clientX,y:e.clientY,date:i})};return Ge("div",{className:`flex-none ${"buttons"===j?"":"md:w-[60%]"} w-full md:w-[70%] bg-white dark:bg-gray-900 border-r border-gray-200 dark:border-gray-700`,onContextMenu:e=>e.preventDefault(),children:[Ge("div",{className:`relative ${Xt} h-full`,children:[Ge("div",{onContextMenu:e=>e.preventDefault(),style:{paddingRight:Y||!ee?"0px":"15px"},children:Ge(Ya,{calendar:e,viewType:k.DAY,currentDate:t,customSubtitle:t.toLocaleDateString(K,{weekday:"long"})})}),Ge("div",V?{className:Qt(St,"border-t border-gray-200 dark:border-gray-700 items-stretch"),ref:$,style:{paddingRight:Y||!ee?"0px":"0.6875rem"},onContextMenu:e=>ne(e,!0),children:[Ge("div",{className:"df-all-day-label flex-shrink-0 p-1 text-xs font-medium text-gray-500 dark:text-gray-400 flex justify-end select-none w-12 text-[10px] md:w-20 md:text-xs flex items-center",onContextMenu:e=>e.preventDefault(),children:G("allDay")}),Ge("div",{className:Qt("flex flex-1 relative self-stretch",!Y&&ee?"border-r border-gray-200 dark:border-gray-700":""),children:Ge("div",{className:"w-full relative",style:{minHeight:`${l}px`},onClick:()=>null==O?void 0:O(t),onMouseDown:e=>{const r=Math.floor((t.getTime()-n.getTime())/864e5);null==C||C(e,r)},onDblClick:e=>{const r=Math.floor((t.getTime()-n.getTime())/864e5);null==C||C(e,r)},onDragOver:M,onDrop:e=>{I(e,t,void 0,!0)},children:o.map(t=>Ge(so,{event:t,isAllDay:!0,isDayView:!0,segmentIndex:t.row,allDayHeight:Z,calendarRef:A,isBeingDragged:w&&(null==b?void 0:b.eventId)===t.id&&"move"===(null==b?void 0:b.mode),hourHeight:W,firstHour:U,onMoveStart:D,onEventUpdate:H,onEventDelete:R,newlyCreatedEventId:v,onDetailPanelOpen:()=>f(null),detailPanelEventId:p,onDetailPanelToggle:e=>y(e),selectedEventId:g,onEventSelect:t=>{const n=!1!==e.getReadOnlyConfig().viewable,a=e.state.readOnly,o=r.find(e=>e.id===t);(Y||F)&&o&&n&&!a?(z(o),_(!0)):(m(t),e.state.highlightedEventId&&(e.highlightEvent(null),X.current=null))},onEventLongPress:e=>{(Y||F)&&m(e)},customDetailPanelContent:P,customEventDetailDialog:L,app:e,isMobile:Y,enableTouch:F},t.id))})})]}:{className:Qt("border-b border-gray-200 dark:border-gray-700",!Y&&ee?"pr-2.75":"")}),Ge("div",{className:"relative overflow-y-auto calendar-content df-day-time-grid",style:{position:"relative",scrollbarGutter:"stable"},children:Ge("div",{className:"relative flex",children:[u&&h&&(()=>{const e=h,t=e.getHours()+e.getMinutes()/60;if(t<U||t>B)return null;return Ge("div",{className:Tt,style:{top:`${(t-U)*W}px`,width:"100%",height:0,zIndex:20,marginTop:"0.75rem"},children:[Ge("div",{className:"flex items-center w-12 md:w-20",children:[Ge("div",{className:"relative w-full flex items-center"}),Ge("div",{className:Nt,children:ge(t)})]}),Ge("div",{className:"flex-1 flex items-center",children:Ge("div",{className:"df-current-time-bar h-0.5 w-full bg-primary relative"})})]})})(),Ge("div",{className:"df-time-column flex-shrink-0 border-gray-200 dark:border-gray-700 w-12 md:w-20",onContextMenu:e=>e.preventDefault(),children:[Ge("div",{className:"h-3"}),i.map((e,t)=>Ge("div",{className:Et,children:Ge("div",{className:`${Ct} text-[10px] md:text-[12px]`,children:q&&0===t?"":e.label})},t))]}),Ge("div",{className:"grow select-none",children:[Ge("div",{className:Qt(Ft,!Y&&ee?"border-r":"","border-t-0"),children:Ge("div",{className:`${zt} -left-9.5`,style:{top:"auto",bottom:"-0.625rem"},children:q?ge(U):""})}),Ge("div",{className:"relative",style:{WebkitTouchCallout:"none"},children:[i.map((e,r)=>Ge("div",{className:Qt(kt,!Y&&ee?"border-r":""),onClick:()=>null==O?void 0:O(t),onDblClick:e=>{var r,a,o,l;const i=Math.floor((t.getTime()-n.getTime())/864e5),s=null===(a=null===(r=A.current)||void 0===r?void 0:r.querySelector(".calendar-content"))||void 0===a?void 0:a.getBoundingClientRect();if(!s)return;const d=(null===(l=null===(o=A.current)||void 0===o?void 0:o.querySelector(".calendar-content"))||void 0===l?void 0:l.scrollTop)||0,c=te(),u=e.clientY-s.top+d-c;null==E||E(e,i,U+u/W)},onTouchStart:e=>{const r=Math.floor((t.getTime()-n.getTime())/864e5);T(e,r)},onTouchEnd:N,onTouchMove:S,onDragOver:M,onDrop:e=>{var n,r,a,o;const l=null===(r=null===(n=A.current)||void 0===n?void 0:n.querySelector(".calendar-content"))||void 0===r?void 0:r.getBoundingClientRect();if(!l)return;const i=(null===(o=null===(a=A.current)||void 0===a?void 0:a.querySelector(".calendar-content"))||void 0===o?void 0:o.scrollTop)||0,s=te(),d=e.clientY-l.top+i-s,c=Math.floor(U+d/W);I(e,t,c)},onContextMenu:e=>ne(e,!1)},r)),Ge("div",{className:Qt(Ft,!Y&&ee?"border-r":""),children:Ge("div",{className:`${zt} -left-9.5`,children:"00:00"})}),Ge("div",{className:"absolute top-0 left-0 right-0 bottom-0 pointer-events-none",children:a.filter(e=>!e.allDay).map(t=>{const n=c.get(t.id);return Ge(so,{event:t,layout:n,isDayView:!0,calendarRef:A,isBeingDragged:w&&(null==b?void 0:b.eventId)===t.id&&"move"===(null==b?void 0:b.mode),hourHeight:W,firstHour:U,onMoveStart:D,onResizeStart:x,onEventUpdate:H,onEventDelete:R,newlyCreatedEventId:v,onDetailPanelOpen:()=>f(null),detailPanelEventId:p,onDetailPanelToggle:e=>y(e),selectedEventId:g,onEventSelect:t=>{const n=!1!==e.getReadOnlyConfig().viewable,a=r.find(e=>e.id===t);(Y||F)&&a&&n?(z(a),_(!0)):(m(t),e.state.highlightedEventId&&(e.highlightEvent(null),X.current=null))},onEventLongPress:e=>{(Y||F)&&m(e)},customDetailPanelContent:P,customEventDetailDialog:L,app:e,isMobile:Y,enableTouch:F},t.id)})})]})]})]})})]}),J&&Ge(oo,{x:J.x,y:J.y,date:J.date,viewType:k.DAY,onClose:()=>Q(null),app:e,onCreateEvent:()=>{if(E){const e=Math.floor((t.getTime()-n.getTime())/864e5);if(0===J.date.getHours()&&0===J.date.getMinutes())null==C||C({clientX:J.x,clientY:J.y},e);else{const t=J.date.getHours()+J.date.getMinutes()/60,n={preventDefault:()=>{},stopPropagation:()=>{},clientX:J.x,clientY:J.y};E(n,e,t)}}}})]})},uo=e=>{const t=e.getDay(),n=e.getDate()-t+(0===t?-6:1),r=new Date(e);return r.setDate(n),r.setHours(0,0,0,0),r},ho=({app:e,config:t,customDetailPanelContent:n,customEventDetailDialog:r,calendarRef:a,switcherMode:o="buttons",selectedEventId:l,onEventSelect:i,onDateChange:u,detailPanelEventId:m,onDetailPanelToggle:v})=>{const f=e.getEvents(),{screenSize:p}=Sr(),y="desktop"!==p,[b,w]=s(!1),{HOUR_HEIGHT:D=La.HOUR_HEIGHT,FIRST_HOUR:x=La.FIRST_HOUR,LAST_HOUR:E=La.LAST_HOUR,ALL_DAY_HEIGHT:C=La.ALL_DAY_HEIGHT,showAllDay:T=!0}=t,N=!T;c(()=>{w("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const S=e.getCustomMobileEventRenderer()||Vr,[M,I]=s(null),[H,R]=s(null),[O,P]=s(null),L=void 0!==l?l:H,A=void 0!==m?m:O,$=h(()=>L&&f.find(e=>e.id===L)||null,[L,f]),j=e=>{i?i(e):R(e)},[Y,F]=s(null),[z,_]=s(!1),[W,B]=s(null),V=d(null),q=e.getCurrentDate(),[G,K]=s(q),X=d(q.getTime());q.getTime()!==X.current&&(X.current=q.getTime(),q.getFullYear()===G.getFullYear()&&q.getMonth()===G.getMonth()||K(q));const J=g(t=>{K(n=>{const r=new Date(n.getFullYear(),n.getMonth()+t,1);return e.setVisibleMonth(r),r})},[e]),Q=d(e.state.highlightedEventId);c(()=>{var t;if(e.state.highlightedEventId!==Q.current)if(e.state.highlightedEventId){j(e.state.highlightedEventId);const n=e.getEvents().find(t=>t.id===e.state.highlightedEventId);if(n&&!n.allDay){const e=ne(n.start),r=null===(t=a.current)||void 0===t?void 0:t.querySelector(".calendar-content");if(r){const t=(e-x)*D;requestAnimationFrame(()=>{r.scrollTo({top:Math.max(0,t-100),behavior:"smooth"})})}}}else j(null);Q.current=e.state.highlightedEventId},[e.state.highlightedEventId,x,D,a,e]);const ee=d(null),te=h(()=>uo(q),[q]),re=h(()=>((e,t,n)=>{const r=new Date(t);r.setHours(0,0,0,0);const a=new Date(t);return a.setHours(23,59,59,999),e.filter(e=>{const t=U(e.start),n=U(e.end);if(e.allDay){const e=new Date(t);e.setHours(0,0,0,0);const o=new Date(n);return o.setHours(0,0,0,0),e<=a&&o>=r}return t<a&&n>r}).map(e=>{const t=U(e.start),r=Math.floor((t.getTime()-n.getTime())/864e5),a=Math.max(0,Math.min(6,r));return Object.assign(Object.assign({},e),{day:a})})})(f,q,te),[f,q,te]),ae=h(()=>((e,t)=>{const n=new Date(t);n.setHours(0,0,0,0);const r=new Date(n);return r.setDate(r.getDate()+1),e.filter(e=>!e.allDay).map(e=>{const t=U(e.start),a=U(e.end);let o=e.start,l=e.end,i=!1;return t<n&&(o=Z(n),i=!0),a>r&&(l=Z(r),i=!0),Object.assign(Object.assign({},e),{start:i?o:e.start,end:i?l:e.end,day:0})})})(re,q),[re,q]),oe=h(()=>Ia.calculateDayEventLayouts(ae,{viewType:"day"}),[ae]),le=h(()=>(e=>{const t=e.filter(e=>e.allDay);t.sort((e,t)=>{const n=U(e.start),r=U(t.start);if(n.getTime()!==r.getTime())return n.getTime()-r.getTime();const a=U(e.end);return U(t.end).getTime()-a.getTime()});const n=[],r=[];return t.forEach(e=>{let t=0,a=!1;for(;!a;)n[t]?n[t].some(t=>{const n=U(e.start),r=U(e.end),a=U(t.start);return n<=U(t.end)&&a<=r})?t++:(n[t].push(e),r.push(Object.assign(Object.assign({},e),{row:t})),a=!0):(n[t]=[e],r.push(Object.assign(Object.assign({},e),{row:t})),a=!0)}),r})(re),[re]),ie=h(()=>{if(0===le.length)return C;return(Math.max(...le.map(e=>e.row))+1)*C},[le,C]),{handleMoveStart:se,handleCreateStart:de,handleResizeStart:ce,handleCreateAllDayEvent:ue,dragState:he,isDragging:me}=Pa(e,{calendarRef:a,allDayRowRef:T?ee:void 0,viewType:k.DAY,onEventsUpdate:t=>{const n=t(re),r=new Set(n.map(e=>e.id)),a=re.filter(e=>!r.has(e.id)),o=new Set(re.map(e=>e.id)),l=n.filter(e=>!o.has(e.id)),i=n.filter(e=>{if(!o.has(e.id))return!1;const t=re.find(t=>t.id===e.id);return t&&(U(t.start).getTime()!==U(e.start).getTime()||U(t.end).getTime()!==U(e.end).getTime()||t.day!==e.day||ne(t.start)!==ne(e.start)||ne(t.end)!==ne(e.end)||t.title!==e.title)});e.applyEventsChanges({delete:a.map(e=>e.id),add:l,update:i.map(e=>({id:e.id,updates:e}))})},onEventCreate:t=>{y?(B(t),_(!0)):(e.addEvent(t),F(t.id))},onEventEdit:()=>{},currentWeekStart:te,events:re,calculateNewEventLayout:(e,t,n)=>((e,t,n,r,a)=>{const o=new Date(r),l=new Date(r);o.setHours(Math.floor(t),t%1*60,0,0),l.setHours(Math.floor(n),n%1*60,0,0);const i=[...a,{id:"-1",title:"Temp",day:0,start:Z(o),end:Z(l),calendarId:"blue",allDay:!1}];return Ia.calculateDayEventLayouts(i,{viewType:"day"}).get("-1")||null})(0,t,n,q,ae),calculateDragLayout:(e,t,n,r)=>((e,t,n,r,a,o)=>{const l=o.filter(t=>t.id!==e.id),i=new Date(a),s=new Date(i);s.setHours(Math.floor(n),n%1*60,0,0);const d=new Date(i);d.setHours(Math.floor(r),r%1*60,0,0);const c=[...l,Object.assign(Object.assign({},e),{start:Z(s),end:Z(d),day:0})];return 0===c.length?null:Ia.calculateDayEventLayouts(c,{viewType:"day"}).get(e.id)||null})(e,0,n,r,q,ae),TIME_COLUMN_WIDTH:y?48:80,isMobile:y}),{handleDrop:ve,handleDragOver:fe}=Aa({app:e,onEventCreated:e=>{F(e.id)}}),pe=Array.from({length:24},(e,t)=>({hour:t+x,label:ge(t+x)})),ye=g(t=>{const n=new Date(t.getFullYear(),t.getMonth(),t.getDate());e.setCurrentDate(n),K(new Date(n.getFullYear(),n.getMonth(),1))},[e]),be=h(()=>{const e=new Date;e.setHours(0,0,0,0);const t=new Date(q);return t.setHours(0,0,0,0),t.getTime()===e.getTime()},[q]);return c(()=>{I(new Date);const e=setInterval(()=>I(new Date),6e4);return()=>clearInterval(e)},[]),Ge("div",{className:"df-day-view flex h-full bg-gray-50 dark:bg-gray-800",children:[Ge(co,{app:e,currentDate:q,currentWeekStart:te,events:f,currentDayEvents:re,organizedAllDayEvents:le,allDayAreaHeight:ie,timeSlots:pe,eventLayouts:oe,isToday:be,currentTime:M,selectedEventId:L,setSelectedEventId:j,newlyCreatedEventId:Y,setNewlyCreatedEventId:F,detailPanelEventId:A,setDetailPanelEventId:e=>{v?v(e):P(e)},dragState:he,isDragging:me,handleMoveStart:se,handleResizeStart:ce,handleCreateStart:de,handleCreateAllDayEvent:ue,handleTouchStart:(e,t)=>{if(!y&&!b)return;const n=e.touches[0],r=n.clientX,o=n.clientY,l=e.currentTarget;V.current=setTimeout(()=>{var e,n,i;const s=null===(n=null===(e=a.current)||void 0===e?void 0:e.querySelector(".calendar-content"))||void 0===n?void 0:n.getBoundingClientRect();if(!s)return;const d=null===(i=a.current)||void 0===i?void 0:i.querySelector(".calendar-content"),c=d?d.scrollTop:0,u=o-s.top+c;null==de||de({preventDefault:()=>{},stopPropagation:()=>{},touches:[{clientX:r,clientY:o}],changedTouches:[{clientX:r,clientY:o}],target:l,currentTarget:l,cancelable:!0},t,x+u/D)},500)},handleTouchEnd:()=>{V.current&&(clearTimeout(V.current),V.current=null)},handleTouchMove:()=>{V.current&&(clearTimeout(V.current),V.current=null)},handleDragOver:fe,handleDrop:ve,handleEventUpdate:t=>{e.updateEvent(t.id,t)},handleEventDelete:t=>{e.deleteEvent(t)},onDateChange:u,customDetailPanelContent:n,customEventDetailDialog:r,calendarRef:a,allDayRowRef:ee,switcherMode:o,isMobile:y,isTouch:b,setDraftEvent:B,setIsDrawerOpen:_,ALL_DAY_HEIGHT:C,HOUR_HEIGHT:D,FIRST_HOUR:x,LAST_HOUR:E,showAllDay:T,showStartOfDayLabel:N}),Ge(ja,{app:e,currentDate:q,visibleMonth:G,currentDayEvents:re,selectedEvent:$,setSelectedEvent:e=>j(e?e.id:null),handleMonthChange:J,handleDateSelect:ye,switcherMode:o}),Ge(S,{isOpen:z,onClose:()=>{_(!1),B(null)},onSave:t=>{f.find(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),_(!1),B(null)},draftEvent:W,app:e})]})},go={enableDrag:!0,enableResize:!0,enableCreate:!0,showMiniCalendar:!0,showAllDay:!0,scrollToCurrentTime:!0,hourHeight:72,firstHour:0,lastHour:24,dragConfig:{supportedViews:[k.DAY],enableAllDayCreate:!0},eventsConfig:{enableAutoRecalculate:!0,enableValidation:!0}},mo=(e={})=>{const t=Object.assign(Object.assign({},go),e),n=e=>a(ta,{viewType:k.DAY,originalComponent:ho,app:e.app,config:t,className:"day-view-factory",customDetailPanelContent:e.customDetailPanelContent,customEventDetailDialog:e.customEventDetailDialog,calendarRef:e.calendarRef,switcherMode:e.switcherMode,meta:e.meta,selectedEventId:e.selectedEventId,onEventSelect:e.onEventSelect,detailPanelEventId:e.detailPanelEventId,onDetailPanelToggle:e.onDetailPanelToggle});return n.displayName="DayViewAdapter",{type:k.DAY,component:n,config:t}},vo=({app:e,weekDaysLabels:t,mobileWeekDaysLabels:n,weekDates:a,currentWeekStart:o,gridWidth:l,allDayAreaHeight:i,organizedAllDaySegments:d,allDayLabelText:c,isMobile:u,isTouch:h,showAllDay:g=!0,calendarRef:m,allDayRowRef:v,topFrozenContentRef:f,ALL_DAY_HEIGHT:p,HOUR_HEIGHT:y,FIRST_HOUR:b,dragState:w,isDragging:D,handleMoveStart:x,handleResizeStart:E,handleEventUpdate:C,handleEventDelete:T,onDateChange:N,newlyCreatedEventId:S,setNewlyCreatedEventId:M,selectedEventId:I,setSelectedEventId:H,detailPanelEventId:R,setDetailPanelEventId:O,handleCreateAllDayEvent:P,handleDragOver:L,handleDrop:A,customDetailPanelContent:$,customEventDetailDialog:j,events:Y,setDraftEvent:F,setIsDrawerOpen:z})=>{const _={flexShrink:0},[Z,W]=s(null),U=Bn();return Ge("div",{className:`flex flex-none ${g?"border-b border-gray-200 dark:border-gray-700":""} relative z-10`,onContextMenu:e=>e.preventDefault(),children:[g&&Ge("div",{className:"w-12 md:w-20 shrink-0 bg-white dark:bg-gray-900 z-20 flex flex-col",onContextMenu:e=>e.preventDefault(),children:[Ge("div",{className:"flex-1 border-b border-gray-200 dark:border-gray-700"}),Ge("div",{className:"flex items-center justify-end p-1 text-[10px] md:text-xs font-medium text-gray-500 dark:text-gray-400 select-none",style:{minHeight:`${i}px`},children:c})]}),Ge("div",{className:"flex-1 overflow-x-hidden overflow-y-auto relative",style:{scrollbarGutter:"stable"},children:Ge("div",{ref:f,className:"flex flex-col",style:{width:l,minWidth:"100%"},children:[Ge("div",{className:"df-week-header flex border-b border-gray-200 dark:border-gray-700",style:{marginRight:U?"-50px":"0px",paddingRight:U?"50px":"0px"},children:t.map((e,t)=>Ge("div",{className:"df-week-day-cell flex flex-1 justify-center items-center text-center text-gray-500 dark:text-gray-400 text-sm p-1 select-none "+(u?"flex-col gap-0":""),style:_,children:Ge(r,u?{children:[Ge("div",{className:"text-[12px] leading-tight text-gray-500 font-medium",children:n[t]}),Ge("div",{className:`${wt} w-7 h-7 text-base font-medium ${a[t].isToday?Lt:""}`,children:a[t].date})]}:{children:[Ge("div",{className:"inline-flex items-center justify-center text-sm mt-1 mr-1",children:e}),Ge("div",{className:`${wt} ${a[t].isToday?Lt:""}`,children:a[t].date})]})},t))}),g&&Ge("div",{className:`${St} border-none`,ref:v,style:{minHeight:`${i}px`},children:Ge("div",{className:"df-all-day-content flex flex-1 relative",style:{minHeight:`${i}px`},children:[t.map((e,n)=>{const r=new Date(o);return r.setDate(o.getDate()+n),Ge("div",{className:"df-all-day-cell flex-1 border-r border-gray-200 dark:border-gray-700 relative "+(n!==t.length-1||!u&&U?"":"border-r-0"),style:Object.assign({minHeight:`${i}px`},_),onClick:()=>{const e=new Date(o);e.setDate(o.getDate()+n),null==N||N(e)},onMouseDown:e=>null==P?void 0:P(e,n),onDblClick:e=>null==P?void 0:P(e,n),onDragOver:L,onDrop:e=>{A(e,r,void 0,!0)},onContextMenu:e=>((e,t)=>{if(e.preventDefault(),u)return;const n=new Date(o);n.setDate(o.getDate()+t),n.setHours(0,0,0,0),W({x:e.clientX,y:e.clientY,date:n})})(e,n)},`allday-${n}`)}),Ge("div",{className:"absolute inset-0 pointer-events-none",children:d.map(t=>Ge(so,{event:t.event,segment:t,segmentIndex:t.row,isAllDay:!0,isMultiDay:!0,allDayHeight:p,calendarRef:m,isBeingDragged:D&&(null==w?void 0:w.eventId)===t.event.id&&"move"===(null==w?void 0:w.mode),hourHeight:y,firstHour:b,onMoveStart:x,onResizeStart:E,onEventUpdate:C,onEventDelete:T,newlyCreatedEventId:S,onDetailPanelOpen:()=>M(null),selectedEventId:I,detailPanelEventId:R,onEventSelect:t=>{const n=!1!==e.getReadOnlyConfig().viewable,r=e.state.readOnly;if((u||h)&&t&&n&&!r){const e=Y.find(e=>e.id===t);if(e)return F(e),void z(!0)}H(t)},onEventLongPress:e=>{(u||h)&&H(e)},onDetailPanelToggle:e=>O(e),customDetailPanelContent:$,customEventDetailDialog:j,app:e,isMobile:u,enableTouch:h},t.id))})]})})]})}),Z&&Ge(oo,{x:Z.x,y:Z.y,date:Z.date,viewType:k.WEEK,onClose:()=>W(null),app:e,onCreateEvent:()=>{const e=Math.floor((Z.date.getTime()-o.getTime())/864e5);null==P||P({clientX:Z.x,clientY:Z.y},e)}})]})},fo=({app:e,timeSlots:t,weekDaysLabels:n,currentWeekStart:r,currentWeekEvents:a,eventLayouts:o,gridWidth:l,isMobile:i,isTouch:c,scrollerRef:u,timeGridRef:h,leftFrozenContentRef:g,calendarRef:m,handleScroll:v,handleCreateStart:f,handleTouchStart:p,handleTouchEnd:y,handleTouchMove:b,handleDragOver:w,handleDrop:D,dragState:x,isDragging:E,handleMoveStart:C,handleResizeStart:T,handleEventUpdate:N,handleEventDelete:S,onDateChange:M,newlyCreatedEventId:I,setNewlyCreatedEventId:H,selectedEventId:R,setSelectedEventId:O,detailPanelEventId:P,setDetailPanelEventId:L,customDetailPanelContent:A,customEventDetailDialog:$,events:j,setDraftEvent:Y,setIsDrawerOpen:F,isCurrentWeek:z,currentTime:_,HOUR_HEIGHT:Z,FIRST_HOUR:W,LAST_HOUR:U,showStartOfDayLabel:B})=>{const V={flexShrink:0},q=d(e.state.highlightedEventId),[G,K]=s(null),X=Bn();return Ge("div",{className:"flex flex-1 overflow-hidden relative",children:[Ge("div",{className:"w-12 md:w-20 shrink-0 overflow-hidden relative bg-white dark:bg-gray-900 z-10",onContextMenu:e=>e.preventDefault(),children:Ge("div",{ref:g,children:[Ge("div",{className:"h-3 relative",children:Ge("div",{className:"absolute -bottom-1 right-2 text-[10px] md:text-[12px] text-gray-500 dark:text-gray-400 select-none",children:B?ge(W):""})}),t.map((e,t)=>Ge("div",{className:Et,children:Ge("div",{className:`${Ct} text-[10px] md:text-[12px]`,children:B&&0===t?"":e.label})},t)),Ge("div",{className:"relative",children:Ge("div",{className:`${Ct} text-[10px] md:text-[12px]`,children:"00:00"})}),z&&_&&(()=>{const e=_,t=e.getHours()+e.getMinutes()/60;if(t<W||t>U)return null;return Ge("div",{className:"absolute left-0 w-full z-20 pointer-events-none flex items-center justify-end",style:{top:`${(t-W)*Z}px`,transform:"translateY(-50%)",marginTop:"0.75rem"},children:Ge("div",{className:Nt,children:ge(t)})})})()]})}),Ge("div",{ref:u,className:"flex-1 overflow-auto relative calendar-content snap-x snap-mandatory",onScroll:v,children:Ge("div",{className:"flex",style:{width:l,minWidth:"100%"},children:Ge("div",{className:"grow",children:[Ge("div",{className:`${Ft} border-t-0 flex`,children:n.map((e,t)=>Ge("div",{className:`flex-1 relative ${t!==n.length-1||!i&&X?"border-r":""} border-gray-200 dark:border-gray-700`,style:V},`top-${t}`))}),Ge("div",{ref:h,className:"relative",children:[z&&_&&(()=>{const e=_,t=e.getHours()+e.getMinutes()/60;if(t<W||t>U)return null;const r=e.getDay(),a=0===r?6:r-1;return Ge("div",{className:Tt,style:{top:`${(t-W)*Z}px`,width:"100%",height:0,zIndex:20},children:[Ge("div",{className:"flex items-center w-0"}),Ge("div",{className:"flex flex-1",children:n.map((e,t)=>Ge("div",{className:"flex-1 flex items-center",children:Ge("div",{className:"h-0.5 w-full relative "+(t===a?"bg-primary":"bg-primary/30"),style:{zIndex:9999},children:t===a&&0!==a&&Ge("div",{className:"absolute w-2 h-2 bg-primary rounded-full",style:{top:"-3px",left:"-4px"}})})},t))})]})})(),t.map((e,t)=>Ge("div",{className:kt,children:n.map((a,o)=>{const l=new Date(r);return l.setDate(r.getDate()+o),Ge("div",{className:"df-time-grid-cell flex-1 relative border-r border-gray-200 dark:border-gray-700 select-none snap-start "+(o!==n.length-1||!i&&X?"":"border-r-0"),style:V,onClick:()=>{const e=new Date(r);e.setDate(r.getDate()+o),null==M||M(e)},onDblClick:t=>{null==f||f(t,o,e.hour)},onTouchStart:t=>p(t,o,e.hour),onTouchEnd:y,onTouchMove:b,onDragOver:w,onDrop:t=>{D(t,l,e.hour)},onContextMenu:t=>((e,t,n)=>{if(e.preventDefault(),i)return;const a=new Date(r);if(a.setDate(r.getDate()+t),h.current){const t=h.current.getBoundingClientRect(),n=(e.clientY-t.top)/Z+W,r=Math.floor(n),o=Math.floor(60*(n-r)),l=15*Math.round(o/15),i=60===l?r+1:r,s=60===l?0:l;a.setHours(i,s,0,0)}else a.setHours(n,0,0,0);K({x:e.clientX,y:e.clientY,date:a})})(t,o,e.hour)},`${t}-${o}`)})},t)),Ge("div",{className:`${Ft} flex`,children:n.map((e,t)=>Ge("div",{className:`flex-1 relative ${t!==n.length-1||!i&&X?"border-r":""} border-gray-200 dark:border-gray-700`,style:V},`24-${t}`))}),n.map((t,n)=>{const l=Se(n,a),s=[];return l.forEach(e=>{const t=_a(e,r);if(t.length>0){const r=t.find(e=>e.dayIndex===n);r&&s.push({event:e,segmentInfo:Object.assign(Object.assign({},r),{dayIndex:n})})}else s.push({event:e})}),a.forEach(e=>{if(e.allDay||e.day===n)return;const t=_a(e,r).find(e=>e.dayIndex===n);t&&s.push({event:e,segmentInfo:Object.assign(Object.assign({},t),{dayIndex:n})})}),Ge("div",{className:"absolute top-0 pointer-events-none",style:{left:`calc(${100/7*n}%)`,width:100/7+"%",height:"100%"},children:s.map(({event:t,segmentInfo:r})=>{const a=o.get(n),l=null==a?void 0:a.get(t.id);return Ge(so,{event:t,layout:l,calendarRef:m,isBeingDragged:E&&(null==x?void 0:x.eventId)===t.id&&"move"===(null==x?void 0:x.mode),hourHeight:Z,firstHour:W,onMoveStart:C,onResizeStart:T,onEventUpdate:N,onEventDelete:S,newlyCreatedEventId:I,onDetailPanelOpen:()=>H(null),selectedEventId:R,detailPanelEventId:P,onEventSelect:t=>{const n=!1!==e.getReadOnlyConfig().viewable,r=e.state.readOnly;if((i||c)&&t&&n&&!r){const e=j.find(e=>e.id===t);if(e)return Y(e),void F(!0)}O(t),e.state.highlightedEventId&&(e.highlightEvent(null),q.current=null)},onEventLongPress:e=>{(i||c)&&O(e)},onDetailPanelToggle:e=>L(e),customDetailPanelContent:A,customEventDetailDialog:$,multiDaySegmentInfo:r,app:e,isMobile:i,enableTouch:c},r?`${t.id}-seg-${n}`:t.id)})},`events-day-${n}`)})]})]})})}),G&&Ge(oo,{x:G.x,y:G.y,date:G.date,viewType:k.WEEK,onClose:()=>K(null),app:e,onCreateEvent:()=>{if(f){const e=new Date(r);e.setHours(0,0,0,0);const t=new Date(G.date);t.setHours(0,0,0,0);const n=t.getTime()-e.getTime(),a=Math.round(n/864e5),o=G.date.getHours()+G.date.getMinutes()/60,l={preventDefault:()=>{},stopPropagation:()=>{},clientX:G.x,clientY:G.y};f(l,a,o)}}})]})},po=({app:e,config:t,customDetailPanelContent:n,customEventDetailDialog:r,calendarRef:a,selectedEventId:o,onEventSelect:l,onDateChange:i,detailPanelEventId:u,onDetailPanelToggle:g})=>{const{t:m,getWeekDaysLabels:v,locale:f}=In(),p=e.getCurrentDate(),y=e.getEvents(),{screenSize:b}=Sr(),w="desktop"!==b,D="mobile"===b?48:80,x=d(null),[E,C]=s(!1),{HOUR_HEIGHT:T=La.HOUR_HEIGHT,FIRST_HOUR:N=La.FIRST_HOUR,LAST_HOUR:S=La.LAST_HOUR,ALL_DAY_HEIGHT:M=La.ALL_DAY_HEIGHT,showAllDay:I=!0}=t,H=!I;c(()=>{C("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const R=e.getCustomMobileEventRenderer()||Vr,O=h(()=>uo(p),[p]),[P,L]=s(null),[A,$]=s(null),[j,Y]=s(null),F=void 0!==o?o:A,z=void 0!==u?u:j,_=e=>{l?l(e):$(e)},W=e=>{g?g(e):Y(e)},[B,V]=s(null),[q,G]=s(!1),[K,X]=s(null),J=d(null),Q=d(null),ee=d(null),te=d(null),ae=d(null),oe=h(()=>((e,t)=>{const n=new Date(t);return n.setDate(t.getDate()+6),n.setHours(23,59,59,999),e.filter(e=>{const r=U(e.start);r.setHours(0,0,0,0);const a=U(e.end);return a.setHours(23,59,59,999),a>=t&&r<=n}).map(e=>{const n=U(e.start),r=Math.floor((n.getTime()-t.getTime())/864e5),a=Math.max(0,Math.min(6,r));return Object.assign(Object.assign({},e),{day:a})})})(y,O),[y,O]),le=d(e.state.highlightedEventId);c(()=>{if(e.state.highlightedEventId!==le.current)if(e.state.highlightedEventId){_(e.state.highlightedEventId);const t=oe.find(t=>t.id===e.state.highlightedEventId);if(t&&!t.allDay){const e=ne(t.start),n=ee.current;if(n){const t=(e-N)*T;requestAnimationFrame(()=>{n.scrollTo({top:Math.max(0,t-100),behavior:"smooth"})})}}}else _(null);le.current=e.state.highlightedEventId},[e.state.highlightedEventId,oe,N,T]);const ie=h(()=>((e,t)=>{const n=za(e,t).filter(e=>e.event.allDay);n.sort((e,t)=>{if(e.startDayIndex!==t.startDayIndex)return e.startDayIndex-t.startDayIndex;const n=e.endDayIndex-e.startDayIndex;return t.endDayIndex-t.startDayIndex-n});const r=[];return n.forEach(e=>{let t=0,n=!1;for(;!n;)r.some(n=>n.row===t&&!(e.endDayIndex<n.startDayIndex||e.startDayIndex>n.endDayIndex))?t++:n=!0;r.push(Object.assign(Object.assign({},e),{row:t}))}),r})(oe,O),[oe,O]),se=h(()=>{if(0===ie.length)return M;const e=Math.max(...ie.map(e=>e.row));return M+e*M},[ie,M]),de=h(()=>((e,t)=>{const n=new Map;for(let r=0;r<7;r++){const a=[];e.forEach(e=>{if(e.allDay)return;const n=_a(e,t);if(n.length>0){const o=n.find(e=>e.dayIndex===r);if(o){const n=o.endHour>=24?23.99:o.endHour,l=Object.assign(Object.assign({},e),{start:Z(re(Ie(t,r),o.startHour)),end:Z(re(Ie(t,r),n)),day:r});a.push(l)}}else e.day===r&&a.push(e)});const o=Ia.calculateDayEventLayouts(a,{viewType:"week"});n.set(r,o)}return n})(oe,O),[oe,O]),{handleMoveStart:ce,handleCreateStart:ue,handleResizeStart:he,handleCreateAllDayEvent:me,dragState:ve,isDragging:fe}=Pa(e,{calendarRef:a,allDayRowRef:I?Q:void 0,viewType:k.WEEK,onEventsUpdate:(t,n)=>{const r=t(oe),a=new Set(r.map(e=>e.id)),o=oe.filter(e=>!a.has(e.id)),l=new Set(oe.map(e=>e.id)),i=r.filter(e=>!l.has(e.id)),s=r.filter(e=>{if(!l.has(e.id))return!1;const t=oe.find(t=>t.id===e.id);return t&&(U(t.start).getTime()!==U(e.start).getTime()||U(t.end).getTime()!==U(e.end).getTime()||t.day!==e.day||ne(t.start)!==ne(e.start)||ne(t.end)!==ne(e.end)||t.title!==e.title)});e.applyEventsChanges({delete:o.map(e=>e.id),add:i,update:s.map(e=>({id:e.id,updates:e}))},n)},onEventCreate:t=>{w?(X(t),G(!0)):(e.addEvent(t),V(t.id))},onEventEdit:()=>{},currentWeekStart:O,events:oe,calculateNewEventLayout:(e,t,n)=>((e,t,n,r)=>{const a=new Date,o=new Date;a.setHours(Math.floor(t),t%1*60,0,0),o.setHours(Math.floor(n),n%1*60,0,0);const l={id:"-1",title:"Temp",day:e,start:Z(a),end:Z(o),calendarId:"blue",allDay:!1},i=[...r.filter(t=>t.day===e&&!t.allDay),l];return Ia.calculateDayEventLayouts(i,{viewType:"week"}).get("-1")||null})(e,t,n,oe),calculateDragLayout:(e,t,n,r)=>((e,t,n,r,a)=>{const o=a.map(a=>{if(a.id!==e.id)return a;const o=U(a.start),l=re(o,n),i=re(o,r),s=Z(l),d=Z(i);return Object.assign(Object.assign({},a),{day:t,start:s,end:d})}).filter(e=>e.day===t&&!e.allDay);return 0===o.length?null:Ia.calculateDayEventLayouts(o,{viewType:"week"}).get(e.id)||null})(e,t,n,r,oe),TIME_COLUMN_WIDTH:D,isMobile:w}),{handleDrop:pe,handleDragOver:ye}=Aa({app:e,onEventCreated:e=>{V(e.id)}}),be=h(()=>v(f,"short"),[f,v]),we=h(()=>{if(!w)return[];const e=f.split("-")[0].toLowerCase();return"zh"===e||"ja"===e?v(f,"narrow"):be.map(t=>{if("en"===e){if(t.startsWith("Tu"))return"Tu";if(t.startsWith("Th"))return"Th";if(t.startsWith("Sa"))return"Sa";if(t.startsWith("Su"))return"Su"}return t.charAt(0)})},[w,f,v,be]),De=h(()=>m("allDay"),[m]),xe=Array.from({length:24},(e,t)=>({hour:t+N,label:ge(t+N)})),Ee=h(()=>{const e=new Date;return e.setHours(0,0,0,0),be.map((t,n)=>{const r=new Date(O);r.setDate(O.getDate()+n);const a=new Date(r);return a.setHours(0,0,0,0),{date:r.getDate(),month:r.toLocaleString(f,{month:"short"}),fullDate:new Date(r),isToday:a.getTime()===e.getTime()}})},[O,be,f]),Ce=t=>{e.updateEvent(t.id,t)},ke=t=>{e.deleteEvent(t)},Te=h(()=>{const e=new Date,t=uo(e);return O.getTime()===t.getTime()},[O]);c(()=>{L(new Date);const e=setInterval(()=>L(new Date),6e4);return()=>clearInterval(e)},[]);const Ne=w?"175%":"100%";return Ge("div",{className:"df-calendar relative flex flex-col bg-white dark:bg-gray-900 w-full overflow-hidden h-full select-none df-week-view",children:[Ge(Ya,{calendar:e,viewType:k.WEEK,currentDate:p,onPrevious:()=>e.goToPrevious(),onNext:()=>e.goToNext(),onToday:()=>e.goToToday()}),Ge(vo,{app:e,weekDaysLabels:be,mobileWeekDaysLabels:we,weekDates:Ee,currentWeekStart:O,gridWidth:Ne,allDayAreaHeight:se,organizedAllDaySegments:ie,allDayLabelText:De,isMobile:w,isTouch:E,showAllDay:I,calendarRef:a,allDayRowRef:Q,topFrozenContentRef:te,ALL_DAY_HEIGHT:M,HOUR_HEIGHT:T,FIRST_HOUR:N,dragState:ve,isDragging:fe,handleMoveStart:ce,handleResizeStart:he,handleEventUpdate:Ce,handleEventDelete:ke,onDateChange:i,newlyCreatedEventId:B,setNewlyCreatedEventId:V,selectedEventId:F,setSelectedEventId:_,detailPanelEventId:z,setDetailPanelEventId:W,handleCreateAllDayEvent:me,handleDragOver:ye,handleDrop:pe,customDetailPanelContent:n,customEventDetailDialog:r,events:y,setDraftEvent:X,setIsDrawerOpen:G}),Ge(fo,{app:e,timeSlots:xe,weekDaysLabels:be,currentWeekStart:O,currentWeekEvents:oe,eventLayouts:de,gridWidth:Ne,isMobile:w,isTouch:E,scrollerRef:ee,timeGridRef:x,leftFrozenContentRef:ae,calendarRef:a,handleScroll:e=>{const{scrollTop:t,scrollLeft:n}=e.currentTarget;te.current&&(te.current.style.transform=`translateX(${-n}px)`),ae.current&&(ae.current.style.transform=`translateY(${-t}px)`)},handleCreateStart:ue,handleTouchStart:(e,t,n)=>{if(!w&&!E)return;const r=e.touches[0],a=r.clientX,o=r.clientY,l=e.currentTarget;J.current=setTimeout(()=>{null==ue||ue({preventDefault:()=>{},stopPropagation:()=>{},touches:[{clientX:a,clientY:o}],changedTouches:[{clientX:a,clientY:o}],target:l,currentTarget:l,cancelable:!0},t,n)},500)},handleTouchEnd:()=>{J.current&&(clearTimeout(J.current),J.current=null)},handleTouchMove:()=>{J.current&&(clearTimeout(J.current),J.current=null)},handleDragOver:ye,handleDrop:pe,dragState:ve,isDragging:fe,handleMoveStart:ce,handleResizeStart:he,handleEventUpdate:Ce,handleEventDelete:ke,onDateChange:i,newlyCreatedEventId:B,setNewlyCreatedEventId:V,selectedEventId:F,setSelectedEventId:_,detailPanelEventId:z,setDetailPanelEventId:W,customDetailPanelContent:n,customEventDetailDialog:r,events:y,setDraftEvent:X,setIsDrawerOpen:G,isCurrentWeek:Te,currentTime:P,HOUR_HEIGHT:T,FIRST_HOUR:N,LAST_HOUR:S,showStartOfDayLabel:H}),Ge(R,{isOpen:q,onClose:()=>{G(!1),X(null)},onSave:t=>{y.find(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),G(!1),X(null)},draftEvent:K,app:e})]})},yo={enableDrag:!0,enableResize:!0,enableCreate:!0,showWeekends:!0,showAllDay:!0,startOfWeek:1,scrollToCurrentTime:!0,hourHeight:72,firstHour:0,lastHour:24,dragConfig:{supportedViews:[k.WEEK],enableAllDayCreate:!0},eventsConfig:{enableAutoRecalculate:!0,enableValidation:!0}},bo=(e={})=>{const t=Object.assign(Object.assign({},yo),e),n=e=>a(ta,{viewType:k.WEEK,originalComponent:po,app:e.app,config:t,className:"week-view-factory",customDetailPanelContent:e.customDetailPanelContent,customEventDetailDialog:e.customEventDetailDialog,calendarRef:e.calendarRef,switcherMode:e.switcherMode,meta:e.meta,selectedEventId:e.selectedEventId,detailPanelEventId:e.detailPanelEventId,onEventSelect:e.onEventSelect,onDetailPanelToggle:e.onDetailPanelToggle});return n.displayName="WeekViewAdapter",{type:k.WEEK,component:n,config:t}},wo=f(({currentMonth:t,currentYear:n,newlyCreatedEventId:r,screenSize:a,isScrolling:o,isDragging:l,item:i,weekHeight:u,events:g,dragState:m,calendarRef:v,onEventUpdate:f,onEventDelete:p,onMoveStart:y,onCreateStart:b,onResizeStart:w,onDetailPanelOpen:D,onMoreEventsClick:x,onChangeView:E,onSelectDate:C,selectedEventId:T,onEventSelect:N,onEventLongPress:S,detailPanelEventId:M,onDetailPanelToggle:I,customDetailPanelContent:H,customEventDetailDialog:R,onCalendarDrop:O,onCalendarDragOver:P,app:A,enableTouch:$})=>{const{t:j,locale:Y}=In(),[F,z]=s(!1),_=d(null),Z=d(null),W=d(null),[B,V]=s(null),q=h(()=>{const e=u-33;if(e<=0)return{maxSlots:0,maxSlotsWithMore:0};const t=e-20;return{maxSlots:Math.min(4,Math.floor(e/17)),maxSlotsWithMore:Math.min(4,Math.max(0,Math.floor(t/17)))}},[u]);c(()=>o?(z(!0),_.current&&(clearTimeout(_.current),_.current=null),()=>{_.current&&(clearTimeout(_.current),_.current=null)}):F?(_.current=setTimeout(()=>{z(!1),_.current=null},100),()=>{_.current&&(clearTimeout(_.current),_.current=null)}):void 0,[o,F]);const{weekData:G}=i,K=G.days.find(e=>1===e.day),X=`${u}px`,J=h(()=>za(g,G.startDate),[g,G.startDate]),Q=h(()=>((t,n)=>{const r=[],a=new Date(n);return a.setDate(a.getDate()+6),a.setHours(23,59,59,999),t.forEach(t=>{if(!t.start||!t.end)return void L.warn("Event missing start or end date:",t);const o=U(t.start),l=U(t.end),i=new Date(o);i.setHours(0,0,0,0);const s=new Date(l);s.setHours(0,0,0,0);let d=new Date(s);if(!t.allDay&&0===l.getHours()&&0===l.getMinutes()&&0===l.getSeconds()){const e=l.getTime()-o.getTime();e>0&&e<864e5&&(d=new Date(s),d.setDate(d.getDate()-1))}const c=i.toDateString()!==d.toDateString();if(!c||t.allDay)if(c&&t.allDay){let i=new Date(o);i<n&&(i=new Date(n),i.setHours(0,0,0,0));const s=l>a?a:l;for(;i<=s;){const n=e.PlainDate.from({year:i.getFullYear(),month:i.getMonth()+1,day:i.getDate()});r.push(Object.assign(Object.assign({},t),{start:n,end:n,day:i.getDay()})),i.setDate(i.getDate()+1)}}else r.push(Object.assign(Object.assign({},t),{start:t.start,end:t.end,day:o.getDay()}))}),r})(g,G.startDate),[g,G.startDate]),ee=h(()=>(e=>{const t=[...e].sort((e,t)=>{const n=e.endDayIndex-e.startDayIndex+1,r=t.endDayIndex-t.startDayIndex+1;return e.startDayIndex>t.startDayIndex?1:n!==r?r-n:e.startDayIndex-t.startDayIndex}),n=[];t.forEach(e=>{let t=0,r=!1;for(;!r;)n.some(n=>{var r;const a=Math.abs((null!==(r=n.yPosition)&&void 0!==r?r:0)-t)<16,o=!(e.endDayIndex<n.startDayIndex||e.startDayIndex>n.endDayIndex);return a&&o})?t+=16:r=!0;n.push(Object.assign(Object.assign({},e),{yPosition:t}))});const r=[];return n.forEach(e=>{var t;const n=Math.floor((null!==(t=e.yPosition)&&void 0!==t?t:0)/16);r[n]||(r[n]=[]),r[n].push(e)}),r.forEach(e=>{e.sort((e,t)=>e.startDayIndex-t.startDayIndex)}),r})(J),[J]),te=h(()=>{const e=Array(7).fill(0);return ee.forEach((t,n)=>{t.forEach(t=>{for(let r=t.startDayIndex;r<=t.endDayIndex;r++)e[r]=Math.max(e[r],n+1)})}),e},[ee]),re=h(()=>{const e=Array.from({length:7},()=>new Set);return ee.forEach((t,n)=>{t.forEach(t=>{for(let r=t.startDayIndex;r<=t.endDayIndex;r++)r>=0&&r<7&&e[r].add(n)})}),e},[ee]),ae=h(()=>{const e=ee.flat();for(let t=0;t<G.days.length;t++){const n=G.days[t],r=Q.filter(e=>{if(!e.start||!e.end)return U(e.start).toDateString()===n.date.toDateString();const t=U(e.start),r=U(e.end);if(!e.allDay){if(!(0!==r.getHours()||0!==r.getMinutes()||0!==r.getSeconds())){const e=r.getTime()-t.getTime();if(e>0&&e<864e5)return t.toDateString()===n.date.toDateString()}}return t.toDateString()===n.date.toDateString()||r.toDateString()===n.date.toDateString()}).filter(t=>{if(!t.allDay)return!0;return!e.some(e=>e.originalEventId===t.id)}),a=re[t],o=te[t]-1;let l=0;for(let e=0;e<=o;e++)a.has(e)||l++;if(o+1+Math.max(0,r.length-l)>q.maxSlots)return q.maxSlotsWithMore}return q.maxSlots},[G.days,Q,ee,te,re,q.maxSlots,q.maxSlotsWithMore]),oe=h(()=>Math.max(0,17*ee.length),[ee]),le=(e,o)=>{var i;const s=e.date.toLocaleDateString(Y,{month:Y.startsWith("zh")||Y.startsWith("ja")?"short":"long"})===t&&e.year===n;var d;const c=(e=>[...e].sort((e,t)=>e.allDay!==t.allDay?e.allDay?-1:1:e.allDay&&t.allDay?0:ne(e.start)-ne(t.start)))((d=e.date,Q.filter(e=>{if(!e.start||!e.end)return U(e.start).toDateString()===d.toDateString();const t=U(e.start),n=U(e.end);if(!e.allDay&&0===n.getHours()&&0===n.getMinutes()&&0===n.getSeconds()){const e=n.getTime()-t.getTime();if(e>0&&e<864e5)return t.toDateString()===d.toDateString()}return t.toDateString()===d.toDateString()||n.toDateString()===d.toDateString()}))),u=ee.flat(),h=c.filter(e=>{if(!e.allDay)return!0;return!u.some(t=>t.originalEventId===e.id)}),g=re[o],L=(null!==(i=te[o])&&void 0!==i?i:0)-1,F=[];for(let e=0;e<=L;e++)g.has(e)||F.push(e);const z=h.length,_=Math.max(0,z-F.length),B=Math.max(L+1,0)+_,G=B>q.maxSlots,K=G?q.maxSlotsWithMore:q.maxSlots,J=F.filter(e=>e<K).length,ae=Math.max(0,K-Math.max(L+1,0)),oe=Math.min(z,J+ae),le=h.slice(0,oe),ie=z-oe,se=[];let de=0;const ce=Math.min(K,B);for(let t=0;t<ce;t++)if(g.has(t))se.push(Ge("div",{className:"shrink-0",style:{height:"17px",minHeight:"17px"}},`placeholder-layer-${t}-${e.date.getTime()}`));else if(de<le.length){const e=le[de];se.push(Ge(so,{event:e,isAllDay:!!e.allDay,isMonthView:!0,isBeingDragged:l&&m.eventId===e.id&&"move"===m.mode,calendarRef:v,hourHeight:72,firstHour:0,onEventUpdate:f,onEventDelete:p,onMoveStart:y,onResizeStart:w,onDetailPanelOpen:D,onEventSelect:N,onEventLongPress:S,newlyCreatedEventId:r,selectedEventId:T,detailPanelEventId:M,onDetailPanelToggle:I,customDetailPanelContent:H,customEventDetailDialog:R,app:A,isMobile:"desktop"!==a,enableTouch:$},`${e.id}-${e.day}-${ne(e.start)}-${de}`)),de++}return Ge("div",{className:Qt("df-month-day-cell relative flex flex-col border-r border-gray-200 dark:border-gray-700",s?"text-gray-800 dark:text-gray-100":"text-gray-400 dark:text-gray-600","desktop"!==a&&6===o?"border-r-0":"last:border-r"),style:{height:X},"data-date":(ue=e.date,`${ue.getFullYear()}-${String(ue.getMonth()+1).padStart(2,"0")}-${String(ue.getDate()).padStart(2,"0")}`),onClick:()=>null==C?void 0:C(e.date),onDblClick:t=>null==b?void 0:b(t,e.date),onTouchStart:t=>{if("mobile"!==a&&!$)return;const n=t.touches[0],r=n.clientX,o=n.clientY;W.current={x:r,y:o},Z.current=setTimeout(()=>{null==b||b(t,e.date),Z.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},onTouchMove:e=>{if(Z.current&&W.current){const t=Math.abs(e.touches[0].clientX-W.current.x),n=Math.abs(e.touches[0].clientY-W.current.y);(t>10||n>10)&&(clearTimeout(Z.current),Z.current=null)}},onTouchEnd:()=>{Z.current&&(clearTimeout(Z.current),Z.current=null),W.current=null},onDragOver:P,onDrop:t=>null==O?void 0:O(t,e.date),onContextMenu:t=>((e,t)=>{e.preventDefault(),"mobile"!==a&&V({x:e.clientX,y:e.clientY,date:t})})(t,e.date),children:[Ge("div",{className:"df-month-date-number-container text-right px-2 h-[33px] relative z-20",children:Ge("span",{className:`\n df-month-date-number inline-flex items-center justify-center h-6 min-w-6 rounded-full text-sm font-medium whitespace-nowrap px-1\n ${e.isToday?"bg-primary text-primary-foreground":s?"text-gray-900 dark:text-gray-100":"text-gray-400 dark:text-gray-600"}\n `,children:1===e.day&&"desktop"===a?e.date.toLocaleDateString(Y,{month:"short",day:"numeric"}):e.day})}),Ge("div",{className:"flex-1 overflow-hidden px-1",children:[se,G&&Ge("div",{className:Qt("df-month-more-events text-xs text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 cursor-pointer hover:underline relative z-20 bg-white dark:bg-gray-900","desktop"===a?"text-left font-normal":"text-center font-medium"),onClick:t=>{t.stopPropagation(),x?x(e.date):(null==C||C(e.date),null==E||E(k.DAY))},children:["+",ie,"desktop"===a?` ${j("more")}`:""]})]})]},`day-${e.date.getTime()}`);var ue},ie=h(()=>K?K.date.toLocaleDateString(Y,{month:"long",year:"numeric"}):"",[K,Y]);return Ge("div",{className:"relative select-none border-b border-gray-200 dark:border-gray-700",style:{height:X},children:[K&&Ge("div",{className:`\n df-month-title absolute top-10 left-0 z-30 bg-white/50 dark:bg-gray-900/50 py-2 px-2 duration-300\n ${F?"opacity-100 pointer-events-auto":"opacity-0 pointer-events-none"}\n `,style:{transition:"opacity 0.5s ease",maxWidth:"fit-content"},onContextMenu:e=>e.preventDefault(),children:Ge("span",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:ie})}),Ge("div",{className:"h-full flex flex-col",children:Ge("div",{className:"calendar-week relative h-full",children:[Ge("div",{className:"grid grid-cols-7 h-full",children:G.days.map((e,t)=>le(e,t))}),ee.length>0&&Ge("div",{className:"absolute left-0 right-0 pointer-events-none",style:{top:"33px",height:`${oe}px`,zIndex:10},children:ee.slice(0,ae).map((e,t)=>Ge("div",{className:"absolute inset-0",children:e.map(e=>Ge(so,{event:e.event,isAllDay:!!e.event.allDay,segment:e,segmentIndex:t,isMonthView:!0,isMultiDay:!0,calendarRef:v,hourHeight:72,firstHour:0,onEventUpdate:f,onEventDelete:p,onMoveStart:y,onResizeStart:w,isBeingDragged:l&&m.eventId===e.event.id&&"move"===m.mode,isBeingResized:l&&m.eventId===e.event.id&&"resize"===m.mode,newlyCreatedEventId:r,onDetailPanelOpen:D,selectedEventId:T,onEventSelect:N,onEventLongPress:S,detailPanelEventId:M,onDetailPanelToggle:I,customDetailPanelContent:H,customEventDetailDialog:R,app:A,isMobile:"desktop"!==a,enableTouch:$},e.id))},`layer-${t}`))})]})}),B&&Ge(oo,{x:B.x,y:B.y,date:B.date,viewType:k.MONTH,onClose:()=>V(null),app:A,onCreateEvent:()=>{if(b){const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:B.x,clientY:B.y};b(e,B.date)}}})]})});wo.displayName="WeekComponent";const Do=({app:e,customDetailPanelContent:t,customEventDetailDialog:n,calendarRef:r,selectedEventId:a,onEventSelect:o,detailPanelEventId:l,onDetailPanelToggle:i})=>{const{getWeekDaysLabels:u,getMonthLabels:m,locale:v}=In(),f=e.getCurrentDate(),p=e.getEvents(),y=e.getCalendars().map(e=>e.id+e.colors.lineColor).join("-"),b=d(null),w=h(()=>{const e=b.current;return e&&e.length===p.length&&e.every((e,t)=>e===p[t])?e:(b.current=p,p)},[p]),D=h(()=>{const e=new Map,t=e=>{const t=new Date(e);t.setHours(0,0,0,0);const n=t.getDay(),r=0===n?-6:1-n;return t.setDate(t.getDate()+r),t.setHours(0,0,0,0),t},n=(t,n)=>{const r=e.get(t);r?r.push(n):e.set(t,[n])};return w.forEach(e=>{if(!e.start)return;const r=U(e.start),a=e.end?U(e.end):r,o=new Date(r);o.setHours(0,0,0,0);const l=new Date(a);l.setHours(0,0,0,0);let i=new Date(l);if(!e.allDay){0!==a.getHours()||0!==a.getMinutes()||0!==a.getSeconds()||0!==a.getMilliseconds()||i.setDate(i.getDate()-1)}i<o&&(i=new Date(o));const s=t(o),d=t(i);let c=s.getTime();const u=d.getTime();for(;c<=u;){n(c,e);const t=new Date(c);t.setDate(t.getDate()+7),t.setHours(0,0,0,0),c=t.getTime()}}),e},[w]),{screenSize:x}=Sr(),[E,C]=s(!1);c(()=>{C("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const T=e.getCustomMobileEventRenderer()||Vr,[M,I]=s(119),[H,R]=s(!1),O=d(M),P=d([]),[L,A]=s(null),[$,j]=s(!1),[Y,F]=s(null),[z,_]=s(null),[Z,W]=s(null),B=void 0!==a?a:z,V=void 0!==l?l:Z,q=g(e=>{o?o(e):_(e)},[o]),G=g(e=>{i?i(e):W(e)},[i]),K=d(e.state.highlightedEventId);c(()=>{e.state.highlightedEventId?q(e.state.highlightedEventId):K.current&&q(null),K.current=e.state.highlightedEventId},[e.state.highlightedEventId]);const X=h(()=>{const e=f.getDay(),t=f.getDate()-e+(0===e?-6:1),n=new Date(f);return n.setDate(t),n.setHours(0,0,0,0),n},[f]),{handleMoveStart:J,handleCreateStart:Q,handleResizeStart:ee,dragState:te,isDragging:re}=Pa(e,{calendarRef:r,viewType:k.MONTH,onEventsUpdate:(t,n)=>{const r=t(w),a=new Set(r.map(e=>e.id)),o=w.filter(e=>!a.has(e.id)),l=new Set(w.map(e=>e.id)),i=r.filter(e=>!l.has(e.id)),s=r.filter(e=>{if(!l.has(e.id))return!1;const t=w.find(t=>t.id===e.id);return t&&(U(t.start).getTime()!==U(e.start).getTime()||U(t.end).getTime()!==U(e.end).getTime()||t.day!==e.day||ne(t.start)!==ne(e.start)||ne(t.end)!==ne(e.end)||t.title!==e.title||(null==t?void 0:t.start)!==(null==e?void 0:e.start)||(null==t?void 0:t.end)!==(null==e?void 0:e.end))});e.applyEventsChanges({delete:o.map(e=>e.id),add:i,update:s.map(e=>({id:e.id,updates:e}))},n)},onEventCreate:t=>{"desktop"!==x?(F(t),j(!0)):e.addEvent(t)},onEventEdit:e=>{A(e.id)},currentWeekStart:X,events:w}),{handleDrop:ae,handleDragOver:oe}=Aa({app:e,onEventCreated:e=>{A(e.id)}}),le=h(()=>u(v,"short"),[v,u]),{currentMonth:ie,currentYear:se,isScrolling:de,virtualData:ce,weeksData:ue,scrollElementRef:he,isNavigating:ge,handleScroll:me,handlePreviousMonth:ve,handleNextMonth:fe,handleToday:pe,setScrollTop:ye}=(({currentDate:e,weekHeight:t,onCurrentMonthChange:n,initialWeeksToLoad:r=104,locale:a="en-US",isEnabled:o=!0})=>{const l=d(null),i=g((e,t)=>{const n=new Date(t,e,1),r=a.startsWith("zh")||a.startsWith("ja");return n.toLocaleDateString(a,{month:r?"short":"long"})},[a]),u=h(()=>{const t=new Date(e);return t.setDate(1),t.setHours(0,0,0,0),Ne(t,r)},[e,r]),m=h(()=>{const n=new Date(e);n.setDate(1),n.setHours(0,0,0,0);const r=u.findIndex(e=>e.days.some(e=>e.date.toDateString()===n.toDateString()));return r>0?r*t:0},[u,e,t]),[v,f]=s(m),[p,y]=s(600),[b,w]=s(i(e.getMonth(),e.getFullYear())),[D,x]=s(e.getFullYear()),[E,C]=s(!1),[k,T]=s(u),[M,I]=s(!1),H=d(!1),[R,O]=s(!1),P=d(e),L=d(null),A=d(null),$=d(new S),j=d(0),Y=d(0),F=d(!1),z=g(e=>{e&&(L.current=e)},[]),_=g(e=>{let t=$.current.get(e);return console.log("weekData",t),t||(t=Ce(e),$.current.set(e,t)),t},[]),Z=g((e,n=26)=>{F.current||(F.current=!0,setTimeout(()=>{try{if("future"===e){const e=k[k.length-1],t=[];for(let r=1;r<=n;r++){const n=new Date(e.startDate);n.setDate(n.getDate()+7*r),t.push(_(n))}T(e=>[...e,...t])}else{const e=k[0],r=[];for(let t=n;t>=1;t--){const n=new Date(e.startDate);n.setDate(n.getDate()-7*t),r.push(_(n))}const a=r.length*t;T(e=>[...r,...e]),requestAnimationFrame(()=>{f(e=>e+a),L.current&&(L.current.scrollTop+=a)})}}finally{setTimeout(()=>{F.current=!1},200)}},0))},[k,_,t]),W=h(()=>{const e=k.length*t,n=Math.floor(v/t);let r=Math.max(0,n);r=Math.min(r,Math.max(0,k.length-6));const a=Math.min(k.length-1,r+6-1),o=Math.max(0,r-15),l=Math.min(k.length-1,a+15),i=[];for(let e=o;e<=l;e++)i.push({index:e,weekData:k[e],top:e*t,height:t});return{totalHeight:e,visibleItems:i,displayStartIndex:r}},[v,p,t,k]),U=g(e=>{if(M||E||0===e.length||!R)return;const t=v+p/2,r=e.find(e=>e.top<=t&&e.top+e.height>t)||e[Math.floor(e.length/2)];if(!r)return;const a={};r.weekData.days.forEach(e=>{const t=`${i(e.month,e.year)}-${e.year}`;a[t]=(a[t]||0)+1});let o="",s=0,d=0;Object.entries(a).forEach(([e,t])=>{if(t>d){d=t;const[n,r]=e.split("-");o=n,s=parseInt(r)}}),o&&s&&(l.current?o===l.current.month&&s===l.current.year&&(l.current=null,o===b&&s===D||(w(o),x(s),null==n||n(o,s))):o===b&&s===D||(w(o),x(s),null==n||n(o,s)))},[p,b,D,M,E,n,v,R]),B=g(e=>{const n=performance.now();if(n-j.current<N.SCROLL_THROTTLE)return;j.current=n;const r=e.currentTarget,a=r.scrollTop;Y.current=a,f(a),M||requestAnimationFrame(()=>{const{scrollHeight:e,clientHeight:n}=r;a+n>e-10*t&&!F.current&&Z("future",26),a<10*t&&!F.current&&Z("past",26)}),C(!0),A.current&&clearTimeout(A.current),A.current=setTimeout(()=>{C(!1)},N.SCROLL_DEBOUNCE)},[t,Z,M]),V=g((e,n=!0)=>{if(!L.current)return;I(!0),H.current=!0;const r=()=>{setTimeout(()=>{I(!1),H.current=!1},n?500:200)},a=k.findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(-1!==a){const e=a*t;return L.current.scrollTo({top:e,behavior:n?"smooth":"auto"}),void r()}const o=e.getDay(),l=0===o?6:o-1,i=new Date(e);i.setDate(e.getDate()-l),i.setHours(0,0,0,0);const s=k[0],d=k[k.length-1];let c=0,u=!1,h=!1;i<s.startDate?(c=Math.ceil((s.startDate.getTime()-i.getTime())/6048e5),u=!0):i>d.startDate&&(c=Math.ceil((i.getTime()-d.startDate.getTime())/6048e5),h=!0);const g=Math.min(c+10,52);if(u){const a=[];for(let e=g;e>=1;e--){const t=new Date(s.startDate);t.setDate(t.getDate()-7*e),a.push(_(t))}const o=a.length*t;T(e=>[...a,...e]),requestAnimationFrame(()=>{const l=[...a,...k].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(L.current&&-1!==l){const e=l*t;L.current.scrollTop+=o,f(e=>e+o),setTimeout(()=>{L.current&&L.current.scrollTo({top:e,behavior:n?"smooth":"auto"})},50)}r()})}else if(h){const a=[];for(let e=1;e<=g;e++){const t=new Date(d.startDate);t.setDate(t.getDate()+7*e),a.push(_(t))}T(e=>[...e,...a]),requestAnimationFrame(()=>{const o=[...k,...a].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(L.current&&-1!==o){const e=o*t;L.current.scrollTo({top:e,behavior:n?"smooth":"auto"})}r()})}else r()},[k,t,_]),q=g(()=>{const e=k[W.displayStartIndex].days[0].date,t=new Date(e.getFullYear(),e.getMonth()-1,1);V(t)},[W.displayStartIndex,k,V]),G=g(()=>{const e=k[W.displayStartIndex].days[0].date,t=new Date(e.getFullYear(),e.getMonth()+1,1);V(t)},[W.displayStartIndex,k,V]),K=g(()=>{const e=new Date,r=i(e.getMonth(),e.getFullYear()),a=e.getFullYear(),o=new Date(a,e.getMonth(),1);l.current={month:r,year:a},w(r),x(a),null==n||n(r,a);const s=k.findIndex(e=>e.days.some(e=>e.date.toDateString()===o.toDateString()));if(-1!==s){const e=s*t,n=L.current;n&&(I(!0),H.current=!0,requestAnimationFrame(()=>{f(e),requestAnimationFrame(()=>{n&&(n.scrollTop=e,setTimeout(()=>{H.current=!1,I(!1)},200))})}))}else I(!0),H.current=!0,requestAnimationFrame(()=>{V(o,!0),setTimeout(()=>{H.current=!1,I(!1)},200)})},[k,t,n,V]);return c(()=>{U(W.visibleItems)},[W.visibleItems,U]),c(()=>{const t=P.current,r=t.getMonth(),a=t.getFullYear(),o=e.getMonth(),s=e.getFullYear();if(r!==o||a!==s){const t=6,r=W.displayStartIndex,a=Math.min(k.length-1,r+t-1);let d=!1;for(let t=r;t<=a;t++){const n=k[t];if(n&&n.days.some(t=>t.date.toDateString()===e.toDateString())){d=!0;break}}if(!d){const e=new Date(s,o,1),t=i(o,s);l.current={month:t,year:s},w(t),x(s),null==n||n(t,s),V(e,!0)}}P.current=e},[e,n,V,W,k,i]),c(()=>{const e=L.current;if(!e)return;const t=new ResizeObserver(([e])=>{y(e.contentRect.height)});return t.observe(e),()=>t.disconnect()},[]),c(()=>{const e=L.current;e&&!R&&o&&requestAnimationFrame(()=>{e&&m>0?(e.scrollTop=m,f(m),O(!0)):e&&O(!0)})},[R,m,o]),c(()=>()=>{A.current&&clearTimeout(A.current)},[]),{scrollTop:v,containerHeight:p,currentMonth:b,currentYear:D,isScrolling:E,isNavigating:M,virtualData:W,scrollElementRef:L,handleScroll:B,scrollToDate:V,handlePreviousMonth:q,handleNextMonth:G,handleToday:K,setScrollTop:f,setContainerHeight:y,setCurrentMonth:w,setCurrentYear:x,setIsScrolling:C,cache:$.current,scrollElementRefCallback:z,weeksData:k}})({currentDate:f,weekHeight:M,onCurrentMonthChange:(t,n)=>{const r=v.startsWith("zh")||v.startsWith("ja"),a=m(v,r?"short":"long").indexOf(t);a>=0&&e.setVisibleMonth(new Date(n,a,1))},initialWeeksToLoad:156,locale:v,isEnabled:H}),be=d(0),[we,De]=s(0),xe=h(()=>we-6*M,[we,M]),{visibleWeeks:Ee,startIndex:ke}=h(()=>{const{visibleItems:e,displayStartIndex:t}=ce,n=e.findIndex(e=>e.index===t);if(-1===n)return P.current.length>0?{visibleWeeks:P.current,startIndex:be.current}:{visibleWeeks:[],startIndex:t};const r=e.slice(n,n+8);return r.length>=6&&(P.current=r,be.current=t),{visibleWeeks:r,startIndex:t}},[ce]),Te=h(()=>ke*M,[ke,M]),Se=d(!0),Me=d(!1),Ie=((e,t)=>{const[n,r]=s(e);return c(()=>{const n=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(n)}},[e,t]),n})(ce.displayStartIndex,250);c(()=>{ge&&(Me.current=!0)},[ge]),c(()=>{if(Se.current)return void(Se.current=!1);const t=ue[Ie];if(!t)return;const n=new Date(t.startDate);n.setHours(0,0,0,0);const r=new Date(n);r.setDate(r.getDate()+42+7),e.emitVisibleRange(n,r,Me.current?"navigation":"scroll"),Me.current=!1},[e,ue,Ie]);const He=h(()=>{const e=ce.totalHeight,t=ke*M+16*M+xe;return Math.max(0,e-t)},[ce.totalHeight,ke,M,xe]);c(()=>{const e=he.current;if(!e)return;const t=new ResizeObserver(t=>{for(const n of t){const t=n.contentRect.height;if(De(t),!H&&t>0){const n=Math.max(80,Math.floor(t/6));if(n!==O.current){const t=e.scrollTop;if(t>0){const r=Math.round(t/O.current)*n;e.scrollTop=r,ye(r)}}I(n),O.current=n,requestAnimationFrame(()=>{R(!0)})}}});return t.observe(e),()=>{t.disconnect()}},[he,H,ye]),c(()=>{const e=window.innerHeight-150,t=Math.max(80,Math.floor(e/6));I(t)},[]);const Re=g(t=>{e.updateEvent(t.id,t)},[e]),Oe=g(t=>{e.deleteEvent(t)},[e]),Pe=t=>{e.changeView(t)},Le=g(()=>A(null),[]),Ae=g(t=>{const n=e.getReadOnlyConfig().viewable;if(("desktop"!==x||E)&&t&&n){const e=w.find(e=>e.id===t);if(e)return F(e),void j(!0)}q(t)},[x,E,w,q,e]),$e=g(e=>{("desktop"!==x||E)&&q(e)},[x,E,q]);return Ge("div",{className:ft,children:[Ge(Ya,{calendar:e,viewType:k.MONTH,currentDate:f,customTitle:v.startsWith("zh")||v.startsWith("ja")?`${se}年${ie}`:`${ie} ${se}`,onPrevious:()=>{e.goToPrevious(),ve()},onNext:()=>{e.goToNext(),fe()},onToday:()=>{e.goToToday(),pe()}}),Ge("div",{className:"df-week-header-row sticky top-0 z-10 bg-white dark:bg-gray-900 border-b border-gray-200 dark:border-gray-700",onContextMenu:e=>e.preventDefault(),children:Ge("div",{className:"grid grid-cols-7 px-2",children:le.map((e,t)=>Ge("div",{className:"text-right text-gray-500 dark:text-gray-400 text-sm py-2 pr-2 select-none",children:e},t))})}),Ge("div",{ref:he,className:Dt,style:{scrollSnapType:"y mandatory",overflow:"hidden auto",visibility:H?"visible":"hidden"},onScroll:me,children:[Ge("div",{style:{height:Te}}),Ee.map((a,o)=>{var l;const i=null!==(l=D.get(a.weekData.startDate.getTime()))&&void 0!==l?l:[],s=5===o?Object.assign(Object.assign({},a),{height:a.height+xe}):a;return Ge(wo,{item:s,weekHeight:M,currentMonth:ie,currentYear:se,screenSize:x,isScrolling:de,calendarRef:r,events:i,onEventUpdate:Re,onEventDelete:Oe,onMoveStart:J,onCreateStart:Q,onResizeStart:ee,isDragging:re,dragState:te,newlyCreatedEventId:L,onDetailPanelOpen:Le,onMoreEventsClick:e.onMoreEventsClick,onChangeView:Pe,onSelectDate:e.selectDate,selectedEventId:B,onEventSelect:Ae,onEventLongPress:$e,detailPanelEventId:V,onDetailPanelToggle:G,customDetailPanelContent:t,customEventDetailDialog:n,onCalendarDrop:ae,onCalendarDragOver:oe,calendarSignature:y,app:e,enableTouch:E},`week-${a.weekData.startDate.getTime()}`)}),Ge("div",{style:{height:He}})]}),Ge(T,{isOpen:$,onClose:()=>{j(!1),F(null)},onSave:t=>{w.find(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),j(!1),F(null)},draftEvent:Y,app:e})]})},xo={enableDrag:!0,enableResize:!1,enableCreate:!0,showOtherMonth:!0,weekHeight:120,showWeekNumbers:!1,enableVirtualScroll:!0,initialWeeksToLoad:156,dragConfig:{supportedViews:[k.MONTH],enableAllDayCreate:!1},eventsConfig:{enableAutoRecalculate:!0,enableValidation:!0},virtualScrollConfig:{weekHeight:120,initialWeeksToLoad:156,enableVirtualScroll:!0,enableKeyboardNavigation:!0,supportedViews:[k.MONTH]}},Eo=(e={})=>{const t=Object.assign(Object.assign({},xo),e),n=e=>a(ta,{viewType:k.MONTH,originalComponent:Do,app:e.app,config:t,className:"month-view-factory",customDetailPanelContent:e.customDetailPanelContent,customEventDetailDialog:e.customEventDetailDialog,calendarRef:e.calendarRef,switcherMode:e.switcherMode,meta:e.meta,selectedEventId:e.selectedEventId,detailPanelEventId:e.detailPanelEventId,onEventSelect:e.onEventSelect,onDetailPanelToggle:e.onDetailPanelToggle});return n.displayName="MonthViewAdapter",{type:k.MONTH,component:n,config:t}};const Co=f(({date:e,isToday:t,locale:n,onSelectDate:r,onCreateStart:a,onMoreEventsClick:o,moreCount:l=0,onContextMenu:i})=>{const{t:s}=In(),d=e.getDate(),c=1===d,u=e.toLocaleDateString(n,{month:"short"}).toUpperCase();return Ge("div",{className:`\n relative flex flex-col border-r border-b border-gray-100 dark:border-gray-800\n ${c?"border-l-2 border-l-primary dark:border-l-primary":""}\n overflow-hidden bg-white dark:bg-gray-900 select-none\n `,style:{aspectRatio:"1/1"},onClick:()=>r(e),onDblClick:t=>null==a?void 0:a(t,e),onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),null==i||i(t,e)},"data-date":`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,children:[Ge("div",{className:"flex items-center px-1 py-1 shrink-0 h-6",children:[c&&Ge("span",{className:"text-[9px] font-bold text-primary-foreground bg-primary px-1 py-0.5 rounded-sm leading-none",children:u}),Ge("span",{className:"text-[10px] font-medium ml-auto "+(t?"bg-primary text-primary-foreground rounded-full w-5 h-5 flex items-center justify-center":"text-gray-700 dark:text-gray-300"),children:d})]}),l>0&&Ge("div",{className:"absolute bottom-0.5 left-1 z-20",children:Ge("span",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 cursor-pointer hover:underline",onClick:t=>{t.stopPropagation(),null==o||o(e)},children:["+",l," ",s("more")]})})]})});Co.displayName="YearDayCell";const ko=({segment:e,columnsPerRow:t,isDragging:n,isSelected:a,onMoveStart:o,onResizeStart:l,onEventSelect:i,detailPanelEventId:m,onDetailPanelToggle:f,newlyCreatedEventId:p,onDetailPanelOpen:y,customDetailPanelContent:b,customEventDetailDialog:w,app:D,calendarRef:x})=>{const{event:E,startCellIndex:C,endCellIndex:k,visualRowIndex:T,isFirstSegment:N,isLastSegment:S}=e,M=u(Ve),I=d(null),H=d(null),[R,O]=s(null),[P,L]=s(null),[A,$]=s(!1);c(()=>{if((null==D?void 0:D.state.highlightedEventId)===E.id){$(!0);const e=setTimeout(()=>{$(!1)},300);return()=>{clearTimeout(e),$(!1)}}},[null==D?void 0:D.state.highlightedEventId,E.id]);const j=m===e.id,Y=!(null==D?void 0:D.state.readOnly),F=g(()=>{null==f||f(null),i&&i(null)},[f,i]),z=g(e=>null==D?void 0:D.updateEvent(e.id,e),[D]),_=g(e=>null==D?void 0:D.deleteEvent(e),[D]),Z=h(()=>({event:E,isAllDay:!!E.allDay,onEventUpdate:z,onEventDelete:_,onClose:F}),[E,z,_,F]),W=g(()=>Ge(Ir,{store:M,generatorName:"eventDetailContent",generatorArgs:Z}),[M,Z]),U=h(()=>({event:E,isOpen:j,isAllDay:!!E.allDay,onClose:F,app:D,onEventUpdate:z,onEventDelete:_}),[E,j,F,D,z,_]),B=C/t*100,V=(k-C+1)/t*100,q=E.calendarId||"blue",G=a?ce(q):se(q),K=a?"#fff":de(q),X=ue(q),J=!!E.allDay,Q=J?Fa(E):null,ee=18*T,te=g(()=>{if(!I.current||!(null==x?void 0:x.current))return;const e=x.current.getBoundingClientRect(),t=I.current.getBoundingClientRect(),n=Math.min(window.innerWidth,e.right),r=Math.min(window.innerHeight,e.bottom);requestAnimationFrame(()=>{if(!H.current)return void requestAnimationFrame(()=>{if(!H.current)return;const a=H.current.getBoundingClientRect(),o=a.width||340,l=a.height||240;let i,s;const d=n-t.right,c=t.left-e.left;i=d>=o+20?t.right+10:c>=o+20?t.left-o-10:d>c?Math.max(e.left+10,n-o-10):e.left+10;const u=t.top-l/2+t.height/2,h=Math.max(10,e.top+10),g=r-10;s=u<h?h:u+l>g?Math.max(h,g-l):u,O({top:s,left:i,eventHeight:t.height,eventMiddleY:t.top+t.height/2,isSunday:i<t.left})});const a=H.current.getBoundingClientRect(),o=a.width||340,l=a.height||240;let i,s;const d=n-t.right,c=t.left-e.left;i=d>=o+20?t.right+10:c>=o+20?t.left-o-10:d>c?Math.max(e.left+10,n-o-10):e.left+10;const u=t.top-l/2+t.height/2,h=Math.max(10,e.top+10),g=r-10;s=u<h?h:u+l>g?Math.max(h,g-l):u,O({top:s,left:i,eventHeight:t.height,eventMiddleY:t.top+t.height/2,isSunday:i<t.left})})},[x,R]),ne=()=>{null==f||f(e.id)};c(()=>{p===E.id&&!j&&N&&setTimeout(()=>{ne(),null==y||y()},50)},[p,E.id,j,y,N]),c(()=>{j&&!R&&(O({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>{te()}))},[j,R,te]),c(()=>{if(!j)return;const e=()=>{te()};return window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[j,te]);const re=e=>{const t="left"===e,n=t?N:S;return E.allDay&&n&&l&&Y?Ge("div",{className:`resize-handle absolute ${t?"left-0":"right-0"} top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20`,onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),l(e,E,t?"left":"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}):null};return Ge(r,{children:[Ge("div",{ref:I,className:"df-year-event absolute z-30 text-[12px] px-1 overflow-hidden whitespace-nowrap cursor-pointer transition-colors group",style:{left:`calc(${B}% + 2px)`,top:`${ee}px`,height:"16px",backgroundColor:G,color:K,opacity:1,width:`calc(${V}% - 4px)`,pointerEvents:n?"none":"auto",borderRadius:N&&S?"0.25rem":N?"0.25rem 0 0 0.25rem":S?"0 0.25rem 0.25rem 0":"0",transform:A?"scale(1.05)":"scale(1)",transition:"transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)"},"data-segment-days":k-C+1,"data-event-id":E.id,onMouseDown:e=>{e.stopPropagation(),o&&o(e,E)},onClick:e=>{e.preventDefault(),e.stopPropagation(),i&&i(E.id)},onDblClick:e=>{e.preventDefault(),e.stopPropagation(),ne()},onTouchStart:e=>{e.stopPropagation(),i&&i(E.id),o&&o(e,E)},onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),i&&i(E.id),L({x:e.clientX,y:e.clientY})},title:E.title,children:[re("left"),(()=>{if(E.allDay){const t=()=>e.isFirstSegment?E.title:"···";return Ge("div",{className:"df-year-event-content flex items-center min-w-0 w-full pointer-events-auto h-full",children:[e.isFirstSegment&&Fa(E)&&Ge("div",{className:"df-year-event-icon shrink-0 mr-1",children:Ge("div",{className:"rounded-full p-0.5 text-white flex items-center justify-center",style:{backgroundColor:ue(q),width:"12px",height:"12px"},children:Fa(E)})}),Ge("div",{className:"flex-1 min-w-0",children:Ge("div",{className:"df-year-event-title text-[12px] leading-none whitespace-nowrap overflow-hidden",style:{maskImage:"linear-gradient(to right, black 70%, transparent 100%)",WebkitMaskImage:"linear-gradient(to right, black 70%, transparent 100%)"},children:t()})}),e.isLastSegment&&!e.isFirstSegment&&Ge("div",{className:"shrink-0 ml-1 text-white/80 dark:text-white/90",children:Ge("div",{className:"w-1.5 h-1.5 rounded-full bg-white/60 dark:bg-white/80"})})]})}const t=e.isFirstSegment?E.title:"";return Ge("div",{className:"df-year-event-content w-full h-full flex items-center overflow-hidden gap-1 pointer-events-auto",children:[!J&&Ge("span",{style:{backgroundColor:X},className:"df-year-event-indicator inline-block w-0.75 h-3 shrink-0 rounded-full"}),J&&Q&&Ge("div",{className:"df-year-event-icon shrink-0 flex items-center justify-center opacity-80 scale-75",children:Q}),Ge("span",{className:"df-year-event-title w-full block font-medium whitespace-nowrap overflow-hidden leading-none",style:{maskImage:"linear-gradient(to right, black 70%, transparent 100%)",WebkitMaskImage:"linear-gradient(to right, black 70%, transparent 100%)"},children:t})]})})(),re("right")]}),(()=>{if(!j||!x)return null;if(null==M?void 0:M.isOverridden("eventDetailDialog"))return Ge(Ir,{store:M,generatorName:"eventDetailDialog",generatorArgs:U});if(w){const e=w;if("undefined"==typeof window||"undefined"==typeof document)return null;const t=document.body;return t?v(Ge(e,Object.assign({},U)),t):null}if(!R)return null;const e={event:E,position:R,panelRef:H,isAllDay:!!E.allDay,onClose:F,onEventUpdate:z,onEventDelete:_,eventVisibility:"visible",calendarRef:x,selectedEventElementRef:I};return(null==M?void 0:M.isOverridden("eventDetailContent"))?Ge(Ua,Object.assign({},e,{contentRenderer:W})):b?Ge(Ua,Object.assign({},e,{contentRenderer:b})):Ge(Wa,Object.assign({},e,{app:D}))})(),P&&D&&Ge(lo,{event:E,x:P.x,y:P.y,onClose:()=>L(null),app:D,onDetailPanelToggle:f,detailPanelKey:e.id})]})},To=f(({rowDays:e,events:t,columnsPerRow:n,app:r,calendarRef:a,locale:o,isDragging:l,dragState:i,onMoveStart:d,onResizeStart:c,onCreateStart:u,selectedEventId:g,onEventSelect:m,onMoreEventsClick:v,newlyCreatedEventId:f,onDetailPanelOpen:p,detailPanelEventId:y,onDetailPanelToggle:b,customDetailPanelContent:w,customEventDetailDialog:D})=>{const x=new Date;x.setHours(0,0,0,0);const[E,C]=s(null),T=(e,t)=>{e.preventDefault(),e.stopPropagation(),C({x:e.clientX,y:e.clientY,date:t})},N=h(()=>function(e,t,n){if(0===t.length)return[];const r=t[0],a=t[t.length-1],o=new Date(r.getFullYear(),r.getMonth(),r.getDate()).getTime(),l=new Date(a.getFullYear(),a.getMonth(),a.getDate(),23,59,59,999).getTime(),i=e.filter(e=>{if(!e.start)return!1;const t=U(e.start),n=e.end?U(e.end):t,r=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),a=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime();return r<=l&&a>=o});i.sort((e,t)=>{const n=U(e.start).getTime(),r=e.end?U(e.end).getTime():n,a=U(t.start).getTime(),o=r-n,l=(t.end?U(t.end).getTime():a)-a;return o!==l?l-o:n-a});const s=[],d=[];return i.forEach(e=>{const a=U(e.start),i=e.end?U(e.end):a,c=new Date(a.getFullYear(),a.getMonth(),a.getDate()).getTime(),u=new Date(i.getFullYear(),i.getMonth(),i.getDate()).getTime();let h=-1,g=-1;const m=Math.round((c-o)/864e5);h=m>=0?m:0;const v=Math.round((u-o)/864e5);g=v<t.length?v:t.length-1,h=Math.max(0,Math.min(h,n-1)),g=Math.max(0,Math.min(g,n-1));const f=c>=o,p=u<=l;let y=0;for(;;){let e=!1;d[y]||(d[y]=[]);for(let t=h;t<=g;t++)if(d[y][t]){e=!0;break}if(!e){for(let e=h;e<=g;e++)d[y][e]=!0;break}y++}s.push({id:`${e.id}_${r.getTime()}`,event:e,startCellIndex:h,endCellIndex:g,isFirstSegment:f,isLastSegment:p,visualRowIndex:y})}),s}(t,e,n),[t,e,n]),{visibleSegments:S,moreCounts:M}=h(()=>{const t=new Array(e.length).fill(0);N.forEach(n=>{const r=Math.max(0,n.startCellIndex),a=Math.min(e.length-1,n.endCellIndex);for(let e=r;e<=a;e++)t[e]++});const n=[],r=new Array(e.length).fill(0);return N.forEach(a=>{let o=!0;const l=Math.max(0,a.startCellIndex),i=Math.min(e.length-1,a.endCellIndex);for(let e=l;e<=i;e++){const n=t[e]>3?1:2;if(a.visualRowIndex>n){o=!1;break}}if(o)n.push(a);else for(let e=l;e<=i;e++)r[e]++}),{visibleSegments:n,moreCounts:r}},[N,e.length]);return Ge("div",{className:"relative w-full",style:{display:"grid",gridTemplateColumns:`repeat(${n}, 1fr)`},onContextMenu:e=>e.preventDefault(),children:[e.map((e,t)=>{const n=e.getTime()===x.getTime();return Ge(Co,{date:e,isToday:n,locale:o,onSelectDate:e=>{r.selectDate(e)},onCreateStart:u,onMoreEventsClick:v,moreCount:M[t],onContextMenu:T},e.getTime())}),Ge("div",{className:"absolute inset-0 pointer-events-none",style:{top:26,bottom:0,left:0,right:0},onContextMenu:e=>e.preventDefault(),children:Ge("div",{className:"relative w-full h-full",children:S.map(e=>Ge("div",{className:"pointer-events-auto",children:Ge(ko,{segment:e,columnsPerRow:n,isDragging:l&&i.eventId===e.event.id,isSelected:g===e.event.id,onMoveStart:d,onResizeStart:c,onEventSelect:m,onDetailPanelToggle:b,newlyCreatedEventId:f,onDetailPanelOpen:p,calendarRef:a,app:r,detailPanelEventId:y,customDetailPanelContent:w,customEventDetailDialog:D})},e.id))})}),E&&Ge(oo,{x:E.x,y:E.y,date:E.date,viewType:k.YEAR,onClose:()=>C(null),app:r,onCreateEvent:()=>{if(u){const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:E.x,clientY:E.y};u(e,E.date)}}})]})});To.displayName="YearRowComponent";const No=({app:t,calendarRef:n,customDetailPanelContent:r,customEventDetailDialog:a,config:o,selectedEventId:l,onEventSelect:i,detailPanelEventId:u,onDetailPanelToggle:m})=>{var v;const{t:f,locale:p}=In(),y=t.getCurrentDate(),b=y.getFullYear(),w=t.getEvents(),D=d(null),[x,E]=s(()=>"undefined"!=typeof window?Math.max(1,Math.floor(window.innerWidth/80)):7),[C,T]=s(!1),[N,S]=s(null),[M,I]=s(null),H=void 0!==l?l:N,R=void 0!==u?u:M,O=e=>{i?i(e):S(e)},P=e=>{m?m(e):I(e)},[L,A]=s(null);c(()=>{const e=e=>{const t=e.target,n=t.closest("[data-event-id]"),r=t.closest("[data-event-detail-panel]"),a=t.closest("[data-event-detail-dialog]"),o=t.closest("[data-range-picker-popup]"),l=t.closest("[data-calendar-picker-dropdown]");n||r||a||o||l||(O(null),P(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),c(()=>{const e=D.current;if(!e)return;const t=new ResizeObserver(e=>{const t=e[0].contentRect.width,n=Math.floor(t/80);E(Math.max(1,n)),T(!0)});return t.observe(e),()=>t.disconnect()},[]);const $=d(t.state.highlightedEventId);c(()=>{t.state.highlightedEventId?O(t.state.highlightedEventId):$.current&&O(null),$.current=t.state.highlightedEventId},[t.state.highlightedEventId]);const{handleMoveStart:j,handleResizeStart:Y,handleCreateStart:F,dragState:z,isDragging:_}=Pa(t,{calendarRef:n,viewType:k.YEAR,onEventsUpdate:(e,n)=>{e(w).forEach(e=>{const r=w.find(t=>t.id===e.id);!r||r.start===e.start&&r.end===e.end||t.updateEvent(e.id,e,n)})},currentWeekStart:new Date,events:w,onEventCreate:e=>{t.addEvent(e)},onEventEdit:e=>{A(e.id)}}),Z=null!==(v=null==o?void 0:o.showTimedEventsInYearView)&&void 0!==v&&v,W=g((n,r)=>{if(Z)null==F||F(n,r);else{const n=e.PlainDate.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate()}),a={id:`event-${Date.now()}`,title:f("newEvent")||"New Event",start:n,end:n,allDay:!0};t.addEvent(a),A(a.id)}},[Z,F,t]),B=h(()=>{const e=[],t=new Date(b,0,1),n=new Date(b,11,31),r=new Date(t);for(;r<=n;)e.push(new Date(r)),r.setDate(r.getDate()+1);return e},[b]),V=h(()=>function(e,t){const n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}(B,x),[B,x]),q=h(()=>{const e=new Date(b,0,1),t=new Date(b,11,31,23,59,59);return w.filter(n=>{if(!n.start)return!1;if(!Z&&!n.allDay)return!1;const r=U(n.start),a=n.end?U(n.end):r;return r<=t&&a>=e})},[w,b,Z]);return Ge("div",{className:ft,onContextMenu:e=>e.preventDefault(),children:[Ge(Ya,{calendar:t,viewType:k.YEAR,currentDate:y,customTitle:p.startsWith("zh")||p.startsWith("ja")?`${b}年`:`${b}`,onPrevious:()=>{const e=new Date(y);e.setFullYear(e.getFullYear()-1),t.setCurrentDate(e)},onNext:()=>{const e=new Date(y);e.setFullYear(e.getFullYear()+1),t.setCurrentDate(e)},onToday:()=>{t.goToToday()}}),Ge("div",{ref:D,className:`${Dt} ${xt}`,style:{overflow:"hidden auto"},children:Ge("div",{className:"w-full flex flex-col border-t border-l border-gray-100 dark:border-gray-800",style:{opacity:C?1:0,transition:"opacity 0.2s ease"},children:V.map((e,o)=>Ge(To,{rowDays:e,events:q,columnsPerRow:x,app:t,calendarRef:n,locale:p,isDragging:_,dragState:z,onMoveStart:j,onResizeStart:Y,onCreateStart:W,selectedEventId:H,onEventSelect:O,onMoreEventsClick:t.onMoreEventsClick,newlyCreatedEventId:L,onDetailPanelOpen:()=>A(null),detailPanelEventId:R,onDetailPanelToggle:P,customDetailPanelContent:r,customEventDetailDialog:a},o))})})]})};function So(e,t,n){const r=new Date(n,t,1),a=new Date(n,t+1,0).getDate(),o=r.getDay(),l=r.getTime(),i=new Date(n,t,a,23,59,59,999).getTime(),s=e.filter(e=>{if(!e.start)return!1;const t=U(e.start),n=e.end?U(e.end):t,r=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),a=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime();return r<=i&&a>=l});s.sort((e,t)=>{const n=U(e.start).getTime(),r=e.end?U(e.end).getTime():n,a=U(t.start).getTime(),o=r-n,l=(t.end?U(t.end).getTime():a)-a;return o!==l?l-o:n-a});const d=[],c=[];s.forEach(e=>{const r=U(e.start),a=e.end?U(e.end):r,s=new Date(Math.max(r.getTime(),l)),u=new Date(Math.min(a.getTime(),i)),h=s.getDate(),g=u.getDate(),m=o+(h-1),v=o+(g-1),f=r.getMonth()===t&&r.getFullYear()===n,p=a.getMonth()===t&&a.getFullYear()===n;let y=0;for(;;){let e=!1;c[y]||(c[y]=[]);for(let t=m;t<=v;t++)if(c[y][t]){e=!0;break}if(!e){for(let e=m;e<=v;e++)c[y][e]=!0;break}y++}d.push({id:`${e.id}_month_${t}`,event:e,startCellIndex:m,endCellIndex:v,isFirstSegment:f,isLastSegment:p,visualRowIndex:y,monthIndex:t})});const u=d.length>0?Math.max(...d.map(e=>e.visualRowIndex)):-1;return{segments:d,maxVisualRow:u}}const Mo=({app:t,calendarRef:n,customDetailPanelContent:r,customEventDetailDialog:a,config:o,selectedEventId:l,onEventSelect:i,detailPanelEventId:u,onDetailPanelToggle:m})=>{var v;const{t:f,locale:p,getWeekDaysLabels:y}=In(),b=t.getCurrentDate(),w=b.getFullYear(),D=t.getEvents(),x=new Date;x.setHours(0,0,0,0);const E=d(null),C=d(null),T=d(null),[N,S]=s(0),[M,I]=s(0),[H,R]=s(null),[O,P]=s(null),L=void 0!==l?l:H,A=void 0!==u?u:O,$=e=>{i?i(e):R(e)},j=e=>{m?m(e):P(e)},[Y,F]=s(null),[z,_]=s(null);c(()=>{const e=e=>{const t=e.target,n=t.closest("[data-event-id]"),r=t.closest("[data-event-detail-panel]"),a=t.closest("[data-event-detail-dialog]"),o=t.closest("[data-range-picker-popup]"),l=t.closest("[data-calendar-picker-dropdown]");n||r||a||o||l||($(null),j(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const Z=h(()=>{let e=0;for(let t=0;t<12;t++){const n=new Date(w,t,1),r=new Date(w,t+1,0).getDate(),a=n.getDay()+r;a>e&&(e=a)}return e},[w]),{handleMoveStart:W,handleResizeStart:B,handleCreateStart:V,dragState:q,isDragging:G}=Pa(t,{calendarRef:n,viewType:k.YEAR,onEventsUpdate:(e,n)=>{e(D).forEach(e=>{const r=D.find(t=>t.id===e.id);!r||r.start===e.start&&r.end===e.end||t.updateEvent(e.id,e,n)})},currentWeekStart:new Date,events:D,onEventCreate:e=>{t.addEvent(e)},onEventEdit:e=>{F(e.id)}}),K=null!==(v=null==o?void 0:o.showTimedEventsInYearView)&&void 0!==v&&v,X=g((n,r)=>{if(K)null==V||V(n,r);else{const n=e.PlainDate.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate()}),a={id:`event-${Date.now()}`,title:f("newEvent")||"New Event",start:n,end:n,allDay:!0};t.addEvent(a),F(a.id)}},[K,V,t]),J=h(()=>{const e=y(p,"short"),t=[e[6],...e.slice(0,6)].map(e=>{if(p.startsWith("zh"))return e.charAt(e.length-1);const t=e.substring(0,2);return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}),n=[];for(let e=0;e<Z;e++)n.push(t[e%7]);return n},[p,y,Z]),Q=h(()=>{const e=new Date(w,0,1),t=new Date(w,11,31,23,59,59);return D.filter(n=>{if(!n.start)return!1;if(!K&&!n.allDay)return!1;const r=U(n.start),a=n.end?U(n.end):r;return r<=t&&a>=e})},[D,w,K]);console.log("yearEvents",Q.length);const ee=h(()=>{const e=[];for(let t=0;t<12;t++){const n=new Date(w,t,1),r=new Date(w,t+1,0).getDate(),a=n.getDay(),o=[];for(let e=0;e<a;e++)o.push(null);for(let e=1;e<=r;e++)o.push(new Date(w,t,e));for(;o.length<Z;)o.push(null);const l=n.toLocaleDateString(p,{month:"short"}),i=l.charAt(0).toUpperCase()+l.slice(1).toLowerCase(),{segments:s,maxVisualRow:d}=So(Q,t,w),c=d+1,u=Math.max(60,20+18*c);e.push({monthIndex:t,monthName:i,days:o,eventSegments:s,minHeight:u})}return e},[w,p,Z,Q]),te=g(e=>{const t=e.currentTarget;E.current&&(E.current.scrollLeft=t.scrollLeft),C.current&&(C.current.scrollTop=t.scrollTop)},[]);c(()=>{const e=()=>{if(T.current){const e=T.current,t=e.offsetHeight-e.clientHeight,n=e.offsetWidth-e.clientWidth;I(e=>e!==t?t:e),S(e=>e!==n?n:e)}},t=T.current;if(!t)return;e();const n=new ResizeObserver(()=>{e()});return n.observe(t),()=>{n.disconnect()}},[ee]);return Ge("div",{className:"h-full bg-white dark:bg-gray-900 overflow-hidden select-none",style:{display:"grid",gridTemplateColumns:"3rem 1fr",gridTemplateRows:"auto auto 1fr"},onContextMenu:e=>e.preventDefault(),children:[Ge("div",{className:"col-span-2",children:Ge(Ya,{calendar:t,viewType:k.YEAR,currentDate:b,customTitle:p.startsWith("zh")||p.startsWith("ja")?`${w}年`:`${w}`,onPrevious:()=>{const e=new Date(b);e.setFullYear(e.getFullYear()-1),t.setCurrentDate(e)},onNext:()=>{const e=new Date(b);e.setFullYear(e.getFullYear()+1),t.setCurrentDate(e)},onToday:()=>{t.goToToday()}})}),Ge("div",{className:"bg-gray-50 dark:bg-gray-900 border-r border-b border-gray-200 dark:border-gray-800 z-30"}),Ge("div",{ref:E,className:"overflow-hidden bg-gray-50 dark:bg-gray-900 border-b border-gray-200 dark:border-gray-800",children:Ge("div",{className:"flex",style:{minWidth:`calc(1352px + ${N}px)`},children:[Ge("div",{className:"grid flex-1",style:{gridTemplateColumns:`repeat(${Z}, minmax(0, 1fr))`,minWidth:"1352px"},children:J.map((e,t)=>{const n=t%7;return Ge("div",{className:"text-center py-2 text-[10px] font-bold tracking-wider border-r border-gray-200 dark:border-gray-700 text-gray-500 dark:text-gray-400 "+(0===n||6===n?"df-year-view-weekend-header":""),children:e},t)})}),N>0&&Ge("div",{className:"shrink-0 bg-gray-50 dark:bg-gray-900",style:{width:`${N}px`}})]})}),Ge("div",{ref:C,className:"overflow-hidden bg-white dark:bg-gray-900 border-r border-gray-200 dark:border-gray-700",children:Ge("div",{className:"flex flex-col min-h-full",children:[ee.map(e=>Ge("div",{className:"flex items-center justify-center border-b border-gray-200 dark:border-gray-700 font-bold text-[10px] text-gray-500 dark:text-gray-400 grow shrink-0",style:{minHeight:`${e.minHeight}px`},children:e.monthName},e.monthIndex)),M>0&&Ge("div",{className:"shrink-0 bg-white dark:bg-gray-900",style:{height:`${M}px`}})]})}),Ge("div",{ref:T,className:`overflow-auto ${xt}`,onScroll:te,children:Ge("div",{className:"flex flex-col min-h-full",style:{minWidth:"1352px"},children:ee.map(e=>Ge("div",{className:"relative grow shrink-0",style:{minHeight:`${e.minHeight}px`},children:[Ge("div",{className:"grid absolute inset-0 z-0",style:{gridTemplateColumns:`repeat(${Z}, minmax(0, 1fr))`},children:e.days.map((e,n)=>{const r=n%7,a=0===r||6===r;if(!e)return Ge("div",{className:"bg-gray-50/80 dark:bg-gray-800/40 border-r border-b border-gray-200 dark:border-gray-700 "+(a?"df-year-view-weekend-cell":"")},`empty-${n}`);const o=(e=>e.getTime()===x.getTime())(e);return Ge("div",{"data-date":`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,className:`\n relative flex items-start justify-end p-0.5 border-r border-b border-gray-200 dark:border-gray-700\n cursor-pointer hover:bg-blue-100 dark:hover:bg-primary/20 transition-colors\n ${a?"bg-blue-50 dark:bg-blue-900/30 df-year-view-weekend-cell":""}\n `,onClick:()=>t.selectDate(e),onDblClick:t=>X(t,e),onContextMenu:t=>((e,t)=>{e.preventDefault(),e.stopPropagation(),_({x:e.clientX,y:e.clientY,date:t})})(t,e),children:Ge("span",{className:`\n text-[10px] font-medium w-5 h-5 flex items-center justify-center rounded-full\n ${o?"bg-primary text-primary-foreground font-bold shadow-sm":"text-gray-700 dark:text-gray-300"}\n `,children:e.getDate()})},e.getTime())})}),e.eventSegments.length>0&&Ge("div",{className:"absolute inset-0 pointer-events-none z-20",style:{top:20},children:Ge("div",{className:"relative w-full h-full",children:e.eventSegments.map(e=>Ge("div",{className:"pointer-events-auto",children:Ge(ko,{segment:e,columnsPerRow:Z,isDragging:G&&q.eventId===e.event.id,isSelected:L===e.event.id,onMoveStart:W,onResizeStart:B,onEventSelect:$,onDetailPanelToggle:j,newlyCreatedEventId:Y,onDetailPanelOpen:()=>F(null),calendarRef:n,app:t,detailPanelEventId:A,customDetailPanelContent:r,customEventDetailDialog:a})},e.id))})})]},e.monthIndex))})}),z&&Ge(oo,{x:z.x,y:z.y,date:z.date,viewType:k.YEAR,onClose:()=>_(null),app:t,onCreateEvent:()=>{const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:z.x,clientY:z.y};X(e,z.date)}})]})},Io=e=>{var t;return Ge("fixed-week"===((null===(t=e.config)||void 0===t?void 0:t.mode)||"year-canvas")?Mo:No,Object.assign({},e))},Ho={enableDrag:!1,enableResize:!1,enableCreate:!1,enableVirtualScroll:!0,showDebugInfo:!1,eventsConfig:{enableAutoRecalculate:!1,enableValidation:!0}},Ro=(e={})=>{const t=Object.assign(Object.assign({},Ho),e);e.mode&&(t.viewConfig=Object.assign(Object.assign({},t.viewConfig),{mode:e.mode}));const n=e=>a(ta,{viewType:k.YEAR,originalComponent:Io,app:e.app,config:t,className:"year-view-factory",customDetailPanelContent:e.customDetailPanelContent,customEventDetailDialog:e.customEventDetailDialog,calendarRef:e.calendarRef,meta:e.meta,selectedEventId:e.selectedEventId,detailPanelEventId:e.detailPanelEventId,onEventSelect:e.onEventSelect,onDetailPanelToggle:e.onDetailPanelToggle});return n.displayName="YearViewAdapter",{type:k.YEAR,component:n,config:t}};function Oo(e){return[mo(null==e?void 0:e.day),bo(null==e?void 0:e.week),Eo(null==e?void 0:e.month)]}const Po={enableAutoRecalculate:!0,enableValidation:!0,defaultEvents:[],maxEventsPerDay:50};function Lo(e={}){const t=Object.assign(Object.assign({},Po),e);let n;const r={getAll:()=>n.getAllEvents(),getById:e=>n.getAllEvents().find(t=>t.id===e),add:e=>{if(t.enableValidation){const t=r.validateEvent(e);if(t.length>0)throw new Error(`Event validation failed: ${t.join(", ")}`)}if(t.maxEventsPerDay&&void 0!==e.day){if(r.getByDay(e.day,n.getCurrentDate()).length>=t.maxEventsPerDay)throw new Error(`Maximum events per day (${t.maxEventsPerDay}) exceeded`)}if(n.addEvent(e),t.enableAutoRecalculate){const e=a(n.getCurrentDate()),t=Ae(n.getAllEvents(),e);n.state.events=t}},update:(e,o)=>{const l=r.getById(e);if(!l)throw new Error(`Event with id ${e} not found`);const i=Object.assign(Object.assign({},l),o);if(t.enableValidation){const e=r.validateEvent(i);if(e.length>0)throw new Error(`Event validation failed: ${e.join(", ")}`)}if(n.updateEvent(e,o),t.enableAutoRecalculate){const e=a(n.getCurrentDate()),t=Ae(n.getAllEvents(),e);n.state.events=t}return n.getAllEvents().find(t=>t.id===e)},delete:e=>{n.deleteEvent(e)},getByDate:e=>n.getAllEvents().filter(t=>{const n=U(t.start);n.setHours(0,0,0,0);const r=new Date(e);return r.setHours(0,0,0,0),n.getTime()===r.getTime()}),getByDateRange:(e,t)=>n.getAllEvents().filter(n=>{const r=U(n.start),a=U(n.end);return r>=e&&r<=t||a>=e&&a<=t||r<=e&&a>=t}),getByDay:(e,t)=>n.getAllEvents().filter(t=>t.day===e),getAllDayEvents:(e,t)=>t.filter(t=>t.day===e&&t.allDay),recalculateEventDays:(e,t)=>Ae(e,t),validateEvent:e=>{const t=[];return e.title&&""!==e.title.trim()||t.push("Event title is required"),e.start||t.push("Event start time is required"),e.end||t.push("Event end time is required"),e.start&&e.end&&!e.allDay&&e.start>=e.end&&t.push("Start time must be before end time"),e.id&&"string"!=typeof e.id&&t.push("Event ID must be a string"),t},filterEvents:(e,t)=>e.filter(t)};function a(e){const t=e.getDay(),n=e.getDate()-t+(0===t?-6:1),r=new Date(e);return r.setDate(n),r.setHours(0,0,0,0),r}return{name:"events",config:t,install:e=>{n=e,L.log("Events plugin installed - providing event management services")},api:r}}export{$r as BlossomColorPicker,Ue as CalendarApp,I as CalendarRegistry,ea as CalendarRenderer,rt as Check,Xe as ChevronRight,at as ChevronsUpDown,Ir as ContentSlot,Ka as ContextMenu,ao as ContextMenuColorPicker,Xa as ContextMenuItem,Qa as ContextMenuLabel,Ja as ContextMenuSeparator,Zr as CreateCalendarDialog,Be as CustomRenderingStore,jr as DefaultColorPicker,T as LAYOUT_CONFIG,$ as LOCALES,Mn as LocaleContext,Hn as LocaleProvider,Wr as MiniCalendar,gt as PanelRightClose,mt as PanelRightOpen,tt as Plus,he as TIME_STEP,N as VIRTUAL_MONTH_SCROLL_CONFIG,k as ViewType,S as WeekDataCache,Q as addDays,bn as buildParseRegExp,Pe as calculateDayIndex,Yt as calendarPickerDropdown,bt as cancelButton,kn as capitalize,hr as clipboardStore,Gn as conditionalTheme,lr as convertDateEvent,ir as convertDateEventWithTimeZone,ar as createAllDayEvent,re as createDateWithHour,mo as createDayView,er as createEvent,Oe as createEventWithDate,Ye as createEventWithRealDate,nr as createEvents,Lo as createEventsPlugin,Eo as createMonthView,Oo as createStandardViews,B as createTemporalWithHour,or as createTimedEvent,tr as createTimezoneEvent,rr as createTimezoneEvents,bo as createWeekView,Ro as createYearView,on as dateToPlainDate,ln as dateToPlainDateTime,sn as dateToZonedDateTime,X as daysBetween,J as daysDifference,Er as downloadICS,A as en,ne as extractHourFromDate,un as extractHourFromTemporal,Wn as formatDate,_n as formatDateConsistent,yr as formatDateToICSTimestamp,me as formatEventTimeRange,pr as formatICSDate,Zn as formatMonthYear,En as formatTemporal,ge as formatTime,Ee as generateDayData,xr as generateICS,Ze as generateUniKey,Ce as generateWeekData,Ne as generateWeekRange,Te as generateWeeksData,Me as getAllDayEventsForDay,O as getCalendarColorsForHex,xe as getCurrentWeekDates,Ie as getDateByDayIndex,sr as getDateObj,$e as getDayIndexByDate,oe as getEndOfDay,K as getEndOfTemporal,se as getEventBgColor,fe as getEventEndHour,de as getEventTextColor,Se as getEventsForDay,je as getEventsForWeek,Cn as getIntlLabel,ue as getLineColor,Nn as getMonthLabels,ke as getMonthYearOfWeek,mn as getPlainDate,cr as getSearchHeaderInfo,ce as getSelectedBgColor,ae as getStartOfDay,G as getStartOfTemporal,_e as getTestEvents,Tn as getWeekDaysLabels,De as getWeekRange,Dn as getZoneId,ur as groupSearchResults,Tr as importICSFile,_ as isDate,We as isDeepEqual,ze as isEventEqual,Le as isEventInWeek,ie as isMultiDayEvent,q as isMultiDayTemporalEvent,tn as isPlainDate,nn as isPlainDateTime,le as isSameDay,V as isSamePlainDate,gn as isSameTemporal,F as isValidLocale,rn as isZonedDateTime,Kn as mergeClasses,pn as mergeFormatTemplate,be as monthNames,Un as normalizeCssWidth,dr as normalizeDate,Y as normalizeLocale,xn as normalizeToZoned,ee as now,fn as pad,wr as parseICS,fr as parseICSDate,wn as parseTemporalString,dn as plainDateTimeToDate,cn as plainDateToDate,Ae as recalculateEventDays,Ra as registerDragImplementation,j as registerLocale,Gr as registerSidebarImplementation,Xn as resolveAppliedTheme,ve as roundToTimeStep,Bn as scrollbarTakesSpace,hn as setHourInTemporal,we as shortMonthNames,_t as sidebarContainer,Zt as sidebarHeader,Ut as sidebarHeaderTitle,Wt as sidebarHeaderToggle,Sn as t,an as temporalToDate,qn as themeClasses,Vn as themeCn,te as today,He as updateEventDateAndDay,Fe as updateEventWithRealDate,Pa as useDragForView,In as useLocale,Xr as useSidebarBridge,pe as weekDays,ye as weekDaysFullName,W as zonedDateTimeToDate};
|
|
1
|
+
import{Temporal as e}from"temporal-polyfill";import{options as t,createContext as n,Fragment as r,h as a,render as o,isValidElement as i,cloneElement as l}from"preact";import{createPortal as s,forwardRef as d,memo as c}from"preact/compat";export{createPortal}from"preact/compat";import{useState as u,useEffect as h,useRef as g,useCallback as m,useMemo as v,useContext as f,useLayoutEffect as p}from"preact/hooks";import{__awaiter as y,__rest as b}from"tslib";import{BlossomColorPicker as w,hexToHsl as D,lightnessToSliderValue as x,DEFAULT_COLORS as E,hslToHex as C}from"@dayflow/blossom-color-picker";const k={code:"en-US",messages:{allDay:"All day",noEvents:"No events for this day",more:"more",eventTitle:"Event Title",dateRange:"Date Range",timeRange:"Time Range",note:"Note",addNotePlaceholder:"Add a note...",setAsAllDay:"Set as All-day",setAsTimed:"Set as Timed Event",delete:"Delete",confirm:"Confirm",cancel:"Cancel",today:"Today",day:"Day",week:"Week",month:"Month",year:"Year",newEvent:"New Event",newAllDayEvent:"New All-day Event",newCalendarEvent:"New {calendarName} Event",newAllDayCalendarEvent:"New {calendarName} All-day Event",save:"Save",deleteCalendar:'Delete "{calendarName}"?',deleteCalendarMessage:'Do you want to delete "{calendarName}" or merge its events into another existing calendar?',merge:"Merge",confirmDeleteTitle:'Are you sure you want to delete the calendar "{calendarName}"?',confirmDeleteMessage:"If you delete this calendar, all events associated with the calendar will also be deleted.",mergeConfirmTitle:'Merge "{sourceName}" with "{targetName}"?',mergeConfirmMessage:'Are you sure you want to merge "{sourceName}" with "{targetName}"? Doing so will move all the events from "{sourceName}" to "{targetName}" and "{sourceName}" will be deleted. This cannot be undone.',expandSidebar:"Expand calendar sidebar",collapseSidebar:"Collapse calendar sidebar",calendars:"Calendars",createCalendar:"Create New Calendar",calendarNamePlaceholder:"e.g. Work",customColor:"Custom Color...",create:"Create",calendarOptions:"Calendar Options",untitled:"Untitled",search:"Search",noResults:"No results found",calendar:"Calendar",starts:"Starts",ends:"Ends",notes:"Notes",titlePlaceholder:"Title",notesPlaceholder:"Notes",editEvent:"Edit Event",viewEvent:"View Event",done:"Done",quickCreateEvent:"Quick Create Event",quickCreatePlaceholder:"Movie at 7pm on Friday",noSuggestions:"Type to create",newCalendar:"New Calendar",refreshAll:"Refresh All",tomorrow:"Tomorrow",importCalendar:"Import Calendar",exportCalendar:"Export Calendar",addSchedule:"Add Schedule",importCalendarMessage:"This calendar contains new events. Please select a target calendar.",ok:"OK",cut:"Cut",copy:"Copy",pasteHere:"Paste Here",eventSummary:"Summary"}},T={en:k};function N(e){const t=e.code.split("-")[0].toLowerCase();T[t]=e}function S(e){const t=e.split("-")[0].toLowerCase();return t in T?t:"en"}function M(e){try{new Intl.DateTimeFormat(e);return!0}catch(e){return!1}}var I;!function(e){e.DAY="day",e.WEEK="week",e.MONTH="month",e.YEAR="year"}(I||(I={}));const H={INDENT_STEP:2,MIN_WIDTH:25,MARGIN_BETWEEN:2,CONTAINER_WIDTH:320,OVERLAP_THRESHOLD:.25,EDGE_MARGIN:3,MAX_LOAD_IMBALANCE:0,REBALANCE_THRESHOLD:2},A={OVERSCAN:6,BUFFER_SIZE:100,MIN_YEAR:1900,MAX_YEAR:2200,SCROLL_THROTTLE:8,SCROLL_DEBOUNCE:150,CACHE_CLEANUP_THRESHOLD:200,MOBILE_WEEK_HEIGHT:80,TABLET_WEEK_HEIGHT:90,WEEK_HEIGHT:119};class O{constructor(e=A.BUFFER_SIZE){this.cache=new Map,this.accessOrder=[],this.maxSize=e}static getKey(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}get(e){const t=O.getKey(e),n=this.cache.get(t);if(n)return this.updateAccessOrder(t),n}set(e,t){const n=O.getKey(e);if(this.cache.size>=this.maxSize){const e=this.accessOrder.shift();void 0!==e&&this.cache.delete(e)}this.cache.set(n,t),this.updateAccessOrder(n)}updateAccessOrder(e){const t=this.accessOrder.indexOf(e);t>-1&&this.accessOrder.splice(t,1),this.accessOrder.push(e)}getSize(){return this.cache.size}clear(){this.cache.clear(),this.accessOrder=[]}}var R;!function(e){e.UTC="UTC",e.NEW_YORK="America/New_York",e.CHICAGO="America/Chicago",e.DENVER="America/Denver",e.LOS_ANGELES="America/Los_Angeles",e.TORONTO="America/Toronto",e.VANCOUVER="America/Vancouver",e.PHOENIX="America/Phoenix",e.ANCHORAGE="America/Anchorage",e.HONOLULU="Pacific/Honolulu",e.MEXICO_CITY="America/Mexico_City",e.WINNIPEG="America/Winnipeg",e.HALIFAX="America/Halifax",e.ST_JOHNS="America/St_Johns",e.DETROIT="America/Detroit",e.MIAMI="America/Miami",e.SEATTLE="America/Los_Angeles",e.ATLANTA="America/New_York",e.DALLAS="America/Chicago",e.HOUSTON="America/Chicago",e.LAS_VEGAS="America/Los_Angeles",e.SAN_FRANCISCO="America/Los_Angeles",e.LONDON="Europe/London",e.PARIS="Europe/Paris",e.BERLIN="Europe/Berlin",e.MADRID="Europe/Madrid",e.ROME="Europe/Rome",e.AMSTERDAM="Europe/Amsterdam",e.ZURICH="Europe/Zurich",e.STOCKHOLM="Europe/Stockholm",e.OSLO="Europe/Oslo",e.COPENHAGEN="Europe/Copenhagen",e.MOSCOW="Europe/Moscow",e.ISTANBUL="Europe/Istanbul",e.DUBLIN="Europe/Dublin",e.LISBON="Europe/Lisbon",e.PRAGUE="Europe/Prague",e.VIENNA="Europe/Vienna",e.WARSAW="Europe/Warsaw",e.BRUSSELS="Europe/Brussels",e.ATHENS="Europe/Athens",e.BUCHAREST="Europe/Bucharest",e.HELSINKI="Europe/Helsinki",e.KYIV="Europe/Kyiv",e.BUDAPEST="Europe/Budapest",e.BELGRADE="Europe/Belgrade",e.LUXEMBOURG="Europe/Luxembourg",e.MONACO="Europe/Monaco",e.REYKJAVIK="Atlantic/Reykjavik",e.TOKYO="Asia/Tokyo",e.SHANGHAI="Asia/Shanghai",e.BEIJING="Asia/Shanghai",e.HONG_KONG="Asia/Hong_Kong",e.TAIPEI="Asia/Taipei",e.SEOUL="Asia/Seoul",e.SINGAPORE="Asia/Singapore",e.HANOI="Asia/Ho_Chi_Minh",e.BANGKOK="Asia/Bangkok",e.JAKARTA="Asia/Jakarta",e.KUALA_LUMPUR="Asia/Kuala_Lumpur",e.MANILA="Asia/Manila",e.DUBAI="Asia/Dubai",e.KOLKATA="Asia/Kolkata",e.MUMBAI="Asia/Kolkata",e.RIYADH="Asia/Riyadh",e.TEHRAN="Asia/Tehran",e.JERUSALEM="Asia/Jerusalem",e.TEL_AVIV="Asia/Tel_Aviv",e.BAGHDAD="Asia/Baghdad",e.DHAKA="Asia/Dhaka",e.KARA_CHI="Asia/Karachi",e.KABUL="Asia/Kabul",e.KATHMANDU="Asia/Kathmandu",e.COLOMBO="Asia/Colombo",e.TASHKENT="Asia/Tashkent",e.ALMATY="Asia/Almaty",e.PHNOM_PENH="Asia/Phnom_Penh",e.VIENTIANE="Asia/Vientiane",e.MUSCAT="Asia/Muscat",e.SYDNEY="Australia/Sydney",e.MELBOURNE="Australia/Melbourne",e.BRISBANE="Australia/Brisbane",e.PERTH="Australia/Perth",e.ADELAIDE="Australia/Adelaide",e.DARWIN="Australia/Darwin",e.HOBART="Australia/Hobart",e.AUCKLAND="Pacific/Auckland",e.FIJI="Pacific/Fiji",e.GUAM="Pacific/Guam",e.NOUMEA="Pacific/Noumea",e.PAGO_PAGO="Pacific/Pago_Pago",e.PORT_MORESBY="Pacific/Port_Moresby",e.SAO_PAULO="America/Sao_Paulo",e.RIO_DE_JANEIRO="America/Sao_Paulo",e.BUENOS_AIRES="America/Argentina/Buenos_Aires",e.SANTIAGO="America/Santiago",e.LIMA="America/Lima",e.BOGOTA="America/Bogota",e.CARACAS="America/Caracas",e.LA_PAZ="America/La_Paz",e.MONTEVIDEO="America/Montevideo",e.QUITO="America/Quito",e.ASUNCION="America/Asuncion",e.GEORGETOWN="America/Guyana",e.CAIRO="Africa/Cairo",e.JOHANNESBURG="Africa/Johannesburg",e.LAGOS="Africa/Lagos",e.NAIROBI="Africa/Nairobi",e.CASABLANCA="Africa/Casablanca",e.ALGIERS="Africa/Algiers",e.TUNIS="Africa/Tunis",e.ADDIS_ABABA="Africa/Addis_Ababa",e.ACCRA="Africa/Accra",e.DAKAR="Africa/Dakar",e.LUANDA="Africa/Luanda",e.ANTANANARIVO="Indian/Antananarivo",e.KINSHASA="Africa/Kinshasa",e.DAR_ES_SALAAM="Africa/Dar_es_Salaam",e.MCMURDO="Antarctica/McMurdo",e.CASEY="Antarctica/Casey"}(R||(R={}));const P=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],L=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],$=["January","February","March","April","May","June","July","August","September","October","November","December"],j=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Y=(e,t=1)=>{const n=(e.getDay()-t+7)%7,r=new Date(e);r.setDate(e.getDate()-n),r.setHours(0,0,0,0);const a=new Date(r);return a.setDate(r.getDate()+6),a.setHours(23,59,59,999),{monday:r,sunday:a}},F=(e=1)=>{const t=new Date,n=new Date,r=(t.getDay()-e+7)%7;return P.map((e,a)=>{const o=new Date(t);return o.setDate(t.getDate()-r+a),{date:o.getDate(),month:o.toLocaleString("default",{month:"short"}),isToday:o.getDate()===n.getDate()&&o.getMonth()===n.getMonth()&&o.getFullYear()===n.getFullYear()}})};function z(t){var n;if(!t||"object"!=typeof t)return!1;if(t instanceof Date)return!1;if(t instanceof e.PlainDate)return!0;const r=t;return"PlainDate"===(null===(n=r.constructor)||void 0===n?void 0:n.name)||!("hour"in r)&&!("timeZone"in r)&&"year"in r&&"month"in r&&"day"in r}function _(e){return e instanceof Date}function W(t,n=e.Now.timeZoneId()){return e.Instant.fromEpochMilliseconds(t.getTime()).toZonedDateTimeISO(n)}function U(e){if("number"==typeof e.epochMilliseconds)return new Date(e.epochMilliseconds);const t=e;return new Date(t.year,t.month-1,t.day,t.hour,t.minute)}function B(t,n){if(t instanceof Date)return t;if(z(t))return function(t,n=e.Now.timeZoneId()){if("function"==typeof t.toZonedDateTime)try{return U(t.toZonedDateTime({timeZone:n,plainTime:e.PlainTime.from({hour:0,minute:0})}))}catch(e){}return new Date(t.year,t.month-1,t.day)}(t,n);if(t&&"object"==typeof t&&"hour"in t&&!("timeZone"in t)){const e=t;return new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second||0,e.millisecond||0)}return t&&"object"==typeof t&&"year"in t?U(t):new Date(t)}function Z(t,n){const r=Math.floor(n),a=Math.round(60*(n-r));if(z(t))return e.PlainDateTime.from({year:t.year,month:t.month,day:t.day,hour:r,minute:a});if("function"==typeof t.with)return t.with({hour:r,minute:a,second:0,millisecond:0});const o=t;return e.PlainDateTime.from({year:o.year,month:o.month,day:o.day,hour:r,minute:a})}function V(t,n){if(t instanceof Date&&n instanceof Date)return t.toDateString()===n.toDateString();const r=t=>{if(t instanceof Date)return n=t,e.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()});var n;if(z(t))return t;if("function"==typeof t.toPlainDate)return t.toPlainDate();const r=t;return e.PlainDate.from({year:r.year,month:r.month,day:r.day})},a=r(t),o=r(n);return 0===e.PlainDate.compare(a,o)}function G(e,t){return!V(e,t)}function K(t,n=e.Now.timeZoneId()){if("function"==typeof t.toZonedDateTime){return(z(t)?t:t.toPlainDate()).toZonedDateTime({timeZone:n,plainTime:e.PlainTime.from({hour:0,minute:0})})}const r=t;return(z(t)?t:e.PlainDate.from({year:r.year,month:r.month,day:r.day})).toZonedDateTime({timeZone:n,plainTime:e.PlainTime.from({hour:0,minute:0})})}function q(t,n=e.Now.timeZoneId()){if("function"==typeof t.toZonedDateTime){return(z(t)?t:t.toPlainDate()).toZonedDateTime({timeZone:n,plainTime:e.PlainTime.from({hour:23,minute:59,second:59,millisecond:999})})}const r=t;return(z(t)?t:e.PlainDate.from({year:r.year,month:r.month,day:r.day})).toZonedDateTime({timeZone:n,plainTime:e.PlainTime.from({hour:23,minute:59,second:59,millisecond:999})})}function X(t,n){const r=t=>{if(z(t))return t;if("function"==typeof t.toPlainDate)return t.toPlainDate();const n=t;return e.PlainDate.from({year:n.year,month:n.month,day:n.day})},a=r(t),o=r(n);return a.until(o).days}function J(e,t){const n=new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=new Date(t.getFullYear(),t.getMonth(),t.getDate());return Math.round((r.getTime()-n.getTime())/864e5)}function Q(e,t){const n=new Date(e);return n.setDate(n.getDate()+t),n}function ee(t=e.Now.timeZoneId()){return e.Now.zonedDateTimeISO(t)}function te(t=e.Now.timeZoneId()){return e.Now.plainDateISO(t)}const ne=e=>{if(e instanceof Date){return e.getHours()+e.getMinutes()/60}return function(e){var t;if(e instanceof Date)return e.getHours()+e.getMinutes()/60;if(z(e))return 0;if(null===e||"object"!=typeof e||!("hour"in e)||void 0===e.hour)return 0;const n=e;return n.hour+(null!==(t=n.minute)&&void 0!==t?t:0)/60}(e)},re=(e,t)=>{if(e instanceof Date){const n=new Date(e),r=Math.floor(t),a=Math.round(60*(t-r));return n.setHours(r,a,0,0),n}return Z(e,t)},ae=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(0,0,0,0),t}return K(e)},oe=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(23,59,59,999),t}return q(e)},ie=e=>{const t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())),n=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-n);const r=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-r.getTime())/864e5+1)/7)},le=(t,n)=>{if(t instanceof Date&&n instanceof Date)return t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate();return V(t instanceof Date?e.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}):z(t)?t:t.toPlainDate(),n instanceof Date?e.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()}):z(n)?n:n.toPlainDate())},se=(e,t)=>!le(e,t),de=[{id:"blue",name:"Blue",isDefault:!0,colors:{eventColor:"#eff6ff",eventSelectedColor:"rgba(59, 130, 246)",lineColor:"#3b82f6",textColor:"#1e3a8a"},darkColors:{eventColor:"rgba(30, 64, 175, 0.8)",eventSelectedColor:"rgba(30, 58, 138, 1)",lineColor:"#3b82f6",textColor:"#dbeafe"}},{id:"green",name:"Green",isDefault:!0,colors:{eventColor:"#f0fdf4",eventSelectedColor:"rgba(16, 185, 129, 1)",lineColor:"#10b981",textColor:"#064e3b"},darkColors:{eventColor:"rgba(4, 120, 87, 0.8)",eventSelectedColor:"rgba(6, 78, 59, 1)",lineColor:"#10b981",textColor:"#d1fae5"}},{id:"purple",name:"Purple",isDefault:!0,colors:{eventColor:"#faf5ff",eventSelectedColor:"rgba(139, 92, 246, 1)",lineColor:"#8b5cf6",textColor:"#5b21b6"},darkColors:{eventColor:"rgba(109, 40, 217, 0.8)",eventSelectedColor:"rgba(91, 33, 182, 1)",lineColor:"#8b5cf6",textColor:"#ede9fe"}},{id:"yellow",name:"Yellow",isDefault:!0,colors:{eventColor:"#fefce8",eventSelectedColor:"rgba(245, 158, 11, 1)",lineColor:"#f59e0b",textColor:"#78350f"},darkColors:{eventColor:"rgba(180, 83, 9, 0.8)",eventSelectedColor:"rgba(120, 53, 15, 1)",lineColor:"#f59e0b",textColor:"#fef3c7"}},{id:"red",name:"Red",isDefault:!0,colors:{eventColor:"#fef2f2",eventSelectedColor:"rgba(239, 68, 68, 1)",lineColor:"#ef4444",textColor:"#7f1d1d"},darkColors:{eventColor:"rgba(185, 28, 28, 0.8)",eventSelectedColor:"rgba(127, 29, 29, 1)",lineColor:"#ef4444",textColor:"#fee2e2"}},{id:"orange",name:"Orange",isDefault:!0,colors:{eventColor:"#fff7edb3",eventSelectedColor:"rgba(249, 115, 22, 1)",lineColor:"#f97316",textColor:"#7c2d12"},darkColors:{eventColor:"rgba(194, 65, 12, 0.8)",eventSelectedColor:"rgba(124, 45, 18, 1)",lineColor:"#f97316",textColor:"#fed7aa"}},{id:"pink",name:"Pink",isDefault:!0,colors:{eventColor:"#fdf2f8",eventSelectedColor:"rgba(236, 72, 153, 1)",lineColor:"#ec4899",textColor:"#831843"},darkColors:{eventColor:"rgba(190, 24, 93, 0.8)",eventSelectedColor:"rgba(131, 24, 67, 1)",lineColor:"#ec4899",textColor:"#fce7f3"}},{id:"teal",name:"Teal",isDefault:!0,colors:{eventColor:"#f0fdfa",eventSelectedColor:"rgba(20, 184, 166, 1)",lineColor:"#14b8a6",textColor:"#134e4a"},darkColors:{eventColor:"rgba(15, 118, 110, 0.8)",eventSelectedColor:"rgba(19, 78, 74, 1)",lineColor:"#14b8a6",textColor:"#ccfbf1"}},{id:"indigo",name:"Indigo",isDefault:!0,colors:{eventColor:"#eef2ffb3",eventSelectedColor:"rgba(99, 102, 241, 1)",lineColor:"#6366f1",textColor:"#312e81"},darkColors:{eventColor:"rgba(67, 56, 202, 0.8)",eventSelectedColor:"rgba(49, 46, 129, 1)",lineColor:"#6366f1",textColor:"#e0e7ff"}},{id:"gray",name:"Gray",isDefault:!0,colors:{eventColor:"#f9fafbb3",eventSelectedColor:"rgba(107, 114, 128, 1)",lineColor:"#6b7280",textColor:"#1f2937"},darkColors:{eventColor:"rgba(75, 85, 99, 0.8)",eventSelectedColor:"rgba(31, 41, 55, 1)",lineColor:"#6b7280",textColor:"#f3f4f6"}}];class ce{constructor(e,t,n="light"){this.calendars=new Map,this.defaultCalendarId=t||"blue",this.currentTheme=n;const r=e&&e.length>0;e?e.forEach(e=>{this.calendars.set(e.id,e)}):de.forEach(e=>{this.calendars.set(e.id,Object.assign(Object.assign({},e),{isVisible:!r&&e.isVisible}))})}register(e){this.calendars.set(e.id,e)}unregister(e){return this.calendars.delete(e)}get(e){return this.calendars.get(e)}getAll(){return Array.from(this.calendars.values())}getVisible(){return this.getAll().filter(e=>!1!==e.isVisible)}has(e){return this.calendars.has(e)}reorder(e,t){const n=Array.from(this.calendars.entries());if(e<0||e>=n.length||t<0||t>=n.length)return;const[r]=n.splice(e,1);n.splice(t,0,r),this.calendars.clear(),n.forEach(([e,t])=>{this.calendars.set(e,t)})}setVisibility(e,t){const n=this.calendars.get(e);n&&this.calendars.set(e,Object.assign(Object.assign({},n),{isVisible:t}))}setAllVisibility(e){this.calendars.forEach((t,n)=>{this.calendars.set(n,Object.assign(Object.assign({},t),{isVisible:e}))})}updateCalendar(e,t){const n=this.calendars.get(e);n&&this.calendars.set(e,Object.assign(Object.assign({},n),t))}setDefaultCalendar(e){if(!this.has(e))throw new Error(`Calendar type '${e}' does not exist`);this.defaultCalendarId=e}getDefaultCalendarId(){return this.defaultCalendarId}getDefaultCalendar(){const e=this.get(this.defaultCalendarId);return e||this.getAll()[0]}setTheme(e){this.currentTheme=e}getTheme(){return this.currentTheme}resolveColors(e,t){const n=t||this.currentTheme,r=ce.isDarkTheme(n);let a;return e&&(a=this.get(e)),a||(a=this.getDefaultCalendar()),r&&a.darkColors?a.darkColors:a.colors}getSelectedBgColor(e,t){return this.resolveColors(e,t).eventSelectedColor}getLineColor(e,t){return this.resolveColors(e,t).lineColor}getTextColor(e,t){return this.resolveColors(e,t).textColor}static isDarkTheme(e){return"dark"===e||"light"!==e&&(!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-color-scheme: dark)").matches)}static validate(e){const t=[];return e.id||t.push("Calendar type must have an id"),e.name||t.push("Calendar type must have a name"),e.colors?(e.colors.eventColor||t.push("Calendar colors must include eventColor"),e.colors.eventSelectedColor||t.push("Calendar colors must include eventSelectedColor"),e.colors.lineColor||t.push("Calendar colors must include lineColor"),e.colors.textColor||t.push("Calendar colors must include textColor")):t.push("Calendar type must have colors configuration"),t}}let ue=new ce;function he(){return ue}function ge(e){const t=de.find(t=>t.colors.lineColor.toLowerCase()===e.toLowerCase());return t?{colors:t.colors,darkColors:t.darkColors}:{colors:{eventColor:e+"1A",eventSelectedColor:e,lineColor:e,textColor:e},darkColors:{eventColor:e+"CC",eventSelectedColor:e,lineColor:e,textColor:"#ffffff"}}}const me=(e,t)=>(t||he()).resolveColors(e).eventColor,ve=(e,t)=>(t||he()).resolveColors(e).textColor,fe=(e,t)=>(t||he()).resolveColors(e).eventSelectedColor,pe=(e,t)=>(t||he()).resolveColors(e).lineColor,ye=.25,be=(e,t=0,n="24h",r=!0)=>{const a=Math.floor(e),o=t||Math.round(60*(e-a));if("12h"===n){const e=a>=12?"PM":"AM",t=a%12||12;return 0===o?`${t}${r?` ${e}`:""}`:`${t}:${o.toString().padStart(2,"0")}${r?` ${e}`:""}`}return`${a.toString().padStart(2,"0")}:${o.toString().padStart(2,"0")}`},we=e=>{if(!e.end)return 0;const t=ne(e.end);if(e.allDay||!e.start)return t;const n=B(e.start),r=B(e.end);if(!(n.getFullYear()!==r.getFullYear()||n.getMonth()!==r.getMonth()||n.getDate()!==r.getDate()))return t;if(0===t&&0===r.getMinutes()&&0===r.getSeconds()&&0===r.getMilliseconds()){const e=r.getTime()-n.getTime();if(e>0&&e<864e5)return 24}return t},De=(e,t="24h")=>{const n=ne(e.start),r=we(e);return`${be(n,0,t)} - ${be(r,0,t)}`},xe=e=>.25*Math.round(e/.25),Ee=(t,n,r="24h",a=new Date)=>{const o=e.Now.timeZoneId(),i=a.getFullYear(),l=a.getMonth()+1,s=a.getDate();return t.map(t=>{try{const a=t.hour%24,d=e.ZonedDateTime.from({year:i,month:l,day:s,hour:a,minute:0,second:0,timeZone:o}).withTimeZone(n);return be(d.hour,d.minute,r)}catch(e){return""}})},Ce=(e,t=new Date)=>{var n,r;try{return null!==(r=null===(n=new Intl.DateTimeFormat("en",{timeZone:e,timeZoneName:"short"}).formatToParts(t).find(e=>"timeZoneName"===e.type))||void 0===n?void 0:n.value)&&void 0!==r?r:e}catch(t){return e}},ke=e=>{const t=new Date(e),n=t.getDate(),r=t.getMonth(),a=t.getFullYear(),o=new Date;return{date:t,day:n,month:r,year:a,monthName:$[r],shortMonthName:j[r],isToday:o.getDate()===n&&o.getMonth()===r&&o.getFullYear()===a}},Te=e=>{const t={};e.forEach(e=>{const n=`${e.month}-${e.year}`;t[n]=(t[n]||0)+1});let n=0,r="";Object.entries(t).forEach(([e,t])=>{t>n&&(n=t,r=e)});const[a,o]=r.split("-").map(Number);return{month:$[a],monthIndex:a,year:o}},Ne=e=>{const t=[],n=new Date(e);for(let e=0;e<7;e++){const e=new Date(n);t.push(ke(e)),n.setDate(n.getDate()+1)}return{days:t,startDate:new Date(e),monthYear:Te(t)}},Se=(e,t=3)=>{const n=5*t,{monday:r}=Y(e),a=[],o=Math.floor(n/2),i=new Date(r);i.setDate(i.getDate()-7*o);for(let e=0;e<n;e++){const t=new Date(i);t.setDate(t.getDate()+7*e),a.push(Ne(t))}return a};function Me(e,t,n=1){const r=[],a=Math.floor(t/2),o=(e.getDay()-n+7)%7,i=new Date(e);i.setDate(e.getDate()-o),i.setHours(0,0,0,0);const l=new Date(i);l.setDate(l.getDate()-7*a);for(let e=0;e<t;e++){const t=new Date(l);t.setDate(t.getDate()+7*e),r.push(Ne(t))}return r}const Ie=(e,t)=>t.filter(t=>t.day===e&&!t.allDay),He=(e,t,n)=>t.filter(t=>{if(!t.allDay)return!1;if(!n)return t.day===e;const r=new Date(n);r.setDate(n.getDate()+e),r.setHours(0,0,0,0);const a=B(t.start);a.setHours(0,0,0,0);const o=B(t.end);return o.setHours(0,0,0,0),r>=a&&r<=o}),Ae=(e,t)=>{const n=new Date(e);return n.setDate(e.getDate()+t),n},Oe=(t,n,r)=>{const a=Ae(r,n);return Object.assign(Object.assign({},t),{day:n,start:t.allDay?e.PlainDate.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate()}):e.ZonedDateTime.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate(),hour:a.getHours(),minute:a.getMinutes(),timeZone:e.Now.timeZoneId()}),end:t.allDay?e.PlainDate.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate()}):e.ZonedDateTime.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate(),hour:a.getHours(),minute:a.getMinutes(),timeZone:e.Now.timeZoneId()})})},Re=(t,n)=>n?e.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}):e.ZonedDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:t.getHours(),minute:t.getMinutes(),second:t.getSeconds(),millisecond:t.getMilliseconds(),timeZone:e.Now.timeZoneId()}),Pe=(e,t)=>{var n,r;const a=Ae(t,null!==(n=e.day)&&void 0!==n?n:0),o=null!==(r=e.allDay)&&void 0!==r&&r;return Object.assign(Object.assign({},e),{start:Re(a,o),end:Re(a,o)})},Le=(e,t)=>{const n=new Date(e);n.setHours(0,0,0,0);const r=new Date(t);r.setHours(0,0,0,0);const a=n.getTime()-r.getTime();return Math.floor(a/864e5)},$e=(e,t)=>{const n=Le(e,t);return n>=0&&n<=6},je=(e,t)=>e.map(e=>{const n=B(e.start),r=Le(n,t);return Object.assign(Object.assign({},e),{day:r})}),Ye=(e,t)=>{const n=new Date(e);n.setHours(0,0,0,0);const r=new Date(t);r.setHours(0,0,0,0);const a=r.getTime()-n.getTime();return Math.floor(a/864e5)},Fe=(e,t)=>{const n=new Date(t);return n.setDate(t.getDate()+6),n.setHours(23,59,59,999),e.filter(e=>{const r=B(e.start);return r>=t&&r<=n}).map(e=>{const n=Le(B(e.start),t);return Object.assign(Object.assign({},e),{day:n})})},ze=(e,t)=>{var n,r;const a=new Date(t);a.setDate(t.getDate()+(null!==(n=e.day)&&void 0!==n?n:0));const o=null!==(r=e.allDay)&&void 0!==r&&r;return Object.assign(Object.assign({},e),{start:Re(a,o),end:Re(a,o)})},_e=(e,t,n)=>{var r;const a=new Date(n);a.setDate(n.getDate()+t);const o=null!==(r=e.allDay)&&void 0!==r&&r;return Object.assign(Object.assign({},e),{day:t,start:Re(a,o),end:Re(a,o)})},We=(t,n)=>{var r,a;const o=Ae(n,null!==(r=t.day)&&void 0!==r?r:0);if(null!==(a=t.allDay)&&void 0!==a&&a){const n=e.PlainDate.from({year:o.getFullYear(),month:o.getMonth()+1,day:o.getDate()});return Object.assign(Object.assign({},t),{start:n,end:n})}const i=e.PlainDateTime.from({year:o.getFullYear(),month:o.getMonth()+1,day:o.getDate(),hour:o.getHours(),minute:o.getMinutes(),second:o.getSeconds(),millisecond:o.getMilliseconds()});return Object.assign(Object.assign({},t),{start:i,end:i})},Ue=(t,n,r)=>{var a,o;const i=Ae(n,null!==(a=t.day)&&void 0!==a?a:0);if(null!==(o=t.allDay)&&void 0!==o&&o){const n=e.PlainDate.from({year:i.getFullYear(),month:i.getMonth()+1,day:i.getDate()});return Object.assign(Object.assign({},t),{start:n,end:n})}const l=e.ZonedDateTime.from({year:i.getFullYear(),month:i.getMonth()+1,day:i.getDate(),hour:i.getHours(),minute:i.getMinutes(),second:i.getSeconds(),millisecond:i.getMilliseconds(),timeZone:r});return Object.assign(Object.assign({},t),{start:l,end:l})},Be=(e,t)=>e===t||!(!e||!t)&&(e.title===t.title&&e.calendarId===t.calendarId&&(e.description||"")===(t.description||"")&&!!e.allDay==!!t.allDay&&e.start.toString()===t.start.toString()&&e.end.toString()===t.end.toString()),Ze=(e,t)=>B(e.start).getTime()!==B(t.start).getTime()||B(e.end).getTime()!==B(t.end).getTime()||e.title!==t.title||e.day!==t.day||!!e.allDay!=!!t.allDay;function Ve(){const t=new Date,n=t.getDay(),r=new Date(t),a=0===n?-6:1-n;r.setDate(t.getDate()+a),r.setHours(0,0,0,0);return[{id:"15",title:"C-早开始",day:3,startHour:8.5,endHour:10,calendarId:"teal"},{id:"16",title:"D-晚开始",day:3,startHour:9,endHour:10.5,calendarId:"red"},{id:"21",title:"A",day:0,startHour:14,endHour:16,calendarId:"blue"},{id:"22",title:"B",day:0,startHour:14.5,endHour:16,calendarId:"green"},{id:"23",title:"C",day:0,startHour:14.5,endHour:16,calendarId:"purple"},{id:"24",title:"D",day:0,startHour:15,endHour:16,calendarId:"yellow"},{id:"25",title:"E",day:0,startHour:15,endHour:16,calendarId:"red"},{id:"26",title:"F",day:0,startHour:15.5,endHour:16,calendarId:"orange"},{id:"27",title:"G",day:0,startHour:15,endHour:16,calendarId:"pink"},{id:"28",title:"H",day:0,startHour:15.5,endHour:16,calendarId:"teal"},{id:"29",title:"L",day:0,startHour:15.5,endHour:16,calendarId:"teal"},{id:"30",title:"I",day:0,startHour:15.5,endHour:16,calendarId:"blue"},{id:"99",title:"X",day:0,startHour:15.5,endHour:16,calendarId:"blue"},{id:"6",title:"假日",day:0,startHour:0,endHour:0,calendarId:"blue",allDay:!0},{id:"7",title:"研讨会",day:2,startHour:0,endHour:0,calendarId:"green",allDay:!0},{id:"8",title:"团队建设",day:4,startHour:0,endHour:0,calendarId:"purple",allDay:!0},{id:"41",title:"A",day:3,startHour:16,endHour:18.25,calendarId:"blue"},{id:"42",title:"B",day:3,startHour:16.5,endHour:18,calendarId:"green"},{id:"43",title:"C",day:3,startHour:16.75,endHour:17.75,calendarId:"purple"},{id:"44",title:"D",day:3,startHour:17,endHour:19,calendarId:"yellow"},{id:"45",title:"E",day:3,startHour:17.75,endHour:18.75,calendarId:"red"},{id:"46",title:"X",day:2,startHour:15,endHour:15.75,calendarId:"orange"},{id:"47",title:"Y",day:2,startHour:15.5,endHour:19.5,calendarId:"pink"},{id:"48",title:"Z",day:2,startHour:15,endHour:15.75,calendarId:"teal"},{id:"59",title:"Q",day:2,startHour:17,endHour:18,calendarId:"teal"},{id:"60",title:"W",day:2,startHour:15.5,endHour:18,calendarId:"teal"},{id:"31",title:"A",day:6,startHour:14,endHour:16,calendarId:"blue"},{id:"32",title:"B",day:6,startHour:14.5,endHour:16,calendarId:"green"},{id:"33",title:"C",day:6,startHour:14.5,endHour:16,calendarId:"purple"},{id:"34",title:"D",day:6,startHour:15,endHour:16,calendarId:"yellow"},{id:"35",title:"E",day:6,startHour:15.5,endHour:16.5,calendarId:"red"},{id:"36",title:"F",day:6,startHour:16.25,endHour:16.75,calendarId:"orange"},{id:"37",title:"G",day:6,startHour:16,endHour:17.25,calendarId:"pink"},{id:"51",title:"下周会议1",day:1,startHour:9,endHour:10,calendarId:"blue"},{id:"52",title:"下周会议2",day:3,startHour:14,endHour:15,calendarId:"green"},{id:"81",title:"A",day:5,startHour:14,endHour:16,calendarId:"blue"},{id:"82",title:"B",day:5,startHour:14.5,endHour:16,calendarId:"green"},{id:"83",title:"C",day:5,startHour:14.5,endHour:16,calendarId:"purple"},{id:"84",title:"D",day:5,startHour:15,endHour:16,calendarId:"yellow"},{id:"85",title:"E",day:5,startHour:15,endHour:16,calendarId:"red"},{id:"86",title:"F",day:5,startHour:15.75,endHour:17,calendarId:"orange"},{id:"87",title:"G",day:5,startHour:14.75,endHour:17.5,calendarId:"pink"}].map(t=>{const n=new Date(r);if(n.setDate(r.getDate()+t.day),t.allDay)return{id:t.id,title:t.title,start:e.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()}),end:e.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()}),allDay:!0,calendarId:t.calendarId,day:t.day};const a=Math.floor(t.startHour),o=Math.round(60*(t.startHour-a)),i=Math.floor(t.endHour),l=Math.round(60*(t.endHour-i));return{id:t.id,title:t.title,start:e.ZonedDateTime.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate(),hour:a,minute:o,timeZone:e.Now.timeZoneId()}),end:e.ZonedDateTime.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate(),hour:i,minute:l,timeZone:e.Now.timeZoneId()}),allDay:!1,calendarId:t.calendarId,day:t.day}})}function Ge(){return Date.now().toString(36)+Math.random().toString(36).slice(2,8)}function Ke(e,t){if(e===t)return!0;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;const a=e,o=t;for(const e of n)if(!r.includes(e)||!Ke(a[e],o[e]))return!1;return!0}const qe=new class{constructor(){var e,t;this.isDevelopment="production"!==(null===(t=null===(e=globalThis.process)||void 0===e?void 0:e.env)||void 0===t?void 0:t.NODE_ENV)}formatMessage(e,t,...n){if(!this.isDevelopment)return;const r=(new Date).toISOString(),a=`[DayFlow ${e.toUpperCase()}] ${r}:`;switch(e){case"log":console.log(a,t,...n);break;case"warn":console.warn(a,t,...n);break;case"error":console.error(a,t,...n);break;case"debug":console.debug(a,t,...n)}}log(e,...t){this.formatMessage("log",e,...t)}warn(e,...t){this.formatMessage("warn",e,...t)}error(e,...t){this.formatMessage("error",e,...t)}debug(e,...t){this.formatMessage("debug",e,...t)}};class Xe{constructor(e=[]){this.events=new Map,this.isInTransaction=!1,this.pendingChanges=[],e.forEach(e=>this.events.set(e.id,e))}beginTransaction(){this.isInTransaction?console.warn("Transaction already in progress. Nested transactions are not supported."):(this.isInTransaction=!0,this.pendingChanges=[])}endTransaction(){var e;if(!this.isInTransaction)return;const t=Xe.normalizeChanges(this.pendingChanges);this.isInTransaction=!1,this.pendingChanges=[],t.length>0&&(null===(e=this.onEventBatchChange)||void 0===e||e.call(this,t))}createEvent(e){if(this.events.has(e.id))throw new Error(`Event with ID ${e.id} already exists.`);this.events.set(e.id,e),this.emitChange({type:"create",event:e})}updateEvent(e,t){const n=this.events.get(e);if(!n)throw new Error(`Event with id ${e} not found`);const r=Object.assign(Object.assign({},n),t);this.events.set(e,r),this.emitChange({type:"update",before:n,after:r})}deleteEvent(e){const t=this.events.get(e);t&&(this.events.delete(e),this.emitChange({type:"delete",event:t}))}getEvent(e){return this.events.get(e)}getAllEvents(){return Array.from(this.events.values())}emitChange(e){var t;this.isInTransaction?this.pendingChanges.push(e):null===(t=this.onEventChange)||void 0===t||t.call(this,e)}static normalizeChanges(e){const t=new Map;for(const n of e){const e="delete"===n.type?n.event.id:"update"===n.type?n.after.id:n.event.id,r=t.get(e);r?"create"===r.type?"update"===n.type?t.set(e,{type:"create",event:n.after}):"delete"===n.type&&t.delete(e):"update"===r.type?"update"===n.type?t.set(e,{type:"update",before:r.before,after:n.after}):"delete"===n.type&&t.set(e,{type:"delete",event:r.before}):"delete"===r.type&&"create"===n.type&&t.set(e,{type:"update",before:r.event,after:n.event}):t.set(e,n)}return Array.from(t.values())}}class Je{constructor(e){var t,n,r,a,o;this.undoStack=[],this.pendingSnapshot=null,this.pendingChangeSource=null,this.MAX_UNDO_STACK=50,this.subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e)),this.notify=()=>{this.listeners.forEach(e=>e(this))},this.pushToUndo=e=>{this.undoStack.push({type:"events_snapshot",data:e||[...this.state.events]}),this.undoStack.length>this.MAX_UNDO_STACK&&this.undoStack.shift()},this.undo=()=>{if(0===this.undoStack.length)return;const e=this.undoStack.pop();"events_snapshot"===(null==e?void 0:e.type)&&(this.state.events=e.data,this.store=new Xe(this.state.events),this.setupStoreListeners(),this.triggerRender(),this.notify())},this.getReadOnlyConfig=()=>{var e,t;const n=this.state.readOnly;return!0===n?{draggable:!1,viewable:!1}:!1===n?{draggable:!0,viewable:!0}:{draggable:null!==(e=n.draggable)&&void 0!==e&&e,viewable:null!==(t=n.viewable)&&void 0!==t&&t}},this.isInternalEditable=()=>!0!==this.state.readOnly&&"object"!=typeof this.state.readOnly,this.changeView=e=>{var t,n;if(!this.state.views.has(e))throw new Error(`View ${e} is not registered`);this.state.currentView=e,this.state.highlightedEventId=null,null===(n=(t=this.callbacks).onViewChange)||void 0===n||n.call(t,e),this.handleVisibleRangeChange("viewChange"),this.notify()},this.getCurrentView=()=>{const e=this.state.views.get(this.state.currentView);if(!e)throw new Error(`Current view ${this.state.currentView} is not registered`);return e},this.emitVisibleRange=(e,t,n="navigation")=>{var r,a;null===(a=(r=this.callbacks).onVisibleRangeChange)||void 0===a||a.call(r,new Date(e),new Date(t),n)},this.handleVisibleRangeChange=e=>{var t,n,r,a;const o=this.state.views.get(this.state.currentView);switch(null==o?void 0:o.type){case I.DAY:{const t=new Date(this.state.currentDate);t.setHours(0,0,0,0);const n=new Date(t);n.setDate(n.getDate()+1),this.emitVisibleRange(t,n,e);break}case I.WEEK:{const r=null!==(n=null===(t=null==o?void 0:o.config)||void 0===t?void 0:t.startOfWeek)&&void 0!==n?n:1,{monday:a}=Y(this.state.currentDate,r),i=new Date(a),l=new Date(a);l.setDate(l.getDate()+7),this.emitVisibleRange(i,l,e);break}case I.MONTH:{if("navigation"===e)break;const t=new Date(this.state.currentDate.getFullYear(),this.state.currentDate.getMonth(),1),n=null!==(a=null===(r=null==o?void 0:o.config)||void 0===r?void 0:r.startOfWeek)&&void 0!==a?a:1,{monday:i}=Y(t,n),l=new Date(i),s=new Date(i);s.setDate(s.getDate()+42),this.emitVisibleRange(l,s,e);break}case I.YEAR:{const t=new Date(this.state.currentDate.getFullYear(),0,1);t.setHours(0,0,0,0);const n=new Date(this.state.currentDate.getFullYear(),11,31);n.setDate(n.getDate()+1),this.emitVisibleRange(t,n,e);break}}},this.setCurrentDate=e=>{var t,n;this.state.currentDate=new Date(e),null===(n=(t=this.callbacks).onDateChange)||void 0===n||n.call(t,this.state.currentDate),this.setVisibleMonth(this.state.currentDate),this.handleVisibleRangeChange("navigation"),this.notify()},this.getCurrentDate=()=>new Date(this.state.currentDate),this.setVisibleMonth=e=>{var t,n;const r=new Date(e.getFullYear(),e.getMonth(),1);this.visibleMonth.getFullYear()===r.getFullYear()&&this.visibleMonth.getMonth()===r.getMonth()||(this.visibleMonth=r,null===(n=(t=this.callbacks).onVisibleMonthChange)||void 0===n||n.call(t,new Date(this.visibleMonth)),this.notify())},this.getVisibleMonth=()=>new Date(this.visibleMonth),this.goToToday=()=>{this.setCurrentDate(new Date)},this.goToPrevious=()=>{const e=new Date(this.state.currentDate);switch(this.state.currentView){case I.DAY:e.setDate(e.getDate()-1);break;case I.WEEK:e.setDate(e.getDate()-7);break;case I.MONTH:e.setMonth(e.getMonth()-1);break;case I.YEAR:e.setFullYear(e.getFullYear()-1)}this.setCurrentDate(e)},this.goToNext=()=>{const e=new Date(this.state.currentDate);switch(this.state.currentView){case I.DAY:e.setDate(e.getDate()+1);break;case I.WEEK:e.setDate(e.getDate()+7);break;case I.MONTH:e.setMonth(e.getMonth()+1);break;case I.YEAR:e.setFullYear(e.getFullYear()+1)}this.setCurrentDate(e)},this.selectDate=e=>{var t,n;this.setCurrentDate(e),null===(n=(t=this.callbacks).onDateChange)||void 0===n||n.call(t,new Date(e))},this.applyEventsChanges=(e,t,n)=>{if(this.isInternalEditable()||t){if(t?this.pendingSnapshot||(this.pendingSnapshot=[...this.state.events]):this.pendingSnapshot?(this.pushToUndo(this.pendingSnapshot),this.pendingSnapshot=null):this.pushToUndo(),t){let t=[...this.state.events];if(e.delete){const n=new Set(e.delete);t=t.filter(e=>!n.has(e.id))}return e.update&&e.update.forEach(({id:e,updates:n})=>{const r=t.findIndex(t=>t.id===e);-1!==r&&(t[r]=Object.assign(Object.assign({},t[r]),n))}),e.add&&(t=[...t,...e.add]),this.state.events=t,void this.notify()}n&&(this.pendingChangeSource=n),this.store.beginTransaction(),e.delete&&e.delete.forEach(e=>this.store.deleteEvent(e)),e.update&&e.update.forEach(({id:e,updates:t})=>{try{this.store.updateEvent(e,t)}catch(t){console.warn(`Failed to update event ${e}:`,t)}}),e.add&&e.add.forEach(e=>{try{this.store.createEvent(e)}catch(t){console.warn(`Failed to create event ${e.id}:`,t)}}),this.store.endTransaction()}},this.addEvent=e=>{this.isInternalEditable()?(this.pendingSnapshot=null,this.pushToUndo(),this.store.createEvent(e)):qe.warn("Cannot add event in read-only mode")},this.updateEvent=(e,t,n,r)=>{if(this.isInternalEditable()||n){if(this.isInternalEditable()){if(r&&(this.pendingChangeSource=r),n?this.pendingSnapshot||(this.pendingSnapshot=[...this.state.events]):this.pendingSnapshot?(this.pushToUndo(this.pendingSnapshot),this.pendingSnapshot=null):this.pushToUndo(),n){const n=this.state.events.findIndex(t=>t.id===e);if(-1===n)throw new Error(`Event with id ${e} not found`);const r=Object.assign(Object.assign({},this.state.events[n]),t);return this.state.events=[...this.state.events.slice(0,n),r,...this.state.events.slice(n+1)],void this.notify()}this.store.updateEvent(e,t)}}else qe.warn("Cannot update event in read-only mode")},this.deleteEvent=e=>{this.isInternalEditable()?(this.pendingSnapshot=null,this.pushToUndo(),this.store.deleteEvent(e)):qe.warn("Cannot delete event in read-only mode")},this.getAllEvents=()=>[...this.state.events],this.onEventClick=e=>{var t,n;null===(n=(t=this.callbacks).onEventClick)||void 0===n||n.call(t,e)},this.onMoreEventsClick=e=>{var t,n;null===(n=(t=this.callbacks).onMoreEventsClick)||void 0===n||n.call(t,e)},this.highlightEvent=e=>{var t,n;this.state.highlightedEventId!==e&&(this.state.highlightedEventId=e,null===(n=(t=this.callbacks).onRender)||void 0===n||n.call(t),this.notify())},this.selectEvent=e=>{var t,n;this.state.selectedEventId!==e&&(this.state.selectedEventId=e,null===(n=(t=this.callbacks).onRender)||void 0===n||n.call(t),this.notify())},this.dismissUI=()=>{var e,t;null===(t=(e=this.callbacks).onDismissUI)||void 0===t||t.call(e),this.notify()},this.getEvents=()=>{const e=this.getAllEvents(),t=new Set(this.calendarRegistry.getAll().filter(e=>!1!==e.isVisible).map(e=>e.id));return e.filter(e=>!e.calendarId||(!this.calendarRegistry.has(e.calendarId)||t.has(e.calendarId)))},this.getCalendars=()=>this.calendarRegistry.getAll(),this.reorderCalendars=(e,t)=>{var n,r;this.calendarRegistry.reorder(e,t),null===(r=(n=this.callbacks).onRender)||void 0===r||r.call(n),this.notify()},this.setCalendarVisibility=(e,t)=>{var n,r;this.calendarRegistry.setVisibility(e,t),null===(r=(n=this.callbacks).onRender)||void 0===r||r.call(n),this.notify()},this.setAllCalendarsVisibility=e=>{var t,n;this.calendarRegistry.setAllVisibility(e),null===(n=(t=this.callbacks).onRender)||void 0===n||n.call(t),this.notify()},this.updateCalendar=(e,t,n)=>{var r,a,o,i;if(this.calendarRegistry.updateCalendar(e,t),n)return void this.notify();const l=this.calendarRegistry.get(e);l&&(null===(a=(r=this.callbacks).onCalendarUpdate)||void 0===a||a.call(r,l)),null===(i=(o=this.callbacks).onRender)||void 0===i||i.call(o),this.notify()},this.createCalendar=e=>{var t,n,r,a;this.calendarRegistry.register(e),null===(n=(t=this.callbacks).onCalendarCreate)||void 0===n||n.call(t,e),null===(a=(r=this.callbacks).onRender)||void 0===a||a.call(r),this.notify()},this.deleteCalendar=e=>{var t,n,r,a;this.calendarRegistry.unregister(e),null===(n=(t=this.callbacks).onCalendarDelete)||void 0===n||n.call(t,e),null===(a=(r=this.callbacks).onRender)||void 0===a||a.call(r),this.notify()},this.mergeCalendars=(e,t)=>{var n,r;const a=this.store.getAllEvents().filter(t=>t.calendarId===e);this.pushToUndo(),this.store.beginTransaction(),a.forEach(e=>{this.store.updateEvent(e.id,{calendarId:t})}),this.store.endTransaction(),this.deleteCalendar(e),null===(r=(n=this.callbacks).onCalendarMerge)||void 0===r||r.call(n,e,t)},this.getCalendarHeaderConfig=()=>this.useCalendarHeader,this.installPlugin=e=>{this.state.plugins.has(e.name)?qe.warn(`Plugin ${e.name} is already installed`):(this.state.plugins.set(e.name,e),e.install(this))},this.getPlugin=e=>{const t=this.state.plugins.get(e);return null==t?void 0:t.api},this.hasPlugin=e=>this.state.plugins.has(e),this.getPluginConfig=e=>{const t=this.state.plugins.get(e);return(null==t?void 0:t.config)||{}},this.updatePluginConfig=(e,t)=>{const n=this.state.plugins.get(e);n&&(n.config=Object.assign(Object.assign({},n.config),t),this.notify())},this.getViewConfig=e=>{const t=this.state.views.get(e);return(null==t?void 0:t.config)||{}},this.triggerRender=()=>{var e,t;null===(t=(e=this.callbacks).onRender)||void 0===t||t.call(e),this.notify()},this.getCalendarRegistry=()=>this.calendarRegistry,this.getUseEventDetailDialog=()=>this.useEventDetailDialog,this.getCustomMobileEventRenderer=()=>this.customMobileEventRenderer,this.updateConfig=e=>{var t;let n=!1;if(void 0!==e.customMobileEventRenderer&&e.customMobileEventRenderer!==this.customMobileEventRenderer&&(this.customMobileEventRenderer=e.customMobileEventRenderer,n=!0),void 0!==e.useEventDetailDialog&&e.useEventDetailDialog!==this.useEventDetailDialog&&(this.useEventDetailDialog=e.useEventDetailDialog,n=!0),void 0!==e.useCalendarHeader&&e.useCalendarHeader!==this.useCalendarHeader&&(this.useCalendarHeader=e.useCalendarHeader,n=!0),void 0===e.readOnly||Ke(e.readOnly,this.state.readOnly)||(this.state.readOnly=e.readOnly,n=!0),e.callbacks&&(this.callbacks=Object.assign(Object.assign({},this.callbacks),e.callbacks)),void 0!==(null===(t=e.theme)||void 0===t?void 0:t.mode)&&e.theme.mode!==this.getTheme()&&this.setTheme(e.theme.mode),void 0!==e.switcherMode&&e.switcherMode!==this.state.switcherMode&&(this.state.switcherMode=e.switcherMode,n=!0),void 0!==e.locale){const t=Je.resolveLocale(e.locale);Ke(t,this.state.locale)||(this.state.locale=t,n=!0)}n&&(this.triggerRender(),this.notify())},this.setTheme=e=>{var t,n;this.calendarRegistry.setTheme(e),this.themeChangeListeners.forEach(t=>{t(e)}),null===(n=(t=this.callbacks).onRender)||void 0===n||n.call(t),this.notify()},this.getTheme=()=>this.calendarRegistry.getTheme(),this.subscribeThemeChange=e=>(this.themeChangeListeners.add(e),()=>{this.unsubscribeThemeChange(e)}),this.unsubscribeThemeChange=e=>{this.themeChangeListeners.delete(e)},this.state={currentView:e.defaultView||I.WEEK,currentDate:e.initialDate||new Date,events:e.events||[],switcherMode:e.switcherMode||"buttons",plugins:new Map,views:new Map,locale:Je.resolveLocale(e.locale),highlightedEventId:null,selectedEventId:null,readOnly:e.readOnly||!1},this.callbacks=e.callbacks||{},this.themeChangeListeners=new Set,this.listeners=new Set,this.store=new Xe(this.state.events),this.setupStoreListeners(),this.calendarRegistry=new ce(e.calendars,e.defaultCalendar,(null===(t=e.theme)||void 0===t?void 0:t.mode)||"light"),o=this.calendarRegistry,ue=o;const i=this.state.currentDate;this.visibleMonth=new Date(i.getFullYear(),i.getMonth(),1),this.useEventDetailDialog=null!==(n=e.useEventDetailDialog)&&void 0!==n&&n,this.useCalendarHeader=null===(r=e.useCalendarHeader)||void 0===r||r,this.customMobileEventRenderer=e.customMobileEventRenderer,e.views.forEach(e=>{this.state.views.set(e.type,e)}),null===(a=e.plugins)||void 0===a||a.forEach(e=>{this.installPlugin(e)}),this.handleVisibleRangeChange("initial")}setupStoreListeners(){this.store.onEventChange=e=>{var t,n,r,a,o,i;this.state.events=this.store.getAllEvents(),"create"===e.type?null===(n=(t=this.callbacks).onEventCreate)||void 0===n||n.call(t,e.event):"update"===e.type?null===(a=(r=this.callbacks).onEventUpdate)||void 0===a||a.call(r,e.after):"delete"===e.type&&(null===(i=(o=this.callbacks).onEventDelete)||void 0===i||i.call(o,e.event.id)),this.triggerRender(),this.notify()},this.store.onEventBatchChange=e=>{var t,n;this.state.events=this.store.getAllEvents(),"drag"!==this.pendingChangeSource&&"resize"!==this.pendingChangeSource&&(null===(n=(t=this.callbacks).onEventBatchChange)||void 0===n||n.call(t,e)),this.pendingChangeSource=null,this.triggerRender(),this.notify()}}static resolveLocale(e){return e?"string"==typeof e?M(e)?e:"en-US":e&&"object"==typeof e&&!M(e.code)?Object.assign(Object.assign({},e),{code:"en-US"}):e:"en-US"}}var Qe=0;function et(e,n,r,a,o,i){n||(n={});var l,s,d=n;if("ref"in d)for(s in d={},n)"ref"==s?l=n[s]:d[s]=n[s];var c={type:e,props:d,key:r,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Qe,__i:-1,__u:0,__source:o,__self:i};if("function"==typeof e&&(l=e.defaultProps))for(s in l)void 0===d[s]&&(d[s]=l[s]);return t.vnode&&t.vnode(c),c}const tt=t=>{if(!t)return"";let n,r,a;t instanceof Date?(a=t.getFullYear(),r=t.getMonth()+1,n=t.getDate()):z(t)?(a=t.year,r=t.month,n=t.day):(!function(t){if(!t||"object"!=typeof t)return!1;if(t instanceof Date)return!1;const n=t;e.ZonedDateTime}(t),a=t.year,r=t.month,n=t.day);const o=String(r).padStart(2,"0");return`${String(n).padStart(2,"0")}/${o}/${a}`},nt=e=>`${["January","February","March","April","May","June","July","August","September","October","November","December"][e.getMonth()]} ${e.getFullYear()}`,rt=e=>{const t=e.year,n=e.month;return`${e.day} ${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][n-1]} ${t}`};function at(e){return null!==e&&"object"==typeof e&&!("hour"in e)&&"year"in e&&"month"in e&&"day"in e&&!(e instanceof Date)}function ot(e){return null!==e&&"object"==typeof e&&"hour"in e&&!("timeZone"in e)&&"year"in e&&!(e instanceof Date)}function it(e){return null!==e&&"object"==typeof e&&"timeZone"in e&&"year"in e&&!(e instanceof Date)}function lt(e){if(e instanceof Date)return e;if(at(e))return new Date(e.year,e.month-1,e.day);if(ot(e))return new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second||0,e.millisecond||0);if(it(e))try{if("function"==typeof e.toInstant){const t=e.toInstant();return new Date(t.epochMilliseconds)}return new Date(e.year,e.month-1,e.day,e.hour,e.minute)}catch(t){return new Date(e.year,e.month-1,e.day,e.hour,e.minute)}return new Date(e)}function st(t){return e.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()})}function dt(t){return e.PlainDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:t.getHours(),minute:t.getMinutes(),second:t.getSeconds(),millisecond:t.getMilliseconds()})}function ct(t,n=e.Now.timeZoneId()){return e.ZonedDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:t.getHours(),minute:t.getMinutes(),second:t.getSeconds(),millisecond:t.getMilliseconds(),timeZone:n})}function ut(e){return new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second||0,e.millisecond||0)}function ht(e){return new Date(e.year,e.month-1,e.day)}function gt(e){if(e instanceof Date)return e.getHours()+e.getMinutes()/60;if(at(e))return 0;const t=e;return t.hour+t.minute/60}function mt(e,t){const n=Math.floor(t),r=Math.round(60*(t-n));return it(e),e.with({hour:n,minute:r,second:0,millisecond:0})}function vt(e){return e instanceof Date?st(e):at(e)?e:(ot(e),e.toPlainDate())}function ft(e,t){if(e instanceof Date&&t instanceof Date)return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate();const n=vt(e),r=vt(t);return n.equals(r)}const pt=/(YYYY|YY|MM|DD|HH|mm)/g,yt=e=>e.toString().padStart(2,"0"),bt=(e,t)=>{const n=(null!=t?t:"").trim(),r=/[Hhms]/.test(e)||!n?e:`${e} ${n}`.trim();return r.replaceAll(/(H{1,2}):MM/g,(e,t)=>`${t}:mm`)},wt=e=>e.replaceAll(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),Dt=e=>{let t,n=0,r="^";for(;null!==(t=pt.exec(e));){r+=wt(e.slice(n,t.index));const a=t[0];r+=`(?<${a}>\\d{${"YYYY"===a?4:2}})`,n=t.index+a.length}return r+=wt(e.slice(n))+"$",new RegExp(r)},xt=(t,n,r,a)=>{const o=t.trim();if(!o)return null;const i=o.match(n),l=null==i?void 0:i.groups;if(!l)return null;const s=l.YYYY?Number(l.YYYY):l.YY?Number(l.YY)+2e3:r.year,d=l.MM?Number(l.MM):r.month,c=l.DD?Number(l.DD):r.day,u=l.HH?Number(l.HH):r.hour,h=l.mm?Number(l.mm):r.minute;try{return e.ZonedDateTime.from({timeZone:a,year:s,month:d,day:c,hour:u,minute:h,second:r.second,millisecond:r.millisecond,microsecond:r.microsecond,nanosecond:r.nanosecond})}catch(e){return null}},Et=t=>{const n=t;return n.timeZoneId&&"string"==typeof n.timeZoneId?n.timeZoneId:n.timeZone&&"string"==typeof n.timeZone.id?n.timeZone.id:"string"==typeof n.timeZone?n.timeZone:e.Now.timeZoneId()},Ct=(t,n,r)=>{var a,o,i,l,s,d,c,u,h,g,m,v,f,p,y,b,w,D,x,E,C,k,T,N;if(!t){const t=null!=n?n:r?Et(r):e.Now.timeZoneId();return null!=r?r:e.Now.zonedDateTimeISO(t)}if(at(t)){const r=null!=n?n:e.Now.timeZoneId(),a=`${t.year}-${yt(t.month)}-${yt(t.day)}T00:00:00[${r}]`;return e.ZonedDateTime.from(a)}const S=t;if("hour"in S&&!("timeZone"in S)){const r=null!=n?n:e.Now.timeZoneId();if("function"==typeof S.toZonedDateTime)try{return t.toZonedDateTime(r)}catch(e){}return e.ZonedDateTime.from({timeZone:r,year:S.year,month:S.month,day:S.day,hour:S.hour,minute:S.minute,second:null!==(a=S.second)&&void 0!==a?a:0,millisecond:null!==(o=S.millisecond)&&void 0!==o?o:0,microsecond:null!==(i=S.microsecond)&&void 0!==i?i:0,nanosecond:null!==(l=S.nanosecond)&&void 0!==l?l:0})}try{return e.ZonedDateTime.from(t)}catch(t){const a=S,o=null!==(h=null!==(u=null!==(c=null!==(d="string"==typeof(null==a?void 0:a.timeZone)?a.timeZone:null===(s=null==a?void 0:a.timeZone)||void 0===s?void 0:s.id)&&void 0!==d?d:null==a?void 0:a.timeZoneId)&&void 0!==c?c:n)&&void 0!==u?u:r?Et(r):void 0)&&void 0!==h?h:e.Now.timeZoneId();if("function"==typeof(null==a?void 0:a.toZonedDateTime))try{return a.toZonedDateTime({timeZone:o})}catch(e){}const i=null!=r?r:e.Now.zonedDateTimeISO(o);return e.ZonedDateTime.from({timeZone:o,year:null!==(g=null==a?void 0:a.year)&&void 0!==g?g:i.year,month:null!==(m=null==a?void 0:a.month)&&void 0!==m?m:i.month,day:null!==(v=null==a?void 0:a.day)&&void 0!==v?v:i.day,hour:null!==(p=null!==(f=null==a?void 0:a.hour)&&void 0!==f?f:null==r?void 0:r.hour)&&void 0!==p?p:0,minute:null!==(b=null!==(y=null==a?void 0:a.minute)&&void 0!==y?y:null==r?void 0:r.minute)&&void 0!==b?b:0,second:null!==(D=null!==(w=null==a?void 0:a.second)&&void 0!==w?w:null==r?void 0:r.second)&&void 0!==D?D:0,millisecond:null!==(E=null!==(x=null==a?void 0:a.millisecond)&&void 0!==x?x:null==r?void 0:r.millisecond)&&void 0!==E?E:0,microsecond:null!==(k=null!==(C=null==a?void 0:a.microsecond)&&void 0!==C?C:null==r?void 0:r.microsecond)&&void 0!==k?k:0,nanosecond:null!==(N=null!==(T=null==a?void 0:a.nanosecond)&&void 0!==T?T:null==r?void 0:r.nanosecond)&&void 0!==N?N:0})}},kt=(e,t,n)=>{const r=bt(t,n),a={YYYY:e.year.toString(),YY:yt(e.year%100),MM:yt(e.month),DD:yt(e.day),HH:yt(e.hour),mm:yt(e.minute)};return r.replace(pt,e=>{var t;return null!==(t=a[e])&&void 0!==t?t:e})};function Tt(e,t="240px"){return"number"==typeof e?`${e}px`:"string"==typeof e&&e.trim().length>0?e:t}let Nt=null;function St(){if("undefined"==typeof document)return!1;if(null!==Nt)return Nt;const e=document.createElement("style");e.textContent=".df-calendar-container .__df_measure__::-webkit-scrollbar { display: block !important; }",document.head.append(e);const t=document.createElement("div");t.className="df-calendar-container",t.style.cssText="position:absolute;top:-9999px;width:100px;height:100px;overflow:hidden";const n=document.createElement("div");n.className="__df_measure__",n.style.cssText="width:100px;height:100px;overflow:scroll",t.append(n),document.body.append(t);const r=n.offsetWidth-n.clientWidth>0;return t.remove(),e.remove(),Nt=r,r}const Mt=(e,t,n)=>`${e} ${t} ${n.split(" ").filter(Boolean).map(e=>`dark:${e}`).join(" ")}`.trim(),It={container:"bg-white dark:bg-gray-900",card:"bg-white dark:bg-gray-800",sidebar:"bg-gray-50 dark:bg-gray-900",text:"text-gray-900 dark:text-gray-100",textMuted:"text-gray-500 dark:text-gray-400",textSubtle:"text-gray-600 dark:text-gray-300",textEmphasis:"text-gray-900 dark:text-white",border:"border-gray-200 dark:border-gray-700",borderLight:"border-gray-100 dark:border-gray-800",borderStrong:"border-gray-300 dark:border-gray-600",bgPrimary:"bg-white dark:bg-gray-900",bgSecondary:"bg-gray-50 dark:bg-gray-800",bgTertiary:"bg-gray-100 dark:bg-gray-700",bgMuted:"bg-gray-100 dark:bg-gray-800",hover:"hover:bg-gray-100 dark:hover:bg-gray-800",hoverSubtle:"hover:bg-gray-50 dark:hover:bg-gray-900",active:"bg-gray-200 dark:bg-gray-700",focus:"focus:ring-primary",input:"bg-white dark:bg-gray-700 border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100",inputFocus:"focus:border-primary focus:ring-primary",buttonPrimary:"bg-primary text-primary-foreground hover:bg-primary/90",buttonSecondary:"bg-gray-200 dark:bg-gray-700 text-gray-900 dark:text-gray-100 hover:bg-gray-300 dark:hover:bg-gray-600",buttonDanger:"bg-destructive text-destructive-foreground hover:bg-destructive/90",buttonSuccess:"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-200 hover:bg-blue-200 dark:hover:bg-blue-800",shadow:"shadow-sm dark:shadow-gray-900/50",shadowMd:"shadow-md dark:shadow-gray-900/50",shadowLg:"shadow-lg dark:shadow-gray-900/50",divider:"border-gray-200 dark:border-gray-700"},Ht=(e,t,n)=>e?t:n,At=(...e)=>e.filter(Boolean).join(" "),Ot=e=>{if("undefined"==typeof document)return e;const t=document.documentElement,n=[t.dataset.dayflowThemeOverride,t.dataset.themeOverride,t.dataset.theme];for(const e of n)if("light"===e||"dark"===e)return e;return t.classList.contains("dark")?"dark":t.classList.contains("light")?"light":e};function Rt(t,n=!1){if(t instanceof e.PlainDate||t instanceof e.PlainDateTime)return t;if(t instanceof Date)return n?st(t):dt(t);throw new Error("Invalid time type: "+typeof t)}function Pt(t,n){if(t instanceof e.ZonedDateTime)return t;if(t instanceof Date)return ct(t,n);throw new Error("Invalid time type: "+typeof t)}function Lt(e){var t;const n=Rt(e.start,e.allDay),r=Rt(e.end,e.allDay);return{id:e.id,title:e.title,description:e.description,start:n,end:r,allDay:null!==(t=e.allDay)&&void 0!==t&&t,calendarId:e.calendarId,meta:e.meta}}function $t(e){const t=Pt(e.start,e.timeZone),n=Pt(e.end,e.timeZone);return{id:e.id,title:e.title,description:e.description,start:t,end:n,allDay:!1,calendarId:e.calendarId,meta:e.meta}}function jt(e){return e.map(e=>Lt(e))}function Yt(e){return e.map(e=>$t(e))}function Ft(e,t,n,r){return Lt(Object.assign({id:e,title:t,start:n,end:n,allDay:!0},r))}function zt(e,t,n,r,a){return Lt(Object.assign({id:e,title:t,start:n,end:r},a))}function _t(e,t,n,r,a=!1,o){return Lt(Object.assign({id:e,title:t,start:n,end:r,allDay:a},o))}function Wt(e,t,n,r,a,o){return $t(Object.assign({id:e,title:t,start:n,end:r,timeZone:a},o))}const Ut=e=>{try{return e instanceof Date?e:"string"==typeof e?new Date(e):B(e)}catch(e){return new Date}},Bt=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},Zt=(e,t,n,r)=>{const a=e.getTime()-t.getTime(),o=Math.round(a/864e5);let i="",l="text-gray-500 dark:text-gray-400";if(0===o)i=r("today")||"Today",l="text-primary";else if(1===o||2===o)try{const e=new Intl.RelativeTimeFormat(n,{numeric:"auto"}).format(o,"day");i=e.charAt(0).toUpperCase()+e.slice(1),l="text-black dark:text-white"}catch(t){i=e.toLocaleDateString(n,{weekday:"long"})}else i=e.toLocaleDateString(n,{year:"numeric",month:"long",day:"numeric",weekday:"long"});return{title:i,colorClass:l}},Vt=(e,t)=>{const n=new Map;e.forEach(e=>{var t;const r=Ut(e.start),a=Bt(r),o=a.getTime();n.has(o)||n.set(o,{date:a,events:[]}),null===(t=n.get(o))||void 0===t||t.events.push(e)});const r=t.getTime();n.has(r)||n.set(r,{date:t,events:[]});return Array.from(n.values()).toSorted((e,t)=>e.date.getTime()-t.date.getTime())};const Gt=new class{constructor(){this.lastCopiedEvent=null}setEvent(e){this.lastCopiedEvent=e}getEvent(){return this.lastCopiedEvent}hasEvent(){return null!==this.lastCopiedEvent}clear(){this.lastCopiedEvent=null}};function Kt(e){return String(e).padStart(2,"0")}function qt(t,n,r){const a=t.trim(),o=/^(\d{4})(\d{2})(\d{2})$/,i=/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z$/;if("DATE"===(null==n?void 0:n.value)||o.test(a)){const t=a.match(o);if(t)return e.PlainDate.from({year:Number.parseInt(t[1],10),month:Number.parseInt(t[2],10),day:Number.parseInt(t[3],10)})}if(i.test(a)){const t=a.match(i);if(t){const n=e.Instant.from(`${t[1]}-${t[2]}-${t[3]}T${t[4]}:${t[5]}:${t[6]}Z`),a=r||e.Now.timeZoneId();return n.toZonedDateTimeISO(a)}}const l=a.match(/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})$/);if(l){const t={year:Number.parseInt(l[1],10),month:Number.parseInt(l[2],10),day:Number.parseInt(l[3],10),hour:Number.parseInt(l[4],10),minute:Number.parseInt(l[5],10),second:Number.parseInt(l[6],10)};return(null==n?void 0:n.tzid)?e.ZonedDateTime.from(Object.assign(Object.assign({},t),{timeZone:n.tzid})):e.PlainDateTime.from(t)}throw new Error(`Invalid ICS date format: ${t}`)}function Xt(e,t=!1){if(t||at(e)){const t=at(e)?e:e.toPlainDate();return{value:`${t.year}${Kt(t.month)}${Kt(t.day)}`,params:{VALUE:"DATE"}}}if(it(e)){const t=e.toInstant().toZonedDateTimeISO("UTC");return{value:`${t.year}${Kt(t.month)}${Kt(t.day)}T${Kt(t.hour)}${Kt(t.minute)}${Kt(t.second)}Z`}}if(ot(e))return{value:`${e.year}${Kt(e.month)}${Kt(e.day)}T${Kt(e.hour)}${Kt(e.minute)}${Kt(e.second)}`};throw new Error("Unsupported Temporal type")}function Jt(e){return`${e.getUTCFullYear()}${Kt(e.getUTCMonth()+1)}${Kt(e.getUTCDate())}T${Kt(e.getUTCHours())}${Kt(e.getUTCMinutes())}${Kt(e.getUTCSeconds())}Z`}function Qt(e){return e?e.replaceAll("\\","\\\\").replaceAll(";","\\;").replaceAll(",","\\,").replaceAll("\n","\\n"):""}function en(e){return e?e.replaceAll("\\,",",").replaceAll("\\;",";").replaceAll(/\\[nN]/g,"\n").replaceAll("\\\\","\\"):""}function tn(e){if(e.length<=75)return e;const t=[];let n=e;for(t.push(n.slice(0,75)),n=n.slice(75);n.length>0;)t.push(" "+n.slice(0,74)),n=n.slice(74);return t.join("\r\n")}function nn(e,t,n){let r=e;return n&&Object.entries(n).forEach(([e,t])=>{r+=`;${e}=${t}`}),r+=`:${t}`,tn(r)}function rn(e){var t,n,r;const a=["BEGIN:VEVENT"],o=(null===(t=e.meta)||void 0===t?void 0:t.originalUid)||`${e.id}@dayflow`;a.push(`UID:${o}`),a.push(`DTSTAMP:${Jt(new Date)}`);const i=Xt(e.start,e.allDay),l=Xt(e.end,e.allDay);if(a.push(nn("DTSTART",i.value,i.params)),a.push(nn("DTEND",l.value,l.params)),a.push(nn("SUMMARY",Qt(e.title))),e.description&&a.push(nn("DESCRIPTION",Qt(e.description))),(null===(n=e.meta)||void 0===n?void 0:n.location)&&a.push(nn("LOCATION",Qt(e.meta.location))),(null===(r=e.meta)||void 0===r?void 0:r.categories)&&Array.isArray(e.meta.categories)){const t=e.meta.categories.map(Qt).join(",");a.push(nn("CATEGORIES",t))}return a.push("END:VEVENT"),a}function an(e){const t=[];let n=null,r=!1;for(const a of e){const e=a.trim().toUpperCase();e.startsWith("BEGIN:VEVENT")?(r=!0,n=[]):e.startsWith("END:VEVENT")?(r&&n&&t.push(n),r=!1,n=null):r&&n&&n.push(a)}return t}function on(e){const t={};for(const n of e){const e=n.indexOf(":");if(-1===e)continue;const r=n.slice(0,e),a=n.slice(e+1),[o,...i]=r.split(";"),l=o.trim().toUpperCase(),s={};switch(i.forEach(e=>{const[t,n]=e.split("=");t&&n&&(s[t.trim().toUpperCase()]=n.trim())}),l){case"UID":t.uid=a.trim();break;case"SUMMARY":t.summary=en(a);break;case"DESCRIPTION":t.description=en(a);break;case"LOCATION":t.location=en(a);break;case"DTSTART":t.dtstart=a.trim(),t.dtstartParams={value:s.VALUE,tzid:s.TZID};break;case"DTEND":t.dtend=a.trim(),t.dtendParams={value:s.VALUE,tzid:s.TZID};break;case"CATEGORIES":t.categories=a.split(",").map(e=>en(e.trim()))}}if(!t.dtstart)throw new Error("Missing DTSTART in VEVENT");return t.uid||(t.uid=Ge()),t}function ln(t,n){var r;const{calendarId:a="default",generateNewIds:o=!0,idPrefix:i="ics-",defaultTimeZone:l}=n,s=o?`${i}${Ge()}`:t.uid,d=qt(t.dtstart,t.dtstartParams,l);let c;c=t.dtend?qt(t.dtend,t.dtendParams,l):at(d)?d.add({days:1}):d.add({hours:1});const u="DATE"===(null===(r=t.dtstartParams)||void 0===r?void 0:r.value)||at(d),h=l||e.Now.timeZoneId();let g,m;if(at(d))g=d.toZonedDateTime({timeZone:h,plainTime:"00:00:00"});else if(ot(d))try{g=d.toZonedDateTime(h)}catch(t){g=e.ZonedDateTime.from(Object.assign(Object.assign({},d),{timeZone:h}))}else g=d;if(at(c))m=c.toZonedDateTime({timeZone:h,plainTime:"00:00:00"});else if(ot(c))try{m=c.toZonedDateTime(h)}catch(t){m=e.ZonedDateTime.from(Object.assign(Object.assign({},c),{timeZone:h}))}else m=c;return{id:s,calendarId:a,title:t.summary||"(No Title)",description:t.description,start:g,end:m,allDay:u,meta:{location:t.location,originalUid:t.uid,categories:t.categories}}}function sn(e,t={}){const n={success:!1,events:[],errors:[],totalParsed:0,totalImported:0};try{const r=e.replaceAll(/(\r\n|\n|\r)[ \t]/g,""),a=an(r.split(/\r\n|\n|\r/));n.totalParsed=a.length,a.forEach((e,r)=>{try{const r=ln(on(e),t);n.events.push(r)}catch(e){n.errors.push({line:0,message:e instanceof Error?e.message:"Unknown parsing error",eventUid:`index-${r}`})}}),n.success=0===n.errors.length,n.totalImported=n.events.length}catch(e){n.errors.push({message:`Fatal parsing error: ${e instanceof Error?e.message:"Unknown error"}`})}return n}function dn(e,t={}){const{calendarName:n="DayFlow Calendar",productId:r="-//DayFlow//DayFlow Calendar//EN"}=t,a=["BEGIN:VCALENDAR","VERSION:2.0",`PRODID:${r}`,"CALSCALE:GREGORIAN","METHOD:PUBLISH",`X-WR-CALNAME:${Qt(n)}`];return e.forEach(e=>{a.push(...rn(e))}),a.push("END:VCALENDAR"),a.join("\r\n")}function cn(e,t={}){const n=dn(e,t),r=`${t.filename||"calendar"}.ics`,a=new Blob([n],{type:"text/calendar;charset=utf-8"}),o=URL.createObjectURL(a),i=document.createElement("a");i.href=o,i.setAttribute("download",r),document.body.append(i),i.click(),i.remove(),URL.revokeObjectURL(o)}function un(e,t){return y(this,void 0,void 0,function*(){try{const n=yield e.text();if(!n)throw new Error("File content is empty");return sn(n,t)}catch(e){return{success:!1,events:[],errors:[{message:e instanceof Error?e.message:"string"==typeof e?e:"Failed to read file"}],totalParsed:0,totalImported:0}}})}let hn=null;const gn=()=>{const[e,t]=u(()=>hn||{weekHeight:A.WEEK_HEIGHT,screenSize:"desktop",weeksPerView:6});return h(()=>{const e=()=>{const e=window.innerWidth,n=window.innerHeight-150,r=Math.max(80,Math.floor(n/6)),a=e<768?{weekHeight:Math.max(A.MOBILE_WEEK_HEIGHT,r),screenSize:"mobile",weeksPerView:6}:e<1024?{weekHeight:Math.max(A.TABLET_WEEK_HEIGHT,r),screenSize:"tablet",weeksPerView:6}:{weekHeight:Math.max(A.WEEK_HEIGHT,r),screenSize:"desktop",weeksPerView:6};hn=a,t(e=>e.screenSize===a.screenSize&&e.weekHeight===a.weekHeight&&e.weeksPerView===a.weeksPerView?e:a)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e},mn=n({locale:"en-US",t:e=>e,getWeekDaysLabels:()=>[],getMonthLabels:()=>[],isDefault:!0});function vn(){return f(mn)}const fn=n(null);let pn=0;function yn({generatorName:e,generatorArgs:t,defaultContent:n,store:r}){const a=g(null),o=f(fn),i=r||o,l=g(null),[,s]=u(0);l.current||(l.current="df-slot-"+pn++),h(()=>{if(!a.current||!i)return;const n=l.current;i.register({id:n,containerEl:a.current,generatorName:e,generatorArgs:t});const r=i.subscribe(()=>{s(e=>e+1)});return()=>{i.unregister(n),r()}},[i]),h(()=>{if(!i||!l.current)return;const n=l.current;i.register({id:n,containerEl:a.current,generatorName:e,generatorArgs:t})},[e,t]);const d="eventContent"===e,c="sidebar"===e,m=null==i?void 0:i.isOverridden(e);return et("div",{ref:a,className:"df-content-slot "+(d||c?"flex h-full flex-1 flex-col":""),children:!m&&n})}const bn="df-month-view h-full flex flex-col bg-white dark:bg-gray-900 select-none",wn="p-2 flex justify-between",Dn="text-2xl font-bold text-gray-900 dark:text-gray-100",xn="rounded-md bg-background border border-border px-3 py-2 text-xs font-medium text-gray-700 dark:text-gray-300 hover:bg-(--hover)",En="df-date-number inline-flex items-center justify-center h-6 w-6 rounded-full text-sm mt-1 select-none",Cn="flex-1 overflow-auto will-change-scroll",kn="scrollbar-hide",Tn="df-time-slot relative h-[4.5rem] flex",Nn="df-time-label absolute top-0 -translate-y-1/2 right-2 text-[12px] text-gray-500 dark:text-gray-400 select-none",Sn="df-time-grid-row h-[4.5rem] border-t border-gray-200 dark:border-gray-700 flex",Mn="df-current-time-line absolute left-0 top-0 w-full flex pointer-events-none",In="df-current-time-label ml-2 text-primary-foreground text-xs font-bold px-1.5 bg-primary rounded-sm",Hn="df-all-day-row flex items-center border-b border-gray-200 dark:border-gray-700 sticky",An="rounded-xl my-0.5",On="rounded-sm",Rn="df-event-title font-medium text-xs truncate pr-1",Pn="df-month-event-color-bar inline-block w-0.75 h-3 mr-1 shrink-0 rounded-full",Ln="h-3 w-3 mr-1",$n="resize-handle absolute right-0 top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20",jn="bg-primary rounded-full text-primary-foreground",Yn="df-nav-button calendar-nav-button group relative inline-flex items-center justify-center w-7 h-7 rounded-md border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 hover:border-gray-300 dark:hover:border-gray-500 active:bg-gray-100 dark:active:bg-gray-600 transition-all duration-150 shadow-sm hover:shadow focus:outline-none",Fn="h-4 w-4 transition-transform group-hover:scale-110",zn="df-event-detail-panel fixed bg-white dark:bg-gray-800 shadow-lg border border-gray-200 dark:border-gray-700 rounded-lg",_n="bg-white dark:bg-gray-800 rounded-md shadow-lg border border-gray-200 dark:border-gray-700 overflow-hidden transition-all duration-200 origin-top-right animate-in fade-in zoom-in-95",Wn="h-3 border-t border-gray-200 dark:border-gray-700 relative",Un="absolute top-0 -translate-y-1/2 text-[12px] text-gray-500 dark:text-gray-400",Bn="df-sidebar flex h-full flex-col border-r border-gray-200 dark:border-gray-700 bg-white dark:bg-slate-900",Zn="df-sidebar-header flex items-center px-2 py-1",Vn="df-sidebar-header-toggle flex h-8 w-8 items-center justify-center rounded hover:bg-gray-100 dark:hover:bg-slate-800",Gn="df-sidebar-header-title text-sm font-semibold text-gray-700 dark:text-gray-200",Kn="flex h-7 w-7 items-center justify-center rounded hover:bg-gray-100 dark:hover:bg-slate-800 transition-colors",qn="text-gray-500 dark:text-gray-400",Xn="text-gray-600 dark:text-gray-300",Jn="text-xs",Qn="text-sm",er="flex flex-col",tr="mr-1",nr=(...e)=>e.filter(Boolean).join(" "),rr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:et("path",{d:"m15 18-6-6 6-6"})}),ar=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:et("path",{d:"m9 18 6-6-6-6"})}),or=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("path",{d:"m11 17-5-5 5-5"}),et("path",{d:"m18 17-5-5 5-5"})]}),ir=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("path",{d:"m6 17 5-5-5-5"}),et("path",{d:"m13 17 5-5-5-5"})]}),lr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:et("path",{d:"m6 9 6 6 6-6"})}),sr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("path",{d:"M5 12h14"}),et("path",{d:"M12 5v14"})]}),dr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("circle",{cx:"11",cy:"11",r:"8"}),et("path",{d:"m21 21-4.3-4.3"})]}),cr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:et("path",{d:"M20 6 9 17l-5-5"})}),ur=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("path",{d:"m7 15 5 5 5-5"}),et("path",{d:"m7 9 5-5 5 5"})]}),hr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("path",{d:"M18 6 6 18"}),et("path",{d:"m6 6 12 12"})]}),gr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("path",{d:"M8 2v4"}),et("path",{d:"M16 2v4"}),et("rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}),et("path",{d:"M3 10h18"}),et("path",{d:"M8 14h.01"}),et("path",{d:"M12 14h.01"}),et("path",{d:"M16 14h.01"}),et("path",{d:"M8 18h.01"}),et("path",{d:"M12 18h.01"}),et("path",{d:"M16 18h.01"})]}),mr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("path",{d:"M18 8L22 12L18 16"}),et("path",{d:"M2 12H22"})]}),vr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:et("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),fr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("rect",{width:"18",height:"14",x:"3",y:"8",rx:"2"}),et("path",{d:"M12 5a3 3 0 1 0-3 3"}),et("path",{d:"M12 5a3 3 0 1 1 3 3"}),et("path",{d:"M3 12h18"}),et("path",{d:"M12 22V8"})]}),pr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:et("path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z"})}),yr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("path",{d:"M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z"}),et("circle",{cx:"12",cy:"10",r:"3"})]}),br=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:et("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),wr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),et("path",{d:"M15 3v18"}),et("path",{d:"m8 9 3 3-3 3"})]}),Dr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),et("path",{d:"M15 3v18"}),et("path",{d:"m10 15-3-3 3-3"})]}),xr=({className:e,width:t=24,height:n=24})=>et("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[et("path",{d:"m12 19-7-7 7-7"}),et("path",{d:"M19 12H5"})]});function Er(e,t){var n,r,a,o,i;try{if("today"===e){return null!==(r=null===(n=new Intl.RelativeTimeFormat(t,{numeric:"auto"}).formatToParts(0,"day").find(e=>"literal"===e.type))||void 0===n?void 0:n.value)&&void 0!==r?r:null}if("week"===e){return null!==(o=null===(a=new Intl.RelativeTimeFormat(t,{numeric:"always"}).formatToParts(1,"week").find(e=>"unit"===e.type))||void 0===a?void 0:a.value)&&void 0!==o?o:null}return null!==(i=new Intl.DisplayNames(t,{type:"dateTimeField"}).of(e))&&void 0!==i?i:null}catch(e){return null}}function Cr(e){return e.charAt(0).toUpperCase()+e.slice(1)}const kr=(e,t="short",n=1)=>{const r=[],a=new Date(2024,0,7);for(let o=0;o<7;o++){const i=new Date(a);i.setDate(a.getDate()+n+o);try{r.push(i.toLocaleDateString(e,{weekday:t}))}catch(e){r.push(i.toLocaleDateString("en-US",{weekday:t}))}}return r},Tr=(e,t="long")=>{const n=[];for(let r=0;r<12;r++){const a=new Date(2024,r,1);try{n.push(a.toLocaleDateString(e,{month:t}))}catch(e){n.push(a.toLocaleDateString("en-US",{month:t}))}}return n};function Nr(e,t="en-US"){var n;if(["today","day","week","month","year"].includes(e)){const n=Er(e,t);if(n)return Cr(n)}const r=S(t),a=T[r],o=null===(n=null==a?void 0:a.messages)||void 0===n?void 0:n[e];if(o)return o;const i=T.en.messages;return(null==i?void 0:i[e])||e}const Sr=({locale:e="en-US",messages:t,children:n})=>{const r=v(()=>{if("string"==typeof e){return{code:M(e)?e:"en-US",messages:void 0}}return e&&"string"!=typeof e&&!M(e.code)?Object.assign(Object.assign({},e),{code:"en-US"}):e||{code:"en-US"}},[e]),a=v(()=>{const e=r.code;return{locale:e,t:(n,a)=>{var o,i,l;let s=null!==(l=null!==(o=null==t?void 0:t[n])&&void 0!==o?o:null===(i=r.messages)||void 0===i?void 0:i[n])&&void 0!==l?l:Nr(n,e);return a&&Object.entries(a).forEach(([e,t])=>{s=s.replaceAll(new RegExp(`{${e}}`,"g"),t)}),s},getWeekDaysLabels:kr,getMonthLabels:Tr,isDefault:!1}},[r,t]);return et(mn.Provider,{value:a,children:n})},Mr=({calendar:e,mode:t="buttons"})=>{const[n,r]=u(!1),a=g(null),{t:o}=vn(),i=Array.from(e.state.views.keys()),l=e.state.currentView;return h(()=>{const e=e=>{a.current&&!a.current.contains(e.target)&&r(!1)};if(n)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[n]),i.length<=1?null:et("div","select"===t?{className:"relative inline-block",ref:a,children:[et("button",{type:"button",onClick:()=>r(!n),className:"flex h-7 min-w-30 items-center justify-between gap-2 rounded-lg border border-gray-200 bg-white px-3 text-sm font-medium shadow-sm transition-all duration-200 hover:bg-gray-50 focus:outline-none dark:border-gray-600 dark:bg-gray-800 dark:hover:bg-gray-700","aria-expanded":n,"aria-haspopup":"listbox",children:[et("span",{className:"text-gray-900 dark:text-gray-100",children:o(l)}),et("span",{className:`${qn} transition-transform duration-200 ${n?"rotate-180":""}`,children:et(lr,{width:16,height:16})})]}),n&&et("div",{className:"absolute top-full left-0 z-50 mt-1 w-full min-w-30 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-600 rounded-lg shadow-lg dark:shadow-gray-900/50 overflow-hidden animate-in",children:et("div",{className:"p-1",role:"listbox",children:i.map(t=>et("button",{type:"button",onClick:()=>{e.changeView(t),r(!1),e.triggerRender()},className:"w-full rounded px-3 py-0.5 text-left text-sm transition-colors duration-150 focus:outline-none "+(l===t?"bg-primary/10 font-medium text-primary":"text-gray-700 hover:bg-gray-50 dark:text-gray-300 dark:hover:bg-gray-700"),role:"option","aria-selected":l===t,children:o(t)},t))})}),et("style",{children:"\n @keyframes slideIn {\n from {\n opacity: 0;\n transform: translateY(-4px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n .animate-in {\n animation: slideIn 0.15s ease-out;\n }\n "})]}:{className:"mb-1 inline-flex items-center gap-1 rounded-lg bg-gray-100 p-0.5 dark:bg-gray-800",children:i.map(t=>et("button",{type:"button",className:"h-6 rounded-md px-4 text-sm font-medium transition-all duration-200 focus:outline-none "+(l===t?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-gray-100":"text-gray-600 hover:bg-gray-50 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-100"),onClick:()=>{e.changeView(t),e.triggerRender()},children:o(t)},t))})},Ir=({calendar:e,switcherMode:t="buttons",onAddCalendar:n,onSearchChange:r,onSearchClick:a,searchValue:o="",isSearchOpen:i=!1,isEditable:l=!0,safeAreaLeft:s})=>{const d=f(fn),c="buttons"===t,u=e.state.currentView===I.DAY,{screenSize:h}=gn(),g="mobile"===h,{t:p}=vn(),y=m(e=>{const t=e.currentTarget.value;t!==o&&(null==r||r(t))},[r,o]);return et(yn,{store:d,generatorName:"headerContent",generatorArgs:v(()=>({calendar:e,switcherMode:t,onAddCalendar:n,onSearchChange:r,onSearchClick:a,searchValue:o,isSearchOpen:i,isEditable:l,safeAreaLeft:s}),[e,t,n,r,a,o,i,l,s]),defaultContent:et("div",{className:"df-header flex shrink-0 items-center justify-between border-b bg-white pt-1 pr-2 transition-colors duration-200 dark:bg-gray-900 "+(u||i?"border-gray-200 dark:border-gray-700":"border-transparent"),style:{paddingLeft:s||8,transition:"padding-left 160ms ease-in-out"},onContextMenu:e=>e.preventDefault(),children:[et("div",{className:"df-header-left mb-1 flex items-center",children:n&&l&&et("button",{type:"button",id:"dayflow-add-event-btn",onClick:n,className:Kn,title:g?p("newEvent")||"New Event":p("createCalendar")||"Add Calendar",children:et(sr,{className:`h-4 w-4 ${qn}`})})}),et("div",{className:"df-header-mid flex flex-1 justify-center",children:c&&et(Mr,{mode:t,calendar:e})}),et("div",{className:"df-header-right mb-1 flex items-center justify-end gap-3 pb-1",children:[!c&&et(Mr,{mode:t,calendar:e}),et("button",{type:"button",onClick:a,className:`md:hidden ${Kn}`,title:p("search")||"Search",children:et(dr,{width:16,height:16})}),et("div",{className:"group relative hidden md:block",children:[et("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3",children:et("span",{className:"text-gray-400 transition-colors group-focus-within:text-primary",children:et(dr,{width:16,height:16})})}),et("input",{id:"dayflow-search-input",type:"text",placeholder:p("search")||"Search",value:o,onChange:y,className:"pl-9 pr-8 py-1 h-7 text-sm border border-slate-200 dark:border-gray-600 rounded-lg text-gray-900 dark:text-gray-100 placeholder-gray-500 dark:placeholder-gray-400 focus:outline-none focus:ring-1 focus:ring-primary focus:border-primary transition resize-none w-48"}),o&&et("button",{type:"button",onClick:()=>{null==r||r("")},className:"absolute inset-y-0 right-0 flex items-center pr-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",children:et("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[et("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),et("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]})]})})},Hr=n(void 0),Ar=({children:e,initialTheme:t="light",onThemeChange:n})=>{const[r,a]=u(t),[o,i]=u("light"),l="auto"===r?o:r;h(()=>{a(t)},[t]);const s=m(e=>{a(e)},[]);h(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-color-scheme: dark)"),t=e=>{const t=e.matches?"dark":"light";i(t)},n=e.matches?"dark":"light";return i(n),e.addEventListener?e.addEventListener("change",t):e.addListener&&e.addListener(t),()=>{e.removeEventListener?e.removeEventListener("change",t):e.removeListener&&e.removeListener(t)}},[]),h(()=>{if("undefined"==typeof document)return;const e=document.documentElement,t=Ot(l),n="auto"===r?t:l;e.classList.remove("light","dark"),e.classList.add(n),"auto"===r?delete e.dataset.dayflowThemeOverride:e.dataset.dayflowThemeOverride=n,e.dataset.theme=n},[l,r,o]),h(()=>{n&&n(r,l)},[r,l,n]);const d=v(()=>({theme:r,effectiveTheme:l,setTheme:s}),[r,l,s]);return et(Hr.Provider,{value:d,children:e})},Or=()=>{const e=f(Hr);if(void 0===e)throw new Error("useTheme must be used within a ThemeProvider");return e},Rr=e=>{const t=g(null),n=g(null);return h(()=>{if(t.current){const r=b(e,[]);n.current=new w(t.current,r),r.initialExpanded&&n.current.expand()}return()=>{n.current&&(n.current.destroy(),n.current=null)}},[]),h(()=>{if(n.current){const t=b(e,[]);n.current.setOptions(t)}},[e]),et("div",{ref:t,className:e.className})},Pr=({color:e,onChange:t,onClose:n})=>{const r=v(()=>{const{h:t,l:n}=D(e);return{hue:t,saturation:x(n),lightness:n,alpha:100,layer:"outer"}},[e]);return et("div",{className:"flex justify-center",children:et(Rr,{defaultValue:r,coreSize:36,petalSize:32,initialExpanded:!0,openOnHover:!1,onChange:e=>t({hex:e.hex},!0),onCollapse:n})})},Lr=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],$r=({onClose:e,onCreate:t,colorPickerMode:n="default"})=>{const{t:a}=vn(),{effectiveTheme:o}=Or(),[i,l]=u(""),[d,c]=u(Lr[Math.floor(Math.random()*Lr.length)]),[h,g]=u(!1),[m,f]=u(""),p=v(()=>{const e=E[Math.floor(Math.random()*E.length)],t=e.layer||"outer",n=x(e.l);return{hue:e.h,saturation:n,lightness:e.l,alpha:100,layer:t}},[]),[y,b]=u(null),w=e=>{c(e.hex)},D="dark"===o,k={default:{picker:{background:D?"#1e293b":"#ffffff",boxShadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",borderRadius:"0.5rem",border:D?"1px solid #4b5563":"1px solid #e5e7eb"},head:{background:D?"#1e293b":"#ffffff",borderBottom:D?"1px solid #4b5563":"1px solid #e5e7eb",boxShadow:"none"},body:{background:D?"#1e293b":"#ffffff"},controls:{border:D?"1px solid #4b5563":"1px solid #e5e7eb"},input:{background:D?"#374151":"#ffffff",color:D?"#f3f4f6":"#1f2937",border:D?"1px solid #4b5563":"1px solid #e5e7eb",boxShadow:"none"},previews:{border:D?"1px solid #4b5563":"1px solid #e5e7eb"},actions:{borderTop:D?"1px solid #4b5563":"1px solid #e5e7eb"}}};return"undefined"==typeof window?null:s(et("div",{className:"fixed inset-0 z-10000 flex items-center justify-center bg-black/50",children:et("div",{className:"animate-in fade-in zoom-in-95 w-full max-w-sm rounded-lg bg-white p-6 shadow-xl dark:bg-slate-900",onClick:e=>e.stopPropagation(),children:[et("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white "+("default"===n?"mb-6":"mb-4"),children:a("createCalendar")}),et("form",{onSubmit:r=>{var a;if(r.preventDefault(),!i.trim())return;let o;o="default"===n?null!==(a=null==y?void 0:y.hex)&&void 0!==a?a:C(p.hue,p.saturation,p.lightness):d;const{colors:l,darkColors:s}=ge(o),c={id:Ge(),name:i.trim(),colors:l,darkColors:s,isVisible:!0,isDefault:!1};t(c),e()},children:["default"===n?et("div",{className:"mb-8 flex items-center gap-4",children:[et("div",{className:"flex-1",children:et("input",{id:"blossom-calendar-name",name:"calendar-name",type:"text",value:i,onChange:e=>l(e.target.value),className:"w-full rounded-lg border border-slate-200 px-3 py-1.5 text-sm text-gray-900 shadow-sm transition focus:border-primary focus:ring-2 focus:ring-primary focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",placeholder:a("calendarNamePlaceholder"),autoFocus:!0})}),et("div",{className:"relative h-9 w-9 shrink-0",children:et("div",{className:"absolute inset-0 flex items-center justify-center",children:et(Rr,{defaultValue:p,coreSize:36,petalSize:32,openOnHover:!1,onChange:e=>b(e),onCollapse:e=>b(e),className:"z-50"})})})]}):et(r,{children:[et("div",{className:"mb-4",children:et("div",{className:"flex items-center gap-3",children:[et("div",{className:"h-9 w-9 rounded-md border border-gray-200 shadow-sm dark:border-gray-600",style:{backgroundColor:d}}),et("input",{id:"custom-calendar-name",name:"calendar-name",type:"text",value:i,onChange:e=>l(e.target.value),className:"w-full flex-1 rounded-lg border border-slate-200 px-3 py-1.5 text-sm text-gray-900 shadow-sm transition focus:border-primary focus:ring-2 focus:ring-primary focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",placeholder:a("calendarNamePlaceholder"),autoFocus:!0})]})}),et("div",{className:"mb-6",children:[et("div",{className:"grid grid-cols-7 gap-6",children:Lr.map(e=>et("button",{type:"button",className:"h-6 w-6 rounded-full border border-gray-200 focus:ring-2 focus:ring-primary focus:ring-offset-2 focus:outline-none dark:border-gray-600 dark:focus:ring-offset-slate-800 "+(d===e?"ring-2 ring-primary ring-offset-2 dark:ring-offset-slate-800":""),style:{backgroundColor:e},onClick:()=>c(e)},e))}),et("div",{className:"relative mt-2",children:[et("button",{type:"button",onClick:()=>{f(d),g(!0)},className:"flex w-full cursor-pointer items-center rounded-sm px-2 py-1.5 text-sm text-slate-700 transition-colors hover:bg-slate-100 focus:bg-slate-100 focus:outline-none dark:text-slate-200 dark:hover:bg-slate-800 dark:focus:bg-slate-800",children:a("customColor")}),h&&et("div",{className:"absolute top-full left-0 z-10001 mt-2",children:et(yn,{generatorName:"colorPickerWrapper",generatorArgs:{variant:"photoshop",color:d,onChange:w,onAccept:()=>{g(!1)},onCancel:()=>{c(m),g(!1)},styles:k},defaultContent:et("div",{children:et(Pr,{color:d,onChange:w})})})})]})]})]}),et("div",{className:"flex justify-end space-x-2",children:[et("button",{type:"button",onClick:e,className:"rounded border border-slate-200 px-2 py-1 text-xs font-medium text-gray-700 transition hover:bg-gray-50 dark:border-gray-600 dark:text-gray-300 dark:hover:bg-gray-800",children:a("cancel")}),et("button",{type:"submit",disabled:!i.trim(),className:"rounded bg-primary px-2 py-1 text-xs font-medium text-primary-foreground transition hover:bg-primary/90 disabled:opacity-50",children:a("create")})]})]})]})}),document.body)},jr=(t,n)=>e.PlainDate.compare(t,n),Yr=({calendarDays:e,visibleMonth:t,startDate:n,endDate:a,weekDayLabels:o,disabled:i,onDaySelect:l})=>et(r,{children:[et("div",{className:"grid grid-cols-7 gap-1 px-1 pt-2 pb-3 text-center text-[12px] tracking-wide text-slate-400 uppercase dark:text-gray-500",children:o.map(e=>et("span",{children:e},e))}),et("div",{className:"grid grid-cols-7 gap-1 px-1",children:e.map(e=>{const r=e.month!==t.month,o=0===jr(e,n),s=0===jr(e,a),d=jr(e,n)>=0&&jr(e,a)<=0;return et("button",{type:"button",disabled:i,onClick:()=>l(e),className:`flex h-9 w-9 items-center justify-center rounded-md text-sm transition ${o||s?"bg-primary text-primary-foreground font-semibold":d?"bg-primary/10 text-primary":r?"text-slate-300 dark:text-gray-600":"text-slate-700 dark:text-gray-300 hover:bg-primary/10 hover:text-primary"}`,children:e.day},e.toString())})})]}),Fr=({visibleMonth:e,monthLabels:t,disabled:n,onMonthChange:r,onYearChange:a})=>et("div",{className:"flex items-center justify-between border-b border-slate-100 px-3 py-2 text-sm font-medium text-slate-700 dark:border-gray-600 dark:text-gray-300",children:[et("div",{className:"flex items-center gap-1",children:[et("button",{type:"button",disabled:n,onClick:()=>a(-1),className:"rounded-md px-2 py-1 text-slate-400 transition hover:text-slate-600 disabled:opacity-40 dark:text-gray-400 dark:hover:text-gray-200",children:et(or,{width:14,height:12})}),et("button",{type:"button",disabled:n,onClick:()=>r(-1),className:"rounded-md px-2 py-1 text-slate-400 transition hover:text-slate-600 disabled:opacity-40 dark:text-gray-400 dark:hover:text-gray-200",children:et(rr,{width:14,height:12})})]}),et("div",{className:"text-sm font-semibold text-slate-700 dark:text-gray-300",children:[t[e.month-1]," ",e.year]}),et("div",{className:"flex items-center gap-1",children:[et("button",{type:"button",disabled:n,onClick:()=>r(1),className:"rounded-md px-2 py-1 text-slate-400 transition hover:text-slate-600 disabled:opacity-40 dark:text-gray-400 dark:hover:text-gray-200",children:et(ar,{width:14,height:12})}),et("button",{type:"button",disabled:n,onClick:()=>a(1),className:"rounded-md px-2 py-1 text-slate-400 transition hover:text-slate-600 disabled:opacity-40 dark:text-gray-400 dark:hover:text-gray-200",children:et(ir,{width:14,height:12})})]})]}),zr=Array.from({length:24},(e,t)=>t),_r=Array.from({length:60},(e,t)=>t),Wr=({focusedField:e,draftRange:t,disabled:n,onHourSelect:r,onMinuteSelect:a,timeListRefs:o})=>{const i=e,l=t["start"===i?0:1],s=l.minute,d=_r.includes(s)?_r:[..._r,s].toSorted((e,t)=>e-t);return et("div",{className:"flex flex-col rounded-xl border border-slate-200 bg-white shadow-sm sm:w-28 dark:border-gray-600 dark:bg-gray-800",children:[et("div",{className:"flex justify-center border-b border-slate-100 dark:border-gray-600",children:et("div",{className:"py-1.5 text-base text-slate-700 dark:text-gray-300",children:[l.hour.toString().padStart(2,"0"),":",l.minute.toString().padStart(2,"0")]})}),et("div",{className:"flex p-1",children:[et("div",{className:"w-14",children:et("div",{className:`h-72 overflow-y-auto ${kn} rounded-md border border-slate-100 bg-white dark:border-gray-600 dark:bg-gray-700`,role:"listbox","aria-label":"Hour",ref:e=>{o.current&&o.current[i]&&(o.current[i].hour=e)},children:zr.map(e=>{const t=e===l.hour;return et("button",{type:"button",role:"option","aria-selected":t,disabled:n,onClick:()=>r(i,e),className:"flex h-8 w-full items-center justify-center text-sm transition "+(t?"bg-primary font-semibold text-primary-foreground":"text-slate-600 hover:bg-primary/10 hover:text-primary dark:text-gray-300"),"data-active":t?"true":void 0,children:yt(e)},e)})})}),et("div",{className:"w-14",children:et("div",{className:`h-72 overflow-y-auto ${kn} rounded-md border border-slate-100 bg-white dark:border-gray-600 dark:bg-gray-700`,role:"listbox","aria-label":"Minute",ref:e=>{o.current&&o.current[i]&&(o.current[i].minute=e)},children:d.map(e=>{const t=e===s;return et("button",{type:"button",role:"option","aria-selected":t,disabled:n,onClick:()=>a(i,e),className:"flex h-8 w-full items-center justify-center text-sm transition "+(t?"bg-primary font-semibold text-primary-foreground":"text-slate-600 hover:bg-primary/10 hover:text-primary dark:text-gray-300"),"data-active":t?"true":void 0,children:yt(e)},e)})})})]})]})},Ur=({visibleMonth:e,monthLabels:t,weekDayLabels:n,calendarDays:r,draftRange:a,focusedField:o,isTimeEnabled:i,disabled:l,matchTriggerWidth:s,popupRef:d,timeListRefs:c,onMonthChange:u,onYearChange:h,onDaySelect:g,onHourSelect:m,onMinuteSelect:v,onOk:f,getPopupStyle:p})=>{const y=a[0].toPlainDate(),b=a[1].toPlainDate();return et("div",{ref:d,style:p(),"data-range-picker-popup":"true",children:et("div",{className:"space-y-3 rounded-xl border border-slate-200 bg-white p-3 dark:border-gray-600 dark:bg-gray-800",style:{boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",width:s?"100%":void 0},children:[et("div",{className:"flex gap-1",children:[et("div",{className:"w-full flex-3 rounded-xl border border-slate-200 bg-white shadow-sm dark:border-gray-600 dark:bg-gray-800",children:[et(Fr,{visibleMonth:e,monthLabels:t,disabled:l,onMonthChange:u,onYearChange:h}),et(Yr,{calendarDays:r,visibleMonth:e,startDate:y,endDate:b,weekDayLabels:n,disabled:l,onDaySelect:g})]}),i&&et("div",{className:"flex flex-1 justify-end sm:w-32",children:et(Wr,{focusedField:o,draftRange:a,disabled:l,onHourSelect:m,onMinuteSelect:v,timeListRefs:c})})]}),et("div",{className:"flex justify-end",children:et("button",{type:"button",onClick:f,disabled:l,className:"inline-flex items-center rounded-full bg-primary px-4 py-1.5 text-sm font-semibold text-primary-foreground shadow-sm transition hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-50",children:"OK"})})]})})},Br=({value:t,format:n="YYYY-MM-DD HH:mm",showTimeFormat:r="HH:mm",showTime:a=!0,onChange:o,onOk:i,timeZone:l,disabled:d=!1,placement:c="bottomLeft",autoAdjustOverflow:f=!0,getPopupContainer:p,matchTriggerWidth:y=!1,locale:b="en-US"})=>{const w=v(()=>"string"==typeof b?b:(null==b?void 0:b.code)||"en-US",[b]),D=v(()=>void 0===a||("object"==typeof a||Boolean(a)),[a]),x=v(()=>Tr(w,"short"),[w]),E=v(()=>kr(w,"narrow"),[w]),C=v(()=>D?"object"==typeof a&&(null==a?void 0:a.format)?a.format:r:"",[D,a,r]),k=v(()=>bt(n,C),[n,C]),T=v(()=>Dt(k),[k]),N=v(()=>{const n=null!=l?l:z(t[0])?z(t[1])?e.Now.timeZoneId():Et(t[1]):Et(t[0]),r=Ct(t[0],n);return[r,Ct(t[1],n,r)]},[t,l]),[S,M]=u(N),I=g(N),[H,A]=u("start"),[O,R]=u([kt(N[0],n,C),kt(N[1],n,C)]),P=g([kt(N[0],n,C),kt(N[1],n,C)]),L=g(N),[$,j]=u(N[0].toPlainDate().with({day:1})),[Y,F]=u(!1),_=m(e=>{F(e)},[]),[W,U]=u(c),B=g(c),Z=g(null),V=g(null),G=g({start:{hour:null,minute:null},end:{hour:null,minute:null}}),K=g(!1),q=g(!1);h(()=>{P.current=O},[O]),h(()=>{L.current=S},[S]),h(()=>{const t=I.current,n=0!==e.ZonedDateTime.compare(t[0],N[0]),r=0!==e.ZonedDateTime.compare(t[1],N[1]);(n||r)&&M(N),I.current=N},[N]),h(()=>{j(N[0].toPlainDate().with({day:1}))},[N[0]]);const X=m((e,t,n=0)=>{var r;if(!e||!t)return;const a=e.getBoundingClientRect(),o=t.getBoundingClientRect().top-a.top+e.scrollTop-n,i=(null===(r=window.matchMedia)||void 0===r?void 0:r.call(window,"(prefers-reduced-motion: reduce)").matches)?"auto":"smooth";Math.abs(e.scrollTop-o)>1&&e.scrollTo({top:o,behavior:i})},[]),J=m(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=G.current[e];["hour","minute"].forEach(e=>{const n=t[e];if(!n)return;const r=n.querySelector('[data-active="true"]');r&&X(n,r,0)})})})},[X]);h(()=>{Y&&D&&J(H)},[H,Y,J,D]);const Q=S[0].epochMilliseconds,ee=S[0].offsetNanoseconds,te=S[1].epochMilliseconds,ne=S[1].offsetNanoseconds;h(()=>{if(q.current)return;const[e,t]=L.current,r=kt(e,n,C),a=kt(t,n,C),[o,i]=P.current;o===r&&i===a||(P.current=[r,a],R([r,a]))},[Q,ee,te,ne,n,C]),h(()=>{if(!Y)return;const e=e=>{var t,n;const r=e.target;if(null===(t=Z.current)||void 0===t?void 0:t.contains(r))return;if(null===(n=V.current)||void 0===n?void 0:n.contains(r))return;r.closest("[data-range-picker-popup]")||_(!1)},t=setTimeout(()=>{document.addEventListener("mousedown",e)},100);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[Y]),h(()=>{Y||(A("start"),K.current||M(N),K.current=!1)},[Y,N]);const re=m(e=>{o&&o(e,[kt(e[0],n,C),kt(e[1],n,C)])},[C,n,o]),ae=m(e=>{i&&i(e,[kt(e[0],n,C),kt(e[1],n,C)])},[C,n,i]),oe=m((t,n)=>{M(r=>{const a=[...r];if("start"===t){const t=Ct(a[1],Et(n),n),r=e.ZonedDateTime.compare(n,t)>0?n:t;return[n,r]}const o=Ct(a[0],Et(n),n);return[e.ZonedDateTime.compare(o,n)>0?n:o,n]})},[]),ie=t=>{if(d)return;const n=(t,n)=>{var r,a,o,i;const l=Et(t);return e.ZonedDateTime.from({timeZone:l,year:n.year,month:n.month,day:n.day,hour:t.hour,minute:t.minute,second:null!==(r=t.second)&&void 0!==r?r:0,millisecond:null!==(a=t.millisecond)&&void 0!==a?a:0,microsecond:null!==(o=t.microsecond)&&void 0!==o?o:0,nanosecond:null!==(i=t.nanosecond)&&void 0!==i?i:0})};if("start"===H){const e=n(S[0],t),r=S[1].epochMilliseconds-S[0].epochMilliseconds,a=e.add({milliseconds:r});return void M([e,a])}const r=n(S[1],t),a=S[1].epochMilliseconds-S[0].epochMilliseconds;if(e.ZonedDateTime.compare(r,S[0])<0){const e=n(S[0],t),r=e.add({milliseconds:a});return void M([e,r])}const o=[S[0],r];M(o),j(r.toPlainDate().with({day:1}))},le=m((t,n)=>{if(d)return;const r="start"===t?0:1;M(a=>{const o=a[r],i=o.with({hour:n,minute:o.minute,second:0,millisecond:0,microsecond:0,nanosecond:0});if("start"===t){const t=Ct(a[1],Et(i),i);return[i,e.ZonedDateTime.compare(i,t)>0?i:t]}const l=Ct(a[0],Et(i),i);return[e.ZonedDateTime.compare(l,i)>0?i:l,i]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const e=G.current[t].hour;if(!e)return;const n=e.querySelector('[data-active="true"]');n&&X(e,n,0)})})},[d]),se=m((t,n)=>{if(d)return;const r="start"===t?0:1;M(a=>{const o=a[r].with({minute:n,second:0,millisecond:0,microsecond:0,nanosecond:0});if("start"===t){const t=Ct(a[1],Et(o),o);return[o,e.ZonedDateTime.compare(o,t)>0?o:t]}const i=Ct(a[0],Et(o),o);return[e.ZonedDateTime.compare(i,o)>0?o:i,o]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const e=G.current[t].minute;if(!e)return;const n=e.querySelector('[data-active="true"]');n&&X(e,n,0)})})},[d]),de=m((e,t)=>{const n="start"===e?0:1;R(e=>{const r=[...e];return r[n]=t,r})},[]),ce=m((e,t)=>{const r="start"===e?0:1,a=S[r],o=Et(a),i=xt(t,T,a,o);if(i){oe(e,i);const t=i.toPlainDate().with({day:1});return j(t),"start"===e&&A("end"),!0}return R(e=>{const t=[...e];return t[r]=kt(S[r],n,C),t}),!1},[S,C,n,T,oe]),ue=m(e=>t=>{const n=t.currentTarget.value;q.current=!0,de(e,n);const r="start"===e?0:1,a=L.current[r],o=Et(a),i=xt(n,T,a,o);if(i){oe(e,i);const t=i.toPlainDate().with({day:1});j(t),J(e)}},[de,T,oe,J]),he=m(e=>t=>{var r;if(d)return;if(q.current=!1,Y){const t="start"===e?0:1,r=kt(L.current[t],n,C);return void R(e=>{const n=[...e];return n[t]=r,n})}const a=t.relatedTarget;a&&(null===(r=Z.current)||void 0===r?void 0:r.contains(a))||ce(e,t.currentTarget.value)},[ce,d,Y,n,C]),ge=m(e=>t=>{"Enter"===t.key&&(t.preventDefault(),q.current=!1,ce(e,t.currentTarget.value)),"Escape"===t.key&&t.currentTarget.blur()},[ce]),me=()=>{K.current=!0,re(S),ae(S),_(!1)},ve=e=>{j(t=>t.add({months:e}).with({day:1}))},fe=e=>{j(t=>t.add({years:e}).with({day:1}))},pe=v(()=>{const e=$,t=e.dayOfWeek%7,n=e.subtract({days:t});return Array.from({length:42},(e,t)=>n.add({days:t}))},[$]),ye=m((e=c)=>{if(!f||!Z.current)return e;const t=Z.current.getBoundingClientRect(),n=y?t.width:480,r=window.innerHeight-t.bottom,a=t.top,o=window.innerWidth-t.left,i=t.right;let l=e;return l.startsWith("bottom")&&r<500&&a>r?l=l.replace("bottom","top"):l.startsWith("top")&&a<500&&r>a&&(l=l.replace("top","bottom")),l.endsWith("Left")&&o<n&&i>o?l=l.replace("Left","Right"):l.endsWith("Right")&&i<n&&o>i&&(l=l.replace("Right","Left")),l},[f,y,c]),be=m(()=>{const e=ye();B.current!==e&&(B.current=e,U(e))},[ye]),we=e=>{if(d)return;A(e);const t=S["start"===e?0:1].toPlainDate().with({day:1});j(t);const n=ye();B.current!==n&&(B.current=n,U(n)),_(!0)};h(()=>{if(!Y)return;be();const e=()=>be();return window.addEventListener("resize",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e,!0)}},[Y,be]);const De=()=>{if(!Z.current)return{};const e=Z.current.getBoundingClientRect(),t={position:"fixed",zIndex:9999};return B.current.startsWith("bottom")?t.top=e.bottom+8:t.bottom=window.innerHeight-e.top+8,c.endsWith("Left")?t.left=e.left:t.right=window.innerWidth-e.right,y&&(t.width=`${e.width}px`),t};return et("div",{className:"relative max-w-100",ref:Z,children:[et("div",{className:"flex items-center gap-2 rounded-lg border text-sm shadow-sm transition "+(d?"cursor-not-allowed border-slate-200 bg-slate-50 text-slate-400 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-500":Y?"border-primary bg-white shadow-md dark:bg-gray-700":"border-slate-200 bg-white dark:border-gray-600 dark:bg-gray-700"),children:[et("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:et("input",{type:"text",name:"range-start",value:O[0],onChange:ue("start"),onFocus:()=>we("start"),onClick:()=>we("start"),onBlur:he("start"),onKeyDown:ge("start"),className:"w-full rounded-md border px-2 py-1.5 text-sm font-medium transition focus:ring-2 focus:outline-none "+(d?"cursor-not-allowed border-transparent bg-transparent text-slate-400 dark:text-gray-500":"start"===H&&Y?"bg-white text-primary dark:bg-gray-700":"border-transparent bg-transparent text-slate-700 dark:text-gray-300"),placeholder:k,autoComplete:"off",disabled:d})}),et(mr,{className:"text-slate-400 dark:text-gray-500"}),et("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:et("input",{type:"text",name:"range-end",value:O[1],onChange:ue("end"),onFocus:()=>we("end"),onClick:()=>we("end"),onBlur:he("end"),onKeyDown:ge("end"),className:"w-full rounded-md border px-2 py-1.5 text-sm font-medium transition focus:ring-2 focus:outline-none "+(d?"cursor-not-allowed border-transparent bg-transparent text-slate-400 dark:text-gray-500":"end"===H&&Y?"bg-white text-primary dark:bg-gray-700":"border-transparent bg-transparent text-slate-700 dark:text-gray-300"),placeholder:k,autoComplete:"off",disabled:d})})]}),Y&&s(et(Ur,{visibleMonth:$,monthLabels:x,weekDayLabels:E,calendarDays:pe,draftRange:S,focusedField:H,isTimeEnabled:!!D,disabled:d,matchTriggerWidth:y,popupRef:V,timeListRefs:G,onMonthChange:ve,onYearChange:fe,onDaySelect:ie,onHourSelect:le,onMinuteSelect:se,onOk:me,getPopupStyle:De}),p?p():document.body)]})},Zr=({options:e,value:t,onChange:n,registry:r,variant:a="desktop",disabled:o=!1})=>{const[i,l]=u(!1),[d,c]=u({}),m=g(null),v=g(null),f=()=>{if(v.current){const e=v.current.getBoundingClientRect(),t="mobile"===a,n={position:"fixed",zIndex:10001,minWidth:t?"12rem":`${e.width}px`,top:`${e.bottom+4}px`};t?n.right=window.innerWidth-e.right+"px":n.left=`${e.left}px`,c(n)}};h(()=>{const e=e=>{!m.current||m.current.contains(e.target)||e.target.closest("[data-calendar-picker-dropdown]")||l(!1)};return i&&(f(),window.addEventListener("mousedown",e),window.addEventListener("scroll",f,!0),window.addEventListener("resize",f)),()=>{window.removeEventListener("mousedown",e),window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)}},[i]);const p=e=>(r||he()).resolveColors(e).lineColor,y=(e,t)=>{e.stopPropagation(),n(t),l(!1)},b=e.find(e=>e.value===t),w=()=>i&&"undefined"!=typeof window?s("mobile"===a?et("div",{"data-calendar-picker-dropdown":"true",style:d,className:_n,children:e.map(e=>et("div",{className:"flex cursor-pointer items-center px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-700 "+(e.value===t?"bg-gray-50 dark:bg-gray-700/50":""),onClick:t=>y(t,e.value),children:[et("div",{className:"mr-3 flex min-w-0 flex-1 items-center",children:[et("div",{className:"mr-2 flex w-5 justify-center",children:e.value===t&&et(cr,{className:"h-4 w-4 text-primary"})}),et("span",{className:"truncate text-sm text-gray-700 dark:text-gray-200",children:e.label})]}),et("span",{className:"h-3 w-3 shrink-0 rounded-full",style:{backgroundColor:p(e.value)}})]},e.value))}):et("ul",{"data-calendar-picker-dropdown":"true",style:d,className:"animate-in fade-in zoom-in-95 origin-top-left overflow-hidden rounded-md border border-gray-200 bg-white shadow-lg transition-all duration-200 dark:border-gray-600 dark:bg-gray-700 dark:shadow-gray-900/50",children:e.map(e=>et("li",{className:"flex cursor-pointer items-center px-2 py-1 transition-colors hover:bg-gray-100 dark:hover:bg-gray-600 "+(t===e.value?"font-semibold":""),onClick:t=>y(t,e.value),children:[t===e.value?et("span",{className:"mr-2 text-sm text-primary",children:et(cr,{width:12,height:12})}):et("div",{className:"mr-2 h-3 w-3 text-sm",children:" "}),et("span",{className:"mr-2 h-3 w-3 shrink-0 rounded-sm",style:{backgroundColor:p(e.value)}}),et("span",{className:"text-sm whitespace-nowrap text-gray-700 dark:text-gray-200",children:e.label})]},e.value))}),document.body):null;return et("div","mobile"===a?{className:"relative inline-block",ref:m,children:[et("button",{type:"button",ref:v,disabled:o,onClick:e=>{e.stopPropagation(),o||l(!i)},className:"flex items-center space-x-2 rounded-md bg-gray-100 px-3 py-1.5 transition-colors dark:bg-gray-700 "+(o?"cursor-default opacity-50":""),children:[et("span",{className:"h-3 w-3 rounded-full",style:{backgroundColor:p(t)}}),et("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-200",children:(null==b?void 0:b.label)||t}),et(ur,{className:"h-4 w-4 text-gray-400"})]}),w()]}:{className:"relative inline-block",ref:m,children:[et("button",{ref:v,type:"button",onClick:e=>{e.stopPropagation(),l(!i)},className:"flex h-8 items-center space-x-2 rounded-md bg-gray-100 px-2 py-1 transition-colors hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",children:[et("span",{className:"h-4 w-4 shrink-0 rounded-sm",style:{backgroundColor:p(t)}}),et(ur,{className:"h-4 w-4 text-gray-600 dark:text-gray-300"})]}),w()]})},Vr=({event:t,isOpen:n,onEventUpdate:r,onEventDelete:a,onClose:o,app:i})=>{var l;const[d,c]=u(t),{t:g}=vn();h(()=>{c(t)},[t]);const m=v(()=>(i?i.getCalendarRegistry():he()).getVisible().map(e=>({label:e.name,value:e.id})),[i,null==i?void 0:i.getCalendars()]),f=v(()=>!Be(t,d),[t,d]),p=v(()=>z(d.start)?d.end&&!z(d.end)&&d.end.timeZoneId||e.Now.timeZoneId():d.start.timeZoneId||e.Now.timeZoneId(),[d.end,d.start]),y=e=>{const[t,n]=e;c(Object.assign(Object.assign({},d),{start:t.toPlainDate(),end:n.toPlainDate()}))},b=!(null==i?void 0:i.state.readOnly),w=!1!==(null==i?void 0:i.getReadOnlyConfig().viewable);if(!n||!w)return null;if("undefined"==typeof window||"undefined"==typeof document)return null;const D=et("div",{className:"fixed inset-0 flex items-center justify-center",style:{pointerEvents:"auto",zIndex:9998},"data-event-detail-dialog":"true",children:[et("div",{className:"absolute inset-0 bg-black/60 dark:bg-black/80",onClick:e=>{const t=e.target;t.closest("[data-range-picker-popup]")||t===e.currentTarget&&o()}}),et("div",{className:"df-dialog-container relative bg-white dark:bg-gray-800 shadow-2xl border border-gray-200 dark:border-gray-700 rounded-lg p-6 max-w-md w-full mx-4",children:[et("button",{type:"button",onClick:o,className:"absolute top-4 right-4 text-gray-400 transition hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-200","aria-label":"Close",children:et("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:et("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),et("div",{children:[et("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:g("eventTitle")}),et("div",{className:"mb-4 flex items-center justify-between gap-3",children:[et("div",{className:"flex-1",children:et("input",{id:`event-dialog-title-${d.id}`,name:"title",type:"text",value:d.title,readOnly:!b,disabled:!b,onChange:e=>{c(Object.assign(Object.assign({},d),{title:e.target.value}))},className:"w-full rounded-lg border border-slate-200 px-3 py-1.5 text-sm text-gray-900 shadow-sm transition focus:border-primary focus:ring-2 focus:ring-primary focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100"})}),b&&et(Zr,{options:m,value:d.calendarId||"blue",onChange:e=>{c(Object.assign(Object.assign({},d),{calendarId:e}))},registry:null==i?void 0:i.getCalendarRegistry()})]}),d.allDay?et("div",{className:"mb-4",children:[et("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:g("dateRange")}),et(Br,{value:[d.start,d.end],format:"YYYY-MM-DD",showTime:!1,timeZone:p,matchTriggerWidth:!0,disabled:!b,onChange:y,onOk:y,locale:null==i?void 0:i.state.locale})]}):et("div",{className:"mb-4",children:[et("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:g("timeRange")}),et(Br,{value:[d.start,d.end],timeZone:p,disabled:!b,onChange:e=>{const[t,n]=e;c(Object.assign(Object.assign({},d),{start:t,end:n}))},onOk:e=>{const[t,n]=e;c(Object.assign(Object.assign({},d),{start:t,end:n}))},locale:null==i?void 0:i.state.locale})]}),et("div",{className:"mb-4",children:[et("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:g("note")}),et("textarea",{id:`event-dialog-note-${d.id}`,name:"note",value:null!==(l=d.description)&&void 0!==l?l:"",readOnly:!b,disabled:!b,onChange:e=>c(Object.assign(Object.assign({},d),{description:e.target.value})),rows:4,className:"w-full resize-none rounded-lg border border-slate-200 px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:border-primary focus:ring-2 focus:ring-primary focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",placeholder:g("addNotePlaceholder")})]}),b&&et("div",{className:"flex space-x-2",children:[d.allDay?et("button",{type:"button",className:"rounded-lg bg-secondary/10 px-3 py-2 text-xs font-medium text-secondary transition hover:bg-secondary/20",onClick:()=>{const t=z(d.start)?d.start:d.start.toPlainDate(),n=e.ZonedDateTime.from({year:t.year,month:t.month,day:t.day,hour:9,minute:0,timeZone:e.Now.timeZoneId()}),r=e.ZonedDateTime.from({year:t.year,month:t.month,day:t.day,hour:10,minute:0,timeZone:e.Now.timeZoneId()});c(Object.assign(Object.assign({},d),{allDay:!1,start:n,end:r}))},children:g("setAsTimed")}):et("button",{type:"button",className:"rounded-lg bg-secondary/10 px-3 py-2 text-xs font-medium text-secondary transition hover:bg-secondary/20",onClick:()=>{const e=z(d.start)?d.start:d.start.toPlainDate();c(Object.assign(Object.assign({},d),{allDay:!0,start:e,end:e}))},children:g("setAsAllDay")}),et("button",{type:"button",className:"rounded-lg border border-border bg-destructive px-3 py-2 text-xs font-medium text-destructive-foreground transition hover:bg-destructive/90",onClick:()=>{a(t.id),o()},children:g("delete")}),et("button",{type:"button",className:"ml-auto rounded-lg bg-primary px-3 py-2 text-xs font-medium text-primary-foreground transition "+(f?"shadow-lg shadow-primary/20 hover:bg-primary/90":"cursor-not-allowed opacity-50 grayscale-[0.5]"),onClick:()=>{r(d),o()},disabled:!f,children:g("save")})]})]})]})]}),x=document.body;return x?s(D,x):null},Gr=e=>e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}),Kr=({app:e,anchorRef:t,onClose:n,isOpen:r})=>{const{t:a}=vn(),[o,i]=u(""),[l,d]=u(0),[c,m]=u(!1),f=g(null),y=g(null);h(()=>{r||m(!1)},[r]),h(()=>{r&&(setTimeout(()=>{var e;return null===(e=f.current)||void 0===e?void 0:e.focus()},50),i(""),d(0))},[r]),h(()=>{const e=e=>{r&&y.current&&!y.current.contains(e.target)&&t.current&&!t.current.contains(e.target)&&n()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[r,n,t]);const[b,w]=u({top:0,left:0}),[D,x]=u("top"),[E,C]=u(0),k=v(()=>{const e=new Date,t=new Date(e);t.setHours(t.getHours()+1,0,0,0);const n=new Date(t);return n.setHours(n.getHours()+1),{start:t,end:n}},[r]),T=v(()=>{if(!o.trim())return[];const t=[],n=e.getCalendars(),r=e.getAllEvents(),a=o.toLowerCase(),i=r.find(e=>e.title.toLowerCase()===a);let l=null==i?void 0:i.calendarId;if(!l){const e=n.filter(e=>!1!==e.isVisible);if(e.length>0){const t=Math.floor(Math.random()*e.length);l=e[t].id}else n.length>0&&(l=n[0].id)}const s=n.find(e=>e.id===l),d=(null==s?void 0:s.colors.lineColor)||"#3b82f6";t.push({type:"new",title:o,calendarId:l||"",color:d,start:k.start,end:k.end});const c=new Set([o.toLowerCase()]);return r.filter(e=>e.title.toLowerCase().includes(a)&&!c.has(e.title.toLowerCase())).slice(0,5).forEach(e=>{c.add(e.title.toLowerCase());const r=n.find(t=>t.id===e.calendarId);t.push({type:"history",title:e.title,calendarId:e.calendarId||"",color:(null==r?void 0:r.colors.lineColor)||"#9ca3af",start:k.start,end:k.end})}),t},[o,e,k]);p(()=>{if(r&&t.current&&y.current){const e=t.current.getBoundingClientRect(),n=y.current.offsetHeight,r=340;let a=e.left+e.width/2-r/2;const o=12,i=window.innerWidth;a<o?a=o:a+r>i-o&&(a=i-r-o);const l=e.left+e.width/2;C(l-a);let s=0,d="top";e.top<n+20?(d="bottom",s=e.bottom+12):(d="top",s=e.top-12-n),x(d),w({top:s,left:a}),m(!0)}},[r,t,T]);const N=t=>{if(!t.calendarId)return;const r=Ge(),a={id:r,title:t.title,start:W(t.start),end:W(t.end),calendarId:t.calendarId,allDay:!1};e.addEvent(a),e.setCurrentDate(t.start),e.highlightEvent(r),n()};return h(()=>{if(!r)return;const e=e=>{"ArrowDown"===e.key?(e.preventDefault(),d(e=>(e+1)%T.length)):"ArrowUp"===e.key?(e.preventDefault(),d(e=>(e-1+T.length)%T.length)):"Enter"===e.key&&(e.preventDefault(),T[l]&&N(T[l]))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[r,T,l]),r?s(et("div",{ref:y,className:"fixed z-1000 flex w-85 flex-col rounded-xl border border-gray-200 bg-white shadow-2xl dark:border-slate-700 dark:bg-slate-800 "+(c?"animate-in fade-in zoom-in-95 duration-100":""),style:{top:b.top,left:b.left,visibility:c?"visible":"hidden"},children:[et("div",{className:"p-4 pb-2",children:[et("div",{className:"mb-2 text-xs font-semibold tracking-wider text-gray-500 uppercase dark:text-gray-400",children:a("quickCreateEvent")||"Quick Create Event"}),et("div",{className:"relative",children:et("input",{ref:f,type:"text",className:"w-full rounded-lg border border-slate-200 px-3 py-1.5 text-sm text-gray-900 shadow-sm transition focus:border-primary focus:ring-2 focus:ring-primary focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",placeholder:a("quickCreatePlaceholder")||"Enter title (e.g. Code review)",value:o,onChange:e=>i(e.target.value)})})]}),et("div",{className:"max-h-75 flex-1 overflow-y-auto px-2 py-1",children:[0===T.length&&o&&et("div",{className:"px-4 py-3 text-center text-sm text-gray-400",children:a("noSuggestions")||"Type to create"}),T.map((e,t)=>{return et("div",{className:"flex cursor-pointer items-center rounded-lg px-4 py-2 transition-colors "+(t===l?"bg-primary/10 ring-1 ring-primary/20 ring-inset dark:bg-primary/20":"hover:bg-gray-50 dark:hover:bg-slate-700/50"),onClick:()=>N(e),onMouseEnter:()=>d(t),children:[et("div",{className:"mr-3 h-8 w-1 shrink-0 rounded-full",style:{backgroundColor:e.color}}),et("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[et("div",{className:"truncate text-sm font-medium text-gray-900 dark:text-gray-100",children:e.title}),et("div",{className:"flex",children:et("span",{className:"rounded bg-gray-100 px-1 text-[10px] font-semibold text-gray-500 dark:bg-slate-700 dark:text-gray-400",children:"new"===e.type?a("today"):a("tomorrow")})}),et("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:(n=e.start,r=e.end,`${Gr(n)} - ${Gr(r)}`)})]})]},`${e.type}-${t}`);var n,r})]}),et("div",{className:"absolute h-3 w-3 -translate-x-1/2 rotate-45 border-gray-200 bg-white dark:border-slate-700 dark:bg-slate-800 "+("top"===D?"-bottom-1.5 border-r border-b":"-top-1.5 border-t border-l"),style:{left:E}})]}),document.body):null},qr=({visibleMonth:e,currentDate:t,showHeader:n=!1,onMonthChange:r,onDateSelect:a})=>{const{locale:o}=vn(),i=v(()=>(new Date).toDateString(),[]),l=t.toDateString(),s=v(()=>kr(o,"narrow"),[o]),d=v(()=>e.toLocaleDateString(o,{month:"long",year:"numeric"}),[e,o]),c=v(()=>{const t=e.getFullYear(),n=e.getMonth(),r=(new Date(t,n,1).getDay()+6)%7,a=[];for(let e=0;e<42;e++){const o=new Date(t,n,e-r+1),s=o.toDateString();a.push({date:o.getDate(),fullDate:o,isCurrentMonth:o.getMonth()===n,isToday:s===i,isSelected:s===l})}return a},[e,l,i]);return et("div",{className:"px-3 py-3",children:[n?et("div",{className:"mb-3 flex items-center justify-between",children:[et("button",{type:"button",className:"flex h-7 w-7 items-center justify-center rounded-full text-gray-500 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-slate-800",onClick:()=>r(-1),"aria-label":"Previous month",children:et(rr,{className:"h-4 w-4"})}),et("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:d}),et("button",{type:"button",className:"flex h-7 w-7 items-center justify-center rounded-full text-gray-500 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-slate-800",onClick:()=>r(1),"aria-label":"Next month",children:et(ar,{className:"h-4 w-4"})})]}):"",et("div",{className:"df-mini-calendar-grid grid grid-cols-7 gap-1 text-xs justify-items-center",children:[s.map((e,t)=>et("div",{className:"df-mini-calendar-header text-center text-gray-500 dark:text-gray-400 font-medium py-1 h-6 w-6 text-gray-500 dark:text-gray-400",children:e},`weekday-${t}`)),c.map(e=>et("button",{type:"button",className:` df-mini-calendar-day text-center py-1 rounded text-xs h-6 w-6 ${e.isToday?jn:e.isCurrentMonth?"text-gray-900 dark:text-gray-100":"text-gray-400 dark:text-gray-600"} ${e.isSelected&&!e.isToday?"bg-secondary text-secondary-foreground rounded-full font-medium":""} `,onClick:()=>a(e.fullDate),children:e.date},e.fullDate.getTime()))]})]})},Xr=({checked:e,onChange:t,disabled:n})=>et("div",{className:`flex h-7 w-12 items-center rounded-full p-1 transition-colors ${n?"cursor-default opacity-50":"cursor-pointer"} ${e?"bg-green-500":"bg-gray-300"}`,onClick:()=>!n&&t(!e),children:et("div",{className:"h-5 w-5 transform rounded-full bg-white shadow-md transition-transform "+(e?"translate-x-5":"")})}),Jr=({date:e,onChange:t})=>{const n=Array.from({length:24},(e,t)=>t),r=Array.from({length:12},(e,t)=>5*t),a=[...n,...n,...n],o=[...r,...r,...r],i=32,l=e.getHours(),s=5*Math.round(e.getMinutes()/5),d=(24+l)*i,c=(12+s/5)*i,[m,v]=u(d),[f,p]=u(c),y=g(null),b=g(null),w=g(null);h(()=>{y.current&&(y.current.scrollTop=d,v(d)),b.current&&(b.current.scrollTop=c,p(c))},[d,c]);const D=(n,r)=>{const l=n.currentTarget;let s=l.scrollTop;if("hour"===r){const e=768;s<320?(s+=e,l.scrollTop=s):s>1600&&(s-=e,l.scrollTop=s),v(s)}else{const e=384;s<160?(s+=e,l.scrollTop=s):s>800&&(s-=e,l.scrollTop=s),p(s)}w.current&&clearTimeout(w.current),w.current=setTimeout(()=>{((n,r)=>{const l=Math.round(r/i);if("hour"===n){const n=a[l];if(void 0!==n&&n!==e.getHours()){const r=new Date(e);r.setHours(n),t(r)}}else{const n=o[l];if(void 0!==n&&5*Math.round(e.getMinutes()/5)!==n){const r=new Date(e);r.setMinutes(n),t(r)}}})(r,s)},150)},x=(e,t)=>{const n=96+e*i+16-(t+112),r=Math.min(Math.abs(n)/112,1);return{transform:`perspective(500px) rotateX(${-(n/112*80)}deg) scale(${1-.4*r})`,opacity:1-.7*r,transition:"transform 0.1s ease-out, opacity 0.1s ease-out"}};return et("div",{className:"relative mt-2 flex h-56 overflow-hidden rounded-lg",children:[et("style",{children:"\n .no-scrollbar::-webkit-scrollbar { display: none; }\n .no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }\n "}),et("div",{ref:y,className:"no-scrollbar flex-1 snap-y snap-mandatory overflow-y-auto",style:{touchAction:"pan-y"},onScroll:e=>D(e,"hour"),children:[et("div",{style:{height:96}}),a.map((n,r)=>et("div",{className:"flex h-8 cursor-pointer snap-center items-center justify-end pr-5",onClick:()=>{var a;const o=new Date(e);o.setHours(n),t(o),null===(a=y.current)||void 0===a||a.scrollTo({top:r*i,behavior:"smooth"})},children:et("div",{className:"w-10 text-center text-xl transition-colors duration-200 "+(n===l?"font-bold text-black dark:text-white":"text-gray-400 dark:text-gray-500"),style:x(r,m),children:n.toString().padStart(2,"0")})},`h-${r}-${n}`)),et("div",{style:{height:96}})]}),et("div",{ref:b,className:"no-scrollbar flex-1 snap-y snap-mandatory overflow-y-auto",style:{touchAction:"pan-y"},onScroll:e=>D(e,"minute"),children:[et("div",{style:{height:96}}),o.map((n,r)=>et("div",{className:"flex h-8 cursor-pointer snap-center items-center justify-start pl-5",onClick:()=>{var a;const o=new Date(e);o.setMinutes(n),t(o),null===(a=b.current)||void 0===a||a.scrollTo({top:r*i,behavior:"smooth"})},children:et("div",{className:"w-10 text-center text-xl transition-colors duration-200 "+(n===s?"font-bold text-black dark:text-white":"text-gray-400 dark:text-gray-500"),style:x(r,f),children:n.toString().padStart(2,"0")})},`m-${r}-${n}`)),et("div",{style:{height:96}})]}),et("div",{className:"pointer-events-none absolute top-24 right-2 left-2 h-8 rounded-lg border border-gray-300 bg-gray-300/20 dark:border-gray-600 dark:bg-gray-500/20"})]})},Qr=({isOpen:e,onClose:t,onSave:n,onEventDelete:r,draftEvent:a,app:o,timeFormat:i="24h"})=>{const{locale:l,t:d}=vn(),c=o.getReadOnlyConfig(),g=!o.state.readOnly,m=!1!==c.viewable,[f,p]=u(""),[y,b]=u(""),[w,D]=u(!1),[x,E]=u(new Date),[C,k]=u(new Date),[T,N]=u(""),[S,M]=u(new Date),[I,H]=u(new Date),[A,O]=u(null),[R,P]=u(e),[L,$]=u(!1),[j,Y]=u(!1);h(()=>{if(!e){$(!0);const e=setTimeout(()=>{P(!1),$(!1)},300);return()=>clearTimeout(e)}P(!0),$(!1)},[e]),h(()=>{if(e&&a){const e=o.getEvents().some(e=>e.id===a.id);Y(e)}},[e,a,o]);const F=o.getCalendars(),z=F.map(e=>({label:e.name,value:e.id}));h(()=>{if(e&&F.length>0){F.some(e=>e.id===y)||"blue"!==y&&""!==y||b(F[0].id)}},[F,e,y]),h(()=>(e?(document.body.style.overflow="hidden",document.documentElement.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%"):(document.body.style.overflow="",document.documentElement.style.overflow="",document.body.style.position="",document.body.style.width=""),()=>{document.body.style.overflow="",document.documentElement.style.overflow="",document.body.style.position="",document.body.style.width=""}),[e]),h(()=>{var t,n;if(e&&a){if(p(a.title||""),b(a.calendarId||(null===(t=F[0])||void 0===t?void 0:t.id)||"blue"),D(a.allDay||!1),a.start)try{const e=B(a.start);E(e),M(e)}catch(e){console.error("Failed to parse start date",e);const t=new Date;E(t),M(t)}if(a.end)try{const e=B(a.end);k(e),H(e)}catch(e){console.error("Failed to parse end date",e);const t=new Date;k(t),H(t)}}else if(e&&!a){b((null===(n=F[0])||void 0===n?void 0:n.id)||"blue");const e=new Date;e.setMinutes(0,0,0),E(e),M(e),k(new Date(e.getTime()+36e5)),H(e)}},[e,a]);const _=v(()=>{if(!e||!a)return!1;let t=new Date(x),n=new Date(C);w&&(t.setHours(0,0,0,0),n.setHours(0,0,0,0));const r=Object.assign(Object.assign({},a),{title:f,calendarId:y,allDay:w,description:T,start:W(t),end:W(n)});return!Be(a,r)},[e,a,f,y,w,x,C,T]);if(!R||!m)return null;const U=e=>{O(t=>t===e?null:e)},Z=e=>e.toLocaleDateString(l,{day:"numeric",month:"short",year:"numeric"}),V=(e,t)=>{if("start"===e){const e=new Date(t);e.setHours(x.getHours(),x.getMinutes());const n=e.getTime()-x.getTime();E(e);const r=new Date(C.getTime()+n);k(r)}else{const e=new Date(t);e.setHours(C.getHours(),C.getMinutes()),k(e)}},G=(e,t)=>{"start"===e?M(e=>{const n=new Date(e);return n.setMonth(e.getMonth()+t),n}):H(e=>{const n=new Date(e);return n.setMonth(e.getMonth()+t),n})};return s(et("div",{className:"pointer-events-none fixed inset-0 z-10000 flex items-end",children:[et("div",{className:"pointer-events-auto absolute inset-0 bg-black/30 transition-opacity duration-300 "+(L?"opacity-0":"opacity-100"),style:{touchAction:"none"},onClick:t}),et("div",{className:"pointer-events-auto relative flex h-[85vh] w-full flex-col overflow-hidden rounded-t-2xl bg-gray-100 shadow-xl dark:bg-gray-800 "+(L?"animate-slide-down":"animate-slide-up"),onClick:e=>e.stopPropagation(),children:[et("div",{className:"flex items-center justify-between border-b border-gray-200 bg-white p-4 dark:border-gray-700 dark:bg-gray-900",children:[et("button",{type:"button",onClick:t,className:"px-2 py-1 text-gray-500 hover:text-gray-700",children:d("cancel")}),et("span",{className:"text-lg font-semibold",children:d(!g&&j?"viewEvent":j?"editEvent":"newEvent")}),g&&et("button",{type:"button",onClick:()=>{if(!a)return;let e=new Date(x),t=new Date(C);w&&(e.setHours(0,0,0,0),t.setHours(0,0,0,0));const r=Object.assign(Object.assign({},a),{title:f,calendarId:y,allDay:w,start:W(e),end:W(t)});n(r)},disabled:!_,className:"px-2 py-1 font-bold transition-colors "+(_?"text-primary":"cursor-not-allowed text-gray-400 opacity-50"),children:d(j?"done":"create")}),!g&&et("span",{className:"w-12"})]}),et("div",{className:"flex-1 space-y-4 overflow-y-auto p-4",children:[et("div",{className:"rounded-lg bg-white px-4 py-3 dark:bg-gray-900",children:et("input",{type:"text",placeholder:d("titlePlaceholder"),value:f,onChange:e=>g&&p(e.currentTarget.value),readOnly:!g,className:"w-full bg-transparent text-xl font-medium placeholder-gray-400 focus:outline-none",autoFocus:g})}),F.length>0&&et("div",{className:"relative flex items-center justify-between rounded-lg bg-white px-4 py-3 dark:bg-gray-900",children:[et("span",{className:"text-gray-700 dark:text-gray-300",children:d("calendar")}),et(Zr,{options:z,value:y,onChange:g?b:()=>{},registry:o.getCalendarRegistry(),variant:"mobile",disabled:!g})]}),et("div",{className:"flex items-center justify-between rounded-lg bg-white px-4 py-3 dark:bg-gray-900",children:[et("span",{className:"text-gray-700 dark:text-gray-300",children:d("allDay")}),et(Xr,{checked:w,onChange:g?D:()=>{},disabled:!g})]}),et("div",{className:"overflow-hidden rounded-lg bg-white dark:bg-gray-900",children:[et("div",{className:"flex items-center justify-between border-b border-gray-100 px-4 py-3 last:border-0 dark:border-gray-800",children:[et("span",{className:"text-gray-700 dark:text-gray-300",children:d("starts")}),et("div",{className:"flex space-x-2",children:[et("button",{type:"button",className:"rounded-md px-3 py-1 transition-colors "+("start-date"===A?"bg-gray-200 text-primary dark:bg-gray-700 dark:text-white":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"),onClick:()=>g&&U("start-date"),disabled:!g,children:Z(x)}),!w&&et("button",{type:"button",className:"rounded-md px-3 py-1 transition-colors "+("start-time"===A?"bg-gray-200 text-primary dark:bg-gray-700 dark:text-white":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"),onClick:()=>g&&U("start-time"),disabled:!g,children:be(x.getHours()+x.getMinutes()/60,0,i)})]})]}),et("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("start-date"===A?"max-h-100":"max-h-0"),children:et("div",{className:"",children:et(qr,{currentDate:x,visibleMonth:S,onDateSelect:e=>V("start",e),onMonthChange:e=>G("start",e),showHeader:!0})})}),et("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("start-time"===A?"max-h-75":"max-h-0"),children:et("div",{className:"",children:et(Jr,{date:x,onChange:e=>{const t=C.getTime()-x.getTime();E(e),k(new Date(e.getTime()+t))},timeFormat:i})})})]}),et("div",{className:"overflow-hidden rounded-lg bg-white dark:bg-gray-900",children:[et("div",{className:"flex items-center justify-between border-b border-gray-100 px-4 py-3 last:border-0 dark:border-gray-800",children:[et("span",{className:"text-gray-700 dark:text-gray-300",children:d("ends")}),et("div",{className:"flex space-x-2",children:[et("button",{type:"button",className:"rounded-md px-3 py-1 transition-colors "+("end-date"===A?"bg-gray-200 text-primary dark:bg-gray-700 dark:text-white":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"),onClick:()=>g&&U("end-date"),disabled:!g,children:Z(C)}),!w&&et("button",{type:"button",className:"rounded-md px-3 py-1 transition-colors "+("end-time"===A?"bg-gray-200 text-primary dark:bg-gray-700 dark:text-white":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"),onClick:()=>g&&U("end-time"),disabled:!g,children:be(C.getHours()+C.getMinutes()/60,0,i)})]})]}),et("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("end-date"===A?"max-h-100":"max-h-0"),children:et("div",{className:"",children:et(qr,{currentDate:C,visibleMonth:I,onDateSelect:e=>V("end",e),onMonthChange:e=>G("end",e),showHeader:!0})})}),et("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("end-time"===A?"max-h-75":"max-h-0"),children:et("div",{className:"",children:et(Jr,{date:C,onChange:e=>{if(e<x){const t=C.getTime()-x.getTime();k(e),E(new Date(e.getTime()-t))}else k(e)},timeFormat:i})})})]}),et("div",{className:"rounded-lg bg-white px-4 py-3 dark:bg-gray-900",children:et("textarea",{placeholder:d("notesPlaceholder"),value:T,onChange:e=>g&&N(e.currentTarget.value),readOnly:!g,className:"min-h-20 w-full bg-transparent text-base placeholder-gray-400 focus:outline-none"})}),g&&j&&r&&a&&et("button",{type:"button",onClick:()=>r(a.id),className:"w-full rounded-lg bg-white px-4 py-3 text-left font-medium text-red-500 dark:bg-gray-900",children:d("delete")})]})]})]}),document.body)},ea=()=>et("svg",{className:"h-12 w-12 text-gray-300 dark:text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:et("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),ta=({loading:e,results:t,keyword:n,onResultClick:r,emptyText:a})=>{const{t:o,locale:i}=vn(),l=v(()=>Bt(new Date),[]),s=v(()=>Vt(t,l),[t,l]),d=e=>Ut(e);return e?et("div",{className:"flex h-40 flex-col items-center justify-center text-gray-500",children:[et(vr,{className:"mb-2 h-8 w-8 animate-spin"}),et("span",{children:"Loading..."})]}):0===t.length?n?et("div",{className:"flex h-40 flex-col items-center justify-center text-gray-500",children:[et(ea,{}),et("span",{className:"mt-2 text-sm",children:"string"==typeof a?a:a&&"object"==typeof a?a[i]||a.en||"No results found":o("noResults")||"No results found"})]}):null:et("div",{className:"space-y-6",children:s.map(e=>{const{title:t,colorClass:n}=Zt(e.date,l,i,o);return et("div",{children:[et("h3",{className:`sticky top-0 z-10 mb-4 bg-white px-2 py-1 text-sm font-medium dark:bg-gray-900 ${n} border-b border-gray-200 dark:border-gray-700`,children:t}),et("div",{className:"flex flex-col",children:e.events.map(e=>{const t=d(e.start),n=d(e.end),a={hour:"2-digit",minute:"2-digit"},l=e.allDay?o("allDay")||"All Day":t.toLocaleTimeString(i,a),s=e.allDay?"":n.toLocaleTimeString(i,a);return et("div",{children:[et("div",{className:"group mx-2 mb-1 cursor-pointer rounded-lg p-2 transition-colors hover:bg-gray-50 dark:hover:bg-gray-800",onClick:()=>null==r?void 0:r(e),children:et("div",{className:"flex items-stretch gap-3",children:[et("div",{className:"w-1 shrink-0 rounded-full",style:{backgroundColor:e.color||"#3b82f6"}}),et("div",{className:"flex min-w-0 flex-1 items-start justify-between",children:[et("div",{className:"truncate pr-2 text-sm font-medium text-black dark:text-white",children:e.title}),et("div",{className:"flex shrink-0 flex-col items-end text-xs leading-tight",children:[et("div",{className:"text-black dark:text-white",children:l}),s&&et("div",{className:"text-gray-500 dark:text-gray-400",children:s})]})]})]})}),et("div",{className:"mx-2 border-b border-gray-200 dark:border-gray-700"})]},e.id)})})]},e.date.getTime())})})},na=({isOpen:e,onClose:t,keyword:n,onSearchChange:r,results:a,loading:o,onResultClick:i,emptyText:l})=>{const d=g(null),{t:c}=vn();return h(()=>(e?(setTimeout(()=>{var e;null===(e=d.current)||void 0===e||e.focus()},100),document.body.style.overflow="hidden"):document.body.style.overflow="",()=>{document.body.style.overflow=""}),[e]),e&&"undefined"!=typeof window?s(et("div",{className:"fixed inset-0 z-9999 bg-white dark:bg-gray-900 flex flex-col",children:[et("div",{className:"flex items-center p-2 border-b border-gray-200 dark:border-gray-700 gap-2",children:[et("button",{type:"button",onClick:t,className:"p-2 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:et(xr,{className:"h-6 w-6"})}),et("div",{className:"relative flex-1",children:[et("input",{ref:d,type:"text",placeholder:c("search")||"Search",value:n,onChange:e=>{const t=e.target.value;t!==n&&r(t)},className:"w-full rounded-full border-none bg-gray-100 py-2 pr-10 pl-3 text-gray-900 focus:ring-2 focus:ring-primary focus:outline-none dark:bg-gray-800 dark:text-gray-100"}),n&&et("button",{type:"button",onClick:()=>{""!==n&&r("")},className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400",children:et(hr,{className:"h-4 w-4"})})]})]}),et("div",{className:"flex-1 overflow-y-auto p-2 select-none",children:et(ta,{loading:o,results:a,keyword:n,onResultClick:e=>{null==i||i(e)},emptyText:l})})]}),document.body):null},ra=({isOpen:e,loading:t,results:n,keyword:r,onResultClick:a,emptyText:o})=>et("div",{className:"relative hidden h-full flex-col overflow-hidden border-l border-gray-200 bg-white transition-all duration-300 ease-in-out select-none md:flex dark:border-gray-700 dark:bg-gray-900 "+(e?"w-64":"w-0 border-l-0"),children:et("div",{className:"min-w-64 flex-1 overflow-y-auto",children:et(ta,{loading:t,results:n,keyword:r,onResultClick:a,emptyText:o})})});let aa=null;function oa(e){aa=e}const ia={enabled:!1,width:"0px",isCollapsed:!1,toggleCollapsed:()=>{},miniWidth:"0px",content:null,extraContent:null,safeAreaLeft:0};function la(e){return aa&&e.hasPlugin("sidebar")?aa(e):ia}const sa=({locale:e,messages:t,children:n})=>vn().isDefault?et(Sr,{locale:e,messages:t,children:n}):n,da=({app:e,customDetailPanelContent:t,customEventDetailDialog:n,meta:r,customMessages:o,search:i,titleBarSlot:l,collapsedSafeAreaLeft:d})=>{const c=f(fn),{tick:p,selectedEventId:b}=function(e){const[t,n]=u(0),[r,a]=u(null);return h(()=>e.subscribe(e=>{n(e=>e+1),a(t=>{var n;const r=null!==(n=e.state.selectedEventId)&&void 0!==n?n:null;return t===r?t:r})}),[e]),{tick:t,selectedEventId:r}}(e),{isMobile:w}=function(){const[e,t]=u(!1);return h(()=>{const e=()=>{t(window.matchMedia("(max-width: 768px)").matches)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),{isMobile:e}}(),D=function(e,t){const[n,r]=u(""),[a,o]=u(!1),[i,l]=u(!1),[s,d]=u(!1),[c,g]=u([]);h(()=>{e.state.highlightedEventId&&e.selectEvent(e.state.highlightedEventId)},[e.state.highlightedEventId,e]),h(()=>{a||null===e.state.highlightedEventId||e.highlightEvent(null)},[a,e]),h(()=>{var r;if(!n.trim())return o(!1),g([]),void(null!==e.state.highlightedEventId&&e.highlightEvent(null));const a=null!==(r=null==t?void 0:t.debounceDelay)&&void 0!==r?r:300,i=setTimeout(()=>y(this,void 0,void 0,function*(){var r;d(!0),o(!0);try{let a=[];if(null==t?void 0:t.customSearch){const r=e.getEvents().map(t=>{var n;return Object.assign(Object.assign({},t),{color:(null===(n=e.getCalendarRegistry().get(t.calendarId||""))||void 0===n?void 0:n.colors.lineColor)||e.getCalendarRegistry().resolveColors().lineColor})});a=t.customSearch({keyword:n,events:r})}else if(null==t?void 0:t.onSearch)a=yield t.onSearch(n);else{const t=n.toLowerCase();a=e.getEvents().filter(e=>e.title.toLowerCase().includes(t)||e.description&&e.description.toLowerCase().includes(t)).map(t=>{var n;return Object.assign(Object.assign({},t),{color:(null===(n=e.getCalendarRegistry().get(t.calendarId||""))||void 0===n?void 0:n.colors.lineColor)||e.getCalendarRegistry().resolveColors().lineColor})})}g(a),null===(r=null==t?void 0:t.onSearchStateChange)||void 0===r||r.call(t,{keyword:n,loading:!1,results:a})}catch(e){console.error("Search failed",e),g([])}finally{d(!1)}}),a);return()=>clearTimeout(i)},[n,t,e]);const v=m(t=>{let n;n=t.start instanceof Date?t.start:"string"==typeof t.start?new Date(t.start):B(t.start),e.setCurrentDate(n),e.highlightEvent(t.id),i&&l(!1)},[e,i]),f=m(()=>{r(""),l(!0)},[]),p=m(()=>{o(!1),r(""),e.highlightEvent(null)},[e]),b=m(()=>{l(!1),r(""),e.highlightEvent(null)},[e]);return{searchKeyword:n,setSearchKeyword:r,isSearchOpen:a,setIsSearchOpen:o,isMobileSearchOpen:i,setIsMobileSearchOpen:l,searchLoading:s,searchResults:c,handleSearchResultClick:v,handleSearchClick:f,handleSearchClose:p,handleMobileSearchClose:b}}(e,i),x=n||(e.getUseEventDetailDialog()?Vr:void 0),E=function(e,t,n){const[r,a]=u(null);h(()=>{a(null)},[e]);const o=m(()=>{a(null),e.selectEvent(null)},[e]),i=m(t=>e.updateEvent(t.id,t),[e]),l=m(t=>{e.deleteEvent(t),a(null),e.selectEvent(null)},[e]),s=v(()=>{if(!t||!r)return null;const n=r.split("::")[0],a=e.getEvents().find(e=>e.id===n);return a?{event:a,isOpen:!0,isAllDay:z(a.start),onEventUpdate:i,onEventDelete:l,onClose:o,app:e}:null},[n,r,t,o,i,l,e]);return{detailPanelEventId:r,setDetailPanelEventId:a,dialogProps:s}}(e,x,p),C=la(e),k=function(e,t,n){const[r,a]=u(!1),o=g(null),[i,l]=u(!1),[s,d]=u(null),[c,h]=u(!1),v=m(()=>{h(!0)},[]),f=m(i=>{var s,c;if(!e.state.readOnly){if(t){const t=new Date;t.setMinutes(0,0,0),t.setHours(t.getHours()+1);const n=new Date(t);n.setHours(n.getHours()+1);const r={id:Ge(),title:"",start:W(t),end:W(n),calendarId:(null===(s=e.getCalendars().find(e=>!1!==e.isVisible))||void 0===s?void 0:s.id)||(null===(c=e.getCalendars()[0])||void 0===c?void 0:c.id)};return d(r),void l(!0)}n?r?a(!1):(o.current=i.currentTarget,a(!0)):v()}},[t,r,e,n,v]);return{isQuickCreateOpen:r,setIsQuickCreateOpen:a,quickCreateAnchorRef:o,isMobileDrawerOpen:i,setIsMobileDrawerOpen:l,mobileDraftEvent:s,setMobileDraftEvent:d,handleAddButtonClick:f,isCreateCalendarOpen:c,setIsCreateCalendarOpen:h}}(e,w,C.enabled),[T,N]=u(()=>e.getTheme());h(()=>e.subscribeThemeChange(e=>N(e)),[e]);const S=m(t=>e.setTheme(t),[e]);h(()=>{const t=e.callbacks,n=t.onDismissUI;return t.onDismissUI=()=>{E.detailPanelEventId&&E.setDetailPanelEventId(null),k.isMobileDrawerOpen&&k.setIsMobileDrawerOpen(!1),null==n||n()},()=>{t.onDismissUI=n}},[e,E,k]),h(()=>{if(!w||!E.detailPanelEventId)return;const t=E.detailPanelEventId.split("::")[0],n=e.getEvents().find(e=>e.id===t);n&&(k.setMobileDraftEvent(n),k.setIsMobileDrawerOpen(!0)),E.setDetailPanelEventId(null)},[E.detailPanelEventId,w]);const M=m(t=>{e.setCurrentDate(t),e.selectEvent(null)},[e]),I=m(t=>e.selectEvent(t),[e]),H=g(null),A={app:e,config:e.getCurrentView().config||{},customDetailPanelContent:t,customEventDetailDialog:x,switcherMode:e.state.switcherMode,calendarRef:H,meta:r,selectedEventId:b,onEventSelect:I,onDateChange:M,detailPanelEventId:E.detailPanelEventId,onDetailPanelToggle:E.setDetailPanelEventId},O=v(()=>({isCollapsed:C.isCollapsed,toggleCollapsed:C.toggleCollapsed}),[C.isCollapsed,C.toggleCollapsed]),R=void 0!==d,P=R?"0px":C.miniWidth,L=R&&C.isCollapsed?d:C.safeAreaLeft,$=e.getCalendarHeaderConfig(),j=Object.assign({calendar:e,switcherMode:e.state.switcherMode,onAddCalendar:k.handleAddButtonClick,onSearchChange:D.setSearchKeyword,onSearchClick:D.handleSearchClick,searchValue:D.searchKeyword,isSearchOpen:D.isSearchOpen,isEditable:!e.state.readOnly},L>0?{safeAreaLeft:L}:{}),Y=e.getCurrentView().component,F=e.getCustomMobileEventRenderer()||Qr;return et(Ar,{initialTheme:T,onThemeChange:S,children:et(sa,{locale:e.state.locale,messages:o,children:et("div",{className:"df-calendar-container relative flex flex-row overflow-hidden select-none",children:[et(yn,{store:c,generatorName:"titleBarSlot",generatorArgs:O,defaultContent:l&&("function"==typeof l?l(O):l)}),C.enabled&&et("aside",{className:"absolute top-0 bottom-0 left-0 z-0 h-full",style:{width:C.width},children:C.content}),et("div",{className:"relative z-10 flex h-full flex-1 flex-col overflow-hidden border-l bg-white transition-all duration-250 ease-in-out dark:bg-gray-900 "+(C.isCollapsed?"border-gray-200 shadow-xl dark:border-gray-700":"border-transparent"),style:{marginLeft:C.enabled?C.isCollapsed?P:C.width:0},children:[!1===$?null:"function"==typeof $?$(j):a(Ir,j),et("div",{className:"relative flex-1 overflow-hidden",ref:H,children:[et("div",{className:"calendar-renderer relative flex h-full flex-row",children:[et("div",{className:"h-full flex-1 overflow-hidden",children:et(Y,Object.assign({},A))}),et(ra,{isOpen:D.isSearchOpen,onClose:D.handleSearchClose,loading:D.searchLoading,results:D.searchResults,keyword:D.searchKeyword,onResultClick:D.handleSearchResultClick,emptyText:null==i?void 0:i.emptyText})]}),et(na,{isOpen:D.isMobileSearchOpen,onClose:D.handleMobileSearchClose,keyword:D.searchKeyword,onSearchChange:D.setSearchKeyword,results:D.searchResults,loading:D.searchLoading,onResultClick:D.handleSearchResultClick,emptyText:null==i?void 0:i.emptyText})]})]}),et(Kr,{app:e,anchorRef:k.quickCreateAnchorRef,isOpen:k.isQuickCreateOpen,onClose:()=>k.setIsQuickCreateOpen(!1)}),et(F,{isOpen:k.isMobileDrawerOpen,onClose:()=>{k.setIsMobileDrawerOpen(!1),k.setMobileDraftEvent(null)},onSave:t=>{e.getEvents().some(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),k.setIsMobileDrawerOpen(!1),k.setMobileDraftEvent(null)},onEventDelete:t=>{e.deleteEvent(t),k.setIsMobileDrawerOpen(!1),k.setMobileDraftEvent(null)},draftEvent:k.mobileDraftEvent,app:e}),C.extraContent,k.isCreateCalendarOpen&&et($r,{onClose:()=>k.setIsCreateCalendarOpen(!1),onCreate:t=>{e.createCalendar(t),k.setIsCreateCalendarOpen(!1)}}),(()=>{if(!E.dialogProps)return null;const e=x,t="undefined"==typeof document?null:document.body;if(!t)return null;const n=null==c?void 0:c.isOverridden("eventDetailDialog");return et(yn,{store:c,generatorName:"eventDetailDialog",generatorArgs:E.dialogProps,defaultContent:n?null:s(a(e,E.dialogProps),t)})})()]})})})};class ca{constructor(e){this.renderings=new Map,this.overrides=new Set,this.listeners=new Set,e&&e.length>0&&(this.overrides=new Set(e))}register(e){this.renderings.set(e.id,e),this.notify()}unregister(e){this.renderings.delete(e)&&this.notify()}setOverrides(e){this.overrides=new Set(e),this.notify()}isOverridden(e){return this.overrides.has(e)}subscribe(e){return this.listeners.add(e),e(this.renderings),()=>{this.listeners.delete(e)}}notify(){this.listeners.forEach(e=>e(this.renderings))}}class ua{constructor(e,t){this.app=e,this.container=null,this.unsubscribe=null,this.renderRequested=!1,this.extraProps={},this.customRenderingStore=new ca(t),this.unsubscribe=e.subscribe(()=>this.requestRender())}setProps(e){Ke(this.extraProps,e)||(this.extraProps=e,this.requestRender())}requestRender(){this.renderRequested||(this.renderRequested=!0,requestAnimationFrame(()=>{this.render(),this.renderRequested=!1}))}mount(e){this.container=e,this.requestRender()}unmount(){this.container&&(o(null,this.container),this.container=null),this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null)}getCustomRenderingStore(){return this.customRenderingStore}render(){this.container&&o(a(fn.Provider,{value:this.customRenderingStore},a(da,Object.assign({app:this.app},this.extraProps))),this.container)}}const ha=d(({x:e,y:t,onClose:n,children:r,className:a},o)=>{const i=g(null);h(()=>{const e=()=>n(),t=e=>{if(i.current&&!i.current.contains(e.target)){if(e.target.closest("[data-submenu-content]"))return;n()}};window.dispatchEvent(new CustomEvent("dayflow-close-all-menus")),window.addEventListener("dayflow-close-all-menus",e),document.body.addEventListener("mousedown",t,{capture:!0}),document.body.addEventListener("contextmenu",t,{capture:!0});const r=e=>{"Escape"===e.key&&n()};window.addEventListener("keydown",r);const a=()=>n();return window.addEventListener("scroll",a,!0),window.addEventListener("resize",a),()=>{window.removeEventListener("dayflow-close-all-menus",e),document.body.removeEventListener("mousedown",t,{capture:!0}),document.body.removeEventListener("contextmenu",t,{capture:!0}),window.removeEventListener("keydown",r),window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",a)}},[n]);return s(et("div",{ref:e=>{i.current=e,"function"==typeof o?o(e):o&&"current"in o&&(o.current=e)},className:`animate-in fade-in-0 zoom-in-95 fixed z-50 min-w-32 overflow-visible rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md duration-100 ease-out dark:border-slate-800 dark:bg-slate-950 dark:text-slate-50 ${a||""}`,style:{top:t,left:e},onContextMenu:e=>e.preventDefault(),"data-context-menu-root":"true",children:r}),document.body)});ha.displayName="ContextMenu";const ga=({onClick:e,children:t,icon:n,danger:r,disabled:a})=>et("div",{className:`group relative flex cursor-default items-center rounded-sm px-3 py-0.5 text-[12px] transition-colors outline-none select-none ${a?"pointer-events-none opacity-50":"hover:bg-primary hover:text-white focus:bg-primary focus:text-white dark:hover:bg-primary dark:hover:text-white dark:focus:bg-primary dark:focus:text-white"} ${r?"text-destructive hover:bg-destructive hover:text-destructive-foreground focus:bg-destructive focus:text-destructive-foreground":"text-slate-900 dark:text-slate-50"}`,onClick:t=>{t.stopPropagation(),a||e()},"data-disabled":a,children:[n&&et("span",{className:"mr-2 h-4 w-4",children:n}),t]}),ma=()=>et("div",{className:"-mx-1 my-1 h-px bg-slate-200 dark:bg-slate-800"}),va=({children:e})=>et("div",{className:"px-3 py-0.5 text-[12px] font-semibold text-slate-950 dark:text-slate-50",children:e}),fa=({children:e})=>{const[t,n]=u(!1),r=g(null);return h(()=>()=>{r.current&&clearTimeout(r.current)},[]),et("div",{className:"relative",onMouseEnter:()=>{r.current&&(clearTimeout(r.current),r.current=null),n(!0)},onMouseLeave:()=>{r.current=setTimeout(()=>{n(!1)},100)},children:(Array.isArray(e)?e:[e]).map(e=>i(e)?l(e,{isOpen:t}):e)})},pa=({children:e,icon:t,isOpen:n})=>et("div",{className:"relative flex cursor-default items-center rounded-sm px-3 py-0.5 text-[12px] transition-colors outline-none select-none hover:bg-primary hover:text-white focus:bg-primary focus:text-white dark:hover:bg-primary dark:hover:text-white dark:focus:bg-primary dark:focus:text-white "+(n?"bg-primary text-white":""),children:[t&&et("span",{className:"mr-2 h-4 w-4",children:t}),et("span",{className:"grow text-left",children:e}),et(ar,{className:"ml-auto h-4 w-4 "+(n?"text-white opacity-100":"opacity-60")})]}),ya=({children:e,isOpen:t})=>{const n=g(null),[r,a]=u("right");return h(()=>{var e;if(t&&n.current){const t=n.current.getBoundingClientRect(),r=null===(e=n.current.parentElement)||void 0===e?void 0:e.getBoundingClientRect();r&&(r.right+t.width>window.innerWidth?a("left"):a("right"))}},[t]),t?et("div",{ref:n,className:"animate-in fade-in-0 zoom-in-95 absolute top-0 z-50 min-w-32 overflow-hidden rounded-md border border-slate-200 bg-white p-1 whitespace-nowrap text-slate-950 shadow-md duration-100 ease-out dark:border-slate-800 dark:bg-slate-950 dark:text-slate-50",style:{left:"right"===r?"100%":"auto",right:"left"===r?"100%":"auto",marginLeft:"right"===r?"0.25rem":0,marginRight:"left"===r?"0.25rem":0},"data-submenu-content":"true",children:e}):null},ba=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],wa=({selectedColor:e,onSelect:t,onCustomColor:n})=>{const{t:r}=vn();return et("div",{children:[et("div",{className:"grid grid-cols-7 gap-2 p-1 px-3",children:ba.map(n=>et("button",{type:"button",className:"h-5 w-5 rounded-full border border-gray-200 transition-transform hover:scale-110 focus:ring-2 focus:ring-primary focus:ring-offset-1 focus:outline-none dark:border-gray-600 dark:focus:ring-offset-slate-800 "+((null==e?void 0:e.toLowerCase())===n.toLowerCase()?"ring-2 ring-primary ring-offset-1 dark:ring-offset-slate-800":""),style:{backgroundColor:n},onClick:e=>{e.stopPropagation(),t(n)},title:n},n))}),n&&et("div",{className:"mt-1 flex cursor-pointer items-center rounded-sm px-3 py-0.5 text-[12px] text-slate-700 transition-colors hover:bg-primary hover:text-white dark:text-slate-200 dark:hover:bg-primary dark:hover:text-white",onClick:e=>{e.stopPropagation(),n()},children:r("customColor")})]})},Da=({x:t,y:n,date:r,onClose:a,app:o,onCreateEvent:i,viewType:l})=>{const{t:s}=vn(),d=Gt.hasEvent();return et(ha,{x:t,y:n,onClose:a,className:"df-context-menu",children:[et(ga,{onClick:()=>{i(),a()},children:s("newEvent")||"New Event"}),et(ga,{onClick:()=>y(void 0,void 0,void 0,function*(){yield((t,n,r)=>y(void 0,void 0,void 0,function*(){if(Gt.hasEvent())try{let a=Gt.getEvent();if(!a){const e=yield navigator.clipboard.readText();e&&(a=JSON.parse(e))}if(a&&"object"==typeof a&&"title"in a){const o=a,i=lt(o.start),l=lt(o.end).getTime()-i.getTime(),s=a,d=new Date(n),c=r===I.MONTH||r===I.YEAR,u=0===d.getHours()&&0===d.getMinutes(),h=0!==i.getHours()||0!==i.getMinutes();!o.allDay&&(c||u&&h)&&d.setHours(i.getHours(),i.getMinutes(),i.getSeconds(),i.getMilliseconds());const g=new Date(d.getTime()+(l>0?l:36e5)),m=Object.assign(Object.assign({},s),{title:o.title,id:Ge(),start:o.allDay?st(d):ct(d,e.Now.timeZoneId()),end:o.allDay?st(g):ct(g,e.Now.timeZoneId()),calendarId:o.calendarId&&t.getCalendarRegistry().has(o.calendarId)?o.calendarId:t.getCalendarRegistry().getDefaultCalendarId()||"default"});t.addEvent(m)}}catch(e){console.error("Failed to paste event:",e)}}))(o,r,l),a()}),disabled:!d,children:s("pasteHere")||"Paste Here"})]})},xa=({event:e,x:t,y:n,onClose:a,app:o})=>{var i;const{t:l}=vn(),s=o.getCalendars(),d=o.callbacks,c=null===(i=null==d?void 0:d.renderEventContextMenu)||void 0===i?void 0:i.call(d,e,a);return et(ha,{x:t,y:n,onClose:a,children:[et(fa,{children:[et(pa,{children:l("calendars")||"Calendars"}),et(ya,{children:s.map(t=>{const n=t.id===e.calendarId;return et(ga,{onClick:()=>{return n=t.id,o.updateEvent(e.id,{calendarId:n}),void a();var n},children:et("div",{className:"flex w-full items-center",children:[et("div",{className:"w-4 shrink-0",children:n&&et(cr,{className:"h-3 w-3 text-primary"})}),et("div",{className:"flex min-w-0 items-center gap-1.5",children:[et("div",{className:"h-3 w-3 shrink-0 rounded-sm",style:{backgroundColor:t.colors.lineColor}}),et("span",{className:"truncate "+(n?"font-semibold":""),children:t.name})]})]})},t.id)})})]}),et(ma,{}),et(ga,{onClick:()=>{o.deleteEvent(e.id),a()},danger:!0,children:l("delete")||"Delete"}),et(ga,{onClick:()=>y(void 0,void 0,void 0,function*(){try{const t=JSON.stringify(e,null,2);yield navigator.clipboard.writeText(t),Gt.setEvent(e),o.deleteEvent(e.id)}catch(e){console.error("Failed to cut event: ",e)}a()}),children:l("cut")||"Cut"}),et(ga,{onClick:()=>y(void 0,void 0,void 0,function*(){try{const t=JSON.stringify(e,null,2);yield navigator.clipboard.writeText(t),Gt.setEvent(e)}catch(e){console.error("Failed to copy event: ",e)}a()}),children:l("copy")||"Copy"}),c&&et(r,{children:[et(ma,{}),c]})]})},Ea=e=>{if(!1===e.icon)return null;if(void 0!==e.icon&&"boolean"!=typeof e.icon)return e.icon;const t=e.title.toLowerCase();return t.includes("holiday")||t.includes("vacation")||t.includes("假期")?et(fr,{className:"h-3 w-3"}):t.includes("birthday")||t.includes("anniversary")||t.includes("生日")?et(pr,{className:"h-3 w-3"}):t.includes("conference")||t.includes("meeting")||t.includes("会议")||t.includes("研讨")?et(br,{className:"h-3 w-3"}):t.includes("trip")||t.includes("travel")||t.includes("旅行")?et(yr,{className:"h-3 w-3"}):et(gr,{className:"h-3 w-3"})},Ca=(e,t,n=7)=>{const r=[],a=new Date(t);return a.setDate(t.getDate()+(n-1)),a.setHours(23,59,59,999),e.forEach(e=>{const o=B(e.start),i=B(e.end),l=new Date(o);l.setHours(0,0,0,0);const s=new Date(i);s.setHours(0,0,0,0);let d=new Date(s);if(!e.allDay){if(!(0!==i.getHours()||0!==i.getMinutes()||0!==i.getSeconds())){const e=i.getTime()-o.getTime();e>0&&e<864e5&&(d=new Date(s),d.setDate(d.getDate()-1))}}const c=J(l,d)>0;if(!c&&e.allDay){if(l<t||l>a)return;const o=Math.floor((l.getTime()-t.getTime())/864e5);return void(o>=0&&o<=n-1&&r.push({id:`${e.id}-week-${t.getTime()}`,originalEventId:e.id,event:e,startDayIndex:o,endDayIndex:o,segmentType:"single",totalDays:1,segmentIndex:0,isFirstSegment:!0,isLastSegment:!0}))}if(!c)return;const u=l;let h;if(e.allDay)h=new Date(s),h.setHours(23,59,59,999);else{0!==i.getHours()||0!==i.getMinutes()||0!==i.getSeconds()?(h=new Date(s),h.setHours(23,59,59,999)):(h=new Date(s),h.setTime(h.getTime()-1))}if(h<t||u>a)return;const g=u<t?t:u,m=h>a?a:h,v=Math.max(0,Math.floor((g.getTime()-t.getTime())/864e5)),f=Math.min(n-1,Math.floor((m.getTime()-t.getTime())/864e5)),p=u>=t,y=h<=a,b=0===v||f===n-1;let w;w=p&&y?"single":p?b&&f===n-1?"start-week-end":"start":y?b&&0===v?"end-week-start":"end":"middle";const D=J(u,h)+1;r.push({id:`${e.id}-week-${t.getTime()}`,originalEventId:e.id,event:e,startDayIndex:v,endDayIndex:f,segmentType:w,totalDays:D,segmentIndex:0,isFirstSegment:p,isLastSegment:y})}),r},ka=(e,t,n=7)=>{if(e.allDay)return[];const r=B(e.start),a=B(e.end),o=new Date(r);o.setHours(0,0,0,0);const i=new Date(a);i.setHours(0,0,0,0);const l=J(o,i);if(0===l)return[];const s=0!==a.getHours()||0!==a.getMinutes()||0!==a.getSeconds()||0!==a.getMilliseconds(),d=a.getTime()-r.getTime();if(!e.allDay&&1===l&&!s&&d<864e5)return[];const c=s?l:Math.max(0,l-1),u=[];for(let e=0;e<=c;e++){const i=new Date(o);i.setDate(o.getDate()+e);const l=Math.floor((i.getTime()-t.getTime())/864e5);if(l<0||l>n-1)continue;const d=0===e,h=e===c,g=d?r.getHours()+r.getMinutes()/60:0,m=h&&s?a.getHours()+a.getMinutes()/60:24;u.push({dayIndex:l,startHour:g,endHour:m,isFirst:d,isLast:h})}return u},Ta=c(({segment:e,segmentIndex:t,isDragging:n,isResizing:a=!1,isSelected:o=!1,onMoveStart:i,onResizeStart:l,onEventLongPress:s,isMobile:d=!1,isDraggable:c=!0,isEditable:h=!0,viewable:m=!0,isPopping:v})=>{const[f,p]=u(!1),y=17*t,b=`calc(${e.startDayIndex/7*100}% + 2px)`,w=`calc(${(e.endDayIndex-e.startDayIndex+1)/7*100}% - 4px)`,D=g(null),x=g(null),E=t=>{const n="left"===t;return(n?e.isFirstSegment:e.isLastSegment)&&l&&h?et("div",{className:`resize-handle absolute ${n?"left-0":"right-0"} top-0 bottom-0 z-20 w-1 cursor-ew-resize opacity-0 transition-opacity group-hover:opacity-100`,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),l(t,e.event,n?"left":"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}):null},C=e.event.calendarId||"blue",k=e.endDayIndex-e.startDayIndex+1;return et("div",{className:"group absolute flex items-center px-1 text-xs transition-all duration-200 select-none hover:shadow-sm dark:hover:shadow-lg dark:hover:shadow-black/20",style:Object.assign(Object.assign({left:b,width:w,top:`${y}px`,height:"16px",borderRadius:(T=e.segmentType,{single:"0.25rem",start:"0.25rem 0 0 0.25rem","start-week-end":"0.25rem 0 0 0.25rem",end:"0 0.25rem 0.25rem 0","end-week-start":"0 0.25rem 0.25rem 0",middle:"0"}[T]),pointerEvents:"auto",zIndex:10,transform:v?"scale(1.02)":"scale(1)",transition:"transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)",willChange:"transform"},o||n||f?{backgroundColor:fe(C),color:"#fff"}:{backgroundColor:me(C),color:ve(C)}),{cursor:c||m?"pointer":"default"}),"data-segment-days":k,onMouseDown:t=>{if(!c&&!m)return;t.preventDefault(),t.stopPropagation(),p(!0);!t.target.closest(".resize-handle")&&c&&(null==i||i(t,e.event))},onMouseUp:()=>{p(!1)},onMouseLeave:()=>{p(!1)},onTouchStart:t=>{if(!i||!d||!c&&!m)return;t.stopPropagation(),p(!0);const n=t.touches[0],r=n.clientX,a=n.clientY,o=t.currentTarget;x.current={x:r,y:a},D.current=setTimeout(()=>{s&&s(e.event.id);c&&i({preventDefault:()=>{},stopPropagation:()=>{},currentTarget:o,touches:[{clientX:r,clientY:a}],cancelable:!1},e.event),D.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},onTouchMove:e=>{if(D.current&&x.current){const t=Math.abs(e.touches[0].clientX-x.current.x),n=Math.abs(e.touches[0].clientY-x.current.y);(t>10||n>10)&&(clearTimeout(D.current),D.current=null,x.current=null,p(!1))}},onTouchEnd:()=>{p(!1),D.current&&(clearTimeout(D.current),D.current=null),x.current=null},title:`${e.event.title} (${tt(e.event.start)} - ${tt(e.event.end)})`,children:[d&&o&&h&&et(r,{children:[e.isFirstSegment&&et("div",{className:"pointer-events-auto absolute top-1/2 left-5 z-50 h-2.5 w-2.5 -translate-y-1/2 rounded-full border-2 bg-white",style:{borderColor:pe(C)},onTouchStart:t=>{t.stopPropagation(),null==l||l(t,e.event,"left")}}),e.isLastSegment&&et("div",{className:"pointer-events-auto absolute top-1/2 right-5 z-50 h-2.5 w-2.5 -translate-y-1/2 rounded-full border-2 bg-white",style:{borderColor:pe(C)},onTouchStart:t=>{t.stopPropagation(),null==l||l(t,e.event,"right")}})]}),E("left"),et("div",{className:"min-w-0 flex-1",style:{cursor:a?"ew-resize":"pointer"},children:(()=>{const t=e.event.allDay,n=e.event.calendarId||"blue",r=ne(e.event.start),a=we(e.event),o=be(r),i=be(a);if(t){const t=()=>e.isFirstSegment?e.event.title:"middle"===e.segmentType||e.isLastSegment&&e.totalDays>1?"···":e.event.title;return et("div",{className:"pointer-events-auto flex w-full min-w-0 items-center",children:[e.isFirstSegment&&Ea(e.event)&&et("div",{className:"mr-1 shrink-0",children:et("div",{className:"flex items-center justify-center rounded-full p-0.5 text-white",style:{backgroundColor:pe(n),width:"12px",height:"12px"},children:Ea(e.event)})}),et("div",{className:"min-w-0 flex-1",children:et("div",{className:"truncate text-xs",children:t()})}),e.isLastSegment&&"single"!==e.segmentType&&et("div",{className:"ml-1 shrink-0 text-white/80 dark:text-white/90",children:et("div",{className:"h-1.5 w-1.5 rounded-full bg-white/60 dark:bg-white/80"})})]})}const l=e.isFirstSegment||e.isLastSegment?e.event.title:"···",s=e.endDayIndex-e.startDayIndex+1,c=s>1?{position:"absolute",right:`calc(${s>1?(s-1)/s*100:0}% + 2px)`,top:"50%",transform:"translateY(-50%)"}:void 0;return et("div",{className:"pointer-events-auto relative flex w-full min-w-0 items-center",children:[et("div",{className:Pn,style:{backgroundColor:pe(n)}}),et("div",{className:"flex min-w-0 flex-1 items-center",children:et("span",{className:`block overflow-hidden whitespace-nowrap ${d?"mobile-mask-fade":"truncate"} text-xs font-medium`,children:l})}),e.isFirstSegment&&!d&&et("span",{className:"text-xs font-medium whitespace-nowrap "+(1===s?"ml-2":""),style:c,children:o}),e.isLastSegment&&!e.event.allDay&&24!==a&&!d&&et("span",{className:"ml-auto text-xs font-medium whitespace-nowrap",children:`ends ${i}`})]})})()}),E("right")]});var T});Ta.displayName="MultiDayEvent";const Na=({event:e,isEditable:t,onResizeStart:n,isMultiDay:r,segment:a,isSlidingView:o})=>{const i=!1!==e.icon,l="boolean"==typeof e.icon?null:e.icon;return et("div",{className:"flex h-full items-center overflow-hidden pl-3 px-1 group relative py-0",style:(()=>{if(!o||!r||!a)return{};if(a.startDayIndex<2&&a.endDayIndex>=2){return{paddingLeft:`calc(${(2-a.startDayIndex)/(a.endDayIndex-a.startDayIndex+1)*100}% + 0.75rem)`}}return{}})(),children:[n&&t&&et("div",{className:"resize-handle absolute left-0 top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20",onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),n(t,e,"left")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}),i&&(l?et("div",{className:"mr-1 shrink-0",children:l}):et(gr,{className:Ln})),et("div",{className:`${Rn} pr-1`,style:{lineHeight:"1.2"},children:e.title}),n&&t&&et("div",{className:$n,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),n(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]})},Sa=({event:e,isEventSelected:t})=>{const n=!1!==e.icon,r="boolean"==typeof e.icon?null:e.icon;return et("div",{className:"text-xs px-1 rounded truncate cursor-pointer flex items-center",children:[n&&(r?et("div",{className:`${tr} shrink-0`,children:r}):e.title.toLowerCase().includes("easter")||e.title.toLowerCase().includes("holiday")?et("span",{className:`inline-block ${tr} shrink-0 ${t?"text-yellow-200":"text-yellow-600"}`,children:"⭐"}):et(gr,{className:`${Ln} ${t?"text-white":""}`})),et("span",{className:"truncate "+(t?"text-white":""),children:e.title})]})},Ma=({event:e,app:t,isEventSelected:n,hideTime:r,isMobile:a})=>{const o=`${Math.floor(ne(e.start)).toString().padStart(2,"0")}:${Math.round(ne(e.start)%1*60).toString().padStart(2,"0")}`;return et("div",{className:"text-xs cursor-pointer flex items-center justify-between",children:[et("div",{className:"flex min-w-0 flex-1 items-center",children:[et("div",{style:{backgroundColor:pe(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())},className:Pn}),et("span",{className:`block overflow-hidden whitespace-nowrap ${a?"mobile-mask-fade":"truncate"} ${n?"text-white":""}`,children:e.title})]}),!r&&!a&&et("span",{className:`${Jn} ml-1 shrink-0 ${n?"text-white":""}`,style:n?void 0:{opacity:.8},children:o})]})},Ia=({event:e,app:t,multiDaySegmentInfo:n,isEditable:a,isTouchEnabled:o,isEventSelected:i,onResizeStart:l,timeFormat:s="24h"})=>{const d=n?n.startHour:ne(e.start),c=n?n.endHour:we(e),u=c-d,h=!n||n.isFirst,g=!n||n.isLast,m=e.calendarId||"blue";return et(r,{children:[et("div",{className:"df-event-color-bar absolute left-1 top-1 bottom-1 w-[3px] rounded-full",style:{backgroundColor:pe(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())}}),et("div",{className:"flex h-full flex-col overflow-hidden pl-3 "+(we(e)-ne(e.start)<=.25?"px-1 py-0":"p-1"),children:[et("div",{className:`${Rn} pr-1`,style:{lineHeight:u<=.25?"1.2":"normal"},children:e.title}),u>.5&&et("div",{className:"df-event-time text-xs opacity-80 truncate",children:n?`${be(d,0,s)} - ${be(c,0,s)}`:De(e,s)})]}),l&&a&&et(r,{children:[h&&et("div",{className:"absolute top-0 left-0 w-full h-1.5 cursor-ns-resize z-10 rounded-t-sm",onMouseDown:t=>l(t,e,"top")}),g&&et("div",{className:"absolute bottom-0 left-0 w-full h-1.5 cursor-ns-resize z-10 rounded-b-sm",onMouseDown:t=>l(t,e,"bottom")}),!h&&g&&n&&et("div",{className:$n,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),l(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]}),o&&i&&l&&a&&et(r,{children:[et("div",{className:"absolute -top-1.5 right-5 z-50 h-2.5 w-2.5 rounded-full border-2 bg-white",style:{borderColor:pe(m,null==t?void 0:t.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),l(t,e,"top")}}),et("div",{className:"absolute -bottom-1.5 left-5 z-50 h-2.5 w-2.5 rounded-full border-2 bg-white",style:{borderColor:pe(m,null==t?void 0:t.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),l(t,e,"bottom")}})]})]})},Ha=({event:e,segment:t,isEditable:n,onMoveStart:a,onResizeStart:o})=>{const i=!!e.allDay,l=e.calendarId||"blue",s=pe(l),d=i?Ea(e):null,{isFirstSegment:c,isLastSegment:u}=t,h=t=>{const r="left"===t,a=r?c:u;return e.allDay&&a&&o&&n?et("div",{className:`resize-handle absolute ${r?"left-0":"right-0"} top-0 bottom-0 z-20 w-1 cursor-ew-resize opacity-0 transition-opacity group-hover:opacity-100`,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),o(t,e,r?"left":"right")},onTouchStart:t=>{t.stopPropagation(),o(t,e,r?"left":"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}):null};return et(r,{children:[h("left"),(()=>{if(i){const n=()=>t.isFirstSegment?e.title:"···";return et("div",{className:"df-year-event-content pointer-events-auto flex h-full w-full min-w-0 items-center",onMouseDown:t=>{a&&(t.stopPropagation(),a(t,e))},children:[t.isFirstSegment&&Ea(e)&&et("div",{className:"df-year-event-icon mr-1 shrink-0",children:et("div",{className:"flex items-center justify-center rounded-full p-0.5 text-white",style:{backgroundColor:pe(l),width:"12px",height:"12px"},children:Ea(e)})}),et("div",{className:"min-w-0 flex-1",children:et("div",{className:"df-year-event-title overflow-hidden text-[12px] leading-none whitespace-nowrap",style:{maskImage:"linear-gradient(to right, black 70%, transparent 100%)",WebkitMaskImage:"linear-gradient(to right, black 70%, transparent 100%)"},children:n()})}),t.isLastSegment&&!t.isFirstSegment&&et("div",{className:"ml-1 shrink-0 text-white/80 dark:text-white/90",children:et("div",{className:"h-1.5 w-1.5 rounded-full bg-white/60 dark:bg-white/80"})})]})}const n=t.isFirstSegment?e.title:"";return et("div",{className:"df-year-event-content pointer-events-auto flex h-full w-full items-center gap-1 overflow-hidden",onMouseDown:t=>{a&&(t.stopPropagation(),a(t,e))},children:[!i&&et("span",{style:{backgroundColor:s},className:"df-year-event-indicator inline-block h-3 w-0.75 shrink-0 rounded-full"}),i&&d&&et("div",{className:"df-year-event-icon flex shrink-0 scale-75 items-center justify-center opacity-80",children:d}),et("span",{className:"df-year-event-title block w-full overflow-hidden text-[12px] leading-none font-medium whitespace-nowrap",style:{maskImage:"linear-gradient(to right, black 70%, transparent 100%)",WebkitMaskImage:"linear-gradient(to right, black 70%, transparent 100%)"},children:n})]})})(),h("right")]})},Aa=({event:e,viewType:t,isMultiDay:n,segment:r,yearSegment:a,segmentIndex:o,isBeingDragged:i,isBeingResized:l,isEventSelected:s,isPopping:d,isEditable:c,isDraggable:u,canOpenDetail:h,isTouchEnabled:g,hideTime:m,isMobile:v,isSlidingView:f,app:p,onMoveStart:y,onResizeStart:b,multiDaySegmentInfo:w,customRenderingStore:D,eventContentSlotArgs:x,timeFormat:E="24h"})=>{const C=t===I.MONTH;let k;return k=t===I.YEAR&&a?et(Ha,{event:e,segment:a,isEditable:c,onMoveStart:y,onResizeStart:b}):C?n&&r?et(Ta,{segment:r,segmentIndex:null!=o?o:0,isDragging:i||s,isResizing:l,isSelected:s,onMoveStart:y,onResizeStart:b,isMobile:v,isDraggable:u,isEditable:c,viewable:h,isPopping:d}):e.allDay?et(Sa,{event:e,isEventSelected:s}):et(Ma,{event:e,app:p,isEventSelected:s,hideTime:m,isMobile:v}):e.allDay?et(Na,{event:e,isEditable:c,onResizeStart:b,isMultiDay:n,segment:r,isSlidingView:f}):et(Ia,{event:e,app:p,multiDaySegmentInfo:w,isEditable:c,isTouchEnabled:g,isEventSelected:s,onResizeStart:b,timeFormat:E}),et(yn,{store:D,generatorName:"eventContent",generatorArgs:x,defaultContent:k})},Oa=({event:t,position:n,panelRef:r,isAllDay:a,eventVisibility:o,calendarRef:i,selectedEventElementRef:l,onEventUpdate:d,onEventDelete:c,app:g})=>{var m;const{effectiveTheme:f}=Or(),p=Ot(f),{t:y}=vn(),[b,w]=u(t.title),[D,x]=u(null!==(m=t.description)&&void 0!==m?m:"");h(()=>{w(t.title)},[t.title]),h(()=>{var e;x(null!==(e=t.description)&&void 0!==e?e:"")},[t.description]),h(()=>{const e=setTimeout(()=>{b!==t.title&&d(Object.assign(Object.assign({},t),{title:b}))},500);return()=>clearTimeout(e)},[b,t]),h(()=>{const e=setTimeout(()=>{var e;const n=null!==(e=t.description)&&void 0!==e?e:"";D!==n&&d(Object.assign(Object.assign({},t),{description:D}))},500);return()=>clearTimeout(e)},[D,t]);const E=v(()=>z(t.start)?t.end&&!z(t.end)&&t.end.timeZoneId||e.Now.timeZoneId():t.start.timeZoneId||e.Now.timeZoneId(),[t.end,t.start]),C=v(()=>(g?g.getCalendarRegistry():he()).getVisible().map(e=>({label:e.name,value:e.id})),[g,null==g?void 0:g.getCalendars()]),k="dark"===p||"undefined"!=typeof document&&document.documentElement.classList.contains("dark"),T=!(null==g?void 0:g.state.readOnly);if(!(!1!==(null==g?void 0:g.getReadOnlyConfig().viewable)))return null;const N=k?"#1f2937":"white",S=k?"rgb(55, 65, 81)":"rgb(229, 231, 235)",M=(()=>{var e;let t={};if("sticky-top"===o){const r=null===(e=i.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(r){const e=r.getBoundingClientRect().top+3-n.top;t=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:N,transform:"rotate(45deg)",transformOrigin:"center",top:e-6+"px",borderRight:""+(n.isSunday?`1px solid ${S}`:"none"),borderTop:""+(n.isSunday?`1px solid ${S}`:"none"),borderLeft:""+(n.isSunday?"none":`1px solid ${S}`),borderBottom:""+(n.isSunday?"none":`1px solid ${S}`)},n.isSunday?{right:"-6px"}:{left:"-6px"})}}else if("sticky-bottom"===o){const e=r.current;let a=200;if(e){const t=e.getBoundingClientRect(),n=window.getComputedStyle(e),r=Number.parseInt(n.paddingBottom,10)||0,o=Number.parseInt(n.borderBottomWidth,10)||0;a=t.height-r-o-6+11}t={position:"absolute",width:"12px",height:"12px",backgroundColor:N,transform:"rotate(45deg)",transformOrigin:"center",top:`${a}px`,left:n.isSunday?void 0:"-6px",right:n.isSunday?"-6px":void 0,borderRight:""+(n.isSunday?`1px solid ${S}`:"none"),borderTop:""+(n.isSunday?`1px solid ${S}`:"none"),borderLeft:""+(n.isSunday?"none":`1px solid ${S}`),borderBottom:""+(n.isSunday?"none":`1px solid ${S}`)}}else if(n&&l.current&&i.current){const e=l.current.getBoundingClientRect(),a=i.current.querySelector(".calendar-content");if(a){const o=a.getBoundingClientRect(),i=Math.max(e.top,o.top),l=Math.min(e.bottom,o.bottom),s=Math.max(0,l-i);let d;d=s===e.height?e.top+e.height/2:s>0?i+s/2:e.top+e.height/2;const c=d-n.top,u=r.current;let h=228;if(u){const e=u.getBoundingClientRect(),t=window.getComputedStyle(u),n=Number.parseInt(t.paddingBottom,10)||0,r=Number.parseInt(t.borderBottomWidth,10)||0;h=e.height-n-r+11}const g=12,m=Math.max(g,Math.min(h,c));t=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:N,transform:"rotate(45deg)",transformOrigin:"center",top:m-6+"px",borderRight:""+(n.isSunday?`1px solid ${S}`:"none"),borderTop:""+(n.isSunday?`1px solid ${S}`:"none"),borderLeft:""+(n.isSunday?"none":`1px solid ${S}`),borderBottom:""+(n.isSunday?"none":`1px solid ${S}`)},n.isSunday?{right:"-6px"}:{left:"-6px"})}}return t})(),I=et("div",{ref:r,className:`${zn} p-4`,"data-event-detail-panel":"true","data-event-id":t.id,style:{top:`${n.top}px`,left:`${n.left}px`,zIndex:9999,pointerEvents:"auto"},children:[et("div",{style:M}),et("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:y("eventTitle")}),et("div",{className:"mb-3 flex items-center justify-between gap-3",children:[et("div",{className:"flex-1",children:et("input",{id:`event-title-${t.id}`,name:"title",type:"text",value:b,readOnly:!T,disabled:!T,onChange:e=>w(e.target.value),onInput:e=>w(e.target.value),className:"w-full rounded-lg border border-slate-200 px-3 py-1.5 text-sm text-gray-900 shadow-sm transition focus:border-primary focus:ring-2 focus:ring-primary focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100"})}),T&&et(Zr,{options:C,value:t.calendarId||"blue",onChange:e=>{d(Object.assign(Object.assign({},t),{calendarId:e}))},registry:null==g?void 0:g.getCalendarRegistry()})]}),et("div",a?{className:"mb-3",children:[et("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:y("dateRange")}),et(Br,{value:[t.start,t.end],format:"YYYY-MM-DD",showTime:!1,timeZone:E,matchTriggerWidth:!0,disabled:!T,onChange:e=>{const[n,r]=e;d(Object.assign(Object.assign({},t),{start:n.toPlainDate(),end:r.toPlainDate()}))},locale:null==g?void 0:g.state.locale})]}:{className:"mb-3",children:[et("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:y("timeRange")}),et(Br,{value:[t.start,t.end],timeZone:E,disabled:!T,onChange:e=>{const[n,r]=e;d(Object.assign(Object.assign({},t),{start:n,end:r}))},locale:null==g?void 0:g.state.locale})]}),et("div",{className:"mb-3",children:[et("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:y("note")}),et("textarea",{id:`event-note-${t.id}`,name:"note",value:D,readOnly:!T,disabled:!T,onChange:e=>x(e.target.value),onInput:e=>x(e.target.value),rows:3,className:"w-full resize-none rounded-lg border border-slate-200 px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:border-primary focus:ring-2 focus:ring-primary focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",placeholder:y("addNotePlaceholder")})]}),T&&et("div",{className:"flex space-x-2",children:[et("button",a?{type:"button",className:"rounded bg-primary px-2 py-1 text-xs font-medium text-primary-foreground transition hover:bg-primary",onClick:()=>{const n=z(t.start)?t.start:t.start.toPlainDate(),r=e.ZonedDateTime.from({year:n.year,month:n.month,day:n.day,hour:9,minute:0,timeZone:e.Now.timeZoneId()}),a=e.ZonedDateTime.from({year:n.year,month:n.month,day:n.day,hour:10,minute:0,timeZone:e.Now.timeZoneId()});d(Object.assign(Object.assign({},t),{allDay:!1,start:r,end:a}))},children:y("setAsTimed")}:{type:"button",className:"rounded bg-primary px-2 py-1 text-xs font-medium text-primary-foreground transition hover:bg-primary",onClick:()=>{const e=z(t.start)?t.start:t.start.toPlainDate();d(Object.assign(Object.assign({},t),{allDay:!0,start:e,end:e}))},children:y("setAsAllDay")}),et("button",{type:"button",className:"rounded bg-destructive px-2 py-1 text-xs font-medium text-destructive-foreground transition hover:bg-destructive/90",onClick:()=>c(t.id),children:y("delete")})]})]});if("undefined"==typeof window||"undefined"==typeof document)return null;const H=document.body;return H?s(I,H):null},Ra=({event:e,position:t,panelRef:n,isAllDay:r,eventVisibility:a,calendarRef:o,selectedEventElementRef:i,onEventUpdate:l,onEventDelete:d,onClose:c,contentRenderer:u})=>{const{effectiveTheme:h}=Or(),g=Ot(h),m="dark"===g?"#1f2937":"white",v="dark"===g?"rgb(55, 65, 81)":"rgb(229, 231, 235)",f=(()=>{var e;let r={};if("sticky-top"===a){const n=null===(e=o.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(n){const e=n.getBoundingClientRect().top+3-t.top;r=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:m,transform:"rotate(45deg)",transformOrigin:"center",top:e-6+"px",borderRight:""+(t.isSunday?`1px solid ${v}`:"none"),borderTop:""+(t.isSunday?`1px solid ${v}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${v}`),borderBottom:""+(t.isSunday?"none":`1px solid ${v}`)},t.isSunday?{right:"-6px"}:{left:"-6px"})}}else if("sticky-bottom"===a){const e=n.current;let a=200;if(e){const t=e.getBoundingClientRect(),n=window.getComputedStyle(e),r=Number.parseInt(n.paddingBottom,10)||0,o=Number.parseInt(n.borderBottomWidth,10)||0;a=t.height-r-o-6+11}r={position:"absolute",width:"12px",height:"12px",backgroundColor:m,transform:"rotate(45deg)",transformOrigin:"center",top:`${a}px`,left:t.isSunday?void 0:"-6px",right:t.isSunday?"-6px":void 0,borderRight:""+(t.isSunday?`1px solid ${v}`:"none"),borderTop:""+(t.isSunday?`1px solid ${v}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${v}`),borderBottom:""+(t.isSunday?"none":`1px solid ${v}`)}}else if(t&&i.current&&o.current){const e=i.current.getBoundingClientRect(),a=o.current.querySelector(".calendar-content");if(a){const o=a.getBoundingClientRect(),i=Math.max(e.top,o.top),l=Math.min(e.bottom,o.bottom),s=Math.max(0,l-i);let d;d=s===e.height?e.top+e.height/2:s>0?i+s/2:e.top+e.height/2;const c=d-t.top,u=n.current;let h=228;if(u){const e=u.getBoundingClientRect(),t=window.getComputedStyle(u),n=Number.parseInt(t.paddingBottom,10)||0,r=Number.parseInt(t.borderBottomWidth,10)||0;h=e.height-n-r+11}const g=12,f=Math.max(g,Math.min(h,c));r=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:m,transform:"rotate(45deg)",transformOrigin:"center",top:f-6+"px",borderRight:""+(t.isSunday?`1px solid ${v}`:"none"),borderTop:""+(t.isSunday?`1px solid ${v}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${v}`),borderBottom:""+(t.isSunday?"none":`1px solid ${v}`)},t.isSunday?{right:"-6px"}:{left:"-6px"})}}return r})(),p=et("div",{ref:n,className:`${zn} p-3`,"data-event-detail-panel":"true","data-event-id":e.id,style:{top:`${t.top}px`,left:`${t.left}px`,zIndex:9999,pointerEvents:"auto",backgroundColor:"dark"===g?"#1f2937":"#ffffff"},children:[et("div",{style:f}),et(u,{event:e,isAllDay:r,onEventUpdate:l,onEventDelete:d,onClose:c})]});return s(p,document.body)},Pa=({showDetailPanel:e,customEventDetailDialog:t,detailPanelPosition:n,event:r,detailPanelRef:a,isAllDay:o,eventVisibility:i,calendarRef:l,selectedEventElementRef:s,onEventUpdate:d,onEventDelete:c,handlePanelClose:u,customRenderingStore:h,contentSlotRenderer:g,customDetailPanelContent:m,app:v})=>{if(!e)return null;if(t)return null;if(!n)return null;const f={event:r,position:n,panelRef:a,isAllDay:o,eventVisibility:i,calendarRef:l,selectedEventElementRef:s,onEventUpdate:d,onEventDelete:c,onClose:u};return(null==h?void 0:h.isOverridden("eventDetailContent"))?et(Ra,Object.assign({},f,{contentRenderer:g})):m?et(Ra,Object.assign({},f,{contentRenderer:m})):et(Oa,Object.assign({},f,{app:v}))},La=(e,t)=>{if(!e.current)return t?48:80;const n=e.current.querySelector(".df-time-column");return n?n.getBoundingClientRect().width:t?48:80},$a=(e,t,n,r,a)=>{let o="df-event calendar-event select-none pointer-events-auto px-0.5";const i=e===I.DAY,l=e===I.MONTH,s=e===I.YEAR;i?o+=" df-day-event flex flex-col":l||s?s&&(o+=" df-year-event transition-colors group px-1 overflow-hidden whitespace-nowrap cursor-pointer"):o+=" df-week-event flex flex-col";const d=()=>{if(n&&r){const{segmentType:e}=r;if("single"===e||"start"===e)return An;if("start-week-end"===e)return"rounded-l-xl rounded-r-none my-0.5";if("end"===e||"end-week-start"===e)return"rounded-r-xl rounded-l-none my-0.5";if("middle"===e)return"rounded-none my-0.5"}return An};if(s)return`${o} ${(()=>{if(a){const{isFirstSegment:e,isLastSegment:t}=a;return e&&t?"rounded":e?"rounded-l rounded-r-none":t?"rounded-r rounded-l-none":"rounded-none"}return"rounded"})()}`;if(l){let e=`\n ${o}\n ${t?d():On}\n `;return n||(e+=" mb-[2px]"),e}return`\n ${o}\n shadow-sm\n ${t?d():On}\n `},ja=({event:e,layout:t,isAllDay:n=!1,allDayHeight:a=28,calendarRef:o,isBeingDragged:i=!1,isBeingResized:l=!1,viewType:s,isMultiDay:d=!1,segment:c,yearSegment:p,columnsPerRow:y,segmentIndex:b=0,hourHeight:w,firstHour:D,selectedEventId:x,detailPanelEventId:E,onMoveStart:C,onResizeStart:k,onEventUpdate:T,onEventDelete:N,newlyCreatedEventId:S,onDetailPanelOpen:M,onEventSelect:H,onEventLongPress:A,onDetailPanelToggle:O,customDetailPanelContent:R,customEventDetailDialog:P,multiDaySegmentInfo:L,app:$,isMobile:j=!1,isSlidingView:Y=!1,enableTouch:F,hideTime:z,timeFormat:_="24h"})=>{const W=f(fn),U=null!=F?F:j,B=s===I.YEAR,[Z,V]=u(null),[G,K]=u(!1),q=g(null),X=g(null),J=g(null),Q=g(null),ee=d&&c?`${e.id}::${c.id}`:void 0===(null==L?void 0:L.dayIndex)?B&&p?p.id:e.id:`${e.id}::day-${L.dayIndex}`,te=E===ee,re=te&&!P,ae=null==$?void 0:$.getReadOnlyConfig(),oe=!(null==$?void 0:$.state.readOnly),ie=!1!==(null==ae?void 0:ae.viewable),le=!1!==(null==ae?void 0:ae.draggable),{isSelected:se,setIsSelected:de,isPressed:ce,setIsPressed:ue,handleTouchStart:he,handleTouchMove:ge,handleTouchEnd:pe}=(({event:e,isTouchEnabled:t,onMoveStart:n,onEventLongPress:r,onDetailPanelToggle:a,canOpenDetail:o,app:i,multiDaySegmentInfo:l,isMultiDay:s,segment:d,detailPanelKey:c})=>{const[h,m]=u(!1),[v,f]=u(!1),p=g(null),y=g(null);return{isSelected:h,setIsSelected:m,isPressed:v,setIsPressed:f,handleTouchStart:a=>{if(!n||!t)return;f(!0);const o=a.touches[0],i=o.clientX,c=o.clientY,u=a.currentTarget;y.current={x:i,y:c},p.current=setTimeout(()=>{var t;r?r(e.id):m(!0);const a={preventDefault:()=>{},stopPropagation:()=>{},currentTarget:u,touches:[{clientX:i,clientY:c}],cancelable:!1};if(l){const r=Object.assign(Object.assign({},e),{day:null!==(t=l.dayIndex)&&void 0!==t?t:e.day,_segmentInfo:l});n(a,r)}else if(s&&d){const t=Object.assign(Object.assign({},e),{day:d.startDayIndex,_segmentInfo:{dayIndex:d.startDayIndex,isFirst:d.isFirstSegment,isLast:d.isLastSegment}});n(a,t)}else n(a,e);p.current=null,y.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},handleTouchMove:e=>{if(p.current&&y.current){const t=Math.abs(e.touches[0].clientX-y.current.x),n=Math.abs(e.touches[0].clientY-y.current.y);(t>10||n>10)&&(clearTimeout(p.current),p.current=null,y.current=null,f(!1))}},handleTouchEnd:n=>{f(!1),p.current&&(clearTimeout(p.current),p.current=null),t&&y.current&&(n.preventDefault(),n.stopPropagation(),i&&i.onEventClick(e),o?null==a||a(c):null==a||a(null)),y.current=null}}})({event:e,isTouchEnabled:U,onMoveStart:C,onEventLongPress:A,onDetailPanelToggle:O,canOpenDetail:ie,app:$,multiDaySegmentInfo:L,isMultiDay:d,segment:c,detailPanelKey:ee}),ye=(void 0===x?se:x===e.id)||!U&&ce||i,[be,De]=u("visible"),xe=e=>{Q.current=e},Ee=m(()=>((e,t,n,r,a,o)=>{var i;if(null!==r)return r;if(t===n){const e=n.split("::").at(-1);if(e&&e.startsWith("day-")){const t=Number(e.replace("day-",""));if(!Number.isNaN(t))return t}}return void 0!==(null==a?void 0:a.dayIndex)?a.dayIndex:o?o.startDayIndex:null!==(i=e.day)&&void 0!==i?i:0})(e,E||void 0,ee,Q.current,L,c),[e,E,ee,L,c]),Ce=m(e=>((e,t,n,r)=>{if(!t.current)return null;const a=t.current.getBoundingClientRect();if(n===I.MONTH){const t=a.width/7,n=e-a.left,r=Math.floor(n/t);return Number.isFinite(r)?Math.max(0,Math.min(6,r)):null}const o=La(t,r),i=n===I.DAY?1:7,l=(a.width-o)/i,s=e-a.left-o,d=Math.floor(s/l);return Number.isFinite(d)?Math.max(0,Math.min(i-1,d)):null})(e,o,s,j),[o,s,j]),ke=m(e=>((e,t,n,r)=>{if(!t.current)return null;const a=t.current.getBoundingClientRect();if(n===I.MONTH){const t=a.width/7;return{left:a.left+e*t,width:t}}const o=La(t,r);if(n===I.DAY){const e=a.width-o;return{left:a.left+o,width:e}}const i=(a.width-o)/7;return{left:a.left+o+e*i,width:i}})(e,o,s,j),[o,s,j]),{detailPanelPosition:Te,setDetailPanelPosition:Ne,updatePanelPosition:Se}=(({event:e,viewType:t,isMultiDay:n,segment:r,yearSegment:a,multiDaySegmentInfo:o,calendarRef:i,eventRef:l,detailPanelRef:s,selectedEventElementRef:d,isMobile:c,eventVisibility:g,firstHour:v,hourHeight:f,columnsPerRow:p,showDetailPanel:y,detailPanelEventId:b,detailPanelKey:w,getActiveDayIdx:D,getDayMetricsWrapper:x})=>{const[E,C]=u(null),k=t===I.DAY,T=t===I.MONTH,N=t===I.YEAR,S=m(()=>{if(!d.current||!i.current||!s.current)return;const e=i.current.getBoundingClientRect(),t=D(),a=x(t);let o,u;if(a)o=a.left,u=a.width;else if(T)u=e.width/7,o=e.left+t*u;else{const n=La(i,c);u=(e.width-n)/7,o=e.left+n+t*u}const h=Math.min(window.innerWidth,e.right),m=Math.min(window.innerHeight,e.bottom);requestAnimationFrame(()=>{var a,i,c;if(!s.current)return;if(!d.current)return;const u=s.current.getBoundingClientRect(),v=u.width,f=u.height;let p,y,b;if("sticky-top"===g||"sticky-bottom"===g){const e=null===(a=l.current)||void 0===a?void 0:a.getBoundingClientRect();if(!e)return;b=e}else b=d.current.getBoundingClientRect();if(T&&n&&r){const n=x(t),r=null!==(i=null==n?void 0:n.width)&&void 0!==i?i:e.width/7,a=null!==(c=null==n?void 0:n.left)&&void 0!==c?c:e.left+t*r,o=a+r;b={top:b.top,bottom:b.bottom,left:a,right:o,width:o-a,height:b.height,x:a,y:b.top,toJSON:()=>({})}}const w=h-b.right,D=b.left-e.left;p=w>=v+20?b.right+10:D>=v+20?b.left-v-10:w>D?Math.max(e.left+10,h-v-10):e.left+10;const E=b.top-f/2+b.height/2,k=Math.max(10,e.top+10),S=m-10;y=E<k?k:E+f>S?S-f:E,C(e=>{if(!e)return null;let t=p<o;return N&&(t=p<b.left),Object.assign(Object.assign({},e),{top:y,left:p,isSunday:t})})})},[i,e.day,e.start,e.end,g,T,v,f,n,r,o,b,w,c,k,N,a,p,D,x,d,s,l]);return h(()=>{!y||E||c||(C({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>S()))},[y,E,S,c]),{detailPanelPosition:E,setDetailPanelPosition:C,updatePanelPosition:S}})({event:e,viewType:s,isMultiDay:d,segment:c,yearSegment:p,multiDaySegmentInfo:L,calendarRef:o,eventRef:q,detailPanelRef:X,selectedEventElementRef:J,isMobile:j,eventVisibility:be,firstHour:D,hourHeight:w,columnsPerRow:y,showDetailPanel:te,detailPanelEventId:E,detailPanelKey:ee,getActiveDayIdx:Ee,getDayMetricsWrapper:ke}),{handleClick:Me,handleDoubleClick:Ie,handleContextMenu:He}=(({event:e,viewType:t,isAllDay:n,isMultiDay:r,segment:a,multiDaySegmentInfo:o,calendarRef:i,firstHour:l,hourHeight:s,isMobile:d,canOpenDetail:c,detailPanelKey:u,app:h,onEventSelect:g,onDetailPanelToggle:v,setIsSelected:f,setDetailPanelPosition:p,setContextMenuPosition:y,setActiveDayIndex:b,getClickedDayIdx:w,updatePanelPosition:D,selectedEventElementRef:x})=>{const E=t===I.MONTH,C=t===I.YEAR,k=m(()=>new Promise(t=>{if(!i.current||n||E||C)return void t();const r=i.current.querySelector(".calendar-content");if(!r)return void t();const a=o?o.startHour:ne(e.start),d=o?o.endHour:we(e),c=(a-l)*s,u=c+Math.max((d-a)*s,s/4),h=r.scrollTop,g=r.clientHeight;if(c>=h&&u<=h+g)return void t();const m=((a+d)/2-l)*s-g/2,v=r.scrollHeight-g;r.scrollTo({top:Math.max(0,Math.min(v,m)),behavior:"smooth"}),setTimeout(()=>t(),300)}),[i,n,E,C,o,e.start,e.end,l,s]),T=m(t=>{t.preventDefault(),t.stopPropagation(),g&&g(e.id),y({x:t.clientX,y:t.clientY})},[e.id,g,y]),N=m(t=>{var n,o,i,l,s;if(!c)return;t.preventDefault(),t.stopPropagation();let h=t.currentTarget;if(r){const e=h.querySelector("div");e&&(h=e)}if(x.current=h,r){const r=w(t.clientX);b(null===r?null!==(o=null!==(n=null==a?void 0:a.startDayIndex)&&void 0!==n?n:e.day)&&void 0!==o?o:0:Math.min(Math.max(r,null!==(i=null==a?void 0:a.startDayIndex)&&void 0!==i?i:0),null!==(l=null==a?void 0:a.endDayIndex)&&void 0!==l?l:6))}else b(null!==(s=e.day)&&void 0!==s?s:null);k().then(()=>{f(!0),d||(null==v||v(u),p({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>D()))})},[c,r,x,w,b,null==a?void 0:a.startDayIndex,null==a?void 0:a.endDayIndex,e.day,k,f,d,v,u,p,D]);return{handleClick:m(t=>{var n,i,l;if(t.preventDefault(),t.stopPropagation(),r){const r=w(t.clientX);b(null===r?null!==(i=null!==(n=null==o?void 0:o.dayIndex)&&void 0!==n?n:e.day)&&void 0!==i?i:null:a?Math.min(Math.max(r,a.startDayIndex),a.endDayIndex):r)}else b(null!==(l=e.day)&&void 0!==l?l:null);h&&h.onEventClick(e),g?g(e.id):c&&f(!0),null==v||v(null),p(null)},[r,w,b,a,null==o?void 0:o.dayIndex,e,h,g,c,f,v,p]),handleDoubleClick:N,handleContextMenu:T,scrollEventToCenter:k}})({event:e,viewType:s,isAllDay:n,isMultiDay:d,segment:c,multiDaySegmentInfo:L,calendarRef:o,firstHour:D,hourHeight:w,isMobile:j,canOpenDetail:ie,detailPanelKey:ee,app:$,onEventSelect:H,onDetailPanelToggle:O,setIsSelected:de,setDetailPanelPosition:Ne,setContextMenuPosition:V,setActiveDayIndex:xe,getClickedDayIdx:Ce,updatePanelPosition:Se,selectedEventElementRef:J}),{calculateEventStyle:Ae}=(({event:e,layout:t,isAllDay:n,allDayHeight:r,viewType:a,isMultiDay:o,segment:i,yearSegment:l,columnsPerRow:s,segmentIndex:d,hourHeight:c,firstHour:u,isEventSelected:h,showDetailPanel:g,isPopping:m,isDraggable:v,canOpenDetail:f,eventVisibility:p,calendarRef:y,isMobile:b,eventRef:w,getActiveDayIdx:D,getDayMetricsWrapper:x,multiDaySegmentInfo:E})=>{const C=a===I.DAY,k=a===I.MONTH,T=a===I.YEAR;return{calculateEventStyle:()=>{var a,N,S,M,I,H,A,O;if(T&&l&&s){const{startCellIndex:e,endCellIndex:t,visualRowIndex:n}=l,r=2;return{position:"absolute",left:`calc(${e/s*100}% + ${r}px)`,top:18*n+"px",width:`calc(${(t-e+1)/s*100}% - ${2*r}px)`,height:"16px",opacity:1,zIndex:h||g?1e3:1,transform:m?"scale(1.05)":"scale(1)",transition:"transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)",cursor:v||f?"pointer":"default"}}if(k)return o&&i?{opacity:1,zIndex:h||g?1e3:1,cursor:v||f?"pointer":"default"}:{opacity:1,zIndex:h||g?1e3:1,transform:m?"scale(1.05)":"scale(1)",transition:"transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)",cursor:v||f?"pointer":"default"};if(n){const e={height:r-4+"px",opacity:1,zIndex:h||g?1e3:1,transform:m?"scale(1.05)":"scale(1)",transition:"transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)",cursor:v||f?"pointer":"default"},t=d*r;if(Object.assign(e,{top:`${t}px`}),C)Object.assign(e,{width:"100%",left:"0px",right:"2px",position:"absolute"});else if(o&&i){const t=s||7,n=(i.endDayIndex-i.startDayIndex+1)/t*100,r=i.startDayIndex/t*100,a=2,o=i.isFirstSegment?a:0,l=o+(i.isLastSegment?a:0);Object.assign(e,{width:l>0?`calc(${n}% - ${l}px)`:`${n}%`,left:o>0?`calc(${r}% + ${o}px)`:`${r}%`,position:"absolute",pointerEvents:"auto"})}else Object.assign(e,{width:"100%",left:"0px",position:"relative"});return e}const R=E?E.startHour:ne(e.start),P=E?E.endHour:we(e),L={top:(R-u)*c+3+"px",height:Math.max((P-R)*c,c/4)-4+"px",position:"absolute",opacity:1,zIndex:h||g?1e3:null!==(a=null==t?void 0:t.zIndex)&&void 0!==a?a:1,transform:m?"scale(1.05)":"scale(1)",transition:"transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)",cursor:v||f?"pointer":"default"};if(h&&g&&("sticky-top"===p||"sticky-bottom"===p)){const e=null===(N=y.current)||void 0===N?void 0:N.getBoundingClientRect();if(e){const n=D(),r=La(y,b),a=C?1:s||7;let o=(e.width-r)/a,i=e.left+r+(C?0:n*o);k&&(o=e.width/7,i=e.left+n*o);const l=x(n);l&&(i=l.left,o=l.width);let d=null===(S=y.current)||void 0===S?void 0:S.querySelector(".calendar-content");d||(d=null===(M=y.current)||void 0===M?void 0:M.querySelector(".calendar-renderer"));const c=null==d?void 0:d.getBoundingClientRect(),u=null===(H=null===(I=w.current)||void 0===I?void 0:I.parentElement)||void 0===H?void 0:H.getBoundingClientRect();let h,g;if(u&&u.width>0)t?(h=u.left+t.left/100*u.width,g=C?t.width/100*u.width:(t.width-1)/100*u.width):(h=u.left,g=C?u.width:u.width-3);else{const e=x(n),r=null!==(A=null==e?void 0:e.left)&&void 0!==A?A:i,a=null!==(O=null==e?void 0:e.width)&&void 0!==O?O:o;h=r,g=a-3,t&&(h=r+t.left/100*a,g=C?t.width/100*a:(t.width-1)/100*a)}if("sticky-top"===p){let t=c?c.top:e.top;return t=Math.max(t,0),t=Math.max(t,e.top),t=Math.min(t,e.bottom-6),t=Math.min(t,window.innerHeight-6),{position:"fixed",top:`${t}px`,left:`${h}px`,width:`${g}px`,height:"6px",zIndex:1e3,overflow:"hidden"}}let m=c?c.bottom:e.bottom;return m=Math.min(m,window.innerHeight),m=Math.min(m,e.bottom),m=Math.max(m,e.top+6),m=Math.max(m,6),{position:"fixed",top:m-6+"px",left:`${h}px`,width:`${g}px`,height:"6px",zIndex:1e3,overflow:"hidden"}}}if(t&&!n){const e=C?`${t.width}%`:t.width-1+"%";return Object.assign(Object.assign({},L),{left:`${t.left}%`,width:e,right:"auto"})}return Object.assign(Object.assign({},L),{left:"0px",right:C?"0px":"3px"})}}})({event:e,layout:t,isAllDay:n,allDayHeight:a,viewType:s,isMultiDay:d,segment:c,yearSegment:p,columnsPerRow:y,segmentIndex:b,hourHeight:w,firstHour:D,isEventSelected:ye,showDetailPanel:te,isPopping:G,isDraggable:le,canOpenDetail:ie,eventVisibility:be,calendarRef:o,isMobile:j,eventRef:q,getActiveDayIdx:Ee,getDayMetricsWrapper:ke,multiDaySegmentInfo:L});(({event:e,isEventSelected:t,showDetailPanel:n,eventRef:r,calendarRef:a,isAllDay:o,viewType:i,multiDaySegmentInfo:l,firstHour:s,hourHeight:d,updatePanelPosition:c,eventVisibility:u,setEventVisibility:g})=>{const v=i===I.MONTH,f=i===I.YEAR,p=m(()=>{if(!t||!n||!r.current||!a.current||o||v||f)return;const i=a.current.querySelector(".calendar-content");if(!i)return;const h=l?l.startHour:ne(e.start),m=l?l.endHour:we(e),p=(h-s)*d,y=p+Math.max((m-h)*d,d/4),b=i.getBoundingClientRect(),w=i.scrollTop,D=w+b.height,x=b.bottom<0,E=b.top>window.innerHeight;let C=u;x?C="sticky-top":E?C="sticky-bottom":"visible"===u?y<w?C="sticky-top":p>D-20&&(C="sticky-bottom"):"sticky-top"===u?y>=w&&(C="visible"):"sticky-bottom"===u&&p<=D-20&&(C="visible"),C!==u&&g(C),c()},[t,n,a,o,v,e.start,e.end,s,d,c,l,u,g]);h(()=>{var e,r;if(!t||!n||o)return;const i=null===(e=a.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(!i)return;const l=()=>p(),s=()=>{p(),c()},d=[i];let u=null===(r=a.current)||void 0===r?void 0:r.parentElement;for(;u;){const e=window.getComputedStyle(u);"auto"!==e.overflowY&&"scroll"!==e.overflowY&&"auto"!==e.overflowX&&"scroll"!==e.overflowX||d.push(u),u=u.parentElement}d.forEach(e=>{e.addEventListener("scroll",l)}),window.addEventListener("scroll",l,!0),window.addEventListener("resize",s);let h=null;return a.current&&(h=new ResizeObserver(()=>{s()}),h.observe(a.current)),p(),()=>{d.forEach(e=>{e.removeEventListener("scroll",l)}),window.removeEventListener("scroll",l,!0),window.removeEventListener("resize",s),h&&h.disconnect()}},[t,n,o,p,c,a])})({event:e,isEventSelected:ye,showDetailPanel:te,eventRef:q,calendarRef:o,isAllDay:n,viewType:s,multiDaySegmentInfo:L,firstHour:D,hourHeight:w,updatePanelPosition:Se,eventVisibility:be,setEventVisibility:De});const Oe=te&&!!P;(({eventRef:e,detailPanelRef:t,eventId:n,isEventSelected:r,showDetailPanel:a,onEventSelect:o,onDetailPanelToggle:i,setIsSelected:l,setActiveDayIndex:s})=>{h(()=>{if(!r&&!a)return;const d=d=>{var c,u;const h=d.target,g=null===(c=e.current)||void 0===c?void 0:c.contains(h),m=null!==h.closest(`[data-event-id="${n}"]`),v=null===(u=t.current)||void 0===u?void 0:u.contains(h),f=h.closest("[data-event-detail-dialog]"),p=h.closest("[data-range-picker-popup]"),y=h.closest("[data-calendar-picker-dropdown]");a?g||m||v||f||p||y||(null==o||o(null),s(null),l(!1),null==i||i(null)):!r||g||m||f||p||y||(null==o||o(null),s(null),l(!1),null==i||i(null))};return document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d)}},[r,a,o,i,n])})({eventRef:q,detailPanelRef:X,eventId:e.id,isEventSelected:!Oe&&ye,showDetailPanel:re,onEventSelect:H,onDetailPanelToggle:O,setIsSelected:de,setActiveDayIndex:xe});const Re=m(()=>{H&&H(null),Q.current=null,de(!1),null==O||O(null)},[H,O,de]),Pe=v(()=>({event:e,isAllDay:n,onEventUpdate:T,onEventDelete:N,onClose:Re}),[e,n,T,N,Re]),Le=v(()=>({event:e,isAllDay:n,isMobile:j,isMonthView:s===I.MONTH,segment:c,layout:t}),[e,n,j,s,c,t]),$e=m(()=>et(yn,{store:W,generatorName:"eventDetailContent",generatorArgs:Pe}),[W,Pe]);h(()=>{if((null==$?void 0:$.state.highlightedEventId)===e.id){K(!0);const e=setTimeout(()=>{K(!1)},300);return()=>{clearTimeout(e),K(!1)}}},[null==$?void 0:$.state.highlightedEventId,e.id]),h(()=>{const t=d&&(null==c?void 0:c.isFirstSegment)||B&&(null==p?void 0:p.isFirstSegment)||!d&&!B;S===e.id&&!te&&t&&setTimeout(()=>{null==O||O(ee),null==M||M()},50)},[S,e.id,te,d,c,B,p,O,M,ee]);const je=e.calendarId||"blue",Ye=null==$?void 0:$.getCalendarRegistry();return et(r,{children:[et("div",{ref:q,"data-event-id":e.id,className:`${$a(s,n,d,c,p)} ${n&&S===e.id?"df-all-day-event-animate":""}`,style:Object.assign(Object.assign({},Ae()),{backgroundColor:ye?fe(je,Ye):me(je,Ye),color:ye?"#fff":ve(je,Ye)}),onClick:U?void 0:Me,onContextMenu:U?void 0:He,onDblClick:U?void 0:Ie,onMouseDown:t=>{var n;if(U||ue(!0),C){const r=t;C(r,L?Object.assign(Object.assign({},e),{day:null!==(n=L.dayIndex)&&void 0!==n?n:e.day,_segmentInfo:L}):d&&c?Object.assign(Object.assign({},e),{day:c.startDayIndex,_segmentInfo:{dayIndex:c.startDayIndex,isFirst:c.isFirstSegment,isLast:c.isLastSegment}}):e)}},onMouseUp:()=>!U&&ue(!1),onMouseLeave:()=>!U&&ue(!1),onTouchStart:he,onTouchMove:ge,onTouchEnd:pe,children:et(Aa,{event:e,viewType:s,isMultiDay:d,segment:c,yearSegment:p,segmentIndex:b,isBeingDragged:i,isBeingResized:l,isEventSelected:ye,isPopping:G,isEditable:oe,isDraggable:le,canOpenDetail:ie,isTouchEnabled:U,hideTime:z,isMobile:j,isSlidingView:Y,app:$,onMoveStart:C,onResizeStart:k,multiDaySegmentInfo:L,customRenderingStore:W,eventContentSlotArgs:Le,layout:t,timeFormat:_})}),te&&!P&&et("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:9998,pointerEvents:"none"}}),et(Pa,{showDetailPanel:te,customEventDetailDialog:P,detailPanelPosition:Te,event:e,detailPanelRef:X,isAllDay:n,eventVisibility:be,calendarRef:o,selectedEventElementRef:J,onEventUpdate:T,onEventDelete:N,handlePanelClose:Re,customRenderingStore:W,contentSlotRenderer:$e,customDetailPanelContent:R,app:$}),Z&&$&&et(xa,{event:e,x:Z.x,y:Z.y,onClose:()=>V(null),app:$,onDetailPanelToggle:O,detailPanelKey:ee})]})},Ya=({handlePreviousMonth:e,handleToday:t,handleNextMonth:n})=>{const{t:r}=vn();return et("div",{className:"df-navigation flex items-center gap-1",children:[et("button",{type:"button",className:Yn,onClick:e,"aria-label":"Previous month",children:et(rr,{className:Fn})}),et("button",{type:"button",className:"df-today-button calendar-today-button inline-flex items-center justify-center px-4 h-7 text-sm font-medium rounded-md border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 hover:bg-gray-50 dark:hover:bg-gray-700 hover:border-gray-300 dark:hover:border-gray-500 active:bg-gray-100 dark:active:bg-gray-600 transition-all duration-150 shadow-sm hover:shadow focus:outline-none",onClick:t,children:r("today")}),et("button",{type:"button",className:Yn,onClick:n,"aria-label":"Next month",children:et(ar,{className:Fn})})]})},Fa=({viewType:e,currentDate:t,onPrevious:n,onNext:r,onToday:a,customTitle:o,customSubtitle:i,showTodayBox:l,stickyYear:s,stickyYearOffset:d=0,nextYear:c,nextYearOffset:u=0})=>{const{locale:h}=vn(),g=void 0===l||l,m=o||(()=>{switch(e){case"day":return t.toLocaleDateString(h,{day:"numeric",month:"long",year:"numeric"});case"week":case"month":return t.toLocaleDateString(h,{month:"long",year:"numeric"});case"year":return t.getFullYear().toString();default:return""}})(),v="day"===e?i||("day"===e?t.toLocaleDateString(h,{weekday:"long"}):null):null;return et("div",{className:wn,style:{position:"relative"},onContextMenu:e=>e.preventDefault(),children:[et("div",{className:"flex-1",children:et("div","year"===e&&s?{style:{position:"relative",overflow:"hidden",height:"1.5em"},children:[et("h1",{className:Dn,style:{position:"absolute",top:0,left:0,transform:`translateY(-${d}px)`,willChange:"transform"},children:s}),c&&et("h1",{className:Dn,style:{position:"absolute",top:0,left:0,transform:`translateY(${u}px)`,willChange:"transform"},children:c})]}:{children:[et("div",{className:`${Dn} text-gray-900 dark:text-white`,children:m}),v&&et("div",{className:"mt-3 text-gray-600 dark:text-gray-400",children:v})]})}),g&&n&&r&&a&&et("div",{className:"flex items-center gap-2",children:et(Ya,{handlePreviousMonth:n,handleNextMonth:r,handleToday:a})})]})},za=({app:e,currentDate:t,currentWeekStart:n,events:r,currentDayEvents:a,organizedAllDayEvents:o,allDayAreaHeight:i,timeSlots:l,eventLayouts:s,isToday:d,currentTime:c,selectedEventId:h,setSelectedEventId:m,newlyCreatedEventId:f,setNewlyCreatedEventId:p,detailPanelEventId:y,setDetailPanelEventId:b,dragState:w,isDragging:D,handleMoveStart:x,handleResizeStart:E,handleCreateStart:C,handleCreateAllDayEvent:k,handleTouchStart:T,handleTouchEnd:N,handleTouchMove:S,handleDragOver:M,handleDrop:H,handleEventUpdate:A,handleEventDelete:O,onDateChange:R,customDetailPanelContent:P,customEventDetailDialog:L,calendarRef:$,allDayRowRef:j,timeGridRef:Y,switcherMode:F,isMobile:z,isTouch:_,setDraftEvent:W,setIsDrawerOpen:U,ALL_DAY_HEIGHT:B,HOUR_HEIGHT:Z,FIRST_HOUR:V,LAST_HOUR:G,showAllDay:K,showStartOfDayLabel:q,timeFormat:X="24h",secondaryTimeSlots:J,primaryTzLabel:Q,secondaryTzLabel:ee})=>{var te;const ne=!!J&&J.length>0&&!z,{t:re,locale:ae}=vn(),oe=g(e.state.highlightedEventId),[ie,le]=u(null),se=v(()=>St(),[]),de=()=>{var e;const t=null===(e=$.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(!t)return 0;const n=t.querySelector(".df-time-grid-row");return n?n.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop:0},ce=(e,n)=>{var r,a,o,i;if(e.preventDefault(),z)return;const l=new Date(t);if(n)l.setHours(0,0,0,0);else{const t=null===(a=null===(r=$.current)||void 0===r?void 0:r.querySelector(".calendar-content"))||void 0===a?void 0:a.getBoundingClientRect();if(t){const n=(null===(i=null===(o=$.current)||void 0===o?void 0:o.querySelector(".calendar-content"))||void 0===i?void 0:i.scrollTop)||0,r=de(),a=(e.clientY-t.top+n-r)/Z+V,s=Math.floor(a),d=Math.floor(60*(a-s)),c=15*Math.round(d/15),u=60===c?s+1:s,h=60===c?0:c;l.setHours(u,h,0,0)}}le({x:e.clientX,y:e.clientY,date:l})};return et("div",{className:`flex-none ${"buttons"===F?"":"md:w-[60%]"} w-full border-r border-gray-200 bg-white md:w-[70%] dark:border-gray-700 dark:bg-gray-900`,onContextMenu:e=>e.preventDefault(),children:[et("div",{className:`relative ${er} h-full`,children:[et("div",{onContextMenu:e=>e.preventDefault(),style:{paddingRight:z||!se?"0px":"15px"},children:et(Fa,{calendar:e,viewType:I.DAY,currentDate:t,customSubtitle:t.toLocaleDateString(ae,{weekday:"long"})})}),et("div",K?{className:nr(Hn,"items-stretch border-t border-gray-200 dark:border-gray-700"),ref:j,style:{paddingRight:z||!se?"0px":"0.6875rem"},onContextMenu:e=>ce(e,!0),children:[et("div",{className:"df-all-day-label flex-shrink-0 p-1 text-xs font-medium text-gray-500 dark:text-gray-400 flex justify-end select-none flex w-12 items-center text-[10px] md:w-20 md:text-xs",onContextMenu:e=>e.preventDefault(),children:re("allDay")}),et("div",{className:nr("relative flex flex-1 self-stretch",!z&&se?"border-r border-gray-200 dark:border-gray-700":""),children:et("div",{className:"relative w-full",style:{minHeight:`${i}px`},onClick:()=>null==R?void 0:R(t),onMouseDown:e=>{const r=Math.floor((t.getTime()-n.getTime())/864e5);null==k||k(e,r)},onDblClick:e=>{const r=Math.floor((t.getTime()-n.getTime())/864e5);null==k||k(e,r)},onDragOver:M,onDrop:e=>{H(e,t,void 0,!0)},children:o.map(t=>et(ja,{event:t,isAllDay:!0,viewType:I.DAY,segmentIndex:t.row,allDayHeight:B,calendarRef:$,isBeingDragged:D&&(null==w?void 0:w.eventId)===t.id&&"move"===(null==w?void 0:w.mode),hourHeight:Z,firstHour:V,onMoveStart:x,onEventUpdate:A,onEventDelete:O,newlyCreatedEventId:f,onDetailPanelOpen:()=>p(null),detailPanelEventId:y,onDetailPanelToggle:e=>b(e),selectedEventId:h,onEventSelect:t=>{const n=e.getReadOnlyConfig().viewable,a=e.state.readOnly,o=r.find(e=>e.id===t);(z||_)&&o&&n&&!a?(W(o),U(!0)):(m(t),e.state.highlightedEventId&&(e.highlightEvent(null),oe.current=null))},onEventLongPress:e=>{(z||_)&&m(e)},customDetailPanelContent:P,customEventDetailDialog:L,app:e,isMobile:z,enableTouch:_},t.id))})})]}:{className:nr("border-b border-gray-200 dark:border-gray-700",!z&&se?"pr-2.75":"")}),et("div",{className:"relative overflow-y-auto calendar-content df-day-time-grid",style:{position:"relative",scrollbarGutter:"stable"},children:et("div",{className:"relative flex",children:[d&&c&&(()=>{const e=c,t=e.getHours()+e.getMinutes()/60;if(t<V||t>G)return null;return et("div",{className:Mn,style:{top:`${(t-V)*Z}px`,width:"100%",height:0,zIndex:20,marginTop:ne?"2rem":"0.75rem"},children:[et("div",{className:"flex w-12 items-center md:w-20",children:[et("div",{className:"relative flex w-full items-center"}),et("div",{className:In,children:be(t,0,X,!1)})]}),et("div",{className:"flex flex-1 items-center",children:et("div",{className:"df-current-time-bar h-0.5 w-full bg-primary relative"})})]})})(),et("div",{className:"df-time-column flex-shrink-0 border-gray-200 dark:border-gray-700 "+(ne?"w-20 md:w-22":"w-12 md:w-20"),onContextMenu:e=>e.preventDefault(),children:[et("div",{className:ne?"h-8":"h-3",children:ne&&et("div",{className:"flex items-center justify-evenly gap-1 pt-1 pr-1 pb-0.5",children:[et("span",{className:"text-[9px]select-none text-gray-500 md:text-[10px] dark:text-gray-400",children:ee}),et("span",{className:"text-[9px] text-gray-500 md:text-[10px] dark:text-gray-400",children:Q})]})}),l.map((e,t)=>{var n;return et("div",{className:Tn,children:et("div",ne?{className:"absolute top-0 right-0 flex w-full -translate-y-1/2 items-center justify-evenly gap-1 text-gray-500 select-none dark:text-gray-400",children:[et("span",{className:"text-[10px] md:text-[12px]",children:q&&0===t?"":null!==(n=null==J?void 0:J[t])&&void 0!==n?n:""}),et("span",{className:"text-[10px] text-gray-500 md:text-[12px] dark:text-gray-400",children:q&&0===t?"":e.label})]}:{className:`${Nn} text-[10px] md:text-[12px]`,children:q&&0===t?"":e.label})},t)})]}),et("div",{className:"grow select-none",children:[et("div",{className:nr(Wn,!z&&se?"border-r":"","border-t-0"),style:ne?{height:"2rem"}:void 0,children:et("div",{className:`${Un} -left-9.5`,style:{top:"auto",bottom:"-0.625rem"},children:q?be(V,0,X):""})}),et("div",{className:"relative",style:{WebkitTouchCallout:"none"},ref:Y,children:[l.map((e,r)=>et("div",{className:nr(Sn,!z&&se?"border-r":""),onClick:()=>null==R?void 0:R(t),onDblClick:e=>{var r,a,o,i;const l=Math.floor((t.getTime()-n.getTime())/864e5),s=null===(a=null===(r=$.current)||void 0===r?void 0:r.querySelector(".calendar-content"))||void 0===a?void 0:a.getBoundingClientRect();if(!s)return;const d=(null===(i=null===(o=$.current)||void 0===o?void 0:o.querySelector(".calendar-content"))||void 0===i?void 0:i.scrollTop)||0,c=de(),u=e.clientY-s.top+d-c;null==C||C(e,l,V+u/Z)},onTouchStart:e=>{const r=Math.floor((t.getTime()-n.getTime())/864e5);T(e,r)},onTouchEnd:N,onTouchMove:S,onDragOver:M,onDrop:e=>{var n,r,a,o;const i=null===(r=null===(n=$.current)||void 0===n?void 0:n.querySelector(".calendar-content"))||void 0===r?void 0:r.getBoundingClientRect();if(!i)return;const l=(null===(o=null===(a=$.current)||void 0===a?void 0:a.querySelector(".calendar-content"))||void 0===o?void 0:o.scrollTop)||0,s=de(),d=e.clientY-i.top+l-s,c=Math.floor(V+d/Z);H(e,t,c)},onContextMenu:e=>ce(e,!1)},r)),et("div",{className:nr(Wn,!z&&se?"border-r":""),children:et("div",ne?{className:"absolute -top-2.5 flex items-center justify-evenly text-[10px] text-gray-500 select-none md:text-[12px] dark:text-gray-400",style:{left:z?"-5rem":"-5.5rem",width:z?"5rem":"5.5rem"},children:[et("span",{children:null!==(te=null==J?void 0:J[0])&&void 0!==te?te:""}),et("span",{children:be(0,0,X)})]}:{className:`${Un} -left-9.5`,children:be(0,0,X)})}),et("div",{className:"pointer-events-none absolute top-0 right-0 bottom-0 left-0",children:a.filter(e=>!e.allDay).map(t=>{const n=s.get(t.id);return et(ja,{event:t,layout:n,viewType:I.DAY,calendarRef:$,isBeingDragged:D&&(null==w?void 0:w.eventId)===t.id&&"move"===(null==w?void 0:w.mode),hourHeight:Z,firstHour:V,onMoveStart:x,onResizeStart:E,onEventUpdate:A,onEventDelete:O,newlyCreatedEventId:f,onDetailPanelOpen:()=>p(null),detailPanelEventId:y,onDetailPanelToggle:e=>b(e),selectedEventId:h,onEventSelect:t=>{const n=e.getReadOnlyConfig().viewable,a=r.find(e=>e.id===t);(z||_)&&a&&n?(W(a),U(!0)):(m(t),e.state.highlightedEventId&&(e.highlightEvent(null),oe.current=null))},onEventLongPress:e=>{(z||_)&&m(e)},customDetailPanelContent:P,customEventDetailDialog:L,app:e,isMobile:z,enableTouch:_},t.id)})})]})]})]})})]}),ie&&et(Da,{x:ie.x,y:ie.y,date:ie.date,viewType:I.DAY,onClose:()=>le(null),app:e,onCreateEvent:()=>{if(C){const e=Math.floor((t.getTime()-n.getTime())/864e5);if(0===ie.date.getHours()&&0===ie.date.getMinutes())null==k||k({clientX:ie.x,clientY:ie.y},e);else{const t=ie.date.getHours()+ie.date.getMinutes()/60,n={preventDefault:()=>{},stopPropagation:()=>{},clientX:ie.x,clientY:ie.y};C(n,e,t)}}}})]})},_a=({app:e,currentDate:t,visibleMonth:n,currentDayEvents:r,selectedEvent:a,setSelectedEvent:o,handleMonthChange:i,handleDateSelect:l,switcherMode:s,timeFormat:d="24h"})=>{const{t:c,locale:u}=vn(),h=[...r].toSorted((e,t)=>e.allDay&&!t.allDay?-1:!e.allDay&&t.allDay?1:0);return et("div",{className:"df-right-panel hidden flex-none md:block w-[30%] bg-white dark:bg-gray-900",onContextMenu:e=>e.preventDefault(),children:et("div",{className:`${er} h-full`,children:[et("div",{className:"df-mini-calendar px-2 border-b border-gray-200 dark:border-gray-700",children:et("div",{children:[et("div",{className:"flex items-center justify-end gap-2",children:[et("div",{className:wn,style:{position:"relative"},children:et("div",{children:et("h1",{className:Dn,children:" "})})}),et(Ya,{handlePreviousMonth:()=>e.goToPrevious(),handleNextMonth:()=>e.goToNext(),handleToday:()=>e.goToToday()})]}),et(qr,{visibleMonth:n,currentDate:t,showHeader:!0,onMonthChange:i,onDateSelect:l})]})}),et("div",{className:"flex-1 overflow-y-auto",children:et("div",{className:"p-4",children:[et("h3",{className:"text-lg font-semibold mb-3 sticky top-0 z-10 bg-white py-2 dark:bg-gray-900",children:t.toLocaleDateString(u,{weekday:"long",month:"long",day:"numeric"})}),0===h.length?et("p",{className:`${qn} ${Qn}`,children:c("noEvents")}):et("div",{className:"space-y-2",children:h.map(t=>et("div",{className:` p-2 cursor-pointer rounded border-l-4 transition-colors ${(null==a?void 0:a.id)===t.id?"border-primary bg-primary/10":"border-gray-300 bg-gray-50 dark:border-gray-600 dark:bg-gray-800"} hover:bg-gray-100 dark:hover:bg-gray-700`,style:{borderLeftColor:pe(t.calendarId||"blue")},onClick:()=>{o(t),e.onEventClick(t)},children:[et("div",{className:`font-medium ${Qn}`,children:t.title}),!t.allDay&&et("div",{className:`${Jn} ${Xn}`,children:[be(ne(t.start),0,d)," ","- ",be(we(t),0,d)]}),t.allDay&&et("div",{className:`${Jn} ${Xn}`,children:c("allDay")})]},t.id))})]})})]})})},Wa={PARALLEL_THRESHOLD:.25,NESTED_THRESHOLD:.5,INDENT_STEP_PERCENT:2.5,MIN_WIDTH:25,MARGIN_BETWEEN:1,EDGE_MARGIN_PERCENT:.9};function Ua(e){return Object.assign(Object.assign({},e),{parentId:void 0,children:[],_startHour:e.allDay?0:ne(e.start),_endHour:e.allDay?0:we(e)})}function Ba(e){var t;return null!==(t=e._startHour)&&void 0!==t?t:ne(e.start)}function Za(e){var t;return null!==(t=e._endHour)&&void 0!==t?t:we(e)}function Va(e,t){return e.day===t.day&&!e.allDay&&!t.allDay&&(Ba(e)<Za(t)&&Ba(t)<Za(e))}function Ga(e,t){const n=Za(e)-Ba(e);if(n<1.25)return!1;const r=Ba(e)+.4*n,a=Ba(t)>=r,o=Va(e,t);return a&&o}function Ka(e,t,n=Wa){if(!Va(e,t))return!1;const r=Math.abs(Ba(e)-Ba(t));return r<=n.PARALLEL_THRESHOLD||(r>n.PARALLEL_THRESHOLD&&r<n.NESTED_THRESHOLD||function(e,t){return!(!Va(e,t)||!Ga(e,t)&&!Ga(t,e))}(e,t))}function qa(e,t){const n=Ba(e)<=Ba(t)&&Za(e)>=Za(t),r=Ba(e)<=Ba(t)&&Ba(t)<Za(e)&&Va(e,t);return n||r}function Xa(e){const t=[],n=new Set;for(const r of e){if(n.has(r.id))continue;const a=[r];n.add(r.id);for(const t of e){if(n.has(t.id))continue;Math.abs(Ba(r)-Ba(t))<=Wa.PARALLEL_THRESHOLD&&(a.push(t),n.add(t.id))}a.sort((e,t)=>Ba(e)-Ba(t));const o={events:a,startHour:Math.min(...a.map(e=>Ba(e))),endHour:Math.max(...a.map(e=>Za(e)))};t.push(o)}return t.sort((e,t)=>e.startHour-t.startHour),t}function Ja(e){return"day"===e?.5:2.5}function Qa(e){const t=Za(e)-Ba(e);return Math.max(.1,Math.min(1,t/4))}function eo(e){if(e.length<2)return!1;for(let t=0;t<e.length;t++)for(let n=t+1;n<e.length;n++)if(Ka(e[t],e[n],Wa))return!0;return!1}function to(e,t,n,r,a={}){const o=Ja(a.viewType);let i=e.depth*o;if(e.isProcessed){const t=function(e,t){let n=e;for(;n.parent&&n.parent.depth>0;)n=n.parent;return 1===n.depth?n.depth*Ja(t):null}(e,a.viewType);null!==t&&(i=t)}const l="day"===a.viewType;let s=0;1===e.depth?s=l?.5:1.5:2===e.depth?s=l?-.01:-1:e.depth>=3&&(s=l?.55:-3.5);const d=t+i+s;let c=n-(i+s);if(d+c>t+n&&(c=t+n-d),r.set(e.event.id,{id:e.event.id,left:d,width:c,zIndex:e.depth,level:e.depth,isPrimary:0===e.depth,indentOffset:i*(a.containerWidth||320)/100,importance:Qa(e.event)}),0===e.children.length)return;const u=[...e.children].toSorted((e,t)=>Za(t.event)-Ba(t.event)-(Za(e.event)-Ba(e.event)));1===u.length?to(u[0],d,c,r,a):eo(u.map(e=>e.event))?no(u,d,c,r,a):u.forEach(e=>to(e,d,c,r,a))}function no(e,t,n,r,a={}){const o=e.length,i=e[0].depth,l=i*Ja(a.viewType),s="day"===a.viewType;let d=1===i?s?.5:1.5:2===i?s?-.01:-1:s?.55:-3.5;const c=t+l+d,u=n-(l+d);if(u<=0)return void e.forEach(e=>to(e,t,n,r,a));let h=Wa.MARGIN_BETWEEN*(1===i?s?.15:.3:s?.1:.2);const g=(u-h*(o-1))/o;e.forEach((e,t)=>{const n=c+t*(g+h);if(r.set(e.event.id,{id:e.event.id,left:n,width:g,zIndex:e.depth,level:e.depth,isPrimary:0===e.depth,indentOffset:l*(a.containerWidth||320)/100,importance:Qa(e.event)}),e.children.length>0){const t=[...e.children].toSorted((e,t)=>Za(t.event)-Ba(t.event)-(Za(e.event)-Ba(e.event)));1===t.length?to(t[0],n,g,r,a):eo(t.map(e=>e.event))?no(t,n,g,r,a):t.forEach(e=>to(e,n,g,r,a))}})}function ro(e,t,n={}){const r=100-("day"===n.viewType?0:Wa.EDGE_MARGIN_PERCENT);if(1===e.length)to(e[0],0,r,t,n);else if(e.length>1){const a=e.length,o=(r-Wa.MARGIN_BETWEEN*(a-1))/a;e.forEach((e,r)=>{to(e,r*(o+Wa.MARGIN_BETWEEN),Math.max(o,Wa.MIN_WIDTH),t,n)})}}function ao(e){let t=0;for(const n of e.children)t+=1+ao(n);return t}function oo(e,t){var n,r;const a=null===(r=null===(n=e[0])||void 0===n?void 0:n.parent)||void 0===r?void 0:r.depth;return void 0===a?[]:t.filter(e=>e.depth===a).map(e=>({node:e,load:ao(e)})).toSorted((e,t)=>t.load-e.load)}function io(e){return!(e.length<2)&&e[0].load-e.at(-1).load>=2}function lo(e,t){t.parentId=e.id,e.children.includes(t.id)||e.children.push(t.id)}function so(e,t){e.parent&&(e.parent.children=e.parent.children.filter(t=>t!==e));const n=t.children.find(t=>qa(t.event,e.event));n?(e.parent=n,e.depth=n.depth+1,n.children.push(e),lo(n.event,e.event)):(e.parent=t,e.depth=t.depth+1,t.children.push(e),lo(t.event,e.event))}function co(e,t){0===e.children.length?t.push(e):e.children.forEach(e=>co(e,t))}function uo(e,t){const n=[];return co(e,n),n.find(e=>qa(t.event,e.event))||n[0]||null}function ho(e){let t=0;for(;t<5;){e.sort((e,t)=>t.load-e.load);const n=e[0],r=e.at(-1);if(n.load-r.load<2)break;const a=uo(n.node,r.node);if(!a)break;so(a,r.node),n.load--,r.load++,t++}}function go(e,t){const n=t.startHour-e.startHour;if(function(e,t){for(const n of e.events)for(const e of t.events)if(Va(n,e)&&Math.abs(Ba(e)-Ba(n))<Wa.NESTED_THRESHOLD)return!0;return!1}(e,t))return!1;if(n<Wa.NESTED_THRESHOLD)return!1;for(const n of e.events)for(const e of t.events)if(qa(n,e))return!0;return!1}function mo(e,t,n){const r=t.events.filter(t=>qa(t,e));if(0===r.length)return null;if(1===r.length)return r[0];const a=r.map(t=>({parent:t,load:t.children.length,hasParallelSibling:t.children.some(t=>{const r=n.find(e=>e.id===t);return r&&Ka(e,r,Wa)})}));return a.sort((t,n)=>t.load!==n.load?t.load-n.load:t.hasParallelSibling!==n.hasParallelSibling?t.hasParallelSibling?-1:1:Math.abs(Ba(e)-Ba(t.parent))-Math.abs(Ba(e)-Ba(n.parent))),a[0].parent}function vo(e,t,n){if(0===t.length)return null;let r=1/0,a=[];for(const e of t){const t=e.children.length;t<r?(r=t,a=[e]):t===r&&a.push(e)}const o=Za(e)-Ba(e),i=a.flatMap(e=>e.children);return o>Math.max(...i.map(e=>{const t=n.find(t=>t.id===e);return t?Za(t)-Ba(t):0}),0)?a[0]:a.at(-1)||null}function fo(e,t){t.parentId=e.id,e.children.includes(t.id)||e.children.push(t.id)}function po(e){let t=0;for(const n of e.children)t+=1+po(n);return t}function yo(e){const t=new Map;for(const n of e){const e={event:n,children:[],parent:null,depth:0,isProcessed:!1};t.set(n.id,e)}for(const n of e)if(n.parentId){const e=t.get(n.id),r=t.get(n.parentId);e&&r&&(e.parent=r,e.depth=r.depth+1,r.children.push(e))}return t}function bo(e,t){const n=t.get(e.id);if(!n)return null;let r=n;for(;r.parent&&r.depth>1;)r=r.parent;if(1!==r.depth)return null;const a=r.parent;if(!a)return null;const o=a.children.filter(e=>1===e.depth&&e.event.id!==r.event.id);let i=1/0,l=null;for(const e of o){const t=po(e);t<i&&(i=t,l=e)}return l?l.event:null}function wo(e,t,n){const r=[];if(1===e.length){const a=mo(e[0],t,n);return a&&(r.push({child:e[0],parent:a}),fo(a,e[0])),r}const a=t.events.filter(t=>e.every(e=>qa(t,e)));if(0===a.length){for(const a of e){const o=mo(a,t,n);if(o)r.push({child:a,parent:o}),fo(o,a);else{const t=e.find(e=>e.id!==a.id&&Va(e,a));if(t){const e=bo(t,yo(n));e&&(r.push({child:a,parent:e}),fo(e,a))}}}return r}const o=[...e].toSorted((e,t)=>Za(t)-Ba(t)-(Za(e)-Ba(e)));if(o.length%a.length===0){const e=o.length/a.length;for(let t=0;t<a.length;t++){const n=a[t],i=o.slice(t*e,(t+1)*e);for(const e of i)r.push({child:e,parent:n}),fo(n,e)}}else for(const e of o){const t=vo(e,a,o);t&&(r.push({child:e,parent:t}),fo(t,e))}return r}function Do(e,t){const n=[],r=new Map,a=new Map;t.forEach(e=>a.set(e.id,e));for(const t of e)for(const e of t.events){const t={event:a.get(e.id),children:[],parent:null,depth:0,isProcessed:!1};n.push(t),r.set(e.id,t)}for(let n=0;n<e.length;n++){const o=e[n],i=o.events.map(e=>a.get(e.id));let l=!1;for(let s=n-1;s>=0&&!l;s--){const n=e[s],d={events:n.events.map(e=>a.get(e.id)),startHour:n.startHour,endHour:n.endHour};if(go(d,{events:i,startHour:o.startHour,endHour:o.endHour})){const e=wo(i,d,t);for(const t of e){const e=r.get(t.child.id),n=r.get(t.parent.id);e.parent=n,e.depth=n.depth+1,n.children.push(e)}l=!0}}}const o=n.filter(e=>null===e.parent);return o.forEach(e=>{e.depth=0}),function(e,t){for(let n=e.length-1;n>=1;n--){const r=oo(e[n].events.map(e=>t.find(t=>t.event.id===e.id)),t);io(r)&&ho(r)}}(e,n),o}const xo={calculateDayEventLayouts(e,t={}){const n=e.map(Ua);for(const e of n)e.parentId=void 0,e.children=[];const r=new Map,a=n.filter(e=>!e.allDay);if(0===a.length)return r;const o=function(e){const t=[],n=new Set;for(const r of e){if(n.has(r.id))continue;const a=[r],o=[r];for(n.add(r.id);o.length>0;){const t=o.shift();for(const r of e)n.has(r.id)||Va(t,r)&&(a.push(r),o.push(r),n.add(r.id))}t.push(a)}return t}(a);for(const e of o)if(1===e.length){const n="day"===t.viewType?0:Wa.EDGE_MARGIN_PERCENT;r.set(e[0].id,{id:e[0].id,left:0,width:100-n,zIndex:0,level:0,isPrimary:!0,indentOffset:0,importance:Math.max(.1,Math.min(1,(e[0]._endHour-e[0]._startHour)/4))})}else{ro(Do(Xa([...e].toSorted((e,t)=>e._startHour!==t._startHour?e._startHour-t._startHour:t._endHour-t._startHour-(e._endHour-e._startHour))),e),r,t)}return r}},Eo=(e,t=1)=>{const n=(e.getDay()-t+7)%7,r=new Date(e);return r.setDate(e.getDate()-n),r.setHours(0,0,0,0),r},Co={HOUR_HEIGHT:72,FIRST_HOUR:0,LAST_HOUR:24,ALL_DAY_HEIGHT:28};function ko(t){const{app:n,onEventCreated:r}=t,{t:a}=vn(),o=m(e=>{e.dataTransfer&&e.dataTransfer.types.includes("application/x-dayflow-calendar")&&(e.preventDefault(),e.dataTransfer.dropEffect="copy")},[]);return{handleDrop:m((t,o,i,l)=>{if(t.preventDefault(),!t.dataTransfer)return null;const s=t.dataTransfer.getData("application/x-dayflow-calendar");if(!s)return null;try{const t=JSON.parse(s);let d,c,u=!1;l?(d=e.PlainDateTime.from({year:o.getFullYear(),month:o.getMonth()+1,day:o.getDate(),hour:0,minute:0}),c=e.PlainDateTime.from({year:o.getFullYear(),month:o.getMonth()+1,day:o.getDate(),hour:23,minute:59,second:59}),u=!0):void 0===i?(d=e.PlainDateTime.from({year:o.getFullYear(),month:o.getMonth()+1,day:o.getDate(),hour:9,minute:0}),c=d.add({hours:1})):(d=e.PlainDateTime.from({year:o.getFullYear(),month:o.getMonth()+1,day:o.getDate(),hour:i,minute:0}),c=d.add({hours:1}));const h={id:`event-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,title:a(u?"newAllDayCalendarEvent":"newCalendarEvent",{calendarName:t.calendarName}),description:"",start:d,end:c,calendarId:t.calendarId,allDay:u};return n.addEvent(h),null==r||r(h),h}catch(e){return console.error("Error creating event from calendar drop:",e),null}},[n,r]),handleDragOver:o}}let To=null;function No(e){To=e}const So={handleMoveStart:()=>{},handleCreateStart:()=>{},handleResizeStart:void 0,handleCreateAllDayEvent:()=>{},dragState:{active:!1,mode:null,eventId:null,targetDate:null,startDate:null,endDate:null},isDragging:!1};function Mo(e,t){return To?To(e,t):So}const Io=({app:e,config:t,customDetailPanelContent:n,customEventDetailDialog:r,calendarRef:a,switcherMode:o="buttons",selectedEventId:i,onEventSelect:l,onDateChange:s,detailPanelEventId:d,onDetailPanelToggle:c})=>{const f=e.getEvents(),{screenSize:y}=gn(),b="desktop"!==y,[w,D]=u(!1),{hourHeight:x=Co.HOUR_HEIGHT,firstHour:E=Co.FIRST_HOUR,lastHour:C=Co.LAST_HOUR,allDayHeight:k=Co.ALL_DAY_HEIGHT,showAllDay:T=!0,timeFormat:N="24h",secondaryTimeZone:S}=t,M=x,H=E,A=C,O=k,R=!T;h(()=>{D("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const P=e.getCustomMobileEventRenderer()||Qr,[L,$]=u(null),[j,Y]=u(null),[F,z]=u(null),_=void 0===i?j:i,U=void 0===d?F:d,Z=v(()=>_&&f.find(e=>e.id===_)||null,[_,f]),V=e=>{l?l(e):Y(e)},[G,K]=u(null),[q,X]=u(!1),[J,Q]=u(null),ee=g(null),te=e.getCurrentDate(),[re,ae]=u(te),oe=g(te.getTime());te.getTime()!==oe.current&&(oe.current=te.getTime(),te.getFullYear()===re.getFullYear()&&te.getMonth()===re.getMonth()||ae(te));const ie=m(t=>{ae(n=>{const r=new Date(n.getFullYear(),n.getMonth()+t,1);return e.setVisibleMonth(r),r})},[e]),le=g(e.state.highlightedEventId);h(()=>{var t;if(e.state.highlightedEventId!==le.current)if(e.state.highlightedEventId){V(e.state.highlightedEventId);const n=e.getEvents().find(t=>t.id===e.state.highlightedEventId);if(n&&!n.allDay){const e=ne(n.start),r=null===(t=a.current)||void 0===t?void 0:t.querySelector(".calendar-content");if(r){const t=(e-H)*M;requestAnimationFrame(()=>{r.scrollTo({top:Math.max(0,t-100),behavior:"smooth"})})}}}else V(null);le.current=e.state.highlightedEventId},[e.state.highlightedEventId,H,M,a,e]);const se=g(null),de=g(null),ce=v(()=>Eo(te),[te]),ue=v(()=>((e,t,n)=>{const r=new Date(t);r.setHours(0,0,0,0);const a=new Date(t);return a.setHours(23,59,59,999),e.filter(e=>{const t=B(e.start),n=B(e.end);if(e.allDay){const e=new Date(t);e.setHours(0,0,0,0);const o=new Date(n);return o.setHours(0,0,0,0),e<=a&&o>=r}return t<a&&n>r}).map(e=>{const t=B(e.start),r=Math.floor((t.getTime()-n.getTime())/864e5),a=Math.max(0,Math.min(6,r));return Object.assign(Object.assign({},e),{day:a})})})(f,te,ce),[f,te,ce]),he=v(()=>((e,t)=>{const n=new Date(t);n.setHours(0,0,0,0);const r=new Date(n);return r.setDate(r.getDate()+1),e.filter(e=>!e.allDay).map(e=>{const t=B(e.start),a=B(e.end);let o=e.start,i=e.end,l=!1;return t<n&&(o=W(n),l=!0),a>r&&(i=W(r),l=!0),Object.assign(Object.assign({},e),{start:l?o:e.start,end:l?i:e.end,day:0})})})(ue,te),[ue,te]),ge=v(()=>xo.calculateDayEventLayouts(he,{viewType:"day"}),[he]),me=v(()=>(e=>{const t=e.filter(e=>e.allDay);t.sort((e,t)=>{const n=B(e.start),r=B(t.start);if(n.getTime()!==r.getTime())return n.getTime()-r.getTime();const a=B(e.end);return B(t.end).getTime()-a.getTime()});const n=[],r=[];return t.forEach(e=>{let t=0,a=!1;for(;!a;)n[t]?n[t].some(t=>{const n=B(e.start),r=B(e.end),a=B(t.start);return n<=B(t.end)&&a<=r})?t++:(n[t].push(e),r.push(Object.assign(Object.assign({},e),{row:t})),a=!0):(n[t]=[e],r.push(Object.assign(Object.assign({},e),{row:t})),a=!0)}),r})(ue),[ue]),ve=v(()=>{if(0===me.length)return O;return(Math.max(...me.map(e=>e.row))+1)*O},[me,O]),{handleMoveStart:fe,handleCreateStart:pe,handleResizeStart:ye,handleCreateAllDayEvent:we,dragState:De,isDragging:xe}=Mo(e,{calendarRef:a,allDayRowRef:T?se:void 0,timeGridRef:de,viewType:I.DAY,onEventsUpdate:(t,n,r)=>{const a=t(ue),o=new Set(a.map(e=>e.id)),i=ue.filter(e=>!o.has(e.id)),l=new Set(ue.map(e=>e.id)),s=a.filter(e=>!l.has(e.id)),d=a.filter(e=>{if(!l.has(e.id))return!1;const t=f.find(t=>t.id===e.id);return t&&Ze(t,e)});e.applyEventsChanges({delete:i.map(e=>e.id),add:s,update:d.map(e=>({id:e.id,updates:e}))},void 0,r)},onEventCreate:t=>{b?(Q(t),X(!0)):(e.addEvent(t),K(t.id))},onEventEdit:()=>{},currentWeekStart:ce,events:ue,calculateNewEventLayout:(e,t,n)=>((e,t,n,r,a)=>{const o=new Date(r),i=new Date(r);o.setHours(Math.floor(t),t%1*60,0,0),i.setHours(Math.floor(n),n%1*60,0,0);const l=[...a,{id:"-1",title:"Temp",day:0,start:W(o),end:W(i),calendarId:"blue",allDay:!1}];return xo.calculateDayEventLayouts(l,{viewType:"day"}).get("-1")||null})(0,t,n,te,he),calculateDragLayout:(e,t,n,r)=>((e,t,n,r,a,o)=>{const i=o.filter(t=>t.id!==e.id),l=new Date(a),s=new Date(l);s.setHours(Math.floor(n),n%1*60,0,0);const d=new Date(l);d.setHours(Math.floor(r),r%1*60,0,0);const c=[...i,Object.assign(Object.assign({},e),{start:W(s),end:W(d),day:0})];return 0===c.length?null:xo.calculateDayEventLayouts(c,{viewType:"day"}).get(e.id)||null})(e,0,n,r,te,he),TIME_COLUMN_WIDTH:S&&!b?88:b?48:80,isMobile:b}),{handleDrop:ke,handleDragOver:Te}=ko({app:e,onEventCreated:e=>{K(e.id)}}),Ne=Array.from({length:24},(e,t)=>({hour:t+H,label:be(t+H,0,N)})),Se=v(()=>S?Ee(Ne,S,N):void 0,[S,N,H]),Me=v(()=>S?Ce(Intl.DateTimeFormat().resolvedOptions().timeZone):void 0,[S]),Ie=v(()=>S?Ce(S):void 0,[S]),He=m(t=>{const n=new Date(t.getFullYear(),t.getMonth(),t.getDate());e.setCurrentDate(n),ae(new Date(n.getFullYear(),n.getMonth(),1))},[e]),Ae=v(()=>{const e=new Date;e.setHours(0,0,0,0);const t=new Date(te);return t.setHours(0,0,0,0),t.getTime()===e.getTime()},[te]);return p(()=>{var e;if(t.scrollToCurrentTime){const t=null===(e=a.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(t){const e=new Date,n=e.getHours()+e.getMinutes()/60,r=t.clientHeight;t.scrollTop=Math.max(0,(n-H)*M-r/2)}}},[]),h(()=>{$(new Date);const e=setInterval(()=>$(new Date),6e4);return()=>clearInterval(e)},[]),et("div",{className:"df-day-view flex h-full bg-gray-50 dark:bg-gray-800",children:[et(za,{app:e,currentDate:te,currentWeekStart:ce,events:f,currentDayEvents:ue,organizedAllDayEvents:me,allDayAreaHeight:ve,timeSlots:Ne,eventLayouts:ge,isToday:Ae,currentTime:L,selectedEventId:_,setSelectedEventId:V,newlyCreatedEventId:G,setNewlyCreatedEventId:K,detailPanelEventId:U,setDetailPanelEventId:e=>{c?c(e):z(e)},dragState:De,isDragging:xe,handleMoveStart:fe,handleResizeStart:ye,handleCreateStart:pe,handleCreateAllDayEvent:we,handleTouchStart:(e,t)=>{if(!b&&!w)return;const n=e.touches[0],r=n.clientX,o=n.clientY,i=e.currentTarget;ee.current=setTimeout(()=>{var e,n,l;const s=null===(n=null===(e=a.current)||void 0===e?void 0:e.querySelector(".calendar-content"))||void 0===n?void 0:n.getBoundingClientRect();if(!s)return;const d=null===(l=a.current)||void 0===l?void 0:l.querySelector(".calendar-content"),c=d?d.scrollTop:0,u=o-s.top+c;null==pe||pe({preventDefault:()=>{},stopPropagation:()=>{},touches:[{clientX:r,clientY:o}],changedTouches:[{clientX:r,clientY:o}],target:i,currentTarget:i,cancelable:!0},t,H+u/M)},500)},handleTouchEnd:()=>{ee.current&&(clearTimeout(ee.current),ee.current=null)},handleTouchMove:()=>{ee.current&&(clearTimeout(ee.current),ee.current=null)},handleDragOver:Te,handleDrop:ke,handleEventUpdate:t=>{e.updateEvent(t.id,t)},handleEventDelete:t=>{e.deleteEvent(t)},onDateChange:s,customDetailPanelContent:n,customEventDetailDialog:r,calendarRef:a,allDayRowRef:se,timeGridRef:de,switcherMode:o,isMobile:b,isTouch:w,setDraftEvent:Q,setIsDrawerOpen:X,ALL_DAY_HEIGHT:O,HOUR_HEIGHT:M,FIRST_HOUR:H,LAST_HOUR:A,showAllDay:T,showStartOfDayLabel:R,timeFormat:N,secondaryTimeSlots:Se,primaryTzLabel:Me,secondaryTzLabel:Ie}),et(_a,{app:e,currentDate:te,visibleMonth:re,currentDayEvents:ue,selectedEvent:Z,setSelectedEvent:e=>V(e?e.id:null),handleMonthChange:ie,handleDateSelect:He,switcherMode:o,timeFormat:N}),et(P,{isOpen:q,onClose:()=>{X(!1),Q(null)},onSave:t=>{f.some(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),X(!1),Q(null)},draftEvent:J,app:e,timeFormat:N})]})},Ho=({originalComponent:e,app:t,config:n,customDetailPanelContent:r,customEventDetailDialog:a,calendarRef:o,switcherMode:i,meta:l,selectedEventId:s,detailPanelEventId:d,onEventSelect:c,onDateChange:u,onDetailPanelToggle:h})=>{const g=t.getPlugin("events"),f=t.getPlugin("drag"),p=t.getCurrentDate(),y=t.state.currentView,b=t.getEvents(),w=m(e=>{g?g.update(e.id,e):t.updateEvent(e.id,e)},[g,t]),D=m(e=>{g?g.delete(e):t.deleteEvent(e)},[g,t]),x=m(e=>{g?g.add(e):t.addEvent(e)},[g,t]),E=m(e=>{u?u(e):t.setCurrentDate(e)},[t,u]),C=m(e=>{t.changeView(e)},[t]),k=v(()=>Object.assign({},n),[n]),T=v(()=>({app:t,currentDate:p,currentView:y,events:b,onEventUpdate:w,onEventDelete:D,onEventCreate:x,onDateChange:E,onViewChange:C,config:k,customDetailPanelContent:r,customEventDetailDialog:a,calendarRef:o,switcherMode:i,meta:l,selectedEventId:s,detailPanelEventId:d,onEventSelect:c,onDetailPanelToggle:h}),[t,p,y,b,w,D,x,E,C,k,r,a,o,i,l,s,d,c,h]),N=v(()=>{const e={currentDate:p,events:b,setEvents:e=>{b.forEach(e=>D(e.id)),e.forEach(e=>x(e))},updateEvent:w,deleteEvent:D,addEvent:x,goToPrevious:()=>{const e=new Date(p);switch(y){case I.DAY:e.setDate(e.getDate()-1);break;case I.WEEK:e.setDate(e.getDate()-7);break;case I.MONTH:e.setMonth(e.getMonth()-1)}E(e)},goToNext:()=>{const e=new Date(p);switch(y){case I.DAY:e.setDate(e.getDate()+1);break;case I.WEEK:e.setDate(e.getDate()+7);break;case I.MONTH:e.setMonth(e.getMonth()+1)}E(e)},goToToday:()=>{E(new Date)},changeView:C,selectDate:E};return Object.assign(Object.assign({calendar:e},T),{eventsService:g,dragService:f})},[p,b,y,w,D,x,E,C,T,g,f]);return et(e,Object.assign({},N))},Ao={showAllDay:!0,scrollToCurrentTime:!0,hourHeight:72,firstHour:0,lastHour:24,allDayHeight:28,timeFormat:"24h"},Oo=(e={})=>{const t=Object.assign(Object.assign({},Ao),e),n=e=>a(Ho,{viewType:I.DAY,originalComponent:Io,app:e.app,config:t,className:"day-view-factory",customDetailPanelContent:e.customDetailPanelContent,customEventDetailDialog:e.customEventDetailDialog,calendarRef:e.calendarRef,switcherMode:e.switcherMode,meta:e.meta,selectedEventId:e.selectedEventId,onEventSelect:e.onEventSelect,detailPanelEventId:e.detailPanelEventId,onDetailPanelToggle:e.onDetailPanelToggle});return n.displayName="DayViewAdapter",{type:I.DAY,component:n,config:t}},Ro=e=>{const t=e.toLowerCase();return t.startsWith("tu")||t.startsWith("th")||t.startsWith("sa")||t.startsWith("su")?e.slice(0,2):e.slice(0,1)},Po=({app:e,fullWeekDates:t=[],mobilePageStart:n,onDateChange:a})=>et("div",{className:"flex w-full flex-col border-b border-gray-200 bg-white py-3 dark:border-gray-700 dark:bg-gray-900",children:[et("div",{className:"mb-1 grid grid-cols-7",children:t.map((e,t)=>et("div",{className:"flex justify-center",children:et("span",{className:"text-[10px] font-medium "+(e.isToday?"text-primary":"text-gray-500"),children:Ro(e.dayName)})},`label-${t}`))}),et("div",{className:"relative grid grid-cols-7 overflow-hidden",children:(()=>{if(!n)return null;const o=t.findIndex(e=>e.fullDate.getTime()===n.getTime());return et(r,{children:[et("div",{className:"absolute rounded-full bg-gray-100 transition-all duration-300 dark:bg-gray-800",style:{left:-1===o?"0":`calc(${(o+.5)/7*100}% - 16px)`,top:0,width:`calc(${1/7*100}% + 32px)`,height:"32px"}}),t.map((t,n)=>{const r=t.isCurrent,i=n>=o&&n<o+2;return et("div",{className:"relative z-10 flex cursor-pointer items-center justify-center",style:{height:"32px"},onClick:()=>{e.setCurrentDate(t.fullDate),null==a||a(t.fullDate)},children:et("div",{className:`relative flex h-8 w-8 items-center justify-center rounded-full text-sm font-medium transition-all duration-300 ${r?"bg-gray-900 text-white shadow-sm dark:bg-gray-100 dark:text-gray-900":t.isToday?"font-bold text-primary":i?"text-gray-900 dark:text-gray-100":"text-gray-500 dark:text-gray-400"} `,children:[t.date,t.isToday&&!r&&et("div",{className:"absolute bottom-1 h-1 w-1 rounded-full bg-primary"})]})},`date-${n}`)})]})})()})]}),Lo=({app:e,weekDaysLabels:t,mobileWeekDaysLabels:n,weekDates:a,fullWeekDates:o,isSlidingView:i,mobilePageStart:l,currentWeekStart:s,gridWidth:d,allDayAreaHeight:c,organizedAllDaySegments:h,allDayLabelText:g,isMobile:m,isTouch:f,showAllDay:p=!0,calendarRef:y,allDayRowRef:b,topFrozenContentRef:w,ALL_DAY_HEIGHT:D,HOUR_HEIGHT:x,FIRST_HOUR:E,dragState:C,isDragging:k,primaryTzLabel:T,secondaryTzLabel:N,secondaryTimeSlots:S,handleMoveStart:M,handleResizeStart:H,handleEventUpdate:A,handleEventDelete:O,onDateChange:R,newlyCreatedEventId:P,setNewlyCreatedEventId:L,selectedEventId:$,setSelectedEventId:j,detailPanelEventId:Y,setDetailPanelEventId:F,handleCreateAllDayEvent:z,handleDragOver:_,handleDrop:W,customDetailPanelContent:U,customEventDetailDialog:B})=>{const Z={flexShrink:0},[V,G]=u(null),K=v(()=>St(),[]),q=!!S&&S.length>0&&!m;return et("div",{className:"flex w-full flex-col",children:[i&&o&&l&&et(Po,{app:e,fullWeekDates:o,mobilePageStart:l,onDateChange:R}),et("div",{className:`flex flex-none ${p?"border-b border-gray-200 dark:border-gray-700":""} relative z-10`,onContextMenu:e=>e.preventDefault(),children:[p&&et("div",{className:"z-20 flex w-12 shrink-0 flex-col bg-white md:w-20 dark:bg-gray-900",onContextMenu:e=>e.preventDefault(),children:[et("div",{className:"flex flex-1 items-center border-b border-gray-200 transition-all duration-300 ease-in-out dark:border-gray-700 "+(i?"hidden":""),children:q&&et("div",{className:"flex w-full items-center justify-evenly gap-0.5 pt-2 pb-0.5",children:[et("span",{className:"text-[9px] text-gray-500 select-none md:text-[10px] dark:text-gray-400",children:N}),et("span",{className:"text-[9px] text-gray-500 select-none md:text-[10px] dark:text-gray-400",children:T})]})}),et("div",{className:"flex items-center justify-end p-1 text-[10px] font-medium text-gray-500 transition-[min-height] duration-300 ease-in-out select-none md:text-xs dark:text-gray-400",style:{minHeight:`${c}px`},children:g})]}),et("div",{className:"relative flex-1 overflow-hidden transition-[min-height] duration-300 ease-in-out",style:{scrollbarGutter:"stable",minHeight:p?`${c+(i?0:36)}px`:"auto"},children:et("div",{ref:w,className:"flex flex-col",style:{width:d,minWidth:"100%",transform:i?"translateX(calc(-100% / 3))":void 0},children:[!i&&et("div",{className:"df-week-header flex border-b border-gray-200 dark:border-gray-700",style:{marginRight:K?"-50px":"0px",paddingRight:K?"50px":"0px"},children:t.map((e,t)=>et("div",{className:"df-week-day-cell flex flex-1 justify-center items-center text-center text-gray-500 dark:text-gray-400 text-sm p-1 select-none "+(m?"flex-col gap-0":""),style:Z,children:et(r,m?{children:[et("div",{className:"text-[12px] leading-tight font-medium text-gray-500",children:n[t]}),et("div",{className:`${En} h-7 w-7 text-base font-medium ${a[t].isToday?jn:""}`,children:a[t].date})]}:{children:[et("div",{className:"mt-1 mr-1 inline-flex items-center justify-center text-sm",children:e}),et("div",{className:`${En} ${a[t].isToday?jn:""}`,children:a[t].date})]})},t))}),p&&et("div",{className:`${Hn} border-none transition-[min-height] duration-300 ease-in-out`,ref:b,style:{minHeight:`${c}px`},children:et("div",{className:"df-all-day-content flex flex-1 relative transition-[min-height] duration-300 ease-in-out",style:{minHeight:`${c}px`},children:[t.map((e,n)=>{const r=new Date(s);return r.setDate(s.getDate()+n),et("div",{className:"df-all-day-cell flex-1 border-r border-gray-200 dark:border-gray-700 relative transition-[min-height] duration-300 ease-in-out "+(n!==t.length-1||!m&&K?"":"border-r-0"),style:Object.assign({minHeight:`${c}px`},Z),onMouseDown:e=>null==z?void 0:z(e,n),onDblClick:e=>null==z?void 0:z(e,n),onDragOver:_,onDrop:e=>{W(e,r,void 0,!0)},onContextMenu:e=>((e,t)=>{if(e.preventDefault(),m)return;const n=new Date(s);n.setDate(s.getDate()+t),n.setHours(0,0,0,0),G({x:e.clientX,y:e.clientY,date:n})})(e,n)},`allday-${n}`)}),et("div",{className:"pointer-events-none absolute inset-0",children:h.map(n=>et(ja,{event:n.event,segment:n,segmentIndex:n.row,isAllDay:!0,isMultiDay:!0,allDayHeight:D,calendarRef:y,viewType:I.WEEK,columnsPerRow:t.length,isBeingDragged:k&&(null==C?void 0:C.eventId)===n.event.id&&"move"===(null==C?void 0:C.mode),hourHeight:x,firstHour:E,onMoveStart:M,onResizeStart:H,onEventUpdate:A,onEventDelete:O,newlyCreatedEventId:P,onDetailPanelOpen:()=>L(null),selectedEventId:$,detailPanelEventId:Y,onEventSelect:e=>{j(e)},onEventLongPress:e=>{(m||f)&&j(e)},onDetailPanelToggle:e=>F(e),customDetailPanelContent:U,customEventDetailDialog:B,app:e,isMobile:m,isSlidingView:i,enableTouch:f},n.event.id))})]})})]})}),V&&et(Da,{x:V.x,y:V.y,date:V.date,viewType:I.WEEK,onClose:()=>G(null),app:e,onCreateEvent:()=>{const e=Math.floor((V.date.getTime()-s.getTime())/864e5);null==z||z({clientX:V.x,clientY:V.y},e)}})]})]})},$o=({app:e,timeSlots:t,weekDaysLabels:n,currentWeekStart:a,currentWeekEvents:o,eventLayouts:i,gridWidth:l,isMobile:s,isTouch:d,scrollerRef:c,timeGridRef:h,leftFrozenContentRef:m,swipeContentRef:f,calendarRef:p,handleScroll:y,handleCreateStart:b,handleTouchStart:w,handleTouchEnd:D,handleTouchMove:x,handleDragOver:E,handleDrop:C,dragState:k,isDragging:T,handleMoveStart:N,handleResizeStart:S,handleEventUpdate:M,handleEventDelete:H,onDateChange:A,newlyCreatedEventId:O,setNewlyCreatedEventId:R,selectedEventId:P,setSelectedEventId:L,detailPanelEventId:$,setDetailPanelEventId:j,customDetailPanelContent:Y,customEventDetailDialog:F,isSlidingView:z,isCurrentWeek:_,currentTime:W,HOUR_HEIGHT:U,FIRST_HOUR:B,LAST_HOUR:Z,showStartOfDayLabel:V,timeFormat:G="24h",secondaryTimeSlots:K})=>{var q,X;const J=!!K&&K.length>0&&!s,Q={flexShrink:0},ee=g(e.state.highlightedEventId),[te,ne]=u(null),re=v(()=>St(),[]);return et("div",{className:"relative flex flex-1 overflow-hidden",children:[et("div",{ref:c,className:"calendar-content relative flex-1 overflow-auto "+("300%"===l?"overflow-x-hidden":"snap-x snap-mandatory"),style:{display:"grid",gridTemplateColumns:"auto 1fr"},onScroll:y,children:[et("div",{ref:m,className:"sticky left-0 z-10 w-12 shrink-0 bg-white md:w-20 dark:bg-gray-900",onContextMenu:e=>e.preventDefault(),children:[et("div",{className:"relative h-3",children:J?et(r,{children:et("div",{className:"absolute right-0 -bottom-1 flex w-full items-center justify-evenly select-none",children:[et("span",{className:"text-[10px] text-gray-500 md:text-[12px] dark:text-gray-400",children:V&&null!==(q=null==K?void 0:K[0])&&void 0!==q?q:""}),et("span",{className:"text-[10px] text-gray-500 md:text-[12px] dark:text-gray-400",children:V?be(B,0,G):""})]})}):et("div",{className:"absolute right-2 -bottom-1 text-[10px] text-gray-500 select-none md:text-[12px] dark:text-gray-400",children:V?be(B,0,G):""})}),t.map((e,t)=>{var n;return et("div",{className:Tn,children:et("div",J?{className:"absolute top-0 right-0 flex w-full -translate-y-1/2 items-center justify-evenly text-gray-500 select-none dark:text-gray-400",children:[et("span",{className:"text-[10px] md:text-[12px]",children:V&&0===t?"":null!==(n=null==K?void 0:K[t])&&void 0!==n?n:""}),et("span",{className:"text-[10px] md:text-[12px]",children:V&&0===t?"":e.label})]}:{className:`${Nn} text-[10px] md:text-[12px]`,children:V&&0===t?"":e.label})},t)}),et("div",{className:"relative",children:et("div",J?{className:"absolute top-0 right-0 flex w-full -translate-y-1/2 items-center justify-evenly text-gray-500 select-none dark:text-gray-400",children:[et("span",{className:"text-[10px] md:text-[12px]",children:null!==(X=null==K?void 0:K[0])&&void 0!==X?X:""}),et("span",{className:"text-[10px] md:text-[12px]",children:be(0,0,G)})]}:{className:`${Nn} text-[10px] md:text-[12px]`,children:be(0,0,G)})}),_&&W&&(()=>{const e=W,t=e.getHours()+e.getMinutes()/60;if(t<B||t>Z)return null;return et("div",{className:"pointer-events-none absolute left-0 z-20 flex w-full items-center justify-end",style:{top:`${(t-B)*U}px`,transform:"translateY(-50%)",marginTop:"0.75rem"},children:et("div",{className:In,children:be(t,0,G,!1)})})})()]}),et("div",{ref:f,className:"flex",style:{width:l,minWidth:"100%",transform:z?"translateX(calc(-100% / 3))":void 0},children:et("div",{className:"grow",children:[et("div",{className:`${Wn} flex border-t-0`,children:n.map((e,t)=>et("div",{className:`relative flex-1 ${t!==n.length-1||!s&&re?"border-r":""} border-gray-200 dark:border-gray-700`,style:Q},`top-${t}`))}),et("div",{ref:h,className:"relative",children:[_&&W&&(()=>{const e=W,t=e.getHours()+e.getMinutes()/60;if(t<B||t>Z)return null;const r=new Date(e);r.setHours(0,0,0,0);const o=new Date(a);o.setHours(0,0,0,0);const i=r.getTime()-o.getTime(),l=Math.round(i/864e5);return et("div",{className:Mn,style:{top:`${(t-B)*U}px`,width:"100%",height:0,zIndex:20},children:[et("div",{className:"flex w-0 items-center"}),et("div",{className:"flex flex-1",children:n.map((e,t)=>et("div",{className:"flex flex-1 items-center",children:et("div",{className:"relative h-0.5 w-full "+(t===l?"bg-primary":"bg-primary/30"),style:{zIndex:9999},children:t===l&&0!==l&&et("div",{className:"absolute h-2 w-2 rounded-full bg-primary",style:{top:"-3px",left:"-4px"}})})},t))})]})})(),t.map((e,t)=>et("div",{className:Sn,children:n.map((r,o)=>{const i=new Date(a);return i.setDate(a.getDate()+o),et("div",{className:"df-time-grid-cell flex-1 relative border-r border-gray-200 dark:border-gray-700 select-none snap-start "+(o!==n.length-1||!s&&re?"":"border-r-0"),style:Q,onClick:()=>{const e=new Date(a);e.setDate(a.getDate()+o),null==A||A(e)},onDblClick:t=>{null==b||b(t,o,e.hour)},onTouchStart:t=>w(t,o,e.hour),onTouchEnd:D,onTouchMove:x,onDragOver:E,onDrop:t=>{C(t,i,e.hour)},onContextMenu:t=>((e,t,n)=>{if(e.preventDefault(),s)return;const r=new Date(a);if(r.setDate(a.getDate()+t),h.current){const t=h.current.getBoundingClientRect(),n=(e.clientY-t.top)/U+B,a=Math.floor(n),o=Math.floor(60*(n-a)),i=15*Math.round(o/15),l=60===i?a+1:a,s=60===i?0:i;r.setHours(l,s,0,0)}else r.setHours(n,0,0,0);ne({x:e.clientX,y:e.clientY,date:r})})(t,o,e.hour)},`${t}-${o}`)})},t)),et("div",{className:`${Wn} flex`,children:n.map((e,t)=>et("div",{className:`relative flex-1 ${t!==n.length-1||!s&&re?"border-r":""} border-gray-200 dark:border-gray-700`,style:Q},`24-${t}`))}),n.map((t,r)=>{const l=n.length,c=Ie(r,o),u=[];return c.forEach(e=>{const t=ka(e,a);if(t.length>0){const n=t.find(e=>e.dayIndex===r);n&&u.push({event:e,segmentInfo:Object.assign(Object.assign({},n),{dayIndex:r})})}else u.push({event:e})}),o.forEach(e=>{if(e.allDay||e.day===r)return;const t=ka(e,a).find(e=>e.dayIndex===r);t&&u.push({event:e,segmentInfo:Object.assign(Object.assign({},t),{dayIndex:r})})}),et("div",{className:"pointer-events-none absolute top-0",style:{left:`calc(${100/l*r}%)`,width:100/l+"%",height:"100%"},children:u.map(({event:t,segmentInfo:n})=>{const a=i.get(r),o=null==a?void 0:a.get(t.id);return et(ja,{event:t,layout:o,viewType:I.WEEK,calendarRef:p,columnsPerRow:l,isBeingDragged:T&&(null==k?void 0:k.eventId)===t.id&&"move"===(null==k?void 0:k.mode),hourHeight:U,firstHour:B,onMoveStart:N,onResizeStart:S,onEventUpdate:M,onEventDelete:H,newlyCreatedEventId:O,onDetailPanelOpen:()=>R(null),selectedEventId:P,detailPanelEventId:$,onEventSelect:t=>{L(t),e.state.highlightedEventId&&(e.highlightEvent(null),ee.current=null)},onEventLongPress:e=>{(s||d)&&L(e)},onDetailPanelToggle:e=>j(e),customDetailPanelContent:Y,customEventDetailDialog:F,multiDaySegmentInfo:n,app:e,isMobile:s,isSlidingView:z,enableTouch:d},n?`${t.id}-seg-${r}`:t.id)})},`events-day-${r}`)})]})]})})]}),te&&et(Da,{x:te.x,y:te.y,date:te.date,viewType:I.WEEK,onClose:()=>ne(null),app:e,onCreateEvent:()=>{if(b){const e=new Date(a);e.setHours(0,0,0,0);const t=new Date(te.date);t.setHours(0,0,0,0);const n=t.getTime()-e.getTime(),r=Math.round(n/864e5),o=te.date.getHours()+te.date.getMinutes()/60,i={preventDefault:()=>{},stopPropagation:()=>{},clientX:te.x,clientY:te.y};b(i,r,o)}}})]})},jo=({app:e,config:t,customDetailPanelContent:n,customEventDetailDialog:r,calendarRef:a,selectedEventId:o,onEventSelect:i,onDateChange:l,detailPanelEventId:s,onDetailPanelToggle:d})=>{var c;const{t:m,getWeekDaysLabels:f,locale:y}=vn(),b=e.getCurrentDate(),w=v(()=>b,[b.getTime()]),D=e.getEvents(),{screenSize:x}=gn(),E="desktop"!==x,C=g(null),[k,T]=u(!1),{hourHeight:N=Co.HOUR_HEIGHT,firstHour:S=Co.FIRST_HOUR,lastHour:M=Co.LAST_HOUR,allDayHeight:H=Co.ALL_DAY_HEIGHT,showAllDay:A=!0,timeFormat:O="24h",secondaryTimeZone:R}=t,P=R&&"mobile"!==x?88:"mobile"===x?48:80,L=N,$=S,j=M,Y=H,F=!A;h(()=>{T("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const z=e.getCustomMobileEventRenderer()||Qr,_="desktop"!==x,U=_?2:7,Z=_,V=null!==(c=t.startOfWeek)&&void 0!==c?c:1,G=Z?"300%":"100%",K=v(()=>Eo(w,V),[w,V]),[q,X]=u(()=>{const e=new Date(w);return e.setHours(0,0,0,0),e});h(()=>{Z&&X(e=>{const t=new Date(w);t.setHours(0,0,0,0);const n=new Date(e),r=new Date(e);return r.setDate(r.getDate()+U-1),t>=n&&t<=r?e:t})},[w,Z,U]);const J=Z?q:K,Q=Z?3*U:7,ee=v(()=>{if(!Z)return J;const e=new Date(J);return e.setDate(e.getDate()-U),e},[J,Z,U]),[te,ae]=u(null),[oe,ie]=u(null),[le,se]=u(null),de=void 0===o?oe:o,ce=void 0===s?le:s,ue=e=>{i?i(e):ie(e)},he=e=>{d?d(e):se(e)},[ge,me]=u(null),[ve,fe]=u(!1),[pe,ye]=u(null),we=g(null),[De,xe]=u(0),[ke,Te]=u(!1),Ne=g(null),Se=g(null),Me=g(null),Ie=g(null),He=g(null),Oe=g({x:0,y:0}),Re=g(!1),Pe=g(0);h(()=>{if(!Z)return;const t=Se.current;if(!t)return;const n=e=>{Oe.current={x:e.touches[0].clientX,y:e.touches[0].clientY},Re.current=!1,Pe.current=0,Te(!1)},r=e=>{if(ke)return;const n=e.touches[0].clientX-Oe.current.x,r=e.touches[0].clientY-Oe.current.y;if(!Re.current&&Math.abs(n)>10&&Math.abs(n)>Math.abs(r)&&(Re.current=!0),Re.current){e.cancelable&&e.preventDefault();const r=t.clientWidth/2,a=Math.max(-r,Math.min(r,n)),o=`translateX(calc(-100% / 3 + ${a}px))`;Me.current&&(Me.current.style.transition="none",Me.current.style.transform=o),He.current&&(He.current.style.transition="none",He.current.style.transform=o),Pe.current=a}},a=()=>{var n;if(!Re.current)return void(Pe.current=0);const r=Pe.current,a=((null===(n=He.current)||void 0===n?void 0:n.clientWidth)||t.clientWidth)/Q;r>100?(Te(!0),xe(a),setTimeout(()=>{const t=new Date(q);t.setDate(t.getDate()-1),X(t),e.setCurrentDate(t),xe(0),Pe.current=0,Te(!1)},300)):r<-100?(Te(!0),xe(-a),setTimeout(()=>{const t=new Date(q);t.setDate(t.getDate()+1),X(t),e.setCurrentDate(t),xe(0),Pe.current=0,Te(!1)},300)):(Te(!0),xe(0),Pe.current=0,setTimeout(()=>{Te(!1)},300))};return t.addEventListener("touchstart",n,{passive:!0}),t.addEventListener("touchmove",r,{passive:!1}),t.addEventListener("touchend",a,{passive:!0}),()=>{t.removeEventListener("touchstart",n),t.removeEventListener("touchmove",r),t.removeEventListener("touchend",a)}},[Z,e,J,ke,U,Q]);const Le=v(()=>((e,t,n=7)=>{const r=new Date(t);return r.setDate(t.getDate()+(n-1)),r.setHours(23,59,59,999),e.filter(e=>{const n=B(e.start);n.setHours(0,0,0,0);const a=B(e.end);return a.setHours(23,59,59,999),a>=t&&n<=r}).map(e=>{const r=B(e.start),a=Math.floor((r.getTime()-t.getTime())/864e5),o=Math.max(0,Math.min(n-1,a));return Object.assign(Object.assign({},e),{day:o})})})(D,ee,Q),[D,ee,Q]),$e=g(e.state.highlightedEventId);h(()=>{if(e.state.highlightedEventId!==$e.current)if(e.state.highlightedEventId){ue(e.state.highlightedEventId);const t=Le.find(t=>t.id===e.state.highlightedEventId);if(t&&!t.allDay){const e=ne(t.start),n=Se.current;if(n){const t=(e-$)*L;requestAnimationFrame(()=>{n.scrollTo({top:Math.max(0,t-100),behavior:"smooth"})})}}}else ue(null);$e.current=e.state.highlightedEventId},[e.state.highlightedEventId,Le,$,L]);const je=v(()=>((e,t,n=7)=>{const r=Ca(e,t,n).filter(e=>e.event.allDay);r.sort((e,t)=>{const n=B(e.event.start).getTime(),r=B(t.event.start).getTime();if(n!==r)return n-r;const a=e.totalDays;return t.totalDays-a});const a=[];return r.forEach(e=>{let t=0,n=!1;for(;!n;){let r=!1;for(const n of a)if(n.row===t&&!(e.endDayIndex<n.startDayIndex||e.startDayIndex>n.endDayIndex)){r=!0;break}r?t++:n=!0}a.push(Object.assign(Object.assign({},e),{row:t}))}),a})(Le,ee,Q),[Le,ee,Q]),Ye=v(()=>{const e=Z?je.filter(e=>e.endDayIndex>=U&&e.startDayIndex<=2*U-1):je;if(0===e.length)return Y;const t=Math.max(...e.map(e=>e.row));return Y+t*Y},[je,Y,Z,U]),Fe=v(()=>((e,t,n=7)=>{const r=new Map;for(let a=0;a<n;a++){const o=[];e.forEach(e=>{if(e.allDay)return;const r=ka(e,t,n);if(r.length>0){const n=r.find(e=>e.dayIndex===a);if(n){const r=n.endHour>=24?23.99:n.endHour,i=Object.assign(Object.assign({},e),{start:W(re(Ae(t,a),n.startHour)),end:W(re(Ae(t,a),r)),day:a});o.push(i)}}else e.day===a&&o.push(e)});const i=xo.calculateDayEventLayouts(o,{viewType:"week"});r.set(a,i)}return r})(Le,ee,Q),[Le,ee,Q]),{handleMoveStart:ze,handleCreateStart:_e,handleResizeStart:We,handleCreateAllDayEvent:Ue,dragState:Be,isDragging:Ve}=Mo(e,{calendarRef:a,allDayRowRef:A?Ne:void 0,timeGridRef:C,viewType:I.WEEK,onEventsUpdate:(t,n,r)=>{const a=t(Le),o=new Set(a.map(e=>e.id)),i=Le.filter(e=>!o.has(e.id)),l=new Set(Le.map(e=>e.id)),s=a.filter(e=>!l.has(e.id)),d=a.filter(e=>{if(!l.has(e.id))return!1;const t=Le.find(t=>t.id===e.id);return t&&Ze(t,e)});e.applyEventsChanges({delete:i.map(e=>e.id),add:s,update:d.map(e=>({id:e.id,updates:e}))},n,r)},onEventCreate:t=>{E?(ye(t),fe(!0)):(e.addEvent(t),me(t.id))},onEventEdit:()=>{},currentWeekStart:ee,events:Le,calculateNewEventLayout:(e,t,n)=>((e,t,n,r)=>{const a=new Date,o=new Date;a.setHours(Math.floor(t),t%1*60,0,0),o.setHours(Math.floor(n),n%1*60,0,0);const i={id:"-1",title:"Temp",day:e,start:W(a),end:W(o),calendarId:"blue",allDay:!1},l=[...r.filter(t=>t.day===e&&!t.allDay),i];return xo.calculateDayEventLayouts(l,{viewType:"week"}).get("-1")||null})(e,t,n,Le),calculateDragLayout:(e,t,n,r)=>((e,t,n,r,a)=>{const o=a.map(a=>{if(a.id!==e.id)return a;const o=B(a.start),i=re(o,n),l=re(o,r),s=W(i),d=W(l);return Object.assign(Object.assign({},a),{day:t,start:s,end:d})}).filter(e=>e.day===t&&!e.allDay);return 0===o.length?null:xo.calculateDayEventLayouts(o,{viewType:"week"}).get(e.id)||null})(e,t,n,r,Le),TIME_COLUMN_WIDTH:P,isMobile:E,gridWidth:G,displayDays:Q}),{handleDrop:Ge,handleDragOver:Ke}=ko({app:e,onEventCreated:e=>{me(e.id)}}),qe=v(()=>Z?Array.from({length:Q},(e,t)=>{const n=new Date(ee);return n.setDate(n.getDate()+t),n.toLocaleDateString(y,{weekday:"short"})}):f(y,"short",V),[y,f,Z,ee,Q,V]),Xe=v(()=>{if(!E)return[];const e=y.split("-")[0].toLowerCase();return"zh"===e||"ja"===e?f(y,"narrow"):qe.map(t=>{if("en"===e){if(t.startsWith("Tu"))return"Tu";if(t.startsWith("Th"))return"Th";if(t.startsWith("Sa"))return"Sa";if(t.startsWith("Su"))return"Su"}return t.charAt(0)})},[E,y,f,qe]),Je=v(()=>m("allDay"),[m]),Qe=Array.from({length:24},(e,t)=>({hour:t+$,label:be(t+$,0,O)})),tt=v(()=>R?Ee(Qe,R,O):void 0,[R,O,$]),nt=v(()=>R?Ce(Intl.DateTimeFormat().resolvedOptions().timeZone):void 0,[R]),rt=v(()=>R?Ce(R):void 0,[R]),at=v(()=>{const e=new Date;return e.setHours(0,0,0,0),qe.map((t,n)=>{const r=new Date(ee);r.setDate(ee.getDate()+n);const a=new Date(r);return a.setHours(0,0,0,0),{date:r.getDate(),month:r.toLocaleString(y,{month:"short"}),fullDate:new Date(r),isToday:a.getTime()===e.getTime()}})},[ee,qe,y]),ot=v(()=>{const e=new Date;e.setHours(0,0,0,0);const t=K;return Array.from({length:7},(n,r)=>{const a=new Date(t);a.setDate(t.getDate()+r);const o=new Date(a);return o.setHours(0,0,0,0),{date:a.getDate(),month:a.toLocaleString(y,{month:"short"}),fullDate:new Date(a),isToday:o.getTime()===e.getTime(),isCurrent:o.getTime()===new Date(w).setHours(0,0,0,0),dayName:a.toLocaleDateString(y,{weekday:"short"})}})},[K,y,w]);h(()=>{if(!Z)return Me.current&&(Me.current.style.transform="",Me.current.style.transition=""),void(He.current&&(He.current.style.transform="",He.current.style.transition=""));const e=ke?"transform 0.3s ease-out":"none",t=`translateX(calc(calc(-100% / 3) + ${De}px))`;Me.current&&(Me.current.style.transition=e,Me.current.style.transform=t),He.current&&(He.current.style.transition=e,He.current.style.transform=t)},[De,ke,Z]);const it=t=>{e.updateEvent(t.id,t)},lt=t=>{e.deleteEvent(t)},st=v(()=>{const e=new Date;e.setHours(0,0,0,0);const t=new Date(ee);t.setHours(0,0,0,0);const n=new Date(t);return n.setDate(t.getDate()+Q),e>=t&&e<n},[ee,Q]);return p(()=>{if(t.scrollToCurrentTime&&Se.current){const e=Se.current,t=new Date,n=t.getHours()+t.getMinutes()/60,r=e.clientHeight;e.scrollTop=Math.max(0,(n-$)*L-r/2)}},[]),h(()=>{ae(new Date);const e=setInterval(()=>ae(new Date),6e4);return()=>clearInterval(e)},[]),et("div",{className:"df-calendar relative flex flex-col bg-white dark:bg-gray-900 w-full overflow-hidden h-full select-none df-week-view",children:[et(Fa,{calendar:e,viewType:I.WEEK,currentDate:w,onPrevious:()=>{if(Z){const t=new Date(w);t.setDate(t.getDate()-1),X(e=>{const t=new Date(e);return t.setDate(t.getDate()-1),t}),e.setCurrentDate(t)}else e.goToPrevious()},onNext:()=>{if(Z){const t=new Date(w);t.setDate(t.getDate()+1),X(e=>{const t=new Date(e);return t.setDate(t.getDate()+1),t}),e.setCurrentDate(t)}else e.goToNext()},onToday:()=>e.goToToday()}),et(Lo,{app:e,weekDaysLabels:qe,mobileWeekDaysLabels:Xe,weekDates:at,fullWeekDates:ot,isSlidingView:Z,mobilePageStart:q,currentWeekStart:ee,gridWidth:G,allDayAreaHeight:Ye,organizedAllDaySegments:je,allDayLabelText:Je,isMobile:E,isTouch:k,showAllDay:A,calendarRef:a,allDayRowRef:Ne,topFrozenContentRef:Me,ALL_DAY_HEIGHT:Y,HOUR_HEIGHT:L,FIRST_HOUR:$,dragState:Be,isDragging:Ve,secondaryTimeSlots:tt,primaryTzLabel:nt,secondaryTzLabel:rt,handleMoveStart:ze,handleResizeStart:We,handleEventUpdate:it,handleEventDelete:lt,onDateChange:l,newlyCreatedEventId:ge,setNewlyCreatedEventId:me,selectedEventId:de,setSelectedEventId:ue,detailPanelEventId:ce,setDetailPanelEventId:he,handleCreateAllDayEvent:Ue,handleDragOver:Ke,handleDrop:Ge,customDetailPanelContent:n,customEventDetailDialog:r}),et($o,{app:e,timeSlots:Qe,weekDaysLabels:qe,currentWeekStart:ee,currentWeekEvents:Le,eventLayouts:Fe,gridWidth:G,isMobile:E,isSlidingView:Z,isTouch:k,scrollerRef:Se,timeGridRef:C,leftFrozenContentRef:Ie,swipeContentRef:He,calendarRef:a,handleScroll:e=>{const{scrollLeft:t}=e.currentTarget;if(Me.current){const e=Z?"calc(-100% / 3)":"0px",n=Z?`${De}px`:`-${t}px`;Me.current.style.transform=`translateX(calc(${e} + ${n}))`,Me.current.style.transition=Z&&ke?"transform 0.3s ease-out":"none"}},handleCreateStart:_e,handleTouchStart:(e,t,n)=>{if(!E&&!k)return;const r=e.touches[0],a=r.clientX,o=r.clientY,i=e.currentTarget;we.current=setTimeout(()=>{null==_e||_e({preventDefault:()=>{},stopPropagation:()=>{},touches:[{clientX:a,clientY:o}],changedTouches:[{clientX:a,clientY:o}],target:i,currentTarget:i,cancelable:!0},t,n)},500)},handleTouchEnd:()=>{we.current&&(clearTimeout(we.current),we.current=null)},handleTouchMove:()=>{we.current&&(clearTimeout(we.current),we.current=null)},handleDragOver:Ke,handleDrop:Ge,dragState:Be,isDragging:Ve,handleMoveStart:ze,handleResizeStart:We,handleEventUpdate:it,handleEventDelete:lt,onDateChange:l,newlyCreatedEventId:ge,setNewlyCreatedEventId:me,selectedEventId:de,setSelectedEventId:ue,detailPanelEventId:ce,setDetailPanelEventId:he,customDetailPanelContent:n,customEventDetailDialog:r,isCurrentWeek:st,currentTime:te,HOUR_HEIGHT:L,FIRST_HOUR:$,LAST_HOUR:j,showStartOfDayLabel:F,timeFormat:O,secondaryTimeSlots:tt}),et(z,{isOpen:ve,onClose:()=>{fe(!1),ye(null)},onSave:t=>{D.some(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),fe(!1),ye(null)},draftEvent:pe,app:e,timeFormat:O})]})},Yo={showWeekends:!0,showAllDay:!0,startOfWeek:1,scrollToCurrentTime:!0,hourHeight:72,firstHour:0,lastHour:24,allDayHeight:28,timeFormat:"24h"},Fo=(e={})=>{const t=Object.assign(Object.assign({},Yo),e),n=e=>a(Ho,{viewType:I.WEEK,originalComponent:jo,app:e.app,config:t,className:"week-view-factory",customDetailPanelContent:e.customDetailPanelContent,customEventDetailDialog:e.customEventDetailDialog,calendarRef:e.calendarRef,switcherMode:e.switcherMode,meta:e.meta,selectedEventId:e.selectedEventId,detailPanelEventId:e.detailPanelEventId,onEventSelect:e.onEventSelect,onDetailPanelToggle:e.onDetailPanelToggle});return n.displayName="WeekViewAdapter",{type:I.WEEK,component:n,config:t}},zo=c(({currentMonth:t,currentYear:n,newlyCreatedEventId:r,screenSize:a,isScrolling:o,isDragging:i,showWeekNumbers:l,showMonthIndicator:s=!0,item:d,weekHeight:c,events:m,dragState:f,calendarRef:p,onEventUpdate:y,onEventDelete:b,onMoveStart:w,onCreateStart:D,onResizeStart:x,onDetailPanelOpen:E,onMoreEventsClick:C,onChangeView:k,onSelectDate:T,selectedEventId:N,onEventSelect:S,onEventLongPress:M,detailPanelEventId:H,onDetailPanelToggle:A,customDetailPanelContent:O,customEventDetailDialog:R,onCalendarDrop:P,onCalendarDragOver:L,app:$,enableTouch:j})=>{const{t:Y,locale:F}=vn(),[z,_]=u(!1),W=g(null),U=g(null),Z=g(null),[V,G]=u(null),K=v(()=>{const e=c-33;if(e<=0)return{maxSlots:0,maxSlotsWithMore:0};const t=e-20;return{maxSlots:Math.min(4,Math.floor(e/17)),maxSlotsWithMore:Math.min(4,Math.max(0,Math.floor(t/17)))}},[c]);h(()=>o?(_(!0),W.current&&(clearTimeout(W.current),W.current=null),()=>{W.current&&(clearTimeout(W.current),W.current=null)}):z?(W.current=setTimeout(()=>{_(!1),W.current=null},100),()=>{W.current&&(clearTimeout(W.current),W.current=null)}):void 0,[o,z]);const{weekData:q}=d,X=q.days.find(e=>1===e.day),J=`${c}px`,Q=v(()=>St(),[]),ee=v(()=>Ca(m,q.startDate),[m,q.startDate]),te=v(()=>((t,n)=>{const r=[],a=new Date(n);return a.setDate(a.getDate()+6),a.setHours(23,59,59,999),t.forEach(t=>{if(!t.start||!t.end)return void qe.warn("Event missing start or end date:",t);const o=B(t.start),i=B(t.end),l=new Date(o);l.setHours(0,0,0,0);const s=new Date(i);s.setHours(0,0,0,0);let d=new Date(s);if(!t.allDay&&0===i.getHours()&&0===i.getMinutes()&&0===i.getSeconds()){const e=i.getTime()-o.getTime();e>0&&e<864e5&&(d=new Date(s),d.setDate(d.getDate()-1))}const c=l.toDateString()!==d.toDateString();if(!c||t.allDay)if(c&&t.allDay){let l=new Date(o);l<n&&(l=new Date(n),l.setHours(0,0,0,0));const s=i>a?a:i;for(let a=o.getTime();a<=s.getTime();a+=864e5){const o=new Date(a);if(o<n)continue;const i=e.PlainDate.from({year:o.getFullYear(),month:o.getMonth()+1,day:o.getDate()});r.push(Object.assign(Object.assign({},t),{start:i,end:i,day:l.getDay()}))}}else r.push(Object.assign(Object.assign({},t),{start:t.start,end:t.end,day:o.getDay()}))}),r})(m,q.startDate),[m,q.startDate]),re=v(()=>{const e=new Map;return q.days.forEach(t=>{const n=t.date.toDateString();e.set(n,te.filter(e=>{if(!e.start||!e.end)return B(e.start).toDateString()===n;const t=B(e.start),r=B(e.end);if(!e.allDay){if(!(0!==r.getHours()||0!==r.getMinutes()||0!==r.getSeconds())){const e=r.getTime()-t.getTime();if(e>0&&e<864e5)return t.toDateString()===n}}return t.toDateString()===n||r.toDateString()===n}))}),e},[te,q.days]),ae=v(()=>(e=>{const t=[...e].toSorted((e,t)=>{const n=e.endDayIndex-e.startDayIndex+1,r=t.endDayIndex-t.startDayIndex+1;return e.startDayIndex>t.startDayIndex?1:n!==r?r-n:e.startDayIndex-t.startDayIndex}),n=[];t.forEach(e=>{var t;let r=0,a=!1;for(;!a;){let o=!1;for(const a of n){const n=Math.abs((null!==(t=a.yPosition)&&void 0!==t?t:0)-r)<16,i=!(e.endDayIndex<a.startDayIndex||e.startDayIndex>a.endDayIndex);if(n&&i){o=!0;break}}o?r+=16:a=!0}n.push(Object.assign(Object.assign({},e),{yPosition:r}))});const r=[];return n.forEach(e=>{var t;const n=Math.floor((null!==(t=e.yPosition)&&void 0!==t?t:0)/16);r[n]||(r[n]=[]),r[n].push(e)}),r.forEach(e=>{e.sort((e,t)=>e.startDayIndex-t.startDayIndex)}),r})(ee),[ee]),oe=v(()=>ae.flat(),[ae]),le=v(()=>{const e=Array.from({length:7}).fill(0);return ae.forEach((t,n)=>{t.forEach(t=>{for(let r=t.startDayIndex;r<=t.endDayIndex;r++)e[r]=Math.max(e[r],n+1)})}),e},[ae]),se=v(()=>{const e=Array.from({length:7},()=>new Set);return ae.forEach((t,n)=>{t.forEach(t=>{for(let r=t.startDayIndex;r<=t.endDayIndex;r++)r>=0&&r<7&&e[r].add(n)})}),e},[ae]),de=v(()=>{var e;for(let t=0;t<q.days.length;t++){const n=q.days[t],r=(null!==(e=re.get(n.date.toDateString()))&&void 0!==e?e:[]).filter(e=>{if(!e.allDay)return!0;return!oe.some(t=>t.originalEventId===e.id)}),a=se[t],o=le[t]-1;let i=0;for(let e=0;e<=o;e++)a.has(e)||i++;if(o+1+Math.max(0,r.length-i)>K.maxSlots)return K.maxSlotsWithMore}return K.maxSlots},[q.days,re,oe,le,se,K.maxSlots,K.maxSlotsWithMore]),ce=v(()=>Math.max(0,17*ae.length),[ae]),ue=(e,o)=>{var s,d;const c=e.date.toLocaleDateString(F,{month:F.startsWith("zh")||F.startsWith("ja")?"short":"long"})===t&&e.year===n,u=(e=>[...e].toSorted((e,t)=>e.allDay!==t.allDay?e.allDay?-1:1:e.allDay&&t.allDay?0:ne(e.start)-ne(t.start)))(null!==(s=re.get(e.date.toDateString()))&&void 0!==s?s:[]),h=u.filter(e=>{if(!e.allDay)return!0;return!oe.some(t=>t.originalEventId===e.id)}),g=se[o],m=(null!==(d=le[o])&&void 0!==d?d:0)-1,v=[];for(let e=0;e<=m;e++)g.has(e)||v.push(e);const z=h.length,_=Math.max(0,z-v.length),W=Math.max(m+1,0)+_,B=W>K.maxSlots,V=B?K.maxSlotsWithMore:K.maxSlots,q=v.filter(e=>e<V).length,X=Math.max(0,V-Math.max(m+1,0)),ee=Math.min(z,q+X),te=h.slice(0,ee),ae=z-ee,de=[];let ce=0;const ue=Math.min(V,W);for(let t=0;t<ue;t++)if(g.has(t))de.push(et("div",{className:"shrink-0",style:{height:"17px",minHeight:"17px"}},`placeholder-layer-${t}-${e.date.getTime()}`));else if(ce<te.length){const e=te[ce];de.push(et(ja,{event:e,isAllDay:!!e.allDay,viewType:I.MONTH,isBeingDragged:i&&f.eventId===e.id&&"move"===f.mode,calendarRef:p,hourHeight:72,firstHour:0,onEventUpdate:y,onEventDelete:b,onMoveStart:w,onResizeStart:x,onDetailPanelOpen:E,onEventSelect:S,onEventLongPress:M,newlyCreatedEventId:r,selectedEventId:N,detailPanelEventId:H,onDetailPanelToggle:A,customDetailPanelContent:O,customEventDetailDialog:R,app:$,isMobile:"desktop"!==a,enableTouch:j},`${e.id}-${e.day}-${ne(e.start)}-${ce}`)),ce++}return et("div",{className:nr("df-month-day-cell relative flex flex-col border-r border-gray-200 dark:border-gray-700",c?"text-gray-800 dark:text-gray-100":"text-gray-400 dark:text-gray-600",6===o?Q?"last:border-r":"border-r-0":""),style:{height:J},"data-date":(he=e.date,`${he.getFullYear()}-${String(he.getMonth()+1).padStart(2,"0")}-${String(he.getDate()).padStart(2,"0")}`),onClick:()=>null==T?void 0:T(e.date),onDblClick:t=>null==D?void 0:D(t,e.date),onTouchStart:t=>{if("mobile"!==a&&!j)return;const n=t.touches[0],r=n.clientX,o=n.clientY;Z.current={x:r,y:o},U.current=setTimeout(()=>{null==D||D(t,e.date),U.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},onTouchMove:e=>{if(U.current&&Z.current){const t=Math.abs(e.touches[0].clientX-Z.current.x),n=Math.abs(e.touches[0].clientY-Z.current.y);(t>10||n>10)&&(clearTimeout(U.current),U.current=null)}},onTouchEnd:()=>{U.current&&(clearTimeout(U.current),U.current=null),Z.current=null},onDragOver:L,onDrop:t=>null==P?void 0:P(t,e.date),onContextMenu:t=>((e,t)=>{e.preventDefault(),"mobile"!==a&&G({x:e.clientX,y:e.clientY,date:t})})(t,e.date),children:[et("div",{className:"df-month-date-number-container flex items-center justify-end text-right px-2 h-[33px] relative z-20",children:[l&&0===o&&"mobile"!==a&&et("span",{className:"mr-auto ml-1 text-[10px] font-medium text-gray-400 dark:text-gray-500",children:ie(e.date)}),et("span",{className:` df-month-date-number inline-flex items-center justify-center h-6 min-w-6 rounded-full text-sm font-medium whitespace-nowrap px-1 ${e.isToday?"bg-primary text-primary-foreground":c?"text-gray-900 dark:text-gray-100":"text-gray-400 dark:text-gray-600"} `,children:1===e.day&&"desktop"===a?e.date.toLocaleDateString(F,{month:"short",day:"numeric"}):e.day})]}),et("div",{className:"flex-1 overflow-hidden px-1",children:[de,B&&et("div",{className:nr("df-month-more-events text-xs text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 cursor-pointer hover:underline relative z-20 bg-white dark:bg-gray-900","desktop"===a?"text-left font-normal":"text-center font-medium"),onClick:t=>{t.stopPropagation(),C?C(e.date):(null==T||T(e.date),null==k||k(I.DAY))},children:["+",ae,"desktop"===a?` ${Y("more")}`:""]})]})]},`day-${e.date.getTime()}`);var he},he=v(()=>X?X.date.toLocaleDateString(F,{month:"long",year:"numeric"}):"",[X,F]);return et("div",{className:"relative border-b border-gray-200 select-none dark:border-gray-700",style:{height:J},children:[s&&X&&et("div",{className:` df-month-title absolute top-10 left-0 z-30 bg-white/50 dark:bg-gray-900/50 py-2 px-2 duration-300 ${z?"pointer-events-auto opacity-100":"pointer-events-none opacity-0"} `,style:{transition:"opacity 0.5s ease",maxWidth:"fit-content"},onContextMenu:e=>e.preventDefault(),children:et("span",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:he})}),et("div",{className:"flex h-full flex-col",children:et("div",{className:"calendar-week relative h-full",children:[et("div",{className:"grid h-full grid-cols-7",children:q.days.map((e,t)=>ue(e,t))}),ae.length>0&&et("div",{className:"pointer-events-none absolute right-0 left-0",style:{top:"33px",height:`${ce}px`,zIndex:10},children:ae.slice(0,de).map((e,t)=>et("div",{className:"absolute inset-0",children:e.map(e=>et(ja,{event:e.event,isAllDay:!!e.event.allDay,segment:e,segmentIndex:t,viewType:I.MONTH,isMultiDay:!0,calendarRef:p,hourHeight:72,firstHour:0,onEventUpdate:y,onEventDelete:b,onMoveStart:w,onResizeStart:x,isBeingDragged:i&&f.eventId===e.event.id&&"move"===f.mode,isBeingResized:i&&f.eventId===e.event.id&&"resize"===f.mode,newlyCreatedEventId:r,onDetailPanelOpen:E,selectedEventId:N,onEventSelect:S,onEventLongPress:M,detailPanelEventId:H,onDetailPanelToggle:A,customDetailPanelContent:O,customEventDetailDialog:R,app:$,isMobile:"desktop"!==a,enableTouch:j},e.id))},`layer-${t}`))})]})}),V&&et(Da,{x:V.x,y:V.y,date:V.date,viewType:I.MONTH,onClose:()=>G(null),app:$,onCreateEvent:()=>{if(D){const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:V.x,clientY:V.y};D(e,V.date)}}})]})});zo.displayName="WeekComponent";const _o=({app:e,config:t,customDetailPanelContent:n,customEventDetailDialog:r,calendarRef:a,selectedEventId:o,onEventSelect:i,detailPanelEventId:l,onDetailPanelToggle:s})=>{var d;const{getWeekDaysLabels:c,getMonthLabels:f,locale:p}=vn(),y=e.getCurrentDate(),b=e.getEvents(),w=null!==(d=t.startOfWeek)&&void 0!==d?d:1,D=e.getCalendars().map(e=>e.id+e.colors.lineColor).join("-"),x=g(null),E=v(()=>{const e=x.current;return e&&e.length===b.length&&e.every((e,t)=>e===b[t])?e:(x.current=b,b)},[b]),C=v(()=>{const e=new Map,t=e=>{const t=new Date(e);t.setHours(0,0,0,0);const n=(t.getDay()-w+7)%7;return t.setDate(t.getDate()-n),t.setHours(0,0,0,0),t},n=(t,n)=>{const r=e.get(t);r?r.push(n):e.set(t,[n])};return E.forEach(e=>{if(!e.start)return;const r=B(e.start),a=e.end?B(e.end):r,o=new Date(r);o.setHours(0,0,0,0);const i=new Date(a);i.setHours(0,0,0,0);let l=new Date(i);if(!e.allDay){0!==a.getHours()||0!==a.getMinutes()||0!==a.getSeconds()||0!==a.getMilliseconds()||l.setDate(l.getDate()-1)}l<o&&(l=new Date(o));const s=t(o),d=t(l);let c=s.getTime();const u=d.getTime();for(;c<=u;){n(c,e);const t=new Date(c);t.setDate(t.getDate()+7),t.setHours(0,0,0,0),c=t.getTime()}}),e},[E,w]),{screenSize:k}=gn(),[T,N]=u(!1);h(()=>{N("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const S=e.getCustomMobileEventRenderer()||Qr,[M,H]=u(119),[R,P]=u(!1),L=g(M),$=g([]),[j,Y]=u(null),[F,z]=u(!1),[_,W]=u(null),[U,Z]=u(null),[V,G]=u(null),K=void 0===o?U:o,q=void 0===l?V:l,X=m(e=>{i?i(e):Z(e)},[i]),J=m(e=>{s?s(e):G(e)},[s]),Q=g(e.state.highlightedEventId);h(()=>{e.state.highlightedEventId?X(e.state.highlightedEventId):Q.current&&X(null),Q.current=e.state.highlightedEventId},[e.state.highlightedEventId]);const ee=v(()=>{const e=(y.getDay()-w+7)%7,t=new Date(y);return t.setDate(y.getDate()-e),t.setHours(0,0,0,0),t},[y,w]),{handleMoveStart:te,handleCreateStart:ne,handleResizeStart:re,dragState:ae,isDragging:oe}=Mo(e,{calendarRef:a,viewType:I.MONTH,onEventsUpdate:(t,n,r)=>{const a=t(E),o=new Set(a.map(e=>e.id)),i=E.filter(e=>!o.has(e.id)),l=new Set(E.map(e=>e.id)),s=a.filter(e=>!l.has(e.id)),d=a.filter(e=>{if(!l.has(e.id))return!1;const t=E.find(t=>t.id===e.id);return t&&Ze(t,e)});e.applyEventsChanges({delete:i.map(e=>e.id),add:s,update:d.map(e=>({id:e.id,updates:e}))},n,r)},onEventCreate:t=>{"desktop"===k?e.addEvent(t):(W(t),z(!0))},onEventEdit:e=>{Y(e.id)},currentWeekStart:ee,events:E}),{handleDrop:ie,handleDragOver:le}=ko({app:e,onEventCreated:e=>{Y(e.id)}}),se=v(()=>c(p,"short",w),[p,c,w]),{currentMonth:de,currentYear:ce,isScrolling:ue,virtualData:he,weeksData:ge,scrollElementRef:me,isNavigating:ve,handleScroll:fe,handlePreviousMonth:pe,handleNextMonth:ye,handleToday:be,setScrollTop:we}=(({currentDate:e,weekHeight:t,onCurrentMonthChange:n,initialWeeksToLoad:r=104,locale:a="en-US",startOfWeek:o=1,isEnabled:i=!0})=>{const l=g(null),s=m((e,t)=>{const n=new Date(t,e,1),r=a.startsWith("zh")||a.startsWith("ja");return n.toLocaleDateString(a,{month:r?"short":"long"})},[a]),d=v(()=>{const t=new Date(e);return t.setDate(1),t.setHours(0,0,0,0),Me(t,r,o)},[e,r,o]),c=v(()=>{const n=new Date(e);n.setDate(1),n.setHours(0,0,0,0);const r=d.findIndex(e=>e.days.some(e=>e.date.toDateString()===n.toDateString()));return r>0?r*t:0},[d,e,t]),[f,p]=u(c),[y,b]=u(600),[w,D]=u(s(e.getMonth(),e.getFullYear())),[x,E]=u(e.getFullYear()),[C,k]=u(!1),[T,N]=u(d),[S,M]=u(!1),I=g(!1),[H,R]=u(!1),P=g(e),L=g(null),$=g(null),j=g(new O),Y=g(0),F=g(0),z=g(!1),_=m(e=>{e&&(L.current=e)},[]),W=m(e=>{let t=j.current.get(e);return t||(t=Ne(e),j.current.set(e,t)),t},[]),U=m((e,n=26)=>{z.current||(z.current=!0,setTimeout(()=>{try{if("future"===e){const e=T.at(-1),t=[];for(let r=1;r<=n;r++){const n=new Date(e.startDate);n.setDate(n.getDate()+7*r),t.push(W(n))}N(e=>[...e,...t])}else{const e=T[0],r=[];for(let t=n;t>=1;t--){const n=new Date(e.startDate);n.setDate(n.getDate()-7*t),r.push(W(n))}const a=r.length*t;N(e=>[...r,...e]),requestAnimationFrame(()=>{p(e=>e+a),L.current&&(L.current.scrollTop+=a)})}}finally{setTimeout(()=>{z.current=!1},200)}},0))},[T,W,t]),B=v(()=>{const e=T.length*t,n=Math.floor(f/t);let r=Math.max(0,n);r=Math.min(r,Math.max(0,T.length-6));const a=Math.min(T.length-1,r+6-1),o=Math.max(0,r-15),i=Math.min(T.length-1,a+15),l=[];for(let e=o;e<=i;e++)l.push({index:e,weekData:T[e],top:e*t,height:t});return{totalHeight:e,visibleItems:l,displayStartIndex:r}},[f,y,t,T]),Z=m(e=>{if(S||C||0===e.length||!H)return;const t=f+y/2,r=e.find(e=>e.top<=t&&e.top+e.height>t)||e[Math.floor(e.length/2)];if(!r)return;const a={};r.weekData.days.forEach(e=>{const t=`${s(e.month,e.year)}-${e.year}`;a[t]=(a[t]||0)+1});let o="",i=0,d=0;Object.entries(a).forEach(([e,t])=>{if(t>d){d=t;const[n,r]=e.split("-");o=n,i=Number.parseInt(r,10)}}),o&&i&&(l.current?o===l.current.month&&i===l.current.year&&(l.current=null,o===w&&i===x||(D(o),E(i),null==n||n(o,i))):o===w&&i===x||(D(o),E(i),null==n||n(o,i)))},[y,w,x,S,C,n,f,H]),V=m(e=>{const n=performance.now();if(n-Y.current<A.SCROLL_THROTTLE)return;Y.current=n;const r=e.currentTarget,a=r.scrollTop;F.current=a,p(a),S||requestAnimationFrame(()=>{const{scrollHeight:e,clientHeight:n}=r;a+n>e-10*t&&!z.current&&U("future",26),a<10*t&&!z.current&&U("past",26)}),k(!0),$.current&&clearTimeout($.current),$.current=setTimeout(()=>{k(!1)},A.SCROLL_DEBOUNCE)},[t,U,S]),G=m((e,n=!0)=>{if(!L.current)return;M(!0),I.current=!0;const r=()=>{setTimeout(()=>{M(!1),I.current=!1},n?500:200)},a=T.findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(-1!==a){const e=a*t;return L.current.scrollTo({top:e,behavior:n?"smooth":"auto"}),void r()}const i=(e.getDay()-o+7)%7,l=new Date(e);l.setDate(e.getDate()-i),l.setHours(0,0,0,0);const s=T[0],d=T.at(-1);let c=0,u=!1,h=!1;l<s.startDate?(c=Math.ceil((s.startDate.getTime()-l.getTime())/6048e5),u=!0):l>d.startDate&&(c=Math.ceil((l.getTime()-d.startDate.getTime())/6048e5),h=!0);const g=Math.min(c+10,52);if(u){const a=[];for(let e=g;e>=1;e--){const t=new Date(s.startDate);t.setDate(t.getDate()-7*e),a.push(W(t))}const o=a.length*t;N(e=>[...a,...e]),requestAnimationFrame(()=>{const i=[...a,...T].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(L.current&&-1!==i){const e=i*t;L.current.scrollTop+=o,p(e=>e+o),setTimeout(()=>{L.current&&L.current.scrollTo({top:e,behavior:n?"smooth":"auto"})},50)}r()})}else if(h){const a=[];for(let e=1;e<=g;e++){const t=new Date(d.startDate);t.setDate(t.getDate()+7*e),a.push(W(t))}N(e=>[...e,...a]),requestAnimationFrame(()=>{const o=[...T,...a].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(L.current&&-1!==o){const e=o*t;L.current.scrollTo({top:e,behavior:n?"smooth":"auto"})}r()})}else r()},[T,t,W]),K=m(()=>{const e=T[B.displayStartIndex].days[0].date,t=new Date(e.getFullYear(),e.getMonth()-1,1);G(t)},[B.displayStartIndex,T,G]),q=m(()=>{const e=T[B.displayStartIndex].days[0].date,t=new Date(e.getFullYear(),e.getMonth()+1,1);G(t)},[B.displayStartIndex,T,G]),X=m(()=>{const e=new Date,r=s(e.getMonth(),e.getFullYear()),a=e.getFullYear(),o=new Date(a,e.getMonth(),1);l.current={month:r,year:a},D(r),E(a),null==n||n(r,a);const i=T.findIndex(e=>e.days.some(e=>e.date.toDateString()===o.toDateString()));if(-1===i)M(!0),I.current=!0,requestAnimationFrame(()=>{G(o,!0),setTimeout(()=>{I.current=!1,M(!1)},200)});else{const e=i*t,n=L.current;n&&(M(!0),I.current=!0,requestAnimationFrame(()=>{p(e),requestAnimationFrame(()=>{n&&(n.scrollTop=e,setTimeout(()=>{I.current=!1,M(!1)},200))})}))}},[T,t,n,G]);return h(()=>{Z(B.visibleItems)},[B.visibleItems,Z]),h(()=>{const t=P.current,r=t.getMonth(),a=t.getFullYear(),o=e.getMonth(),i=e.getFullYear();if(r!==o||a!==i){const t=6,r=B.displayStartIndex,a=Math.min(T.length-1,r+t-1);let d=!1;for(let t=r;t<=a;t++){const n=T[t];if(n&&n.days.some(t=>t.date.toDateString()===e.toDateString())){d=!0;break}}if(!d){const e=new Date(i,o,1),t=s(o,i);l.current={month:t,year:i},D(t),E(i),null==n||n(t,i),G(e,!0)}}P.current=e},[e,n,G,B,T,s]),h(()=>{const e=L.current;if(!e)return;const t=new ResizeObserver(([e])=>{b(e.contentRect.height)});return t.observe(e),()=>t.disconnect()},[]),h(()=>{const e=L.current;e&&!H&&i&&requestAnimationFrame(()=>{e&&c>0?(e.scrollTop=c,p(c),R(!0)):e&&R(!0)})},[H,c,i]),h(()=>()=>{$.current&&clearTimeout($.current)},[]),{scrollTop:f,containerHeight:y,currentMonth:w,currentYear:x,isScrolling:C,isNavigating:S,virtualData:B,scrollElementRef:L,handleScroll:V,scrollToDate:G,handlePreviousMonth:K,handleNextMonth:q,handleToday:X,setScrollTop:p,setContainerHeight:b,setCurrentMonth:D,setCurrentYear:E,setIsScrolling:k,cache:j.current,scrollElementRefCallback:_,weeksData:T}})({currentDate:y,weekHeight:M,onCurrentMonthChange:(t,n)=>{const r=p.startsWith("zh")||p.startsWith("ja"),a=f(p,r?"short":"long").indexOf(t);a>=0&&e.setVisibleMonth(new Date(n,a,1))},initialWeeksToLoad:156,locale:p,startOfWeek:w,isEnabled:R}),De=g(0),[xe,Ee]=u(0),Ce=v(()=>xe-6*M,[xe,M]),{visibleWeeks:ke,startIndex:Te}=v(()=>{var e,t;const{visibleItems:n,displayStartIndex:r}=he,a=n.findIndex(e=>e.index===r);if(-1===a)return $.current.length>0?{visibleWeeks:$.current,startIndex:De.current}:{visibleWeeks:[],startIndex:r};const o=Math.max(0,a-2),i=n.slice(o,a+8),l=null!==(t=null===(e=n[o])||void 0===e?void 0:e.index)&&void 0!==t?t:r;return i.length>=6&&($.current=i,De.current=l),{visibleWeeks:i,startIndex:l}},[he]),Se=v(()=>Te*M,[Te,M]),Ie=g(!0),He=g(!1),Ae=((e,t)=>{const[n,r]=u(e);return h(()=>{const n=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(n)}},[e,t]),n})(he.displayStartIndex,250);h(()=>{ve&&(He.current=!0)},[ve]),h(()=>{if(Ie.current)return void(Ie.current=!1);const t=ge[Ae];if(!t)return;const n=new Date(t.startDate);n.setHours(0,0,0,0);const r=new Date(n);r.setDate(r.getDate()+42+7),e.emitVisibleRange(n,r,He.current?"navigation":"scroll"),He.current=!1},[e,ge,Ae]);const Oe=v(()=>{const e=he.totalHeight,t=Te*M+ke.length*M+Ce;return Math.max(0,e-t)},[he.totalHeight,Te,M,Ce,ke.length]);h(()=>{const e=me.current;if(!e)return;const t=new ResizeObserver(t=>{for(const n of t){const t=n.contentRect.height;if(Ee(t),t>0){const n=Math.max(80,Math.ceil(t/6));if(n!==L.current){const t=e.scrollTop;if(t>0){const r=Math.round(t/L.current)*n;e.scrollTop=r,we(r)}H(n),L.current=n}}}});return t.observe(e),()=>{t.disconnect()}},[me,we]),h(()=>{const e=window.innerHeight-150,t=Math.max(80,Math.ceil(e/6));H(t),L.current=t,P(!0)},[]);const Re=m(t=>{e.updateEvent(t.id,t)},[e]),Pe=m(t=>{e.deleteEvent(t)},[e]),Le=t=>{e.changeView(t)},$e=m(()=>Y(null),[]),je=m(t=>{const n=e.getReadOnlyConfig().viewable;if(("desktop"!==k||T)&&t&&n){const e=E.find(e=>e.id===t);if(e)return W(e),void z(!0)}X(t)},[k,T,E,X,e]),Ye=m(e=>{("desktop"!==k||T)&&X(e)},[k,T,X]);return et("div",{className:bn,children:[et(Fa,{calendar:e,viewType:I.MONTH,currentDate:y,customTitle:p.startsWith("zh")||p.startsWith("ja")?`${ce}年${de}`:`${de} ${ce}`,onPrevious:()=>{e.goToPrevious(),pe()},onNext:()=>{e.goToNext(),ye()},onToday:()=>{e.goToToday(),be()}}),et("div",{className:"df-week-header-row sticky top-0 z-10 bg-white dark:bg-gray-900 border-b border-gray-200 dark:border-gray-700",onContextMenu:e=>e.preventDefault(),children:et("div",{className:"grid grid-cols-7 px-2",children:se.map((e,t)=>et("div",{className:"text-right text-gray-500 dark:text-gray-400 text-sm py-2 pr-2 select-none",children:e},`${e}-${t}`))})}),et("div",{ref:me,className:Cn,style:{overflow:"hidden auto",visibility:R?"visible":"hidden"},onScroll:fe,children:[et("div",{style:{height:Se}}),ke.map((o,i)=>{var l;const s=null!==(l=C.get(o.weekData.startDate.getTime()))&&void 0!==l?l:[],d=5===i?Object.assign(Object.assign({},o),{height:o.height+Ce}):o,c=!(!1===t.showMonthIndicator||!o.weekData.days.some(e=>1===e.day))&&ue;return et(zo,{item:d,weekHeight:M,showWeekNumbers:t.showWeekNumbers,showMonthIndicator:t.showMonthIndicator,currentMonth:de,currentYear:ce,screenSize:k,isScrolling:c,calendarRef:a,events:s,onEventUpdate:Re,onEventDelete:Pe,onMoveStart:te,onCreateStart:ne,onResizeStart:re,isDragging:oe,dragState:ae,newlyCreatedEventId:j,onDetailPanelOpen:$e,onMoreEventsClick:e.onMoreEventsClick,onChangeView:Le,onSelectDate:e.selectDate,selectedEventId:K,onEventSelect:je,onEventLongPress:Ye,detailPanelEventId:q,onDetailPanelToggle:J,customDetailPanelContent:n,customEventDetailDialog:r,onCalendarDrop:ie,onCalendarDragOver:le,calendarSignature:D,app:e,enableTouch:T},`week-${o.weekData.startDate.getTime()}`)}),et("div",{style:{height:Oe}})]}),et(S,{isOpen:F,onClose:()=>{z(!1),W(null)},onSave:t=>{E.some(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),z(!1),W(null)},draftEvent:_,app:e})]})},Wo={showWeekNumbers:!1,showMonthIndicator:!0,startOfWeek:1},Uo=(e={})=>{const t=Object.assign(Object.assign({},Wo),e),n=e=>a(Ho,{viewType:I.MONTH,originalComponent:_o,app:e.app,config:t,className:"month-view-factory",customDetailPanelContent:e.customDetailPanelContent,customEventDetailDialog:e.customEventDetailDialog,calendarRef:e.calendarRef,switcherMode:e.switcherMode,meta:e.meta,selectedEventId:e.selectedEventId,detailPanelEventId:e.detailPanelEventId,onEventSelect:e.onEventSelect,onDetailPanelToggle:e.onDetailPanelToggle});return n.displayName="MonthViewAdapter",{type:I.MONTH,component:n,config:t}};const Bo=c(({date:e,isToday:t,locale:n,onSelectDate:r,onCreateStart:a,onMoreEventsClick:o,moreCount:i=0,onContextMenu:l})=>{const{t:s}=vn(),d=e.getDate(),c=1===d,u=e.toLocaleDateString(n,{month:"short"}).toUpperCase();return et("div",{className:`relative flex flex-col border-r border-b border-gray-100 dark:border-gray-800 ${c?"border-l-2 border-l-primary dark:border-l-primary":""} overflow-hidden bg-white select-none dark:bg-gray-900`,style:{aspectRatio:"1/1"},onClick:()=>r(e),onDblClick:t=>null==a?void 0:a(t,e),onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),null==l||l(t,e)},"data-date":`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,children:[et("div",{className:"flex h-6 shrink-0 items-center px-1 py-1",children:[c&&et("span",{className:"rounded-sm bg-primary px-1 py-0.5 text-[9px] leading-none font-bold text-primary-foreground",children:u}),et("span",{className:"ml-auto text-[10px] font-medium "+(t?"flex h-5 w-5 items-center justify-center rounded-full bg-primary text-primary-foreground":"text-gray-700 dark:text-gray-300"),children:d})]}),i>0&&et("div",{className:"absolute bottom-0.5 left-1 z-20",children:et("span",{className:"cursor-pointer text-xs font-medium text-gray-500 hover:text-gray-700 hover:underline dark:text-gray-400 dark:hover:text-gray-200",onClick:t=>{t.stopPropagation(),null==o||o(e)},children:["+",i," ",s("more")]})})]})});Bo.displayName="YearDayCell";const Zo=c(({rowDays:e,events:t,columnsPerRow:n,app:r,calendarRef:a,locale:o,isDragging:i,dragState:l,onMoveStart:s,onResizeStart:d,onCreateStart:c,selectedEventId:u,onEventSelect:h,onMoreEventsClick:g,newlyCreatedEventId:m,onDetailPanelOpen:f,detailPanelEventId:p,onDetailPanelToggle:y,customDetailPanelContent:b,customEventDetailDialog:w,onContextMenu:D})=>{const x=new Date;x.setHours(0,0,0,0);const E=(e,t)=>{e.preventDefault(),e.stopPropagation(),D({x:e.clientX,y:e.clientY,date:t})},C=v(()=>function(e,t,n){if(0===t.length)return[];const r=t[0],a=t.at(-1),o=new Date(r.getFullYear(),r.getMonth(),r.getDate()).getTime(),i=new Date(a.getFullYear(),a.getMonth(),a.getDate(),23,59,59,999).getTime(),l=e.filter(e=>{if(!e.start)return!1;const t=B(e.start),n=e.end?B(e.end):t,r=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),a=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime();return r<=i&&a>=o});l.sort((e,t)=>{const n=B(e.start).getTime(),r=e.end?B(e.end).getTime():n,a=B(t.start).getTime(),o=r-n,i=(t.end?B(t.end).getTime():a)-a;return o!==i?i-o:n-a});const s=[],d=[];return l.forEach(e=>{const a=B(e.start),l=e.end?B(e.end):a,c=new Date(a.getFullYear(),a.getMonth(),a.getDate()).getTime(),u=new Date(l.getFullYear(),l.getMonth(),l.getDate()).getTime();let h=-1,g=-1;const m=Math.round((c-o)/864e5);h=m>=0?m:0;const v=Math.round((u-o)/864e5);g=v<t.length?v:t.length-1,h=Math.max(0,Math.min(h,n-1)),g=Math.max(0,Math.min(g,n-1));const f=c>=o,p=u<=i;let y=0;for(;;){let e=!1;d[y]||(d[y]=[]);for(let t=h;t<=g;t++)if(d[y][t]){e=!0;break}if(!e){for(let e=h;e<=g;e++)d[y][e]=!0;break}y++}s.push({id:`${e.id}_${r.getTime()}`,event:e,startCellIndex:h,endCellIndex:g,isFirstSegment:f,isLastSegment:p,visualRowIndex:y})}),s}(t,e,n),[t,e,n]),{visibleSegments:k,moreCounts:T}=v(()=>{const t=Array.from({length:e.length}).fill(0);C.forEach(n=>{const r=Math.max(0,n.startCellIndex),a=Math.min(e.length-1,n.endCellIndex);for(let e=r;e<=a;e++)t[e]++});const n=[],r=Array.from({length:e.length}).fill(0);return C.forEach(a=>{let o=!0;const i=Math.max(0,a.startCellIndex),l=Math.min(e.length-1,a.endCellIndex);for(let e=i;e<=l;e++){const n=t[e]>3?1:2;if(a.visualRowIndex>n){o=!1;break}}if(o)n.push(a);else for(let e=i;e<=l;e++)r[e]++}),{visibleSegments:n,moreCounts:r}},[C,e.length]);return et("div",{className:"relative w-full",style:{display:"grid",gridTemplateColumns:`repeat(${n}, 1fr)`},onContextMenu:e=>e.preventDefault(),children:[e.map((e,t)=>{const n=e.getTime()===x.getTime();return et(Bo,{date:e,isToday:n,locale:o,onSelectDate:e=>{r.selectDate(e)},onCreateStart:c,onMoreEventsClick:g,moreCount:T[t],onContextMenu:E},e.getTime())}),et("div",{className:"pointer-events-none absolute inset-0",style:{top:26,bottom:0,left:0,right:0},onContextMenu:e=>e.preventDefault(),children:et("div",{className:"relative h-full w-full",children:k.map(e=>et("div",{className:"pointer-events-auto",children:et(ja,{event:e.event,viewType:I.YEAR,yearSegment:e,columnsPerRow:n,isBeingDragged:i&&l.eventId===e.event.id,selectedEventId:u,onMoveStart:s,onResizeStart:d,onEventSelect:h,onDetailPanelToggle:y,newlyCreatedEventId:m,onDetailPanelOpen:f,calendarRef:a,app:r,detailPanelEventId:p,customDetailPanelContent:b,customEventDetailDialog:w,firstHour:0,hourHeight:0,onEventUpdate:e=>r.updateEvent(e.id,e),onEventDelete:e=>r.deleteEvent(e)})},e.id))})})]})});Zo.displayName="YearRowComponent";const Vo=({app:t,calendarRef:n,customDetailPanelContent:r,customEventDetailDialog:a,config:o,selectedEventId:i,onEventSelect:l,detailPanelEventId:s,onDetailPanelToggle:d})=>{var c;const{t:f,locale:p}=vn(),y=t.getCurrentDate(),b=y.getFullYear(),w=t.getEvents(),D=g(null),[x,E]=u(()=>"undefined"!=typeof window?Math.max(1,Math.floor(window.innerWidth/80)):7),[C,k]=u(!1),[T,N]=u(null),[S,M]=u(null),H=void 0===i?T:i,A=void 0===s?S:s,O=e=>{l?l(e):N(e)},R=e=>{d?d(e):M(e)},[P,L]=u(null),[$,j]=u(null);h(()=>{const e=e=>{if(2===e.button)return;const t=e.target,n=t.closest("[data-event-id]"),r=t.closest("[data-event-detail-panel]"),a=t.closest("[data-event-detail-dialog]"),o=t.closest("[data-range-picker-popup]"),i=t.closest("[data-calendar-picker-dropdown]"),l=t.closest(".df-context-menu");n||r||a||o||i||l||(O(null),R(null),j(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const Y=g(null);h(()=>{const e=D.current;if(!e)return;const t=new ResizeObserver(e=>{Y.current&&clearTimeout(Y.current),Y.current=setTimeout(()=>{const t=e[0].contentRect.width,n=Math.floor(t/80);E(Math.max(1,n)),k(!0)},60)});return t.observe(e),()=>{t.disconnect(),Y.current&&clearTimeout(Y.current)}},[]);const F=g(t.state.highlightedEventId);h(()=>{t.state.highlightedEventId?O(t.state.highlightedEventId):F.current&&O(null),F.current=t.state.highlightedEventId},[t.state.highlightedEventId]);const{handleMoveStart:z,handleResizeStart:_,handleCreateStart:W,dragState:U,isDragging:Z}=Mo(t,{calendarRef:n,viewType:I.YEAR,onEventsUpdate:(e,n,r)=>{const a=e(w).filter(e=>{const t=w.find(t=>t.id===e.id);return t&&Ze(t,e)});a.length>0&&t.applyEventsChanges({update:a.map(e=>({id:e.id,updates:e}))},n,r)},currentWeekStart:new Date,events:w,onEventCreate:e=>{t.addEvent(e)},onEventEdit:e=>{L(e.id)}}),V=null!==(c=null==o?void 0:o.showTimedEventsInYearView)&&void 0!==c&&c,G=m((n,r)=>{if(V)null==W||W(n,r);else{const n=e.PlainDate.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate()}),a={id:`event-${Date.now()}`,title:f("newEvent")||"New Event",start:n,end:n,allDay:!0,calendarId:t.getCalendarRegistry().getDefaultCalendarId()||"default"};t.addEvent(a),L(a.id)}},[V,W,t,f]),K=v(()=>{const e=[],t=new Date(b,0,1),n=new Date(b,11,31);for(let r=t.getTime();r<=n.getTime();r+=864e5)e.push(new Date(r));return e},[b]),q=v(()=>function(e,t){const n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}(K,x),[K,x]),X=v(()=>{const e=new Date(b,0,1),t=new Date(b,11,31,23,59,59);return w.filter(n=>{if(!n.start)return!1;if(!V&&!n.allDay)return!1;const r=B(n.start),a=n.end?B(n.end):r;return r<=t&&a>=e})},[w,b,V]);return et("div",{className:bn,onContextMenu:e=>e.preventDefault(),children:[et(Fa,{calendar:t,viewType:I.YEAR,currentDate:y,customTitle:p.startsWith("zh")||p.startsWith("ja")?`${b}年`:`${b}`,onPrevious:()=>{const e=new Date(y);e.setFullYear(e.getFullYear()-1),t.setCurrentDate(e)},onNext:()=>{const e=new Date(y);e.setFullYear(e.getFullYear()+1),t.setCurrentDate(e)},onToday:()=>{t.goToToday()}}),et("div",{ref:D,className:`${Cn} ${kn}`,style:{overflow:"hidden auto"},children:et("div",{className:"flex w-full flex-col border-t border-l border-gray-100 dark:border-gray-800",style:{opacity:C?1:0,transition:"opacity 0.2s ease"},children:q.map((e,o)=>et(Zo,{rowDays:e,events:X,columnsPerRow:x,app:t,calendarRef:n,locale:p,isDragging:Z,dragState:U,onMoveStart:z,onResizeStart:_,onCreateStart:G,selectedEventId:H,onEventSelect:O,onMoreEventsClick:t.onMoreEventsClick,newlyCreatedEventId:P,onDetailPanelOpen:()=>L(null),detailPanelEventId:A,onDetailPanelToggle:R,customDetailPanelContent:r,customEventDetailDialog:a,onContextMenu:j},o))})}),$&&et(Da,{x:$.x,y:$.y,date:$.date,viewType:I.YEAR,onClose:()=>j(null),app:t,onCreateEvent:()=>{if($&&$.date){const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:$.x,clientY:$.y};G(e,$.date)}}})]})};function Go(e,t,n,r=1){const a=new Date(n,t,1),o=new Date(n,t+1,0).getDate(),i=(a.getDay()-r+7)%7,l=a.getTime(),s=new Date(n,t,o,23,59,59,999).getTime(),d=e.filter(e=>{if(!e.start)return!1;const t=B(e.start),n=e.end?B(e.end):t,r=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),a=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime();return r<=s&&a>=l});d.sort((e,t)=>{const n=B(e.start).getTime(),r=e.end?B(e.end).getTime():n,a=B(t.start).getTime(),o=r-n,i=(t.end?B(t.end).getTime():a)-a;return o!==i?i-o:n-a});const c=[],u=[];d.forEach(e=>{const r=B(e.start),a=e.end?B(e.end):r,o=new Date(Math.max(r.getTime(),l)),d=new Date(Math.min(a.getTime(),s)),h=o.getDate(),g=d.getDate(),m=i+(h-1),v=i+(g-1),f=r.getMonth()===t&&r.getFullYear()===n,p=a.getMonth()===t&&a.getFullYear()===n;let y=0;for(;;){let e=!1;u[y]||(u[y]=[]);for(let t=m;t<=v;t++)if(u[y][t]){e=!0;break}if(!e){for(let e=m;e<=v;e++)u[y][e]=!0;break}y++}c.push({id:`${e.id}_month_${t}`,event:e,startCellIndex:m,endCellIndex:v,isFirstSegment:f,isLastSegment:p,visualRowIndex:y,monthIndex:t})});const h=c.length>0?Math.max(...c.map(e=>e.visualRowIndex)):-1;return{segments:c,maxVisualRow:h}}const Ko=({app:t,calendarRef:n,customDetailPanelContent:r,customEventDetailDialog:a,config:o,selectedEventId:i,onEventSelect:l,detailPanelEventId:s,onDetailPanelToggle:d})=>{var c,f;const{t:p,locale:y,getWeekDaysLabels:b}=vn(),w=t.getCurrentDate(),D=w.getFullYear(),x=t.getEvents(),E=new Date;E.setHours(0,0,0,0);const C=null!==(c=null==o?void 0:o.startOfWeek)&&void 0!==c?c:1,k=g(null),T=g(null),N=g(null),[S,M]=u(0),[H,A]=u(0),[O,R]=u(null),[P,L]=u(null),$=void 0===i?O:i,j=void 0===s?P:s,Y=e=>{l?l(e):R(e)},F=e=>{d?d(e):L(e)},[z,_]=u(null),[W,U]=u(null);h(()=>{const e=e=>{const t=e.target,n=t.closest("[data-event-id]"),r=t.closest("[data-event-detail-panel]"),a=t.closest("[data-event-detail-dialog]"),o=t.closest("[data-range-picker-popup]"),i=t.closest("[data-calendar-picker-dropdown]");n||r||a||o||i||(Y(null),F(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const Z=v(()=>{let e=0;for(let t=0;t<12;t++){const n=new Date(D,t,1),r=new Date(D,t+1,0).getDate(),a=(n.getDay()-C+7)%7+r;a>e&&(e=a)}return e},[D,C]),{handleMoveStart:V,handleResizeStart:G,handleCreateStart:K,dragState:q,isDragging:X}=Mo(t,{calendarRef:n,viewType:I.YEAR,onEventsUpdate:(e,n,r)=>{const a=e(x).filter(e=>{const t=x.find(t=>t.id===e.id);return t&&Ze(t,e)});a.length>0&&t.applyEventsChanges({update:a.map(e=>({id:e.id,updates:e}))},n,r)},currentWeekStart:new Date,events:x,onEventCreate:e=>{t.addEvent(e)},onEventEdit:e=>{_(e.id)}}),J=null!==(f=null==o?void 0:o.showTimedEventsInYearView)&&void 0!==f&&f,Q=m((n,r)=>{if(J)null==K||K(n,r);else{const n=e.PlainDate.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate()}),a={id:`event-${Date.now()}`,title:p("newEvent")||"New Event",start:n,end:n,allDay:!0};t.addEvent(a),_(a.id)}},[J,K,t]),ee=v(()=>{const e=b(y,"short",C).map(e=>{if(y.startsWith("zh"))return e.at(-1);const t=e.slice(0,2);return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}),t=[];for(let n=0;n<Z;n++)t.push(e[n%7]);return t},[y,b,Z,C]),te=v(()=>{const e=new Date(D,0,1),t=new Date(D,11,31,23,59,59);return x.filter(n=>{if(!n.start)return!1;if(!J&&!n.allDay)return!1;const r=B(n.start),a=n.end?B(n.end):r;return r<=t&&a>=e})},[x,D,J]),ne=v(()=>{const e=[];for(let t=0;t<12;t++){const n=new Date(D,t,1),r=new Date(D,t+1,0).getDate(),a=(n.getDay()-C+7)%7,o=[];for(let e=0;e<a;e++)o.push(null);for(let e=1;e<=r;e++)o.push(new Date(D,t,e));for(;o.length<Z;)o.push(null);const i=n.toLocaleDateString(y,{month:"short"}),l=i.charAt(0).toUpperCase()+i.slice(1).toLowerCase(),{segments:s,maxVisualRow:d}=Go(te,t,D,C),c=d+1,u=Math.max(60,20+18*c);e.push({monthIndex:t,monthName:l,days:o,eventSegments:s,minHeight:u})}return e},[D,y,Z,te,C]),re=m(e=>{const t=e.currentTarget;k.current&&(k.current.scrollLeft=t.scrollLeft),T.current&&(T.current.scrollTop=t.scrollTop)},[]);h(()=>{const e=()=>{if(N.current){const e=N.current,t=e.offsetHeight-e.clientHeight,n=e.offsetWidth-e.clientWidth;A(e=>e===t?e:t),M(e=>e===n?e:n)}},t=N.current;if(!t)return;e();const n=new ResizeObserver(()=>{e()});return n.observe(t),()=>{n.disconnect()}},[ne]);return et("div",{className:"h-full overflow-hidden bg-white select-none dark:bg-gray-900",style:{display:"grid",gridTemplateColumns:"3rem 1fr",gridTemplateRows:"auto auto 1fr"},onContextMenu:e=>e.preventDefault(),children:[et("div",{className:"col-span-2",children:et(Fa,{calendar:t,viewType:I.YEAR,currentDate:w,customTitle:y.startsWith("zh")||y.startsWith("ja")?`${D}年`:`${D}`,onPrevious:()=>{const e=new Date(w);e.setFullYear(e.getFullYear()-1),t.setCurrentDate(e)},onNext:()=>{const e=new Date(w);e.setFullYear(e.getFullYear()+1),t.setCurrentDate(e)},onToday:()=>{t.goToToday()}})}),et("div",{className:"z-30 border-r border-b border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900"}),et("div",{ref:k,className:"overflow-hidden border-b border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900",children:et("div",{className:"flex",style:{minWidth:`calc(1352px + ${S}px)`},children:[et("div",{className:"grid flex-1",style:{gridTemplateColumns:`repeat(${Z}, minmax(0, 1fr))`,minWidth:"1352px"},children:ee.map((e,t)=>{const n=(t+C)%7;return et("div",{className:"border-r border-gray-200 py-2 text-center text-[10px] font-bold tracking-wider text-gray-500 dark:border-gray-700 dark:text-gray-400 "+(0===n||6===n?"df-year-view-weekend-header":""),children:e},`label-${t}`)})}),S>0&&et("div",{className:"shrink-0 bg-gray-50 dark:bg-gray-900",style:{width:`${S}px`}})]})}),et("div",{ref:T,className:"overflow-hidden border-r border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-900",children:et("div",{className:"flex min-h-full flex-col",children:[ne.map(e=>et("div",{className:"flex shrink-0 grow items-center justify-center border-b border-gray-200 text-[10px] font-bold text-gray-500 dark:border-gray-700 dark:text-gray-400",style:{minHeight:`${e.minHeight}px`},children:e.monthName},e.monthIndex)),H>0&&et("div",{className:"shrink-0 bg-white dark:bg-gray-900",style:{height:`${H}px`}})]})}),et("div",{ref:N,className:`overflow-auto ${kn}`,onScroll:re,children:et("div",{className:"flex min-h-full flex-col",style:{minWidth:"1352px"},children:ne.map(e=>et("div",{className:"relative shrink-0 grow",style:{minHeight:`${e.minHeight}px`},children:[et("div",{className:"absolute inset-0 z-0 grid",style:{gridTemplateColumns:`repeat(${Z}, minmax(0, 1fr))`},children:e.days.map((n,r)=>{const a=(r+C)%7,o=0===a||6===a;if(!n)return et("div",{className:"border-r border-b border-gray-200 bg-gray-50/80 dark:border-gray-700 dark:bg-gray-800/40 "+(o?"df-year-view-weekend-cell":"")},`empty-${e.monthIndex}-${r}`);const i=(e=>e.getTime()===E.getTime())(n);return et("div",{"data-date":`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}-${String(n.getDate()).padStart(2,"0")}`,className:`relative flex cursor-pointer items-start justify-end border-r border-b border-gray-200 p-0.5 transition-colors hover:bg-blue-100 dark:border-gray-700 dark:hover:bg-primary/20 ${o?"df-year-view-weekend-cell bg-blue-50 dark:bg-blue-900/30":""} `,onClick:()=>t.selectDate(n),onDblClick:e=>Q(e,n),onContextMenu:e=>((e,t)=>{e.preventDefault(),e.stopPropagation(),U({x:e.clientX,y:e.clientY,date:t})})(e,n),children:et("span",{className:`flex h-5 w-5 items-center justify-center rounded-full text-[10px] font-medium ${i?"bg-primary font-bold text-primary-foreground shadow-sm":"text-gray-700 dark:text-gray-300"} `,children:n.getDate()})},n.getTime())})}),e.eventSegments.length>0&&et("div",{className:"pointer-events-none absolute inset-0 z-20",style:{top:20},children:et("div",{className:"relative h-full w-full",children:e.eventSegments.map(e=>et("div",{className:"pointer-events-auto",children:et(ja,{event:e.event,viewType:I.YEAR,yearSegment:e,columnsPerRow:Z,isBeingDragged:X&&q.eventId===e.event.id,selectedEventId:$,onMoveStart:V,onResizeStart:G,onEventSelect:Y,onDetailPanelToggle:F,newlyCreatedEventId:z,onDetailPanelOpen:()=>_(null),calendarRef:n,app:t,detailPanelEventId:j,customDetailPanelContent:r,customEventDetailDialog:a,firstHour:0,hourHeight:0,onEventUpdate:e=>t.updateEvent(e.id,e),onEventDelete:e=>t.deleteEvent(e)})},e.id))})})]},e.monthIndex))})}),W&&et(Da,{x:W.x,y:W.y,date:W.date,viewType:I.YEAR,onClose:()=>U(null),app:t,onCreateEvent:()=>{const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:W.x,clientY:W.y};Q(e,W.date)}})]})},qo=e=>{var t;return et("fixed-week"===((null===(t=e.config)||void 0===t?void 0:t.mode)||"year-canvas")?Ko:Vo,Object.assign({},e))},Xo={startOfWeek:1},Jo=(e={})=>{const t=Object.assign(Object.assign({},Xo),e),n=e=>a(Ho,{viewType:I.YEAR,originalComponent:qo,app:e.app,config:t,className:"year-view-factory",customDetailPanelContent:e.customDetailPanelContent,customEventDetailDialog:e.customEventDetailDialog,calendarRef:e.calendarRef,meta:e.meta,selectedEventId:e.selectedEventId,detailPanelEventId:e.detailPanelEventId,onEventSelect:e.onEventSelect,onDetailPanelToggle:e.onDetailPanelToggle});return n.displayName="YearViewAdapter",{type:I.YEAR,component:n,config:t}};function Qo(e){return[Oo(null==e?void 0:e.day),Fo(null==e?void 0:e.week),Uo(null==e?void 0:e.month)]}const ei={enableAutoRecalculate:!0,enableValidation:!0,defaultEvents:[],maxEventsPerDay:50};function ti(e){const t=e.getDay(),n=e.getDate()-t+(0===t?-6:1),r=new Date(e);return r.setDate(n),r.setHours(0,0,0,0),r}function ni(e={}){const t=Object.assign(Object.assign({},ei),e);let n;const r={getAll:()=>n.getAllEvents(),getById:e=>n.getAllEvents().find(t=>t.id===e),add:e=>{if(t.enableValidation){const t=r.validateEvent(e);if(t.length>0)throw new Error(`Event validation failed: ${t.join(", ")}`)}if(t.maxEventsPerDay&&void 0!==e.day){if(r.getByDay(e.day,n.getCurrentDate()).length>=t.maxEventsPerDay)throw new Error(`Maximum events per day (${t.maxEventsPerDay}) exceeded`)}if(n.addEvent(e),t.enableAutoRecalculate){const e=ti(n.getCurrentDate()),t=je(n.getAllEvents(),e);n.state.events=t}},update:(e,a)=>{const o=r.getById(e);if(!o)throw new Error(`Event with id ${e} not found`);const i=Object.assign(Object.assign({},o),a);if(t.enableValidation){const e=r.validateEvent(i);if(e.length>0)throw new Error(`Event validation failed: ${e.join(", ")}`)}if(n.updateEvent(e,a),t.enableAutoRecalculate){const e=ti(n.getCurrentDate()),t=je(n.getAllEvents(),e);n.state.events=t}return n.getAllEvents().find(t=>t.id===e)},delete:e=>{n.deleteEvent(e)},getByDate:e=>n.getAllEvents().filter(t=>{const n=B(t.start);n.setHours(0,0,0,0);const r=new Date(e);return r.setHours(0,0,0,0),n.getTime()===r.getTime()}),getByDateRange:(e,t)=>n.getAllEvents().filter(n=>{const r=B(n.start),a=B(n.end);return r>=e&&r<=t||a>=e&&a<=t||r<=e&&a>=t}),getByDay:(e,t)=>n.getAllEvents().filter(t=>t.day===e),getAllDayEvents:(e,t)=>t.filter(t=>t.day===e&&t.allDay),recalculateEventDays:(e,t)=>je(e,t),validateEvent:e=>{const t=[];return e.title&&""!==e.title.trim()||t.push("Event title is required"),e.start||t.push("Event start time is required"),e.end||t.push("Event end time is required"),e.start&&e.end&&!e.allDay&&e.start>=e.end&&t.push("Start time must be before end time"),e.id&&"string"!=typeof e.id&&t.push("Event ID must be a string"),t},filterEvents:(e,t)=>e.filter(t)};return{name:"events",config:t,install:e=>{n=e},api:r}}export{Rr as BlossomColorPicker,Je as CalendarApp,ce as CalendarRegistry,ua as CalendarRenderer,cr as Check,ar as ChevronRight,ur as ChevronsUpDown,yn as ContentSlot,ha as ContextMenu,wa as ContextMenuColorPicker,ga as ContextMenuItem,va as ContextMenuLabel,ma as ContextMenuSeparator,$r as CreateCalendarDialog,ca as CustomRenderingStore,Pr as DefaultColorPicker,H as LAYOUT_CONFIG,T as LOCALES,mn as LocaleContext,Sr as LocaleProvider,qr as MiniCalendar,wr as PanelRightClose,Dr as PanelRightOpen,sr as Plus,ye as TIME_STEP,R as TimeZone,A as VIRTUAL_MONTH_SCROLL_CONFIG,I as ViewType,O as WeekDataCache,Q as addDays,Dt as buildParseRegExp,Le as calculateDayIndex,_n as calendarPickerDropdown,xn as cancelButton,Cr as capitalize,Gt as clipboardStore,Ht as conditionalTheme,_t as convertDateEvent,Wt as convertDateEventWithTimeZone,ln as convertToDayFlowEvent,Ft as createAllDayEvent,re as createDateWithHour,Oo as createDayView,Lt as createEvent,Pe as createEventWithDate,We as createEventWithPlainDateTime,ze as createEventWithRealDate,Ue as createEventWithZonedDateTime,jt as createEvents,ni as createEventsPlugin,Uo as createMonthView,Qo as createStandardViews,Z as createTemporalWithHour,zt as createTimedEvent,$t as createTimezoneEvent,Yt as createTimezoneEvents,Fo as createWeekView,Jo as createYearView,st as dateToPlainDate,dt as dateToPlainDateTime,ct as dateToZonedDateTime,X as daysBetween,J as daysDifference,cn as downloadICS,k as en,Qt as escapeICSValue,ne as extractHourFromDate,gt as extractHourFromTemporal,an as extractVEvents,tn as foldLine,rt as formatDate,tt as formatDateConsistent,Jt as formatDateToICSTimestamp,De as formatEventTimeRange,Xt as formatICSDate,nt as formatMonthYear,nn as formatProperty,kt as formatTemporal,be as formatTime,ke as generateDayData,dn as generateICS,Ee as generateSecondaryTimeSlots,Ge as generateUniKey,rn as generateVEvent,Ne as generateWeekData,Me as generateWeekRange,Se as generateWeeksData,He as getAllDayEventsForDay,ge as getCalendarColorsForHex,F as getCurrentWeekDates,Ae as getDateByDayIndex,Ut as getDateObj,Ye as getDayIndexByDate,oe as getEndOfDay,q as getEndOfTemporal,me as getEventBgColor,we as getEventEndHour,ve as getEventTextColor,Ie as getEventsForDay,Fe as getEventsForWeek,Er as getIntlLabel,pe as getLineColor,Tr as getMonthLabels,Te as getMonthYearOfWeek,vt as getPlainDate,Zt as getSearchHeaderInfo,fe as getSelectedBgColor,ae as getStartOfDay,K as getStartOfTemporal,Ve as getTestEvents,Ce as getTimezoneDisplayLabel,kr as getWeekDaysLabels,ie as getWeekNumber,Y as getWeekRange,Et as getZoneId,Vt as groupSearchResults,Ze as hasEventChanged,un as importICSFile,_ as isDate,Ke as isDeepEqual,Be as isEventDeepEqual,$e as isEventInWeek,se as isMultiDayEvent,G as isMultiDayTemporalEvent,at as isPlainDate,ot as isPlainDateTime,le as isSameDay,V as isSamePlainDate,ft as isSameTemporal,M as isValidLocale,it as isZonedDateTime,At as mergeClasses,bt as mergeFormatTemplate,$ as monthNames,Tt as normalizeCssWidth,Bt as normalizeDate,S as normalizeLocale,Ct as normalizeToZoned,ee as now,yt as pad,Kt as pad2,sn as parseICS,qt as parseICSDate,xt as parseTemporalString,on as parseVEventLines,ut as plainDateTimeToDate,ht as plainDateToDate,je as recalculateEventDays,No as registerDragImplementation,N as registerLocale,oa as registerSidebarImplementation,Ot as resolveAppliedTheme,xe as roundToTimeStep,St as scrollbarTakesSpace,mt as setHourInTemporal,j as shortMonthNames,Bn as sidebarContainer,Zn as sidebarHeader,Gn as sidebarHeaderTitle,Vn as sidebarHeaderToggle,Nr as t,lt as temporalToDate,It as themeClasses,Mt as themeCn,te as today,en as unescapeICSValue,Oe as updateEventDateAndDay,_e as updateEventWithRealDate,Mo as useDragForView,vn as useLocale,la as useSidebarBridge,P as weekDays,L as weekDaysFullName,U as zonedDateTimeToDate};
|