@dayflow/core 3.1.2 → 3.2.1
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 +43 -18
- package/dist/index.d.ts +664 -443
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/styles.css +168 -18
- package/package.json +43 -42
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e,t=require("temporal-polyfill"),n=require("preact"),r=require("preact/hooks"),a=require("preact/compat"),o=require("tslib"),l=require("@dayflow/blossom-color-picker");exports.ViewType=void 0,(e=exports.ViewType||(exports.ViewType={})).DAY="day",e.WEEK="week",e.MONTH="month",e.YEAR="year";const s={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 i{constructor(e=s.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 d=[{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 c{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)}):d.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 u=new c;function h(){return u}function g(e){const t=d.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 m{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=m.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 p=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)}},f={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"}},v={en:f};function y(e){const t=e.split("-")[0].toLowerCase();return t in v?t:"en"}function b(e){try{return new Intl.DateTimeFormat(e),!0}catch(e){return!1}}function w(e){var n;return!(!e||"object"!=typeof e)&&(!(e instanceof Date)&&(e instanceof t.Temporal.PlainDate||("PlainDate"===(null===(n=null==e?void 0:e.constructor)||void 0===n?void 0:n.name)||!("hour"in e)&&!("timeZone"in e)&&"year"in e&&"month"in e&&"day"in e)))}function x(e,n=t.Temporal.Now.timeZoneId()){return t.Temporal.Instant.fromEpochMilliseconds(e.getTime()).toZonedDateTimeISO(n)}function D(e){return"number"==typeof e.epochMilliseconds?new Date(e.epochMilliseconds):new Date(e.year,e.month-1,e.day,e.hour,e.minute)}function E(e,n){if(e instanceof Date)return e;if(w(e))return function(e,n=t.Temporal.Now.timeZoneId()){if("function"==typeof e.toZonedDateTime)try{return D(e.toZonedDateTime({timeZone:n,plainTime:t.Temporal.PlainTime.from({hour:0,minute:0})}))}catch(e){}return new Date(e.year,e.month-1,e.day)}(e,n);if(e&&"object"==typeof e&&"hour"in e&&!("timeZone"in e)){const t=e;return new Date(t.year,t.month-1,t.day,t.hour,t.minute,t.second||0,t.millisecond||0)}return e&&"object"==typeof e&&"year"in e?D(e):new Date(e)}function C(e,n){const r=Math.floor(n),a=Math.round(60*(n-r));return w(e)?t.Temporal.PlainDateTime.from({year:e.year,month:e.month,day:e.day,hour:r,minute:a}):"function"==typeof e.with?e.with({hour:r,minute:a,second:0,millisecond:0}):t.Temporal.PlainDateTime.from({year:e.year,month:e.month,day:e.day,hour:r,minute:a})}function k(e,n){if(e instanceof Date&&n instanceof Date)return e.toDateString()===n.toDateString();const r=e=>{return e instanceof Date?(n=e,t.Temporal.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()})):w(e)?e:"function"==typeof e.toPlainDate?e.toPlainDate():t.Temporal.PlainDate.from({year:e.year,month:e.month,day:e.day});var n},a=r(e),o=r(n);return 0===t.Temporal.PlainDate.compare(a,o)}function T(e,n=t.Temporal.Now.timeZoneId()){if("function"==typeof e.toZonedDateTime){return(w(e)?e:e.toPlainDate()).toZonedDateTime({timeZone:n,plainTime:t.Temporal.PlainTime.from({hour:0,minute:0})})}return(w(e)?e:t.Temporal.PlainDate.from({year:e.year,month:e.month,day:e.day})).toZonedDateTime({timeZone:n,plainTime:t.Temporal.PlainTime.from({hour:0,minute:0})})}function S(e,n=t.Temporal.Now.timeZoneId()){if("function"==typeof e.toZonedDateTime){return(w(e)?e:e.toPlainDate()).toZonedDateTime({timeZone:n,plainTime:t.Temporal.PlainTime.from({hour:23,minute:59,second:59,millisecond:999})})}return(w(e)?e:t.Temporal.PlainDate.from({year:e.year,month:e.month,day:e.day})).toZonedDateTime({timeZone:n,plainTime:t.Temporal.PlainTime.from({hour:23,minute:59,second:59,millisecond:999})})}function M(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)}const N=e=>{if(e instanceof Date){return e.getHours()+e.getMinutes()/60}return(t=e)instanceof Date?t.getHours()+t.getMinutes()/60:w(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},I=(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 C(e,t)},R=(e,n)=>{if(e instanceof Date&&n instanceof Date)return e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate();return k(e instanceof Date?t.Temporal.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()}):w(e)?e:e.toPlainDate(),n instanceof Date?t.Temporal.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()}):w(n)?n:n.toPlainDate())},H=(e,t)=>(t||h()).resolveColors(e).eventColor,O=(e,t)=>(t||h()).resolveColors(e).textColor,P=(e,t)=>(t||h()).resolveColors(e).eventSelectedColor,L=(e,t)=>(t||h()).resolveColors(e).lineColor,A=(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")}`},$=e=>{const t=N(e.start),n=j(e);return`${A(t)} - ${A(n)}`},j=e=>{if(!e.end)return 0;const t=N(e.end);if(e.allDay||!e.start)return t;const n=E(e.start),r=E(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},Y=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],F=["January","February","March","April","May","June","July","August","September","October","November","December"],z=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],V=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}},_=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:F[r],shortMonthName:z[r],isToday:o.getDate()===n&&o.getMonth()===r&&o.getFullYear()===a}},W=e=>{const t=[],n=new Date(e);for(let e=0;e<7;e++){const e=new Date(n);t.push(_(e)),n.setDate(n.getDate()+1)}return{days:t,startDate:new Date(e),monthYear:Z(t)}},Z=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:F[a],monthIndex:a,year:o}};function U(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 s=new Date(a);s.setDate(s.getDate()-7*r);for(let e=0;e<t;e++){const t=new Date(s);t.setDate(t.getDate()+7*e),n.push(W(t))}return n}const B=(e,t)=>t.filter(t=>t.day===e&&!t.allDay),q=(e,t)=>{const n=new Date(e);return n.setDate(e.getDate()+t),n},G=(e,n)=>n?t.Temporal.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()}):t.Temporal.ZonedDateTime.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),millisecond:e.getMilliseconds(),timeZone:t.Temporal.Now.timeZoneId()}),K=(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)},X=(e,t)=>e.map(e=>{const n=E(e.start),r=K(n,t);return Object.assign(Object.assign({},e),{day:r})}),J=(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 Q(){return Date.now().toString(36)+Math.random().toString(36).substring(2,8)}function ee(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)||!ee(e[a],t[a]))return!1;return!0}class te{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 ne=n.createContext(null);var re=0;function ae(e,t,r,a,o,l){t||(t={});var s,i,d=t;if("ref"in d)for(i in d={},t)"ref"==i?s=t[i]:d[i]=t[i];var c={type:e,props:d,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--re,__i:-1,__u:0,__source:o,__self:l};if("function"==typeof e&&(s=e.defaultProps))for(i in s)void 0===d[i]&&(d[i]=s[i]);return n.options.vnode&&n.options.vnode(c),c}const oe=({className:e,width:t=24,height:n=24})=>ae("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:ae("path",{d:"m15 18-6-6 6-6"})}),le=({className:e,width:t=24,height:n=24})=>ae("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:ae("path",{d:"m9 18 6-6-6-6"})}),se=({className:e,width:t=24,height:n=24})=>ae("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:[ae("path",{d:"m11 17-5-5 5-5"}),ae("path",{d:"m18 17-5-5 5-5"})]}),ie=({className:e,width:t=24,height:n=24})=>ae("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:[ae("path",{d:"m6 17 5-5-5-5"}),ae("path",{d:"m13 17 5-5-5-5"})]}),de=({className:e,width:t=24,height:n=24})=>ae("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:ae("path",{d:"m6 9 6 6 6-6"})}),ce=({className:e,width:t=24,height:n=24})=>ae("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:[ae("path",{d:"M5 12h14"}),ae("path",{d:"M12 5v14"})]}),ue=({className:e,width:t=24,height:n=24})=>ae("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:[ae("circle",{cx:"11",cy:"11",r:"8"}),ae("path",{d:"m21 21-4.3-4.3"})]}),he=({className:e,width:t=24,height:n=24})=>ae("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:ae("path",{d:"M20 6 9 17l-5-5"})}),ge=({className:e,width:t=24,height:n=24})=>ae("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:[ae("path",{d:"m7 15 5 5 5-5"}),ae("path",{d:"m7 9 5-5 5 5"})]}),me=({className:e,width:t=24,height:n=24})=>ae("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:[ae("path",{d:"M18 6 6 18"}),ae("path",{d:"m6 6 12 12"})]}),pe=({className:e,width:t=24,height:n=24})=>ae("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:[ae("path",{d:"M8 2v4"}),ae("path",{d:"M16 2v4"}),ae("rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}),ae("path",{d:"M3 10h18"}),ae("path",{d:"M8 14h.01"}),ae("path",{d:"M12 14h.01"}),ae("path",{d:"M16 14h.01"}),ae("path",{d:"M8 18h.01"}),ae("path",{d:"M12 18h.01"}),ae("path",{d:"M16 18h.01"})]}),fe=({className:e,width:t=24,height:n=24})=>ae("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:[ae("path",{d:"M18 8L22 12L18 16"}),ae("path",{d:"M2 12H22"})]}),ve=({className:e,width:t=24,height:n=24})=>ae("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:ae("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),ye=({className:e,width:t=24,height:n=24})=>ae("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:[ae("rect",{width:"18",height:"14",x:"3",y:"8",rx:"2"}),ae("path",{d:"M12 5a3 3 0 1 0-3 3"}),ae("path",{d:"M12 5a3 3 0 1 1 3 3"}),ae("path",{d:"M3 12h18"}),ae("path",{d:"M12 22V8"})]}),be=({className:e,width:t=24,height:n=24})=>ae("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:ae("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"})}),we=({className:e,width:t=24,height:n=24})=>ae("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:[ae("path",{d:"M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z"}),ae("circle",{cx:"12",cy:"10",r:"3"})]}),xe=({className:e,width:t=24,height:n=24})=>ae("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:ae("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"})}),De=({className:e,width:t=24,height:n=24})=>ae("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:[ae("path",{d:"m12 19-7-7 7-7"}),ae("path",{d:"M19 12H5"})]}),Ee="df-month-view h-full flex flex-col bg-white dark:bg-gray-900 select-none",Ce="p-2 flex justify-between",ke="text-2xl font-bold text-gray-900 dark:text-gray-100",Te="df-date-number inline-flex items-center justify-center h-6 w-6 rounded-full text-sm mt-1 select-none",Se="flex-1 overflow-auto will-change-scroll",Me="scrollbar-hide",Ne="df-time-slot relative h-[4.5rem] flex",Ie="df-time-label absolute top-0 -translate-y-1/2 right-2 text-[12px] text-gray-500 dark:text-gray-400 select-none",Re="df-time-grid-row h-[4.5rem] border-t border-gray-200 dark:border-gray-700 flex",He="df-current-time-line absolute left-0 top-0 w-full flex pointer-events-none",Oe="df-current-time-label ml-2 text-primary-foreground text-xs font-bold px-1.5 bg-primary rounded-sm",Pe="df-all-day-row flex items-center border-b border-gray-200 dark:border-gray-700 sticky",Le="rounded-xl my-0.5",Ae="rounded-sm",$e="df-event-title font-medium text-xs truncate pr-1",je="df-month-event-color-bar inline-block w-0.75 h-3 mr-1 shrink-0 rounded-full",Ye="h-3 w-3 mr-1",Fe="resize-handle absolute right-0 top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20",ze="bg-primary rounded-full text-primary-foreground",Ve="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",_e="h-4 w-4 transition-transform group-hover:scale-110",We="df-event-detail-panel fixed bg-white dark:bg-gray-800 shadow-lg border border-gray-200 dark:border-gray-700 rounded-lg",Ze="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",Ue="h-3 border-t border-gray-200 dark:border-gray-700 relative",Be="absolute top-0 -translate-y-1/2 text-[12px] text-gray-500 dark:text-gray-400",qe="flex h-7 w-7 items-center justify-center rounded hover:bg-gray-100 dark:hover:bg-slate-800 transition-colors",Ge="text-gray-500 dark:text-gray-400",Ke="text-gray-600 dark:text-gray-300",Xe="text-xs",Je="text-sm",Qe="flex flex-col",et="mr-1",tt=(...e)=>e.filter(Boolean).join(" "),nt=({options:e,value:t,onChange:n,registry:o,variant:l="desktop",disabled:s=!1})=>{const[i,d]=r.useState(!1),[c,u]=r.useState({}),g=r.useRef(null),m=r.useRef(null),p=()=>{if(m.current){const e=m.current.getBoundingClientRect(),t="mobile"===l,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`,u(n)}};r.useEffect(()=>{const e=e=>{!g.current||g.current.contains(e.target)||e.target.closest("[data-calendar-picker-dropdown]")||d(!1)};return i&&(p(),window.addEventListener("mousedown",e),window.addEventListener("scroll",p,!0),window.addEventListener("resize",p)),()=>{window.removeEventListener("mousedown",e),window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p)}},[i]);const f=e=>(o||h()).resolveColors(e).lineColor,v=(e,t)=>{e.stopPropagation(),n(t),d(!1)},y=e.find(e=>e.value===t),b=()=>i&&"undefined"!=typeof window?"mobile"===l?a.createPortal(ae("div",{"data-calendar-picker-dropdown":"true",style:c,className:Ze,children:e.map(e=>ae("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=>v(t,e.value),children:[ae("div",{className:"flex items-center flex-1 min-w-0 mr-3",children:[ae("div",{className:"w-5 flex justify-center mr-2",children:e.value===t&&ae(he,{className:"w-4 h-4 text-primary"})}),ae("span",{className:"text-sm text-gray-700 dark:text-gray-200 truncate",children:e.label})]}),ae("span",{className:"w-3 h-3 rounded-full shrink-0",style:{backgroundColor:f(e.value)}})]},e.value))}),document.body):a.createPortal(ae("ul",{"data-calendar-picker-dropdown":"true",style:c,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=>ae("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=>v(t,e.value),children:[t===e.value?ae("span",{className:"mr-2 text-sm text-primary",children:ae(he,{width:12,height:12})}):ae("div",{className:"mr-2 text-sm w-3 h-3",children:" "}),ae("span",{className:"w-3 h-3 mr-2 rounded-sm shrink-0",style:{backgroundColor:f(e.value)}}),ae("span",{className:"text-sm whitespace-nowrap text-gray-700 dark:text-gray-200",children:e.label})]},e.value))}),document.body):null;return ae("div","mobile"===l?{className:"relative inline-block",ref:g,children:[ae("button",{ref:m,disabled:s,onClick:e=>{e.stopPropagation(),s||d(!i)},className:"flex items-center space-x-2 bg-gray-100 dark:bg-gray-700 rounded-md px-3 py-1.5 transition-colors "+(s?"opacity-50 cursor-default":""),children:[ae("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:f(t)}}),ae("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-200",children:(null==y?void 0:y.label)||t}),ae(ge,{className:"w-4 h-4 text-gray-400"})]}),b()]}:{className:"relative inline-block",ref:g,children:[ae("button",{ref:m,type:"button",onClick:e=>{e.stopPropagation(),d(!i)},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:[ae("span",{className:"w-4 h-4 rounded-sm shrink-0",style:{backgroundColor:f(t)}}),ae(ge,{className:"w-4 h-4 text-gray-600 dark:text-gray-300"})]}),b()]})};function rt(e){return null!==e&&"object"==typeof e&&!("hour"in e)&&"year"in e&&"month"in e&&"day"in e&&!(e instanceof Date)}function at(e){return null!==e&&"object"==typeof e&&"hour"in e&&!("timeZone"in e)&&"year"in e&&!(e instanceof Date)}function ot(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(rt(e))return new Date(e.year,e.month-1,e.day);if(at(e))return new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second||0,e.millisecond||0);if(ot(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(e){return t.Temporal.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()})}function it(e){return t.Temporal.PlainDateTime.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),millisecond:e.getMilliseconds()})}function dt(e,n=t.Temporal.Now.timeZoneId()){return t.Temporal.ZonedDateTime.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),millisecond:e.getMilliseconds(),timeZone:n})}function ct(e){return e instanceof Date?st(e):rt(e)?e:(at(e),e.toPlainDate())}const ut=/(YYYY|YY|MM|DD|HH|mm)/g,ht=e=>e.toString().padStart(2,"0"),gt=(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`)},mt=e=>e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),pt=e=>{let t,n=0,r="^";for(;null!==(t=ut.exec(e));){r+=mt(e.slice(n,t.index));const a=t[0];r+=`(?<${a}>\\d{${"YYYY"===a?4:2}})`,n=t.index+a.length}return r+=mt(e.slice(n))+"$",new RegExp(r)},ft=(e,n,r,a)=>{const o=e.trim();if(!o)return null;const l=o.match(n),s=null==l?void 0:l.groups;if(!s)return null;const i=s.YYYY?Number(s.YYYY):s.YY?Number(s.YY)+2e3:r.year,d=s.MM?Number(s.MM):r.month,c=s.DD?Number(s.DD):r.day,u=s.HH?Number(s.HH):r.hour,h=s.mm?Number(s.mm):r.minute;try{return t.Temporal.ZonedDateTime.from({timeZone:a,year:i,month:d,day:c,hour:u,minute:h,second:r.second,millisecond:r.millisecond,microsecond:r.microsecond,nanosecond:r.nanosecond})}catch(e){return null}},vt=e=>{const n=e;if(n.timeZoneId&&"string"==typeof n.timeZoneId)return n.timeZoneId;if("timeZoneId"in e&&"string"==typeof e.timeZoneId)return e.timeZoneId;const r=e.timeZone;return r&&"string"==typeof r.id?r.id:"string"==typeof n.timeZone?n.timeZone:t.Temporal.Now.timeZoneId()},yt=(e,n,r)=>{var a,o,l,s,i,d,c,u,h,g,m,p,f,v,y,b,w,x,D,E,C,k,T,S;if(!e){const e=null!=n?n:r?vt(r):t.Temporal.Now.timeZoneId();return null!=r?r:t.Temporal.Now.zonedDateTimeISO(e)}if(rt(e)){const r=null!=n?n:t.Temporal.Now.timeZoneId(),a=`${e.year}-${ht(e.month)}-${ht(e.day)}T00:00:00[${r}]`;return t.Temporal.ZonedDateTime.from(a)}if("hour"in e&&!("timeZone"in e)){const r=null!=n?n:t.Temporal.Now.timeZoneId();if("function"==typeof e.toZonedDateTime)try{return e.toZonedDateTime(r)}catch(e){}return t.Temporal.ZonedDateTime.from({timeZone:r,year:e.year,month:e.month,day:e.day,hour:e.hour,minute:e.minute,second:null!==(a=e.second)&&void 0!==a?a:0,millisecond:null!==(o=e.millisecond)&&void 0!==o?o:0,microsecond:null!==(l=e.microsecond)&&void 0!==l?l:0,nanosecond:null!==(s=e.nanosecond)&&void 0!==s?s:0})}try{return t.Temporal.ZonedDateTime.from(e)}catch(a){const o=e,l=null!==(h=null!==(u=null!==(c=null!==(d="string"==typeof(null==o?void 0:o.timeZone)?o.timeZone:null===(i=null==o?void 0:o.timeZone)||void 0===i?void 0:i.id)&&void 0!==d?d:null==o?void 0:o.timeZoneId)&&void 0!==c?c:n)&&void 0!==u?u:r?vt(r):void 0)&&void 0!==h?h:t.Temporal.Now.timeZoneId();if("function"==typeof(null==o?void 0:o.toZonedDateTime))try{return o.toZonedDateTime({timeZone:l})}catch(e){}const s=null!=r?r:t.Temporal.Now.zonedDateTimeISO(l);return t.Temporal.ZonedDateTime.from({timeZone:l,year:null!==(g=null==o?void 0:o.year)&&void 0!==g?g:s.year,month:null!==(m=null==o?void 0:o.month)&&void 0!==m?m:s.month,day:null!==(p=null==o?void 0:o.day)&&void 0!==p?p:s.day,hour:null!==(v=null!==(f=null==o?void 0:o.hour)&&void 0!==f?f:null==r?void 0:r.hour)&&void 0!==v?v: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!==(x=null!==(w=null==o?void 0:o.second)&&void 0!==w?w:null==r?void 0:r.second)&&void 0!==x?x:0,millisecond:null!==(E=null!==(D=null==o?void 0:o.millisecond)&&void 0!==D?D: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!==(S=null!==(T=null==o?void 0:o.nanosecond)&&void 0!==T?T:null==r?void 0:r.nanosecond)&&void 0!==S?S:0})}},bt=(e,t,n)=>{const r=gt(t,n),a={YYYY:e.year.toString(),YY:ht(e.year%100),MM:ht(e.month),DD:ht(e.day),HH:ht(e.hour),mm:ht(e.minute)};return r.replace(ut,e=>{var t;return null!==(t=a[e])&&void 0!==t?t:e})};function wt(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 xt(e){return e.charAt(0).toUpperCase()+e.slice(1)}const Dt=(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},Et=(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 Ct(e,t="en-US"){var n;if(["today","day","week","month","year"].includes(e)){const n=wt(e,t);if(n)return xt(n)}const r=y(t),a=v[r],o=null===(n=null==a?void 0:a.messages)||void 0===n?void 0:n[e];if(o)return o;const l=v.en.messages;return(null==l?void 0:l[e])||e}const kt=n.createContext({locale:"en-US",t:e=>e,getWeekDaysLabels:()=>[],getMonthLabels:()=>[],isDefault:!0});function Tt(){return r.useContext(kt)}const St=({locale:e="en-US",messages:t,children:n})=>{const a=r.useMemo(()=>{if("string"==typeof e){return{code:b(e)?e:"en-US",messages:void 0}}return e&&"string"!=typeof e&&!b(e.code)?Object.assign(Object.assign({},e),{code:"en-US"}):e||{code:"en-US"}},[e]),o=r.useMemo(()=>{const e=a.code;return{locale:e,t:(n,r)=>{var o,l,s;let i=null!==(s=null!==(o=null==t?void 0:t[n])&&void 0!==o?o:null===(l=a.messages)||void 0===l?void 0:l[n])&&void 0!==s?s:Ct(n,e);return r&&Object.entries(r).forEach(([e,t])=>{i=i.replace(new RegExp(`{${e}}`,"g"),t)}),i},getWeekDaysLabels:Dt,getMonthLabels:Et,isDefault:!1}},[a,t]);return ae(kt.Provider,{value:o,children:n})},Mt=Array.from({length:24},(e,t)=>t),Nt=Array.from({length:60},(e,t)=>t),It=({visibleMonth:e,monthLabels:t,disabled:n,onMonthChange:r,onYearChange:a})=>ae("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:[ae("div",{className:"flex items-center gap-1",children:[ae("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:ae(se,{width:14,height:12})}),ae("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:ae(oe,{width:14,height:12})})]}),ae("div",{className:"text-sm font-semibold text-slate-700 dark:text-gray-300",children:[t[e.month-1]," ",e.year]}),ae("div",{className:"flex items-center gap-1",children:[ae("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:ae(le,{width:14,height:12})}),ae("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:ae(ie,{width:14,height:12})})]})]}),Rt=(e,n)=>t.Temporal.PlainDate.compare(e,n),Ht=({calendarDays:e,visibleMonth:t,startDate:r,endDate:a,weekDayLabels:o,disabled:l,onDaySelect:s})=>ae(n.Fragment,{children:[ae("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)=>ae("span",{children:e},t))}),ae("div",{className:"grid grid-cols-7 gap-1 px-1 ",children:e.map(e=>{const n=e.month!==t.month,o=0===Rt(e,r),i=0===Rt(e,a),d=Rt(e,r)>=0&&Rt(e,a)<=0;return ae("button",{type:"button",disabled:l,onClick:()=>s(e),className:`flex h-9 w-9 items-center justify-center rounded-md text-sm transition ${o||i?"bg-primary text-primary-foreground font-semibold":d?"bg-primary/10 text-primary":n?"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())})})]}),Ot=({focusedField:e,draftRange:t,disabled:n,onHourSelect:r,onMinuteSelect:a,timeListRefs:o})=>{const l=e,s=t["start"===l?0:1],i=s.minute,d=Nt.includes(i)?Nt:[...Nt,i].sort((e,t)=>e-t);return ae("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:[ae("div",{className:"flex border-b border-slate-100 dark:border-gray-600 justify-center",children:ae("div",{className:"text-base py-1.5 text-slate-700 dark:text-gray-300",children:[s.hour.toString().padStart(2,"0"),":",s.minute.toString().padStart(2,"0")]})}),ae("div",{className:"flex p-1",children:[ae("div",{className:"w-14",children:ae("div",{className:`h-72 overflow-y-auto ${Me} 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:Mt.map(e=>{const t=e===s.hour;return ae("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:ht(e)},e)})})}),ae("div",{className:"w-14",children:ae("div",{className:`h-72 overflow-y-auto ${Me} 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===i;return ae("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:ht(e)},e)})})})]})]})},Pt=({visibleMonth:e,monthLabels:t,weekDayLabels:n,calendarDays:r,draftRange:a,focusedField:o,isTimeEnabled:l,disabled:s,matchTriggerWidth:i,popupRef:d,timeListRefs:c,onMonthChange:u,onYearChange:h,onDaySelect:g,onHourSelect:m,onMinuteSelect:p,onOk:f,getPopupStyle:v})=>{const y=a[0].toPlainDate(),b=a[1].toPlainDate();return ae("div",{ref:d,style:v(),"data-range-picker-popup":"true",children:ae("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:i?"100%":void 0},children:[ae("div",{className:"flex gap-1",children:[ae("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:[ae(It,{visibleMonth:e,monthLabels:t,disabled:s,onMonthChange:u,onYearChange:h}),ae(Ht,{calendarDays:r,visibleMonth:e,startDate:y,endDate:b,weekDayLabels:n,disabled:s,onDaySelect:g})]}),l&&ae("div",{className:"flex flex-1 justify-end sm:w-32",children:ae(Ot,{focusedField:o,draftRange:a,disabled:s,onHourSelect:m,onMinuteSelect:p,timeListRefs:c})})]}),ae("div",{className:"flex justify-end",children:ae("button",{type:"button",onClick:f,disabled:s,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"})})]})})},Lt=({value:e,format:n="YYYY-MM-DD HH:mm",showTimeFormat:o="HH:mm",showTime:l=!0,onChange:s,onOk:i,timeZone:d,disabled:c=!1,placement:u="bottomLeft",autoAdjustOverflow:h=!0,getPopupContainer:g,matchTriggerWidth:m=!1,locale:p="en-US"})=>{const f=r.useMemo(()=>"string"==typeof p?p:(null==p?void 0:p.code)||"en-US",[p]),v=r.useMemo(()=>void 0===l||("object"==typeof l||Boolean(l)),[l]),y=r.useMemo(()=>Et(f,"short"),[f]),b=r.useMemo(()=>Dt(f,"narrow"),[f]),x=r.useMemo(()=>v?"object"==typeof l&&(null==l?void 0:l.format)?l.format:o:"",[v,l,o]),D=r.useMemo(()=>gt(n,x),[n,x]),E=r.useMemo(()=>pt(D),[D]),C=r.useMemo(()=>{const n=null!=d?d:w(e[0])?w(e[1])?t.Temporal.Now.timeZoneId():vt(e[1]):vt(e[0]),r=yt(e[0],n);return[r,yt(e[1],n,r)]},[e,d]),[k,T]=r.useState(C),S=r.useRef(C),[M,N]=r.useState("start"),[I,R]=r.useState([bt(C[0],n,x),bt(C[1],n,x)]),H=r.useRef([bt(C[0],n,x),bt(C[1],n,x)]),O=r.useRef(C),[P,L]=r.useState(C[0].toPlainDate().with({day:1})),[A,$]=r.useState(!1),j=r.useCallback(e=>{$(e)},[]),[Y,F]=r.useState(u),z=r.useRef(u),V=r.useRef(null),_=r.useRef(null),W=r.useRef({start:{hour:null,minute:null},end:{hour:null,minute:null}}),Z=r.useRef(!1),U=r.useRef(!1);r.useEffect(()=>{H.current=I},[I]),r.useEffect(()=>{O.current=k},[k]),r.useEffect(()=>{const e=S.current,n=0!==t.Temporal.ZonedDateTime.compare(e[0],C[0]),r=0!==t.Temporal.ZonedDateTime.compare(e[1],C[1]);(n||r)&&T(C),S.current=C},[C]),r.useEffect(()=>{L(C[0].toPlainDate().with({day:1}))},[C[0]]);const B=r.useCallback((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})},[]),q=r.useCallback(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=W.current[e];["hour","minute"].forEach(e=>{const n=t[e];if(!n)return;const r=n.querySelector('[data-active="true"]');r&&B(n,r,0)})})})},[B]);r.useEffect(()=>{A&&v&&q(M)},[M,A,q,v]);const G=k[0].epochMilliseconds,K=k[0].offsetNanoseconds,X=k[1].epochMilliseconds,J=k[1].offsetNanoseconds;r.useEffect(()=>{if(U.current)return;const[e,t]=O.current,r=bt(e,n,x),a=bt(t,n,x),[o,l]=H.current;o===r&&l===a||(H.current=[r,a],R([r,a]))},[G,K,X,J,n,x]),r.useEffect(()=>{if(!A)return;const e=e=>{var t,n;const r=e.target;if(null===(t=V.current)||void 0===t?void 0:t.contains(r))return;if(null===(n=_.current)||void 0===n?void 0:n.contains(r))return;r.closest("[data-range-picker-popup]")||j(!1)},t=setTimeout(()=>{document.addEventListener("mousedown",e)},100);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[A]),r.useEffect(()=>{A||(N("start"),Z.current||T(C),Z.current=!1)},[A,C]);const Q=r.useCallback(e=>{s&&s(e,[bt(e[0],n,x),bt(e[1],n,x)])},[x,n,s]),ee=r.useCallback(e=>{i&&i(e,[bt(e[0],n,x),bt(e[1],n,x)])},[x,n,i]),te=r.useCallback((e,n)=>{T(r=>{const a=[...r];if("start"===e){const e=yt(a[1],vt(n),n),r=t.Temporal.ZonedDateTime.compare(n,e)>0?n:e;return[n,r]}const o=yt(a[0],vt(n),n);return[t.Temporal.ZonedDateTime.compare(o,n)>0?n:o,n]})},[]),ne=e=>{if(c)return;const n=(e,n)=>{var r,a,o,l;const s=vt(e);return t.Temporal.ZonedDateTime.from({timeZone:s,year:n.year,month:n.month,day:n.day,hour:e.hour,minute:e.minute,second:null!==(r=e.second)&&void 0!==r?r:0,millisecond:null!==(a=e.millisecond)&&void 0!==a?a:0,microsecond:null!==(o=e.microsecond)&&void 0!==o?o:0,nanosecond:null!==(l=e.nanosecond)&&void 0!==l?l:0})};if("start"===M){const t=n(k[0],e),r=k[1].epochMilliseconds-k[0].epochMilliseconds,a=t.add({milliseconds:r});return void T([t,a])}const r=n(k[1],e),a=k[1].epochMilliseconds-k[0].epochMilliseconds;if(t.Temporal.ZonedDateTime.compare(r,k[0])<0){const t=n(k[0],e),r=t.add({milliseconds:a});return void T([t,r])}const o=[k[0],r];T(o),L(r.toPlainDate().with({day:1}))},re=r.useCallback((e,n)=>{if(c)return;const r="start"===e?0:1;T(a=>{const o=a[r],l=o.with({hour:n,minute:o.minute,second:0,millisecond:0,microsecond:0,nanosecond:0});if("start"===e){const e=yt(a[1],vt(l),l);return[l,t.Temporal.ZonedDateTime.compare(l,e)>0?l:e]}const s=yt(a[0],vt(l),l);return[t.Temporal.ZonedDateTime.compare(s,l)>0?l:s,l]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=W.current[e].hour;if(!t)return;const n=t.querySelector('[data-active="true"]');n&&B(t,n,0)})})},[c]),oe=r.useCallback((e,n)=>{if(c)return;const r="start"===e?0:1;T(a=>{const o=a[r].with({minute:n,second:0,millisecond:0,microsecond:0,nanosecond:0});if("start"===e){const e=yt(a[1],vt(o),o);return[o,t.Temporal.ZonedDateTime.compare(o,e)>0?o:e]}const l=yt(a[0],vt(o),o);return[t.Temporal.ZonedDateTime.compare(l,o)>0?o:l,o]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=W.current[e].minute;if(!t)return;const n=t.querySelector('[data-active="true"]');n&&B(t,n,0)})})},[c]),le=r.useCallback((e,t)=>{const n="start"===e?0:1;R(e=>{const r=[...e];return r[n]=t,r})},[]),se=r.useCallback((e,t)=>{const r="start"===e?0:1,a=k[r],o=vt(a),l=ft(t,E,a,o);if(l){te(e,l);const t=l.toPlainDate().with({day:1});return L(t),"start"===e&&N("end"),!0}return R(e=>{const t=[...e];return t[r]=bt(k[r],n,x),t}),!1},[k,x,n,E,te]),ie=r.useCallback(e=>t=>{const n=t.target.value;U.current=!0,le(e,n);const r="start"===e?0:1,a=O.current[r],o=vt(a),l=ft(n,E,a,o);if(l){te(e,l);const t=l.toPlainDate().with({day:1});L(t),q(e)}},[le,E,te,q]),de=r.useCallback(e=>t=>{var r;if(c)return;if(U.current=!1,A){const t="start"===e?0:1,r=bt(O.current[t],n,x);return void R(e=>{const n=[...e];return n[t]=r,n})}const a=t.relatedTarget;a&&(null===(r=V.current)||void 0===r?void 0:r.contains(a))||se(e,t.target.value)},[se,c,A,n,x]),ce=r.useCallback(e=>t=>{"Enter"===t.key&&(t.preventDefault(),U.current=!1,se(e,t.currentTarget.value)),"Escape"===t.key&&t.currentTarget.blur()},[se]),ue=()=>{Z.current=!0,Q(k),ee(k),j(!1)},he=e=>{L(t=>t.add({months:e}).with({day:1}))},ge=e=>{L(t=>t.add({years:e}).with({day:1}))},me=r.useMemo(()=>{const e=P,t=e.dayOfWeek%7,n=e.subtract({days:t});return Array.from({length:42},(e,t)=>n.add({days:t}))},[P]),pe=r.useCallback((e=u)=>{if(!h||!V.current)return e;const t=V.current.getBoundingClientRect(),n=m?t.width:480,r=window.innerHeight-t.bottom,a=t.top,o=window.innerWidth-t.left,l=t.right;let s=e;return s.startsWith("bottom")&&r<500&&a>r?s=s.replace("bottom","top"):s.startsWith("top")&&a<500&&r>a&&(s=s.replace("top","bottom")),s.endsWith("Left")&&o<n&&l>o?s=s.replace("Left","Right"):s.endsWith("Right")&&l<n&&o>l&&(s=s.replace("Right","Left")),s},[h,m,u]),ve=r.useCallback(()=>{const e=pe();z.current!==e&&(z.current=e,F(e))},[pe]),ye=e=>{if(c)return;N(e);const t=k["start"===e?0:1].toPlainDate().with({day:1});L(t);const n=pe();z.current!==n&&(z.current=n,F(n)),j(!0)};r.useEffect(()=>{if(!A)return;ve();const e=()=>ve();return window.addEventListener("resize",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e,!0)}},[A,ve]);const be=()=>{if(!V.current)return{};const e=V.current.getBoundingClientRect(),t=z.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,m&&(n.width=`${e.width}px`),n};return ae("div",{className:"relative max-w-100",ref:V,children:[ae("div",{className:"flex items-center gap-2 rounded-lg border text-sm shadow-sm transition "+(c?"cursor-not-allowed border-slate-200 dark:border-gray-600 bg-slate-50 dark:bg-gray-800 text-slate-400 dark:text-gray-500":A?"border-primary bg-white dark:bg-gray-700 shadow-md":"border-slate-200 dark:border-gray-600 bg-white dark:bg-gray-700"),children:[ae("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:ae("input",{type:"text",name:"range-start",value:I[0],onChange:ie("start"),onFocus:()=>ye("start"),onClick:()=>ye("start"),onBlur:de("start"),onKeyDown:ce("start"),className:"w-full rounded-md border px-2 py-1.5 text-sm font-medium transition focus:outline-none focus:ring-2 "+(c?"cursor-not-allowed border-transparent bg-transparent text-slate-400 dark:text-gray-500":"start"===M&&A?" bg-white dark:bg-gray-700 text-primary":"border-transparent bg-transparent text-slate-700 dark:text-gray-300"),placeholder:D,autoComplete:"off",disabled:c})}),ae(fe,{className:"text-slate-400 dark:text-gray-500"}),ae("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:ae("input",{type:"text",name:"range-end",value:I[1],onChange:ie("end"),onFocus:()=>ye("end"),onClick:()=>ye("end"),onBlur:de("end"),onKeyDown:ce("end"),className:"w-full rounded-md border px-2 py-1.5 text-sm font-medium transition focus:outline-none focus:ring-2 "+(c?"cursor-not-allowed border-transparent bg-transparent text-slate-400 dark:text-gray-500":"end"===M&&A?"bg-white dark:bg-gray-700 text-primary":"border-transparent bg-transparent text-slate-700 dark:text-gray-300"),placeholder:D,autoComplete:"off",disabled:c})})]}),A&&(g?a.createPortal(ae(Pt,{visibleMonth:P,monthLabels:y,weekDayLabels:b,calendarDays:me,draftRange:k,focusedField:M,isTimeEnabled:!!v,disabled:c,matchTriggerWidth:m,popupRef:_,timeListRefs:W,onMonthChange:he,onYearChange:ge,onDaySelect:ne,onHourSelect:re,onMinuteSelect:oe,onOk:ue,getPopupStyle:be}),g()):a.createPortal(ae(Pt,{visibleMonth:P,monthLabels:y,weekDayLabels:b,calendarDays:me,draftRange:k,focusedField:M,isTimeEnabled:!!v,disabled:c,matchTriggerWidth:m,popupRef:_,timeListRefs:W,onMonthChange:he,onYearChange:ge,onDaySelect:ne,onHourSelect:re,onMinuteSelect:oe,onOk:ue,getPopupStyle:be}),document.body))]})},At=({event:e,isOpen:n,isAllDay:o,onEventUpdate:l,onEventDelete:s,onClose:i,app:d})=>{var c;const[u,g]=r.useState(e),{t:m}=Tt();r.useEffect(()=>{g(e)},[e]);const p=r.useMemo(()=>(d?d.getCalendarRegistry():h()).getVisible().map(e=>({label:e.name,value:e.id})),[d,null==d?void 0:d.getCalendars()]),f=r.useMemo(()=>!J(e,u),[e,u]),v=r.useMemo(()=>w(u.start)?u.end&&!w(u.end)&&(u.end.timeZoneId||u.end.timeZoneId)||t.Temporal.Now.timeZoneId():u.start.timeZoneId||u.start.timeZoneId||t.Temporal.Now.timeZoneId(),[u.end,u.start]),y=e=>{const[t,n]=e;g(Object.assign(Object.assign({},u),{start:t.toPlainDate(),end:n.toPlainDate()}))},b=!(null==d?void 0:d.state.readOnly),x=!1!==(null==d?void 0:d.getReadOnlyConfig().viewable);if(!n||!x)return null;if("undefined"==typeof window||"undefined"==typeof document)return null;const D=ae("div",{className:"fixed inset-0 flex items-center justify-center",style:{pointerEvents:"auto",zIndex:9998},"data-event-detail-dialog":"true",children:[ae("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&&i()}}),ae("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:[ae("button",{onClick:i,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:ae("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:ae("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),ae("div",{children:[ae("span",{className:"block text-xs text-gray-600 dark:text-gray-300 mb-1",children:m("eventTitle")}),ae("div",{className:"flex items-center justify-between gap-3 mb-4",children:[ae("div",{className:"flex-1",children:ae("input",{id:`event-dialog-title-${u.id}`,name:"title",type:"text",value:u.title,readOnly:!b,disabled:!b,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"})}),b&&ae(nt,{options:p,value:u.calendarId||"blue",onChange:e=>{g(Object.assign(Object.assign({},u),{calendarId:e}))},registry:null==d?void 0:d.getCalendarRegistry()})]}),u.allDay?ae("div",{className:"mb-4",children:[ae("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-1",children:m("dateRange")}),ae(Lt,{value:[u.start,u.end],format:"YYYY-MM-DD",showTime:!1,timeZone:v,matchTriggerWidth:!0,disabled:!b,onChange:y,onOk:y,locale:null==d?void 0:d.state.locale})]}):ae("div",{className:"mb-4",children:[ae("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-1",children:m("timeRange")}),ae(Lt,{value:[u.start,u.end],timeZone:v,disabled:!b,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==d?void 0:d.state.locale})]}),ae("div",{className:"mb-4",children:[ae("span",{className:"block text-xs text-gray-600 dark:text-gray-300 mb-1",children:m("note")}),ae("textarea",{id:`event-dialog-note-${u.id}`,name:"note",value:null!==(c=u.description)&&void 0!==c?c:"",readOnly:!b,disabled:!b,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")})]}),b&&ae("div",{className:"flex space-x-2",children:[u.allDay?ae("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=w(u.start)?u.start:u.start.toPlainDate(),n=t.Temporal.ZonedDateTime.from({year:e.year,month:e.month,day:e.day,hour:9,minute:0,timeZone:t.Temporal.Now.timeZoneId()}),r=t.Temporal.ZonedDateTime.from({year:e.year,month:e.month,day:e.day,hour:10,minute:0,timeZone:t.Temporal.Now.timeZoneId()});g(Object.assign(Object.assign({},u),{allDay:!1,start:n,end:r}))},children:m("setAsTimed")}):ae("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=w(u.start)?u.start:u.start.toPlainDate();g(Object.assign(Object.assign({},u),{allDay:!0,start:e,end:e}))},children:m("setAsAllDay")}),ae("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:()=>{s(e.id),i()},children:m("delete")}),ae("button",{className:"px-3 py-2 bg-primary text-primary-foreground rounded-lg text-xs font-medium transition ml-auto "+(f?"hover:bg-primary/90 shadow-lg shadow-primary/20":"opacity-50 cursor-not-allowed grayscale-[0.5]"),onClick:()=>{l(u),i()},disabled:!f,children:m("save")})]})]})]})]}),E=document.body;return E?a.createPortal(D,E):null},$t=({calendar:e,mode:t="buttons"})=>{const[n,a]=r.useState(!1),o=r.useRef(null),{t:l}=Tt(),s=Array.from(e.state.views.keys()),i=e.state.currentView;return s.length<=1?null:(r.useEffect(()=>{const e=e=>{o.current&&!o.current.contains(e.target)&&a(!1)};if(n)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[n]),ae("div","select"===t?{className:"relative inline-block",ref:o,children:[ae("button",{onClick:()=>a(!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:[ae("span",{className:"text-gray-900 dark:text-gray-100",children:l(i)}),ae("span",{className:`${Ge} transition-transform duration-200 ${n?"rotate-180":""}`,children:ae(de,{width:16,height:16})})]}),n&&ae("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:ae("div",{className:"p-1",role:"listbox",children:s.map(t=>ae("button",{onClick:()=>{e.changeView(t),a(!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:l(t)},t))})}),ae("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:s.map(t=>ae("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:l(t)},t))}))},jt=e=>{if(!e)return"";let n,r,a;e instanceof Date?(n=e.getFullYear(),r=e.getMonth()+1,a=e.getDate()):w(e)?(n=e.year,r=e.month,a=e.day):(!function(e){!e||"object"!=typeof e||e instanceof Date||t.Temporal.ZonedDateTime}(e),n=e.year,r=e.month,a=e.day);const o=String(r).padStart(2,"0");return`${String(a).padStart(2,"0")}/${o}/${n}`};function Yt(){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 Ft=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 zt(e,n=!1){if(e instanceof t.Temporal.PlainDate||e instanceof t.Temporal.PlainDateTime)return e;if(e instanceof Date)return n?st(e):it(e);throw new Error("Invalid time type: "+typeof e)}function Vt(e,n){if(e instanceof t.Temporal.ZonedDateTime)return e;if(e instanceof Date)return dt(e,n);throw new Error("Invalid time type: "+typeof e)}function _t(e){var t;const n=zt(e.start,e.allDay),r=zt(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 Wt(e){const t=Vt(e.start,e.timeZone),n=Vt(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}}const Zt=e=>{try{return e instanceof Date?e:"string"==typeof e?new Date(e):E(e)}catch(e){return new Date}},Ut=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},Bt=(e,t,n,r)=>{const a=e.getTime()-t.getTime(),o=Math.round(a/864e5);let l="",s="text-gray-500 dark:text-gray-400";if(0===o)l=r("today")||"Today",s="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),s="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:s}},qt=(e,t)=>{const n=new Map;e.forEach(e=>{var t;const r=Zt(e.start),a=Ut(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 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}},Kt=/^(\d{4})(\d{2})(\d{2})$/,Xt=/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})$/,Jt=/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z$/;function Qt(e,n,r){const a=e.trim();if("DATE"===(null==n?void 0:n.value)||Kt.test(a)){const e=a.match(Kt);if(e)return t.Temporal.PlainDate.from({year:parseInt(e[1],10),month:parseInt(e[2],10),day:parseInt(e[3],10)})}if(Jt.test(a)){const e=a.match(Jt);if(e){const n=t.Temporal.Instant.from(`${e[1]}-${e[2]}-${e[3]}T${e[4]}:${e[5]}:${e[6]}Z`),a=r||t.Temporal.Now.timeZoneId();return n.toZonedDateTimeISO(a)}}const o=a.match(Xt);if(o){const e={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)?t.Temporal.ZonedDateTime.from(Object.assign(Object.assign({},e),{timeZone:n.tzid})):t.Temporal.PlainDateTime.from(e)}throw new Error(`Invalid ICS date format: ${e}`)}function en(e,t=!1){if(t||rt(e)){const t=rt(e)?e:e.toPlainDate();return{value:`${t.year}${nn(t.month)}${nn(t.day)}`,params:{VALUE:"DATE"}}}if(ot(e)){const t=e.toInstant().toZonedDateTimeISO("UTC");return{value:`${t.year}${nn(t.month)}${nn(t.day)}T${nn(t.hour)}${nn(t.minute)}${nn(t.second)}Z`}}if(at(e))return{value:`${e.year}${nn(e.month)}${nn(e.day)}T${nn(e.hour)}${nn(e.minute)}${nn(e.second)}`};throw new Error("Unsupported Temporal type")}function tn(e){return`${e.getUTCFullYear()}${nn(e.getUTCMonth()+1)}${nn(e.getUTCDate())}T${nn(e.getUTCHours())}${nn(e.getUTCMinutes())}${nn(e.getUTCSeconds())}Z`}function nn(e){return String(e).padStart(2,"0")}function rn(e,n={}){const r={success:!1,events:[],errors:[],totalParsed:0,totalImported:0};try{const a=e.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((e,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(";"),s=o.trim().toUpperCase(),i={};switch(l.forEach(e=>{const[t,n]=e.split("=");t&&n&&(i[t.trim().toUpperCase()]=n.trim())}),s){case"UID":t.uid=a.trim();break;case"SUMMARY":t.summary=an(a);break;case"DESCRIPTION":t.description=an(a);break;case"LOCATION":t.location=an(a);break;case"DTSTART":t.dtstart=a.trim(),t.dtstartParams={value:i.VALUE,tzid:i.TZID};break;case"DTEND":t.dtend=a.trim(),t.dtendParams={value:i.VALUE,tzid:i.TZID};break;case"CATEGORIES":t.categories=a.split(",").map(e=>an(e.trim()))}}if(!t.dtstart)throw new Error("Missing DTSTART in VEVENT");t.uid||(t.uid=Q());return t}(e),o=function(e,n){var r;const{calendarId:a="default",generateNewIds:o=!0,idPrefix:l="ics-",defaultTimeZone:s}=n,i=o?`${l}${Q()}`:e.uid,d=Qt(e.dtstart,e.dtstartParams,s);let c;c=e.dtend?Qt(e.dtend,e.dtendParams,s):rt(d)?d.add({days:1}):d.add({hours:1});const u="DATE"===(null===(r=e.dtstartParams)||void 0===r?void 0:r.value)||rt(d),h=s||t.Temporal.Now.timeZoneId();let g,m;if(rt(d))g=d.toZonedDateTime({timeZone:h,plainTime:"00:00:00"});else if(at(d))try{if("function"!=typeof d.toZonedDateTime)throw new Error("toZonedDateTime missing");g=d.toZonedDateTime(h)}catch(e){g=t.Temporal.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(rt(c))m=c.toZonedDateTime({timeZone:h,plainTime:"00:00:00"});else if(at(c))try{if("function"!=typeof c.toZonedDateTime)throw new Error("toZonedDateTime missing");m=c.toZonedDateTime(h)}catch(e){m=t.Temporal.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:i,calendarId:a,title:e.summary||"(No Title)",description:e.description,start:g,end:m,allDay:u,meta:{location:e.location,originalUid:e.uid,categories:e.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 an(e){return e.replace(/\\,/g,",").replace(/\\;/g,";").replace(/\\[nN]/g,"\n").replace(/\\\\/g,"\\")}function on(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:${sn(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:${tn(new Date)}`);const s=en(e.start,e.allDay),i=en(e.end,e.allDay);a.push(ln("DTSTART",s.value,s.params)),a.push(ln("DTEND",i.value,i.params)),a.push(ln("SUMMARY",sn(e.title))),e.description&&a.push(ln("DESCRIPTION",sn(e.description)));const d=null===(n=e.meta)||void 0===n?void 0:n.location;d&&a.push(ln("LOCATION",sn(d)));const c=null===(r=e.meta)||void 0===r?void 0:r.categories;if(c&&Array.isArray(c)){const e=c.map(sn).join(",");a.push(ln("CATEGORIES",e))}return a.push("END:VEVENT"),a}(e))}),o.push("END:VCALENDAR"),o.join("\r\n")}function ln(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 sn(e){return e?e.replace(/\\/g,"\\\\").replace(/;/g,"\\;").replace(/,/g,"\\,").replace(/\n/g,"\\n"):""}let dn=null;const cn=()=>{const[e,t]=r.useState(()=>dn||{weekHeight:s.WEEK_HEIGHT,screenSize:"desktop",weeksPerView:6});return r.useEffect(()=>{const e=()=>{const e=window.innerWidth,n=window.innerHeight-150,r=Math.max(80,Math.floor(n/6)),a=e<768?{weekHeight:Math.max(s.MOBILE_WEEK_HEIGHT,r),screenSize:"mobile",weeksPerView:6}:e<1024?{weekHeight:Math.max(s.TABLET_WEEK_HEIGHT,r),screenSize:"tablet",weeksPerView:6}:{weekHeight:Math.max(s.WEEK_HEIGHT,r),screenSize:"desktop",weeksPerView:6};dn=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 un=0;function hn({generatorName:e,generatorArgs:t,defaultContent:n,store:a}){const o=r.useRef(null),l=r.useContext(ne),s=a||l,i=r.useRef(null),[,d]=r.useState(0);i.current||(i.current="df-slot-"+un++),r.useEffect(()=>{if(!o.current||!s)return;const n=i.current;s.register({id:n,containerEl:o.current,generatorName:e,generatorArgs:t});const r=s.subscribe(()=>{d(e=>e+1)});return()=>{s.unregister(n),r()}},[s]),r.useEffect(()=>{if(!s||!i.current)return;const n=i.current;s.register({id:n,containerEl:o.current,generatorName:e,generatorArgs:t})},[e,t]);const c="eventContent"===e,u="sidebar"===e,h=null==s?void 0:s.isOverridden(e);return ae("div",{ref:o,className:"df-content-slot "+(c||u?"flex-1 flex flex-col h-full":""),children:!h&&n})}const gn=({calendar:e,switcherMode:t="buttons",onAddCalendar:n,onSearchChange:a,onSearchClick:o,searchValue:l="",isSearchOpen:s=!1,isEditable:i=!0,safeAreaLeft:d})=>{const c=r.useContext(ne),u="buttons"===t,h=e.state.currentView===exports.ViewType.DAY,{screenSize:g}=cn(),m="mobile"===g,{t:p}=Tt(),f=r.useCallback(e=>{const t=e.target.value;t!==l&&(null==a||a(t))},[a,l]);return ae(hn,{store:c,generatorName:"headerContent",generatorArgs:r.useMemo(()=>({calendar:e,switcherMode:t,onAddCalendar:n,onSearchChange:a,onSearchClick:o,searchValue:l,isSearchOpen:s,isEditable:i,safeAreaLeft:d}),[e,t,n,a,o,l,s,i,d]),defaultContent:ae("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 "+(h||s?"border-gray-200 dark:border-gray-700":"border-transparent"),style:{paddingLeft:d||8,transition:"padding-left 160ms ease-in-out"},onContextMenu:e=>e.preventDefault(),children:[ae("div",{className:"df-header-left flex items-center mb-1",children:n&&i&&ae("button",{id:"dayflow-add-event-btn",onClick:n,className:qe,title:m?p("newEvent")||"New Event":p("createCalendar")||"Add Calendar",children:ae(ce,{className:`h-4 w-4 ${Ge}`})})}),ae("div",{className:"df-header-mid flex-1 flex justify-center",children:u&&ae($t,{mode:t,calendar:e})}),ae("div",{className:"df-header-right flex items-center justify-end gap-3 mb-1 pb-1",children:[!u&&ae($t,{mode:t,calendar:e}),ae("button",{onClick:o,className:`md:hidden ${qe}`,title:p("search")||"Search",children:ae(ue,{width:16,height:16})}),ae("div",{className:"relative hidden md:block group",children:[ae("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:ae("span",{className:"text-gray-400 group-focus-within:text-primary transition-colors",children:ae(ue,{width:16,height:16})})}),ae("input",{id:"dayflow-search-input",type:"text",placeholder:p("search")||"Search",value:l,onChange:f,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"}),l&&ae("button",{onClick:()=>{null==a||a("")},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:ae("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[ae("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ae("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]})]})})},mn=({loading:e,results:t,keyword:n,onResultClick:a,emptyText:o})=>{const{t:l,locale:s}=Tt(),i=r.useMemo(()=>Ut(new Date),[]),d=r.useMemo(()=>qt(t,i),[t,i]),c=e=>Zt(e);return e?ae("div",{className:"flex flex-col items-center justify-center h-40 text-gray-500",children:[ae(ve,{className:"w-8 h-8 animate-spin mb-2"}),ae("span",{children:"Loading..."})]}):0===t.length?n?ae("div",{className:"flex flex-col items-center justify-center h-40 text-gray-500",children:[ae(pn,{}),ae("span",{className:"mt-2 text-sm",children:"string"==typeof o?o:o&&"object"==typeof o?o[s]||o.en||"No results found":l("noResults")||"No results found"})]}):null:ae("div",{className:"space-y-6",children:d.map(e=>{const{title:t,colorClass:n}=Bt(e.date,i,s,l);return ae("div",{children:[ae("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}),ae("div",{className:"flex flex-col",children:e.events.map(e=>{const t=c(e.start),n=c(e.end),r={hour:"2-digit",minute:"2-digit"},o=e.allDay?l("allDay")||"All Day":t.toLocaleTimeString(s,r),i=e.allDay?"":n.toLocaleTimeString(s,r);return ae("div",{children:[ae("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==a?void 0:a(e),children:ae("div",{className:"flex items-stretch gap-3",children:[ae("div",{className:"w-1 rounded-full shrink-0",style:{backgroundColor:e.color||"#3b82f6"}}),ae("div",{className:"flex-1 min-w-0 flex justify-between items-start",children:[ae("div",{className:"font-medium text-black dark:text-white truncate pr-2 text-sm",children:e.title}),ae("div",{className:"text-xs flex flex-col items-end shrink-0 leading-tight",children:[ae("div",{className:"text-black dark:text-white",children:o}),i&&ae("div",{className:"text-gray-500 dark:text-gray-400",children:i})]})]})]})}),ae("div",{className:"mx-2 border-b border-gray-200 dark:border-gray-700"})]},e.id)})})]},e.date.getTime())})})},pn=()=>ae("svg",{className:"w-12 h-12 text-gray-300 dark:text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:ae("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),fn=({isOpen:e,onClose:t,loading:n,results:r,keyword:a,onResultClick:o,emptyText:l})=>ae("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:ae("div",{className:"flex-1 overflow-y-auto min-w-64",children:ae(mn,{loading:n,results:r,keyword:a,onResultClick:o,emptyText:l})})}),vn=({isOpen:e,onClose:t,keyword:n,onSearchChange:o,results:l,loading:s,onResultClick:i,emptyText:d})=>{const c=r.useRef(null),{t:u}=Tt();return r.useEffect(()=>(e?(setTimeout(()=>{var e;null===(e=c.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?a.createPortal(ae("div",{className:"fixed inset-0 z-9999 bg-white dark:bg-gray-900 flex flex-col",children:[ae("div",{className:"flex items-center p-2 border-b border-gray-200 dark:border-gray-700 gap-2",children:[ae("button",{onClick:t,className:"p-2 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:ae(De,{className:"w-6 h-6"})}),ae("div",{className:"flex-1 relative",children:[ae("input",{ref:c,type:"text",placeholder:u("search")||"Search",value:n,onChange:e=>{const t=e.target.value;t!==n&&o(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&&ae("button",{onClick:()=>{""!==n&&o("")},className:"absolute inset-y-0 right-0 pr-3 flex items-center text-gray-400",children:ae(me,{className:"w-4 h-4"})})]})]}),ae("div",{className:"flex-1 overflow-y-auto p-2 select-none",children:ae(mn,{loading:s,results:l,keyword:n,onResultClick:e=>{null==i||i(e)},emptyText:d})})]}),document.body):null},yn=({app:e,anchorRef:t,onClose:n,isOpen:o})=>{const{t:l}=Tt(),[s,i]=r.useState(""),[d,c]=r.useState(0),[u,h]=r.useState(!1),g=r.useRef(null),m=r.useRef(null);r.useEffect(()=>{o||h(!1)},[o]),r.useEffect(()=>{o&&(setTimeout(()=>{var e;return null===(e=g.current)||void 0===e?void 0:e.focus()},50),i(""),c(0))},[o]),r.useEffect(()=>{const e=e=>{o&&m.current&&!m.current.contains(e.target)&&t.current&&!t.current.contains(e.target)&&n()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[o,n,t]);const[p,f]=r.useState({top:0,left:0}),[v,y]=r.useState("top"),[b,w]=r.useState(0),D=r.useMemo(()=>{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}},[o]),E=r.useMemo(()=>{if(!s.trim())return[];const t=[],n=e.getCalendars(),r=e.getAllEvents(),a=s.toLowerCase(),o=r.find(e=>e.title.toLowerCase()===a);let l=null==o?void 0:o.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 i=n.find(e=>e.id===l),d=(null==i?void 0:i.colors.lineColor)||"#3b82f6";t.push({type:"new",title:s,calendarId:l||"",color:d,start:D.start,end:D.end});const c=new Set;c.add(s.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:D.start,end:D.end})}),t},[s,e,D]);r.useLayoutEffect(()=>{if(o&&t.current&&m.current){const e=t.current.getBoundingClientRect(),n=m.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 s=e.left+e.width/2;w(s-a);let i=0,d="top";e.top<n+20?(d="bottom",i=e.bottom+12):(d="top",i=e.top-12-n),y(d),f({top:i,left:a}),h(!0)}},[o,t,E]);const C=t=>{if(!t.calendarId)return;const r=Q(),a={id:r,title:t.title,start:x(t.start),end:x(t.end),calendarId:t.calendarId,allDay:!1};e.addEvent(a),e.setCurrentDate(t.start),e.highlightEvent(r),n()};r.useEffect(()=>{if(!o)return;const e=e=>{"ArrowDown"===e.key?(e.preventDefault(),c(e=>(e+1)%E.length)):"ArrowUp"===e.key?(e.preventDefault(),c(e=>(e-1+E.length)%E.length)):"Enter"===e.key&&(e.preventDefault(),E[d]&&C(E[d]))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[o,E,d]);const k=(e,t)=>{const n=e=>e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1});return`${n(e)} - ${n(t)}`};return o?a.createPortal(ae("div",{ref:m,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 "+(u?"animate-in fade-in zoom-in-95 duration-100":""),style:{top:p.top,left:p.left,visibility:u?"visible":"hidden"},children:[ae("div",{className:"p-4 pb-2",children:[ae("div",{className:"mb-2 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:l("quickCreateEvent")||"Quick Create Event"}),ae("div",{className:"relative",children:ae("input",{ref:g,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:l("quickCreatePlaceholder")||"Enter title (e.g. Code review)",value:s,onChange:e=>i(e.target.value)})})]}),ae("div",{className:"flex-1 overflow-y-auto max-h-75 py-1 px-2",children:[0===E.length&&s&&ae("div",{className:"px-4 py-3 text-sm text-gray-400 text-center",children:l("noSuggestions")||"Type to create"}),E.map((e,t)=>ae("div",{className:"flex items-center px-4 py-2 cursor-pointer transition-colors rounded-lg "+(t===d?"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:()=>C(e),onMouseEnter:()=>c(t),children:[ae("div",{className:"w-1 h-8 rounded-full mr-3 shrink-0",style:{backgroundColor:e.color}}),ae("div",{className:"flex-1 min-w-0 flex flex-col gap-0.5",children:[ae("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 truncate",children:e.title}),ae("div",{className:"flex",children:ae("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?l("today"):l("tomorrow")})}),ae("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:k(e.start,e.end)})]})]},`${e.type}-${t}`))]}),ae("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"===v?"-bottom-1.5 border-b border-r":"-top-1.5 border-t border-l"),style:{left:b}})]}),document.body):null},bn=e=>{const t=r.useRef(null),n=r.useRef(null);return r.useEffect(()=>{if(t.current){const{className:r}=e,a=o.__rest(e,["className"]);n.current=new l.BlossomColorPicker(t.current,a),a.initialExpanded&&n.current.expand()}return()=>{n.current&&(n.current.destroy(),n.current=null)}},[]),r.useEffect(()=>{if(n.current){const{className:t}=e,r=o.__rest(e,["className"]);n.current.setOptions(r)}},[e]),ae("div",{ref:t,className:e.className})},wn=({color:e,onChange:t,onClose:n})=>{const a=r.useMemo(()=>{const{h:t,s:n,l:r}=l.hexToHsl(e);return{hue:t,saturation:l.lightnessToSliderValue(r),lightness:r,alpha:100,layer:"outer"}},[e]);return ae("div",{className:"flex justify-center",children:ae(bn,{defaultValue:a,coreSize:36,petalSize:32,initialExpanded:!0,openOnHover:!1,onChange:e=>t({hex:e.hex},!0),onCollapse:n})})},xn=n.createContext(void 0),Dn=({children:e,initialTheme:t="light",onThemeChange:n})=>{const[a,o]=r.useState(t),[l,s]=r.useState("light"),i="auto"===a?l:a;r.useEffect(()=>{o(t)},[t]);const d=r.useCallback(e=>{o(e)},[]);r.useEffect(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-color-scheme: dark)"),t=e=>{const t=e.matches?"dark":"light";s(t)},n=e.matches?"dark":"light";return s(n),e.addEventListener?e.addEventListener("change",t):e.addListener&&e.addListener(t),()=>{e.removeEventListener?e.removeEventListener("change",t):e.removeListener&&e.removeListener(t)}},[]),r.useEffect(()=>{if("undefined"==typeof document)return;const e=document.documentElement,t=Ft(i),n="auto"===a?t:i;e.classList.remove("light","dark"),e.classList.add(n),"auto"===a?e.removeAttribute("data-dayflow-theme-override"):e.setAttribute("data-dayflow-theme-override",n),e.setAttribute("data-theme",n)},[i,a,l]),r.useEffect(()=>{n&&n(a,i)},[a,i,n]);const c={theme:a,effectiveTheme:i,setTheme:d};return ae(xn.Provider,{value:c,children:e})},En=()=>{const e=r.useContext(xn);if(void 0===e)throw new Error("useTheme must be used within a ThemeProvider");return e},Cn=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],kn=({onClose:e,onCreate:t,colorPickerMode:o="default"})=>{const{t:s}=Tt(),{effectiveTheme:i}=En(),[d,c]=r.useState(""),[u,h]=r.useState(Cn[Math.floor(Math.random()*Cn.length)]),[m,p]=r.useState(!1),[f,v]=r.useState(""),y=r.useMemo(()=>{const e=l.DEFAULT_COLORS[Math.floor(Math.random()*l.DEFAULT_COLORS.length)],t=e.layer||"outer",n=l.lightnessToSliderValue(e.l);return{hue:e.h,saturation:n,lightness:e.l,alpha:100,layer:t}},[]),[b,w]=r.useState(null),x=e=>{h(e.hex)},D="dark"===i,E={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:a.createPortal(ae("div",{className:"fixed inset-0 z-10000 flex items-center justify-center bg-black/50",children:ae("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:[ae("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white "+("default"===o?"mb-6":"mb-4"),children:s("createCalendar")}),ae("form",{onSubmit:n=>{var r;if(n.preventDefault(),!d.trim())return;let a;a="default"===o?null!==(r=null==b?void 0:b.hex)&&void 0!==r?r:l.hslToHex(y.hue,y.saturation,y.lightness):u;const{colors:s,darkColors:i}=g(a),c={id:Q(),name:d.trim(),colors:s,darkColors:i,isVisible:!0,isDefault:!1};t(c),e()},children:["default"===o?ae("div",{className:"mb-8 flex items-center gap-4",children:[ae("div",{className:"flex-1",children:ae("input",{id:"blossom-calendar-name",name:"calendar-name",type:"text",value:d,onChange:e=>c(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:s("calendarNamePlaceholder"),autoFocus:!0})}),ae("div",{className:"w-9 h-9 relative shrink-0",children:ae("div",{className:"absolute inset-0 flex items-center justify-center",children:ae(bn,{defaultValue:y,coreSize:36,petalSize:32,openOnHover:!1,onChange:e=>w(e),onCollapse:e=>w(e),className:"z-50"})})})]}):ae(n.Fragment,{children:[ae("div",{className:"mb-4",children:ae("div",{className:"flex items-center gap-3",children:[ae("div",{className:"h-9 w-9 rounded-md border border-gray-200 shadow-sm dark:border-gray-600",style:{backgroundColor:u}}),ae("input",{id:"custom-calendar-name",name:"calendar-name",type:"text",value:d,onChange:e=>c(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:s("calendarNamePlaceholder"),autoFocus:!0})]})}),ae("div",{className:"mb-6",children:[ae("div",{className:"grid grid-cols-7 gap-6",children:Cn.map(e=>ae("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 "+(u===e?"ring-2 ring-primary ring-offset-2 dark:ring-offset-slate-800":""),style:{backgroundColor:e},onClick:()=>h(e)},e))}),ae("div",{className:"mt-2 relative",children:[ae("button",{type:"button",onClick:()=>{v(u),p(!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:s("customColor")}),m&&ae("div",{className:"absolute left-0 top-full z-10001 mt-2",children:ae(hn,{generatorName:"colorPickerWrapper",generatorArgs:{variant:"photoshop",color:u,onChange:x,onAccept:()=>{p(!1)},onCancel:()=>{h(f),p(!1)},styles:E},defaultContent:ae("div",{children:ae(wn,{color:u,onChange:x})})})})]})]})]}),ae("div",{className:"flex justify-end space-x-2",children:[ae("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:s("cancel")}),ae("button",{type:"submit",disabled:!d.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:s("create")})]})]})]})}),document.body)},Tn=({visibleMonth:e,currentDate:t,showHeader:n=!1,onMonthChange:a,onDateSelect:o})=>{const{locale:l}=Tt(),s=r.useMemo(()=>(new Date).toDateString(),[]),i=t.toDateString(),d=r.useMemo(()=>Dt(l,"narrow"),[l]),c=r.useMemo(()=>e.toLocaleDateString(l,{month:"long",year:"numeric"}),[e,l]),u=r.useMemo(()=>{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),l=o.toDateString();a.push({date:o.getDate(),fullDate:o,isCurrentMonth:o.getMonth()===n,isToday:l===s,isSelected:l===i})}return a},[e,i,s]);return ae("div",{className:"px-3 py-3",children:[n?ae("div",{className:"mb-3 flex items-center justify-between",children:[ae("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:()=>a(-1),"aria-label":"Previous month",children:ae(oe,{className:"h-4 w-4"})}),ae("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:c}),ae("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:()=>a(1),"aria-label":"Next month",children:ae(le,{className:"h-4 w-4"})})]}):"",ae("div",{className:"df-mini-calendar-grid grid grid-cols-7 gap-1 text-xs justify-items-center",children:[d.map((e,t)=>ae("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}`)),u.map(e=>ae("button",{type:"button",className:`\n df-mini-calendar-day text-center py-1 rounded text-xs h-6 w-6\n ${e.isToday?ze: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:()=>o(e.fullDate),children:e.date},e.fullDate.getTime()))]})]})},Sn=({checked:e,onChange:t,disabled:n})=>ae("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:ae("div",{className:"bg-white w-5 h-5 rounded-full shadow-md transform transition-transform "+(e?"translate-x-5":"")})}),Mn=({date:e,onChange:t})=>{const n=Array.from({length:24},(e,t)=>t),a=Array.from({length:12},(e,t)=>5*t),o=[...n,...n,...n],l=[...a,...a,...a],s=32,i=e.getHours(),d=5*Math.round(e.getMinutes()/5),c=(24+i)*s,u=(12+d/5)*s,[h,g]=r.useState(c),[m,p]=r.useState(u),f=r.useRef(null),v=r.useRef(null),y=r.useRef(null);r.useEffect(()=>{f.current&&(f.current.scrollTop=c,g(c)),v.current&&(v.current.scrollTop=u,p(u))},[c,u]);const b=(n,r)=>{const a=n.currentTarget;let i=a.scrollTop;if("hour"===r){const e=768;i<320?(i+=e,a.scrollTop=i):i>1600&&(i-=e,a.scrollTop=i),g(i)}else{const e=384;i<160?(i+=e,a.scrollTop=i):i>800&&(i-=e,a.scrollTop=i),p(i)}y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{((n,r)=>{const a=Math.round(r/s);if("hour"===n){const n=o[a];if(void 0!==n&&n!==e.getHours()){const r=new Date(e);r.setHours(n),t(r)}}else{const n=l[a];if(void 0!==n&&5*Math.round(e.getMinutes()/5)!==n){const r=new Date(e);r.setMinutes(n),t(r)}}})(r,i)},150)},w=(e,t)=>{const n=96+e*s+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 ae("div",{className:"flex h-56 overflow-hidden rounded-lg mt-2 relative ",children:[ae("style",{dangerouslySetInnerHTML:{__html:"\n .no-scrollbar::-webkit-scrollbar { display: none; }\n .no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }\n "}}),ae("div",{ref:f,className:"flex-1 overflow-y-auto snap-y snap-mandatory no-scrollbar",style:{touchAction:"pan-y"},onScroll:e=>b(e,"hour"),children:[ae("div",{style:{height:96}}),o.map((n,r)=>ae("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=f.current)||void 0===a||a.scrollTo({top:r*s,behavior:"smooth"})},children:ae("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:w(r,h),children:n.toString().padStart(2,"0")})},r)),ae("div",{style:{height:96}})]}),ae("div",{ref:v,className:"flex-1 overflow-y-auto snap-y snap-mandatory no-scrollbar",style:{touchAction:"pan-y"},onScroll:e=>b(e,"minute"),children:[ae("div",{style:{height:96}}),l.map((n,r)=>ae("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=v.current)||void 0===a||a.scrollTo({top:r*s,behavior:"smooth"})},children:ae("div",{className:"w-10 text-center text-xl transition-colors duration-200 "+(n===d?"font-bold text-black dark:text-white":"text-gray-400 dark:text-gray-500"),style:w(r,m),children:n.toString().padStart(2,"0")})},r)),ae("div",{style:{height:96}})]}),ae("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"})]})},Nn=({isOpen:e,onClose:t,onSave:n,onEventDelete:o,draftEvent:l,app:s})=>{const{locale:i,t:d}=Tt(),c=s.getReadOnlyConfig(),u=!s.state.readOnly,h=!1!==c.viewable,[g,m]=r.useState(""),[p,f]=r.useState(""),[v,y]=r.useState(!1),[b,w]=r.useState(new Date),[D,C]=r.useState(new Date),[k,T]=r.useState(""),[S,M]=r.useState(new Date),[N,I]=r.useState(new Date),[R,H]=r.useState(null),[O,P]=r.useState(e),[L,$]=r.useState(!1),[j,Y]=r.useState(!1);r.useEffect(()=>{if(!e){$(!0);const e=setTimeout(()=>{P(!1),$(!1)},300);return()=>clearTimeout(e)}P(!0),$(!1)},[e]),r.useEffect(()=>{if(e&&l){const e=s.getEvents().some(e=>e.id===l.id);Y(e)}},[e,l,s]);const F=s.getCalendars(),z=F.map(e=>({label:e.name,value:e.id}));r.useEffect(()=>{if(e&&F.length>0){F.some(e=>e.id===p)||"blue"!==p&&""!==p||f(F[0].id)}},[F,e,p]),r.useEffect(()=>(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]),r.useEffect(()=>{var t,n;if(e&&l){if(m(l.title||""),f(l.calendarId||(null===(t=F[0])||void 0===t?void 0:t.id)||"blue"),y(l.allDay||!1),l.start)try{const e=E(l.start);w(e),M(e)}catch(e){console.error("Failed to parse start date",e);const t=new Date;w(t),M(t)}if(l.end)try{const e=E(l.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&&!l){f((null===(n=F[0])||void 0===n?void 0:n.id)||"blue");const e=new Date;e.setMinutes(0,0,0),w(e),M(e),C(new Date(e.getTime()+36e5)),I(e)}},[e,l]);const V=r.useMemo(()=>{if(!e||!l)return!1;let t=new Date(b),n=new Date(D);v&&(t.setHours(0,0,0,0),n.setHours(0,0,0,0));const r=Object.assign(Object.assign({},l),{title:g,calendarId:p,allDay:v,description:k,start:x(t),end:x(n)});return!J(l,r)},[e,l,g,p,v,b,D,k]);if(!O||!h)return null;const _=e=>{H(t=>t===e?null:e)},W=e=>e.toLocaleDateString(i,{day:"numeric",month:"short",year:"numeric"}),Z=(e,t)=>{if("start"===e){const e=new Date(t);e.setHours(b.getHours(),b.getMinutes());const n=e.getTime()-b.getTime();w(e);const r=new Date(D.getTime()+n);C(r)}else{const e=new Date(t);e.setHours(D.getHours(),D.getMinutes()),C(e)}},U=(e,t)=>{"start"===e?M(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 a.createPortal(ae("div",{className:"fixed inset-0 z-10000 flex items-end pointer-events-none",children:[ae("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}),ae("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:[ae("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:[ae("button",{onClick:t,className:"text-gray-500 hover:text-gray-700 px-2 py-1",children:d("cancel")}),ae("span",{className:"font-semibold text-lg",children:d(!u&&j?"viewEvent":j?"editEvent":"newEvent")}),u&&ae("button",{onClick:()=>{if(!l)return;let e=new Date(b),t=new Date(D);v&&(e.setHours(0,0,0,0),t.setHours(0,0,0,0));const r=Object.assign(Object.assign({},l),{title:g,calendarId:p,allDay:v,start:x(e),end:x(t)});n(r)},disabled:!V,className:"font-bold px-2 py-1 transition-colors "+(V?"text-primary":"text-gray-400 cursor-not-allowed opacity-50"),children:d(j?"done":"create")}),!u&&ae("span",{className:"w-12"})]}),ae("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[ae("div",{className:"bg-white dark:bg-gray-900 rounded-lg px-4 py-3",children:ae("input",{type:"text",placeholder:d("titlePlaceholder"),value:g,onChange:e=>u&&m(e.target.value),readOnly:!u,className:"w-full bg-transparent text-xl font-medium placeholder-gray-400 focus:outline-none",autoFocus:u})}),F.length>0&&ae("div",{className:"bg-white dark:bg-gray-900 rounded-lg px-4 py-3 flex justify-between items-center relative",children:[ae("span",{className:"text-gray-700 dark:text-gray-300",children:d("calendar")}),ae(nt,{options:z,value:p,onChange:u?f:()=>{},registry:s.getCalendarRegistry(),variant:"mobile",disabled:!u})]}),ae("div",{className:"bg-white dark:bg-gray-900 rounded-lg px-4 py-3 flex justify-between items-center",children:[ae("span",{className:"text-gray-700 dark:text-gray-300",children:d("allDay")}),ae(Sn,{checked:v,onChange:u?y:()=>{},disabled:!u})]}),ae("div",{className:"bg-white dark:bg-gray-900 rounded-lg overflow-hidden",children:[ae("div",{className:"flex justify-between items-center px-4 py-3 border-b border-gray-100 dark:border-gray-800 last:border-0",children:[ae("span",{className:"text-gray-700 dark:text-gray-300",children:d("starts")}),ae("div",{className:"flex space-x-2",children:[ae("button",{className:"px-3 py-1 rounded-md transition-colors "+("start-date"===R?"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(b)}),!v&&ae("button",{className:"px-3 py-1 rounded-md transition-colors "+("start-time"===R?"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:A(b.getHours()+b.getMinutes()/60)})]})]}),ae("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("start-date"===R?"max-h-100":"max-h-0"),children:ae("div",{className:"",children:ae(Tn,{currentDate:b,visibleMonth:S,onDateSelect:e=>Z("start",e),onMonthChange:e=>U("start",e),showHeader:!0})})}),ae("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("start-time"===R?"max-h-75":"max-h-0"),children:ae("div",{className:"",children:ae(Mn,{date:b,onChange:e=>{const t=D.getTime()-b.getTime();w(e),C(new Date(e.getTime()+t))}})})})]}),ae("div",{className:"bg-white dark:bg-gray-900 rounded-lg overflow-hidden",children:[ae("div",{className:"flex justify-between items-center px-4 py-3 border-b border-gray-100 dark:border-gray-800 last:border-0",children:[ae("span",{className:"text-gray-700 dark:text-gray-300",children:d("ends")}),ae("div",{className:"flex space-x-2",children:[ae("button",{className:"px-3 py-1 rounded-md transition-colors "+("end-date"===R?"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(D)}),!v&&ae("button",{className:"px-3 py-1 rounded-md transition-colors "+("end-time"===R?"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:A(D.getHours()+D.getMinutes()/60)})]})]}),ae("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("end-date"===R?"max-h-100":"max-h-0"),children:ae("div",{className:"",children:ae(Tn,{currentDate:D,visibleMonth:N,onDateSelect:e=>Z("end",e),onMonthChange:e=>U("end",e),showHeader:!0})})}),ae("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("end-time"===R?"max-h-75":"max-h-0"),children:ae("div",{className:"",children:ae(Mn,{date:D,onChange:e=>{if(e<b){const t=D.getTime()-b.getTime();C(e),w(new Date(e.getTime()-t))}else C(e)}})})})]}),ae("div",{className:"bg-white dark:bg-gray-900 rounded-lg px-4 py-3",children:ae("textarea",{placeholder:d("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&&j&&o&&l&&ae("button",{onClick:()=>o(l.id),className:"w-full bg-white dark:bg-gray-900 rounded-lg px-4 py-3 text-red-500 font-medium text-left",children:d("delete")})]})]})]}),document.body)};let In=null;const Rn={enabled:!1,width:"0px",isCollapsed:!1,toggleCollapsed:()=>{},miniWidth:"0px",content:null,extraContent:null,safeAreaLeft:0};function Hn(e){return In&&e.hasPlugin("sidebar")?In(e):Rn}const On=({locale:e,messages:t,children:r})=>Tt().isDefault?ae(St,{locale:e,messages:t,children:r}):ae(n.Fragment,{children:r}),Pn=({app:e,customDetailPanelContent:t,customEventDetailDialog:l,meta:s,customMessages:i,search:d,titleBarSlot:c,collapsedSafeAreaLeft:u})=>{const h=r.useContext(ne),{tick:g,selectedEventId:m}=function(e){const[t,n]=r.useState(0),[a,o]=r.useState(null);return r.useEffect(()=>e.subscribe(e=>{n(e=>e+1),o(t=>{var n;const r=null!==(n=e.state.selectedEventId)&&void 0!==n?n:null;return t!==r?r:t})}),[e]),{tick:t,selectedEventId:a}}(e),{isMobile:p}=function(){const[e,t]=r.useState(!1);return r.useEffect(()=>{const e=()=>{t(window.matchMedia("(max-width: 768px)").matches)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),{isMobile:e}}(),f=function(e,t){const[n,a]=r.useState(""),[l,s]=r.useState(!1),[i,d]=r.useState(!1),[c,u]=r.useState(!1),[h,g]=r.useState([]);r.useEffect(()=>{e.state.highlightedEventId&&e.selectEvent(e.state.highlightedEventId)},[e.state.highlightedEventId,e]),r.useEffect(()=>{l||null===e.state.highlightedEventId||e.highlightEvent(null)},[l,e]),r.useEffect(()=>{var r;if(!n.trim())return s(!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,l=setTimeout(()=>o.__awaiter(this,void 0,void 0,function*(){var r;u(!0),s(!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{u(!1)}}),a);return()=>clearTimeout(l)},[n,t,e]);const m=r.useCallback(t=>{let n;n=t.start instanceof Date?t.start:"string"==typeof t.start?new Date(t.start):E(t.start),e.setCurrentDate(n),e.highlightEvent(t.id),i&&d(!1)},[e,i]),p=r.useCallback(()=>{a(""),d(!0)},[]),f=r.useCallback(()=>{s(!1),a(""),e.highlightEvent(null)},[e]),v=r.useCallback(()=>{d(!1),a(""),e.highlightEvent(null)},[e]);return{searchKeyword:n,setSearchKeyword:a,isSearchOpen:l,setIsSearchOpen:s,isMobileSearchOpen:i,setIsMobileSearchOpen:d,searchLoading:c,searchResults:h,handleSearchResultClick:m,handleSearchClick:p,handleSearchClose:f,handleMobileSearchClose:v}}(e,d),v=l||(e.getUseEventDetailDialog()?At:void 0),y=function(e,t,n){const[a,o]=r.useState(null);r.useEffect(()=>{o(null)},[e]);const l=r.useCallback(()=>{o(null),e.selectEvent(null)},[e]),s=r.useCallback(t=>e.updateEvent(t.id,t),[e]),i=r.useCallback(t=>{e.deleteEvent(t),o(null),e.selectEvent(null)},[e]),d=r.useMemo(()=>{if(!t||!a)return null;const n=a.split("::")[0],r=e.getEvents().find(e=>e.id===n);return r?{event:r,isOpen:!0,isAllDay:w(r.start),onEventUpdate:s,onEventDelete:i,onClose:l,app:e}:null},[n,a,t,l,s,i,e]);return{detailPanelEventId:a,setDetailPanelEventId:o,dialogProps:d}}(e,v,g),b=Hn(e),D=function(e,t,n){const[a,o]=r.useState(!1),l=r.useRef(null),[s,i]=r.useState(!1),[d,c]=r.useState(null),[u,h]=r.useState(!1),g=r.useCallback(()=>{h(!0)},[]),m=r.useCallback(r=>{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:Q(),title:"",start:x(t),end:x(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 c(r),void i(!0)}n?a?o(!1):(l.current=r.currentTarget,o(!0)):g()}},[t,a,e,n,g]);return{isQuickCreateOpen:a,setIsQuickCreateOpen:o,quickCreateAnchorRef:l,isMobileDrawerOpen:s,setIsMobileDrawerOpen:i,mobileDraftEvent:d,setMobileDraftEvent:c,handleAddButtonClick:m,isCreateCalendarOpen:u,setIsCreateCalendarOpen:h}}(e,p,b.enabled),[C,k]=r.useState(()=>e.getTheme());r.useEffect(()=>e.subscribeThemeChange(e=>k(e)),[e]);const T=r.useCallback(t=>e.setTheme(t),[e]);r.useEffect(()=>{const t=e.callbacks,n=t.onDismissUI;return t.onDismissUI=()=>{y.detailPanelEventId&&y.setDetailPanelEventId(null),D.isMobileDrawerOpen&&D.setIsMobileDrawerOpen(!1),null==n||n()},()=>{t.onDismissUI=n}},[e,y,D]),r.useEffect(()=>{if(!p||!y.detailPanelEventId)return;const t=y.detailPanelEventId.split("::")[0],n=e.getEvents().find(e=>e.id===t);n&&(D.setMobileDraftEvent(n),D.setIsMobileDrawerOpen(!0)),y.setDetailPanelEventId(null)},[y.detailPanelEventId,p]);const S=r.useCallback(t=>{e.setCurrentDate(t),e.selectEvent(null)},[e]),M=r.useCallback(t=>e.selectEvent(t),[e]),N=r.useRef(null),I={app:e,config:e.getCurrentView().config||{},customDetailPanelContent:t,customEventDetailDialog:v,switcherMode:e.state.switcherMode,calendarRef:N,meta:s,selectedEventId:m,onEventSelect:M,onDateChange:S,detailPanelEventId:y.detailPanelEventId,onDetailPanelToggle:y.setDetailPanelEventId},R=r.useMemo(()=>({isCollapsed:b.isCollapsed,toggleCollapsed:b.toggleCollapsed}),[b.isCollapsed,b.toggleCollapsed]),H=null!=u?"0px":b.miniWidth,O=null!=u&&b.isCollapsed?u:b.safeAreaLeft,P=e.getCalendarHeaderConfig(),L=Object.assign({calendar:e,switcherMode:e.state.switcherMode,onAddCalendar:D.handleAddButtonClick,onSearchChange:f.setSearchKeyword,onSearchClick:f.handleSearchClick,searchValue:f.searchKeyword,isSearchOpen:f.isSearchOpen,isEditable:!e.state.readOnly},O>0?{safeAreaLeft:O}:{}),A=e.getCurrentView().component,$=e.getCustomMobileEventRenderer()||Nn;return ae(Dn,{initialTheme:C,onThemeChange:T,children:ae(On,{locale:e.state.locale,messages:i,children:ae("div",{className:"df-calendar-container relative flex flex-row overflow-hidden select-none",children:[ae(hn,{store:h,generatorName:"titleBarSlot",generatorArgs:R,defaultContent:c&&("function"==typeof c?c(R):c)}),b.enabled&&ae("aside",{className:"absolute top-0 bottom-0 left-0 z-0 h-full",style:{width:b.width},children:b.content}),ae("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 "+(b.isCollapsed?"border-gray-200 dark:border-gray-700 shadow-xl":"border-transparent"),style:{marginLeft:b.enabled?b.isCollapsed?H:b.width:0},children:[!1===P?null:"function"==typeof P?P(L):n.h(gn,L),ae("div",{className:"flex-1 overflow-hidden relative",ref:N,children:[ae("div",{className:"calendar-renderer h-full relative flex flex-row",children:[ae("div",{className:"flex-1 h-full overflow-hidden",children:ae(A,Object.assign({},I))}),ae(fn,{isOpen:f.isSearchOpen,onClose:f.handleSearchClose,loading:f.searchLoading,results:f.searchResults,keyword:f.searchKeyword,onResultClick:f.handleSearchResultClick,emptyText:null==d?void 0:d.emptyText})]}),ae(vn,{isOpen:f.isMobileSearchOpen,onClose:f.handleMobileSearchClose,keyword:f.searchKeyword,onSearchChange:f.setSearchKeyword,results:f.searchResults,loading:f.searchLoading,onResultClick:f.handleSearchResultClick,emptyText:null==d?void 0:d.emptyText})]})]}),ae(yn,{app:e,anchorRef:D.quickCreateAnchorRef,isOpen:D.isQuickCreateOpen,onClose:()=>D.setIsQuickCreateOpen(!1)}),ae($,{isOpen:D.isMobileDrawerOpen,onClose:()=>{D.setIsMobileDrawerOpen(!1),D.setMobileDraftEvent(null)},onSave:t=>{e.getEvents().some(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),D.setIsMobileDrawerOpen(!1),D.setMobileDraftEvent(null)},onEventDelete:t=>{e.deleteEvent(t),D.setIsMobileDrawerOpen(!1),D.setMobileDraftEvent(null)},draftEvent:D.mobileDraftEvent,app:e}),b.extraContent,D.isCreateCalendarOpen&&ae(kn,{onClose:()=>D.setIsCreateCalendarOpen(!1),onCreate:t=>{e.createCalendar(t),D.setIsCreateCalendarOpen(!1)}}),(()=>{if(!y.dialogProps)return null;const e=v,t="undefined"!=typeof document?document.body:null;if(!t)return null;const r=null==h?void 0:h.isOverridden("eventDetailDialog");return ae(hn,{store:h,generatorName:"eventDetailDialog",generatorArgs:y.dialogProps,defaultContent:r?null:a.createPortal(n.h(e,y.dialogProps),t)})})()]})})})};const Ln=({originalComponent:e,app:t,config:n,customDetailPanelContent:a,customEventDetailDialog:l,calendarRef:s,switcherMode:i,meta:d,selectedEventId:c,detailPanelEventId:u,onEventSelect:h,onDateChange:g,onDetailPanelToggle:m})=>{const p=t.getPlugin("events"),f=n.enableDrag?t.getPlugin("drag"):void 0,v=t.getCurrentDate(),y=t.state.currentView,b=t.getEvents(),w=r.useCallback(e=>{p?p.update(e.id,e):t.updateEvent(e.id,e)},[p,t]),x=r.useCallback(e=>{p?p.delete(e):t.deleteEvent(e)},[p,t]),D=r.useCallback(e=>{p?p.add(e):t.addEvent(e)},[p,t]),E=r.useCallback(e=>{g?g(e):t.setCurrentDate(e)},[t,g]),C=r.useCallback(e=>{t.changeView(e)},[t]),k=r.useMemo(()=>{const{dragConfig:e,eventsConfig:t,virtualScrollConfig:r}=n,a=o.__rest(n,["dragConfig","eventsConfig","virtualScrollConfig"]),l=Object.assign({},a);return f&&Object.assign(l,e||{}),p&&Object.assign(l,t||{}),l},[n,f,p]),T=r.useMemo(()=>({app:t,currentDate:v,currentView:y,events:b,onEventUpdate:w,onEventDelete:x,onEventCreate:D,onDateChange:E,onViewChange:C,config:k,customDetailPanelContent:a,customEventDetailDialog:l,calendarRef:s,switcherMode:i,meta:d,selectedEventId:c,detailPanelEventId:u,onEventSelect:h,onDetailPanelToggle:m}),[t,v,y,b,w,x,D,E,C,k,a,l,s,i,d,c,u,h,m]),S=r.useMemo(()=>{const e={currentDate:v,events:b,setEvents:e=>{b.forEach(e=>x(e.id)),e.forEach(e=>D(e))},updateEvent:w,deleteEvent:x,addEvent:D,goToPrevious:()=>{const e=new Date(v);switch(y){case exports.ViewType.DAY:e.setDate(e.getDate()-1);break;case exports.ViewType.WEEK:e.setDate(e.getDate()-7);break;case exports.ViewType.MONTH:e.setMonth(e.getMonth()-1)}E(e)},goToNext:()=>{const e=new Date(v);switch(y){case exports.ViewType.DAY:e.setDate(e.getDate()+1);break;case exports.ViewType.WEEK:e.setDate(e.getDate()+7);break;case exports.ViewType.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:p,dragService:f})},[v,b,y,w,x,D,E,C,T,p,f]);return ae(e,Object.assign({},S))},An={PARALLEL_THRESHOLD:.25,NESTED_THRESHOLD:.5,INDENT_STEP_PERCENT:2.5,MIN_WIDTH:25,MARGIN_BETWEEN:1,EDGE_MARGIN_PERCENT:.9};function $n(e){return Object.assign(Object.assign({},e),{parentId:void 0,children:[],_startHour:e.allDay?0:N(e.start),_endHour:e.allDay?0:j(e)})}function jn(e){var t;return null!==(t=e._startHour)&&void 0!==t?t:N(e.start)}function Yn(e){var t;return null!==(t=e._endHour)&&void 0!==t?t:j(e)}function Fn(e,t){return e.day===t.day&&!e.allDay&&!t.allDay&&(jn(e)<Yn(t)&&jn(t)<Yn(e))}function zn(e,t){const n=Yn(e)-jn(e);if(n<1.25)return!1;const r=jn(e)+.4*n,a=jn(t)>=r,o=Fn(e,t);return a&&o}function Vn(e,t,n=An){if(!Fn(e,t))return!1;const r=Math.abs(jn(e)-jn(t));return r<=n.PARALLEL_THRESHOLD||(r>n.PARALLEL_THRESHOLD&&r<n.NESTED_THRESHOLD||function(e,t){return!(!Fn(e,t)||!zn(e,t)&&!zn(t,e))}(e,t))}function _n(e,t){const n=jn(e)<=jn(t)&&Yn(e)>=Yn(t),r=jn(e)<=jn(t)&&jn(t)<Yn(e)&&Fn(e,t);return n||r}function Wn(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(jn(r)-jn(t))<=An.PARALLEL_THRESHOLD&&(a.push(t),n.add(t.id))}a.sort((e,t)=>jn(e)-jn(t));const o={events:a,startHour:Math.min(...a.map(e=>jn(e))),endHour:Math.max(...a.map(e=>Yn(e)))};t.push(o)}return t.sort((e,t)=>e.startHour-t.startHour),t}function Zn(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:Un(e)})).sort((e,t)=>t.load-e.load)}function Un(e){let t=0;for(const n of e.children)t+=1+Un(n);return t}function Bn(e){return!(e.length<2)&&e[0].load-e[e.length-1].load>=2}function qn(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=Gn(n.node,r.node);if(!a)break;Xn(a,r.node),n.load--,r.load++,t++}}function Gn(e,t){const n=[];return Kn(e,n),n.find(e=>_n(t.event,e.event))||n[0]||null}function Kn(e,t){0===e.children.length?t.push(e):e.children.forEach(e=>Kn(e,t))}function Xn(e,t){e.parent&&(e.parent.children=e.parent.children.filter(t=>t!==e));const n=t.children.find(t=>_n(t.event,e.event));n?(e.parent=n,e.depth=n.depth+1,n.children.push(e),Jn(n.event,e.event)):(e.parent=t,e.depth=t.depth+1,t.children.push(e),Jn(t.event,e.event))}function Jn(e,t){t.parentId=e.id,e.children.includes(t.id)||e.children.push(t.id)}function Qn(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 s=!1;for(let i=n-1;i>=0&&!s;i--){const n=e[i],d={events:n.events.map(e=>a.get(e.id)),startHour:n.startHour,endHour:n.endHour};if(er(d,{events:l,startHour:o.startHour,endHour:o.endHour})){const e=tr(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)}s=!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=Zn(e[n].events.map(e=>t.find(t=>t.event.id===e.id)),t);Bn(r)&&qn(r)}}(e,n),o}function er(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(!Fn(n,e))continue;if(Math.abs(jn(e)-jn(n))<An.NESTED_THRESHOLD)return!0}return!1}(e,t))return!1;if(n<An.NESTED_THRESHOLD)return!1;for(const n of e.events)for(const e of t.events)if(_n(n,e))return!0;return!1}function tr(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=rr(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=>_n(t,e)));if(0===o.length){for(const o of e){const e=rr(o,t,n);e&&(r.push({child:o,parent:e}),a(e,o))}return r}const l=[...e].sort((e,t)=>Yn(t)-jn(t)-(Yn(e)-jn(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],s=l.slice(t*e,(t+1)*e);for(const e of s)r.push({child:e,parent:n}),a(n,e)}}else for(const e of l){const t=nr(e,o,l);t&&(r.push({child:e,parent:t}),a(t,e))}return r}function nr(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=Yn(e)-jn(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?Yn(t)-jn(t):0}),0)?a[0]:a[a.length-1]}function rr(e,t,n){const r=t.events.filter(t=>_n(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&&Vn(e,r,An)})}));return a.sort((t,n)=>t.load!==n.load?t.load-n.load:t.hasParallelSibling!==n.hasParallelSibling?t.hasParallelSibling?-1:1:Math.abs(jn(e)-jn(t.parent))-Math.abs(jn(e)-jn(n.parent))),a[0].parent}function ar(e,t,n={}){const r=100-("day"===n.viewType?0:An.EDGE_MARGIN_PERCENT);if(1===e.length)lr(e[0],0,r,t,n);else if(e.length>1){const a=e.length,o=(r-An.MARGIN_BETWEEN*(a-1))/a;e.forEach((e,r)=>{lr(e,r*(o+An.MARGIN_BETWEEN),Math.max(o,An.MIN_WIDTH),t,n)})}}function or(e){return"day"===e?.5:2.5}function lr(e,t,n,r,a={}){const o=or(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*or(t):null}(e,a.viewType);null!==t&&(l=t)}const s="day"===a.viewType;let i=0;1===e.depth?i=s?.5:1.5:2===e.depth?i=s?-.01:-1:e.depth>=3&&(i=s?.55:-3.5);const d=t+l+i;let c=n-(l+i);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:dr(e.event)}),0===e.children.length)return;const u=[...e.children].sort((e,t)=>Yn(t.event)-jn(t.event)-(Yn(e.event)-jn(e.event)));1===u.length?lr(u[0],d,c,r,a):ir(u.map(e=>e.event))?sr(u,d,c,r,a):u.forEach(e=>lr(e,d,c,r,a))}function sr(e,t,n,r,a={}){const o=e.length,l=e[0].depth,s=l*or(a.viewType),i="day"===a.viewType;let d=1===l?i?.5:1.5:2===l?i?-.01:-1:i?.55:-3.5;const c=t+s+d,u=n-(s+d);if(u<=0)return void e.forEach(e=>lr(e,t,n,r,a));let h=An.MARGIN_BETWEEN*(1===l?i?.15:.3:i?.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:s*(a.containerWidth||320)/100,importance:dr(e.event)}),e.children.length>0){const t=[...e.children].sort((e,t)=>Yn(t.event)-jn(t.event)-(Yn(e.event)-jn(e.event)));1===t.length?lr(t[0],n,g,r,a):ir(t.map(e=>e.event))?sr(t,n,g,r,a):t.forEach(e=>lr(e,n,g,r,a))}})}function ir(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(Vn(e[t],e[n],An))return!0;return!1}function dr(e){const t=Yn(e)-jn(e);return Math.max(.1,Math.min(1,t/4))}class cr{static calculateDayEventLayouts(e,t={}){const n=e.map($n);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)||Fn(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:An.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{ar(Qn(Wn([...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 ur=null;const hr={handleMoveStart:()=>{},handleCreateStart:()=>{},handleResizeStart:void 0,handleCreateAllDayEvent:()=>{},dragState:{active:!1,mode:null,eventId:null,targetDate:null,startDate:null,endDate:null},isDragging:!1};function gr(e,t){return ur?ur(e,t):hr}const mr={HOUR_HEIGHT:72,FIRST_HOUR:0,LAST_HOUR:24,ALL_DAY_HEIGHT:28};function pr(e){const{app:n,onEventCreated:a}=e,{t:o}=Tt(),l=r.useCallback(e=>{e.dataTransfer.types.includes("application/x-dayflow-calendar")&&(e.preventDefault(),e.dataTransfer.dropEffect="copy")},[]);return{handleDrop:r.useCallback((e,r,l,s)=>{e.preventDefault();const i=e.dataTransfer.getData("application/x-dayflow-calendar");if(!i)return null;try{const e=JSON.parse(i);let d,c,u=!1;s?(d=t.Temporal.PlainDateTime.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate(),hour:0,minute:0}),c=t.Temporal.PlainDateTime.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate(),hour:23,minute:59,second:59}),u=!0):void 0!==l?(d=t.Temporal.PlainDateTime.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate(),hour:l,minute:0}),c=d.add({hours:1})):(d=t.Temporal.PlainDateTime.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate(),hour:9,minute:0}),c=d.add({hours:1}));const h={id:`event-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,title:o(u?"newAllDayCalendarEvent":"newCalendarEvent",{calendarName:e.calendarName}),description:"",start:d,end:c,calendarId:e.calendarId,allDay:u};return n.addEvent(h),null==a||a(h),h}catch(e){return console.error("Error creating event from calendar drop:",e),null}},[n,a]),handleDragOver:l}}const fr=({handlePreviousMonth:e,handleToday:t,handleNextMonth:n})=>{const{t:r}=Tt();return ae("div",{className:"df-navigation flex items-center gap-1",children:[ae("button",{className:Ve,onClick:e,"aria-label":"Previous month",children:ae(oe,{className:_e})}),ae("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")}),ae("button",{className:Ve,onClick:n,"aria-label":"Next month",children:ae(le,{className:_e})})]})},vr=({app:e,currentDate:t,visibleMonth:n,currentDayEvents:r,selectedEvent:a,setSelectedEvent:o,handleMonthChange:l,handleDateSelect:s,switcherMode:i})=>{const{t:d,locale:c}=Tt(),u=[...r].sort((e,t)=>e.allDay&&!t.allDay?-1:!e.allDay&&t.allDay?1:0);return ae("div",{className:"df-right-panel hidden md:block flex-none w-[30%] bg-white dark:bg-gray-900",onContextMenu:e=>e.preventDefault(),children:ae("div",{className:`${Qe} h-full`,children:[ae("div",{className:"df-mini-calendar px-2 border-b border-gray-200 dark:border-gray-700",children:ae("div",{children:[ae("div",{className:"flex items-center justify-end gap-2",children:[ae("div",{className:Ce,style:{position:"relative"},children:ae("div",{children:ae("h1",{className:ke,children:" "})})}),ae(fr,{handlePreviousMonth:()=>e.goToPrevious(),handleNextMonth:()=>e.goToNext(),handleToday:()=>e.goToToday()})]}),ae(Tn,{visibleMonth:n,currentDate:t,showHeader:!0,onMonthChange:l,onDateSelect:s})]})}),ae("div",{className:"flex-1 overflow-y-auto",children:ae("div",{className:"p-4",children:[ae("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?ae("p",{className:`${Ge} ${Je}`,children:d("noEvents")}):ae("div",{className:"space-y-2",children:u.map(t=>ae("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:L(t.calendarId||"blue")},onClick:()=>{o(t),e.onEventClick(t)},children:[ae("div",{className:`font-medium ${Je}`,children:t.title}),!t.allDay&&ae("div",{className:`${Xe} ${Ke}`,children:[A(N(t.start))," -"," ",A(j(t))]}),t.allDay&&ae("div",{className:`${Xe} ${Ke}`,children:d("allDay")})]},t.id))})]})})]})})},yr=({viewType:e,currentDate:t,onPrevious:n,onNext:r,onToday:a,customTitle:o,customSubtitle:l,showTodayBox:s,stickyYear:i,stickyYearOffset:d=0,nextYear:c,nextYearOffset:u=0})=>{const{locale:h}=Tt(),g=void 0===s||s,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""}})(),p="day"===e?l||("day"===e?t.toLocaleDateString(h,{weekday:"long"}):null):null;return ae("div",{className:Ce,style:{position:"relative"},onContextMenu:e=>e.preventDefault(),children:[ae("div",{className:"flex-1",children:ae("div","year"===e&&i?{style:{position:"relative",overflow:"hidden",height:"1.5em"},children:[ae("h1",{className:ke,style:{position:"absolute",top:0,left:0,transform:`translateY(-${d}px)`,willChange:"transform"},children:i}),c&&ae("h1",{className:ke,style:{position:"absolute",top:0,left:0,transform:`translateY(${u}px)`,willChange:"transform"},children:c})]}:{children:[ae("div",{className:`${ke} text-gray-900 dark:text-white`,children:m}),p&&ae("div",{className:"mt-3 text-gray-600 dark:text-gray-400",children:p})]})}),g&&n&&r&&a&&ae("div",{className:"flex items-center gap-2",children:ae(fr,{handlePreviousMonth:n,handleNextMonth:r,handleToday:a})})]})},br=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("假期")?ae(ye,{className:"h-3 w-3"}):t.includes("birthday")||t.includes("anniversary")||t.includes("生日")?ae(be,{className:"h-3 w-3"}):t.includes("conference")||t.includes("meeting")||t.includes("会议")||t.includes("研讨")?ae(xe,{className:"h-3 w-3"}):t.includes("trip")||t.includes("travel")||t.includes("旅行")?ae(we,{className:"h-3 w-3"}):ae(pe,{className:"h-3 w-3"})},wr=(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=E(e.start),o=E(e.end),l=new Date(a);l.setHours(0,0,0,0);const s=new Date(o);s.setHours(0,0,0,0);let i=new Date(s);if(!e.allDay){if(!(0!==o.getHours()||0!==o.getMinutes()||0!==o.getSeconds())){const e=o.getTime()-a.getTime();e>0&&e<864e5&&(i=new Date(s),i.setDate(i.getDate()-1))}}const d=M(l,i)>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(s),u.setHours(23,59,59,999);else{0!==o.getHours()||0!==o.getMinutes()||0!==o.getSeconds()?(u=new Date(s),u.setHours(23,59,59,999)):(u=new Date(s),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)),p=Math.min(6,Math.floor((g.getTime()-t.getTime())/864e5)),f=c>=t,v=u<=r,y=0===m||6===p;let b;b=f&&v?"single":f?y&&6===p?"start-week-end":"start":v?y&&0===m?"end-week-start":"end":"middle";const w=M(c,u)+1;n.push({id:`${e.id}-week-${t.getTime()}`,originalEventId:e.id,event:e,startDayIndex:m,endDayIndex:p,segmentType:b,totalDays:w,segmentIndex:0,isFirstSegment:f,isLastSegment:v})}),n},xr=(e,t)=>{if(e.allDay)return[];const n=E(e.start),r=E(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=M(a,o);if(0===l)return[];const s=0!==r.getHours()||0!==r.getMinutes()||0!==r.getSeconds()||0!==r.getMilliseconds(),i=r.getTime()-n.getTime();if(!e.allDay&&1===l&&!s&&i<864e5)return[];const d=s?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 i=0===e,u=e===d,h=i?n.getHours()+n.getMinutes()/60:0,g=u&&s?r.getHours()+r.getMinutes()/60:24;c.push({dayIndex:l,startHour:h,endHour:g,isFirst:i,isLast:u})}return c},Dr=a.memo(({segment:e,segmentIndex:t,isDragging:a,isResizing:o=!1,isSelected:l=!1,onMoveStart:s,onResizeStart:i,onEventLongPress:d,isMobile:c=!1,isDraggable:u=!0,isEditable:h=!0,viewable:g=!0,isPopping:m})=>{const[p,f]=r.useState(!1),v=17*t,y=`calc(${e.startDayIndex/7*100}% + 2px)`,b=`calc(${(e.endDayIndex-e.startDayIndex+1)/7*100}% - 4px)`,w=r.useRef(null),x=r.useRef(null),D=t=>{const n="left"===t;return(n?e.isFirstSegment:e.isLastSegment)&&i&&h?ae("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},E=e.event.calendarId||"blue",C=e.endDayIndex-e.startDayIndex+1;return ae("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:y,width:b,top:`${v}px`,height:"16px",borderRadius:(k=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"}[k]),pointerEvents:"auto",zIndex:10,transform:m?"scale(1.02)":"scale(1)",transition:"transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)",willChange:"transform"},l||a||p?{backgroundColor:P(E),color:"#fff"}:{backgroundColor:H(E),color:O(E)}),{cursor:u||g?"pointer":"default"}),"data-segment-days":C,onMouseDown:t=>{if(!u&&!g)return;t.preventDefault(),t.stopPropagation(),f(!0);!t.target.closest(".resize-handle")&&u&&s(t,e.event)},onMouseUp:()=>{f(!1)},onMouseLeave:()=>{f(!1)},onTouchStart:t=>{if(!s||!c||!u&&!g)return;t.stopPropagation(),f(!0);const n=t.touches[0],r=n.clientX,a=n.clientY,o=t.currentTarget;x.current={x:r,y:a},w.current=setTimeout(()=>{d&&d(e.event.id);u&&s({preventDefault:()=>{},stopPropagation:()=>{},currentTarget:o,touches:[{clientX:r,clientY:a}],cancelable:!1},e.event),w.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},onTouchMove:e=>{if(w.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(w.current),w.current=null,x.current=null,f(!1))}},onTouchEnd:()=>{f(!1),w.current&&(clearTimeout(w.current),w.current=null),x.current=null},title:`${e.event.title} (${jt(e.event.start)} - ${jt(e.event.end)})`,children:[c&&l&&h&&ae(n.Fragment,{children:[e.isFirstSegment&&ae("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:L(E)}}),e.isLastSegment&&ae("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:L(E)}})]}),D("left"),ae("div",{className:"flex-1 min-w-0",style:{cursor:o?"ew-resize":"pointer"},children:(()=>{const t=e.event.allDay,n=e.event.calendarId||"blue",r=N(e.event.start),a=j(e.event),o=A(r),l=A(a);if(t){const t=()=>e.isFirstSegment?e.event.title:"middle"===e.segmentType||e.isLastSegment&&e.totalDays>1?"···":e.event.title;return ae("div",{className:"flex items-center min-w-0 w-full pointer-events-auto",children:[e.isFirstSegment&&br(e.event)&&ae("div",{className:"shrink-0 mr-1",children:ae("div",{className:"rounded-full p-0.5 text-white flex items-center justify-center",style:{backgroundColor:L(n),width:"12px",height:"12px"},children:br(e.event)})}),ae("div",{className:"flex-1 min-w-0",children:ae("div",{className:"truncate text-xs",children:t()})}),e.isLastSegment&&"single"!==e.segmentType&&ae("div",{className:"shrink-0 ml-1 text-white/80 dark:text-white/90",children:ae("div",{className:"w-1.5 h-1.5 rounded-full bg-white/60 dark:bg-white/80"})})]})}const s=e.isFirstSegment||e.isLastSegment?e.event.title:"···",i=e.endDayIndex-e.startDayIndex+1,d=i>1?{position:"absolute",right:`calc(${i>1?(i-1)/i*100:0}% + 2px)`,top:"50%",transform:"translateY(-50%)"}:void 0;return ae("div",{className:"relative flex items-center min-w-0 w-full pointer-events-auto",children:[ae("div",{className:je,style:{backgroundColor:L(n)}}),ae("div",{className:"flex items-center min-w-0 flex-1",children:ae("span",{className:`whitespace-nowrap overflow-hidden block ${c?"mobile-mask-fade":"truncate"} font-medium text-xs`,children:s})}),e.isFirstSegment&&!c&&ae("span",{className:"text-xs font-medium whitespace-nowrap "+(1===i?"ml-2":""),style:d,children:o}),e.isLastSegment&&!e.event.allDay&&24!==a&&!c&&ae("span",{className:"text-xs font-medium whitespace-nowrap ml-auto",children:`ends ${l}`})]})})()}),D("right")]});var k});Dr.displayName="MultiDayEvent";const Er=({event:e,position:n,panelRef:o,isAllDay:l,eventVisibility:s,calendarRef:i,selectedEventElementRef:d,onEventUpdate:c,onEventDelete:u,app:g})=>{var m;const{effectiveTheme:p}=En(),f=Ft(p),{t:v}=Tt(),[y,b]=r.useState(e.title),[x,D]=r.useState(null!==(m=e.description)&&void 0!==m?m:"");r.useEffect(()=>{b(e.title)},[e.title]),r.useEffect(()=>{var t;D(null!==(t=e.description)&&void 0!==t?t:"")},[e.description]),r.useEffect(()=>{const t=setTimeout(()=>{y!==e.title&&c(Object.assign(Object.assign({},e),{title:y}))},500);return()=>clearTimeout(t)},[y,e]),r.useEffect(()=>{const t=setTimeout(()=>{var t;const n=null!==(t=e.description)&&void 0!==t?t:"";x!==n&&c(Object.assign(Object.assign({},e),{description:x}))},500);return()=>clearTimeout(t)},[x,e]);const E="dark"===f||"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)",S=r.useMemo(()=>(g?g.getCalendarRegistry():h()).getVisible().map(e=>({label:e.name,value:e.id})),[g,null==g?void 0:g.getCalendars()]),M=r.useMemo(()=>w(e.start)?e.end&&!w(e.end)&&(e.end.timeZoneId||e.end.timeZoneId)||t.Temporal.Now.timeZoneId():e.start.timeZoneId||e.start.timeZoneId||t.Temporal.Now.timeZoneId(),[e.end,e.start]),N=(()=>{var e;let t={};if("sticky-top"===s){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: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"===s){const e=o.current;let r=200;if(e){const t=e.getBoundingClientRect(),n=window.getComputedStyle(e),a=parseInt(n.paddingBottom,10)||0,o=parseInt(n.borderBottomWidth,10)||0;r=t.height-a-o-6+11}t={position:"absolute",width:"12px",height:"12px",backgroundColor:k,transform:"rotate(45deg)",transformOrigin:"center",top:`${r}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&&d.current&&i.current){const e=d.current.getBoundingClientRect(),r=i.current.querySelector(".calendar-content");if(r){const a=r.getBoundingClientRect(),l=Math.max(e.top,a.top),s=Math.min(e.bottom,a.bottom),i=Math.max(0,s-l);let d;d=i===e.height?e.top+e.height/2:i>0?l+i/2:e.top+e.height/2;const c=d-n.top,u=o.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=ae("div",{ref:o,className:`${We} p-4`,"data-event-detail-panel":"true","data-event-id":e.id,style:{top:`${n.top}px`,left:`${n.left}px`,zIndex:9999,pointerEvents:"auto"},children:[ae("div",{style:N}),ae("span",{className:"block text-xs text-gray-600 dark:text-gray-300 mb-1",children:v("eventTitle")}),ae("div",{className:"flex items-center justify-between gap-3 mb-3",children:[ae("div",{className:"flex-1",children:ae("input",{id:`event-title-${e.id}`,name:"title",type:"text",value:y,readOnly:!C,disabled:!C,onChange:e=>b(e.target.value),onInput:e=>b(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&&ae(nt,{options:S,value:e.calendarId||"blue",onChange:t=>{c(Object.assign(Object.assign({},e),{calendarId:t}))},registry:null==g?void 0:g.getCalendarRegistry()})]}),ae("div",l?{className:"mb-3",children:[ae("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-1",children:v("dateRange")}),ae(Lt,{value:[e.start,e.end],format:"YYYY-MM-DD",showTime:!1,timeZone:M,matchTriggerWidth:!0,disabled:!C,onChange:t=>{const[n,r]=t;c(Object.assign(Object.assign({},e),{start:n.toPlainDate(),end:r.toPlainDate()}))},locale:null==g?void 0:g.state.locale})]}:{className:"mb-3",children:[ae("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-1",children:v("timeRange")}),ae(Lt,{value:[e.start,e.end],timeZone:M,disabled:!C,onChange:t=>{const[n,r]=t;c(Object.assign(Object.assign({},e),{start:n,end:r}))},locale:null==g?void 0:g.state.locale})]}),ae("div",{className:"mb-3",children:[ae("span",{className:"block text-xs text-gray-600 dark:text-gray-300 mb-1",children:v("note")}),ae("textarea",{id:`event-note-${e.id}`,name:"note",value:x,readOnly:!C,disabled:!C,onChange:e=>D(e.target.value),onInput:e=>D(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:v("addNotePlaceholder")})]}),C&&ae("div",{className:"flex space-x-2",children:[ae("button",l?{className:"px-2 py-1 bg-primary text-primary-foreground rounded hover:bg-primary text-xs font-medium transition",onClick:()=>{const n=w(e.start)?e.start:e.start.toPlainDate(),r=t.Temporal.ZonedDateTime.from({year:n.year,month:n.month,day:n.day,hour:9,minute:0,timeZone:t.Temporal.Now.timeZoneId()}),a=t.Temporal.ZonedDateTime.from({year:n.year,month:n.month,day:n.day,hour:10,minute:0,timeZone:t.Temporal.Now.timeZoneId()});c(Object.assign(Object.assign({},e),{allDay:!1,start:r,end:a}))},children:v("setAsTimed")}:{className:"px-2 py-1 bg-primary text-primary-foreground rounded hover:bg-primary text-xs font-medium transition",onClick:()=>{const t=w(e.start)?e.start:e.start.toPlainDate();c(Object.assign(Object.assign({},e),{allDay:!0,start:t,end:t}))},children:v("setAsAllDay")}),ae("button",{className:"px-2 py-1 bg-destructive text-destructive-foreground rounded hover:bg-destructive/90 text-xs font-medium transition",onClick:()=>u(e.id),children:v("delete")})]})]});if("undefined"==typeof window||"undefined"==typeof document)return null;const R=document.body;return R?a.createPortal(I,R):null},Cr=({event:e,position:t,panelRef:n,isAllDay:r,eventVisibility:o,calendarRef:l,selectedEventElementRef:s,onEventUpdate:i,onEventDelete:d,onClose:c,contentRenderer:u})=>{const{effectiveTheme:h}=En(),g=Ft(h),m="dark"===g?"#1f2937":"white",p="dark"===g?"rgb(55, 65, 81)":"rgb(229, 231, 235)",f=(()=>{var e;let r={};if("sticky-top"===o){const n=null===(e=l.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 ${p}`:"none"),borderTop:""+(t.isSunday?`1px solid ${p}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${p}`),borderBottom:""+(t.isSunday?"none":`1px solid ${p}`)},t.isSunday?{right:"-6px"}:{left:"-6px"})}}else if("sticky-bottom"===o){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: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 ${p}`:"none"),borderTop:""+(t.isSunday?`1px solid ${p}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${p}`),borderBottom:""+(t.isSunday?"none":`1px solid ${p}`)}}else if(t&&s.current&&l.current){const e=s.current.getBoundingClientRect(),a=l.current.querySelector(".calendar-content");if(a){const o=a.getBoundingClientRect(),l=Math.max(e.top,o.top),s=Math.min(e.bottom,o.bottom),i=Math.max(0,s-l);let d;d=i===e.height?e.top+e.height/2:i>0?l+i/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 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 ${p}`:"none"),borderTop:""+(t.isSunday?`1px solid ${p}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${p}`),borderBottom:""+(t.isSunday?"none":`1px solid ${p}`)},t.isSunday?{right:"-6px"}:{left:"-6px"})}}return r})(),v=ae("div",{ref:n,className:`${We} 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:[ae("div",{style:f}),ae(u,{event:e,isAllDay:r,onEventUpdate:i,onEventDelete:d,onClose:c})]});return a.createPortal(v,document.body)},kr=({event:e,app:t,isEventSelected:n,hideTime:r,isMobile:a})=>{const o=`${Math.floor(N(e.start)).toString().padStart(2,"0")}:${Math.round(N(e.start)%1*60).toString().padStart(2,"0")}`;return ae("div",{className:"text-xs cursor-pointer flex items-center justify-between",children:[ae("div",{className:"flex items-center flex-1 min-w-0",children:[ae("div",{style:{backgroundColor:L(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())},className:je}),ae("span",{className:`whitespace-nowrap overflow-hidden block ${a?"mobile-mask-fade":"truncate"} ${n?"text-white":""}`,children:e.title})]}),!r&&!a&&ae("span",{className:`${Xe} ml-1 shrink-0 ${n?"text-white":""}`,style:n?void 0:{opacity:.8},children:o})]})},Tr=({event:e,isEventSelected:t})=>{const n=!1!==e.icon,r="boolean"!=typeof e.icon?e.icon:null;return ae("div",{className:"text-xs px-1 rounded truncate cursor-pointer flex items-center",children:[n&&(r?ae("div",{className:`${et} shrink-0`,children:r}):e.title.toLowerCase().includes("easter")||e.title.toLowerCase().includes("holiday")?ae("span",{className:`inline-block ${et} shrink-0 ${t?"text-yellow-200":"text-yellow-600"}`,children:"⭐"}):ae(pe,{className:`${Ye} ${t?"text-white":""}`})),ae("span",{className:"truncate "+(t?"text-white":""),children:e.title})]})},Sr=({event:e,isEditable:t,onResizeStart:n})=>{const r=!1!==e.icon,a="boolean"!=typeof e.icon?e.icon:null;return ae("div",{className:"h-full flex items-center overflow-hidden pl-3 px-1 py-0 relative group",children:[n&&t&&ae("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?ae("div",{className:"mr-1 shrink-0",children:a}):ae(pe,{className:Ye})),ae("div",{className:`${$e} pr-1`,style:{lineHeight:"1.2"},children:e.title}),n&&t&&ae("div",{className:Fe,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),n(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]})},Mr=({event:e,app:t,multiDaySegmentInfo:r,isEditable:a,isTouchEnabled:o,isEventSelected:l,onResizeStart:s})=>{const i=r?r.startHour:N(e.start),d=r?r.endHour:j(e),c=d-i,u=!r||r.isFirst,h=!r||r.isLast,g=e.calendarId||"blue";return ae(n.Fragment,{children:[ae("div",{className:"df-event-color-bar absolute left-1 top-1 bottom-1 w-[3px] rounded-full",style:{backgroundColor:L(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())}}),ae("div",{className:"h-full flex flex-col overflow-hidden pl-3 "+(j(e)-N(e.start)<=.25?"px-1 py-0":"p-1"),children:[ae("div",{className:`${$e} pr-1`,style:{lineHeight:c<=.25?"1.2":"normal"},children:e.title}),c>.5&&ae("div",{className:"df-event-time text-xs opacity-80 truncate",children:r?`${A(i)} - ${A(d)}`:$(e)})]}),s&&a&&ae(n.Fragment,{children:[u&&ae("div",{className:"absolute top-0 left-0 w-full h-1.5 cursor-ns-resize z-10 rounded-t-sm",onMouseDown:t=>s(t,e,"top")}),h&&ae("div",{className:"absolute bottom-0 left-0 w-full h-1.5 cursor-ns-resize z-10 rounded-b-sm",onMouseDown:t=>s(t,e,"bottom")}),!u&&h&&r&&ae("div",{className:Fe,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),s(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]}),o&&l&&s&&a&&ae(n.Fragment,{children:[ae("div",{className:"absolute -top-1.5 right-5 w-2.5 h-2.5 bg-white border-2 rounded-full z-50",style:{borderColor:L(g,null==t?void 0:t.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),s(t,e,"top")}}),ae("div",{className:"absolute -bottom-1.5 left-5 w-2.5 h-2.5 bg-white border-2 rounded-full z-50",style:{borderColor:L(g,null==t?void 0:t.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),s(t,e,"bottom")}})]})]})},Nr=a.forwardRef(({x:e,y:t,onClose:n,children:o,className:l},s)=>{const i=r.useRef(null);r.useEffect(()=>{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]);const d={top:t,left:e};return a.createPortal(ae("div",{ref:e=>{i.current=e,"function"==typeof s?s(e):s&&(s.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 ${l||""}`,style:d,onContextMenu:e=>e.preventDefault(),"data-context-menu-root":"true",children:o}),document.body)});Nr.displayName="ContextMenu";const Ir=({onClick:e,children:t,icon:n,danger:r,disabled:a})=>ae("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&&ae("span",{className:"mr-2 h-4 w-4",children:n}),t]}),Rr=()=>ae("div",{className:"-mx-1 my-1 h-px bg-slate-200 dark:bg-slate-800"}),Hr=({children:e})=>{const[t,a]=r.useState(!1),o=r.useRef(null);return r.useEffect(()=>()=>{o.current&&clearTimeout(o.current)},[]),ae("div",{className:"relative",onMouseEnter:()=>{o.current&&(clearTimeout(o.current),o.current=null),a(!0)},onMouseLeave:()=>{o.current=setTimeout(()=>{a(!1)},100)},children:(Array.isArray(e)?e:[e]).map(e=>n.isValidElement(e)?n.cloneElement(e,{isOpen:t}):e)})},Or=({children:e,icon:t,isOpen:n})=>ae("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&&ae("span",{className:"mr-2 h-4 w-4",children:t}),ae("span",{className:"grow text-left",children:e}),ae(le,{className:"ml-auto h-4 w-4 "+(n?"text-white opacity-100":"opacity-60")})]}),Pr=({children:e,isOpen:t})=>{const n=r.useRef(null),[a,o]=r.useState("right");return r.useEffect(()=>{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?o("left"):o("right"))}},[t]),t?ae("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"===a?"100%":"auto",right:"left"===a?"100%":"auto",marginLeft:"right"===a?"0.25rem":0,marginRight:"left"===a?"0.25rem":0},"data-submenu-content":"true",children:e}):null},Lr=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],Ar=({x:e,y:n,date:r,onClose:a,app:l,onCreateEvent:s,viewType:i})=>{const{t:d}=Tt(),c=Gt.hasEvent();return ae(Nr,{x:e,y:n,onClose:a,children:[ae(Ir,{onClick:()=>{s(),a()},children:d("newEvent")||"New Event"}),ae(Ir,{onClick:()=>o.__awaiter(void 0,void 0,void 0,function*(){yield((e,n,r)=>o.__awaiter(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&&a.title){const l=lt(a.start),s=lt(a.end).getTime()-l.getTime(),i=a,{_segmentInfo:d}=i,c=o.__rest(i,["_segmentInfo"]),u=new Date(n),h=r===exports.ViewType.MONTH||r===exports.ViewType.YEAR,g=0===u.getHours()&&0===u.getMinutes(),m=0!==l.getHours()||0!==l.getMinutes();!a.allDay&&(h||g&&m)&&u.setHours(l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds());const p=new Date(u.getTime()+(s>0?s:36e5)),f=Object.assign(Object.assign({},c),{id:Q(),start:a.allDay?st(u):dt(u,t.Temporal.Now.timeZoneId()),end:a.allDay?st(p):dt(p,t.Temporal.Now.timeZoneId()),calendarId:a.calendarId&&e.getCalendarRegistry().has(a.calendarId)?a.calendarId:e.getCalendarRegistry().getDefaultCalendarId()||"default"});e.addEvent(f)}}catch(e){console.error("Failed to paste event:",e)}}))(l,r,i),a()}),disabled:!c,children:d("pasteHere")||"Paste Here"})]})},$r=({event:e,x:t,y:r,onClose:a,app:l})=>{var s,i;const{t:d}=Tt(),c=l.getCalendars(),u=null===(i=null===(s=l.callbacks)||void 0===s?void 0:s.renderEventContextMenu)||void 0===i?void 0:i.call(s,e,a);return ae(Nr,{x:t,y:r,onClose:a,children:[ae(Hr,{children:[ae(Or,{children:d("calendars")||"Calendars"}),ae(Pr,{children:c.map(t=>{const n=t.id===e.calendarId;return ae(Ir,{onClick:()=>{return n=t.id,l.updateEvent(e.id,{calendarId:n}),void a();var n},children:ae("div",{className:"flex items-center w-full",children:[ae("div",{className:"w-4 shrink-0",children:n&&ae(he,{className:"w-3 h-3 text-primary"})}),ae("div",{className:"flex items-center gap-1.5 min-w-0",children:[ae("div",{className:"w-3 h-3 rounded-sm shrink-0",style:{backgroundColor:t.colors.lineColor}}),ae("span",{className:"truncate "+(n?"font-semibold":""),children:t.name})]})]})},t.id)})})]}),ae(Rr,{}),ae(Ir,{onClick:()=>{l.deleteEvent(e.id),a()},danger:!0,children:d("delete")||"Delete"}),ae(Ir,{onClick:()=>o.__awaiter(void 0,void 0,void 0,function*(){try{const t=JSON.stringify(e,null,2);yield navigator.clipboard.writeText(t),Gt.setEvent(e),l.deleteEvent(e.id)}catch(e){console.error("Failed to cut event: ",e)}a()}),children:d("cut")||"Cut"}),ae(Ir,{onClick:()=>o.__awaiter(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:d("copy")||"Copy"}),u&&ae(n.Fragment,{children:[ae(Rr,{}),u]})]})},jr=(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 Le;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 Le};if(e){let e=`\n ${o}\n ${n?l():Ae}\n `;return r||(e+=" mb-[2px]"),e}return`\n ${o}\n shadow-sm\n ${n?l():Ae}\n `},Yr=({event:e,layout:t,isAllDay:a=!1,allDayHeight:o=28,calendarRef:l,isBeingDragged:s=!1,isBeingResized:i=!1,isDayView:d=!1,isMonthView:c=!1,isMultiDay:u=!1,segment:h,segmentIndex:g=0,hourHeight:m,firstHour:p,selectedEventId:f,detailPanelEventId:v,onMoveStart:y,onResizeStart:b,onEventUpdate:w,onEventDelete:x,newlyCreatedEventId:D,onDetailPanelOpen:E,onEventSelect:C,onEventLongPress:k,onDetailPanelToggle:T,customDetailPanelContent:S,customEventDetailDialog:M,multiDaySegmentInfo:I,app:R,isMobile:L=!1,enableTouch:A,hideTime:$})=>{const Y=r.useContext(ne),F=null!=A?A:L,[z,V]=r.useState(null),[_,W]=r.useState(!1),[Z,U]=r.useState(null),B=r.useRef(null),q=r.useRef(null),G=r.useRef(null),K=r.useRef(null),X=u&&h?`${e.id}::${h.id}`:void 0!==(null==I?void 0:I.dayIndex)?`${e.id}::day-${I.dayIndex}`:e.id,J=v===X,Q=J&&!M,ee=null==R?void 0:R.getReadOnlyConfig(),te=!(null==R?void 0:R.state.readOnly),re=!1!==(null==ee?void 0:ee.viewable),oe=!1!==(null==ee?void 0:ee.draggable),{isSelected:le,setIsSelected:se,isPressed:ie,setIsPressed:de,handleTouchStart:ce,handleTouchMove:ue,handleTouchEnd:he}=(({event:e,isTouchEnabled:t,onMoveStart:n,onEventLongPress:a,onEventSelect:o,onDetailPanelToggle:l,canOpenDetail:s,app:i,multiDaySegmentInfo:d,isMultiDay:c,segment:u,detailPanelKey:h})=>{const[g,m]=r.useState(!1),[p,f]=r.useState(!1),v=r.useRef(null),y=r.useRef(null);return{isSelected:g,setIsSelected:m,isPressed:p,setIsPressed:f,handleTouchStart:r=>{if(!n||!t)return;r.stopPropagation(),f(!0);const o=r.touches[0],l=o.clientX,s=o.clientY,i=r.currentTarget;y.current={x:l,y:s},v.current=setTimeout(()=>{var t;a?a(e.id):m(!0);const r={preventDefault:()=>{},stopPropagation:()=>{},currentTarget:i,touches:[{clientX:l,clientY:s}],cancelable:!1};if(d){const a=Object.assign(Object.assign({},e),{day:null!==(t=d.dayIndex)&&void 0!==t?t:e.day,_segmentInfo:d});n(r,a)}else if(c&&u){const t=Object.assign(Object.assign({},e),{day:u.startDayIndex,_segmentInfo:{dayIndex:u.startDayIndex,isFirst:u.isFirstSegment,isLast:u.isLastSegment}});n(r,t)}else n(r,e);v.current=null,y.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},handleTouchMove:e=>{if(v.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(v.current),v.current=null,y.current=null,f(!1))}},handleTouchEnd:n=>{f(!1),v.current&&(clearTimeout(v.current),v.current=null),t&&y.current&&(n.preventDefault(),n.stopPropagation(),o?o(e.id):s&&m(!0),i&&i.onEventClick(e),s?null==l||l(h):null==l||l(null)),y.current=null}}})({event:e,isTouchEnabled:F,onMoveStart:y,onEventLongPress:k,onEventSelect:C,onDetailPanelToggle:T,canOpenDetail:re,app:R,multiDaySegmentInfo:I,isMultiDay:u,segment:h,detailPanelKey:X}),ge=(void 0!==f?f===e.id:le)||ie||s,[me,pe]=r.useState("visible"),fe=e=>{K.current=e},ve=()=>((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,v||void 0,X,K.current,I,h),ye=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,s=r?1:7,i=(o.width-l)/s,d=e-o.left-l,c=Math.floor(d/i);return Number.isFinite(c)?Math.max(0,Math.min(s-1,c)):null})(e,l,c,d,L),be=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 s=(o.width-l)/7;return{left:o.left+l+e*s,width:s}})(e,l,c,d,L),we=r.useCallback(()=>{if(!G.current||!l.current||!q.current)return;const t=l.current.getBoundingClientRect(),n=ve(),r=be(n);let a,o;if(r)a=r.left,o=r.width;else if(c)o=t.width/7,a=t.left+n*o;else{const e=L?48:80;o=(t.width-e)/7,a=t.left+e+n*o}const s=Math.min(window.innerWidth,t.right),i=Math.min(window.innerHeight,t.bottom);requestAnimationFrame(()=>{var r,o,g,f;if(!q.current)return;if(!G.current)return;const v=q.current.getBoundingClientRect(),y=v.width,b=v.height;let w,x,D;if("sticky-top"===me||"sticky-bottom"===me){const t=null===(r=l.current)||void 0===r?void 0:r.querySelector(".calendar-content");if(!t)return;const n=I?I.startHour:N(e.start),a=I?I.endHour:j(e),s=(n-p)*m,i=Math.max((a-n)*m,m/4),d=t.getBoundingClientRect(),c=t.scrollTop,u=d.top+s-c,h=null===(o=B.current)||void 0===o?void 0:o.getBoundingClientRect();if(!h)return;D={top:u,bottom:u+i,left:h.left,right:h.right,width:h.width,height:i,x:h.x,y:u,toJSON:()=>({})}}else D=G.current.getBoundingClientRect();if(c&&u&&h){const e=be(n),r=null!==(g=null==e?void 0:e.width)&&void 0!==g?g:t.width/7,a=null!==(f=null==e?void 0:e.left)&&void 0!==f?f:t.left+n*r,o=a+r;D={top:D.top,bottom:D.bottom,left:a,right:o,width:o-a,height:D.height,x:a,y:D.top,toJSON:()=>({})}}if(("sticky-top"===me||"sticky-bottom"===me)&&!c){const e=ve(),n=be(e),r=L?48:80,a=n?n.left:t.left+r+e*(t.width-r)/(d?1:7),o=n?n.width:(t.width-r)/(d?1:7),l=Math.max(0,d?D.width:o-3),s=d?D.left:a;D=Object.assign(Object.assign({},D),{left:s,right:s+l,width:l})}const E=s-D.right,C=D.left-t.left;w=E>=y+20?D.right+10:C>=y+20?D.left-y-10:E>C?Math.max(t.left+10,s-y-10):t.left+10;const k=D.top-b/2+D.height/2,T=Math.max(10,t.top+10),S=i-10;x=k<T?T:k+b>S?S-b:k,U(e=>e?Object.assign(Object.assign({},e),{top:x,left:w,isSunday:w<a}):null)})},[l,e.day,e.start,e.end,me,c,p,m,u,h,I,v,X,L,d]);(({event:e,isEventSelected:t,showDetailPanel:n,eventRef:a,calendarRef:o,isAllDay:l,isMonthView:s,multiDaySegmentInfo:i,firstHour:d,hourHeight:c,updatePanelPosition:u,setEventVisibility:h})=>{const g=r.useCallback(()=>{if(!t||!n||!a.current||!o.current||l||s)return;const r=o.current.querySelector(".calendar-content");if(!r)return;const g=i?i.startHour:N(e.start),m=i?i.endHour:j(e),p=(g-d)*c,f=p+Math.max((m-g)*c,c/4),v=r.getBoundingClientRect(),y=r.scrollTop;let b=f<y+6,w=p>y+v.height-6;const x=v.bottom<0,D=v.top>window.innerHeight;x?b=!0:D&&(w=!0),h(b?"sticky-top":w?"sticky-bottom":"visible"),u()},[t,n,o,l,s,e.start,e.end,d,c,u,i]);r.useEffect(()=>{var e,r;if(!t||!n||l)return;const a=null===(e=o.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(!a)return;const s=()=>g(),i=()=>{g(),u()},d=[a];let c=null===(r=o.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",s)}),window.addEventListener("scroll",s,!0),window.addEventListener("resize",i);let h=null;return o.current&&(h=new ResizeObserver(()=>{i()}),h.observe(o.current)),g(),()=>{d.forEach(e=>{e.removeEventListener("scroll",s)}),window.removeEventListener("scroll",s,!0),window.removeEventListener("resize",i),h&&h.disconnect()}},[t,n,l,g,u,o])})({event:e,isEventSelected:ge,showDetailPanel:J,eventRef:B,calendarRef:l,isAllDay:a,isMonthView:c,multiDaySegmentInfo:I,firstHour:p,hourHeight:m,updatePanelPosition:we,setEventVisibility:pe});const xe=J&&!!M;(({eventRef:e,detailPanelRef:t,eventId:n,isEventSelected:a,showDetailPanel:o,onEventSelect:l,onDetailPanelToggle:s,setIsSelected:i,setActiveDayIndex:d})=>{r.useEffect(()=>{if(!a&&!o)return;const r=r=>{var c,u;const h=r.target,g=null===(c=e.current)||void 0===c?void 0:c.contains(h),m=null!==h.closest(`[data-event-id="${n}"]`),p=null===(u=t.current)||void 0===u?void 0:u.contains(h),f=h.closest("[data-event-detail-dialog]"),v=h.closest("[data-range-picker-popup]"),y=h.closest("[data-calendar-picker-dropdown]");o?g||m||p||f||v||y||(null==l||l(null),d(null),i(!1),null==s||s(null)):!a||g||m||f||v||y||(null==l||l(null),d(null),i(!1),null==s||s(null))};return document.addEventListener("mousedown",r),()=>{document.removeEventListener("mousedown",r)}},[a,o,l,s,n])})({eventRef:B,detailPanelRef:q,eventId:e.id,isEventSelected:!xe&&ge,showDetailPanel:Q,onEventSelect:C,onDetailPanelToggle:T,setIsSelected:se,setActiveDayIndex:fe});const De=r.useCallback(()=>{C&&C(null),K.current=null,se(!1),null==T||T(null)},[C,T]),Ee=r.useMemo(()=>({event:e,isAllDay:a,onEventUpdate:w,onEventDelete:x,onClose:De}),[e,a,w,x,De]),Ce=r.useMemo(()=>({event:e,isAllDay:a,isMobile:L,isMonthView:c,segment:h,layout:t}),[e,a,L,c,h,t]),ke=r.useCallback(()=>ae(hn,{store:Y,generatorName:"eventDetailContent",generatorArgs:Ee}),[Y,Ee]);r.useEffect(()=>{!J||Z||L||(U({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>we()))},[J,Z,we,L]),r.useEffect(()=>{if((null==R?void 0:R.state.highlightedEventId)===e.id){W(!0);const e=setTimeout(()=>{W(!1)},300);return()=>{clearTimeout(e),W(!1)}}},[null==R?void 0:R.state.highlightedEventId,e.id]);const Te=e.calendarId||"blue",Se=null==R?void 0:R.getCalendarRegistry();return ae(n.Fragment,{children:[ae("div",{ref:B,"data-event-id":e.id,className:jr(c,d,a,u,h),style:Object.assign(Object.assign({},(()=>{var n,r,s,i,f,v,y,b;if(c)return u&&h?{opacity:1,zIndex:ge||J?1e3:1,cursor:oe||re?"pointer":"default"}:{opacity:1,zIndex:ge||J?1e3:1,transform:_?"scale(1.05)":"scale(1)",transition:"transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)",cursor:oe||re?"pointer":"default"};if(a){const e={height:o-4+"px",opacity:1,zIndex:ge||J?1e3:1,transform:_?"scale(1.05)":"scale(1)",transition:"transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)",cursor:oe||re?"pointer":"default"},t=g*o;if(Object.assign(e,{top:`${t}px`}),d)Object.assign(e,{width:"100%",left:"0px",right:"2px",position:"absolute"});else if(u&&h){const t=(h.endDayIndex-h.startDayIndex+1)/7*100,n=h.startDayIndex/7*100,r=2,a=h.isFirstSegment?r:0,o=a+(h.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 w=I?I.startHour:N(e.start),x=I?I.endHour:j(e),D={top:`${(w-p)*m+3}px`,height:Math.max((x-w)*m,m/4)-4+"px",position:"absolute",opacity:1,zIndex:ge||J?1e3:null!==(n=null==t?void 0:t.zIndex)&&void 0!==n?n:1,transform:_?"scale(1.05)":"scale(1)",transition:"transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)",cursor:oe||re?"pointer":"default"};if(ge&&J&&("sticky-top"===me||"sticky-bottom"===me)){const e=null===(r=l.current)||void 0===r?void 0:r.getBoundingClientRect();if(e){const n=ve(),r=L?48:80,a=d?1:7;let o=(e.width-r)/a,u=e.left+r+(d?0:n*o);c&&(o=e.width/7,u=e.left+n*o);const h=be(n);h&&(u=h.left,o=h.width);let g=null===(s=l.current)||void 0===s?void 0:s.querySelector(".calendar-content");g||(g=null===(i=l.current)||void 0===i?void 0:i.querySelector(".calendar-renderer"));const m=null==g?void 0:g.getBoundingClientRect(),p=null===(v=null===(f=B.current)||void 0===f?void 0:f.parentElement)||void 0===v?void 0:v.getBoundingClientRect();let w,x;if(p&&p.width>0)t?(w=p.left+t.left/100*p.width,x=d?t.width/100*p.width:(t.width-1)/100*p.width):(w=p.left,x=d?p.width:p.width-3);else{const e=be(n),r=null!==(y=null==e?void 0:e.left)&&void 0!==y?y:u,a=null!==(b=null==e?void 0:e.width)&&void 0!==b?b:o;w=r,x=a-3,t&&(w=r+t.left/100*a,x=d?t.width/100*a:(t.width-1)/100*a)}if("sticky-top"===me){let t=m?m.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:`${x}px`,height:"6px",zIndex:1e3,overflow:"hidden"}}let D=m?m.bottom:e.bottom;return D=Math.min(D,window.innerHeight),D=Math.min(D,e.bottom),D=Math.max(D,e.top+6),D=Math.max(D,6),{position:"fixed",top:D-6+"px",left:`${w}px`,width:`${x}px`,height:"6px",zIndex:1e3,overflow:"hidden"}}}if(t&&!a){const e=d?`${t.width}%`:t.width-1+"%";return Object.assign(Object.assign({},D),{left:`${t.left}%`,width:e,right:"auto"})}return Object.assign(Object.assign({},D),{left:"0px",right:d?"0px":"3px"})})()),{backgroundColor:ge?P(Te,Se):H(Te,Se),color:ge?"#fff":O(Te,Se)}),onClick:F?void 0:t=>{var n,r,a;if(t.preventDefault(),t.stopPropagation(),u){const a=ye(t.clientX);fe(null!==a?h?Math.min(Math.max(a,h.startDayIndex),h.endDayIndex):a:null!==(r=null!==(n=null==I?void 0:I.dayIndex)&&void 0!==n?n:e.day)&&void 0!==r?r:null)}else fe(null!==(a=e.day)&&void 0!==a?a:null);R&&R.onEventClick(e),C?C(e.id):re&&se(!0),null==T||T(null),U(null)},onContextMenu:F?void 0:t=>{t.preventDefault(),t.stopPropagation(),C&&C(e.id),V({x:t.clientX,y:t.clientY})},onDblClick:F?void 0:t=>{var n,r,o,s,i;if(!re)return;t.preventDefault(),t.stopPropagation();let d=t.currentTarget;if(u){const e=d.querySelector("div");e&&(d=e)}if(G.current=d,u){const a=ye(t.clientX);fe(null!==a?Math.min(Math.max(a,null!==(n=null==h?void 0:h.startDayIndex)&&void 0!==n?n:0),null!==(r=null==h?void 0:h.endDayIndex)&&void 0!==r?r:6):null!==(s=null!==(o=null==h?void 0:h.startDayIndex)&&void 0!==o?o:e.day)&&void 0!==s?s:0)}else fe(null!==(i=e.day)&&void 0!==i?i:null);new Promise(t=>{if(!l.current||a||c)return void t();const n=l.current.querySelector(".calendar-content");if(!n)return void t();const r=I?I.startHour:N(e.start),o=I?I.endHour:j(e),s=(r-p)*m,i=s+Math.max((o-r)*m,m/4),d=n.scrollTop,u=n.clientHeight;if(s>=d&&i<=d+u)return void t();const h=((r+o)/2-p)*m-u/2,g=n.scrollHeight-u;n.scrollTo({top:Math.max(0,Math.min(g,h)),behavior:"smooth"}),setTimeout(()=>t(),300)}).then(()=>{se(!0),L||(null==T||T(X),U({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>we()))})},onMouseDown:t=>{var n;F||de(!0),y&&y(t,I?Object.assign(Object.assign({},e),{day:null!==(n=I.dayIndex)&&void 0!==n?n:e.day,_segmentInfo:I}):u&&h?Object.assign(Object.assign({},e),{day:h.startDayIndex,_segmentInfo:{dayIndex:h.startDayIndex,isFirst:h.isFirstSegment,isLast:h.isLastSegment}}):e)},onMouseUp:()=>!F&&de(!1),onMouseLeave:()=>!F&&de(!1),onTouchStart:ce,onTouchMove:ue,onTouchEnd:he,children:(()=>{let t;return t=c?u&&h?ae(Dr,{segment:h,segmentIndex:null!=g?g:0,isDragging:s||ge,isResizing:i,isSelected:ge,onMoveStart:y||(()=>{}),onResizeStart:b,isMobile:L,isDraggable:oe,isEditable:te,viewable:re,isPopping:_}):e.allDay?ae(Tr,{event:e,isEventSelected:ge}):ae(kr,{event:e,app:R,isEventSelected:ge,hideTime:$,isMobile:L}):e.allDay?ae(Sr,{event:e,isEditable:te,onResizeStart:b}):ae(Mr,{event:e,app:R,multiDaySegmentInfo:I,isEditable:te,isTouchEnabled:F,isEventSelected:ge,onResizeStart:b}),ae(hn,{store:Y,generatorName:"eventContent",generatorArgs:Ce,defaultContent:t})})()}),J&&!M&&ae("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:9998,pointerEvents:"none"}}),(()=>{if(!J)return null;if(M)return null;if(!Z)return null;const t={event:e,position:Z,panelRef:q,isAllDay:a,eventVisibility:me,calendarRef:l,selectedEventElementRef:G,onEventUpdate:w,onEventDelete:x,onClose:De};return(null==Y?void 0:Y.isOverridden("eventDetailContent"))?ae(Cr,Object.assign({},t,{contentRenderer:ke})):S?ae(Cr,Object.assign({},t,{contentRenderer:S})):ae(Er,Object.assign({},t,{app:R}))})(),z&&R&&ae($r,{event:e,x:z.x,y:z.y,onClose:()=>V(null),app:R,onDetailPanelToggle:T,detailPanelKey:X})]})},Fr=({app:e,currentDate:t,currentWeekStart:n,events:a,currentDayEvents:o,organizedAllDayEvents:l,allDayAreaHeight:s,timeSlots:i,eventLayouts:d,isToday:c,currentTime:u,selectedEventId:h,setSelectedEventId:g,newlyCreatedEventId:m,setNewlyCreatedEventId:p,detailPanelEventId:f,setDetailPanelEventId:v,dragState:y,isDragging:b,handleMoveStart:w,handleResizeStart:x,handleCreateStart:D,handleCreateAllDayEvent:E,handleTouchStart:C,handleTouchEnd:k,handleTouchMove:T,handleDragOver:S,handleDrop:M,handleEventUpdate:N,handleEventDelete:I,onDateChange:R,customDetailPanelContent:H,customEventDetailDialog:O,calendarRef:P,allDayRowRef:L,switcherMode:$,isMobile:j,isTouch:Y,setDraftEvent:F,setIsDrawerOpen:z,ALL_DAY_HEIGHT:V,HOUR_HEIGHT:_,FIRST_HOUR:W,LAST_HOUR:Z,showAllDay:U,showStartOfDayLabel:B})=>{const{t:q,locale:G}=Tt(),K=r.useRef(e.state.highlightedEventId),[X,J]=r.useState(null),Q=Yt(),ee=()=>{var e;const t=null===(e=P.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},te=(e,n)=>{var r,a,o,l;if(e.preventDefault(),j)return;const s=new Date(t);if(n)s.setHours(0,0,0,0);else{const t=null===(a=null===(r=P.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=P.current)||void 0===o?void 0:o.querySelector(".calendar-content"))||void 0===l?void 0:l.scrollTop)||0,r=ee(),a=(e.clientY-t.top+n-r)/_+W,i=Math.floor(a),d=Math.floor(60*(a-i)),c=15*Math.round(d/15),u=60===c?i+1:i,h=60===c?0:c;s.setHours(u,h,0,0)}}J({x:e.clientX,y:e.clientY,date:s})};return ae("div",{className:`flex-none ${"buttons"===$?"":"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:[ae("div",{className:`relative ${Qe} h-full`,children:[ae("div",{onContextMenu:e=>e.preventDefault(),style:{paddingRight:j||!Q?"0px":"15px"},children:ae(yr,{calendar:e,viewType:exports.ViewType.DAY,currentDate:t,customSubtitle:t.toLocaleDateString(G,{weekday:"long"})})}),ae("div",U?{className:tt(Pe,"border-t border-gray-200 dark:border-gray-700 items-stretch"),ref:L,style:{paddingRight:j||!Q?"0px":"0.6875rem"},onContextMenu:e=>te(e,!0),children:[ae("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:q("allDay")}),ae("div",{className:tt("flex flex-1 relative self-stretch",!j&&Q?"border-r border-gray-200 dark:border-gray-700":""),children:ae("div",{className:"w-full relative",style:{minHeight:`${s}px`},onClick:()=>null==R?void 0:R(t),onMouseDown:e=>{const r=Math.floor((t.getTime()-n.getTime())/864e5);null==E||E(e,r)},onDblClick:e=>{const r=Math.floor((t.getTime()-n.getTime())/864e5);null==E||E(e,r)},onDragOver:S,onDrop:e=>{M(e,t,void 0,!0)},children:l.map(t=>ae(Yr,{event:t,isAllDay:!0,isDayView:!0,segmentIndex:t.row,allDayHeight:V,calendarRef:P,isBeingDragged:b&&(null==y?void 0:y.eventId)===t.id&&"move"===(null==y?void 0:y.mode),hourHeight:_,firstHour:W,onMoveStart:w,onEventUpdate:N,onEventDelete:I,newlyCreatedEventId:m,onDetailPanelOpen:()=>p(null),detailPanelEventId:f,onDetailPanelToggle:e=>v(e),selectedEventId:h,onEventSelect:t=>{const n=!1!==e.getReadOnlyConfig().viewable,r=e.state.readOnly,o=a.find(e=>e.id===t);(j||Y)&&o&&n&&!r?(F(o),z(!0)):(g(t),e.state.highlightedEventId&&(e.highlightEvent(null),K.current=null))},onEventLongPress:e=>{(j||Y)&&g(e)},customDetailPanelContent:H,customEventDetailDialog:O,app:e,isMobile:j,enableTouch:Y},t.id))})})]}:{className:tt("border-b border-gray-200 dark:border-gray-700",!j&&Q?"pr-2.75":"")}),ae("div",{className:"relative overflow-y-auto calendar-content df-day-time-grid",style:{position:"relative",scrollbarGutter:"stable"},children:ae("div",{className:"relative flex",children:[c&&u&&(()=>{const e=u,t=e.getHours()+e.getMinutes()/60;if(t<W||t>Z)return null;return ae("div",{className:He,style:{top:`${(t-W)*_}px`,width:"100%",height:0,zIndex:20,marginTop:"0.75rem"},children:[ae("div",{className:"flex items-center w-12 md:w-20",children:[ae("div",{className:"relative w-full flex items-center"}),ae("div",{className:Oe,children:A(t)})]}),ae("div",{className:"flex-1 flex items-center",children:ae("div",{className:"df-current-time-bar h-0.5 w-full bg-primary relative"})})]})})(),ae("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:[ae("div",{className:"h-3"}),i.map((e,t)=>ae("div",{className:Ne,children:ae("div",{className:`${Ie} text-[10px] md:text-[12px]`,children:B&&0===t?"":e.label})},t))]}),ae("div",{className:"grow select-none",children:[ae("div",{className:tt(Ue,!j&&Q?"border-r":"","border-t-0"),children:ae("div",{className:`${Be} -left-9.5`,style:{top:"auto",bottom:"-0.625rem"},children:B?A(W):""})}),ae("div",{className:"relative",style:{WebkitTouchCallout:"none"},children:[i.map((e,r)=>ae("div",{className:tt(Re,!j&&Q?"border-r":""),onClick:()=>null==R?void 0:R(t),onDblClick:e=>{var r,a,o,l;const s=Math.floor((t.getTime()-n.getTime())/864e5),i=null===(a=null===(r=P.current)||void 0===r?void 0:r.querySelector(".calendar-content"))||void 0===a?void 0:a.getBoundingClientRect();if(!i)return;const d=(null===(l=null===(o=P.current)||void 0===o?void 0:o.querySelector(".calendar-content"))||void 0===l?void 0:l.scrollTop)||0,c=ee(),u=e.clientY-i.top+d-c;null==D||D(e,s,W+u/_)},onTouchStart:e=>{const r=Math.floor((t.getTime()-n.getTime())/864e5);C(e,r)},onTouchEnd:k,onTouchMove:T,onDragOver:S,onDrop:e=>{var n,r,a,o;const l=null===(r=null===(n=P.current)||void 0===n?void 0:n.querySelector(".calendar-content"))||void 0===r?void 0:r.getBoundingClientRect();if(!l)return;const s=(null===(o=null===(a=P.current)||void 0===a?void 0:a.querySelector(".calendar-content"))||void 0===o?void 0:o.scrollTop)||0,i=ee(),d=e.clientY-l.top+s-i,c=Math.floor(W+d/_);M(e,t,c)},onContextMenu:e=>te(e,!1)},r)),ae("div",{className:tt(Ue,!j&&Q?"border-r":""),children:ae("div",{className:`${Be} -left-9.5`,children:"00:00"})}),ae("div",{className:"absolute top-0 left-0 right-0 bottom-0 pointer-events-none",children:o.filter(e=>!e.allDay).map(t=>{const n=d.get(t.id);return ae(Yr,{event:t,layout:n,isDayView:!0,calendarRef:P,isBeingDragged:b&&(null==y?void 0:y.eventId)===t.id&&"move"===(null==y?void 0:y.mode),hourHeight:_,firstHour:W,onMoveStart:w,onResizeStart:x,onEventUpdate:N,onEventDelete:I,newlyCreatedEventId:m,onDetailPanelOpen:()=>p(null),detailPanelEventId:f,onDetailPanelToggle:e=>v(e),selectedEventId:h,onEventSelect:t=>{const n=!1!==e.getReadOnlyConfig().viewable,r=a.find(e=>e.id===t);(j||Y)&&r&&n?(F(r),z(!0)):(g(t),e.state.highlightedEventId&&(e.highlightEvent(null),K.current=null))},onEventLongPress:e=>{(j||Y)&&g(e)},customDetailPanelContent:H,customEventDetailDialog:O,app:e,isMobile:j,enableTouch:Y},t.id)})})]})]})]})})]}),X&&ae(Ar,{x:X.x,y:X.y,date:X.date,viewType:exports.ViewType.DAY,onClose:()=>J(null),app:e,onCreateEvent:()=>{if(D){const e=Math.floor((t.getTime()-n.getTime())/864e5);if(0===X.date.getHours()&&0===X.date.getMinutes())null==E||E({clientX:X.x,clientY:X.y},e);else{const t=X.date.getHours()+X.date.getMinutes()/60,n={preventDefault:()=>{},stopPropagation:()=>{},clientX:X.x,clientY:X.y};D(n,e,t)}}}})]})},zr=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},Vr=({app:e,config:t,customDetailPanelContent:n,customEventDetailDialog:a,calendarRef:o,switcherMode:l="buttons",selectedEventId:s,onEventSelect:i,onDateChange:d,detailPanelEventId:c,onDetailPanelToggle:u})=>{const h=e.getEvents(),{screenSize:g}=cn(),m="desktop"!==g,[p,f]=r.useState(!1),{HOUR_HEIGHT:v=mr.HOUR_HEIGHT,FIRST_HOUR:y=mr.FIRST_HOUR,LAST_HOUR:b=mr.LAST_HOUR,ALL_DAY_HEIGHT:w=mr.ALL_DAY_HEIGHT,showAllDay:D=!0}=t,C=!D;r.useEffect(()=>{f("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const k=e.getCustomMobileEventRenderer()||Nn,[T,S]=r.useState(null),[M,I]=r.useState(null),[R,H]=r.useState(null),O=void 0!==s?s:M,P=void 0!==c?c:R,L=r.useMemo(()=>O&&h.find(e=>e.id===O)||null,[O,h]),$=e=>{i?i(e):I(e)},[j,Y]=r.useState(null),[F,z]=r.useState(!1),[V,_]=r.useState(null),W=r.useRef(null),Z=e.getCurrentDate(),[U,B]=r.useState(Z),q=r.useRef(Z.getTime());Z.getTime()!==q.current&&(q.current=Z.getTime(),Z.getFullYear()===U.getFullYear()&&Z.getMonth()===U.getMonth()||B(Z));const G=r.useCallback(t=>{B(n=>{const r=new Date(n.getFullYear(),n.getMonth()+t,1);return e.setVisibleMonth(r),r})},[e]),K=r.useRef(e.state.highlightedEventId);r.useEffect(()=>{var t;if(e.state.highlightedEventId!==K.current)if(e.state.highlightedEventId){$(e.state.highlightedEventId);const n=e.getEvents().find(t=>t.id===e.state.highlightedEventId);if(n&&!n.allDay){const e=N(n.start),r=null===(t=o.current)||void 0===t?void 0:t.querySelector(".calendar-content");if(r){const t=(e-y)*v;requestAnimationFrame(()=>{r.scrollTo({top:Math.max(0,t-100),behavior:"smooth"})})}}}else $(null);K.current=e.state.highlightedEventId},[e.state.highlightedEventId,y,v,o,e]);const X=r.useRef(null),J=r.useMemo(()=>zr(Z),[Z]),Q=r.useMemo(()=>((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=E(e.start),n=E(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=E(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})})})(h,Z,J),[h,Z,J]),ee=r.useMemo(()=>((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=E(e.start),a=E(e.end);let o=e.start,l=e.end,s=!1;return t<n&&(o=x(n),s=!0),a>r&&(l=x(r),s=!0),Object.assign(Object.assign({},e),{start:s?o:e.start,end:s?l:e.end,day:0})})})(Q,Z),[Q,Z]),te=r.useMemo(()=>cr.calculateDayEventLayouts(ee,{viewType:"day"}),[ee]),ne=r.useMemo(()=>(e=>{const t=e.filter(e=>e.allDay);t.sort((e,t)=>{const n=E(e.start),r=E(t.start);if(n.getTime()!==r.getTime())return n.getTime()-r.getTime();const a=E(e.end);return E(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=E(e.start),r=E(e.end),a=E(t.start);return n<=E(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})(Q),[Q]),re=r.useMemo(()=>{if(0===ne.length)return w;return(Math.max(...ne.map(e=>e.row))+1)*w},[ne,w]),{handleMoveStart:oe,handleCreateStart:le,handleResizeStart:se,handleCreateAllDayEvent:ie,dragState:de,isDragging:ce}=gr(e,{calendarRef:o,allDayRowRef:D?X:void 0,viewType:exports.ViewType.DAY,onEventsUpdate:t=>{const n=t(Q),r=new Set(n.map(e=>e.id)),a=Q.filter(e=>!r.has(e.id)),o=new Set(Q.map(e=>e.id)),l=n.filter(e=>!o.has(e.id)),s=n.filter(e=>{if(!o.has(e.id))return!1;const t=Q.find(t=>t.id===e.id);return t&&(E(t.start).getTime()!==E(e.start).getTime()||E(t.end).getTime()!==E(e.end).getTime()||t.day!==e.day||N(t.start)!==N(e.start)||N(t.end)!==N(e.end)||t.title!==e.title)});e.applyEventsChanges({delete:a.map(e=>e.id),add:l,update:s.map(e=>({id:e.id,updates:e}))})},onEventCreate:t=>{m?(_(t),z(!0)):(e.addEvent(t),Y(t.id))},onEventEdit:()=>{},currentWeekStart:J,events:Q,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 s=[...a,{id:"-1",title:"Temp",day:0,start:x(o),end:x(l),calendarId:"blue",allDay:!1}];return cr.calculateDayEventLayouts(s,{viewType:"day"}).get("-1")||null})(0,t,n,Z,ee),calculateDragLayout:(e,t,n,r)=>((e,t,n,r,a,o)=>{const l=o.filter(t=>t.id!==e.id),s=new Date(a),i=new Date(s);i.setHours(Math.floor(n),n%1*60,0,0);const d=new Date(s);d.setHours(Math.floor(r),r%1*60,0,0);const c=[...l,Object.assign(Object.assign({},e),{start:x(i),end:x(d),day:0})];return 0===c.length?null:cr.calculateDayEventLayouts(c,{viewType:"day"}).get(e.id)||null})(e,0,n,r,Z,ee),TIME_COLUMN_WIDTH:m?48:80,isMobile:m}),{handleDrop:ue,handleDragOver:he}=pr({app:e,onEventCreated:e=>{Y(e.id)}}),ge=Array.from({length:24},(e,t)=>({hour:t+y,label:A(t+y)})),me=r.useCallback(t=>{const n=new Date(t.getFullYear(),t.getMonth(),t.getDate());e.setCurrentDate(n),B(new Date(n.getFullYear(),n.getMonth(),1))},[e]),pe=r.useMemo(()=>{const e=new Date;e.setHours(0,0,0,0);const t=new Date(Z);return t.setHours(0,0,0,0),t.getTime()===e.getTime()},[Z]);return r.useEffect(()=>{S(new Date);const e=setInterval(()=>S(new Date),6e4);return()=>clearInterval(e)},[]),ae("div",{className:"df-day-view flex h-full bg-gray-50 dark:bg-gray-800",children:[ae(Fr,{app:e,currentDate:Z,currentWeekStart:J,events:h,currentDayEvents:Q,organizedAllDayEvents:ne,allDayAreaHeight:re,timeSlots:ge,eventLayouts:te,isToday:pe,currentTime:T,selectedEventId:O,setSelectedEventId:$,newlyCreatedEventId:j,setNewlyCreatedEventId:Y,detailPanelEventId:P,setDetailPanelEventId:e=>{u?u(e):H(e)},dragState:de,isDragging:ce,handleMoveStart:oe,handleResizeStart:se,handleCreateStart:le,handleCreateAllDayEvent:ie,handleTouchStart:(e,t)=>{if(!m&&!p)return;const n=e.touches[0],r=n.clientX,a=n.clientY,l=e.currentTarget;W.current=setTimeout(()=>{var e,n,s;const i=null===(n=null===(e=o.current)||void 0===e?void 0:e.querySelector(".calendar-content"))||void 0===n?void 0:n.getBoundingClientRect();if(!i)return;const d=null===(s=o.current)||void 0===s?void 0:s.querySelector(".calendar-content"),c=d?d.scrollTop:0,u=a-i.top+c;null==le||le({preventDefault:()=>{},stopPropagation:()=>{},touches:[{clientX:r,clientY:a}],changedTouches:[{clientX:r,clientY:a}],target:l,currentTarget:l,cancelable:!0},t,y+u/v)},500)},handleTouchEnd:()=>{W.current&&(clearTimeout(W.current),W.current=null)},handleTouchMove:()=>{W.current&&(clearTimeout(W.current),W.current=null)},handleDragOver:he,handleDrop:ue,handleEventUpdate:t=>{e.updateEvent(t.id,t)},handleEventDelete:t=>{e.deleteEvent(t)},onDateChange:d,customDetailPanelContent:n,customEventDetailDialog:a,calendarRef:o,allDayRowRef:X,switcherMode:l,isMobile:m,isTouch:p,setDraftEvent:_,setIsDrawerOpen:z,ALL_DAY_HEIGHT:w,HOUR_HEIGHT:v,FIRST_HOUR:y,LAST_HOUR:b,showAllDay:D,showStartOfDayLabel:C}),ae(vr,{app:e,currentDate:Z,visibleMonth:U,currentDayEvents:Q,selectedEvent:L,setSelectedEvent:e=>$(e?e.id:null),handleMonthChange:G,handleDateSelect:me,switcherMode:l}),ae(k,{isOpen:F,onClose:()=>{z(!1),_(null)},onSave:t=>{h.find(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),z(!1),_(null)},draftEvent:V,app:e})]})},_r={enableDrag:!0,enableResize:!0,enableCreate:!0,showMiniCalendar:!0,showAllDay:!0,scrollToCurrentTime:!0,hourHeight:72,firstHour:0,lastHour:24,dragConfig:{supportedViews:[exports.ViewType.DAY],enableAllDayCreate:!0},eventsConfig:{enableAutoRecalculate:!0,enableValidation:!0}},Wr=(e={})=>{const t=Object.assign(Object.assign({},_r),e),r=e=>n.h(Ln,{viewType:exports.ViewType.DAY,originalComponent:Vr,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 r.displayName="DayViewAdapter",{type:exports.ViewType.DAY,component:r,config:t}},Zr=({app:e,weekDaysLabels:t,mobileWeekDaysLabels:a,weekDates:o,currentWeekStart:l,gridWidth:s,allDayAreaHeight:i,organizedAllDaySegments:d,allDayLabelText:c,isMobile:u,isTouch:h,showAllDay:g=!0,calendarRef:m,allDayRowRef:p,topFrozenContentRef:f,ALL_DAY_HEIGHT:v,HOUR_HEIGHT:y,FIRST_HOUR:b,dragState:w,isDragging:x,handleMoveStart:D,handleResizeStart:E,handleEventUpdate:C,handleEventDelete:k,onDateChange:T,newlyCreatedEventId:S,setNewlyCreatedEventId:M,selectedEventId:N,setSelectedEventId:I,detailPanelEventId:R,setDetailPanelEventId:H,handleCreateAllDayEvent:O,handleDragOver:P,handleDrop:L,customDetailPanelContent:A,customEventDetailDialog:$,events:j,setDraftEvent:Y,setIsDrawerOpen:F})=>{const z={flexShrink:0},[V,_]=r.useState(null),W=Yt();return ae("div",{className:`flex flex-none ${g?"border-b border-gray-200 dark:border-gray-700":""} relative z-10`,onContextMenu:e=>e.preventDefault(),children:[g&&ae("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:[ae("div",{className:"flex-1 border-b border-gray-200 dark:border-gray-700"}),ae("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})]}),ae("div",{className:"flex-1 overflow-x-hidden overflow-y-auto relative",style:{scrollbarGutter:"stable"},children:ae("div",{ref:f,className:"flex flex-col",style:{width:s,minWidth:"100%"},children:[ae("div",{className:"df-week-header flex border-b border-gray-200 dark:border-gray-700",style:{marginRight:W?"-50px":"0px",paddingRight:W?"50px":"0px"},children:t.map((e,t)=>ae("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:z,children:ae(n.Fragment,u?{children:[ae("div",{className:"text-[12px] leading-tight text-gray-500 font-medium",children:a[t]}),ae("div",{className:`${Te} w-7 h-7 text-base font-medium ${o[t].isToday?ze:""}`,children:o[t].date})]}:{children:[ae("div",{className:"inline-flex items-center justify-center text-sm mt-1 mr-1",children:e}),ae("div",{className:`${Te} ${o[t].isToday?ze:""}`,children:o[t].date})]})},t))}),g&&ae("div",{className:`${Pe} border-none`,ref:p,style:{minHeight:`${i}px`},children:ae("div",{className:"df-all-day-content flex flex-1 relative",style:{minHeight:`${i}px`},children:[t.map((e,n)=>{const r=new Date(l);return r.setDate(l.getDate()+n),ae("div",{className:"df-all-day-cell flex-1 border-r border-gray-200 dark:border-gray-700 relative "+(n!==t.length-1||!u&&W?"":"border-r-0"),style:Object.assign({minHeight:`${i}px`},z),onClick:()=>{const e=new Date(l);e.setDate(l.getDate()+n),null==T||T(e)},onMouseDown:e=>null==O?void 0:O(e,n),onDblClick:e=>null==O?void 0:O(e,n),onDragOver:P,onDrop:e=>{L(e,r,void 0,!0)},onContextMenu:e=>((e,t)=>{if(e.preventDefault(),u)return;const n=new Date(l);n.setDate(l.getDate()+t),n.setHours(0,0,0,0),_({x:e.clientX,y:e.clientY,date:n})})(e,n)},`allday-${n}`)}),ae("div",{className:"absolute inset-0 pointer-events-none",children:d.map(t=>ae(Yr,{event:t.event,segment:t,segmentIndex:t.row,isAllDay:!0,isMultiDay:!0,allDayHeight:v,calendarRef:m,isBeingDragged:x&&(null==w?void 0:w.eventId)===t.event.id&&"move"===(null==w?void 0:w.mode),hourHeight:y,firstHour:b,onMoveStart:D,onResizeStart:E,onEventUpdate:C,onEventDelete:k,newlyCreatedEventId:S,onDetailPanelOpen:()=>M(null),selectedEventId:N,detailPanelEventId:R,onEventSelect:t=>{const n=!1!==e.getReadOnlyConfig().viewable,r=e.state.readOnly;if((u||h)&&t&&n&&!r){const e=j.find(e=>e.id===t);if(e)return Y(e),void F(!0)}I(t)},onEventLongPress:e=>{(u||h)&&I(e)},onDetailPanelToggle:e=>H(e),customDetailPanelContent:A,customEventDetailDialog:$,app:e,isMobile:u,enableTouch:h},t.id))})]})})]})}),V&&ae(Ar,{x:V.x,y:V.y,date:V.date,viewType:exports.ViewType.WEEK,onClose:()=>_(null),app:e,onCreateEvent:()=>{const e=Math.floor((V.date.getTime()-l.getTime())/864e5);null==O||O({clientX:V.x,clientY:V.y},e)}})]})},Ur=({app:e,timeSlots:t,weekDaysLabels:n,currentWeekStart:a,currentWeekEvents:o,eventLayouts:l,gridWidth:s,isMobile:i,isTouch:d,scrollerRef:c,timeGridRef:u,leftFrozenContentRef:h,calendarRef:g,handleScroll:m,handleCreateStart:p,handleTouchStart:f,handleTouchEnd:v,handleTouchMove:y,handleDragOver:b,handleDrop:w,dragState:x,isDragging:D,handleMoveStart:E,handleResizeStart:C,handleEventUpdate:k,handleEventDelete:T,onDateChange:S,newlyCreatedEventId:M,setNewlyCreatedEventId:N,selectedEventId:I,setSelectedEventId:R,detailPanelEventId:H,setDetailPanelEventId:O,customDetailPanelContent:P,customEventDetailDialog:L,events:$,setDraftEvent:j,setIsDrawerOpen:Y,isCurrentWeek:F,currentTime:z,HOUR_HEIGHT:V,FIRST_HOUR:_,LAST_HOUR:W,showStartOfDayLabel:Z})=>{const U={flexShrink:0},q=r.useRef(e.state.highlightedEventId),[G,K]=r.useState(null),X=Yt();return ae("div",{className:"flex flex-1 overflow-hidden relative",children:[ae("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:ae("div",{ref:h,children:[ae("div",{className:"h-3 relative",children:ae("div",{className:"absolute -bottom-1 right-2 text-[10px] md:text-[12px] text-gray-500 dark:text-gray-400 select-none",children:Z?A(_):""})}),t.map((e,t)=>ae("div",{className:Ne,children:ae("div",{className:`${Ie} text-[10px] md:text-[12px]`,children:Z&&0===t?"":e.label})},t)),ae("div",{className:"relative",children:ae("div",{className:`${Ie} text-[10px] md:text-[12px]`,children:"00:00"})}),F&&z&&(()=>{const e=z,t=e.getHours()+e.getMinutes()/60;if(t<_||t>W)return null;return ae("div",{className:"absolute left-0 w-full z-20 pointer-events-none flex items-center justify-end",style:{top:`${(t-_)*V}px`,transform:"translateY(-50%)",marginTop:"0.75rem"},children:ae("div",{className:Oe,children:A(t)})})})()]})}),ae("div",{ref:c,className:"flex-1 overflow-auto relative calendar-content snap-x snap-mandatory",onScroll:m,children:ae("div",{className:"flex",style:{width:s,minWidth:"100%"},children:ae("div",{className:"grow",children:[ae("div",{className:`${Ue} border-t-0 flex`,children:n.map((e,t)=>ae("div",{className:`flex-1 relative ${t!==n.length-1||!i&&X?"border-r":""} border-gray-200 dark:border-gray-700`,style:U},`top-${t}`))}),ae("div",{ref:u,className:"relative",children:[F&&z&&(()=>{const e=z,t=e.getHours()+e.getMinutes()/60;if(t<_||t>W)return null;const r=e.getDay(),a=0===r?6:r-1;return ae("div",{className:He,style:{top:`${(t-_)*V}px`,width:"100%",height:0,zIndex:20},children:[ae("div",{className:"flex items-center w-0"}),ae("div",{className:"flex flex-1",children:n.map((e,t)=>ae("div",{className:"flex-1 flex items-center",children:ae("div",{className:"h-0.5 w-full relative "+(t===a?"bg-primary":"bg-primary/30"),style:{zIndex:9999},children:t===a&&0!==a&&ae("div",{className:"absolute w-2 h-2 bg-primary rounded-full",style:{top:"-3px",left:"-4px"}})})},t))})]})})(),t.map((e,t)=>ae("div",{className:Re,children:n.map((r,o)=>{const l=new Date(a);return l.setDate(a.getDate()+o),ae("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:U,onClick:()=>{const e=new Date(a);e.setDate(a.getDate()+o),null==S||S(e)},onDblClick:t=>{null==p||p(t,o,e.hour)},onTouchStart:t=>f(t,o,e.hour),onTouchEnd:v,onTouchMove:y,onDragOver:b,onDrop:t=>{w(t,l,e.hour)},onContextMenu:t=>((e,t,n)=>{if(e.preventDefault(),i)return;const r=new Date(a);if(r.setDate(a.getDate()+t),u.current){const t=u.current.getBoundingClientRect(),n=(e.clientY-t.top)/V+_,a=Math.floor(n),o=Math.floor(60*(n-a)),l=15*Math.round(o/15),s=60===l?a+1:a,i=60===l?0:l;r.setHours(s,i,0,0)}else r.setHours(n,0,0,0);K({x:e.clientX,y:e.clientY,date:r})})(t,o,e.hour)},`${t}-${o}`)})},t)),ae("div",{className:`${Ue} flex`,children:n.map((e,t)=>ae("div",{className:`flex-1 relative ${t!==n.length-1||!i&&X?"border-r":""} border-gray-200 dark:border-gray-700`,style:U},`24-${t}`))}),n.map((t,n)=>{const r=B(n,o),s=[];return r.forEach(e=>{const t=xr(e,a);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})}),o.forEach(e=>{if(e.allDay||e.day===n)return;const t=xr(e,a).find(e=>e.dayIndex===n);t&&s.push({event:e,segmentInfo:Object.assign(Object.assign({},t),{dayIndex:n})})}),ae("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=l.get(n),o=null==a?void 0:a.get(t.id);return ae(Yr,{event:t,layout:o,calendarRef:g,isBeingDragged:D&&(null==x?void 0:x.eventId)===t.id&&"move"===(null==x?void 0:x.mode),hourHeight:V,firstHour:_,onMoveStart:E,onResizeStart:C,onEventUpdate:k,onEventDelete:T,newlyCreatedEventId:M,onDetailPanelOpen:()=>N(null),selectedEventId:I,detailPanelEventId:H,onEventSelect:t=>{const n=!1!==e.getReadOnlyConfig().viewable,r=e.state.readOnly;if((i||d)&&t&&n&&!r){const e=$.find(e=>e.id===t);if(e)return j(e),void Y(!0)}R(t),e.state.highlightedEventId&&(e.highlightEvent(null),q.current=null)},onEventLongPress:e=>{(i||d)&&R(e)},onDetailPanelToggle:e=>O(e),customDetailPanelContent:P,customEventDetailDialog:L,multiDaySegmentInfo:r,app:e,isMobile:i,enableTouch:d},r?`${t.id}-seg-${n}`:t.id)})},`events-day-${n}`)})]})]})})}),G&&ae(Ar,{x:G.x,y:G.y,date:G.date,viewType:exports.ViewType.WEEK,onClose:()=>K(null),app:e,onCreateEvent:()=>{if(p){const e=new Date(a);e.setHours(0,0,0,0);const t=new Date(G.date);t.setHours(0,0,0,0);const n=t.getTime()-e.getTime(),r=Math.round(n/864e5),o=G.date.getHours()+G.date.getMinutes()/60,l={preventDefault:()=>{},stopPropagation:()=>{},clientX:G.x,clientY:G.y};p(l,r,o)}}})]})},Br=({app:e,config:t,customDetailPanelContent:n,customEventDetailDialog:a,calendarRef:o,selectedEventId:l,onEventSelect:s,onDateChange:i,detailPanelEventId:d,onDetailPanelToggle:c})=>{const{t:u,getWeekDaysLabels:h,locale:g}=Tt(),m=e.getCurrentDate(),p=e.getEvents(),{screenSize:f}=cn(),v="desktop"!==f,y="mobile"===f?48:80,b=r.useRef(null),[w,D]=r.useState(!1),{HOUR_HEIGHT:C=mr.HOUR_HEIGHT,FIRST_HOUR:k=mr.FIRST_HOUR,LAST_HOUR:T=mr.LAST_HOUR,ALL_DAY_HEIGHT:S=mr.ALL_DAY_HEIGHT,showAllDay:M=!0}=t,R=!M;r.useEffect(()=>{D("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const H=e.getCustomMobileEventRenderer()||Nn,O=r.useMemo(()=>zr(m),[m]),[P,L]=r.useState(null),[$,j]=r.useState(null),[Y,F]=r.useState(null),z=void 0!==l?l:$,V=void 0!==d?d:Y,_=e=>{s?s(e):j(e)},W=e=>{c?c(e):F(e)},[Z,U]=r.useState(null),[B,G]=r.useState(!1),[K,X]=r.useState(null),J=r.useRef(null),Q=r.useRef(null),ee=r.useRef(null),te=r.useRef(null),ne=r.useRef(null),re=r.useMemo(()=>((e,t)=>{const n=new Date(t);return n.setDate(t.getDate()+6),n.setHours(23,59,59,999),e.filter(e=>{const r=E(e.start);r.setHours(0,0,0,0);const a=E(e.end);return a.setHours(23,59,59,999),a>=t&&r<=n}).map(e=>{const n=E(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})})})(p,O),[p,O]),oe=r.useRef(e.state.highlightedEventId);r.useEffect(()=>{if(e.state.highlightedEventId!==oe.current)if(e.state.highlightedEventId){_(e.state.highlightedEventId);const t=re.find(t=>t.id===e.state.highlightedEventId);if(t&&!t.allDay){const e=N(t.start),n=ee.current;if(n){const t=(e-k)*C;requestAnimationFrame(()=>{n.scrollTo({top:Math.max(0,t-100),behavior:"smooth"})})}}}else _(null);oe.current=e.state.highlightedEventId},[e.state.highlightedEventId,re,k,C]);const le=r.useMemo(()=>((e,t)=>{const n=wr(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})(re,O),[re,O]),se=r.useMemo(()=>{if(0===le.length)return S;const e=Math.max(...le.map(e=>e.row));return S+e*S},[le,S]),ie=r.useMemo(()=>((e,t)=>{const n=new Map;for(let r=0;r<7;r++){const a=[];e.forEach(e=>{if(e.allDay)return;const n=xr(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:x(I(q(t,r),o.startHour)),end:x(I(q(t,r),n)),day:r});a.push(l)}}else e.day===r&&a.push(e)});const o=cr.calculateDayEventLayouts(a,{viewType:"week"});n.set(r,o)}return n})(re,O),[re,O]),{handleMoveStart:de,handleCreateStart:ce,handleResizeStart:ue,handleCreateAllDayEvent:he,dragState:ge,isDragging:me}=gr(e,{calendarRef:o,allDayRowRef:M?Q:void 0,viewType:exports.ViewType.WEEK,onEventsUpdate:(t,n)=>{const r=t(re),a=new Set(r.map(e=>e.id)),o=re.filter(e=>!a.has(e.id)),l=new Set(re.map(e=>e.id)),s=r.filter(e=>!l.has(e.id)),i=r.filter(e=>{if(!l.has(e.id))return!1;const t=re.find(t=>t.id===e.id);return t&&(E(t.start).getTime()!==E(e.start).getTime()||E(t.end).getTime()!==E(e.end).getTime()||t.day!==e.day||N(t.start)!==N(e.start)||N(t.end)!==N(e.end)||t.title!==e.title)});e.applyEventsChanges({delete:o.map(e=>e.id),add:s,update:i.map(e=>({id:e.id,updates:e}))},n)},onEventCreate:t=>{v?(X(t),G(!0)):(e.addEvent(t),U(t.id))},onEventEdit:()=>{},currentWeekStart:O,events:re,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:x(a),end:x(o),calendarId:"blue",allDay:!1},s=[...r.filter(t=>t.day===e&&!t.allDay),l];return cr.calculateDayEventLayouts(s,{viewType:"week"}).get("-1")||null})(e,t,n,re),calculateDragLayout:(e,t,n,r)=>((e,t,n,r,a)=>{const o=a.map(a=>{if(a.id!==e.id)return a;const o=E(a.start),l=I(o,n),s=I(o,r),i=x(l),d=x(s);return Object.assign(Object.assign({},a),{day:t,start:i,end:d})}).filter(e=>e.day===t&&!e.allDay);return 0===o.length?null:cr.calculateDayEventLayouts(o,{viewType:"week"}).get(e.id)||null})(e,t,n,r,re),TIME_COLUMN_WIDTH:y,isMobile:v}),{handleDrop:pe,handleDragOver:fe}=pr({app:e,onEventCreated:e=>{U(e.id)}}),ve=r.useMemo(()=>h(g,"short"),[g,h]),ye=r.useMemo(()=>{if(!v)return[];const e=g.split("-")[0].toLowerCase();return"zh"===e||"ja"===e?h(g,"narrow"):ve.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)})},[v,g,h,ve]),be=r.useMemo(()=>u("allDay"),[u]),we=Array.from({length:24},(e,t)=>({hour:t+k,label:A(t+k)})),xe=r.useMemo(()=>{const e=new Date;return e.setHours(0,0,0,0),ve.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(g,{month:"short"}),fullDate:new Date(r),isToday:a.getTime()===e.getTime()}})},[O,ve,g]),De=t=>{e.updateEvent(t.id,t)},Ee=t=>{e.deleteEvent(t)},Ce=r.useMemo(()=>{const e=new Date,t=zr(e);return O.getTime()===t.getTime()},[O]);r.useEffect(()=>{L(new Date);const e=setInterval(()=>L(new Date),6e4);return()=>clearInterval(e)},[]);const ke=v?"175%":"100%";return ae("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:[ae(yr,{calendar:e,viewType:exports.ViewType.WEEK,currentDate:m,onPrevious:()=>e.goToPrevious(),onNext:()=>e.goToNext(),onToday:()=>e.goToToday()}),ae(Zr,{app:e,weekDaysLabels:ve,mobileWeekDaysLabels:ye,weekDates:xe,currentWeekStart:O,gridWidth:ke,allDayAreaHeight:se,organizedAllDaySegments:le,allDayLabelText:be,isMobile:v,isTouch:w,showAllDay:M,calendarRef:o,allDayRowRef:Q,topFrozenContentRef:te,ALL_DAY_HEIGHT:S,HOUR_HEIGHT:C,FIRST_HOUR:k,dragState:ge,isDragging:me,handleMoveStart:de,handleResizeStart:ue,handleEventUpdate:De,handleEventDelete:Ee,onDateChange:i,newlyCreatedEventId:Z,setNewlyCreatedEventId:U,selectedEventId:z,setSelectedEventId:_,detailPanelEventId:V,setDetailPanelEventId:W,handleCreateAllDayEvent:he,handleDragOver:fe,handleDrop:pe,customDetailPanelContent:n,customEventDetailDialog:a,events:p,setDraftEvent:X,setIsDrawerOpen:G}),ae(Ur,{app:e,timeSlots:we,weekDaysLabels:ve,currentWeekStart:O,currentWeekEvents:re,eventLayouts:ie,gridWidth:ke,isMobile:v,isTouch:w,scrollerRef:ee,timeGridRef:b,leftFrozenContentRef:ne,calendarRef:o,handleScroll:e=>{const{scrollTop:t,scrollLeft:n}=e.currentTarget;te.current&&(te.current.style.transform=`translateX(${-n}px)`),ne.current&&(ne.current.style.transform=`translateY(${-t}px)`)},handleCreateStart:ce,handleTouchStart:(e,t,n)=>{if(!v&&!w)return;const r=e.touches[0],a=r.clientX,o=r.clientY,l=e.currentTarget;J.current=setTimeout(()=>{null==ce||ce({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:fe,handleDrop:pe,dragState:ge,isDragging:me,handleMoveStart:de,handleResizeStart:ue,handleEventUpdate:De,handleEventDelete:Ee,onDateChange:i,newlyCreatedEventId:Z,setNewlyCreatedEventId:U,selectedEventId:z,setSelectedEventId:_,detailPanelEventId:V,setDetailPanelEventId:W,customDetailPanelContent:n,customEventDetailDialog:a,events:p,setDraftEvent:X,setIsDrawerOpen:G,isCurrentWeek:Ce,currentTime:P,HOUR_HEIGHT:C,FIRST_HOUR:k,LAST_HOUR:T,showStartOfDayLabel:R}),ae(H,{isOpen:B,onClose:()=>{G(!1),X(null)},onSave:t=>{p.find(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),G(!1),X(null)},draftEvent:K,app:e})]})},qr={enableDrag:!0,enableResize:!0,enableCreate:!0,showWeekends:!0,showAllDay:!0,startOfWeek:1,scrollToCurrentTime:!0,hourHeight:72,firstHour:0,lastHour:24,dragConfig:{supportedViews:[exports.ViewType.WEEK],enableAllDayCreate:!0},eventsConfig:{enableAutoRecalculate:!0,enableValidation:!0}},Gr=(e={})=>{const t=Object.assign(Object.assign({},qr),e),r=e=>n.h(Ln,{viewType:exports.ViewType.WEEK,originalComponent:Br,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 r.displayName="WeekViewAdapter",{type:exports.ViewType.WEEK,component:r,config:t}},Kr=a.memo(({currentMonth:e,currentYear:n,newlyCreatedEventId:a,screenSize:o,isScrolling:l,isDragging:s,item:i,weekHeight:d,events:c,dragState:u,calendarRef:h,onEventUpdate:g,onEventDelete:m,onMoveStart:f,onCreateStart:v,onResizeStart:y,onDetailPanelOpen:b,onMoreEventsClick:w,onChangeView:x,onSelectDate:D,selectedEventId:C,onEventSelect:k,onEventLongPress:T,detailPanelEventId:S,onDetailPanelToggle:M,customDetailPanelContent:I,customEventDetailDialog:R,onCalendarDrop:H,onCalendarDragOver:O,app:P,enableTouch:L})=>{const{t:A,locale:$}=Tt(),[j,Y]=r.useState(!1),F=r.useRef(null),z=r.useRef(null),V=r.useRef(null),[_,W]=r.useState(null),Z=r.useMemo(()=>{const e=d-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)))}},[d]);r.useEffect(()=>l?(Y(!0),F.current&&(clearTimeout(F.current),F.current=null),()=>{F.current&&(clearTimeout(F.current),F.current=null)}):j?(F.current=setTimeout(()=>{Y(!1),F.current=null},100),()=>{F.current&&(clearTimeout(F.current),F.current=null)}):void 0,[l,j]);const{weekData:U}=i,B=U.days.find(e=>1===e.day),q=`${d}px`,G=r.useMemo(()=>wr(c,U.startDate),[c,U.startDate]),K=r.useMemo(()=>((e,n)=>{const r=[],a=new Date(n);return a.setDate(a.getDate()+6),a.setHours(23,59,59,999),e.forEach(e=>{if(!e.start||!e.end)return void p.warn("Event missing start or end date:",e);const o=E(e.start),l=E(e.end),s=new Date(o);s.setHours(0,0,0,0);const i=new Date(l);i.setHours(0,0,0,0);let d=new Date(i);if(!e.allDay&&0===l.getHours()&&0===l.getMinutes()&&0===l.getSeconds()){const e=l.getTime()-o.getTime();e>0&&e<864e5&&(d=new Date(i),d.setDate(d.getDate()-1))}const c=s.toDateString()!==d.toDateString();if(!c||e.allDay)if(c&&e.allDay){let s=new Date(o);s<n&&(s=new Date(n),s.setHours(0,0,0,0));const i=l>a?a:l;for(;s<=i;){const n=t.Temporal.PlainDate.from({year:s.getFullYear(),month:s.getMonth()+1,day:s.getDate()});r.push(Object.assign(Object.assign({},e),{start:n,end:n,day:s.getDay()})),s.setDate(s.getDate()+1)}}else r.push(Object.assign(Object.assign({},e),{start:e.start,end:e.end,day:o.getDay()}))}),r})(c,U.startDate),[c,U.startDate]),X=r.useMemo(()=>(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})(G),[G]),J=r.useMemo(()=>{const e=Array(7).fill(0);return X.forEach((t,n)=>{t.forEach(t=>{for(let r=t.startDayIndex;r<=t.endDayIndex;r++)e[r]=Math.max(e[r],n+1)})}),e},[X]),Q=r.useMemo(()=>{const e=Array.from({length:7},()=>new Set);return X.forEach((t,n)=>{t.forEach(t=>{for(let r=t.startDayIndex;r<=t.endDayIndex;r++)r>=0&&r<7&&e[r].add(n)})}),e},[X]),ee=r.useMemo(()=>{const e=X.flat();for(let t=0;t<U.days.length;t++){const n=U.days[t],r=K.filter(e=>{if(!e.start||!e.end)return E(e.start).toDateString()===n.date.toDateString();const t=E(e.start),r=E(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=Q[t],o=J[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)>Z.maxSlots)return Z.maxSlotsWithMore}return Z.maxSlots},[U.days,K,X,J,Q,Z.maxSlots,Z.maxSlotsWithMore]),te=r.useMemo(()=>Math.max(0,17*X.length),[X]),ne=(t,r)=>{var l;const i=t.date.toLocaleDateString($,{month:$.startsWith("zh")||$.startsWith("ja")?"short":"long"})===e&&t.year===n;var d;const c=(e=>[...e].sort((e,t)=>e.allDay!==t.allDay?e.allDay?-1:1:e.allDay&&t.allDay?0:N(e.start)-N(t.start)))((d=t.date,K.filter(e=>{if(!e.start||!e.end)return E(e.start).toDateString()===d.toDateString();const t=E(e.start),n=E(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()}))),p=X.flat(),j=c.filter(e=>{if(!e.allDay)return!0;return!p.some(t=>t.originalEventId===e.id)}),Y=Q[r],F=(null!==(l=J[r])&&void 0!==l?l:0)-1,_=[];for(let e=0;e<=F;e++)Y.has(e)||_.push(e);const U=j.length,B=Math.max(0,U-_.length),G=Math.max(F+1,0)+B,ee=G>Z.maxSlots,te=ee?Z.maxSlotsWithMore:Z.maxSlots,ne=_.filter(e=>e<te).length,re=Math.max(0,te-Math.max(F+1,0)),oe=Math.min(U,ne+re),le=j.slice(0,oe),se=U-oe,ie=[];let de=0;const ce=Math.min(te,G);for(let e=0;e<ce;e++)if(Y.has(e))ie.push(ae("div",{className:"shrink-0",style:{height:"17px",minHeight:"17px"}},`placeholder-layer-${e}-${t.date.getTime()}`));else if(de<le.length){const e=le[de];ie.push(ae(Yr,{event:e,isAllDay:!!e.allDay,isMonthView:!0,isBeingDragged:s&&u.eventId===e.id&&"move"===u.mode,calendarRef:h,hourHeight:72,firstHour:0,onEventUpdate:g,onEventDelete:m,onMoveStart:f,onResizeStart:y,onDetailPanelOpen:b,onEventSelect:k,onEventLongPress:T,newlyCreatedEventId:a,selectedEventId:C,detailPanelEventId:S,onDetailPanelToggle:M,customDetailPanelContent:I,customEventDetailDialog:R,app:P,isMobile:"desktop"!==o,enableTouch:L},`${e.id}-${e.day}-${N(e.start)}-${de}`)),de++}return ae("div",{className:tt("df-month-day-cell relative flex flex-col border-r border-gray-200 dark:border-gray-700",i?"text-gray-800 dark:text-gray-100":"text-gray-400 dark:text-gray-600","desktop"!==o&&6===r?"border-r-0":"last:border-r"),style:{height:q},"data-date":(ue=t.date,`${ue.getFullYear()}-${String(ue.getMonth()+1).padStart(2,"0")}-${String(ue.getDate()).padStart(2,"0")}`),onClick:()=>null==D?void 0:D(t.date),onDblClick:e=>null==v?void 0:v(e,t.date),onTouchStart:e=>{if("mobile"!==o&&!L)return;const n=e.touches[0],r=n.clientX,a=n.clientY;V.current={x:r,y:a},z.current=setTimeout(()=>{null==v||v(e,t.date),z.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},onTouchMove:e=>{if(z.current&&V.current){const t=Math.abs(e.touches[0].clientX-V.current.x),n=Math.abs(e.touches[0].clientY-V.current.y);(t>10||n>10)&&(clearTimeout(z.current),z.current=null)}},onTouchEnd:()=>{z.current&&(clearTimeout(z.current),z.current=null),V.current=null},onDragOver:O,onDrop:e=>null==H?void 0:H(e,t.date),onContextMenu:e=>((e,t)=>{e.preventDefault(),"mobile"!==o&&W({x:e.clientX,y:e.clientY,date:t})})(e,t.date),children:[ae("div",{className:"df-month-date-number-container text-right px-2 h-[33px] relative z-20",children:ae("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 ${t.isToday?"bg-primary text-primary-foreground":i?"text-gray-900 dark:text-gray-100":"text-gray-400 dark:text-gray-600"}\n `,children:1===t.day&&"desktop"===o?t.date.toLocaleDateString($,{month:"short",day:"numeric"}):t.day})}),ae("div",{className:"flex-1 overflow-hidden px-1",children:[ie,ee&&ae("div",{className:tt("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"===o?"text-left font-normal":"text-center font-medium"),onClick:e=>{e.stopPropagation(),w?w(t.date):(null==D||D(t.date),null==x||x(exports.ViewType.DAY))},children:["+",se,"desktop"===o?` ${A("more")}`:""]})]})]},`day-${t.date.getTime()}`);var ue},re=r.useMemo(()=>B?B.date.toLocaleDateString($,{month:"long",year:"numeric"}):"",[B,$]);return ae("div",{className:"relative select-none border-b border-gray-200 dark:border-gray-700",style:{height:q},children:[B&&ae("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 ${j?"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:ae("span",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:re})}),ae("div",{className:"h-full flex flex-col",children:ae("div",{className:"calendar-week relative h-full",children:[ae("div",{className:"grid grid-cols-7 h-full",children:U.days.map((e,t)=>ne(e,t))}),X.length>0&&ae("div",{className:"absolute left-0 right-0 pointer-events-none",style:{top:"33px",height:`${te}px`,zIndex:10},children:X.slice(0,ee).map((e,t)=>ae("div",{className:"absolute inset-0",children:e.map(e=>ae(Yr,{event:e.event,isAllDay:!!e.event.allDay,segment:e,segmentIndex:t,isMonthView:!0,isMultiDay:!0,calendarRef:h,hourHeight:72,firstHour:0,onEventUpdate:g,onEventDelete:m,onMoveStart:f,onResizeStart:y,isBeingDragged:s&&u.eventId===e.event.id&&"move"===u.mode,isBeingResized:s&&u.eventId===e.event.id&&"resize"===u.mode,newlyCreatedEventId:a,onDetailPanelOpen:b,selectedEventId:C,onEventSelect:k,onEventLongPress:T,detailPanelEventId:S,onDetailPanelToggle:M,customDetailPanelContent:I,customEventDetailDialog:R,app:P,isMobile:"desktop"!==o,enableTouch:L},e.id))},`layer-${t}`))})]})}),_&&ae(Ar,{x:_.x,y:_.y,date:_.date,viewType:exports.ViewType.MONTH,onClose:()=>W(null),app:P,onCreateEvent:()=>{if(v){const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:_.x,clientY:_.y};v(e,_.date)}}})]})});Kr.displayName="WeekComponent";const Xr=({app:e,customDetailPanelContent:t,customEventDetailDialog:n,calendarRef:a,selectedEventId:o,onEventSelect:l,detailPanelEventId:d,onDetailPanelToggle:c})=>{const{getWeekDaysLabels:u,getMonthLabels:h,locale:g}=Tt(),m=e.getCurrentDate(),p=e.getEvents(),f=e.getCalendars().map(e=>e.id+e.colors.lineColor).join("-"),v=r.useRef(null),y=r.useMemo(()=>{const e=v.current;return e&&e.length===p.length&&e.every((e,t)=>e===p[t])?e:(v.current=p,p)},[p]),b=r.useMemo(()=>{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 y.forEach(e=>{if(!e.start)return;const r=E(e.start),a=e.end?E(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 s=new Date(l);if(!e.allDay){0!==a.getHours()||0!==a.getMinutes()||0!==a.getSeconds()||0!==a.getMilliseconds()||s.setDate(s.getDate()-1)}s<o&&(s=new Date(o));const i=t(o),d=t(s);let c=i.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},[y]),{screenSize:w}=cn(),[x,D]=r.useState(!1);r.useEffect(()=>{D("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const C=e.getCustomMobileEventRenderer()||Nn,[k,T]=r.useState(119),[S,M]=r.useState(!1),I=r.useRef(k),R=r.useRef([]),[H,O]=r.useState(null),[P,L]=r.useState(!1),[A,$]=r.useState(null),[j,Y]=r.useState(null),[F,z]=r.useState(null),V=void 0!==o?o:j,_=void 0!==d?d:F,Z=r.useCallback(e=>{l?l(e):Y(e)},[l]),B=r.useCallback(e=>{c?c(e):z(e)},[c]),q=r.useRef(e.state.highlightedEventId);r.useEffect(()=>{e.state.highlightedEventId?Z(e.state.highlightedEventId):q.current&&Z(null),q.current=e.state.highlightedEventId},[e.state.highlightedEventId]);const G=r.useMemo(()=>{const e=m.getDay(),t=m.getDate()-e+(0===e?-6:1),n=new Date(m);return n.setDate(t),n.setHours(0,0,0,0),n},[m]),{handleMoveStart:K,handleCreateStart:X,handleResizeStart:J,dragState:Q,isDragging:ee}=gr(e,{calendarRef:a,viewType:exports.ViewType.MONTH,onEventsUpdate:(t,n)=>{const r=t(y),a=new Set(r.map(e=>e.id)),o=y.filter(e=>!a.has(e.id)),l=new Set(y.map(e=>e.id)),s=r.filter(e=>!l.has(e.id)),i=r.filter(e=>{if(!l.has(e.id))return!1;const t=y.find(t=>t.id===e.id);return t&&(E(t.start).getTime()!==E(e.start).getTime()||E(t.end).getTime()!==E(e.end).getTime()||t.day!==e.day||N(t.start)!==N(e.start)||N(t.end)!==N(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:s,update:i.map(e=>({id:e.id,updates:e}))},n)},onEventCreate:t=>{"desktop"!==w?($(t),L(!0)):e.addEvent(t)},onEventEdit:e=>{O(e.id)},currentWeekStart:G,events:y}),{handleDrop:te,handleDragOver:ne}=pr({app:e,onEventCreated:e=>{O(e.id)}}),re=r.useMemo(()=>u(g,"short"),[g,u]),{currentMonth:oe,currentYear:le,isScrolling:se,virtualData:ie,weeksData:de,scrollElementRef:ce,isNavigating:ue,handleScroll:he,handlePreviousMonth:ge,handleNextMonth:me,handleToday:pe,setScrollTop:fe}=(({currentDate:e,weekHeight:t,onCurrentMonthChange:n,initialWeeksToLoad:a=104,locale:o="en-US",isEnabled:l=!0})=>{const d=r.useRef(null),c=r.useCallback((e,t)=>{const n=new Date(t,e,1),r=o.startsWith("zh")||o.startsWith("ja");return n.toLocaleDateString(o,{month:r?"short":"long"})},[o]),u=r.useMemo(()=>{const t=new Date(e);return t.setDate(1),t.setHours(0,0,0,0),U(t,a)},[e,a]),h=r.useMemo(()=>{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]),[g,m]=r.useState(h),[p,f]=r.useState(600),[v,y]=r.useState(c(e.getMonth(),e.getFullYear())),[b,w]=r.useState(e.getFullYear()),[x,D]=r.useState(!1),[E,C]=r.useState(u),[k,T]=r.useState(!1),S=r.useRef(!1),[M,N]=r.useState(!1),I=r.useRef(e),R=r.useRef(null),H=r.useRef(null),O=r.useRef(new i),P=r.useRef(0),L=r.useRef(0),A=r.useRef(!1),$=r.useCallback(e=>{e&&(R.current=e)},[]),j=r.useCallback(e=>{let t=O.current.get(e);return console.log("weekData",t),t||(t=W(e),O.current.set(e,t)),t},[]),Y=r.useCallback((e,n=26)=>{A.current||(A.current=!0,setTimeout(()=>{try{if("future"===e){const e=E[E.length-1],t=[];for(let r=1;r<=n;r++){const n=new Date(e.startDate);n.setDate(n.getDate()+7*r),t.push(j(n))}C(e=>[...e,...t])}else{const e=E[0],r=[];for(let t=n;t>=1;t--){const n=new Date(e.startDate);n.setDate(n.getDate()-7*t),r.push(j(n))}const a=r.length*t;C(e=>[...r,...e]),requestAnimationFrame(()=>{m(e=>e+a),R.current&&(R.current.scrollTop+=a)})}}finally{setTimeout(()=>{A.current=!1},200)}},0))},[E,j,t]),F=r.useMemo(()=>{const e=E.length*t,n=Math.floor(g/t);let r=Math.max(0,n);r=Math.min(r,Math.max(0,E.length-6));const a=Math.min(E.length-1,r+6-1),o=Math.max(0,r-15),l=Math.min(E.length-1,a+15),s=[];for(let e=o;e<=l;e++)s.push({index:e,weekData:E[e],top:e*t,height:t});return{totalHeight:e,visibleItems:s,displayStartIndex:r}},[g,p,t,E]),z=r.useCallback(e=>{if(k||x||0===e.length||!M)return;const t=g+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=`${c(e.month,e.year)}-${e.year}`;a[t]=(a[t]||0)+1});let o="",l=0,s=0;Object.entries(a).forEach(([e,t])=>{if(t>s){s=t;const[n,r]=e.split("-");o=n,l=parseInt(r)}}),o&&l&&(d.current?o===d.current.month&&l===d.current.year&&(d.current=null,o===v&&l===b||(y(o),w(l),null==n||n(o,l))):o===v&&l===b||(y(o),w(l),null==n||n(o,l)))},[p,v,b,k,x,n,g,M]),V=r.useCallback(e=>{const n=performance.now();if(n-P.current<s.SCROLL_THROTTLE)return;P.current=n;const r=e.currentTarget,a=r.scrollTop;L.current=a,m(a),k||requestAnimationFrame(()=>{const{scrollHeight:e,clientHeight:n}=r;a+n>e-10*t&&!A.current&&Y("future",26),a<10*t&&!A.current&&Y("past",26)}),D(!0),H.current&&clearTimeout(H.current),H.current=setTimeout(()=>{D(!1)},s.SCROLL_DEBOUNCE)},[t,Y,k]),_=r.useCallback((e,n=!0)=>{if(!R.current)return;T(!0),S.current=!0;const r=()=>{setTimeout(()=>{T(!1),S.current=!1},n?500:200)},a=E.findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(-1!==a){const e=a*t;return R.current.scrollTo({top:e,behavior:n?"smooth":"auto"}),void r()}const o=e.getDay(),l=0===o?6:o-1,s=new Date(e);s.setDate(e.getDate()-l),s.setHours(0,0,0,0);const i=E[0],d=E[E.length-1];let c=0,u=!1,h=!1;s<i.startDate?(c=Math.ceil((i.startDate.getTime()-s.getTime())/6048e5),u=!0):s>d.startDate&&(c=Math.ceil((s.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(i.startDate);t.setDate(t.getDate()-7*e),a.push(j(t))}const o=a.length*t;C(e=>[...a,...e]),requestAnimationFrame(()=>{const l=[...a,...E].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(R.current&&-1!==l){const e=l*t;R.current.scrollTop+=o,m(e=>e+o),setTimeout(()=>{R.current&&R.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(j(t))}C(e=>[...e,...a]),requestAnimationFrame(()=>{const o=[...E,...a].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(R.current&&-1!==o){const e=o*t;R.current.scrollTo({top:e,behavior:n?"smooth":"auto"})}r()})}else r()},[E,t,j]),Z=r.useCallback(()=>{const e=E[F.displayStartIndex].days[0].date,t=new Date(e.getFullYear(),e.getMonth()-1,1);_(t)},[F.displayStartIndex,E,_]),B=r.useCallback(()=>{const e=E[F.displayStartIndex].days[0].date,t=new Date(e.getFullYear(),e.getMonth()+1,1);_(t)},[F.displayStartIndex,E,_]),q=r.useCallback(()=>{const e=new Date,r=c(e.getMonth(),e.getFullYear()),a=e.getFullYear(),o=new Date(a,e.getMonth(),1);d.current={month:r,year:a},y(r),w(a),null==n||n(r,a);const l=E.findIndex(e=>e.days.some(e=>e.date.toDateString()===o.toDateString()));if(-1!==l){const e=l*t,n=R.current;n&&(T(!0),S.current=!0,requestAnimationFrame(()=>{m(e),requestAnimationFrame(()=>{n&&(n.scrollTop=e,setTimeout(()=>{S.current=!1,T(!1)},200))})}))}else T(!0),S.current=!0,requestAnimationFrame(()=>{_(o,!0),setTimeout(()=>{S.current=!1,T(!1)},200)})},[E,t,n,_]);return r.useEffect(()=>{z(F.visibleItems)},[F.visibleItems,z]),r.useEffect(()=>{const t=I.current,r=t.getMonth(),a=t.getFullYear(),o=e.getMonth(),l=e.getFullYear();if(r!==o||a!==l){const t=6,r=F.displayStartIndex,a=Math.min(E.length-1,r+t-1);let s=!1;for(let t=r;t<=a;t++){const n=E[t];if(n&&n.days.some(t=>t.date.toDateString()===e.toDateString())){s=!0;break}}if(!s){const e=new Date(l,o,1),t=c(o,l);d.current={month:t,year:l},y(t),w(l),null==n||n(t,l),_(e,!0)}}I.current=e},[e,n,_,F,E,c]),r.useEffect(()=>{const e=R.current;if(!e)return;const t=new ResizeObserver(([e])=>{f(e.contentRect.height)});return t.observe(e),()=>t.disconnect()},[]),r.useEffect(()=>{const e=R.current;e&&!M&&l&&requestAnimationFrame(()=>{e&&h>0?(e.scrollTop=h,m(h),N(!0)):e&&N(!0)})},[M,h,l]),r.useEffect(()=>()=>{H.current&&clearTimeout(H.current)},[]),{scrollTop:g,containerHeight:p,currentMonth:v,currentYear:b,isScrolling:x,isNavigating:k,virtualData:F,scrollElementRef:R,handleScroll:V,scrollToDate:_,handlePreviousMonth:Z,handleNextMonth:B,handleToday:q,setScrollTop:m,setContainerHeight:f,setCurrentMonth:y,setCurrentYear:w,setIsScrolling:D,cache:O.current,scrollElementRefCallback:$,weeksData:E}})({currentDate:m,weekHeight:k,onCurrentMonthChange:(t,n)=>{const r=g.startsWith("zh")||g.startsWith("ja"),a=h(g,r?"short":"long").indexOf(t);a>=0&&e.setVisibleMonth(new Date(n,a,1))},initialWeeksToLoad:156,locale:g,isEnabled:S}),ve=r.useRef(0),[ye,be]=r.useState(0),we=r.useMemo(()=>ye-6*k,[ye,k]),{visibleWeeks:xe,startIndex:De}=r.useMemo(()=>{const{visibleItems:e,displayStartIndex:t}=ie,n=e.findIndex(e=>e.index===t);if(-1===n)return R.current.length>0?{visibleWeeks:R.current,startIndex:ve.current}:{visibleWeeks:[],startIndex:t};const r=e.slice(n,n+8);return r.length>=6&&(R.current=r,ve.current=t),{visibleWeeks:r,startIndex:t}},[ie]),Ce=r.useMemo(()=>De*k,[De,k]),ke=r.useRef(!0),Te=r.useRef(!1),Me=((e,t)=>{const[n,a]=r.useState(e);return r.useEffect(()=>{const n=setTimeout(()=>{a(e)},t);return()=>{clearTimeout(n)}},[e,t]),n})(ie.displayStartIndex,250);r.useEffect(()=>{ue&&(Te.current=!0)},[ue]),r.useEffect(()=>{if(ke.current)return void(ke.current=!1);const t=de[Me];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,Te.current?"navigation":"scroll"),Te.current=!1},[e,de,Me]);const Ne=r.useMemo(()=>{const e=ie.totalHeight,t=De*k+16*k+we;return Math.max(0,e-t)},[ie.totalHeight,De,k,we]);r.useEffect(()=>{const e=ce.current;if(!e)return;const t=new ResizeObserver(t=>{for(const n of t){const t=n.contentRect.height;if(be(t),!S&&t>0){const n=Math.max(80,Math.floor(t/6));if(n!==I.current){const t=e.scrollTop;if(t>0){const r=Math.round(t/I.current)*n;e.scrollTop=r,fe(r)}}T(n),I.current=n,requestAnimationFrame(()=>{M(!0)})}}});return t.observe(e),()=>{t.disconnect()}},[ce,S,fe]),r.useEffect(()=>{const e=window.innerHeight-150,t=Math.max(80,Math.floor(e/6));T(t)},[]);const Ie=r.useCallback(t=>{e.updateEvent(t.id,t)},[e]),Re=r.useCallback(t=>{e.deleteEvent(t)},[e]),He=t=>{e.changeView(t)},Oe=r.useCallback(()=>O(null),[]),Pe=r.useCallback(t=>{const n=e.getReadOnlyConfig().viewable;if(("desktop"!==w||x)&&t&&n){const e=y.find(e=>e.id===t);if(e)return $(e),void L(!0)}Z(t)},[w,x,y,Z,e]),Le=r.useCallback(e=>{("desktop"!==w||x)&&Z(e)},[w,x,Z]);return ae("div",{className:Ee,children:[ae(yr,{calendar:e,viewType:exports.ViewType.MONTH,currentDate:m,customTitle:g.startsWith("zh")||g.startsWith("ja")?`${le}年${oe}`:`${oe} ${le}`,onPrevious:()=>{e.goToPrevious(),ge()},onNext:()=>{e.goToNext(),me()},onToday:()=>{e.goToToday(),pe()}}),ae("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:ae("div",{className:"grid grid-cols-7 px-2",children:re.map((e,t)=>ae("div",{className:"text-right text-gray-500 dark:text-gray-400 text-sm py-2 pr-2 select-none",children:e},t))})}),ae("div",{ref:ce,className:Se,style:{scrollSnapType:"y mandatory",overflow:"hidden auto",visibility:S?"visible":"hidden"},onScroll:he,children:[ae("div",{style:{height:Ce}}),xe.map((r,o)=>{var l;const s=null!==(l=b.get(r.weekData.startDate.getTime()))&&void 0!==l?l:[],i=5===o?Object.assign(Object.assign({},r),{height:r.height+we}):r;return ae(Kr,{item:i,weekHeight:k,currentMonth:oe,currentYear:le,screenSize:w,isScrolling:se,calendarRef:a,events:s,onEventUpdate:Ie,onEventDelete:Re,onMoveStart:K,onCreateStart:X,onResizeStart:J,isDragging:ee,dragState:Q,newlyCreatedEventId:H,onDetailPanelOpen:Oe,onMoreEventsClick:e.onMoreEventsClick,onChangeView:He,onSelectDate:e.selectDate,selectedEventId:V,onEventSelect:Pe,onEventLongPress:Le,detailPanelEventId:_,onDetailPanelToggle:B,customDetailPanelContent:t,customEventDetailDialog:n,onCalendarDrop:te,onCalendarDragOver:ne,calendarSignature:f,app:e,enableTouch:x},`week-${r.weekData.startDate.getTime()}`)}),ae("div",{style:{height:Ne}})]}),ae(C,{isOpen:P,onClose:()=>{L(!1),$(null)},onSave:t=>{y.find(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),L(!1),$(null)},draftEvent:A,app:e})]})},Jr={enableDrag:!0,enableResize:!1,enableCreate:!0,showOtherMonth:!0,weekHeight:120,showWeekNumbers:!1,enableVirtualScroll:!0,initialWeeksToLoad:156,dragConfig:{supportedViews:[exports.ViewType.MONTH],enableAllDayCreate:!1},eventsConfig:{enableAutoRecalculate:!0,enableValidation:!0},virtualScrollConfig:{weekHeight:120,initialWeeksToLoad:156,enableVirtualScroll:!0,enableKeyboardNavigation:!0,supportedViews:[exports.ViewType.MONTH]}},Qr=(e={})=>{const t=Object.assign(Object.assign({},Jr),e),r=e=>n.h(Ln,{viewType:exports.ViewType.MONTH,originalComponent:Xr,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 r.displayName="MonthViewAdapter",{type:exports.ViewType.MONTH,component:r,config:t}};const ea=a.memo(({date:e,isToday:t,locale:n,onSelectDate:r,onCreateStart:a,onMoreEventsClick:o,moreCount:l=0,onContextMenu:s})=>{const{t:i}=Tt(),d=e.getDate(),c=1===d,u=e.toLocaleDateString(n,{month:"short"}).toUpperCase();return ae("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==s||s(t,e)},"data-date":`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,children:[ae("div",{className:"flex items-center px-1 py-1 shrink-0 h-6",children:[c&&ae("span",{className:"text-[9px] font-bold text-primary-foreground bg-primary px-1 py-0.5 rounded-sm leading-none",children:u}),ae("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&&ae("div",{className:"absolute bottom-0.5 left-1 z-20",children:ae("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," ",i("more")]})})]})});ea.displayName="YearDayCell";const ta=({segment:e,columnsPerRow:t,isDragging:o,isSelected:l,onMoveStart:s,onResizeStart:i,onEventSelect:d,detailPanelEventId:c,onDetailPanelToggle:u,newlyCreatedEventId:h,onDetailPanelOpen:g,customDetailPanelContent:m,customEventDetailDialog:p,app:f,calendarRef:v})=>{const{event:y,startCellIndex:b,endCellIndex:w,visualRowIndex:x,isFirstSegment:D,isLastSegment:E}=e,C=r.useContext(ne),k=r.useRef(null),T=r.useRef(null),[S,M]=r.useState(null),[N,I]=r.useState(null),[R,A]=r.useState(!1);r.useEffect(()=>{if((null==f?void 0:f.state.highlightedEventId)===y.id){A(!0);const e=setTimeout(()=>{A(!1)},300);return()=>{clearTimeout(e),A(!1)}}},[null==f?void 0:f.state.highlightedEventId,y.id]);const $=c===e.id,j=!(null==f?void 0:f.state.readOnly),Y=r.useCallback(()=>{null==u||u(null),d&&d(null)},[u,d]),F=r.useCallback(e=>null==f?void 0:f.updateEvent(e.id,e),[f]),z=r.useCallback(e=>null==f?void 0:f.deleteEvent(e),[f]),V=r.useMemo(()=>({event:y,isAllDay:!!y.allDay,onEventUpdate:F,onEventDelete:z,onClose:Y}),[y,F,z,Y]),_=r.useCallback(()=>ae(hn,{store:C,generatorName:"eventDetailContent",generatorArgs:V}),[C,V]),W=r.useMemo(()=>({event:y,isOpen:$,isAllDay:!!y.allDay,onClose:Y,app:f,onEventUpdate:F,onEventDelete:z}),[y,$,Y,f,F,z]),Z=b/t*100,U=(w-b+1)/t*100,B=y.calendarId||"blue",q=l?P(B):H(B),G=l?"#fff":O(B),K=L(B),X=!!y.allDay,J=X?br(y):null,Q=18*x,ee=r.useCallback(()=>{if(!k.current||!(null==v?void 0:v.current))return;const e=v.current.getBoundingClientRect(),t=k.current.getBoundingClientRect(),n=Math.min(window.innerWidth,e.right),r=Math.min(window.innerHeight,e.bottom);requestAnimationFrame(()=>{if(!T.current)return void requestAnimationFrame(()=>{if(!T.current)return;const a=T.current.getBoundingClientRect(),o=a.width||340,l=a.height||240;let s,i;const d=n-t.right,c=t.left-e.left;s=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;i=u<h?h:u+l>g?Math.max(h,g-l):u,M({top:i,left:s,eventHeight:t.height,eventMiddleY:t.top+t.height/2,isSunday:s<t.left})});const a=T.current.getBoundingClientRect(),o=a.width||340,l=a.height||240;let s,i;const d=n-t.right,c=t.left-e.left;s=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;i=u<h?h:u+l>g?Math.max(h,g-l):u,M({top:i,left:s,eventHeight:t.height,eventMiddleY:t.top+t.height/2,isSunday:s<t.left})})},[v,S]),te=()=>{null==u||u(e.id)};r.useEffect(()=>{h===y.id&&!$&&D&&setTimeout(()=>{te(),null==g||g()},50)},[h,y.id,$,g,D]),r.useEffect(()=>{$&&!S&&(M({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>{ee()}))},[$,S,ee]),r.useEffect(()=>{if(!$)return;const e=()=>{ee()};return window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[$,ee]);const re=e=>{const t="left"===e,n=t?D:E;return y.allDay&&n&&i&&j?ae("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(),i(e,y,t?"left":"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}):null},oe=w-b+1;return ae(n.Fragment,{children:[ae("div",{ref:k,className:"df-year-event absolute z-30 text-[12px] px-1 overflow-hidden whitespace-nowrap cursor-pointer transition-colors group",style:{left:`calc(${Z}% + 2px)`,top:`${Q}px`,height:"16px",backgroundColor:q,color:G,opacity:1,width:`calc(${U}% - 4px)`,pointerEvents:o?"none":"auto",borderRadius:D&&E?"0.25rem":D?"0.25rem 0 0 0.25rem":E?"0 0.25rem 0.25rem 0":"0",transform:R?"scale(1.05)":"scale(1)",transition:"transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)"},"data-segment-days":oe,"data-event-id":y.id,onMouseDown:e=>{e.stopPropagation(),s&&s(e,y)},onClick:e=>{e.preventDefault(),e.stopPropagation(),d&&d(y.id)},onDblClick:e=>{e.preventDefault(),e.stopPropagation(),te()},onTouchStart:e=>{e.stopPropagation(),d&&d(y.id),s&&s(e,y)},onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),d&&d(y.id),I({x:e.clientX,y:e.clientY})},title:y.title,children:[re("left"),(()=>{if(y.allDay){const t=()=>e.isFirstSegment?y.title:"···";return ae("div",{className:"df-year-event-content flex items-center min-w-0 w-full pointer-events-auto h-full",children:[e.isFirstSegment&&br(y)&&ae("div",{className:"df-year-event-icon shrink-0 mr-1",children:ae("div",{className:"rounded-full p-0.5 text-white flex items-center justify-center",style:{backgroundColor:L(B),width:"12px",height:"12px"},children:br(y)})}),ae("div",{className:"flex-1 min-w-0",children:ae("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&&ae("div",{className:"shrink-0 ml-1 text-white/80 dark:text-white/90",children:ae("div",{className:"w-1.5 h-1.5 rounded-full bg-white/60 dark:bg-white/80"})})]})}const t=e.isFirstSegment?y.title:"";return ae("div",{className:"df-year-event-content w-full h-full flex items-center overflow-hidden gap-1 pointer-events-auto",children:[!X&&ae("span",{style:{backgroundColor:K},className:"df-year-event-indicator inline-block w-0.75 h-3 shrink-0 rounded-full"}),X&&J&&ae("div",{className:"df-year-event-icon shrink-0 flex items-center justify-center opacity-80 scale-75",children:J}),ae("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(!$||!v)return null;if(null==C?void 0:C.isOverridden("eventDetailDialog"))return ae(hn,{store:C,generatorName:"eventDetailDialog",generatorArgs:W});if(p){const e=p;if("undefined"==typeof window||"undefined"==typeof document)return null;const t=document.body;return t?a.createPortal(ae(e,Object.assign({},W)),t):null}if(!S)return null;const e={event:y,position:S,panelRef:T,isAllDay:!!y.allDay,onClose:Y,onEventUpdate:F,onEventDelete:z,eventVisibility:"visible",calendarRef:v,selectedEventElementRef:k};return(null==C?void 0:C.isOverridden("eventDetailContent"))?ae(Cr,Object.assign({},e,{contentRenderer:_})):m?ae(Cr,Object.assign({},e,{contentRenderer:m})):ae(Er,Object.assign({},e,{app:f}))})(),N&&f&&ae($r,{event:y,x:N.x,y:N.y,onClose:()=>I(null),app:f,onDetailPanelToggle:u,detailPanelKey:e.id})]})},na=a.memo(({rowDays:e,events:t,columnsPerRow:n,app:a,calendarRef:o,locale:l,isDragging:s,dragState:i,onMoveStart:d,onResizeStart:c,onCreateStart:u,selectedEventId:h,onEventSelect:g,onMoreEventsClick:m,newlyCreatedEventId:p,onDetailPanelOpen:f,detailPanelEventId:v,onDetailPanelToggle:y,customDetailPanelContent:b,customEventDetailDialog:w})=>{const x=new Date;x.setHours(0,0,0,0);const[D,C]=r.useState(null),k=(e,t)=>{e.preventDefault(),e.stopPropagation(),C({x:e.clientX,y:e.clientY,date:t})},T=r.useMemo(()=>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(),s=e.filter(e=>{if(!e.start)return!1;const t=E(e.start),n=e.end?E(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});s.sort((e,t)=>{const n=E(e.start).getTime(),r=e.end?E(e.end).getTime():n,a=E(t.start).getTime(),o=r-n,l=(t.end?E(t.end).getTime():a)-a;return o!==l?l-o:n-a});const i=[],d=[];return s.forEach(e=>{const a=E(e.start),s=e.end?E(e.end):a,c=new Date(a.getFullYear(),a.getMonth(),a.getDate()).getTime(),u=new Date(s.getFullYear(),s.getMonth(),s.getDate()).getTime();let h=-1,g=-1;const m=Math.round((c-o)/864e5);h=m>=0?m:0;const p=Math.round((u-o)/864e5);g=p<t.length?p: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,v=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++}i.push({id:`${e.id}_${r.getTime()}`,event:e,startCellIndex:h,endCellIndex:g,isFirstSegment:f,isLastSegment:v,visualRowIndex:y})}),i}(t,e,n),[t,e,n]),{visibleSegments:S,moreCounts:M}=r.useMemo(()=>{const t=new Array(e.length).fill(0);T.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 T.forEach(a=>{let o=!0;const l=Math.max(0,a.startCellIndex),s=Math.min(e.length-1,a.endCellIndex);for(let e=l;e<=s;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<=s;e++)r[e]++}),{visibleSegments:n,moreCounts:r}},[T,e.length]);return ae("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 ae(ea,{date:e,isToday:n,locale:l,onSelectDate:e=>{a.selectDate(e)},onCreateStart:u,onMoreEventsClick:m,moreCount:M[t],onContextMenu:k},e.getTime())}),ae("div",{className:"absolute inset-0 pointer-events-none",style:{top:26,bottom:0,left:0,right:0},onContextMenu:e=>e.preventDefault(),children:ae("div",{className:"relative w-full h-full",children:S.map(e=>ae("div",{className:"pointer-events-auto",children:ae(ta,{segment:e,columnsPerRow:n,isDragging:s&&i.eventId===e.event.id,isSelected:h===e.event.id,onMoveStart:d,onResizeStart:c,onEventSelect:g,onDetailPanelToggle:y,newlyCreatedEventId:p,onDetailPanelOpen:f,calendarRef:o,app:a,detailPanelEventId:v,customDetailPanelContent:b,customEventDetailDialog:w})},e.id))})}),D&&ae(Ar,{x:D.x,y:D.y,date:D.date,viewType:exports.ViewType.YEAR,onClose:()=>C(null),app:a,onCreateEvent:()=>{if(u){const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:D.x,clientY:D.y};u(e,D.date)}}})]})});na.displayName="YearRowComponent";const ra=({app:e,calendarRef:n,customDetailPanelContent:a,customEventDetailDialog:o,config:l,selectedEventId:s,onEventSelect:i,detailPanelEventId:d,onDetailPanelToggle:c})=>{var u;const{t:h,locale:g}=Tt(),m=e.getCurrentDate(),p=m.getFullYear(),f=e.getEvents(),v=r.useRef(null),[y,b]=r.useState(()=>"undefined"!=typeof window?Math.max(1,Math.floor(window.innerWidth/80)):7),[w,x]=r.useState(!1),[D,C]=r.useState(null),[k,T]=r.useState(null),S=void 0!==s?s:D,M=void 0!==d?d:k,N=e=>{i?i(e):C(e)},I=e=>{c?c(e):T(e)},[R,H]=r.useState(null);r.useEffect(()=>{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||(N(null),I(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),r.useEffect(()=>{const e=v.current;if(!e)return;const t=new ResizeObserver(e=>{const t=e[0].contentRect.width,n=Math.floor(t/80);b(Math.max(1,n)),x(!0)});return t.observe(e),()=>t.disconnect()},[]);const O=r.useRef(e.state.highlightedEventId);r.useEffect(()=>{e.state.highlightedEventId?N(e.state.highlightedEventId):O.current&&N(null),O.current=e.state.highlightedEventId},[e.state.highlightedEventId]);const{handleMoveStart:P,handleResizeStart:L,handleCreateStart:A,dragState:$,isDragging:j}=gr(e,{calendarRef:n,viewType:exports.ViewType.YEAR,onEventsUpdate:(t,n)=>{t(f).forEach(t=>{const r=f.find(e=>e.id===t.id);!r||r.start===t.start&&r.end===t.end||e.updateEvent(t.id,t,n)})},currentWeekStart:new Date,events:f,onEventCreate:t=>{e.addEvent(t)},onEventEdit:e=>{H(e.id)}}),Y=null!==(u=null==l?void 0:l.showTimedEventsInYearView)&&void 0!==u&&u,F=r.useCallback((n,r)=>{if(Y)null==A||A(n,r);else{const n=t.Temporal.PlainDate.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate()}),a={id:`event-${Date.now()}`,title:h("newEvent")||"New Event",start:n,end:n,allDay:!0};e.addEvent(a),H(a.id)}},[Y,A,e]),z=r.useMemo(()=>{const e=[],t=new Date(p,0,1),n=new Date(p,11,31),r=new Date(t);for(;r<=n;)e.push(new Date(r)),r.setDate(r.getDate()+1);return e},[p]),V=r.useMemo(()=>function(e,t){const n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}(z,y),[z,y]),_=r.useMemo(()=>{const e=new Date(p,0,1),t=new Date(p,11,31,23,59,59);return f.filter(n=>{if(!n.start)return!1;if(!Y&&!n.allDay)return!1;const r=E(n.start),a=n.end?E(n.end):r;return r<=t&&a>=e})},[f,p,Y]);return ae("div",{className:Ee,onContextMenu:e=>e.preventDefault(),children:[ae(yr,{calendar:e,viewType:exports.ViewType.YEAR,currentDate:m,customTitle:g.startsWith("zh")||g.startsWith("ja")?`${p}年`:`${p}`,onPrevious:()=>{const t=new Date(m);t.setFullYear(t.getFullYear()-1),e.setCurrentDate(t)},onNext:()=>{const t=new Date(m);t.setFullYear(t.getFullYear()+1),e.setCurrentDate(t)},onToday:()=>{e.goToToday()}}),ae("div",{ref:v,className:`${Se} ${Me}`,style:{overflow:"hidden auto"},children:ae("div",{className:"w-full flex flex-col border-t border-l border-gray-100 dark:border-gray-800",style:{opacity:w?1:0,transition:"opacity 0.2s ease"},children:V.map((t,r)=>ae(na,{rowDays:t,events:_,columnsPerRow:y,app:e,calendarRef:n,locale:g,isDragging:j,dragState:$,onMoveStart:P,onResizeStart:L,onCreateStart:F,selectedEventId:S,onEventSelect:N,onMoreEventsClick:e.onMoreEventsClick,newlyCreatedEventId:R,onDetailPanelOpen:()=>H(null),detailPanelEventId:M,onDetailPanelToggle:I,customDetailPanelContent:a,customEventDetailDialog:o},r))})})]})};function aa(e,t,n){const r=new Date(n,t,1),a=new Date(n,t+1,0).getDate(),o=r.getDay(),l=r.getTime(),s=new Date(n,t,a,23,59,59,999).getTime(),i=e.filter(e=>{if(!e.start)return!1;const t=E(e.start),n=e.end?E(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});i.sort((e,t)=>{const n=E(e.start).getTime(),r=e.end?E(e.end).getTime():n,a=E(t.start).getTime(),o=r-n,l=(t.end?E(t.end).getTime():a)-a;return o!==l?l-o:n-a});const d=[],c=[];i.forEach(e=>{const r=E(e.start),a=e.end?E(e.end):r,i=new Date(Math.max(r.getTime(),l)),u=new Date(Math.min(a.getTime(),s)),h=i.getDate(),g=u.getDate(),m=o+(h-1),p=o+(g-1),f=r.getMonth()===t&&r.getFullYear()===n,v=a.getMonth()===t&&a.getFullYear()===n;let y=0;for(;;){let e=!1;c[y]||(c[y]=[]);for(let t=m;t<=p;t++)if(c[y][t]){e=!0;break}if(!e){for(let e=m;e<=p;e++)c[y][e]=!0;break}y++}d.push({id:`${e.id}_month_${t}`,event:e,startCellIndex:m,endCellIndex:p,isFirstSegment:f,isLastSegment:v,visualRowIndex:y,monthIndex:t})});const u=d.length>0?Math.max(...d.map(e=>e.visualRowIndex)):-1;return{segments:d,maxVisualRow:u}}const oa=({app:e,calendarRef:n,customDetailPanelContent:a,customEventDetailDialog:o,config:l,selectedEventId:s,onEventSelect:i,detailPanelEventId:d,onDetailPanelToggle:c})=>{var u;const{t:h,locale:g,getWeekDaysLabels:m}=Tt(),p=e.getCurrentDate(),f=p.getFullYear(),v=e.getEvents(),y=new Date;y.setHours(0,0,0,0);const b=r.useRef(null),w=r.useRef(null),x=r.useRef(null),[D,C]=r.useState(0),[k,T]=r.useState(0),[S,M]=r.useState(null),[N,I]=r.useState(null),R=void 0!==s?s:S,H=void 0!==d?d:N,O=e=>{i?i(e):M(e)},P=e=>{c?c(e):I(e)},[L,A]=r.useState(null),[$,j]=r.useState(null);r.useEffect(()=>{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)},[]);const Y=r.useMemo(()=>{let e=0;for(let t=0;t<12;t++){const n=new Date(f,t,1),r=new Date(f,t+1,0).getDate(),a=n.getDay()+r;a>e&&(e=a)}return e},[f]),{handleMoveStart:F,handleResizeStart:z,handleCreateStart:V,dragState:_,isDragging:W}=gr(e,{calendarRef:n,viewType:exports.ViewType.YEAR,onEventsUpdate:(t,n)=>{t(v).forEach(t=>{const r=v.find(e=>e.id===t.id);!r||r.start===t.start&&r.end===t.end||e.updateEvent(t.id,t,n)})},currentWeekStart:new Date,events:v,onEventCreate:t=>{e.addEvent(t)},onEventEdit:e=>{A(e.id)}}),Z=null!==(u=null==l?void 0:l.showTimedEventsInYearView)&&void 0!==u&&u,U=r.useCallback((n,r)=>{if(Z)null==V||V(n,r);else{const n=t.Temporal.PlainDate.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate()}),a={id:`event-${Date.now()}`,title:h("newEvent")||"New Event",start:n,end:n,allDay:!0};e.addEvent(a),A(a.id)}},[Z,V,e]),B=r.useMemo(()=>{const e=m(g,"short"),t=[e[6],...e.slice(0,6)].map(e=>{if(g.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<Y;e++)n.push(t[e%7]);return n},[g,m,Y]),q=r.useMemo(()=>{const e=new Date(f,0,1),t=new Date(f,11,31,23,59,59);return v.filter(n=>{if(!n.start)return!1;if(!Z&&!n.allDay)return!1;const r=E(n.start),a=n.end?E(n.end):r;return r<=t&&a>=e})},[v,f,Z]);console.log("yearEvents",q.length);const G=r.useMemo(()=>{const e=[];for(let t=0;t<12;t++){const n=new Date(f,t,1),r=new Date(f,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(f,t,e));for(;o.length<Y;)o.push(null);const l=n.toLocaleDateString(g,{month:"short"}),s=l.charAt(0).toUpperCase()+l.slice(1).toLowerCase(),{segments:i,maxVisualRow:d}=aa(q,t,f),c=d+1,u=Math.max(60,20+18*c);e.push({monthIndex:t,monthName:s,days:o,eventSegments:i,minHeight:u})}return e},[f,g,Y,q]),K=r.useCallback(e=>{const t=e.currentTarget;b.current&&(b.current.scrollLeft=t.scrollLeft),w.current&&(w.current.scrollTop=t.scrollTop)},[]);r.useEffect(()=>{const e=()=>{if(x.current){const e=x.current,t=e.offsetHeight-e.clientHeight,n=e.offsetWidth-e.clientWidth;T(e=>e!==t?t:e),C(e=>e!==n?n:e)}},t=x.current;if(!t)return;e();const n=new ResizeObserver(()=>{e()});return n.observe(t),()=>{n.disconnect()}},[G]);return ae("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:[ae("div",{className:"col-span-2",children:ae(yr,{calendar:e,viewType:exports.ViewType.YEAR,currentDate:p,customTitle:g.startsWith("zh")||g.startsWith("ja")?`${f}年`:`${f}`,onPrevious:()=>{const t=new Date(p);t.setFullYear(t.getFullYear()-1),e.setCurrentDate(t)},onNext:()=>{const t=new Date(p);t.setFullYear(t.getFullYear()+1),e.setCurrentDate(t)},onToday:()=>{e.goToToday()}})}),ae("div",{className:"bg-gray-50 dark:bg-gray-900 border-r border-b border-gray-200 dark:border-gray-800 z-30"}),ae("div",{ref:b,className:"overflow-hidden bg-gray-50 dark:bg-gray-900 border-b border-gray-200 dark:border-gray-800",children:ae("div",{className:"flex",style:{minWidth:`calc(1352px + ${D}px)`},children:[ae("div",{className:"grid flex-1",style:{gridTemplateColumns:`repeat(${Y}, minmax(0, 1fr))`,minWidth:"1352px"},children:B.map((e,t)=>{const n=t%7;return ae("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)})}),D>0&&ae("div",{className:"shrink-0 bg-gray-50 dark:bg-gray-900",style:{width:`${D}px`}})]})}),ae("div",{ref:w,className:"overflow-hidden bg-white dark:bg-gray-900 border-r border-gray-200 dark:border-gray-700",children:ae("div",{className:"flex flex-col min-h-full",children:[G.map(e=>ae("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)),k>0&&ae("div",{className:"shrink-0 bg-white dark:bg-gray-900",style:{height:`${k}px`}})]})}),ae("div",{ref:x,className:`overflow-auto ${Me}`,onScroll:K,children:ae("div",{className:"flex flex-col min-h-full",style:{minWidth:"1352px"},children:G.map(t=>ae("div",{className:"relative grow shrink-0",style:{minHeight:`${t.minHeight}px`},children:[ae("div",{className:"grid absolute inset-0 z-0",style:{gridTemplateColumns:`repeat(${Y}, minmax(0, 1fr))`},children:t.days.map((t,n)=>{const r=n%7,a=0===r||6===r;if(!t)return ae("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()===y.getTime())(t);return ae("div",{"data-date":`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.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:()=>e.selectDate(t),onDblClick:e=>U(e,t),onContextMenu:e=>((e,t)=>{e.preventDefault(),e.stopPropagation(),j({x:e.clientX,y:e.clientY,date:t})})(e,t),children:ae("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:t.getDate()})},t.getTime())})}),t.eventSegments.length>0&&ae("div",{className:"absolute inset-0 pointer-events-none z-20",style:{top:20},children:ae("div",{className:"relative w-full h-full",children:t.eventSegments.map(t=>ae("div",{className:"pointer-events-auto",children:ae(ta,{segment:t,columnsPerRow:Y,isDragging:W&&_.eventId===t.event.id,isSelected:R===t.event.id,onMoveStart:F,onResizeStart:z,onEventSelect:O,onDetailPanelToggle:P,newlyCreatedEventId:L,onDetailPanelOpen:()=>A(null),calendarRef:n,app:e,detailPanelEventId:H,customDetailPanelContent:a,customEventDetailDialog:o})},t.id))})})]},t.monthIndex))})}),$&&ae(Ar,{x:$.x,y:$.y,date:$.date,viewType:exports.ViewType.YEAR,onClose:()=>j(null),app:e,onCreateEvent:()=>{const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:$.x,clientY:$.y};U(e,$.date)}})]})},la=e=>{var t;return ae("fixed-week"===((null===(t=e.config)||void 0===t?void 0:t.mode)||"year-canvas")?oa:ra,Object.assign({},e))},sa={enableDrag:!1,enableResize:!1,enableCreate:!1,enableVirtualScroll:!0,showDebugInfo:!1,eventsConfig:{enableAutoRecalculate:!1,enableValidation:!0}};const ia={enableAutoRecalculate:!0,enableValidation:!0,defaultEvents:[],maxEventsPerDay:50};Object.defineProperty(exports,"createPortal",{enumerable:!0,get:function(){return a.createPortal}}),exports.BlossomColorPicker=bn,exports.CalendarApp=class{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 m(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 exports.ViewType.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 exports.ViewType.WEEK:{const{monday:t}=V(this.state.currentDate),n=new Date(t),r=new Date(t);r.setDate(r.getDate()+7),this.emitVisibleRange(n,r,e);break}case exports.ViewType.MONTH:{if("navigation"===e)break;const t=new Date(this.state.currentDate.getFullYear(),this.state.currentDate.getMonth(),1),{monday:n}=V(t),r=new Date(n),a=new Date(n);a.setDate(a.getDate()+42),this.emitVisibleRange(r,a,e);break}case exports.ViewType.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 exports.ViewType.DAY:e.setDate(e.getDate()-1);break;case exports.ViewType.WEEK:e.setDate(e.getDate()-7);break;case exports.ViewType.MONTH:e.setMonth(e.getMonth()-1);break;case exports.ViewType.YEAR:e.setFullYear(e.getFullYear()-1)}this.setCurrentDate(e)},this.goToNext=()=>{const e=new Date(this.state.currentDate);switch(this.state.currentView){case exports.ViewType.DAY:e.setDate(e.getDate()+1);break;case exports.ViewType.WEEK:e.setDate(e.getDate()+7);break;case exports.ViewType.MONTH:e.setMonth(e.getMonth()+1);break;case exports.ViewType.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)):p.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 p.warn("Cannot update event in read-only mode")},this.deleteEvent=e=>{this.isInternalEditable()?(this.pendingSnapshot=null,this.pushToUndo(),this.store.deleteEvent(e)):p.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 s=this.calendarRegistry.get(e);s&&(null===(a=(r=this.callbacks).onCalendarUpdate)||void 0===a||a.call(r,s)),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)?p.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||ee(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);ee(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||exports.ViewType.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 m(this.state.events),this.setupStoreListeners(),this.calendarRegistry=new c(e.calendars,e.defaultCalendar,(null===(t=e.theme)||void 0===t?void 0:t.mode)||"light"),o=this.calendarRegistry,u=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?b(e)?e:"en-US":e&&"object"==typeof e&&!b(e.code)?Object.assign(Object.assign({},e),{code:"en-US"}):e:"en-US"}},exports.CalendarRegistry=c,exports.CalendarRenderer=class{constructor(e,t){this.app=e,this.container=null,this.unsubscribe=null,this.renderRequested=!1,this.extraProps={},this.customRenderingStore=new te(t),this.unsubscribe=e.subscribe(()=>this.requestRender())}setProps(e){ee(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&&(n.render(null,this.container),this.container=null),this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null)}getCustomRenderingStore(){return this.customRenderingStore}render(){this.container&&n.render(n.h(ne.Provider,{value:this.customRenderingStore},n.h(Pn,Object.assign({app:this.app},this.extraProps))),this.container)}},exports.Check=he,exports.ChevronRight=le,exports.ChevronsUpDown=ge,exports.ContentSlot=hn,exports.ContextMenu=Nr,exports.ContextMenuColorPicker=({selectedColor:e,onSelect:t,onCustomColor:n})=>{const{t:r}=Tt();return ae("div",{children:[ae("div",{className:"grid grid-cols-7 gap-2 p-1 px-3",children:Lr.map(n=>ae("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&&ae("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")})]})},exports.ContextMenuItem=Ir,exports.ContextMenuLabel=({children:e})=>ae("div",{className:"px-3 py-0.5 text-[12px] font-semibold text-slate-950 dark:text-slate-50",children:e}),exports.ContextMenuSeparator=Rr,exports.CreateCalendarDialog=kn,exports.CustomRenderingStore=te,exports.DefaultColorPicker=wn,exports.LAYOUT_CONFIG={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},exports.LOCALES=v,exports.LocaleContext=kt,exports.LocaleProvider=St,exports.MiniCalendar=Tn,exports.PanelRightClose=({className:e,width:t=24,height:n=24})=>ae("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:[ae("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),ae("path",{d:"M15 3v18"}),ae("path",{d:"m8 9 3 3-3 3"})]}),exports.PanelRightOpen=({className:e,width:t=24,height:n=24})=>ae("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:[ae("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),ae("path",{d:"M15 3v18"}),ae("path",{d:"m10 15-3-3 3-3"})]}),exports.Plus=ce,exports.TIME_STEP=.25,exports.VIRTUAL_MONTH_SCROLL_CONFIG=s,exports.WeekDataCache=i,exports.addDays=function(e,t){const n=new Date(e);return n.setDate(n.getDate()+t),n},exports.buildParseRegExp=pt,exports.calculateDayIndex=K,exports.calendarPickerDropdown=Ze,exports.cancelButton="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)",exports.capitalize=xt,exports.clipboardStore=Gt,exports.conditionalTheme=(e,t,n)=>e?t:n,exports.convertDateEvent=function(e,t,n,r,a=!1,o){return _t(Object.assign({id:e,title:t,start:n,end:r,allDay:a},o))},exports.convertDateEventWithTimeZone=function(e,t,n,r,a,o){return Wt(Object.assign({id:e,title:t,start:n,end:r,timeZone:a},o))},exports.createAllDayEvent=function(e,t,n,r){return _t(Object.assign({id:e,title:t,start:n,end:n,allDay:!0},r))},exports.createDateWithHour=I,exports.createDayView=Wr,exports.createEvent=_t,exports.createEventWithDate=(e,t)=>{var n,r;const a=q(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:G(a,o),end:G(a,o)})},exports.createEventWithRealDate=(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:G(a,o),end:G(a,o)})},exports.createEvents=function(e){return e.map(e=>_t(e))},exports.createEventsPlugin=function(e={}){const t=Object.assign(Object.assign({},ia),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=X(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 s=Object.assign(Object.assign({},l),o);if(t.enableValidation){const e=r.validateEvent(s);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=X(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=E(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=E(n.start),a=E(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)=>X(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,p.log("Events plugin installed - providing event management services")},api:r}},exports.createMonthView=Qr,exports.createStandardViews=function(e){return[Wr(null==e?void 0:e.day),Gr(null==e?void 0:e.week),Qr(null==e?void 0:e.month)]},exports.createTemporalWithHour=C,exports.createTimedEvent=function(e,t,n,r,a){return _t(Object.assign({id:e,title:t,start:n,end:r},a))},exports.createTimezoneEvent=Wt,exports.createTimezoneEvents=function(e){return e.map(e=>Wt(e))},exports.createWeekView=Gr,exports.createYearView=(e={})=>{const t=Object.assign(Object.assign({},sa),e);e.mode&&(t.viewConfig=Object.assign(Object.assign({},t.viewConfig),{mode:e.mode}));const r=e=>n.h(Ln,{viewType:exports.ViewType.YEAR,originalComponent:la,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 r.displayName="YearViewAdapter",{type:exports.ViewType.YEAR,component:r,config:t}},exports.dateToPlainDate=st,exports.dateToPlainDateTime=it,exports.dateToZonedDateTime=dt,exports.daysBetween=function(e,n){const r=e=>w(e)?e:"function"==typeof e.toPlainDate?e.toPlainDate():t.Temporal.PlainDate.from({year:e.year,month:e.month,day:e.day}),a=r(e),o=r(n);return a.until(o).days},exports.daysDifference=M,exports.downloadICS=function(e,t={}){const n=on(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)},exports.en=f,exports.extractHourFromDate=N,exports.extractHourFromTemporal=function(e){return e instanceof Date?e.getHours()+e.getMinutes()/60:rt(e)?0:e.hour+e.minute/60},exports.formatDate=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}`},exports.formatDateConsistent=jt,exports.formatDateToICSTimestamp=tn,exports.formatEventTimeRange=$,exports.formatICSDate=en,exports.formatMonthYear=e=>`${["January","February","March","April","May","June","July","August","September","October","November","December"][e.getMonth()]} ${e.getFullYear()}`,exports.formatTemporal=bt,exports.formatTime=A,exports.generateDayData=_,exports.generateICS=on,exports.generateUniKey=Q,exports.generateWeekData=W,exports.generateWeekRange=U,exports.generateWeeksData=(e,t=3)=>{const n=5*t,{monday:r}=V(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(W(t))}return a},exports.getAllDayEventsForDay=(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=E(t.start);a.setHours(0,0,0,0);const o=E(t.end);return o.setHours(0,0,0,0),r>=a&&r<=o}),exports.getCalendarColorsForHex=g,exports.getCurrentWeekDates=()=>{const e=new Date,t=new Date,n=e.getDay(),r=e.getDate()-n+(0===n?-6:1);return Y.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()}})},exports.getDateByDayIndex=q,exports.getDateObj=Zt,exports.getDayIndexByDate=(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)},exports.getEndOfDay=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(23,59,59,999),t}return S(e)},exports.getEndOfTemporal=S,exports.getEventBgColor=H,exports.getEventEndHour=j,exports.getEventTextColor=O,exports.getEventsForDay=B,exports.getEventsForWeek=(e,t)=>{const n=new Date(t);return n.setDate(t.getDate()+6),n.setHours(23,59,59,999),e.filter(e=>{const r=E(e.start);return r>=t&&r<=n}).map(e=>{const n=K(E(e.start),t);return Object.assign(Object.assign({},e),{day:n})})},exports.getIntlLabel=wt,exports.getLineColor=L,exports.getMonthLabels=Et,exports.getMonthYearOfWeek=Z,exports.getPlainDate=ct,exports.getSearchHeaderInfo=Bt,exports.getSelectedBgColor=P,exports.getStartOfDay=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(0,0,0,0),t}return T(e)},exports.getStartOfTemporal=T,exports.getTestEvents=function(){const e=new Date,n=e.getDay(),r=new Date(e),a=0===n?-6:1-n;return r.setDate(e.getDate()+a),r.setHours(0,0,0,0),[{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(e=>{const n=new Date(r);if(n.setDate(r.getDate()+e.day),e.allDay)return{id:e.id,title:e.title,start:t.Temporal.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()}),end:t.Temporal.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()}),allDay:!0,calendarId:e.calendarId,day:e.day};const a=Math.floor(e.startHour),o=Math.round(60*(e.startHour-a)),l=Math.floor(e.endHour),s=Math.round(60*(e.endHour-l));return{id:e.id,title:e.title,start:t.Temporal.ZonedDateTime.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate(),hour:a,minute:o,timeZone:t.Temporal.Now.timeZoneId()}),end:t.Temporal.ZonedDateTime.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate(),hour:l,minute:s,timeZone:t.Temporal.Now.timeZoneId()}),allDay:!1,calendarId:e.calendarId,day:e.day}})},exports.getWeekDaysLabels=Dt,exports.getWeekRange=V,exports.getZoneId=vt,exports.groupSearchResults=qt,exports.importICSFile=function(e,t){return o.__awaiter(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=rn(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)})})},exports.isDate=function(e){return e instanceof Date},exports.isDeepEqual=ee,exports.isEventEqual=J,exports.isEventInWeek=(e,t)=>{const n=K(e,t);return n>=0&&n<=6},exports.isMultiDayEvent=(e,t)=>!R(e,t),exports.isMultiDayTemporalEvent=function(e,t){return!k(e,t)},exports.isPlainDate=rt,exports.isPlainDateTime=at,exports.isSameDay=R,exports.isSamePlainDate=k,exports.isSameTemporal=function(e,t){if(e instanceof Date&&t instanceof Date)return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate();const n=ct(e),r=ct(t);return n.equals(r)},exports.isValidLocale=b,exports.isZonedDateTime=ot,exports.mergeClasses=(...e)=>e.filter(Boolean).join(" "),exports.mergeFormatTemplate=gt,exports.monthNames=F,exports.normalizeCssWidth=function(e,t="240px"){return"number"==typeof e?`${e}px`:"string"==typeof e&&e.trim().length>0?e:t},exports.normalizeDate=Ut,exports.normalizeLocale=y,exports.normalizeToZoned=yt,exports.now=function(e=t.Temporal.Now.timeZoneId()){return t.Temporal.Now.zonedDateTimeISO(e)},exports.pad=ht,exports.parseICS=rn,exports.parseICSDate=Qt,exports.parseTemporalString=ft,exports.plainDateTimeToDate=function(e){return new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second||0,e.millisecond||0)},exports.plainDateToDate=function(e){return new Date(e.year,e.month-1,e.day)},exports.recalculateEventDays=X,exports.registerDragImplementation=function(e){ur=e},exports.registerLocale=function(e){const t=e.code.split("-")[0].toLowerCase();v[t]=e},exports.registerSidebarImplementation=function(e){In=e},exports.resolveAppliedTheme=Ft,exports.roundToTimeStep=e=>.25*Math.round(e/.25),exports.scrollbarTakesSpace=Yt,exports.setHourInTemporal=function(e,t){const n=Math.floor(t),r=Math.round(60*(t-n));return ot(e),e.with({hour:n,minute:r,second:0,millisecond:0})},exports.shortMonthNames=z,exports.sidebarContainer="df-sidebar flex h-full flex-col border-r border-gray-200 dark:border-gray-700 bg-white dark:bg-slate-900",exports.sidebarHeader="df-sidebar-header flex items-center px-2 py-1",exports.sidebarHeaderTitle="df-sidebar-header-title text-sm font-semibold text-gray-700 dark:text-gray-200",exports.sidebarHeaderToggle="df-sidebar-header-toggle flex h-8 w-8 items-center justify-center rounded hover:bg-gray-100 dark:hover:bg-slate-800",exports.t=Ct,exports.temporalToDate=lt,exports.themeClasses={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"},exports.themeCn=(e,t,n)=>`${e} ${t} ${n.split(" ").filter(Boolean).map(e=>`dark:${e}`).join(" ")}`.trim(),exports.today=function(e=t.Temporal.Now.timeZoneId()){return t.Temporal.Now.plainDateISO(e)},exports.updateEventDateAndDay=(e,n,r)=>{const a=q(r,n);return Object.assign(Object.assign({},e),{day:n,start:e.allDay?t.Temporal.PlainDate.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate()}):t.Temporal.ZonedDateTime.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate(),hour:a.getHours(),minute:a.getMinutes(),timeZone:t.Temporal.Now.timeZoneId()}),end:e.allDay?t.Temporal.PlainDate.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate()}):t.Temporal.ZonedDateTime.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate(),hour:a.getHours(),minute:a.getMinutes(),timeZone:t.Temporal.Now.timeZoneId()})})},exports.updateEventWithRealDate=(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:G(a,o),end:G(a,o)})},exports.useDragForView=gr,exports.useLocale=Tt,exports.useSidebarBridge=Hn,exports.weekDays=Y,exports.weekDaysFullName=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],exports.zonedDateTimeToDate=D;
|
|
1
|
+
"use strict";var e=require("temporal-polyfill"),t=require("preact"),n=require("preact/compat"),r=require("preact/hooks"),a=require("tslib"),o=require("@dayflow/blossom-color-picker");const l={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"}},i={en:l};function s(e){const t=e.split("-")[0].toLowerCase();return t in i?t:"en"}function d(e){try{new Intl.DateTimeFormat(e);return!0}catch(e){return!1}}var c;exports.ViewType=void 0,(c=exports.ViewType||(exports.ViewType={})).DAY="day",c.WEEK="week",c.MONTH="month",c.YEAR="year";const u={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 h{constructor(e=u.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=h.getKey(e),n=this.cache.get(t);if(n)return this.updateAccessOrder(t),n}set(e,t){const n=h.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 g;exports.TimeZone=void 0,(g=exports.TimeZone||(exports.TimeZone={})).UTC="UTC",g.NEW_YORK="America/New_York",g.CHICAGO="America/Chicago",g.DENVER="America/Denver",g.LOS_ANGELES="America/Los_Angeles",g.TORONTO="America/Toronto",g.VANCOUVER="America/Vancouver",g.PHOENIX="America/Phoenix",g.ANCHORAGE="America/Anchorage",g.HONOLULU="Pacific/Honolulu",g.MEXICO_CITY="America/Mexico_City",g.WINNIPEG="America/Winnipeg",g.HALIFAX="America/Halifax",g.ST_JOHNS="America/St_Johns",g.DETROIT="America/Detroit",g.MIAMI="America/Miami",g.SEATTLE="America/Los_Angeles",g.ATLANTA="America/New_York",g.DALLAS="America/Chicago",g.HOUSTON="America/Chicago",g.LAS_VEGAS="America/Los_Angeles",g.SAN_FRANCISCO="America/Los_Angeles",g.LONDON="Europe/London",g.PARIS="Europe/Paris",g.BERLIN="Europe/Berlin",g.MADRID="Europe/Madrid",g.ROME="Europe/Rome",g.AMSTERDAM="Europe/Amsterdam",g.ZURICH="Europe/Zurich",g.STOCKHOLM="Europe/Stockholm",g.OSLO="Europe/Oslo",g.COPENHAGEN="Europe/Copenhagen",g.MOSCOW="Europe/Moscow",g.ISTANBUL="Europe/Istanbul",g.DUBLIN="Europe/Dublin",g.LISBON="Europe/Lisbon",g.PRAGUE="Europe/Prague",g.VIENNA="Europe/Vienna",g.WARSAW="Europe/Warsaw",g.BRUSSELS="Europe/Brussels",g.ATHENS="Europe/Athens",g.BUCHAREST="Europe/Bucharest",g.HELSINKI="Europe/Helsinki",g.KYIV="Europe/Kyiv",g.BUDAPEST="Europe/Budapest",g.BELGRADE="Europe/Belgrade",g.LUXEMBOURG="Europe/Luxembourg",g.MONACO="Europe/Monaco",g.REYKJAVIK="Atlantic/Reykjavik",g.TOKYO="Asia/Tokyo",g.SHANGHAI="Asia/Shanghai",g.BEIJING="Asia/Shanghai",g.HONG_KONG="Asia/Hong_Kong",g.TAIPEI="Asia/Taipei",g.SEOUL="Asia/Seoul",g.SINGAPORE="Asia/Singapore",g.HANOI="Asia/Ho_Chi_Minh",g.BANGKOK="Asia/Bangkok",g.JAKARTA="Asia/Jakarta",g.KUALA_LUMPUR="Asia/Kuala_Lumpur",g.MANILA="Asia/Manila",g.DUBAI="Asia/Dubai",g.KOLKATA="Asia/Kolkata",g.MUMBAI="Asia/Kolkata",g.RIYADH="Asia/Riyadh",g.TEHRAN="Asia/Tehran",g.JERUSALEM="Asia/Jerusalem",g.TEL_AVIV="Asia/Tel_Aviv",g.BAGHDAD="Asia/Baghdad",g.DHAKA="Asia/Dhaka",g.KARA_CHI="Asia/Karachi",g.KABUL="Asia/Kabul",g.KATHMANDU="Asia/Kathmandu",g.COLOMBO="Asia/Colombo",g.TASHKENT="Asia/Tashkent",g.ALMATY="Asia/Almaty",g.PHNOM_PENH="Asia/Phnom_Penh",g.VIENTIANE="Asia/Vientiane",g.MUSCAT="Asia/Muscat",g.SYDNEY="Australia/Sydney",g.MELBOURNE="Australia/Melbourne",g.BRISBANE="Australia/Brisbane",g.PERTH="Australia/Perth",g.ADELAIDE="Australia/Adelaide",g.DARWIN="Australia/Darwin",g.HOBART="Australia/Hobart",g.AUCKLAND="Pacific/Auckland",g.FIJI="Pacific/Fiji",g.GUAM="Pacific/Guam",g.NOUMEA="Pacific/Noumea",g.PAGO_PAGO="Pacific/Pago_Pago",g.PORT_MORESBY="Pacific/Port_Moresby",g.SAO_PAULO="America/Sao_Paulo",g.RIO_DE_JANEIRO="America/Sao_Paulo",g.BUENOS_AIRES="America/Argentina/Buenos_Aires",g.SANTIAGO="America/Santiago",g.LIMA="America/Lima",g.BOGOTA="America/Bogota",g.CARACAS="America/Caracas",g.LA_PAZ="America/La_Paz",g.MONTEVIDEO="America/Montevideo",g.QUITO="America/Quito",g.ASUNCION="America/Asuncion",g.GEORGETOWN="America/Guyana",g.CAIRO="Africa/Cairo",g.JOHANNESBURG="Africa/Johannesburg",g.LAGOS="Africa/Lagos",g.NAIROBI="Africa/Nairobi",g.CASABLANCA="Africa/Casablanca",g.ALGIERS="Africa/Algiers",g.TUNIS="Africa/Tunis",g.ADDIS_ABABA="Africa/Addis_Ababa",g.ACCRA="Africa/Accra",g.DAKAR="Africa/Dakar",g.LUANDA="Africa/Luanda",g.ANTANANARIVO="Indian/Antananarivo",g.KINSHASA="Africa/Kinshasa",g.DAR_ES_SALAAM="Africa/Dar_es_Salaam",g.MCMURDO="Antarctica/McMurdo",g.CASEY="Antarctica/Casey";const m=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],p=["January","February","March","April","May","June","July","August","September","October","November","December"],f=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],v=(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}};function y(t){var n;if(!t||"object"!=typeof t)return!1;if(t instanceof Date)return!1;if(t instanceof e.Temporal.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 b(t,n=e.Temporal.Now.timeZoneId()){return e.Temporal.Instant.fromEpochMilliseconds(t.getTime()).toZonedDateTimeISO(n)}function x(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 w(t,n){if(t instanceof Date)return t;if(y(t))return function(t,n=e.Temporal.Now.timeZoneId()){if("function"==typeof t.toZonedDateTime)try{return x(t.toZonedDateTime({timeZone:n,plainTime:e.Temporal.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?x(t):new Date(t)}function D(t,n){const r=Math.floor(n),a=Math.round(60*(n-r));if(y(t))return e.Temporal.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.Temporal.PlainDateTime.from({year:o.year,month:o.month,day:o.day,hour:r,minute:a})}function E(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.Temporal.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()});var n;if(y(t))return t;if("function"==typeof t.toPlainDate)return t.toPlainDate();const r=t;return e.Temporal.PlainDate.from({year:r.year,month:r.month,day:r.day})},a=r(t),o=r(n);return 0===e.Temporal.PlainDate.compare(a,o)}function C(t,n=e.Temporal.Now.timeZoneId()){if("function"==typeof t.toZonedDateTime){return(y(t)?t:t.toPlainDate()).toZonedDateTime({timeZone:n,plainTime:e.Temporal.PlainTime.from({hour:0,minute:0})})}const r=t;return(y(t)?t:e.Temporal.PlainDate.from({year:r.year,month:r.month,day:r.day})).toZonedDateTime({timeZone:n,plainTime:e.Temporal.PlainTime.from({hour:0,minute:0})})}function T(t,n=e.Temporal.Now.timeZoneId()){if("function"==typeof t.toZonedDateTime){return(y(t)?t:t.toPlainDate()).toZonedDateTime({timeZone:n,plainTime:e.Temporal.PlainTime.from({hour:23,minute:59,second:59,millisecond:999})})}const r=t;return(y(t)?t:e.Temporal.PlainDate.from({year:r.year,month:r.month,day:r.day})).toZonedDateTime({timeZone:n,plainTime:e.Temporal.PlainTime.from({hour:23,minute:59,second:59,millisecond:999})})}function k(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)}const S=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(y(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)},M=(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 D(e,t)},N=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)},I=(t,n)=>{if(t instanceof Date&&n instanceof Date)return t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate();return E(t instanceof Date?e.Temporal.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}):y(t)?t:t.toPlainDate(),n instanceof Date?e.Temporal.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()}):y(n)?n:n.toPlainDate())},R=[{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 H{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)}):R.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=H.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 A=new H;function O(){return A}function P(e){const t=R.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 L=(e,t)=>(t||O()).resolveColors(e).eventColor,$=(e,t)=>(t||O()).resolveColors(e).textColor,j=(e,t)=>(t||O()).resolveColors(e).eventSelectedColor,Y=(e,t)=>(t||O()).resolveColors(e).lineColor,F=(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")}`},V=e=>{if(!e.end)return 0;const t=S(e.end);if(e.allDay||!e.start)return t;const n=w(e.start),r=w(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},_=(e,t="24h")=>{const n=S(e.start),r=V(e);return`${F(n,0,t)} - ${F(r,0,t)}`},z=(t,n,r="24h",a=new Date)=>{const o=e.Temporal.Now.timeZoneId(),l=a.getFullYear(),i=a.getMonth()+1,s=a.getDate();return t.map(t=>{try{const a=t.hour%24,d=e.Temporal.ZonedDateTime.from({year:l,month:i,day:s,hour:a,minute:0,second:0,timeZone:o}).withTimeZone(n);return F(d.hour,d.minute,r)}catch(e){return""}})},W=(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}},U=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:p[r],shortMonthName:f[r],isToday:o.getDate()===n&&o.getMonth()===r&&o.getFullYear()===a}},B=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:p[a],monthIndex:a,year:o}},Z=e=>{const t=[],n=new Date(e);for(let e=0;e<7;e++){const e=new Date(n);t.push(U(e)),n.setDate(n.getDate()+1)}return{days:t,startDate:new Date(e),monthYear:B(t)}};function G(e,t,n=1){const r=[],a=Math.floor(t/2),o=(e.getDay()-n+7)%7,l=new Date(e);l.setDate(e.getDate()-o),l.setHours(0,0,0,0);const i=new Date(l);i.setDate(i.getDate()-7*a);for(let e=0;e<t;e++){const t=new Date(i);t.setDate(t.getDate()+7*e),r.push(Z(t))}return r}const K=(e,t)=>t.filter(t=>t.day===e&&!t.allDay),q=(e,t)=>{const n=new Date(e);return n.setDate(e.getDate()+t),n},X=(t,n)=>n?e.Temporal.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}):e.Temporal.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.Temporal.Now.timeZoneId()}),J=(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)},Q=(e,t)=>e.map(e=>{const n=w(e.start),r=J(n,t);return Object.assign(Object.assign({},e),{day:r})}),ee=(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()),te=(e,t)=>w(e.start).getTime()!==w(t.start).getTime()||w(e.end).getTime()!==w(t.end).getTime()||e.title!==t.title||e.day!==t.day||!!e.allDay!=!!t.allDay;function ne(){return Date.now().toString(36)+Math.random().toString(36).slice(2,8)}function re(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)||!re(a[e],o[e]))return!1;return!0}const ae=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 oe{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=oe.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 le{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 oe(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 exports.ViewType.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 exports.ViewType.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}=v(this.state.currentDate,r),l=new Date(a),i=new Date(a);i.setDate(i.getDate()+7),this.emitVisibleRange(l,i,e);break}case exports.ViewType.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:l}=v(t,n),i=new Date(l),s=new Date(l);s.setDate(s.getDate()+42),this.emitVisibleRange(i,s,e);break}case exports.ViewType.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 exports.ViewType.DAY:e.setDate(e.getDate()-1);break;case exports.ViewType.WEEK:e.setDate(e.getDate()-7);break;case exports.ViewType.MONTH:e.setMonth(e.getMonth()-1);break;case exports.ViewType.YEAR:e.setFullYear(e.getFullYear()-1)}this.setCurrentDate(e)},this.goToNext=()=>{const e=new Date(this.state.currentDate);switch(this.state.currentView){case exports.ViewType.DAY:e.setDate(e.getDate()+1);break;case exports.ViewType.WEEK:e.setDate(e.getDate()+7);break;case exports.ViewType.MONTH:e.setMonth(e.getMonth()+1);break;case exports.ViewType.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)):ae.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 ae.warn("Cannot update event in read-only mode")},this.deleteEvent=e=>{this.isInternalEditable()?(this.pendingSnapshot=null,this.pushToUndo(),this.store.deleteEvent(e)):ae.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)?ae.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||re(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=le.resolveLocale(e.locale);re(t,this.state.locale)||(this.state.locale=t,n=!0)}n&&(this.triggerRender(),this.notify())},this.setOverrides=e=>{this.state.overrides=e,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||exports.ViewType.WEEK,currentDate:e.initialDate||new Date,events:e.events||[],switcherMode:e.switcherMode||"buttons",plugins:new Map,views:new Map,locale:le.resolveLocale(e.locale),highlightedEventId:null,selectedEventId:null,readOnly:e.readOnly||!1,overrides:[]},this.callbacks=e.callbacks||{},this.themeChangeListeners=new Set,this.listeners=new Set,this.store=new oe(this.state.events),this.setupStoreListeners(),this.calendarRegistry=new H(e.calendars,e.defaultCalendar,(null===(t=e.theme)||void 0===t?void 0:t.mode)||"light"),o=this.calendarRegistry,A=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(),"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?d(e)?e:"en-US":e&&"object"==typeof e&&!d(e.code)?Object.assign(Object.assign({},e),{code:"en-US"}):e:"en-US"}}var ie=0;function se(e,n,r,a,o,l){n||(n={});var i,s,d=n;if("ref"in d)for(s in d={},n)"ref"==s?i=n[s]:d[s]=n[s];var c={type:e,props:d,key:r,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ie,__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 t.options.vnode&&t.options.vnode(c),c}const de=t=>{if(!t)return"";let n,r,a;t instanceof Date?(a=t.getFullYear(),r=t.getMonth()+1,n=t.getDate()):y(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.Temporal.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}`};function ce(e){return null!==e&&"object"==typeof e&&!("hour"in e)&&"year"in e&&"month"in e&&"day"in e&&!(e instanceof Date)}function ue(e){return null!==e&&"object"==typeof e&&"hour"in e&&!("timeZone"in e)&&"year"in e&&!(e instanceof Date)}function he(e){return null!==e&&"object"==typeof e&&"timeZone"in e&&"year"in e&&!(e instanceof Date)}function ge(e){if(e instanceof Date)return e;if(ce(e))return new Date(e.year,e.month-1,e.day);if(ue(e))return new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second||0,e.millisecond||0);if(he(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 me(t){return e.Temporal.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()})}function pe(t){return e.Temporal.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 fe(t,n=e.Temporal.Now.timeZoneId()){return e.Temporal.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 ve(e){return e instanceof Date?me(e):ce(e)?e:(ue(e),e.toPlainDate())}const ye=/(YYYY|YY|MM|DD|HH|mm)/g,be=e=>e.toString().padStart(2,"0"),xe=(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`)},we=e=>e.replaceAll(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),De=e=>{let t,n=0,r="^";for(;null!==(t=ye.exec(e));){r+=we(e.slice(n,t.index));const a=t[0];r+=`(?<${a}>\\d{${"YYYY"===a?4:2}})`,n=t.index+a.length}return r+=we(e.slice(n))+"$",new RegExp(r)},Ee=(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.Temporal.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}},Ce=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.Temporal.Now.timeZoneId()},Te=(t,n,r)=>{var a,o,l,i,s,d,c,u,h,g,m,p,f,v,y,b,x,w,D,E,C,T,k,S;if(!t){const t=null!=n?n:r?Ce(r):e.Temporal.Now.timeZoneId();return null!=r?r:e.Temporal.Now.zonedDateTimeISO(t)}if(ce(t)){const r=null!=n?n:e.Temporal.Now.timeZoneId(),a=`${t.year}-${be(t.month)}-${be(t.day)}T00:00:00[${r}]`;return e.Temporal.ZonedDateTime.from(a)}const M=t;if("hour"in M&&!("timeZone"in M)){const r=null!=n?n:e.Temporal.Now.timeZoneId();if("function"==typeof M.toZonedDateTime)try{return t.toZonedDateTime(r)}catch(e){}return e.Temporal.ZonedDateTime.from({timeZone:r,year:M.year,month:M.month,day:M.day,hour:M.hour,minute:M.minute,second:null!==(a=M.second)&&void 0!==a?a:0,millisecond:null!==(o=M.millisecond)&&void 0!==o?o:0,microsecond:null!==(l=M.microsecond)&&void 0!==l?l:0,nanosecond:null!==(i=M.nanosecond)&&void 0!==i?i:0})}try{return e.Temporal.ZonedDateTime.from(t)}catch(t){const a=M,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?Ce(r):void 0)&&void 0!==h?h:e.Temporal.Now.timeZoneId();if("function"==typeof(null==a?void 0:a.toZonedDateTime))try{return a.toZonedDateTime({timeZone:o})}catch(e){}const l=null!=r?r:e.Temporal.Now.zonedDateTimeISO(o);return e.Temporal.ZonedDateTime.from({timeZone:o,year:null!==(g=null==a?void 0:a.year)&&void 0!==g?g:l.year,month:null!==(m=null==a?void 0:a.month)&&void 0!==m?m:l.month,day:null!==(p=null==a?void 0:a.day)&&void 0!==p?p:l.day,hour:null!==(v=null!==(f=null==a?void 0:a.hour)&&void 0!==f?f:null==r?void 0:r.hour)&&void 0!==v?v: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!==(w=null!==(x=null==a?void 0:a.second)&&void 0!==x?x:null==r?void 0:r.second)&&void 0!==w?w:0,millisecond:null!==(E=null!==(D=null==a?void 0:a.millisecond)&&void 0!==D?D:null==r?void 0:r.millisecond)&&void 0!==E?E:0,microsecond:null!==(T=null!==(C=null==a?void 0:a.microsecond)&&void 0!==C?C:null==r?void 0:r.microsecond)&&void 0!==T?T:0,nanosecond:null!==(S=null!==(k=null==a?void 0:a.nanosecond)&&void 0!==k?k:null==r?void 0:r.nanosecond)&&void 0!==S?S:0})}},ke=(e,t,n)=>{const r=xe(t,n),a={YYYY:e.year.toString(),YY:be(e.year%100),MM:be(e.month),DD:be(e.day),HH:be(e.hour),mm:be(e.minute)};return r.replace(ye,e=>{var t;return null!==(t=a[e])&&void 0!==t?t:e})};let Se=null;function Me(){if("undefined"==typeof document)return!1;if(null!==Se)return Se;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(),Se=r,r}const Ne=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 Ie(t,n=!1){if(t instanceof e.Temporal.PlainDate||t instanceof e.Temporal.PlainDateTime)return t;if(t instanceof Date)return n?me(t):pe(t);throw new Error("Invalid time type: "+typeof t)}function Re(t,n){if(t instanceof e.Temporal.ZonedDateTime)return t;if(t instanceof Date)return fe(t,n);throw new Error("Invalid time type: "+typeof t)}function He(e){var t;const n=Ie(e.start,e.allDay),r=Ie(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 Ae(e){const t=Re(e.start,e.timeZone),n=Re(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}}const Oe=e=>{try{return e instanceof Date?e:"string"==typeof e?new Date(e):w(e)}catch(e){return new Date}},Pe=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},Le=(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}},$e=(e,t)=>{const n=new Map;e.forEach(e=>{var t;const r=Oe(e.start),a=Pe(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 je=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 Ye(e){return String(e).padStart(2,"0")}function Fe(t,n,r){const a=t.trim(),o=/^(\d{4})(\d{2})(\d{2})$/,l=/^(\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.Temporal.PlainDate.from({year:Number.parseInt(t[1],10),month:Number.parseInt(t[2],10),day:Number.parseInt(t[3],10)})}if(l.test(a)){const t=a.match(l);if(t){const n=e.Temporal.Instant.from(`${t[1]}-${t[2]}-${t[3]}T${t[4]}:${t[5]}:${t[6]}Z`),a=r||e.Temporal.Now.timeZoneId();return n.toZonedDateTimeISO(a)}}const i=a.match(/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})$/);if(i){const t={year:Number.parseInt(i[1],10),month:Number.parseInt(i[2],10),day:Number.parseInt(i[3],10),hour:Number.parseInt(i[4],10),minute:Number.parseInt(i[5],10),second:Number.parseInt(i[6],10)};return(null==n?void 0:n.tzid)?e.Temporal.ZonedDateTime.from(Object.assign(Object.assign({},t),{timeZone:n.tzid})):e.Temporal.PlainDateTime.from(t)}throw new Error(`Invalid ICS date format: ${t}`)}function Ve(e,t=!1){if(t||ce(e)){const t=ce(e)?e:e.toPlainDate();return{value:`${t.year}${Ye(t.month)}${Ye(t.day)}`,params:{VALUE:"DATE"}}}if(he(e)){const t=e.toInstant().toZonedDateTimeISO("UTC");return{value:`${t.year}${Ye(t.month)}${Ye(t.day)}T${Ye(t.hour)}${Ye(t.minute)}${Ye(t.second)}Z`}}if(ue(e))return{value:`${e.year}${Ye(e.month)}${Ye(e.day)}T${Ye(e.hour)}${Ye(e.minute)}${Ye(e.second)}`};throw new Error("Unsupported Temporal type")}function _e(e){return`${e.getUTCFullYear()}${Ye(e.getUTCMonth()+1)}${Ye(e.getUTCDate())}T${Ye(e.getUTCHours())}${Ye(e.getUTCMinutes())}${Ye(e.getUTCSeconds())}Z`}function ze(e){return e?e.replaceAll("\\","\\\\").replaceAll(";","\\;").replaceAll(",","\\,").replaceAll("\n","\\n"):""}function We(e){return e?e.replaceAll("\\,",",").replaceAll("\\;",";").replaceAll(/\\[nN]/g,"\n").replaceAll("\\\\","\\"):""}function Ue(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 Be(e,t,n){let r=e;return n&&Object.entries(n).forEach(([e,t])=>{r+=`;${e}=${t}`}),r+=`:${t}`,Ue(r)}function Ze(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:${_e(new Date)}`);const l=Ve(e.start,e.allDay),i=Ve(e.end,e.allDay);if(a.push(Be("DTSTART",l.value,l.params)),a.push(Be("DTEND",i.value,i.params)),a.push(Be("SUMMARY",ze(e.title))),e.description&&a.push(Be("DESCRIPTION",ze(e.description))),(null===(n=e.meta)||void 0===n?void 0:n.location)&&a.push(Be("LOCATION",ze(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(ze).join(",");a.push(Be("CATEGORIES",t))}return a.push("END:VEVENT"),a}function Ge(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 Ke(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,...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=We(a);break;case"DESCRIPTION":t.description=We(a);break;case"LOCATION":t.location=We(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=>We(e.trim()))}}if(!t.dtstart)throw new Error("Missing DTSTART in VEVENT");return t.uid||(t.uid=ne()),t}function qe(t,n){var r;const{calendarId:a="default",generateNewIds:o=!0,idPrefix:l="ics-",defaultTimeZone:i}=n,s=o?`${l}${ne()}`:t.uid,d=Fe(t.dtstart,t.dtstartParams,i);let c;c=t.dtend?Fe(t.dtend,t.dtendParams,i):ce(d)?d.add({days:1}):d.add({hours:1});const u="DATE"===(null===(r=t.dtstartParams)||void 0===r?void 0:r.value)||ce(d),h=i||e.Temporal.Now.timeZoneId();let g,m;if(ce(d))g=d.toZonedDateTime({timeZone:h,plainTime:"00:00:00"});else if(ue(d))try{g=d.toZonedDateTime(h)}catch(t){g=e.Temporal.ZonedDateTime.from(Object.assign(Object.assign({},d),{timeZone:h}))}else g=d;if(ce(c))m=c.toZonedDateTime({timeZone:h,plainTime:"00:00:00"});else if(ue(c))try{m=c.toZonedDateTime(h)}catch(t){m=e.Temporal.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 Xe(e,t={}){const n={success:!1,events:[],errors:[],totalParsed:0,totalImported:0};try{const r=e.replaceAll(/(\r\n|\n|\r)[ \t]/g,""),a=Ge(r.split(/\r\n|\n|\r/));n.totalParsed=a.length,a.forEach((e,r)=>{try{const r=qe(Ke(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 Je(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:${ze(n)}`];return e.forEach(e=>{a.push(...Ze(e))}),a.push("END:VCALENDAR"),a.join("\r\n")}let Qe=null;const et=()=>{const[e,t]=r.useState(()=>Qe||{weekHeight:u.WEEK_HEIGHT,screenSize:"desktop",weeksPerView:6});return r.useEffect(()=>{const e=()=>{const e=window.innerWidth,n=window.innerHeight-150,r=Math.max(80,Math.floor(n/6)),a=e<768?{weekHeight:Math.max(u.MOBILE_WEEK_HEIGHT,r),screenSize:"mobile",weeksPerView:6}:e<1024?{weekHeight:Math.max(u.TABLET_WEEK_HEIGHT,r),screenSize:"tablet",weeksPerView:6}:{weekHeight:Math.max(u.WEEK_HEIGHT,r),screenSize:"desktop",weeksPerView:6};Qe=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},tt=t.createContext({locale:"en-US",t:e=>e,getWeekDaysLabels:()=>[],getMonthLabels:()=>[],isDefault:!0});function nt(){return r.useContext(tt)}const rt="df-month-view h-full flex flex-col bg-white dark:bg-gray-900 select-none",at="p-2 flex justify-between",ot="text-2xl font-bold text-gray-900 dark:text-gray-100",lt="df-date-number inline-flex items-center justify-center h-6 w-6 rounded-full text-sm mt-1 select-none",it="flex-1 overflow-auto will-change-scroll",st="scrollbar-hide",dt="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",ut="df-time-grid-row h-[4.5rem] border-t border-gray-200 dark:border-gray-700 flex",ht="df-current-time-line absolute left-0 top-0 w-full flex pointer-events-none",gt="df-current-time-label ml-2 text-primary-foreground text-xs font-bold px-1.5 bg-primary rounded-sm",mt="df-all-day-row flex items-center border-b border-gray-200 dark:border-gray-700 sticky",pt="rounded-xl my-0.5",ft="rounded-sm",vt="df-event-title font-medium text-xs truncate pr-1",yt="df-month-event-color-bar inline-block w-0.75 h-3 mr-1 shrink-0 rounded-full",bt="h-3 w-3 mr-1",xt="resize-handle absolute right-0 top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20",wt="bg-primary rounded-full text-primary-foreground",Dt="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",Et="h-4 w-4 transition-transform group-hover:scale-110",Ct="df-event-detail-panel fixed bg-white dark:bg-gray-800 shadow-lg border border-gray-200 dark:border-gray-700 rounded-lg",Tt="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",kt="h-3 border-t border-gray-200 dark:border-gray-700 relative",St="absolute top-0 -translate-y-1/2 text-[12px] text-gray-500 dark:text-gray-400",Mt="flex h-7 w-7 items-center justify-center rounded hover:bg-gray-100 dark:hover:bg-slate-800 transition-colors",Nt="text-gray-500 dark:text-gray-400",It="text-gray-600 dark:text-gray-300",Rt="text-xs",Ht="text-sm",At="flex flex-col",Ot="mr-1",Pt=(...e)=>e.filter(Boolean).join(" "),Lt=({className:e,width:t=24,height:n=24})=>se("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:se("path",{d:"m15 18-6-6 6-6"})}),$t=({className:e,width:t=24,height:n=24})=>se("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:se("path",{d:"m9 18 6-6-6-6"})}),jt=({className:e,width:t=24,height:n=24})=>se("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:[se("path",{d:"m11 17-5-5 5-5"}),se("path",{d:"m18 17-5-5 5-5"})]}),Yt=({className:e,width:t=24,height:n=24})=>se("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:[se("path",{d:"m6 17 5-5-5-5"}),se("path",{d:"m13 17 5-5-5-5"})]}),Ft=({className:e,width:t=24,height:n=24})=>se("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:se("path",{d:"m6 9 6 6 6-6"})}),Vt=({className:e,width:t=24,height:n=24})=>se("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:[se("path",{d:"M5 12h14"}),se("path",{d:"M12 5v14"})]}),_t=({className:e,width:t=24,height:n=24})=>se("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:[se("circle",{cx:"11",cy:"11",r:"8"}),se("path",{d:"m21 21-4.3-4.3"})]}),zt=({className:e,width:t=24,height:n=24})=>se("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:se("path",{d:"M20 6 9 17l-5-5"})}),Wt=({className:e,width:t=24,height:n=24})=>se("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:[se("path",{d:"m7 15 5 5 5-5"}),se("path",{d:"m7 9 5-5 5 5"})]}),Ut=({className:e,width:t=24,height:n=24})=>se("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:[se("path",{d:"M18 6 6 18"}),se("path",{d:"m6 6 12 12"})]}),Bt=({className:e,width:t=24,height:n=24})=>se("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:[se("path",{d:"M8 2v4"}),se("path",{d:"M16 2v4"}),se("rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}),se("path",{d:"M3 10h18"}),se("path",{d:"M8 14h.01"}),se("path",{d:"M12 14h.01"}),se("path",{d:"M16 14h.01"}),se("path",{d:"M8 18h.01"}),se("path",{d:"M12 18h.01"}),se("path",{d:"M16 18h.01"})]}),Zt=({className:e,width:t=24,height:n=24})=>se("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:[se("path",{d:"M18 8L22 12L18 16"}),se("path",{d:"M2 12H22"})]}),Gt=({className:e,width:t=24,height:n=24})=>se("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:se("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),Kt=({className:e,width:t=24,height:n=24})=>se("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:[se("rect",{width:"18",height:"14",x:"3",y:"8",rx:"2"}),se("path",{d:"M12 5a3 3 0 1 0-3 3"}),se("path",{d:"M12 5a3 3 0 1 1 3 3"}),se("path",{d:"M3 12h18"}),se("path",{d:"M12 22V8"})]}),qt=({className:e,width:t=24,height:n=24})=>se("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:se("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"})}),Xt=({className:e,width:t=24,height:n=24})=>se("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:[se("path",{d:"M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z"}),se("circle",{cx:"12",cy:"10",r:"3"})]}),Jt=({className:e,width:t=24,height:n=24})=>se("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:se("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"})}),Qt=({className:e,width:t=24,height:n=24})=>se("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:[se("path",{d:"m12 19-7-7 7-7"}),se("path",{d:"M19 12H5"})]});function en(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 tn(e){return e.charAt(0).toUpperCase()+e.slice(1)}const nn=(e,t="short",n=1)=>{const r=[],a=new Date(2024,0,7);for(let o=0;o<7;o++){const l=new Date(a);l.setDate(a.getDate()+n+o);try{r.push(l.toLocaleDateString(e,{weekday:t}))}catch(e){r.push(l.toLocaleDateString("en-US",{weekday:t}))}}return r},rn=(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 an(e,t="en-US"){var n;if(["today","day","week","month","year"].includes(e)){const n=en(e,t);if(n)return tn(n)}const r=s(t),a=i[r],o=null===(n=null==a?void 0:a.messages)||void 0===n?void 0:n[e];if(o)return o;const l=i.en.messages;return(null==l?void 0:l[e])||e}const on=({locale:e="en-US",messages:t,children:n})=>{const a=r.useMemo(()=>{if("string"==typeof e){return{code:d(e)?e:"en-US",messages:void 0}}return e&&"string"!=typeof e&&!d(e.code)?Object.assign(Object.assign({},e),{code:"en-US"}):e||{code:"en-US"}},[e]),o=r.useMemo(()=>{const e=a.code;return{locale:e,t:(n,r)=>{var o,l,i;let s=null!==(i=null!==(o=null==t?void 0:t[n])&&void 0!==o?o:null===(l=a.messages)||void 0===l?void 0:l[n])&&void 0!==i?i:an(n,e);return r&&Object.entries(r).forEach(([e,t])=>{s=s.replaceAll(new RegExp(`{${e}}`,"g"),t)}),s},getWeekDaysLabels:nn,getMonthLabels:rn,isDefault:!1}},[a,t]);return se(tt.Provider,{value:o,children:n})},ln=({calendar:e,mode:t="buttons"})=>{const[n,a]=r.useState(!1),o=r.useRef(null),{t:l}=nt(),i=Array.from(e.state.views.keys()),s=e.state.currentView;return r.useEffect(()=>{const e=e=>{o.current&&!o.current.contains(e.target)&&a(!1)};if(n)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[n]),i.length<=1?null:se("div","select"===t?{className:"relative inline-block",ref:o,children:[se("button",{type:"button",onClick:()=>a(!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:[se("span",{className:"text-gray-900 dark:text-gray-100",children:l(s)}),se("span",{className:`${Nt} transition-transform duration-200 ${n?"rotate-180":""}`,children:se(Ft,{width:16,height:16})})]}),n&&se("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:se("div",{className:"p-1",role:"listbox",children:i.map(t=>se("button",{type:"button",onClick:()=>{e.changeView(t),a(!1),e.triggerRender()},className:"w-full rounded px-3 py-0.5 text-left text-sm transition-colors duration-150 focus:outline-none "+(s===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":s===t,children:l(t)},t))})}),se("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=>se("button",{type:"button",className:"h-6 rounded-md px-4 text-sm font-medium transition-all duration-200 focus:outline-none "+(s===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:l(t)},t))})},sn=({calendar:e,switcherMode:t="buttons",onAddCalendar:n,onSearchChange:a,onSearchClick:o,searchValue:l="",isSearchOpen:i=!1,isEditable:s=!0,safeAreaLeft:d})=>{const c="buttons"===t,u=e.state.currentView===exports.ViewType.DAY,{screenSize:h}=et(),g="mobile"===h,{t:m}=nt(),p=r.useCallback(e=>{const t=e.currentTarget.value;t!==l&&(null==a||a(t))},[a,l]);return se("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:d||8,transition:"padding-left 160ms ease-in-out"},onContextMenu:e=>e.preventDefault(),children:[se("div",{className:"df-header-left mb-1 flex items-center",children:n&&s&&se("button",{type:"button",id:"dayflow-add-event-btn",onClick:n,className:Mt,title:g?m("newEvent")||"New Event":m("createCalendar")||"Add Calendar",children:se(Vt,{className:`h-4 w-4 ${Nt}`})})}),se("div",{className:"df-header-mid flex flex-1 justify-center",children:c&&se(ln,{mode:t,calendar:e})}),se("div",{className:"df-header-right mb-1 flex items-center justify-end gap-3 pb-1",children:[!c&&se(ln,{mode:t,calendar:e}),se("button",{type:"button",onClick:o,className:`md:hidden ${Mt}`,title:m("search")||"Search",children:se(_t,{width:16,height:16})}),se("div",{className:"group relative hidden md:block",children:[se("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3",children:se("span",{className:"text-gray-400 transition-colors group-focus-within:text-primary",children:se(_t,{width:16,height:16})})}),se("input",{id:"dayflow-search-input",type:"text",placeholder:m("search")||"Search",value:l,onChange:p,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"}),l&&se("button",{type:"button",onClick:()=>{null==a||a("")},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:se("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[se("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),se("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]})]})},dn=t.createContext(void 0),cn=({children:e,initialTheme:t="light",onThemeChange:n})=>{const[a,o]=r.useState(t),[l,i]=r.useState("light"),s="auto"===a?l:a;r.useEffect(()=>{o(t)},[t]);const d=r.useCallback(e=>{o(e)},[]);r.useEffect(()=>{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)}},[]),r.useEffect(()=>{if("undefined"==typeof document)return;const e=document.documentElement,t=Ne(s),n="auto"===a?t:s;e.classList.remove("light","dark"),e.classList.add(n),"auto"===a?delete e.dataset.dayflowThemeOverride:e.dataset.dayflowThemeOverride=n,e.dataset.theme=n},[s,a,l]),r.useEffect(()=>{n&&n(a,s)},[a,s,n]);const c=r.useMemo(()=>({theme:a,effectiveTheme:s,setTheme:d}),[a,s,d]);return se(dn.Provider,{value:c,children:e})},un=()=>{const e=r.useContext(dn);if(void 0===e)throw new Error("useTheme must be used within a ThemeProvider");return e},hn=t.createContext(null);let gn=0;function mn({generatorName:e,generatorArgs:t,defaultContent:n,store:a}){const o=r.useRef(null),l=r.useContext(hn),i=a||l,s=r.useRef(null),[,d]=r.useState(0);s.current||(s.current="df-slot-"+gn++),r.useEffect(()=>{if(!o.current||!i||!e)return;const n=s.current;i.register({id:n,containerEl:o.current,generatorName:e,generatorArgs:t});const r=i.subscribe(()=>{d(e=>e+1)});return()=>{i.unregister(n),r()}},[i,e]),r.useEffect(()=>{if(!i||!s.current||!e)return;const n=s.current;i.register({id:n,containerEl:o.current,generatorName:e,generatorArgs:t})},[e,t]);const c=null==e?void 0:e.startsWith("eventContent"),u="sidebar"===e,h=!!e&&(null==i?void 0:i.isOverridden(e));return se("div",{ref:o,className:"df-content-slot "+(c||u?"flex h-full flex-1 flex-col":""),children:!h&&n})}const pn=e=>{const t=r.useRef(null),n=r.useRef(null);return r.useEffect(()=>{if(t.current){const r=a.__rest(e,[]);n.current=new o.BlossomColorPicker(t.current,r),r.initialExpanded&&n.current.expand()}return()=>{n.current&&(n.current.destroy(),n.current=null)}},[]),r.useEffect(()=>{if(n.current){const t=a.__rest(e,[]);n.current.setOptions(t)}},[e]),se("div",{ref:t,className:e.className})},fn=({color:e,onChange:t,onClose:n})=>{const a=r.useMemo(()=>{const{h:t,l:n}=o.hexToHsl(e);return{hue:t,saturation:o.lightnessToSliderValue(n),lightness:n,alpha:100,layer:"outer"}},[e]);return se("div",{className:"flex justify-center",children:se(pn,{defaultValue:a,coreSize:36,petalSize:32,initialExpanded:!0,openOnHover:!1,onChange:e=>t({hex:e.hex},!0),onCollapse:n})})},vn=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],yn=({onClose:e,onCreate:a,app:l})=>{const{t:i}=nt(),{effectiveTheme:s}=un(),[d,c]=r.useState(""),u=l.state.overrides.includes("createCalendarDialogColorPicker"),[h,g]=r.useState(vn[Math.floor(Math.random()*vn.length)]),[m,p]=r.useState(!1),[f,v]=r.useState(""),y=r.useMemo(()=>{const e=o.DEFAULT_COLORS[Math.floor(Math.random()*o.DEFAULT_COLORS.length)],t=e.layer||"outer",n=o.lightnessToSliderValue(e.l);return{hue:e.h,saturation:n,lightness:e.l,alpha:100,layer:t}},[]),[b,x]=r.useState(null),w=e=>{g(e.hex)},D=()=>{p(!1)},E=()=>{g(f),p(!1)},C="dark"===s,T={default:{picker:{background:C?"#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:C?"1px solid #4b5563":"1px solid #e5e7eb"},head:{background:C?"#1e293b":"#ffffff",borderBottom:C?"1px solid #4b5563":"1px solid #e5e7eb",boxShadow:"none"},body:{background:C?"#1e293b":"#ffffff"},controls:{border:C?"1px solid #4b5563":"1px solid #e5e7eb"},input:{background:C?"#374151":"#ffffff",color:C?"#f3f4f6":"#1f2937",border:C?"1px solid #4b5563":"1px solid #e5e7eb",boxShadow:"none"},previews:{border:C?"1px solid #4b5563":"1px solid #e5e7eb"},actions:{borderTop:C?"1px solid #4b5563":"1px solid #e5e7eb"}}};return"undefined"==typeof window?null:n.createPortal(se("div",{className:"fixed inset-0 z-10000 flex items-center justify-center bg-black/50",children:se("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:[se("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white "+(u?"mb-4":"mb-6"),children:i("createCalendar")}),se("form",{onSubmit:t=>{var n;if(t.preventDefault(),!d.trim())return;let r;r=u?h:null!==(n=null==b?void 0:b.hex)&&void 0!==n?n:o.hslToHex(y.hue,y.saturation,y.lightness);const{colors:l,darkColors:i}=P(r),s={id:ne(),name:d.trim(),colors:l,darkColors:i,isVisible:!0,isDefault:!1};a(s),e()},children:[u?se(t.Fragment,{children:[se("div",{className:"mb-4",children:se("div",{className:"flex items-center gap-3",children:[se("div",{className:"h-9 w-9 rounded-md border border-gray-200 shadow-sm dark:border-gray-600",style:{backgroundColor:h}}),se("input",{id:"custom-calendar-name",name:"calendar-name",type:"text",value:d,onChange:e=>c(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:i("calendarNamePlaceholder"),autoFocus:!0})]})}),se("div",{className:"mb-6",children:[se("div",{className:"mb-4 grid grid-cols-7 gap-4",children:vn.map(e=>se("button",{type:"button",className:"h-7 w-7 rounded-full border border-gray-200 transition-transform hover:scale-110 focus:ring-2 focus:ring-primary focus:ring-offset-2 focus:outline-none dark:border-gray-600 dark:focus:ring-offset-slate-800 "+(h===e?"scale-110 ring-2 ring-primary ring-offset-2 dark:ring-offset-slate-800":""),style:{backgroundColor:e},onClick:()=>g(e)},e))}),se("div",{className:"relative",children:[se("button",{type:"button",onClick:()=>{v(h),p(!0)},className:"flex w-full items-center gap-2 rounded-md border border-slate-200 px-2 py-1 text-sm font-medium text-slate-700 transition-colors hover:bg-slate-50 focus:outline-none dark:border-slate-700 dark:text-slate-200 dark:hover:bg-slate-800",children:i("customColor")}),m&&se("div",{className:"fixed inset-0 z-10001 flex items-center justify-center bg-black/40 backdrop-blur-sm",onClick:E,children:se("div",{className:"animate-in fade-in zoom-in-95 relative",onClick:e=>e.stopPropagation(),children:se(mn,{generatorName:"createCalendarDialogColorPicker",generatorArgs:{color:h,onChange:w,onAccept:D,onCancel:E,styles:T},defaultContent:se("div",{className:"rounded-lg border border-slate-200 bg-white p-4 shadow-2xl dark:border-slate-700 dark:bg-slate-900",children:[se(fn,{color:h,onChange:w}),se("div",{className:"mt-4 flex justify-end gap-2 border-t pt-3 dark:border-slate-700",children:[se("button",{type:"button",onClick:E,className:"rounded-md border border-gray-200 px-3 py-1.5 text-xs font-medium text-slate-600 hover:bg-gray-100 dark:border-gray-600 dark:text-slate-300 dark:hover:bg-gray-800",children:i("cancel")}),se("button",{type:"button",onClick:D,className:"rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm hover:opacity-90",children:"OK"})]})]})})})})]})]})]}):se("div",{className:"mb-8 flex items-center gap-4",children:[se("div",{className:"flex-1",children:se("input",{id:"blossom-calendar-name",name:"calendar-name",type:"text",value:d,onChange:e=>c(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:i("calendarNamePlaceholder"),autoFocus:!0})}),se("div",{className:"relative h-9 w-9 shrink-0",children:se("div",{className:"absolute inset-0 flex items-center justify-center",children:se(pn,{defaultValue:y,coreSize:36,petalSize:32,openOnHover:!1,onChange:e=>x(e),onCollapse:e=>x(e),className:"z-50"})})})]}),se("div",{className:"flex justify-end space-x-2",children:[se("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:i("cancel")}),se("button",{type:"submit",disabled:!d.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:i("create")})]})]})]})}),document.body)},bn=(t,n)=>e.Temporal.PlainDate.compare(t,n),xn=({calendarDays:e,visibleMonth:n,startDate:r,endDate:a,weekDayLabels:o,disabled:l,onDaySelect:i})=>se(t.Fragment,{children:[se("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=>se("span",{children:e},e))}),se("div",{className:"grid grid-cols-7 gap-1 px-1",children:e.map(e=>{const t=e.month!==n.month,o=0===bn(e,r),s=0===bn(e,a),d=bn(e,r)>=0&&bn(e,a)<=0;return se("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":t?"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())})})]}),wn=({visibleMonth:e,monthLabels:t,disabled:n,onMonthChange:r,onYearChange:a})=>se("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:[se("div",{className:"flex items-center gap-1",children:[se("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:se(jt,{width:14,height:12})}),se("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:se(Lt,{width:14,height:12})})]}),se("div",{className:"text-sm font-semibold text-slate-700 dark:text-gray-300",children:[t[e.month-1]," ",e.year]}),se("div",{className:"flex items-center gap-1",children:[se("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:se($t,{width:14,height:12})}),se("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:se(Yt,{width:14,height:12})})]})]}),Dn=Array.from({length:24},(e,t)=>t),En=Array.from({length:60},(e,t)=>t),Cn=({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=En.includes(s)?En:[...En,s].toSorted((e,t)=>e-t);return se("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:[se("div",{className:"flex justify-center border-b border-slate-100 dark:border-gray-600",children:se("div",{className:"py-1.5 text-base text-slate-700 dark:text-gray-300",children:[i.hour.toString().padStart(2,"0"),":",i.minute.toString().padStart(2,"0")]})}),se("div",{className:"flex p-1",children:[se("div",{className:"w-14",children:se("div",{className:`h-72 overflow-y-auto ${st} 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[l]&&(o.current[l].hour=e)},children:Dn.map(e=>{const t=e===i.hour;return se("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 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:be(e)},e)})})}),se("div",{className:"w-14",children:se("div",{className:`h-72 overflow-y-auto ${st} 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[l]&&(o.current[l].minute=e)},children:d.map(e=>{const t=e===s;return se("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 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:be(e)},e)})})})]})]})},Tn=({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:p,onOk:f,getPopupStyle:v})=>{const y=a[0].toPlainDate(),b=a[1].toPlainDate();return se("div",{ref:d,style:v(),"data-range-picker-popup":"true",children:se("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:[se("div",{className:"flex gap-1",children:[se("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:[se(wn,{visibleMonth:e,monthLabels:t,disabled:i,onMonthChange:u,onYearChange:h}),se(xn,{calendarDays:r,visibleMonth:e,startDate:y,endDate:b,weekDayLabels:n,disabled:i,onDaySelect:g})]}),l&&se("div",{className:"flex flex-1 justify-end sm:w-32",children:se(Cn,{focusedField:o,draftRange:a,disabled:i,onHourSelect:m,onMinuteSelect:p,timeListRefs:c})})]}),se("div",{className:"flex justify-end",children:se("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"})})]})})},kn=({value:t,format:a="YYYY-MM-DD HH:mm",showTimeFormat:o="HH:mm",showTime:l=!0,onChange:i,onOk:s,timeZone:d,disabled:c=!1,placement:u="bottomLeft",autoAdjustOverflow:h=!0,getPopupContainer:g,matchTriggerWidth:m=!1,locale:p="en-US"})=>{const f=r.useMemo(()=>"string"==typeof p?p:(null==p?void 0:p.code)||"en-US",[p]),v=r.useMemo(()=>void 0===l||("object"==typeof l||Boolean(l)),[l]),b=r.useMemo(()=>rn(f,"short"),[f]),x=r.useMemo(()=>nn(f,"narrow"),[f]),w=r.useMemo(()=>v?"object"==typeof l&&(null==l?void 0:l.format)?l.format:o:"",[v,l,o]),D=r.useMemo(()=>xe(a,w),[a,w]),E=r.useMemo(()=>De(D),[D]),C=r.useMemo(()=>{const n=null!=d?d:y(t[0])?y(t[1])?e.Temporal.Now.timeZoneId():Ce(t[1]):Ce(t[0]),r=Te(t[0],n);return[r,Te(t[1],n,r)]},[t,d]),[T,k]=r.useState(C),S=r.useRef(C),[M,N]=r.useState("start"),[I,R]=r.useState([ke(C[0],a,w),ke(C[1],a,w)]),H=r.useRef([ke(C[0],a,w),ke(C[1],a,w)]),A=r.useRef(C),[O,P]=r.useState(C[0].toPlainDate().with({day:1})),[L,$]=r.useState(!1),j=r.useCallback(e=>{$(e)},[]),[Y,F]=r.useState(u),V=r.useRef(u),_=r.useRef(null),z=r.useRef(null),W=r.useRef({start:{hour:null,minute:null},end:{hour:null,minute:null}}),U=r.useRef(!1),B=r.useRef(!1);r.useEffect(()=>{H.current=I},[I]),r.useEffect(()=>{A.current=T},[T]),r.useEffect(()=>{const t=S.current,n=0!==e.Temporal.ZonedDateTime.compare(t[0],C[0]),r=0!==e.Temporal.ZonedDateTime.compare(t[1],C[1]);(n||r)&&k(C),S.current=C},[C]),r.useEffect(()=>{P(C[0].toPlainDate().with({day:1}))},[C[0]]);const Z=r.useCallback((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})},[]),G=r.useCallback(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=W.current[e];["hour","minute"].forEach(e=>{const n=t[e];if(!n)return;const r=n.querySelector('[data-active="true"]');r&&Z(n,r,0)})})})},[Z]);r.useEffect(()=>{L&&v&&G(M)},[M,L,G,v]);const K=T[0].epochMilliseconds,q=T[0].offsetNanoseconds,X=T[1].epochMilliseconds,J=T[1].offsetNanoseconds;r.useEffect(()=>{if(B.current)return;const[e,t]=A.current,n=ke(e,a,w),r=ke(t,a,w),[o,l]=H.current;o===n&&l===r||(H.current=[n,r],R([n,r]))},[K,q,X,J,a,w]),r.useEffect(()=>{if(!L)return;const e=e=>{var t,n;const r=e.target;if(null===(t=_.current)||void 0===t?void 0:t.contains(r))return;if(null===(n=z.current)||void 0===n?void 0:n.contains(r))return;r.closest("[data-range-picker-popup]")||j(!1)},t=setTimeout(()=>{document.addEventListener("mousedown",e)},100);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[L]),r.useEffect(()=>{L||(N("start"),U.current||k(C),U.current=!1)},[L,C]);const Q=r.useCallback(e=>{i&&i(e,[ke(e[0],a,w),ke(e[1],a,w)])},[w,a,i]),ee=r.useCallback(e=>{s&&s(e,[ke(e[0],a,w),ke(e[1],a,w)])},[w,a,s]),te=r.useCallback((t,n)=>{k(r=>{const a=[...r];if("start"===t){const t=Te(a[1],Ce(n),n),r=e.Temporal.ZonedDateTime.compare(n,t)>0?n:t;return[n,r]}const o=Te(a[0],Ce(n),n);return[e.Temporal.ZonedDateTime.compare(o,n)>0?n:o,n]})},[]),ne=t=>{if(c)return;const n=(t,n)=>{var r,a,o,l;const i=Ce(t);return e.Temporal.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"===M){const e=n(T[0],t),r=T[1].epochMilliseconds-T[0].epochMilliseconds,a=e.add({milliseconds:r});return void k([e,a])}const r=n(T[1],t),a=T[1].epochMilliseconds-T[0].epochMilliseconds;if(e.Temporal.ZonedDateTime.compare(r,T[0])<0){const e=n(T[0],t),r=e.add({milliseconds:a});return void k([e,r])}const o=[T[0],r];k(o),P(r.toPlainDate().with({day:1}))},re=r.useCallback((t,n)=>{if(c)return;const r="start"===t?0:1;k(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=Te(a[1],Ce(l),l);return[l,e.Temporal.ZonedDateTime.compare(l,t)>0?l:t]}const i=Te(a[0],Ce(l),l);return[e.Temporal.ZonedDateTime.compare(i,l)>0?l:i,l]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const e=W.current[t].hour;if(!e)return;const n=e.querySelector('[data-active="true"]');n&&Z(e,n,0)})})},[c]),ae=r.useCallback((t,n)=>{if(c)return;const r="start"===t?0:1;k(a=>{const o=a[r].with({minute:n,second:0,millisecond:0,microsecond:0,nanosecond:0});if("start"===t){const t=Te(a[1],Ce(o),o);return[o,e.Temporal.ZonedDateTime.compare(o,t)>0?o:t]}const l=Te(a[0],Ce(o),o);return[e.Temporal.ZonedDateTime.compare(l,o)>0?o:l,o]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const e=W.current[t].minute;if(!e)return;const n=e.querySelector('[data-active="true"]');n&&Z(e,n,0)})})},[c]),oe=r.useCallback((e,t)=>{const n="start"===e?0:1;R(e=>{const r=[...e];return r[n]=t,r})},[]),le=r.useCallback((e,t)=>{const n="start"===e?0:1,r=T[n],o=Ce(r),l=Ee(t,E,r,o);if(l){te(e,l);const t=l.toPlainDate().with({day:1});return P(t),"start"===e&&N("end"),!0}return R(e=>{const t=[...e];return t[n]=ke(T[n],a,w),t}),!1},[T,w,a,E,te]),ie=r.useCallback(e=>t=>{const n=t.currentTarget.value;B.current=!0,oe(e,n);const r="start"===e?0:1,a=A.current[r],o=Ce(a),l=Ee(n,E,a,o);if(l){te(e,l);const t=l.toPlainDate().with({day:1});P(t),G(e)}},[oe,E,te,G]),de=r.useCallback(e=>t=>{var n;if(c)return;if(B.current=!1,L){const t="start"===e?0:1,n=ke(A.current[t],a,w);return void R(e=>{const r=[...e];return r[t]=n,r})}const r=t.relatedTarget;r&&(null===(n=_.current)||void 0===n?void 0:n.contains(r))||le(e,t.currentTarget.value)},[le,c,L,a,w]),ce=r.useCallback(e=>t=>{"Enter"===t.key&&(t.preventDefault(),B.current=!1,le(e,t.currentTarget.value)),"Escape"===t.key&&t.currentTarget.blur()},[le]),ue=()=>{U.current=!0,Q(T),ee(T),j(!1)},he=e=>{P(t=>t.add({months:e}).with({day:1}))},ge=e=>{P(t=>t.add({years:e}).with({day:1}))},me=r.useMemo(()=>{const e=O,t=e.dayOfWeek%7,n=e.subtract({days:t});return Array.from({length:42},(e,t)=>n.add({days:t}))},[O]),pe=r.useCallback((e=u)=>{if(!h||!_.current)return e;const t=_.current.getBoundingClientRect(),n=m?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},[h,m,u]),fe=r.useCallback(()=>{const e=pe();V.current!==e&&(V.current=e,F(e))},[pe]),ve=e=>{if(c)return;N(e);const t=T["start"===e?0:1].toPlainDate().with({day:1});P(t);const n=pe();V.current!==n&&(V.current=n,F(n)),j(!0)};r.useEffect(()=>{if(!L)return;fe();const e=()=>fe();return window.addEventListener("resize",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e,!0)}},[L,fe]);const ye=()=>{if(!_.current)return{};const e=_.current.getBoundingClientRect(),t={position:"fixed",zIndex:9999};return V.current.startsWith("bottom")?t.top=e.bottom+8:t.bottom=window.innerHeight-e.top+8,u.endsWith("Left")?t.left=e.left:t.right=window.innerWidth-e.right,m&&(t.width=`${e.width}px`),t};return se("div",{className:"relative max-w-100",ref:_,children:[se("div",{className:"flex items-center gap-2 rounded-lg border text-sm shadow-sm transition "+(c?"cursor-not-allowed border-slate-200 bg-slate-50 text-slate-400 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-500":L?"border-primary bg-white shadow-md dark:bg-gray-700":"border-slate-200 bg-white dark:border-gray-600 dark:bg-gray-700"),children:[se("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:se("input",{type:"text",name:"range-start",value:I[0],onChange:ie("start"),onFocus:()=>ve("start"),onClick:()=>ve("start"),onBlur:de("start"),onKeyDown:ce("start"),className:"w-full rounded-md border px-2 py-1.5 text-sm font-medium transition focus:ring-2 focus:outline-none "+(c?"cursor-not-allowed border-transparent bg-transparent text-slate-400 dark:text-gray-500":"start"===M&&L?"bg-white text-primary dark:bg-gray-700":"border-transparent bg-transparent text-slate-700 dark:text-gray-300"),placeholder:D,autoComplete:"off",disabled:c})}),se(Zt,{className:"text-slate-400 dark:text-gray-500"}),se("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:se("input",{type:"text",name:"range-end",value:I[1],onChange:ie("end"),onFocus:()=>ve("end"),onClick:()=>ve("end"),onBlur:de("end"),onKeyDown:ce("end"),className:"w-full rounded-md border px-2 py-1.5 text-sm font-medium transition focus:ring-2 focus:outline-none "+(c?"cursor-not-allowed border-transparent bg-transparent text-slate-400 dark:text-gray-500":"end"===M&&L?"bg-white text-primary dark:bg-gray-700":"border-transparent bg-transparent text-slate-700 dark:text-gray-300"),placeholder:D,autoComplete:"off",disabled:c})})]}),L&&(g?n.createPortal(se(Tn,{visibleMonth:O,monthLabels:b,weekDayLabels:x,calendarDays:me,draftRange:T,focusedField:M,isTimeEnabled:!!v,disabled:c,matchTriggerWidth:m,popupRef:z,timeListRefs:W,onMonthChange:he,onYearChange:ge,onDaySelect:ne,onHourSelect:re,onMinuteSelect:ae,onOk:ue,getPopupStyle:ye}),g()):n.createPortal(se(Tn,{visibleMonth:O,monthLabels:b,weekDayLabels:x,calendarDays:me,draftRange:T,focusedField:M,isTimeEnabled:!!v,disabled:c,matchTriggerWidth:m,popupRef:z,timeListRefs:W,onMonthChange:he,onYearChange:ge,onDaySelect:ne,onHourSelect:re,onMinuteSelect:ae,onOk:ue,getPopupStyle:ye}),document.body))]})},Sn=({options:e,value:t,onChange:a,registry:o,variant:l="desktop",disabled:i=!1})=>{const[s,d]=r.useState(!1),[c,u]=r.useState({}),h=r.useRef(null),g=r.useRef(null),m=()=>{if(g.current){const e=g.current.getBoundingClientRect(),t="mobile"===l,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`,u(n)}};r.useEffect(()=>{const e=e=>{!h.current||h.current.contains(e.target)||e.target.closest("[data-calendar-picker-dropdown]")||d(!1)};return s&&(m(),window.addEventListener("mousedown",e),window.addEventListener("scroll",m,!0),window.addEventListener("resize",m)),()=>{window.removeEventListener("mousedown",e),window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",m)}},[s]);const p=e=>(o||O()).resolveColors(e).lineColor,f=(e,t)=>{e.stopPropagation(),a(t),d(!1)},v=e.find(e=>e.value===t),y=()=>s&&"undefined"!=typeof window?"mobile"===l?n.createPortal(se("div",{"data-calendar-picker-dropdown":"true",style:c,className:Tt,children:e.map(e=>se("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=>f(t,e.value),children:[se("div",{className:"mr-3 flex min-w-0 flex-1 items-center",children:[se("div",{className:"mr-2 flex w-5 justify-center",children:e.value===t&&se(zt,{className:"h-4 w-4 text-primary"})}),se("span",{className:"truncate text-sm text-gray-700 dark:text-gray-200",children:e.label})]}),se("span",{className:"h-3 w-3 shrink-0 rounded-full",style:{backgroundColor:p(e.value)}})]},e.value))}),document.body):n.createPortal(se("ul",{"data-calendar-picker-dropdown":"true",style:c,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=>se("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=>f(t,e.value),children:[t===e.value?se("span",{className:"mr-2 text-sm text-primary",children:se(zt,{width:12,height:12})}):se("div",{className:"mr-2 h-3 w-3 text-sm",children:" "}),se("span",{className:"mr-2 h-3 w-3 shrink-0 rounded-sm",style:{backgroundColor:p(e.value)}}),se("span",{className:"text-sm whitespace-nowrap text-gray-700 dark:text-gray-200",children:e.label})]},e.value))}),document.body):null;return se("div","mobile"===l?{className:"relative inline-block",ref:h,children:[se("button",{type:"button",ref:g,disabled:i,onClick:e=>{e.stopPropagation(),i||d(!s)},className:"flex items-center space-x-2 rounded-md bg-gray-100 px-3 py-1.5 transition-colors dark:bg-gray-700 "+(i?"cursor-default opacity-50":""),children:[se("span",{className:"h-3 w-3 rounded-full",style:{backgroundColor:p(t)}}),se("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-200",children:(null==v?void 0:v.label)||t}),se(Wt,{className:"h-4 w-4 text-gray-400"})]}),y()]}:{className:"relative inline-block",ref:h,children:[se("button",{ref:g,type:"button",onClick:e=>{e.stopPropagation(),d(!s)},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:[se("span",{className:"h-4 w-4 shrink-0 rounded-sm",style:{backgroundColor:p(t)}}),se(Wt,{className:"h-4 w-4 text-gray-600 dark:text-gray-300"})]}),y()]})},Mn=({event:t,isOpen:a,onEventUpdate:o,onEventDelete:l,onClose:i,app:s})=>{var d;const[c,u]=r.useState(t),{t:h}=nt();r.useEffect(()=>{u(t)},[t]);const g=r.useMemo(()=>(s?s.getCalendarRegistry():O()).getVisible().map(e=>({label:e.name,value:e.id})),[s,null==s?void 0:s.getCalendars()]),m=r.useMemo(()=>!ee(t,c),[t,c]),p=r.useMemo(()=>y(c.start)?c.end&&!y(c.end)&&c.end.timeZoneId||e.Temporal.Now.timeZoneId():c.start.timeZoneId||e.Temporal.Now.timeZoneId(),[c.end,c.start]),f=e=>{const[t,n]=e;u(Object.assign(Object.assign({},c),{start:t.toPlainDate(),end:n.toPlainDate()}))},v=!(null==s?void 0:s.state.readOnly),b=!1!==(null==s?void 0:s.getReadOnlyConfig().viewable);if(!a||!b)return null;if("undefined"==typeof window||"undefined"==typeof document)return null;const x=se("div",{className:"fixed inset-0 flex items-center justify-center",style:{pointerEvents:"auto",zIndex:9998},"data-event-detail-dialog":"true",children:[se("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&&i()}}),se("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:[se("button",{type:"button",onClick:i,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:se("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:se("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),se("div",{children:[se("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:h("eventTitle")}),se("div",{className:"mb-4 flex items-center justify-between gap-3",children:[se("div",{className:"flex-1",children:se("input",{id:`event-dialog-title-${c.id}`,name:"title",type:"text",value:c.title,readOnly:!v,disabled:!v,onChange:e=>{u(Object.assign(Object.assign({},c),{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"})}),v&&se(Sn,{options:g,value:c.calendarId||"blue",onChange:e=>{u(Object.assign(Object.assign({},c),{calendarId:e}))},registry:null==s?void 0:s.getCalendarRegistry()})]}),c.allDay?se("div",{className:"mb-4",children:[se("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:h("dateRange")}),se(kn,{value:[c.start,c.end],format:"YYYY-MM-DD",showTime:!1,timeZone:p,matchTriggerWidth:!0,disabled:!v,onChange:f,onOk:f,locale:null==s?void 0:s.state.locale})]}):se("div",{className:"mb-4",children:[se("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:h("timeRange")}),se(kn,{value:[c.start,c.end],timeZone:p,disabled:!v,onChange:e=>{const[t,n]=e;u(Object.assign(Object.assign({},c),{start:t,end:n}))},onOk:e=>{const[t,n]=e;u(Object.assign(Object.assign({},c),{start:t,end:n}))},locale:null==s?void 0:s.state.locale})]}),se("div",{className:"mb-4",children:[se("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:h("note")}),se("textarea",{id:`event-dialog-note-${c.id}`,name:"note",value:null!==(d=c.description)&&void 0!==d?d:"",readOnly:!v,disabled:!v,onChange:e=>u(Object.assign(Object.assign({},c),{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:h("addNotePlaceholder")})]}),v&&se("div",{className:"flex space-x-2",children:[c.allDay?se("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=y(c.start)?c.start:c.start.toPlainDate(),n=e.Temporal.ZonedDateTime.from({year:t.year,month:t.month,day:t.day,hour:9,minute:0,timeZone:e.Temporal.Now.timeZoneId()}),r=e.Temporal.ZonedDateTime.from({year:t.year,month:t.month,day:t.day,hour:10,minute:0,timeZone:e.Temporal.Now.timeZoneId()});u(Object.assign(Object.assign({},c),{allDay:!1,start:n,end:r}))},children:h("setAsTimed")}):se("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=y(c.start)?c.start:c.start.toPlainDate();u(Object.assign(Object.assign({},c),{allDay:!0,start:e,end:e}))},children:h("setAsAllDay")}),se("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:()=>{l(t.id),i()},children:h("delete")}),se("button",{type:"button",className:"ml-auto rounded-lg bg-primary px-3 py-2 text-xs font-medium text-primary-foreground transition "+(m?"shadow-lg shadow-primary/20 hover:bg-primary/90":"cursor-not-allowed opacity-50 grayscale-[0.5]"),onClick:()=>{o(c),i()},disabled:!m,children:h("save")})]})]})]})]}),w=document.body;return w?n.createPortal(x,w):null},Nn=e=>e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}),In=({app:e,anchorRef:t,onClose:a,isOpen:o})=>{const{t:l}=nt(),[i,s]=r.useState(""),[d,c]=r.useState(0),[u,h]=r.useState(!1),g=r.useRef(null),m=r.useRef(null);r.useEffect(()=>{o||h(!1)},[o]),r.useEffect(()=>{o&&(setTimeout(()=>{var e;return null===(e=g.current)||void 0===e?void 0:e.focus()},50),s(""),c(0))},[o]),r.useEffect(()=>{const e=e=>{o&&m.current&&!m.current.contains(e.target)&&t.current&&!t.current.contains(e.target)&&a()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[o,a,t]);const[p,f]=r.useState({top:0,left:0}),[v,y]=r.useState("top"),[x,w]=r.useState(0),D=r.useMemo(()=>{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}},[o]),E=r.useMemo(()=>{if(!i.trim())return[];const t=[],n=e.getCalendars(),r=e.getAllEvents(),a=i.toLowerCase(),o=r.find(e=>e.title.toLowerCase()===a);let l=null==o?void 0:o.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:i,calendarId:l||"",color:d,start:D.start,end:D.end});const c=new Set([i.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:D.start,end:D.end})}),t},[i,e,D]);r.useLayoutEffect(()=>{if(o&&t.current&&m.current){const e=t.current.getBoundingClientRect(),n=m.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;w(i-a);let s=0,d="top";e.top<n+20?(d="bottom",s=e.bottom+12):(d="top",s=e.top-12-n),y(d),f({top:s,left:a}),h(!0)}},[o,t,E]);const C=t=>{if(!t.calendarId)return;const n=ne(),r={id:n,title:t.title,start:b(t.start),end:b(t.end),calendarId:t.calendarId,allDay:!1};e.addEvent(r),e.setCurrentDate(t.start),e.highlightEvent(n),a()};return r.useEffect(()=>{if(!o)return;const e=e=>{"ArrowDown"===e.key?(e.preventDefault(),c(e=>(e+1)%E.length)):"ArrowUp"===e.key?(e.preventDefault(),c(e=>(e-1+E.length)%E.length)):"Enter"===e.key&&(e.preventDefault(),E[d]&&C(E[d]))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[o,E,d]),o?n.createPortal(se("div",{ref:m,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 "+(u?"animate-in fade-in zoom-in-95 duration-100":""),style:{top:p.top,left:p.left,visibility:u?"visible":"hidden"},children:[se("div",{className:"p-4 pb-2",children:[se("div",{className:"mb-2 text-xs font-semibold tracking-wider text-gray-500 uppercase dark:text-gray-400",children:l("quickCreateEvent")||"Quick Create Event"}),se("div",{className:"relative",children:se("input",{ref:g,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:l("quickCreatePlaceholder")||"Enter title (e.g. Code review)",value:i,onChange:e=>s(e.target.value)})})]}),se("div",{className:"max-h-75 flex-1 overflow-y-auto px-2 py-1",children:[0===E.length&&i&&se("div",{className:"px-4 py-3 text-center text-sm text-gray-400",children:l("noSuggestions")||"Type to create"}),E.map((e,t)=>{return se("div",{className:"flex cursor-pointer items-center rounded-lg px-4 py-2 transition-colors "+(t===d?"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:()=>C(e),onMouseEnter:()=>c(t),children:[se("div",{className:"mr-3 h-8 w-1 shrink-0 rounded-full",style:{backgroundColor:e.color}}),se("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[se("div",{className:"truncate text-sm font-medium text-gray-900 dark:text-gray-100",children:e.title}),se("div",{className:"flex",children:se("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?l("today"):l("tomorrow")})}),se("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:(n=e.start,r=e.end,`${Nn(n)} - ${Nn(r)}`)})]})]},`${e.type}-${t}`);var n,r})]}),se("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"===v?"-bottom-1.5 border-r border-b":"-top-1.5 border-t border-l"),style:{left:x}})]}),document.body):null},Rn=({visibleMonth:e,currentDate:t,showHeader:n=!1,onMonthChange:a,onDateSelect:o})=>{const{locale:l}=nt(),i=r.useMemo(()=>(new Date).toDateString(),[]),s=t.toDateString(),d=r.useMemo(()=>nn(l,"narrow"),[l]),c=r.useMemo(()=>e.toLocaleDateString(l,{month:"long",year:"numeric"}),[e,l]),u=r.useMemo(()=>{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),l=o.toDateString();a.push({date:o.getDate(),fullDate:o,isCurrentMonth:o.getMonth()===n,isToday:l===i,isSelected:l===s})}return a},[e,s,i]);return se("div",{className:"px-3 py-3",children:[n?se("div",{className:"mb-3 flex items-center justify-between",children:[se("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:()=>a(-1),"aria-label":"Previous month",children:se(Lt,{className:"h-4 w-4"})}),se("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:c}),se("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:()=>a(1),"aria-label":"Next month",children:se($t,{className:"h-4 w-4"})})]}):"",se("div",{className:"df-mini-calendar-grid grid grid-cols-7 gap-1 text-xs justify-items-center",children:[d.map((e,t)=>se("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}`)),u.map(e=>se("button",{type:"button",className:` df-mini-calendar-day text-center py-1 rounded text-xs h-6 w-6 ${e.isToday?wt: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:()=>o(e.fullDate),children:e.date},e.fullDate.getTime()))]})]})},Hn=({checked:e,onChange:t,disabled:n})=>se("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:se("div",{className:"h-5 w-5 transform rounded-full bg-white shadow-md transition-transform "+(e?"translate-x-5":"")})}),An=({date:e,onChange:t})=>{const n=Array.from({length:24},(e,t)=>t),a=Array.from({length:12},(e,t)=>5*t),o=[...n,...n,...n],l=[...a,...a,...a],i=32,s=e.getHours(),d=5*Math.round(e.getMinutes()/5),c=(24+s)*i,u=(12+d/5)*i,[h,g]=r.useState(c),[m,p]=r.useState(u),f=r.useRef(null),v=r.useRef(null),y=r.useRef(null);r.useEffect(()=>{f.current&&(f.current.scrollTop=c,g(c)),v.current&&(v.current.scrollTop=u,p(u))},[c,u]);const b=(n,r)=>{const a=n.currentTarget;let s=a.scrollTop;if("hour"===r){const e=768;s<320?(s+=e,a.scrollTop=s):s>1600&&(s-=e,a.scrollTop=s),g(s)}else{const e=384;s<160?(s+=e,a.scrollTop=s):s>800&&(s-=e,a.scrollTop=s),p(s)}y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{((n,r)=>{const a=Math.round(r/i);if("hour"===n){const n=o[a];if(void 0!==n&&n!==e.getHours()){const r=new Date(e);r.setHours(n),t(r)}}else{const n=l[a];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 se("div",{className:"relative mt-2 flex h-56 overflow-hidden rounded-lg",children:[se("style",{children:"\n .no-scrollbar::-webkit-scrollbar { display: none; }\n .no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }\n "}),se("div",{ref:f,className:"no-scrollbar flex-1 snap-y snap-mandatory overflow-y-auto",style:{touchAction:"pan-y"},onScroll:e=>b(e,"hour"),children:[se("div",{style:{height:96}}),o.map((n,r)=>se("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=f.current)||void 0===a||a.scrollTo({top:r*i,behavior:"smooth"})},children:se("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,h),children:n.toString().padStart(2,"0")})},`h-${r}-${n}`)),se("div",{style:{height:96}})]}),se("div",{ref:v,className:"no-scrollbar flex-1 snap-y snap-mandatory overflow-y-auto",style:{touchAction:"pan-y"},onScroll:e=>b(e,"minute"),children:[se("div",{style:{height:96}}),l.map((n,r)=>se("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=v.current)||void 0===a||a.scrollTo({top:r*i,behavior:"smooth"})},children:se("div",{className:"w-10 text-center text-xl transition-colors duration-200 "+(n===d?"font-bold text-black dark:text-white":"text-gray-400 dark:text-gray-500"),style:x(r,m),children:n.toString().padStart(2,"0")})},`m-${r}-${n}`)),se("div",{style:{height:96}})]}),se("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"})]})},On=({isOpen:e,onClose:t,onSave:a,onEventDelete:o,draftEvent:l,app:i,timeFormat:s="24h"})=>{const{locale:d,t:c}=nt(),u=i.getReadOnlyConfig(),h=!i.state.readOnly,g=!1!==u.viewable,[m,p]=r.useState(""),[f,v]=r.useState(""),[y,x]=r.useState(!1),[D,E]=r.useState(new Date),[C,T]=r.useState(new Date),[k,S]=r.useState(""),[M,N]=r.useState(new Date),[I,R]=r.useState(new Date),[H,A]=r.useState(null),[O,P]=r.useState(e),[L,$]=r.useState(!1),[j,Y]=r.useState(!1);r.useEffect(()=>{if(!e){$(!0);const e=setTimeout(()=>{P(!1),$(!1)},300);return()=>clearTimeout(e)}P(!0),$(!1)},[e]),r.useEffect(()=>{if(e&&l){const e=i.getEvents().some(e=>e.id===l.id);Y(e)}},[e,l,i]);const V=i.getCalendars(),_=V.map(e=>({label:e.name,value:e.id}));r.useEffect(()=>{if(e&&V.length>0){V.some(e=>e.id===f)||"blue"!==f&&""!==f||v(V[0].id)}},[V,e,f]),r.useEffect(()=>(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]),r.useEffect(()=>{var t,n;if(e&&l){if(p(l.title||""),v(l.calendarId||(null===(t=V[0])||void 0===t?void 0:t.id)||"blue"),x(l.allDay||!1),l.start)try{const e=w(l.start);E(e),N(e)}catch(e){console.error("Failed to parse start date",e);const t=new Date;E(t),N(t)}if(l.end)try{const e=w(l.end);T(e),R(e)}catch(e){console.error("Failed to parse end date",e);const t=new Date;T(t),R(t)}}else if(e&&!l){v((null===(n=V[0])||void 0===n?void 0:n.id)||"blue");const e=new Date;e.setMinutes(0,0,0),E(e),N(e),T(new Date(e.getTime()+36e5)),R(e)}},[e,l]);const z=r.useMemo(()=>{if(!e||!l)return!1;let t=new Date(D),n=new Date(C);y&&(t.setHours(0,0,0,0),n.setHours(0,0,0,0));const r=Object.assign(Object.assign({},l),{title:m,calendarId:f,allDay:y,description:k,start:b(t),end:b(n)});return!ee(l,r)},[e,l,m,f,y,D,C,k]);if(!O||!g)return null;const W=e=>{A(t=>t===e?null:e)},U=e=>e.toLocaleDateString(d,{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();E(e);const r=new Date(C.getTime()+n);T(r)}else{const e=new Date(t);e.setHours(C.getHours(),C.getMinutes()),T(e)}},Z=(e,t)=>{"start"===e?N(e=>{const n=new Date(e);return n.setMonth(e.getMonth()+t),n}):R(e=>{const n=new Date(e);return n.setMonth(e.getMonth()+t),n})};return n.createPortal(se("div",{className:"pointer-events-none fixed inset-0 z-10000 flex items-end",children:[se("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}),se("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:[se("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:[se("button",{type:"button",onClick:t,className:"px-2 py-1 text-gray-500 hover:text-gray-700",children:c("cancel")}),se("span",{className:"text-lg font-semibold",children:c(!h&&j?"viewEvent":j?"editEvent":"newEvent")}),h&&se("button",{type:"button",onClick:()=>{if(!l)return;let e=new Date(D),t=new Date(C);y&&(e.setHours(0,0,0,0),t.setHours(0,0,0,0));const n=Object.assign(Object.assign({},l),{title:m,calendarId:f,allDay:y,start:b(e),end:b(t)});a(n)},disabled:!z,className:"px-2 py-1 font-bold transition-colors "+(z?"text-primary":"cursor-not-allowed text-gray-400 opacity-50"),children:c(j?"done":"create")}),!h&&se("span",{className:"w-12"})]}),se("div",{className:"flex-1 space-y-4 overflow-y-auto p-4",children:[se("div",{className:"rounded-lg bg-white px-4 py-3 dark:bg-gray-900",children:se("input",{type:"text",placeholder:c("titlePlaceholder"),value:m,onChange:e=>h&&p(e.currentTarget.value),readOnly:!h,className:"w-full bg-transparent text-xl font-medium placeholder-gray-400 focus:outline-none",autoFocus:h})}),V.length>0&&se("div",{className:"relative flex items-center justify-between rounded-lg bg-white px-4 py-3 dark:bg-gray-900",children:[se("span",{className:"text-gray-700 dark:text-gray-300",children:c("calendar")}),se(Sn,{options:_,value:f,onChange:h?v:()=>{},registry:i.getCalendarRegistry(),variant:"mobile",disabled:!h})]}),se("div",{className:"flex items-center justify-between rounded-lg bg-white px-4 py-3 dark:bg-gray-900",children:[se("span",{className:"text-gray-700 dark:text-gray-300",children:c("allDay")}),se(Hn,{checked:y,onChange:h?x:()=>{},disabled:!h})]}),se("div",{className:"overflow-hidden rounded-lg bg-white dark:bg-gray-900",children:[se("div",{className:"flex items-center justify-between border-b border-gray-100 px-4 py-3 last:border-0 dark:border-gray-800",children:[se("span",{className:"text-gray-700 dark:text-gray-300",children:c("starts")}),se("div",{className:"flex space-x-2",children:[se("button",{type:"button",className:"rounded-md px-3 py-1 transition-colors "+("start-date"===H?"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:()=>h&&W("start-date"),disabled:!h,children:U(D)}),!y&&se("button",{type:"button",className:"rounded-md px-3 py-1 transition-colors "+("start-time"===H?"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:()=>h&&W("start-time"),disabled:!h,children:F(D.getHours()+D.getMinutes()/60,0,s)})]})]}),se("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("start-date"===H?"max-h-100":"max-h-0"),children:se("div",{className:"",children:se(Rn,{currentDate:D,visibleMonth:M,onDateSelect:e=>B("start",e),onMonthChange:e=>Z("start",e),showHeader:!0})})}),se("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("start-time"===H?"max-h-75":"max-h-0"),children:se("div",{className:"",children:se(An,{date:D,onChange:e=>{const t=C.getTime()-D.getTime();E(e),T(new Date(e.getTime()+t))},timeFormat:s})})})]}),se("div",{className:"overflow-hidden rounded-lg bg-white dark:bg-gray-900",children:[se("div",{className:"flex items-center justify-between border-b border-gray-100 px-4 py-3 last:border-0 dark:border-gray-800",children:[se("span",{className:"text-gray-700 dark:text-gray-300",children:c("ends")}),se("div",{className:"flex space-x-2",children:[se("button",{type:"button",className:"rounded-md px-3 py-1 transition-colors "+("end-date"===H?"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:()=>h&&W("end-date"),disabled:!h,children:U(C)}),!y&&se("button",{type:"button",className:"rounded-md px-3 py-1 transition-colors "+("end-time"===H?"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:()=>h&&W("end-time"),disabled:!h,children:F(C.getHours()+C.getMinutes()/60,0,s)})]})]}),se("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("end-date"===H?"max-h-100":"max-h-0"),children:se("div",{className:"",children:se(Rn,{currentDate:C,visibleMonth:I,onDateSelect:e=>B("end",e),onMonthChange:e=>Z("end",e),showHeader:!0})})}),se("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("end-time"===H?"max-h-75":"max-h-0"),children:se("div",{className:"",children:se(An,{date:C,onChange:e=>{if(e<D){const t=C.getTime()-D.getTime();T(e),E(new Date(e.getTime()-t))}else T(e)},timeFormat:s})})})]}),se("div",{className:"rounded-lg bg-white px-4 py-3 dark:bg-gray-900",children:se("textarea",{placeholder:c("notesPlaceholder"),value:k,onChange:e=>h&&S(e.currentTarget.value),readOnly:!h,className:"min-h-20 w-full bg-transparent text-base placeholder-gray-400 focus:outline-none"})}),h&&j&&o&&l&&se("button",{type:"button",onClick:()=>o(l.id),className:"w-full rounded-lg bg-white px-4 py-3 text-left font-medium text-red-500 dark:bg-gray-900",children:c("delete")})]})]})]}),document.body)},Pn=()=>se("svg",{className:"h-12 w-12 text-gray-300 dark:text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:se("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),Ln=({loading:e,results:t,keyword:n,onResultClick:a,emptyText:o})=>{const{t:l,locale:i}=nt(),s=r.useMemo(()=>Pe(new Date),[]),d=r.useMemo(()=>$e(t,s),[t,s]),c=e=>Oe(e);return e?se("div",{className:"flex h-40 flex-col items-center justify-center text-gray-500",children:[se(Gt,{className:"mb-2 h-8 w-8 animate-spin"}),se("span",{children:"Loading..."})]}):0===t.length?n?se("div",{className:"flex h-40 flex-col items-center justify-center text-gray-500",children:[se(Pn,{}),se("span",{className:"mt-2 text-sm",children:"string"==typeof o?o:o&&"object"==typeof o?o[i]||o.en||"No results found":l("noResults")||"No results found"})]}):null:se("div",{className:"space-y-6",children:d.map(e=>{const{title:t,colorClass:n}=Le(e.date,s,i,l);return se("div",{children:[se("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}),se("div",{className:"flex flex-col",children:e.events.map(e=>{const t=c(e.start),n=c(e.end),r={hour:"2-digit",minute:"2-digit"},o=e.allDay?l("allDay")||"All Day":t.toLocaleTimeString(i,r),s=e.allDay?"":n.toLocaleTimeString(i,r);return se("div",{children:[se("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==a?void 0:a(e),children:se("div",{className:"flex items-stretch gap-3",children:[se("div",{className:"w-1 shrink-0 rounded-full",style:{backgroundColor:e.color||"#3b82f6"}}),se("div",{className:"flex min-w-0 flex-1 items-start justify-between",children:[se("div",{className:"truncate pr-2 text-sm font-medium text-black dark:text-white",children:e.title}),se("div",{className:"flex shrink-0 flex-col items-end text-xs leading-tight",children:[se("div",{className:"text-black dark:text-white",children:o}),s&&se("div",{className:"text-gray-500 dark:text-gray-400",children:s})]})]})]})}),se("div",{className:"mx-2 border-b border-gray-200 dark:border-gray-700"})]},e.id)})})]},e.date.getTime())})})},$n=({isOpen:e,onClose:t,keyword:a,onSearchChange:o,results:l,loading:i,onResultClick:s,emptyText:d})=>{const c=r.useRef(null),{t:u}=nt();return r.useEffect(()=>(e?(setTimeout(()=>{var e;null===(e=c.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?n.createPortal(se("div",{className:"fixed inset-0 z-9999 bg-white dark:bg-gray-900 flex flex-col",children:[se("div",{className:"flex items-center p-2 border-b border-gray-200 dark:border-gray-700 gap-2",children:[se("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:se(Qt,{className:"h-6 w-6"})}),se("div",{className:"relative flex-1",children:[se("input",{ref:c,type:"text",placeholder:u("search")||"Search",value:a,onChange:e=>{const t=e.target.value;t!==a&&o(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"}),a&&se("button",{type:"button",onClick:()=>{""!==a&&o("")},className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400",children:se(Ut,{className:"h-4 w-4"})})]})]}),se("div",{className:"flex-1 overflow-y-auto p-2 select-none",children:se(Ln,{loading:i,results:l,keyword:a,onResultClick:e=>{null==s||s(e)},emptyText:d})})]}),document.body):null},jn=({isOpen:e,loading:t,results:n,keyword:r,onResultClick:a,emptyText:o})=>se("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:se("div",{className:"min-w-64 flex-1 overflow-y-auto",children:se(Ln,{loading:t,results:n,keyword:r,onResultClick:a,emptyText:o})})});let Yn=null;const Fn={enabled:!1,width:"0px",isCollapsed:!1,toggleCollapsed:()=>{},miniWidth:"0px",content:null,extraContent:null,safeAreaLeft:0};function Vn(e){return Yn&&e.hasPlugin("sidebar")?Yn(e):Fn}const _n=({locale:e,messages:t,children:n})=>nt().isDefault?se(on,{locale:e,messages:t,children:n}):n,zn=({app:e,customDetailPanelContent:o,customEventDetailDialog:l,meta:i,customMessages:s,search:d,titleBarSlot:c,collapsedSafeAreaLeft:u})=>{const h=r.useContext(hn),{tick:g,selectedEventId:m}=function(e){const[t,n]=r.useState(0),[a,o]=r.useState(null);return r.useEffect(()=>e.subscribe(e=>{n(e=>e+1),o(t=>{var n;const r=null!==(n=e.state.selectedEventId)&&void 0!==n?n:null;return t===r?t:r})}),[e]),{tick:t,selectedEventId:a}}(e),{isMobile:p}=function(){const[e,t]=r.useState(!1);return r.useEffect(()=>{const e=()=>{t(window.matchMedia("(max-width: 768px)").matches)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),{isMobile:e}}(),f=function(e,t){const[n,o]=r.useState(""),[l,i]=r.useState(!1),[s,d]=r.useState(!1),[c,u]=r.useState(!1),[h,g]=r.useState([]);r.useEffect(()=>{e.state.highlightedEventId&&e.selectEvent(e.state.highlightedEventId)},[e.state.highlightedEventId,e]),r.useEffect(()=>{l||null===e.state.highlightedEventId||e.highlightEvent(null)},[l,e]),r.useEffect(()=>{var r;if(!n.trim())return i(!1),g([]),void(null!==e.state.highlightedEventId&&e.highlightEvent(null));const o=null!==(r=null==t?void 0:t.debounceDelay)&&void 0!==r?r:300,l=setTimeout(()=>a.__awaiter(this,void 0,void 0,function*(){var r;u(!0),i(!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{u(!1)}}),o);return()=>clearTimeout(l)},[n,t,e]);const m=r.useCallback(t=>{let n;n=t.start instanceof Date?t.start:"string"==typeof t.start?new Date(t.start):w(t.start),e.setCurrentDate(n),e.highlightEvent(t.id),s&&d(!1)},[e,s]),p=r.useCallback(()=>{o(""),d(!0)},[]),f=r.useCallback(()=>{i(!1),o(""),e.highlightEvent(null)},[e]),v=r.useCallback(()=>{d(!1),o(""),e.highlightEvent(null)},[e]);return{searchKeyword:n,setSearchKeyword:o,isSearchOpen:l,setIsSearchOpen:i,isMobileSearchOpen:s,setIsMobileSearchOpen:d,searchLoading:c,searchResults:h,handleSearchResultClick:m,handleSearchClick:p,handleSearchClose:f,handleMobileSearchClose:v}}(e,d),v=l||(e.getUseEventDetailDialog()?Mn:void 0),x=function(e,t,n){const[a,o]=r.useState(null);r.useEffect(()=>{o(null)},[e]);const l=r.useCallback(()=>{o(null),e.selectEvent(null)},[e]),i=r.useCallback(t=>e.updateEvent(t.id,t),[e]),s=r.useCallback(t=>{e.deleteEvent(t),o(null),e.selectEvent(null)},[e]),d=r.useMemo(()=>{if(!t||!a)return null;const n=a.split("::")[0],r=e.getEvents().find(e=>e.id===n);return r?{event:r,isOpen:!0,isAllDay:y(r.start),onEventUpdate:i,onEventDelete:s,onClose:l,app:e}:null},[n,a,t,l,i,s,e]);return{detailPanelEventId:a,setDetailPanelEventId:o,dialogProps:d}}(e,v,g),D=Vn(e),E=function(e,t,n){const[a,o]=r.useState(!1),l=r.useRef(null),[i,s]=r.useState(!1),[d,c]=r.useState(null),[u,h]=r.useState(!1),g=r.useCallback(()=>{h(!0)},[]),m=r.useCallback(r=>{var i,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:ne(),title:"",start:b(t),end:b(n),calendarId:(null===(i=e.getCalendars().find(e=>!1!==e.isVisible))||void 0===i?void 0:i.id)||(null===(d=e.getCalendars()[0])||void 0===d?void 0:d.id)};return c(r),void s(!0)}n?a?o(!1):(l.current=r.currentTarget,o(!0)):g()}},[t,a,e,n,g]);return{isQuickCreateOpen:a,setIsQuickCreateOpen:o,quickCreateAnchorRef:l,isMobileDrawerOpen:i,setIsMobileDrawerOpen:s,mobileDraftEvent:d,setMobileDraftEvent:c,handleAddButtonClick:m,isCreateCalendarOpen:u,setIsCreateCalendarOpen:h}}(e,p,D.enabled),[C,T]=r.useState(()=>e.getTheme());r.useEffect(()=>e.subscribeThemeChange(e=>T(e)),[e]);const k=r.useCallback(t=>e.setTheme(t),[e]);r.useEffect(()=>{const t=e.callbacks,n=t.onDismissUI;return t.onDismissUI=()=>{x.detailPanelEventId&&x.setDetailPanelEventId(null),E.isMobileDrawerOpen&&E.setIsMobileDrawerOpen(!1),null==n||n()},()=>{t.onDismissUI=n}},[e,x,E]),r.useEffect(()=>{if(!p||!x.detailPanelEventId)return;const t=x.detailPanelEventId.split("::")[0],n=e.getEvents().find(e=>e.id===t);n&&(E.setMobileDraftEvent(n),E.setIsMobileDrawerOpen(!0)),x.setDetailPanelEventId(null)},[x.detailPanelEventId,p]);const S=r.useCallback(t=>{e.setCurrentDate(t),e.selectEvent(null)},[e]),M=r.useCallback(t=>e.selectEvent(t),[e]),N=r.useRef(null),I={app:e,config:e.getCurrentView().config||{},customDetailPanelContent:o,customEventDetailDialog:v,switcherMode:e.state.switcherMode,calendarRef:N,meta:i,selectedEventId:m,onEventSelect:M,onDateChange:S,detailPanelEventId:x.detailPanelEventId,onDetailPanelToggle:x.setDetailPanelEventId},R=r.useMemo(()=>({isCollapsed:D.isCollapsed,toggleCollapsed:D.toggleCollapsed}),[D.isCollapsed,D.toggleCollapsed]),H=void 0!==u,A=H?"0px":D.miniWidth,O=H&&D.isCollapsed?u:D.safeAreaLeft,P=e.getCalendarHeaderConfig(),L=Object.assign({calendar:e,switcherMode:e.state.switcherMode,onAddCalendar:E.handleAddButtonClick,onSearchChange:f.setSearchKeyword,onSearchClick:f.handleSearchClick,searchValue:f.searchKeyword,isSearchOpen:f.isSearchOpen,isEditable:!e.state.readOnly},O>0?{safeAreaLeft:O}:{}),$=e.getCurrentView().component,j=e.getCustomMobileEventRenderer()||On;return se(cn,{initialTheme:C,onThemeChange:k,children:se(_n,{locale:e.state.locale,messages:s,children:se("div",{className:"df-calendar-container relative flex flex-row overflow-hidden select-none",children:[se(mn,{store:h,generatorName:"titleBarSlot",generatorArgs:R,defaultContent:c&&("function"==typeof c?c(R):c)}),D.enabled&&se("aside",{className:"absolute top-0 bottom-0 left-0 z-0 h-full",style:{width:D.width},children:D.content}),se("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 "+(D.isCollapsed?"border-gray-200 shadow-xl dark:border-gray-700":"border-transparent"),style:{marginLeft:D.enabled?D.isCollapsed?A:D.width:0},children:[!1===P?null:"function"==typeof P?P(L):t.h(sn,L),se("div",{className:"relative flex-1 overflow-hidden",ref:N,children:[se("div",{className:"calendar-renderer relative flex h-full flex-row",children:[se("div",{className:"h-full flex-1 overflow-hidden",children:se($,Object.assign({},I))}),se(jn,{isOpen:f.isSearchOpen,onClose:f.handleSearchClose,loading:f.searchLoading,results:f.searchResults,keyword:f.searchKeyword,onResultClick:f.handleSearchResultClick,emptyText:null==d?void 0:d.emptyText})]}),se($n,{isOpen:f.isMobileSearchOpen,onClose:f.handleMobileSearchClose,keyword:f.searchKeyword,onSearchChange:f.setSearchKeyword,results:f.searchResults,loading:f.searchLoading,onResultClick:f.handleSearchResultClick,emptyText:null==d?void 0:d.emptyText})]})]}),se(In,{app:e,anchorRef:E.quickCreateAnchorRef,isOpen:E.isQuickCreateOpen,onClose:()=>E.setIsQuickCreateOpen(!1)}),se(j,{isOpen:E.isMobileDrawerOpen,onClose:()=>{E.setIsMobileDrawerOpen(!1),E.setMobileDraftEvent(null)},onSave:t=>{e.getEvents().some(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),E.setIsMobileDrawerOpen(!1),E.setMobileDraftEvent(null)},onEventDelete:t=>{e.deleteEvent(t),E.setIsMobileDrawerOpen(!1),E.setMobileDraftEvent(null)},draftEvent:E.mobileDraftEvent,app:e}),D.extraContent,E.isCreateCalendarOpen&&se(yn,{app:e,onClose:()=>E.setIsCreateCalendarOpen(!1),onCreate:t=>{e.createCalendar(t),E.setIsCreateCalendarOpen(!1)}}),(()=>{if(!x.dialogProps)return null;const e=v,r="undefined"==typeof document?null:document.body;if(!r)return null;const a=null==h?void 0:h.isOverridden("eventDetailDialog");return se(mn,{store:h,generatorName:"eventDetailDialog",generatorArgs:x.dialogProps,defaultContent:a?null:n.createPortal(t.h(e,x.dialogProps),r)})})()]})})})};class Wn{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 Un=n.forwardRef(({x:e,y:t,onClose:a,children:o,className:l},i)=>{const s=r.useRef(null);r.useEffect(()=>{const e=()=>a(),t=e=>{if(s.current&&!s.current.contains(e.target)){if(e.target.closest("[data-submenu-content]"))return;a()}};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 n=e=>{"Escape"===e.key&&a()};window.addEventListener("keydown",n);const r=()=>a();return window.addEventListener("scroll",r,!0),window.addEventListener("resize",r),()=>{window.removeEventListener("dayflow-close-all-menus",e),document.body.removeEventListener("mousedown",t,{capture:!0}),document.body.removeEventListener("contextmenu",t,{capture:!0}),window.removeEventListener("keydown",n),window.removeEventListener("scroll",r,!0),window.removeEventListener("resize",r)}},[a]);const d={top:t,left:e};return n.createPortal(se("div",{ref:e=>{s.current=e,"function"==typeof i?i(e):i&&"current"in i&&(i.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 ${l||""}`,style:d,onContextMenu:e=>e.preventDefault(),"data-context-menu-root":"true",children:o}),document.body)});Un.displayName="ContextMenu";const Bn=({onClick:e,children:t,icon:n,danger:r,disabled:a})=>se("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&&se("span",{className:"mr-2 h-4 w-4",children:n}),t]}),Zn=()=>se("div",{className:"-mx-1 my-1 h-px bg-slate-200 dark:bg-slate-800"}),Gn=({children:e})=>{const[n,a]=r.useState(!1),o=r.useRef(null);return r.useEffect(()=>()=>{o.current&&clearTimeout(o.current)},[]),se("div",{className:"relative",onMouseEnter:()=>{o.current&&(clearTimeout(o.current),o.current=null),a(!0)},onMouseLeave:()=>{o.current=setTimeout(()=>{a(!1)},100)},children:(Array.isArray(e)?e:[e]).map(e=>t.isValidElement(e)?t.cloneElement(e,{isOpen:n}):e)})},Kn=({children:e,icon:t,isOpen:n})=>se("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&&se("span",{className:"mr-2 h-4 w-4",children:t}),se("span",{className:"grow text-left",children:e}),se($t,{className:"ml-auto h-4 w-4 "+(n?"text-white opacity-100":"opacity-60")})]}),qn=({children:e,isOpen:t})=>{const n=r.useRef(null),[a,o]=r.useState("right");return r.useEffect(()=>{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?o("left"):o("right"))}},[t]),t?se("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"===a?"100%":"auto",right:"left"===a?"100%":"auto",marginLeft:"right"===a?"0.25rem":0,marginRight:"left"===a?"0.25rem":0},"data-submenu-content":"true",children:e}):null},Xn=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],Jn=({x:t,y:n,date:r,onClose:o,app:l,onCreateEvent:i,viewType:s})=>{const{t:d}=nt(),c=je.hasEvent();return se(Un,{x:t,y:n,onClose:o,className:"df-context-menu",children:[se(Bn,{onClick:()=>{i(),o()},children:d("newEvent")||"New Event"}),se(Bn,{onClick:()=>a.__awaiter(void 0,void 0,void 0,function*(){yield((t,n,r)=>a.__awaiter(void 0,void 0,void 0,function*(){if(je.hasEvent())try{let a=je.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,l=ge(o.start),i=ge(o.end).getTime()-l.getTime(),s=a,d=new Date(n),c=r===exports.ViewType.MONTH||r===exports.ViewType.YEAR,u=0===d.getHours()&&0===d.getMinutes(),h=0!==l.getHours()||0!==l.getMinutes();!o.allDay&&(c||u&&h)&&d.setHours(l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds());const g=new Date(d.getTime()+(i>0?i:36e5)),m=Object.assign(Object.assign({},s),{title:o.title,id:ne(),start:o.allDay?me(d):fe(d,e.Temporal.Now.timeZoneId()),end:o.allDay?me(g):fe(g,e.Temporal.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)}}))(l,r,s),o()}),disabled:!c,children:d("pasteHere")||"Paste Here"})]})},Qn=({event:e,x:n,y:r,onClose:o,app:l})=>{var i;const{t:s}=nt(),d=l.getCalendars(),c=l.callbacks,u=null===(i=null==c?void 0:c.renderEventContextMenu)||void 0===i?void 0:i.call(c,e,o);return se(Un,{x:n,y:r,onClose:o,children:[se(Gn,{children:[se(Kn,{children:s("calendars")||"Calendars"}),se(qn,{children:d.map(t=>{const n=t.id===e.calendarId;return se(Bn,{onClick:()=>{return n=t.id,l.updateEvent(e.id,{calendarId:n}),void o();var n},children:se("div",{className:"flex w-full items-center",children:[se("div",{className:"w-4 shrink-0",children:n&&se(zt,{className:"h-3 w-3 text-primary"})}),se("div",{className:"flex min-w-0 items-center gap-1.5",children:[se("div",{className:"h-3 w-3 shrink-0 rounded-sm",style:{backgroundColor:t.colors.lineColor}}),se("span",{className:"truncate "+(n?"font-semibold":""),children:t.name})]})]})},t.id)})})]}),se(Zn,{}),se(Bn,{onClick:()=>{l.deleteEvent(e.id),o()},danger:!0,children:s("delete")||"Delete"}),se(Bn,{onClick:()=>a.__awaiter(void 0,void 0,void 0,function*(){try{const t=JSON.stringify(e,null,2);yield navigator.clipboard.writeText(t),je.setEvent(e),l.deleteEvent(e.id)}catch(e){console.error("Failed to cut event: ",e)}o()}),children:s("cut")||"Cut"}),se(Bn,{onClick:()=>a.__awaiter(void 0,void 0,void 0,function*(){try{const t=JSON.stringify(e,null,2);yield navigator.clipboard.writeText(t),je.setEvent(e)}catch(e){console.error("Failed to copy event: ",e)}o()}),children:s("copy")||"Copy"}),u&&se(t.Fragment,{children:[se(Zn,{}),u]})]})},er=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("假期")?se(Kt,{className:"h-3 w-3"}):t.includes("birthday")||t.includes("anniversary")||t.includes("生日")?se(qt,{className:"h-3 w-3"}):t.includes("conference")||t.includes("meeting")||t.includes("会议")||t.includes("研讨")?se(Jt,{className:"h-3 w-3"}):t.includes("trip")||t.includes("travel")||t.includes("旅行")?se(Xt,{className:"h-3 w-3"}):se(Bt,{className:"h-3 w-3"})},tr=(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=w(e.start),l=w(e.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(!e.allDay){if(!(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=k(i,d)>0;if(!c&&e.allDay){if(i<t||i>a)return;const o=Math.floor((i.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=i;let h;if(e.allDay)h=new Date(s),h.setHours(23,59,59,999);else{0!==l.getHours()||0!==l.getMinutes()||0!==l.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,p=Math.max(0,Math.floor((g.getTime()-t.getTime())/864e5)),f=Math.min(n-1,Math.floor((m.getTime()-t.getTime())/864e5)),v=u>=t,y=h<=a,b=0===p||f===n-1;let x;x=v&&y?"single":v?b&&f===n-1?"start-week-end":"start":y?b&&0===p?"end-week-start":"end":"middle";const D=k(u,h)+1;r.push({id:`${e.id}-week-${t.getTime()}`,originalEventId:e.id,event:e,startDayIndex:p,endDayIndex:f,segmentType:x,totalDays:D,segmentIndex:0,isFirstSegment:v,isLastSegment:y})}),r},nr=(e,t,n=7)=>{if(e.allDay)return[];const r=w(e.start),a=w(e.end),o=new Date(r);o.setHours(0,0,0,0);const l=new Date(a);l.setHours(0,0,0,0);const i=k(o,l);if(0===i)return[];const s=0!==a.getHours()||0!==a.getMinutes()||0!==a.getSeconds()||0!==a.getMilliseconds(),d=a.getTime()-r.getTime();if(!e.allDay&&1===i&&!s&&d<864e5)return[];const c=s?i:Math.max(0,i-1),u=[];for(let e=0;e<=c;e++){const l=new Date(o);l.setDate(o.getDate()+e);const i=Math.floor((l.getTime()-t.getTime())/864e5);if(i<0||i>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:i,startHour:g,endHour:m,isFirst:d,isLast:h})}return u},rr=n.memo(({segment:e,segmentIndex:n,isDragging:a,isResizing:o=!1,isSelected:l=!1,onMoveStart:i,onResizeStart:s,onEventLongPress:d,isMobile:c=!1,isDraggable:u=!0,isEditable:h=!0,viewable:g=!0,isPopping:m,renderSlot:p})=>{const[f,v]=r.useState(!1),y=17*n,b=`calc(${e.startDayIndex/7*100}% + 2px)`,x=`calc(${(e.endDayIndex-e.startDayIndex+1)/7*100}% - 4px)`,w=r.useRef(null),D=r.useRef(null),E=t=>{const n="left"===t;return(n?e.isFirstSegment:e.isLastSegment)&&s&&h?se("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(),s(t,e.event,n?"left":"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}):null},C=()=>{const t=e.event.allDay,n=e.event.calendarId||"blue",r=S(e.event.start),a=V(e.event),o=F(r),l=F(a);if(t){const t=()=>e.isFirstSegment?e.event.title:"middle"===e.segmentType||e.isLastSegment&&e.totalDays>1?"···":e.event.title;return se("div",{className:"pointer-events-auto flex w-full min-w-0 items-center",children:[e.isFirstSegment&&er(e.event)&&se("div",{className:"mr-1 shrink-0",children:se("div",{className:"flex items-center justify-center rounded-full p-0.5 text-white",style:{backgroundColor:Y(n),width:"12px",height:"12px"},children:er(e.event)})}),se("div",{className:"min-w-0 flex-1",children:se("div",{className:"truncate text-xs",children:t()})}),e.isLastSegment&&"single"!==e.segmentType&&se("div",{className:"ml-1 shrink-0 text-white/80 dark:text-white/90",children:se("div",{className:"h-1.5 w-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 se("div",{className:"pointer-events-auto relative flex w-full min-w-0 items-center",children:[se("div",{className:yt,style:{backgroundColor:Y(n)}}),se("div",{className:"flex min-w-0 flex-1 items-center",children:se("span",{className:`block overflow-hidden whitespace-nowrap ${c?"mobile-mask-fade":"truncate"} text-xs font-medium`,children:i})}),e.isFirstSegment&&!c&&se("span",{className:"text-xs font-medium whitespace-nowrap "+(1===s?"ml-2":""),style:d,children:o}),e.isLastSegment&&!e.event.allDay&&24!==a&&!c&&se("span",{className:"ml-auto text-xs font-medium whitespace-nowrap",children:`ends ${l}`})]})},T=e.event.calendarId||"blue",k=e.endDayIndex-e.startDayIndex+1;return se("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:x,top:`${y}px`,height:"16px",borderRadius:(M=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"}[M]),pointerEvents:"auto",zIndex:10,transform:m?"scale(1.02)":"scale(1)",transition:"transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)",willChange:"transform"},l||a||f?{backgroundColor:j(T),color:"#fff"}:{backgroundColor:L(T),color:$(T)}),{cursor:u||g?"pointer":"default"}),"data-segment-days":k,onMouseDown:t=>{if(!u&&!g)return;t.preventDefault(),t.stopPropagation(),v(!0);!t.target.closest(".resize-handle")&&u&&(null==i||i(t,e.event))},onMouseUp:()=>{v(!1)},onMouseLeave:()=>{v(!1)},onTouchStart:t=>{if(!i||!c||!u&&!g)return;t.stopPropagation(),v(!0);const n=t.touches[0],r=n.clientX,a=n.clientY,o=t.currentTarget;D.current={x:r,y:a},w.current=setTimeout(()=>{d&&d(e.event.id);u&&i({preventDefault:()=>{},stopPropagation:()=>{},currentTarget:o,touches:[{clientX:r,clientY:a}],cancelable:!1},e.event),w.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},onTouchMove:e=>{if(w.current&&D.current){const t=Math.abs(e.touches[0].clientX-D.current.x),n=Math.abs(e.touches[0].clientY-D.current.y);(t>10||n>10)&&(clearTimeout(w.current),w.current=null,D.current=null,v(!1))}},onTouchEnd:()=>{v(!1),w.current&&(clearTimeout(w.current),w.current=null),D.current=null},title:`${e.event.title} (${de(e.event.start)} - ${de(e.event.end)})`,children:[c&&l&&h&&se(t.Fragment,{children:[e.isFirstSegment&&se("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:Y(T)},onTouchStart:t=>{t.stopPropagation(),null==s||s(t,e.event,"left")}}),e.isLastSegment&&se("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:Y(T)},onTouchStart:t=>{t.stopPropagation(),null==s||s(t,e.event,"right")}})]}),E("left"),se("div",{className:"min-w-0 flex-1",style:{cursor:o?"ew-resize":"pointer"},children:p?p(C()):C()}),E("right")]});var M});rr.displayName="MultiDayEvent";const ar=({event:e,isEditable:t,onResizeStart:n,isMultiDay:r,segment:a,isSlidingView:o})=>{const l=!1!==e.icon,i="boolean"==typeof e.icon?null:e.icon;return se("div",{className:"absolute inset-0 flex items-center overflow-hidden pl-3 px-1 group 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&&se("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()}}),l&&(i?se("div",{className:"mr-1 shrink-0",children:i}):se(Bt,{className:bt})),se("div",{className:`${vt} pr-1`,style:{lineHeight:"1.2"},children:e.title}),n&&t&&se("div",{className:xt,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),n(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]})},or=({event:e,isEventSelected:t})=>{const n=!1!==e.icon,r="boolean"==typeof e.icon?null:e.icon;return se("div",{className:"text-xs px-1 rounded truncate cursor-pointer flex items-center",children:[n&&(r?se("div",{className:`${Ot} shrink-0`,children:r}):e.title.toLowerCase().includes("easter")||e.title.toLowerCase().includes("holiday")?se("span",{className:`inline-block ${Ot} shrink-0 ${t?"text-yellow-200":"text-yellow-600"}`,children:"⭐"}):se(Bt,{className:`${bt} ${t?"text-white":""}`})),se("span",{className:"truncate "+(t?"text-white":""),children:e.title})]})},lr=({event:e,app:t,isEventSelected:n,hideTime:r,isMobile:a})=>{const o=`${Math.floor(S(e.start)).toString().padStart(2,"0")}:${Math.round(S(e.start)%1*60).toString().padStart(2,"0")}`;return se("div",{className:"text-xs cursor-pointer flex items-center justify-between px-0.5",children:[se("div",{className:"flex min-w-0 flex-1 items-center",children:[se("div",{style:{backgroundColor:Y(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())},className:yt}),se("span",{className:`block overflow-hidden whitespace-nowrap ${a?"mobile-mask-fade":"truncate"} ${n?"text-white":""}`,children:e.title})]}),!r&&!a&&se("span",{className:`${Rt} ml-1 shrink-0 ${n?"text-white":""}`,style:n?void 0:{opacity:.8},children:o})]})},ir=({event:e,app:n,multiDaySegmentInfo:r,isEditable:a,isTouchEnabled:o,isEventSelected:l,onResizeStart:i,timeFormat:s="24h"})=>{const d=r?r.startHour:S(e.start),c=r?r.endHour:V(e),u=c-d,h=!r||r.isFirst,g=!r||r.isLast,m=e.calendarId||"blue";return se(t.Fragment,{children:[se("div",{className:"df-event-color-bar absolute left-1 top-1 bottom-1 w-[3px] rounded-full",style:{backgroundColor:Y(e.calendarId||"blue",null==n?void 0:n.getCalendarRegistry())}}),se("div",{className:"flex h-full flex-col overflow-hidden pl-3 "+(V(e)-S(e.start)<=.25?"px-1 py-0":"p-1"),children:[se("div",{className:`${vt} pr-1`,style:{lineHeight:u<=.25?"1.2":"normal"},children:e.title}),u>.5&&se("div",{className:"df-event-time text-xs opacity-80 truncate",children:r?`${F(d,0,s)} - ${F(c,0,s)}`:_(e,s)})]}),i&&a&&se(t.Fragment,{children:[h&&se("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")}),g&&se("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")}),!h&&g&&r&&se("div",{className:xt,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),i(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]}),o&&l&&i&&a&&se(t.Fragment,{children:[se("div",{className:"absolute -top-1.5 right-5 z-50 h-2.5 w-2.5 rounded-full border-2 bg-white",style:{borderColor:Y(m,null==n?void 0:n.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),i(t,e,"top")}}),se("div",{className:"absolute -bottom-1.5 left-5 z-50 h-2.5 w-2.5 rounded-full border-2 bg-white",style:{borderColor:Y(m,null==n?void 0:n.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),i(t,e,"bottom")}})]})]})},sr=({event:e,segment:n,isEditable:r,onMoveStart:a,onResizeStart:o,renderSlot:l})=>{const i=!!e.allDay,s=e.calendarId||"blue",d=Y(s),c=i?er(e):null,{isFirstSegment:u,isLastSegment:h}=n,g=t=>{const n="left"===t,a=n?u:h;return e.allDay&&a&&o&&r?se("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(),o(t,e,n?"left":"right")},onTouchStart:t=>{t.stopPropagation(),o(t,e,n?"left":"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}):null},m=()=>{if(i){const t=()=>n.isFirstSegment?e.title:"···";return se("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:[n.isFirstSegment&&er(e)&&se("div",{className:"df-year-event-icon mr-1 shrink-0",children:se("div",{className:"flex items-center justify-center rounded-full p-0.5 text-white",style:{backgroundColor:Y(s),width:"12px",height:"12px"},children:er(e)})}),se("div",{className:"min-w-0 flex-1",children:se("div",{className:"df-year-event-title overflow-hidden text-[12px] leading-[16px] whitespace-nowrap",style:{maskImage:"linear-gradient(to right, black 70%, transparent 100%)",WebkitMaskImage:"linear-gradient(to right, black 70%, transparent 100%)"},children:t()})}),n.isLastSegment&&!n.isFirstSegment&&se("div",{className:"ml-1 shrink-0 text-white/80 dark:text-white/90",children:se("div",{className:"h-1.5 w-1.5 rounded-full bg-white/60 dark:bg-white/80"})})]})}const t=n.isFirstSegment?e.title:"";return se("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&&se("span",{style:{backgroundColor:d},className:"df-year-event-indicator inline-block h-3 w-0.75 shrink-0 rounded-full"}),i&&c&&se("div",{className:"df-year-event-icon flex shrink-0 scale-75 items-center justify-center opacity-80",children:c}),se("span",{className:"df-year-event-title block w-full overflow-hidden text-[12px] leading-[16px] font-medium whitespace-nowrap",style:{maskImage:"linear-gradient(to right, black 70%, transparent 100%)",WebkitMaskImage:"linear-gradient(to right, black 70%, transparent 100%)"},children:t})]})};return se(t.Fragment,{children:[g("left"),l?l(m()):m(),g("right")]})};const dr=({event:e,viewType:t,isAllDay:n,isMultiDay:r,segment:a,yearSegment:o,segmentIndex:l,isBeingDragged:i,isBeingResized:s,isEventSelected:d,isPopping:c,isEditable:u,isDraggable:h,canOpenDetail:g,isTouchEnabled:m,hideTime:p,isMobile:f,isSlidingView:v,app:y,onMoveStart:b,onResizeStart:x,multiDaySegmentInfo:w,customRenderingStore:D,eventContentSlotArgs:E,timeFormat:C="24h"})=>{const T=t===exports.ViewType.MONTH,k=t===exports.ViewType.YEAR,S=function(e,t,n){const r=t.charAt(0).toUpperCase()+t.slice(1),a=n?`eventContentAllDay${r}`:`eventContent${r}`;return(null==e?void 0:e.isOverridden(a))?a:null}(D,t,n);if(T&&r&&a)return se(rr,{segment:a,segmentIndex:null!=l?l:0,isDragging:i||d,isResizing:s,isSelected:d,onMoveStart:b,onResizeStart:x,isMobile:f,isDraggable:h,isEditable:u,viewable:g,isPopping:c,renderSlot:e=>se(mn,{store:D,generatorName:S,generatorArgs:E,defaultContent:e})});if(k&&o)return se(sr,{event:e,segment:o,isEditable:u,onMoveStart:b,onResizeStart:x,renderSlot:e=>se(mn,{store:D,generatorName:S,generatorArgs:E,defaultContent:e})});let M;return M=T?e.allDay?se(or,{event:e,isEventSelected:d}):se(lr,{event:e,app:y,isEventSelected:d,hideTime:p,isMobile:f}):e.allDay?se(ar,{event:e,isEditable:u,onResizeStart:x,isMultiDay:r,segment:a,isSlidingView:v}):se(ir,{event:e,app:y,multiDaySegmentInfo:w,isEditable:u,isTouchEnabled:m,isEventSelected:d,onResizeStart:x,timeFormat:C}),se(mn,{store:D,generatorName:S,generatorArgs:E,defaultContent:M})},cr=({event:t,position:a,panelRef:o,isAllDay:l,eventVisibility:i,calendarRef:s,selectedEventElementRef:d,onEventUpdate:c,onEventDelete:u,app:h})=>{var g;const{effectiveTheme:m}=un(),p=Ne(m),{t:f}=nt(),[v,b]=r.useState(t.title),[x,w]=r.useState(null!==(g=t.description)&&void 0!==g?g:"");r.useEffect(()=>{b(t.title)},[t.title]),r.useEffect(()=>{var e;w(null!==(e=t.description)&&void 0!==e?e:"")},[t.description]),r.useEffect(()=>{const e=setTimeout(()=>{v!==t.title&&c(Object.assign(Object.assign({},t),{title:v}))},500);return()=>clearTimeout(e)},[v,t]),r.useEffect(()=>{const e=setTimeout(()=>{var e;const n=null!==(e=t.description)&&void 0!==e?e:"";x!==n&&c(Object.assign(Object.assign({},t),{description:x}))},500);return()=>clearTimeout(e)},[x,t]);const D=r.useMemo(()=>y(t.start)?t.end&&!y(t.end)&&t.end.timeZoneId||e.Temporal.Now.timeZoneId():t.start.timeZoneId||e.Temporal.Now.timeZoneId(),[t.end,t.start]),E=r.useMemo(()=>(h?h.getCalendarRegistry():O()).getVisible().map(e=>({label:e.name,value:e.id})),[h,null==h?void 0:h.getCalendars()]),C="dark"===p||"undefined"!=typeof document&&document.documentElement.classList.contains("dark"),T=!(null==h?void 0:h.state.readOnly);if(!(!1!==(null==h?void 0:h.getReadOnlyConfig().viewable)))return null;const k=C?"#1f2937":"white",S=C?"rgb(55, 65, 81)":"rgb(229, 231, 235)",M=(()=>{var e;let t={};if("sticky-top"===i){const n=null===(e=s.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(n){const e=n.getBoundingClientRect().top+3-a.top;t=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:k,transform:"rotate(45deg)",transformOrigin:"center",top:e-6+"px",borderRight:""+(a.isSunday?`1px solid ${S}`:"none"),borderTop:""+(a.isSunday?`1px solid ${S}`:"none"),borderLeft:""+(a.isSunday?"none":`1px solid ${S}`),borderBottom:""+(a.isSunday?"none":`1px solid ${S}`)},a.isSunday?{right:"-6px"}:{left:"-6px"})}}else if("sticky-bottom"===i){const e=o.current;let n=200;if(e){const t=e.getBoundingClientRect(),r=window.getComputedStyle(e),a=Number.parseInt(r.paddingBottom,10)||0,o=Number.parseInt(r.borderBottomWidth,10)||0;n=t.height-a-o-6+11}t={position:"absolute",width:"12px",height:"12px",backgroundColor:k,transform:"rotate(45deg)",transformOrigin:"center",top:`${n}px`,left:a.isSunday?void 0:"-6px",right:a.isSunday?"-6px":void 0,borderRight:""+(a.isSunday?`1px solid ${S}`:"none"),borderTop:""+(a.isSunday?`1px solid ${S}`:"none"),borderLeft:""+(a.isSunday?"none":`1px solid ${S}`),borderBottom:""+(a.isSunday?"none":`1px solid ${S}`)}}else if(a&&d.current&&s.current){const e=d.current.getBoundingClientRect(),n=s.current.querySelector(".calendar-content");if(n){const r=n.getBoundingClientRect(),l=Math.max(e.top,r.top),i=Math.min(e.bottom,r.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-a.top,u=o.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:k,transform:"rotate(45deg)",transformOrigin:"center",top:m-6+"px",borderRight:""+(a.isSunday?`1px solid ${S}`:"none"),borderTop:""+(a.isSunday?`1px solid ${S}`:"none"),borderLeft:""+(a.isSunday?"none":`1px solid ${S}`),borderBottom:""+(a.isSunday?"none":`1px solid ${S}`)},a.isSunday?{right:"-6px"}:{left:"-6px"})}}return t})(),N=se("div",{ref:o,className:`${Ct} p-4`,"data-event-detail-panel":"true","data-event-id":t.id,style:{top:`${a.top}px`,left:`${a.left}px`,zIndex:9999,pointerEvents:"auto"},children:[se("div",{style:M}),se("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:f("eventTitle")}),se("div",{className:"mb-3 flex items-center justify-between gap-3",children:[se("div",{className:"flex-1",children:se("input",{id:`event-title-${t.id}`,name:"title",type:"text",value:v,readOnly:!T,disabled:!T,onChange:e=>b(e.target.value),onInput:e=>b(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&&se(Sn,{options:E,value:t.calendarId||"blue",onChange:e=>{c(Object.assign(Object.assign({},t),{calendarId:e}))},registry:null==h?void 0:h.getCalendarRegistry()})]}),se("div",l?{className:"mb-3",children:[se("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:f("dateRange")}),se(kn,{value:[t.start,t.end],format:"YYYY-MM-DD",showTime:!1,timeZone:D,matchTriggerWidth:!0,disabled:!T,onChange:e=>{const[n,r]=e;c(Object.assign(Object.assign({},t),{start:n.toPlainDate(),end:r.toPlainDate()}))},locale:null==h?void 0:h.state.locale})]}:{className:"mb-3",children:[se("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:f("timeRange")}),se(kn,{value:[t.start,t.end],timeZone:D,disabled:!T,onChange:e=>{const[n,r]=e;c(Object.assign(Object.assign({},t),{start:n,end:r}))},locale:null==h?void 0:h.state.locale})]}),se("div",{className:"mb-3",children:[se("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:f("note")}),se("textarea",{id:`event-note-${t.id}`,name:"note",value:x,readOnly:!T,disabled:!T,onChange:e=>w(e.target.value),onInput:e=>w(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:f("addNotePlaceholder")})]}),T&&se("div",{className:"flex space-x-2",children:[se("button",l?{type:"button",className:"rounded bg-primary px-2 py-1 text-xs font-medium text-primary-foreground transition hover:bg-primary",onClick:()=>{const n=y(t.start)?t.start:t.start.toPlainDate(),r=e.Temporal.ZonedDateTime.from({year:n.year,month:n.month,day:n.day,hour:9,minute:0,timeZone:e.Temporal.Now.timeZoneId()}),a=e.Temporal.ZonedDateTime.from({year:n.year,month:n.month,day:n.day,hour:10,minute:0,timeZone:e.Temporal.Now.timeZoneId()});c(Object.assign(Object.assign({},t),{allDay:!1,start:r,end:a}))},children:f("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=y(t.start)?t.start:t.start.toPlainDate();c(Object.assign(Object.assign({},t),{allDay:!0,start:e,end:e}))},children:f("setAsAllDay")}),se("button",{type:"button",className:"rounded bg-destructive px-2 py-1 text-xs font-medium text-destructive-foreground transition hover:bg-destructive/90",onClick:()=>u(t.id),children:f("delete")})]})]});if("undefined"==typeof window||"undefined"==typeof document)return null;const I=document.body;return I?n.createPortal(N,I):null},ur=({event:e,position:t,panelRef:r,isAllDay:a,eventVisibility:o,calendarRef:l,selectedEventElementRef:i,onEventUpdate:s,onEventDelete:d,onClose:c,contentRenderer:u})=>{const{effectiveTheme:h}=un(),g=Ne(h),m="dark"===g?"#1f2937":"white",p="dark"===g?"rgb(55, 65, 81)":"rgb(229, 231, 235)",f=(()=>{var e;let n={};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-t.top;n=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:m,transform:"rotate(45deg)",transformOrigin:"center",top:e-6+"px",borderRight:""+(t.isSunday?`1px solid ${p}`:"none"),borderTop:""+(t.isSunday?`1px solid ${p}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${p}`),borderBottom:""+(t.isSunday?"none":`1px solid ${p}`)},t.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}n={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 ${p}`:"none"),borderTop:""+(t.isSunday?`1px solid ${p}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${p}`),borderBottom:""+(t.isSunday?"none":`1px solid ${p}`)}}else if(t&&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-t.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,f=Math.max(g,Math.min(h,c));n=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:m,transform:"rotate(45deg)",transformOrigin:"center",top:f-6+"px",borderRight:""+(t.isSunday?`1px solid ${p}`:"none"),borderTop:""+(t.isSunday?`1px solid ${p}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${p}`),borderBottom:""+(t.isSunday?"none":`1px solid ${p}`)},t.isSunday?{right:"-6px"}:{left:"-6px"})}}return n})(),v=se("div",{ref:r,className:`${Ct} 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:[se("div",{style:f}),se(u,{event:e,isAllDay:a,onEventUpdate:s,onEventDelete:d,onClose:c})]});return n.createPortal(v,document.body)},hr=({showDetailPanel:e,customEventDetailDialog:t,detailPanelPosition:n,event:r,detailPanelRef:a,isAllDay:o,eventVisibility:l,calendarRef:i,selectedEventElementRef:s,onEventUpdate:d,onEventDelete:c,handlePanelClose:u,customRenderingStore:h,contentSlotRenderer:g,customDetailPanelContent:m,app:p})=>{if(!e)return null;if(t)return null;if(!n)return null;const f={event:r,position:n,panelRef:a,isAllDay:o,eventVisibility:l,calendarRef:i,selectedEventElementRef:s,onEventUpdate:d,onEventDelete:c,onClose:u};return(null==h?void 0:h.isOverridden("eventDetailContent"))?se(ur,Object.assign({},f,{contentRenderer:g})):m?se(ur,Object.assign({},f,{contentRenderer:m})):se(cr,Object.assign({},f,{app:p}))},gr=(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},mr=(e,t,n,r,a)=>{let o="df-event calendar-event select-none pointer-events-auto";const l=e===exports.ViewType.DAY,i=e===exports.ViewType.MONTH,s=e===exports.ViewType.YEAR;l?o+=" df-day-event flex flex-col":i||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 pt;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 pt};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(i){let e=`\n ${o}\n ${t?d():ft}\n `;return n||(e+=" mb-[2px]"),e}return`\n ${o}\n shadow-sm\n ${t?d():ft}\n `},pr=({event:e,layout:n,isAllDay:a=!1,allDayHeight:o=28,calendarRef:l,isBeingDragged:i=!1,isBeingResized:s=!1,viewType:d,isMultiDay:c=!1,segment:u,yearSegment:h,columnsPerRow:g,segmentIndex:m=0,hourHeight:p,firstHour:f,selectedEventId:v,detailPanelEventId:y,onMoveStart:b,onResizeStart:x,onEventUpdate:w,onEventDelete:D,newlyCreatedEventId:E,onDetailPanelOpen:C,onEventSelect:T,onEventLongPress:k,onDetailPanelToggle:M,customDetailPanelContent:N,customEventDetailDialog:I,multiDaySegmentInfo:R,app:H,isMobile:A=!1,isSlidingView:O=!1,enableTouch:P,hideTime:Y,timeFormat:F="24h"})=>{const _=r.useContext(hn),z=null!=P?P:A,W=d===exports.ViewType.YEAR,[U,B]=r.useState(null),[Z,G]=r.useState(!1),K=r.useRef(null),q=r.useRef(null),X=r.useRef(null),J=r.useRef(null),Q=c&&u?`${e.id}::${u.id}`:void 0===(null==R?void 0:R.dayIndex)?W&&h?h.id:e.id:`${e.id}::day-${R.dayIndex}`,ee=y===Q,te=ee&&!I,ne=null==H?void 0:H.getReadOnlyConfig(),re=!(null==H?void 0:H.state.readOnly),ae=!1!==(null==ne?void 0:ne.viewable),oe=!1!==(null==ne?void 0:ne.draggable),{isSelected:le,setIsSelected:ie,isPressed:de,setIsPressed:ce,handleTouchStart:ue,handleTouchMove:he,handleTouchEnd:ge}=(({event:e,isTouchEnabled:t,onMoveStart:n,onEventLongPress:a,onDetailPanelToggle:o,canOpenDetail:l,app:i,multiDaySegmentInfo:s,isMultiDay:d,segment:c,detailPanelKey:u})=>{const[h,g]=r.useState(!1),[m,p]=r.useState(!1),f=r.useRef(null),v=r.useRef(null);return{isSelected:h,setIsSelected:g,isPressed:m,setIsPressed:p,handleTouchStart:r=>{if(!n||!t)return;p(!0);const o=r.touches[0],l=o.clientX,i=o.clientY,u=r.currentTarget;v.current={x:l,y:i},f.current=setTimeout(()=>{var t;a?a(e.id):g(!0);const r={preventDefault:()=>{},stopPropagation:()=>{},currentTarget:u,touches:[{clientX:l,clientY:i}],cancelable:!1};if(s){const a=Object.assign(Object.assign({},e),{day:null!==(t=s.dayIndex)&&void 0!==t?t:e.day,_segmentInfo:s});n(r,a)}else if(d&&c){const t=Object.assign(Object.assign({},e),{day:c.startDayIndex,_segmentInfo:{dayIndex:c.startDayIndex,isFirst:c.isFirstSegment,isLast:c.isLastSegment}});n(r,t)}else n(r,e);f.current=null,v.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},handleTouchMove:e=>{if(f.current&&v.current){const t=Math.abs(e.touches[0].clientX-v.current.x),n=Math.abs(e.touches[0].clientY-v.current.y);(t>10||n>10)&&(clearTimeout(f.current),f.current=null,v.current=null,p(!1))}},handleTouchEnd:n=>{p(!1),f.current&&(clearTimeout(f.current),f.current=null),t&&v.current&&(n.preventDefault(),n.stopPropagation(),i&&i.onEventClick(e),l?null==o||o(u):null==o||o(null)),v.current=null}}})({event:e,isTouchEnabled:z,onMoveStart:b,onEventLongPress:k,onDetailPanelToggle:M,canOpenDetail:ae,app:H,multiDaySegmentInfo:R,isMultiDay:c,segment:u,detailPanelKey:Q}),me=(void 0===v?le:v===e.id)||!z&&de||i,[pe,fe]=r.useState("visible"),ve=e=>{J.current=e},ye=r.useCallback(()=>((e,t,n,r,a,o)=>{var l;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!==(l=e.day)&&void 0!==l?l:0})(e,y||void 0,Q,J.current,R,u),[e,y,Q,R,u]),be=r.useCallback(e=>((e,t,n,r)=>{if(!t.current)return null;const a=t.current.getBoundingClientRect();if(n===exports.ViewType.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=gr(t,r),l=n===exports.ViewType.DAY?1:7,i=(a.width-o)/l,s=e-a.left-o,d=Math.floor(s/i);return Number.isFinite(d)?Math.max(0,Math.min(l-1,d)):null})(e,l,d,A),[l,d,A]),xe=r.useCallback(e=>((e,t,n,r)=>{if(!t.current)return null;const a=t.current.getBoundingClientRect();if(n===exports.ViewType.MONTH){const t=a.width/7;return{left:a.left+e*t,width:t}}const o=gr(t,r);if(n===exports.ViewType.DAY){const e=a.width-o;return{left:a.left+o,width:e}}const l=(a.width-o)/7;return{left:a.left+o+e*l,width:l}})(e,l,d,A),[l,d,A]),{detailPanelPosition:we,setDetailPanelPosition:De,updatePanelPosition:Ee}=(({event:e,viewType:t,isMultiDay:n,segment:a,yearSegment:o,multiDaySegmentInfo:l,calendarRef:i,eventRef:s,detailPanelRef:d,selectedEventElementRef:c,isMobile:u,eventVisibility:h,firstHour:g,hourHeight:m,columnsPerRow:p,showDetailPanel:f,detailPanelEventId:v,detailPanelKey:y,getActiveDayIdx:b,getDayMetricsWrapper:x})=>{const[w,D]=r.useState(null),E=t===exports.ViewType.DAY,C=t===exports.ViewType.MONTH,T=t===exports.ViewType.YEAR,k=r.useCallback(()=>{if(!c.current||!i.current||!d.current)return;const e=i.current.getBoundingClientRect(),t=b(),r=x(t);let o,l;if(r)o=r.left,l=r.width;else if(C)l=e.width/7,o=e.left+t*l;else{const n=gr(i,u);l=(e.width-n)/7,o=e.left+n+t*l}const g=Math.min(window.innerWidth,e.right),m=Math.min(window.innerHeight,e.bottom);requestAnimationFrame(()=>{var r,l,i;if(!d.current)return;if(!c.current)return;const u=d.current.getBoundingClientRect(),p=u.width,f=u.height;let v,y,b;if("sticky-top"===h||"sticky-bottom"===h){const e=null===(r=s.current)||void 0===r?void 0:r.getBoundingClientRect();if(!e)return;b=e}else b=c.current.getBoundingClientRect();if(C&&n&&a){const n=x(t),r=null!==(l=null==n?void 0:n.width)&&void 0!==l?l:e.width/7,a=null!==(i=null==n?void 0:n.left)&&void 0!==i?i: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=g-b.right,E=b.left-e.left;v=w>=p+20?b.right+10:E>=p+20?b.left-p-10:w>E?Math.max(e.left+10,g-p-10):e.left+10;const k=b.top-f/2+b.height/2,S=Math.max(10,e.top+10),M=m-10;y=k<S?S:k+f>M?M-f:k,D(e=>{if(!e)return null;let t=v<o;return T&&(t=v<b.left),Object.assign(Object.assign({},e),{top:y,left:v,isSunday:t})})})},[i,e.day,e.start,e.end,h,C,g,m,n,a,l,v,y,u,E,T,o,p,b,x,c,d,s]);return r.useEffect(()=>{!f||w||u||(D({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>k()))},[f,w,k,u]),{detailPanelPosition:w,setDetailPanelPosition:D,updatePanelPosition:k}})({event:e,viewType:d,isMultiDay:c,segment:u,yearSegment:h,multiDaySegmentInfo:R,calendarRef:l,eventRef:K,detailPanelRef:q,selectedEventElementRef:X,isMobile:A,eventVisibility:pe,firstHour:f,hourHeight:p,columnsPerRow:g,showDetailPanel:ee,detailPanelEventId:y,detailPanelKey:Q,getActiveDayIdx:ye,getDayMetricsWrapper:xe}),{handleClick:Ce,handleDoubleClick:Te,handleContextMenu:ke}=(({event:e,viewType:t,isAllDay:n,isMultiDay:a,segment:o,multiDaySegmentInfo:l,calendarRef:i,firstHour:s,hourHeight:d,isMobile:c,canOpenDetail:u,detailPanelKey:h,app:g,onEventSelect:m,onDetailPanelToggle:p,setIsSelected:f,setDetailPanelPosition:v,setContextMenuPosition:y,setActiveDayIndex:b,getClickedDayIdx:x,updatePanelPosition:w,selectedEventElementRef:D})=>{const E=t===exports.ViewType.MONTH,C=t===exports.ViewType.YEAR,T=r.useCallback(()=>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=l?l.startHour:S(e.start),o=l?l.endHour:V(e),c=(a-s)*d,u=c+Math.max((o-a)*d,d/4),h=r.scrollTop,g=r.clientHeight;if(c>=h&&u<=h+g)return void t();const m=((a+o)/2-s)*d-g/2,p=r.scrollHeight-g;r.scrollTo({top:Math.max(0,Math.min(p,m)),behavior:"smooth"}),setTimeout(()=>t(),300)}),[i,n,E,C,l,e.start,e.end,s,d]),k=r.useCallback(t=>{t.preventDefault(),t.stopPropagation(),m&&m(e.id),y({x:t.clientX,y:t.clientY})},[e.id,m,y]),M=r.useCallback(t=>{var n,r,l,i,s;if(t.preventDefault(),t.stopPropagation(),!u)return;let d=t.currentTarget;if(a){const e=d.querySelector("div");e&&(d=e)}if(D.current=d,a){const a=x(t.clientX);b(null===a?null!==(r=null!==(n=null==o?void 0:o.startDayIndex)&&void 0!==n?n:e.day)&&void 0!==r?r:0:Math.min(Math.max(a,null!==(l=null==o?void 0:o.startDayIndex)&&void 0!==l?l:0),null!==(i=null==o?void 0:o.endDayIndex)&&void 0!==i?i:6))}else b(null!==(s=e.day)&&void 0!==s?s:null);T().then(()=>{f(!0),c||(null==p||p(h),v({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>w()))})},[u,a,D,x,b,null==o?void 0:o.startDayIndex,null==o?void 0:o.endDayIndex,e.day,T,f,c,p,h,v,w]);return{handleClick:r.useCallback(t=>{var n,r,i;if(t.preventDefault(),t.stopPropagation(),a){const a=x(t.clientX);b(null===a?null!==(r=null!==(n=null==l?void 0:l.dayIndex)&&void 0!==n?n:e.day)&&void 0!==r?r:null:o?Math.min(Math.max(a,o.startDayIndex),o.endDayIndex):a)}else b(null!==(i=e.day)&&void 0!==i?i:null);g&&g.onEventClick(e),m?m(e.id):u&&f(!0),null==p||p(null),v(null)},[a,x,b,o,null==l?void 0:l.dayIndex,e,g,m,u,f,p,v]),handleDoubleClick:M,handleContextMenu:k,scrollEventToCenter:T}})({event:e,viewType:d,isAllDay:a,isMultiDay:c,segment:u,multiDaySegmentInfo:R,calendarRef:l,firstHour:f,hourHeight:p,isMobile:A,canOpenDetail:ae,detailPanelKey:Q,app:H,onEventSelect:T,onDetailPanelToggle:M,setIsSelected:ie,setDetailPanelPosition:De,setContextMenuPosition:B,setActiveDayIndex:ve,getClickedDayIdx:be,updatePanelPosition:Ee,selectedEventElementRef:X}),{calculateEventStyle:Se}=(({event:e,layout:t,isAllDay:n,allDayHeight:r,viewType:a,isMultiDay:o,segment:l,yearSegment:i,columnsPerRow:s,segmentIndex:d,hourHeight:c,firstHour:u,isEventSelected:h,showDetailPanel:g,isPopping:m,isDraggable:p,canOpenDetail:f,eventVisibility:v,calendarRef:y,isMobile:b,eventRef:x,getActiveDayIdx:w,getDayMetricsWrapper:D,multiDaySegmentInfo:E})=>{const C=a===exports.ViewType.DAY,T=a===exports.ViewType.MONTH,k=a===exports.ViewType.YEAR;return{calculateEventStyle:()=>{var a,M,N,I,R,H,A,O;if(k&&i&&s){const{startCellIndex:e,endCellIndex:t,visualRowIndex:n}=i,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:p||f?"pointer":"default"}}if(T)return o&&l?{opacity:1,zIndex:h||g?1e3:1,cursor:p||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:p||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:p||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&&l){const t=s||7,n=(l.endDayIndex-l.startDayIndex+1)/t*100,r=l.startDayIndex/t*100,a=2,o=l.isFirstSegment?a:0,i=o+(l.isLastSegment?a:0);Object.assign(e,{width:i>0?`calc(${n}% - ${i}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 P=E?E.startHour:S(e.start),L=E?E.endHour:V(e),$={top:(P-u)*c+3+"px",height:Math.max((L-P)*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:p||f?"pointer":"default"};if(h&&g&&("sticky-top"===v||"sticky-bottom"===v)){const e=null===(M=y.current)||void 0===M?void 0:M.getBoundingClientRect();if(e){const n=w(),r=gr(y,b),a=C?1:s||7;let o=(e.width-r)/a,l=e.left+r+(C?0:n*o);T&&(o=e.width/7,l=e.left+n*o);const i=D(n);i&&(l=i.left,o=i.width);let d=null===(N=y.current)||void 0===N?void 0:N.querySelector(".calendar-content");d||(d=null===(I=y.current)||void 0===I?void 0:I.querySelector(".calendar-renderer"));const c=null==d?void 0:d.getBoundingClientRect(),u=null===(H=null===(R=x.current)||void 0===R?void 0:R.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=D(n),r=null!==(A=null==e?void 0:e.left)&&void 0!==A?A:l,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"===v){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({},$),{left:`${t.left}%`,width:e,right:"auto"})}return Object.assign(Object.assign({},$),{left:"0px",right:C?"0px":"3px"})}}})({event:e,layout:n,isAllDay:a,allDayHeight:o,viewType:d,isMultiDay:c,segment:u,yearSegment:h,columnsPerRow:g,segmentIndex:m,hourHeight:p,firstHour:f,isEventSelected:me,showDetailPanel:ee,isPopping:Z,isDraggable:oe,canOpenDetail:ae,eventVisibility:pe,calendarRef:l,isMobile:A,eventRef:K,getActiveDayIdx:ye,getDayMetricsWrapper:xe,multiDaySegmentInfo:R});(({event:e,isEventSelected:t,showDetailPanel:n,eventRef:a,calendarRef:o,isAllDay:l,viewType:i,multiDaySegmentInfo:s,firstHour:d,hourHeight:c,updatePanelPosition:u,eventVisibility:h,setEventVisibility:g})=>{const m=i===exports.ViewType.MONTH,p=i===exports.ViewType.YEAR,f=r.useCallback(()=>{if(!t||!n||!a.current||!o.current||l||m||p)return;const r=o.current.querySelector(".calendar-content");if(!r)return;const i=s?s.startHour:S(e.start),f=s?s.endHour:V(e),v=(i-d)*c,y=v+Math.max((f-i)*c,c/4),b=r.getBoundingClientRect(),x=r.scrollTop,w=x+b.height,D=b.bottom<0,E=b.top>window.innerHeight;let C=h;D?C="sticky-top":E?C="sticky-bottom":"visible"===h?y<x?C="sticky-top":v>w-20&&(C="sticky-bottom"):"sticky-top"===h?y>=x&&(C="visible"):"sticky-bottom"===h&&v<=w-20&&(C="visible"),C!==h&&g(C),u()},[t,n,o,l,m,e.start,e.end,d,c,u,s,h,g]);r.useEffect(()=>{var e,r;if(!t||!n||l)return;const a=null===(e=o.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(!a)return;const i=()=>f(),s=()=>{f(),u()},d=[a];let c=null===(r=o.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 o.current&&(h=new ResizeObserver(()=>{s()}),h.observe(o.current)),f(),()=>{d.forEach(e=>{e.removeEventListener("scroll",i)}),window.removeEventListener("scroll",i,!0),window.removeEventListener("resize",s),h&&h.disconnect()}},[t,n,l,f,u,o])})({event:e,isEventSelected:me,showDetailPanel:ee,eventRef:K,calendarRef:l,isAllDay:a,viewType:d,multiDaySegmentInfo:R,firstHour:f,hourHeight:p,updatePanelPosition:Ee,eventVisibility:pe,setEventVisibility:fe});const Me=ee&&!!I;(({eventRef:e,detailPanelRef:t,eventId:n,isEventSelected:a,showDetailPanel:o,onEventSelect:l,onDetailPanelToggle:i,setIsSelected:s,setActiveDayIndex:d})=>{r.useEffect(()=>{if(!a&&!o)return;const r=r=>{var c,u;const h=r.target,g=null===(c=e.current)||void 0===c?void 0:c.contains(h),m=null!==h.closest(`[data-event-id="${n}"]`),p=null===(u=t.current)||void 0===u?void 0:u.contains(h),f=h.closest("[data-event-detail-dialog]"),v=h.closest("[data-range-picker-popup]"),y=h.closest("[data-calendar-picker-dropdown]");o?g||m||p||f||v||y||(null==l||l(null),d(null),s(!1),null==i||i(null)):!a||g||m||f||v||y||(null==l||l(null),d(null),s(!1),null==i||i(null))};return document.addEventListener("mousedown",r),()=>{document.removeEventListener("mousedown",r)}},[a,o,l,i,n])})({eventRef:K,detailPanelRef:q,eventId:e.id,isEventSelected:!Me&&me,showDetailPanel:te,onEventSelect:T,onDetailPanelToggle:M,setIsSelected:ie,setActiveDayIndex:ve});const Ne=r.useCallback(()=>{T&&T(null),J.current=null,ie(!1),null==M||M(null)},[T,M,ie]),Ie=r.useMemo(()=>({event:e,isAllDay:a,onEventUpdate:w,onEventDelete:D,onClose:Ne}),[e,a,w,D,Ne]),Re=r.useMemo(()=>({event:e,viewType:d,isAllDay:a,isMobile:A,isSelected:me,isDragging:i,segment:u,layout:n}),[e,d,a,A,me,i,u,n]),He=r.useCallback(()=>se(mn,{store:_,generatorName:"eventDetailContent",generatorArgs:Ie}),[_,Ie]);r.useEffect(()=>{if((null==H?void 0:H.state.highlightedEventId)===e.id){G(!0);const e=setTimeout(()=>{G(!1)},300);return()=>{clearTimeout(e),G(!1)}}},[null==H?void 0:H.state.highlightedEventId,e.id]),r.useEffect(()=>{const t=c&&(null==u?void 0:u.isFirstSegment)||W&&(null==h?void 0:h.isFirstSegment)||!c&&!W;E===e.id&&!ee&&t&&setTimeout(()=>{null==M||M(Q),null==C||C()},50)},[E,e.id,ee,c,u,W,h,M,C,Q]);const Ae=e.calendarId||"blue",Oe=null==H?void 0:H.getCalendarRegistry();return se(t.Fragment,{children:[se("div",{ref:K,"data-event-id":e.id,className:`${mr(d,a,c,u,h)} ${a&&E===e.id?"df-all-day-event-animate":""}`,style:Object.assign(Object.assign({},Se()),{backgroundColor:me?j(Ae,Oe):L(Ae,Oe),color:me?"#fff":$(Ae,Oe)}),onClick:Ce,onContextMenu:ke,onDblClick:Te,onMouseDown:t=>{var n;if(z||ce(!0),b){const r=t;b(r,R?Object.assign(Object.assign({},e),{day:null!==(n=R.dayIndex)&&void 0!==n?n:e.day,_segmentInfo:R}):c&&u?Object.assign(Object.assign({},e),{day:u.startDayIndex,_segmentInfo:{dayIndex:u.startDayIndex,isFirst:u.isFirstSegment,isLast:u.isLastSegment}}):e)}},onMouseUp:()=>!z&&ce(!1),onMouseLeave:()=>!z&&ce(!1),onTouchStart:ue,onTouchMove:he,onTouchEnd:ge,children:se(dr,{event:e,viewType:d,isAllDay:a,isMultiDay:c,segment:u,yearSegment:h,segmentIndex:m,isBeingDragged:i,isBeingResized:s,isEventSelected:me,isPopping:Z,isEditable:re,isDraggable:oe,canOpenDetail:ae,isTouchEnabled:z,hideTime:Y,isMobile:A,isSlidingView:O,app:H,onMoveStart:b,onResizeStart:x,multiDaySegmentInfo:R,customRenderingStore:_,eventContentSlotArgs:Re,layout:n,timeFormat:F})}),ee&&!I&&se("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:9998,pointerEvents:"none"}}),se(hr,{showDetailPanel:ee,customEventDetailDialog:I,detailPanelPosition:we,event:e,detailPanelRef:q,isAllDay:a,eventVisibility:pe,calendarRef:l,selectedEventElementRef:X,onEventUpdate:w,onEventDelete:D,handlePanelClose:Ne,customRenderingStore:_,contentSlotRenderer:He,customDetailPanelContent:N,app:H}),U&&H&&se(Qn,{event:e,x:U.x,y:U.y,onClose:()=>B(null),app:H,onDetailPanelToggle:M,detailPanelKey:Q})]})},fr=({handlePreviousMonth:e,handleToday:t,handleNextMonth:n})=>{const{t:r}=nt();return se("div",{className:"df-navigation flex items-center gap-1",children:[se("button",{type:"button",className:Dt,onClick:e,"aria-label":"Previous month",children:se(Lt,{className:Et})}),se("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")}),se("button",{type:"button",className:Dt,onClick:n,"aria-label":"Next month",children:se($t,{className:Et})})]})},vr=({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}=nt(),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""}})(),p="day"===e?l||("day"===e?t.toLocaleDateString(h,{weekday:"long"}):null):null;return se("div",{className:at,style:{position:"relative"},onContextMenu:e=>e.preventDefault(),children:[se("div",{className:"flex-1",children:se("div","year"===e&&s?{style:{position:"relative",overflow:"hidden",height:"1.5em"},children:[se("h1",{className:ot,style:{position:"absolute",top:0,left:0,transform:`translateY(-${d}px)`,willChange:"transform"},children:s}),c&&se("h1",{className:ot,style:{position:"absolute",top:0,left:0,transform:`translateY(${u}px)`,willChange:"transform"},children:c})]}:{children:[se("div",{className:`${ot} text-gray-900 dark:text-white`,children:m}),p&&se("div",{className:"mt-3 text-gray-600 dark:text-gray-400",children:p})]})}),g&&n&&r&&a&&se("div",{className:"flex items-center gap-2",children:se(fr,{handlePreviousMonth:n,handleNextMonth:r,handleToday:a})})]})},yr=({app:e,currentDate:t,currentWeekStart:n,events:a,currentDayEvents:o,organizedAllDayEvents:l,allDayAreaHeight:i,timeSlots:s,eventLayouts:d,isToday:c,currentTime:u,selectedEventId:h,setSelectedEventId:g,newlyCreatedEventId:m,setNewlyCreatedEventId:p,detailPanelEventId:f,setDetailPanelEventId:v,dragState:y,isDragging:b,handleMoveStart:x,handleResizeStart:w,handleCreateStart:D,handleCreateAllDayEvent:E,handleTouchStart:C,handleTouchEnd:T,handleTouchMove:k,handleDragOver:S,handleDrop:M,handleEventUpdate:N,handleEventDelete:I,onDateChange:R,customDetailPanelContent:H,customEventDetailDialog:A,calendarRef:O,allDayRowRef:P,timeGridRef:L,switcherMode:$,isMobile:j,isTouch:Y,setDraftEvent:V,setIsDrawerOpen:_,ALL_DAY_HEIGHT:z,HOUR_HEIGHT:W,FIRST_HOUR:U,LAST_HOUR:B,showAllDay:Z,showStartOfDayLabel:G,timeFormat:K="24h",secondaryTimeSlots:q,primaryTzLabel:X,secondaryTzLabel:J})=>{var Q;const ee=!!q&&q.length>0&&!j,{t:te,locale:ne}=nt(),re=r.useRef(e.state.highlightedEventId),[ae,oe]=r.useState(null),le=r.useMemo(()=>Me(),[]),ie=()=>{var e;const t=null===(e=O.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},de=(e,n)=>{var r,a,o,l;if(e.preventDefault(),j)return;const i=new Date(t);if(n)i.setHours(0,0,0,0);else{const t=null===(a=null===(r=O.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=O.current)||void 0===o?void 0:o.querySelector(".calendar-content"))||void 0===l?void 0:l.scrollTop)||0,r=ie(),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)}}oe({x:e.clientX,y:e.clientY,date:i})};return se("div",{className:`flex-none ${"buttons"===$?"":"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:[se("div",{className:`relative ${At} h-full`,children:[se("div",{onContextMenu:e=>e.preventDefault(),style:{paddingRight:j||!le?"0px":"15px"},children:se(vr,{calendar:e,viewType:exports.ViewType.DAY,currentDate:t,customSubtitle:t.toLocaleDateString(ne,{weekday:"long"})})}),se("div",Z?{className:Pt(mt,"items-stretch border-t border-gray-200 dark:border-gray-700"),ref:P,style:{paddingRight:j||!le?"0px":"0.6875rem"},onContextMenu:e=>de(e,!0),children:[se("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:te("allDay")}),se("div",{className:Pt("relative flex flex-1 self-stretch",!j&&le?"border-r border-gray-200 dark:border-gray-700":""),children:se("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==E||E(e,r)},onDblClick:e=>{const r=Math.floor((t.getTime()-n.getTime())/864e5);null==E||E(e,r)},onDragOver:S,onDrop:e=>{M(e,t,void 0,!0)},children:l.map(t=>se(pr,{event:t,isAllDay:!0,viewType:exports.ViewType.DAY,segmentIndex:t.row,allDayHeight:z,calendarRef:O,isBeingDragged:b&&(null==y?void 0:y.eventId)===t.id&&"move"===(null==y?void 0:y.mode),hourHeight:W,firstHour:U,onMoveStart:x,onEventUpdate:N,onEventDelete:I,newlyCreatedEventId:m,onDetailPanelOpen:()=>p(null),detailPanelEventId:f,onDetailPanelToggle:e=>v(e),selectedEventId:h,onEventSelect:t=>{const n=e.getReadOnlyConfig().viewable,r=e.state.readOnly,o=a.find(e=>e.id===t);(j||Y)&&o&&n&&!r?(V(o),_(!0)):(g(t),e.state.highlightedEventId&&(e.highlightEvent(null),re.current=null))},onEventLongPress:e=>{(j||Y)&&g(e)},customDetailPanelContent:H,customEventDetailDialog:A,app:e,isMobile:j,enableTouch:Y},t.id))})})]}:{className:Pt("border-b border-gray-200 dark:border-gray-700",!j&&le?"pr-2.75":"")}),se("div",{className:"relative overflow-y-auto calendar-content df-day-time-grid",style:{position:"relative",scrollbarGutter:"stable"},children:se("div",{className:"relative flex",children:[c&&u&&(()=>{const e=u,t=e.getHours()+e.getMinutes()/60;if(t<U||t>B)return null;return se("div",{className:ht,style:{top:`${(t-U)*W}px`,width:"100%",height:0,zIndex:20,marginTop:ee?"2rem":"0.75rem"},children:[se("div",{className:"flex w-12 items-center md:w-20",children:[se("div",{className:"relative flex w-full items-center"}),se("div",{className:gt,children:F(t,0,K,!1)})]}),se("div",{className:"flex flex-1 items-center",children:se("div",{className:"df-current-time-bar h-0.5 w-full bg-primary relative"})})]})})(),se("div",{className:"df-time-column flex-shrink-0 border-gray-200 dark:border-gray-700 "+(ee?"w-20 md:w-22":"w-12 md:w-20"),onContextMenu:e=>e.preventDefault(),children:[se("div",{className:ee?"h-8":"h-3",children:ee&&se("div",{className:"flex items-center justify-evenly gap-1 pt-1 pr-1 pb-0.5",children:[se("span",{className:"text-[9px]select-none text-gray-500 md:text-[10px] dark:text-gray-400",children:J}),se("span",{className:"text-[9px] text-gray-500 md:text-[10px] dark:text-gray-400",children:X})]})}),s.map((e,t)=>{var n;return se("div",{className:dt,children:se("div",ee?{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:[se("span",{className:"text-[10px] md:text-[12px]",children:G&&0===t?"":null!==(n=null==q?void 0:q[t])&&void 0!==n?n:""}),se("span",{className:"text-[10px] text-gray-500 md:text-[12px] dark:text-gray-400",children:G&&0===t?"":e.label})]}:{className:`${ct} text-[10px] md:text-[12px]`,children:G&&0===t?"":e.label})},t)})]}),se("div",{className:"grow select-none",children:[se("div",{className:Pt(kt,!j&&le?"border-r":"","border-t-0"),style:ee?{height:"2rem"}:void 0,children:se("div",{className:`${St} -left-9.5`,style:{top:"auto",bottom:"-0.625rem"},children:G?F(U,0,K):""})}),se("div",{className:"relative",style:{WebkitTouchCallout:"none"},ref:L,children:[s.map((e,r)=>se("div",{className:Pt(ut,!j&&le?"border-r":""),onClick:()=>null==R?void 0:R(t),onDblClick:e=>{var r,a,o,l;const i=Math.floor((t.getTime()-n.getTime())/864e5),s=null===(a=null===(r=O.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=O.current)||void 0===o?void 0:o.querySelector(".calendar-content"))||void 0===l?void 0:l.scrollTop)||0,c=ie(),u=e.clientY-s.top+d-c;null==D||D(e,i,U+u/W)},onTouchStart:e=>{const r=Math.floor((t.getTime()-n.getTime())/864e5);C(e,r)},onTouchEnd:T,onTouchMove:k,onDragOver:S,onDrop:e=>{var n,r,a,o;const l=null===(r=null===(n=O.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=O.current)||void 0===a?void 0:a.querySelector(".calendar-content"))||void 0===o?void 0:o.scrollTop)||0,s=ie(),d=e.clientY-l.top+i-s,c=Math.floor(U+d/W);M(e,t,c)},onContextMenu:e=>de(e,!1)},r)),se("div",{className:Pt(kt,!j&&le?"border-r":""),children:se("div",ee?{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:j?"-5rem":"-5.5rem",width:j?"5rem":"5.5rem"},children:[se("span",{children:null!==(Q=null==q?void 0:q[0])&&void 0!==Q?Q:""}),se("span",{children:F(0,0,K)})]}:{className:`${St} -left-9.5`,children:F(0,0,K)})}),se("div",{className:"pointer-events-none absolute top-0 right-0 bottom-0 left-0",children:o.filter(e=>!e.allDay).map(t=>{const n=d.get(t.id);return se(pr,{event:t,layout:n,viewType:exports.ViewType.DAY,calendarRef:O,isBeingDragged:b&&(null==y?void 0:y.eventId)===t.id&&"move"===(null==y?void 0:y.mode),hourHeight:W,firstHour:U,onMoveStart:x,onResizeStart:w,onEventUpdate:N,onEventDelete:I,newlyCreatedEventId:m,onDetailPanelOpen:()=>p(null),detailPanelEventId:f,onDetailPanelToggle:e=>v(e),selectedEventId:h,onEventSelect:t=>{const n=e.getReadOnlyConfig().viewable,r=a.find(e=>e.id===t);(j||Y)&&r&&n?(V(r),_(!0)):(g(t),e.state.highlightedEventId&&(e.highlightEvent(null),re.current=null))},onEventLongPress:e=>{(j||Y)&&g(e)},customDetailPanelContent:H,customEventDetailDialog:A,app:e,isMobile:j,enableTouch:Y},t.id)})})]})]})]})})]}),ae&&se(Jn,{x:ae.x,y:ae.y,date:ae.date,viewType:exports.ViewType.DAY,onClose:()=>oe(null),app:e,onCreateEvent:()=>{if(D){const e=Math.floor((t.getTime()-n.getTime())/864e5);if(0===ae.date.getHours()&&0===ae.date.getMinutes())null==E||E({clientX:ae.x,clientY:ae.y},e);else{const t=ae.date.getHours()+ae.date.getMinutes()/60,n={preventDefault:()=>{},stopPropagation:()=>{},clientX:ae.x,clientY:ae.y};D(n,e,t)}}}})]})},br=({app:e,currentDate:t,visibleMonth:n,currentDayEvents:r,selectedEvent:a,setSelectedEvent:o,handleMonthChange:l,handleDateSelect:i,switcherMode:s,timeFormat:d="24h"})=>{const{t:c,locale:u}=nt(),h=[...r].toSorted((e,t)=>e.allDay&&!t.allDay?-1:!e.allDay&&t.allDay?1:0);return se("div",{className:"df-right-panel hidden flex-none md:block w-[30%] bg-white dark:bg-gray-900",onContextMenu:e=>e.preventDefault(),children:se("div",{className:`${At} h-full`,children:[se("div",{className:"df-mini-calendar px-2 border-b border-gray-200 dark:border-gray-700",children:se("div",{children:[se("div",{className:"flex items-center justify-end gap-2",children:[se("div",{className:at,style:{position:"relative"},children:se("div",{children:se("h1",{className:ot,children:" "})})}),se(fr,{handlePreviousMonth:()=>e.goToPrevious(),handleNextMonth:()=>e.goToNext(),handleToday:()=>e.goToToday()})]}),se(Rn,{visibleMonth:n,currentDate:t,showHeader:!0,onMonthChange:l,onDateSelect:i})]})}),se("div",{className:"flex-1 overflow-y-auto",children:se("div",{className:"p-4",children:[se("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?se("p",{className:`${Nt} ${Ht}`,children:c("noEvents")}):se("div",{className:"space-y-2",children:h.map(t=>se("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:Y(t.calendarId||"blue")},onClick:()=>{o(t),e.onEventClick(t)},children:[se("div",{className:`font-medium ${Ht}`,children:t.title}),!t.allDay&&se("div",{className:`${Rt} ${It}`,children:[F(S(t.start),0,d)," ","- ",F(V(t),0,d)]}),t.allDay&&se("div",{className:`${Rt} ${It}`,children:c("allDay")})]},t.id))})]})})]})})},xr={PARALLEL_THRESHOLD:.25,NESTED_THRESHOLD:.5,INDENT_STEP_PERCENT:2.5,MIN_WIDTH:25,MARGIN_BETWEEN:1,EDGE_MARGIN_PERCENT:.9};function wr(e){return Object.assign(Object.assign({},e),{parentId:void 0,children:[],_startHour:e.allDay?0:S(e.start),_endHour:e.allDay?0:V(e)})}function Dr(e){var t;return null!==(t=e._startHour)&&void 0!==t?t:S(e.start)}function Er(e){var t;return null!==(t=e._endHour)&&void 0!==t?t:V(e)}function Cr(e,t){return e.day===t.day&&!e.allDay&&!t.allDay&&(Dr(e)<Er(t)&&Dr(t)<Er(e))}function Tr(e,t){const n=Er(e)-Dr(e);if(n<1.25)return!1;const r=Dr(e)+.4*n,a=Dr(t)>=r,o=Cr(e,t);return a&&o}function kr(e,t,n=xr){if(!Cr(e,t))return!1;const r=Math.abs(Dr(e)-Dr(t));return r<=n.PARALLEL_THRESHOLD||(r>n.PARALLEL_THRESHOLD&&r<n.NESTED_THRESHOLD||function(e,t){return!(!Cr(e,t)||!Tr(e,t)&&!Tr(t,e))}(e,t))}function Sr(e,t){const n=Dr(e)<=Dr(t)&&Er(e)>=Er(t),r=Dr(e)<=Dr(t)&&Dr(t)<Er(e)&&Cr(e,t);return n||r}function Mr(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(Dr(r)-Dr(t))<=xr.PARALLEL_THRESHOLD&&(a.push(t),n.add(t.id))}a.sort((e,t)=>Dr(e)-Dr(t));const o={events:a,startHour:Math.min(...a.map(e=>Dr(e))),endHour:Math.max(...a.map(e=>Er(e)))};t.push(o)}return t.sort((e,t)=>e.startHour-t.startHour),t}function Nr(e){return"day"===e?.5:2.5}function Ir(e){const t=Er(e)-Dr(e);return Math.max(.1,Math.min(1,t/4))}function Rr(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(kr(e[t],e[n],xr))return!0;return!1}function Hr(e,t,n,r,a={}){const o=Nr(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*Nr(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:Ir(e.event)}),0===e.children.length)return;const u=[...e.children].toSorted((e,t)=>Er(t.event)-Dr(t.event)-(Er(e.event)-Dr(e.event)));1===u.length?Hr(u[0],d,c,r,a):Rr(u.map(e=>e.event))?Ar(u,d,c,r,a):u.forEach(e=>Hr(e,d,c,r,a))}function Ar(e,t,n,r,a={}){const o=e.length,l=e[0].depth,i=l*Nr(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=>Hr(e,t,n,r,a));let h=xr.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:Ir(e.event)}),e.children.length>0){const t=[...e.children].toSorted((e,t)=>Er(t.event)-Dr(t.event)-(Er(e.event)-Dr(e.event)));1===t.length?Hr(t[0],n,g,r,a):Rr(t.map(e=>e.event))?Ar(t,n,g,r,a):t.forEach(e=>Hr(e,n,g,r,a))}})}function Or(e,t,n={}){const r=100-("day"===n.viewType?0:xr.EDGE_MARGIN_PERCENT);if(1===e.length)Hr(e[0],0,r,t,n);else if(e.length>1){const a=e.length,o=(r-xr.MARGIN_BETWEEN*(a-1))/a;e.forEach((e,r)=>{Hr(e,r*(o+xr.MARGIN_BETWEEN),Math.max(o,xr.MIN_WIDTH),t,n)})}}function Pr(e){let t=0;for(const n of e.children)t+=1+Pr(n);return t}function Lr(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:Pr(e)})).toSorted((e,t)=>t.load-e.load)}function $r(e){return!(e.length<2)&&e[0].load-e.at(-1).load>=2}function jr(e,t){t.parentId=e.id,e.children.includes(t.id)||e.children.push(t.id)}function Yr(e,t){e.parent&&(e.parent.children=e.parent.children.filter(t=>t!==e));const n=t.children.find(t=>Sr(t.event,e.event));n?(e.parent=n,e.depth=n.depth+1,n.children.push(e),jr(n.event,e.event)):(e.parent=t,e.depth=t.depth+1,t.children.push(e),jr(t.event,e.event))}function Fr(e,t){0===e.children.length?t.push(e):e.children.forEach(e=>Fr(e,t))}function Vr(e,t){const n=[];return Fr(e,n),n.find(e=>Sr(t.event,e.event))||n[0]||null}function _r(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=Vr(n.node,r.node);if(!a)break;Yr(a,r.node),n.load--,r.load++,t++}}function zr(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(Cr(n,e)&&Math.abs(Dr(e)-Dr(n))<xr.NESTED_THRESHOLD)return!0;return!1}(e,t))return!1;if(n<xr.NESTED_THRESHOLD)return!1;for(const n of e.events)for(const e of t.events)if(Sr(n,e))return!0;return!1}function Wr(e,t,n){const r=t.events.filter(t=>Sr(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&&kr(e,r,xr)})}));return a.sort((t,n)=>t.load!==n.load?t.load-n.load:t.hasParallelSibling!==n.hasParallelSibling?t.hasParallelSibling?-1:1:Math.abs(Dr(e)-Dr(t.parent))-Math.abs(Dr(e)-Dr(n.parent))),a[0].parent}function Ur(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=Er(e)-Dr(e),l=a.flatMap(e=>e.children);return o>Math.max(...l.map(e=>{const t=n.find(t=>t.id===e);return t?Er(t)-Dr(t):0}),0)?a[0]:a.at(-1)||null}function Br(e,t){t.parentId=e.id,e.children.includes(t.id)||e.children.push(t.id)}function Zr(e){let t=0;for(const n of e.children)t+=1+Zr(n);return t}function Gr(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 Kr(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 l=1/0,i=null;for(const e of o){const t=Zr(e);t<l&&(l=t,i=e)}return i?i.event:null}function qr(e,t,n){const r=[];if(1===e.length){const a=Wr(e[0],t,n);return a&&(r.push({child:e[0],parent:a}),Br(a,e[0])),r}const a=t.events.filter(t=>e.every(e=>Sr(t,e)));if(0===a.length){for(const a of e){const o=Wr(a,t,n);if(o)r.push({child:a,parent:o}),Br(o,a);else{const t=e.find(e=>e.id!==a.id&&Cr(e,a));if(t){const e=Kr(t,Gr(n));e&&(r.push({child:a,parent:e}),Br(e,a))}}}return r}const o=[...e].toSorted((e,t)=>Er(t)-Dr(t)-(Er(e)-Dr(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],l=o.slice(t*e,(t+1)*e);for(const e of l)r.push({child:e,parent:n}),Br(n,e)}}else for(const e of o){const t=Ur(e,a,o);t&&(r.push({child:e,parent:t}),Br(t,e))}return r}function Xr(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(zr(d,{events:l,startHour:o.startHour,endHour:o.endHour})){const e=qr(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=Lr(e[n].events.map(e=>t.find(t=>t.event.id===e.id)),t);$r(r)&&_r(r)}}(e,n),o}const Jr={calculateDayEventLayouts(e,t={}){const n=e.map(wr);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)||Cr(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:xr.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{Or(Xr(Mr([...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}},Qr=(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},ea={HOUR_HEIGHT:72,FIRST_HOUR:0,LAST_HOUR:24,ALL_DAY_HEIGHT:28};function ta(t){const{app:n,onEventCreated:a}=t,{t:o}=nt(),l=r.useCallback(e=>{e.dataTransfer&&e.dataTransfer.types.includes("application/x-dayflow-calendar")&&(e.preventDefault(),e.dataTransfer.dropEffect="copy")},[]);return{handleDrop:r.useCallback((t,r,l,i)=>{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;i?(d=e.Temporal.PlainDateTime.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate(),hour:0,minute:0}),c=e.Temporal.PlainDateTime.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate(),hour:23,minute:59,second:59}),u=!0):void 0===l?(d=e.Temporal.PlainDateTime.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate(),hour:9,minute:0}),c=d.add({hours:1})):(d=e.Temporal.PlainDateTime.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate(),hour:l,minute:0}),c=d.add({hours:1}));const h={id:`event-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,title:o(u?"newAllDayCalendarEvent":"newCalendarEvent",{calendarName:t.calendarName}),description:"",start:d,end:c,calendarId:t.calendarId,allDay:u};return n.addEvent(h),null==a||a(h),h}catch(e){return console.error("Error creating event from calendar drop:",e),null}},[n,a]),handleDragOver:l}}let na=null;const ra={handleMoveStart:()=>{},handleCreateStart:()=>{},handleResizeStart:void 0,handleCreateAllDayEvent:()=>{},dragState:{active:!1,mode:null,eventId:null,targetDate:null,startDate:null,endDate:null},isDragging:!1};function aa(e,t){return na?na(e,t):ra}const oa=({app:e,config:t,customDetailPanelContent:n,customEventDetailDialog:a,calendarRef:o,switcherMode:l="buttons",selectedEventId:i,onEventSelect:s,onDateChange:d,detailPanelEventId:c,onDetailPanelToggle:u})=>{const h=e.getEvents(),{screenSize:g}=et(),m="desktop"!==g,[p,f]=r.useState(!1),{hourHeight:v=ea.HOUR_HEIGHT,firstHour:y=ea.FIRST_HOUR,lastHour:x=ea.LAST_HOUR,allDayHeight:D=ea.ALL_DAY_HEIGHT,showAllDay:E=!0,timeFormat:C="24h",secondaryTimeZone:T}=t,k=v,M=y,N=x,I=D,R=!E;r.useEffect(()=>{f("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const H=e.getCustomMobileEventRenderer()||On,[A,O]=r.useState(null),[P,L]=r.useState(null),[$,j]=r.useState(null),Y=void 0===i?P:i,V=void 0===c?$:c,_=r.useMemo(()=>Y&&h.find(e=>e.id===Y)||null,[Y,h]),U=e=>{s?s(e):L(e)},[B,Z]=r.useState(null),[G,K]=r.useState(!1),[q,X]=r.useState(null),J=r.useRef(null),Q=e.getCurrentDate(),[ee,ne]=r.useState(Q),re=r.useRef(Q.getTime());Q.getTime()!==re.current&&(re.current=Q.getTime(),Q.getFullYear()===ee.getFullYear()&&Q.getMonth()===ee.getMonth()||ne(Q));const ae=r.useCallback(t=>{ne(n=>{const r=new Date(n.getFullYear(),n.getMonth()+t,1);return e.setVisibleMonth(r),r})},[e]),oe=r.useRef(e.state.highlightedEventId);r.useEffect(()=>{var t;if(e.state.highlightedEventId!==oe.current)if(e.state.highlightedEventId){U(e.state.highlightedEventId);const n=e.getEvents().find(t=>t.id===e.state.highlightedEventId);if(n&&!n.allDay){const e=S(n.start),r=null===(t=o.current)||void 0===t?void 0:t.querySelector(".calendar-content");if(r){const t=(e-M)*k;requestAnimationFrame(()=>{r.scrollTo({top:Math.max(0,t-100),behavior:"smooth"})})}}}else U(null);oe.current=e.state.highlightedEventId},[e.state.highlightedEventId,M,k,o,e]);const le=r.useRef(null),ie=r.useRef(null),de=r.useMemo(()=>Qr(Q),[Q]),ce=r.useMemo(()=>((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=w(e.start),n=w(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=w(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})})})(h,Q,de),[h,Q,de]),ue=r.useMemo(()=>((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=w(e.start),a=w(e.end);let o=e.start,l=e.end,i=!1;return t<n&&(o=b(n),i=!0),a>r&&(l=b(r),i=!0),Object.assign(Object.assign({},e),{start:i?o:e.start,end:i?l:e.end,day:0})})})(ce,Q),[ce,Q]),he=r.useMemo(()=>Jr.calculateDayEventLayouts(ue,{viewType:"day"}),[ue]),ge=r.useMemo(()=>(e=>{const t=e.filter(e=>e.allDay);t.sort((e,t)=>{const n=w(e.start),r=w(t.start);if(n.getTime()!==r.getTime())return n.getTime()-r.getTime();const a=w(e.end);return w(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=w(e.start),r=w(e.end),a=w(t.start);return n<=w(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})(ce),[ce]),me=r.useMemo(()=>{if(0===ge.length)return I;return(Math.max(...ge.map(e=>e.row))+1)*I},[ge,I]),{handleMoveStart:pe,handleCreateStart:fe,handleResizeStart:ve,handleCreateAllDayEvent:ye,dragState:be,isDragging:xe}=aa(e,{calendarRef:o,allDayRowRef:E?le:void 0,timeGridRef:ie,viewType:exports.ViewType.DAY,onEventsUpdate:(t,n,r)=>{const a=t(ce),o=new Set(a.map(e=>e.id)),l=ce.filter(e=>!o.has(e.id)),i=new Set(ce.map(e=>e.id)),s=a.filter(e=>!i.has(e.id)),d=a.filter(e=>{if(!i.has(e.id))return!1;const t=h.find(t=>t.id===e.id);return t&&te(t,e)});e.applyEventsChanges({delete:l.map(e=>e.id),add:s,update:d.map(e=>({id:e.id,updates:e}))},void 0,r)},onEventCreate:t=>{m?(X(t),K(!0)):(e.addEvent(t),Z(t.id))},onEventEdit:()=>{},currentWeekStart:de,events:ce,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:b(o),end:b(l),calendarId:"blue",allDay:!1}];return Jr.calculateDayEventLayouts(i,{viewType:"day"}).get("-1")||null})(0,t,n,Q,ue),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:b(s),end:b(d),day:0})];return 0===c.length?null:Jr.calculateDayEventLayouts(c,{viewType:"day"}).get(e.id)||null})(e,0,n,r,Q,ue),TIME_COLUMN_WIDTH:T&&!m?88:m?48:80,isMobile:m}),{handleDrop:we,handleDragOver:De}=ta({app:e,onEventCreated:e=>{Z(e.id)}}),Ee=Array.from({length:24},(e,t)=>({hour:t+M,label:F(t+M,0,C)})),Ce=r.useMemo(()=>T?z(Ee,T,C):void 0,[T,C,M]),Te=r.useMemo(()=>T?W(Intl.DateTimeFormat().resolvedOptions().timeZone):void 0,[T]),ke=r.useMemo(()=>T?W(T):void 0,[T]),Se=r.useCallback(t=>{const n=new Date(t.getFullYear(),t.getMonth(),t.getDate());e.setCurrentDate(n),ne(new Date(n.getFullYear(),n.getMonth(),1))},[e]),Me=r.useMemo(()=>{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 r.useLayoutEffect(()=>{var e;if(t.scrollToCurrentTime){const t=null===(e=o.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-M)*k-r/2)}}},[]),r.useEffect(()=>{O(new Date);const e=setInterval(()=>O(new Date),6e4);return()=>clearInterval(e)},[]),se("div",{className:"df-day-view flex h-full bg-gray-50 dark:bg-gray-800",children:[se(yr,{app:e,currentDate:Q,currentWeekStart:de,events:h,currentDayEvents:ce,organizedAllDayEvents:ge,allDayAreaHeight:me,timeSlots:Ee,eventLayouts:he,isToday:Me,currentTime:A,selectedEventId:Y,setSelectedEventId:U,newlyCreatedEventId:B,setNewlyCreatedEventId:Z,detailPanelEventId:V,setDetailPanelEventId:e=>{u?u(e):j(e)},dragState:be,isDragging:xe,handleMoveStart:pe,handleResizeStart:ve,handleCreateStart:fe,handleCreateAllDayEvent:ye,handleTouchStart:(e,t)=>{if(!m&&!p)return;const n=e.touches[0],r=n.clientX,a=n.clientY,l=e.currentTarget;J.current=setTimeout(()=>{var e,n,i;const s=null===(n=null===(e=o.current)||void 0===e?void 0:e.querySelector(".calendar-content"))||void 0===n?void 0:n.getBoundingClientRect();if(!s)return;const d=null===(i=o.current)||void 0===i?void 0:i.querySelector(".calendar-content"),c=d?d.scrollTop:0,u=a-s.top+c;null==fe||fe({preventDefault:()=>{},stopPropagation:()=>{},touches:[{clientX:r,clientY:a}],changedTouches:[{clientX:r,clientY:a}],target:l,currentTarget:l,cancelable:!0},t,M+u/k)},500)},handleTouchEnd:()=>{J.current&&(clearTimeout(J.current),J.current=null)},handleTouchMove:()=>{J.current&&(clearTimeout(J.current),J.current=null)},handleDragOver:De,handleDrop:we,handleEventUpdate:t=>{e.updateEvent(t.id,t)},handleEventDelete:t=>{e.deleteEvent(t)},onDateChange:d,customDetailPanelContent:n,customEventDetailDialog:a,calendarRef:o,allDayRowRef:le,timeGridRef:ie,switcherMode:l,isMobile:m,isTouch:p,setDraftEvent:X,setIsDrawerOpen:K,ALL_DAY_HEIGHT:I,HOUR_HEIGHT:k,FIRST_HOUR:M,LAST_HOUR:N,showAllDay:E,showStartOfDayLabel:R,timeFormat:C,secondaryTimeSlots:Ce,primaryTzLabel:Te,secondaryTzLabel:ke}),se(br,{app:e,currentDate:Q,visibleMonth:ee,currentDayEvents:ce,selectedEvent:_,setSelectedEvent:e=>U(e?e.id:null),handleMonthChange:ae,handleDateSelect:Se,switcherMode:l,timeFormat:C}),se(H,{isOpen:G,onClose:()=>{K(!1),X(null)},onSave:t=>{h.some(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),K(!1),X(null)},draftEvent:q,app:e,timeFormat:C})]})},la=({originalComponent:e,app:t,config:n,customDetailPanelContent:a,customEventDetailDialog:o,calendarRef:l,switcherMode:i,meta:s,selectedEventId:d,detailPanelEventId:c,onEventSelect:u,onDateChange:h,onDetailPanelToggle:g})=>{const m=t.getPlugin("events"),p=t.getPlugin("drag"),f=t.getCurrentDate(),v=t.state.currentView,y=t.getEvents(),b=r.useCallback(e=>{m?m.update(e.id,e):t.updateEvent(e.id,e)},[m,t]),x=r.useCallback(e=>{m?m.delete(e):t.deleteEvent(e)},[m,t]),w=r.useCallback(e=>{m?m.add(e):t.addEvent(e)},[m,t]),D=r.useCallback(e=>{h?h(e):t.setCurrentDate(e)},[t,h]),E=r.useCallback(e=>{t.changeView(e)},[t]),C=r.useMemo(()=>Object.assign({},n),[n]),T=r.useMemo(()=>({app:t,currentDate:f,currentView:v,events:y,onEventUpdate:b,onEventDelete:x,onEventCreate:w,onDateChange:D,onViewChange:E,config:C,customDetailPanelContent:a,customEventDetailDialog:o,calendarRef:l,switcherMode:i,meta:s,selectedEventId:d,detailPanelEventId:c,onEventSelect:u,onDetailPanelToggle:g}),[t,f,v,y,b,x,w,D,E,C,a,o,l,i,s,d,c,u,g]),k=r.useMemo(()=>{const e={currentDate:f,events:y,setEvents:e=>{y.forEach(e=>x(e.id)),e.forEach(e=>w(e))},updateEvent:b,deleteEvent:x,addEvent:w,goToPrevious:()=>{const e=new Date(f);switch(v){case exports.ViewType.DAY:e.setDate(e.getDate()-1);break;case exports.ViewType.WEEK:e.setDate(e.getDate()-7);break;case exports.ViewType.MONTH:e.setMonth(e.getMonth()-1)}D(e)},goToNext:()=>{const e=new Date(f);switch(v){case exports.ViewType.DAY:e.setDate(e.getDate()+1);break;case exports.ViewType.WEEK:e.setDate(e.getDate()+7);break;case exports.ViewType.MONTH:e.setMonth(e.getMonth()+1)}D(e)},goToToday:()=>{D(new Date)},changeView:E,selectDate:D};return Object.assign(Object.assign({calendar:e},T),{eventsService:m,dragService:p})},[f,y,v,b,x,w,D,E,T,m,p]);return se(e,Object.assign({},k))},ia={showAllDay:!0,scrollToCurrentTime:!0,hourHeight:72,firstHour:0,lastHour:24,allDayHeight:28,timeFormat:"24h"},sa=(e={})=>{const n=Object.assign(Object.assign({},ia),e),r=e=>t.h(la,{viewType:exports.ViewType.DAY,originalComponent:oa,app:e.app,config:n,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 r.displayName="DayViewAdapter",{type:exports.ViewType.DAY,component:r,config:n}},da=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)},ca=({app:e,fullWeekDates:n=[],mobilePageStart:r,onDateChange:a})=>se("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:[se("div",{className:"mb-1 grid grid-cols-7",children:n.map((e,t)=>se("div",{className:"flex justify-center",children:se("span",{className:"text-[10px] font-medium "+(e.isToday?"text-primary":"text-gray-500"),children:da(e.dayName)})},`label-${t}`))}),se("div",{className:"relative grid grid-cols-7 overflow-hidden",children:(()=>{if(!r)return null;const o=n.findIndex(e=>e.fullDate.getTime()===r.getTime()),l=-1===o?"0":`calc(${(o+.5)/7*100}% - 16px)`,i=`calc(${1/7*100}% + 32px)`;return se(t.Fragment,{children:[se("div",{className:"absolute rounded-full bg-gray-100 transition-all duration-300 dark:bg-gray-800",style:{left:l,top:0,width:i,height:"32px"}}),n.map((t,n)=>{const r=t.isCurrent,l=n>=o&&n<o+2;return se("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:se("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":l?"text-gray-900 dark:text-gray-100":"text-gray-500 dark:text-gray-400"} `,children:[t.date,t.isToday&&!r&&se("div",{className:"absolute bottom-1 h-1 w-1 rounded-full bg-primary"})]})},`date-${n}`)})]})})()})]}),ua=({app:e,weekDaysLabels:n,mobileWeekDaysLabels:a,weekDates:o,fullWeekDates:l,isSlidingView:i,mobilePageStart:s,currentWeekStart:d,gridWidth:c,allDayAreaHeight:u,organizedAllDaySegments:h,allDayLabelText:g,isMobile:m,isTouch:p,showAllDay:f=!0,calendarRef:v,allDayRowRef:y,topFrozenContentRef:b,ALL_DAY_HEIGHT:x,HOUR_HEIGHT:w,FIRST_HOUR:D,dragState:E,isDragging:C,primaryTzLabel:T,secondaryTzLabel:k,secondaryTimeSlots:S,handleMoveStart:M,handleResizeStart:N,handleEventUpdate:I,handleEventDelete:R,onDateChange:H,newlyCreatedEventId:A,setNewlyCreatedEventId:O,selectedEventId:P,setSelectedEventId:L,detailPanelEventId:$,setDetailPanelEventId:j,handleCreateAllDayEvent:Y,handleDragOver:F,handleDrop:V,customDetailPanelContent:_,customEventDetailDialog:z})=>{const W={flexShrink:0},[U,B]=r.useState(null),Z=r.useMemo(()=>Me(),[]),G=!!S&&S.length>0&&!m;return se("div",{className:"flex w-full flex-col",children:[i&&l&&s&&se(ca,{app:e,fullWeekDates:l,mobilePageStart:s,onDateChange:H}),se("div",{className:`flex flex-none ${f?"border-b border-gray-200 dark:border-gray-700":""} relative z-10`,onContextMenu:e=>e.preventDefault(),children:[f&&se("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:[se("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:G&&se("div",{className:"flex w-full items-center justify-evenly gap-0.5 pt-2 pb-0.5",children:[se("span",{className:"text-[9px] text-gray-500 select-none md:text-[10px] dark:text-gray-400",children:k}),se("span",{className:"text-[9px] text-gray-500 select-none md:text-[10px] dark:text-gray-400",children:T})]})}),se("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:`${u}px`},children:g})]}),se("div",{className:"relative flex-1 overflow-hidden transition-[min-height] duration-300 ease-in-out",style:{scrollbarGutter:"stable",minHeight:f?`${u+(i?0:36)}px`:"auto"},children:se("div",{ref:b,className:"flex flex-col",style:{width:c,minWidth:"100%",transform:i?"translateX(calc(-100% / 3))":void 0},children:[!i&&se("div",{className:"df-week-header flex border-b border-gray-200 dark:border-gray-700",style:{marginRight:Z?"-50px":"0px",paddingRight:Z?"50px":"0px"},children:n.map((e,n)=>se("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:W,children:se(t.Fragment,m?{children:[se("div",{className:"text-[12px] leading-tight font-medium text-gray-500",children:a[n]}),se("div",{className:`${lt} h-7 w-7 text-base font-medium ${o[n].isToday?wt:""}`,children:o[n].date})]}:{children:[se("div",{className:"mt-1 mr-1 inline-flex items-center justify-center text-sm",children:e}),se("div",{className:`${lt} ${o[n].isToday?wt:""}`,children:o[n].date})]})},n))}),f&&se("div",{className:`${mt} border-none transition-[min-height] duration-300 ease-in-out`,ref:y,style:{minHeight:`${u}px`},children:se("div",{className:"df-all-day-content flex flex-1 relative transition-[min-height] duration-300 ease-in-out",style:{minHeight:`${u}px`},children:[n.map((e,t)=>{const r=new Date(d);return r.setDate(d.getDate()+t),se("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 "+(t!==n.length-1||!m&&Z?"":"border-r-0"),style:Object.assign({minHeight:`${u}px`},W),onMouseDown:e=>null==Y?void 0:Y(e,t),onDblClick:e=>null==Y?void 0:Y(e,t),onDragOver:F,onDrop:e=>{V(e,r,void 0,!0)},onContextMenu:e=>((e,t)=>{if(e.preventDefault(),m)return;const n=new Date(d);n.setDate(d.getDate()+t),n.setHours(0,0,0,0),B({x:e.clientX,y:e.clientY,date:n})})(e,t)},`allday-${t}`)}),se("div",{className:"pointer-events-none absolute inset-0",children:h.map(t=>se(pr,{event:t.event,segment:t,segmentIndex:t.row,isAllDay:!0,isMultiDay:!0,allDayHeight:x,calendarRef:v,viewType:exports.ViewType.WEEK,columnsPerRow:n.length,isBeingDragged:C&&(null==E?void 0:E.eventId)===t.event.id&&"move"===(null==E?void 0:E.mode),hourHeight:w,firstHour:D,onMoveStart:M,onResizeStart:N,onEventUpdate:I,onEventDelete:R,newlyCreatedEventId:A,onDetailPanelOpen:()=>O(null),selectedEventId:P,detailPanelEventId:$,onEventSelect:e=>{L(e)},onEventLongPress:e=>{(m||p)&&L(e)},onDetailPanelToggle:e=>j(e),customDetailPanelContent:_,customEventDetailDialog:z,app:e,isMobile:m,isSlidingView:i,enableTouch:p},t.event.id))})]})})]})}),U&&se(Jn,{x:U.x,y:U.y,date:U.date,viewType:exports.ViewType.WEEK,onClose:()=>B(null),app:e,onCreateEvent:()=>{const e=Math.floor((U.date.getTime()-d.getTime())/864e5);null==Y||Y({clientX:U.x,clientY:U.y},e)}})]})]})},ha=({app:e,timeSlots:n,weekDaysLabels:a,currentWeekStart:o,currentWeekEvents:l,eventLayouts:i,gridWidth:s,isMobile:d,isTouch:c,scrollerRef:u,timeGridRef:h,leftFrozenContentRef:g,swipeContentRef:m,calendarRef:p,handleScroll:f,handleCreateStart:v,handleTouchStart:y,handleTouchEnd:b,handleTouchMove:x,handleDragOver:w,handleDrop:D,dragState:E,isDragging:C,handleMoveStart:T,handleResizeStart:k,handleEventUpdate:S,handleEventDelete:M,onDateChange:N,newlyCreatedEventId:I,setNewlyCreatedEventId:R,selectedEventId:H,setSelectedEventId:A,detailPanelEventId:O,setDetailPanelEventId:P,customDetailPanelContent:L,customEventDetailDialog:$,isSlidingView:j,isCurrentWeek:Y,currentTime:V,HOUR_HEIGHT:_,FIRST_HOUR:z,LAST_HOUR:W,showStartOfDayLabel:U,timeFormat:B="24h",secondaryTimeSlots:Z})=>{var G,q;const X=!!Z&&Z.length>0&&!d,J={flexShrink:0},Q=r.useRef(e.state.highlightedEventId),[ee,te]=r.useState(null),ne=r.useMemo(()=>Me(),[]);return se("div",{className:"relative flex flex-1 overflow-hidden",children:[se("div",{ref:u,className:"calendar-content relative flex-1 overflow-auto "+("300%"===s?"overflow-x-hidden":"snap-x snap-mandatory"),style:{display:"grid",gridTemplateColumns:"auto 1fr"},onScroll:f,children:[se("div",{ref:g,className:"sticky left-0 z-10 w-12 shrink-0 bg-white md:w-20 dark:bg-gray-900",onContextMenu:e=>e.preventDefault(),children:[se("div",{className:"relative h-3",children:X?se(t.Fragment,{children:se("div",{className:"absolute right-0 -bottom-1 flex w-full items-center justify-evenly select-none",children:[se("span",{className:"text-[10px] text-gray-500 md:text-[12px] dark:text-gray-400",children:U&&null!==(G=null==Z?void 0:Z[0])&&void 0!==G?G:""}),se("span",{className:"text-[10px] text-gray-500 md:text-[12px] dark:text-gray-400",children:U?F(z,0,B):""})]})}):se("div",{className:"absolute right-2 -bottom-1 text-[10px] text-gray-500 select-none md:text-[12px] dark:text-gray-400",children:U?F(z,0,B):""})}),n.map((e,t)=>{var n;return se("div",{className:dt,children:se("div",X?{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:[se("span",{className:"text-[10px] md:text-[12px]",children:U&&0===t?"":null!==(n=null==Z?void 0:Z[t])&&void 0!==n?n:""}),se("span",{className:"text-[10px] md:text-[12px]",children:U&&0===t?"":e.label})]}:{className:`${ct} text-[10px] md:text-[12px]`,children:U&&0===t?"":e.label})},t)}),se("div",{className:"relative",children:se("div",X?{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:[se("span",{className:"text-[10px] md:text-[12px]",children:null!==(q=null==Z?void 0:Z[0])&&void 0!==q?q:""}),se("span",{className:"text-[10px] md:text-[12px]",children:F(0,0,B)})]}:{className:`${ct} text-[10px] md:text-[12px]`,children:F(0,0,B)})}),Y&&V&&(()=>{const e=V,t=e.getHours()+e.getMinutes()/60;if(t<z||t>W)return null;return se("div",{className:"pointer-events-none absolute left-0 z-20 flex w-full items-center justify-end",style:{top:`${(t-z)*_}px`,transform:"translateY(-50%)",marginTop:"0.75rem"},children:se("div",{className:gt,children:F(t,0,B,!1)})})})()]}),se("div",{ref:m,className:"flex",style:{width:s,minWidth:"100%",transform:j?"translateX(calc(-100% / 3))":void 0},children:se("div",{className:"grow",children:[se("div",{className:`${kt} flex border-t-0`,children:a.map((e,t)=>se("div",{className:`relative flex-1 ${t!==a.length-1||!d&&ne?"border-r":""} border-gray-200 dark:border-gray-700`,style:J},`top-${t}`))}),se("div",{ref:h,className:"relative",children:[Y&&V&&(()=>{const e=V,t=e.getHours()+e.getMinutes()/60;if(t<z||t>W)return null;const n=new Date(e);n.setHours(0,0,0,0);const r=new Date(o);r.setHours(0,0,0,0);const l=n.getTime()-r.getTime(),i=Math.round(l/864e5);return se("div",{className:ht,style:{top:`${(t-z)*_}px`,width:"100%",height:0,zIndex:20},children:[se("div",{className:"flex w-0 items-center"}),se("div",{className:"flex flex-1",children:a.map((e,t)=>se("div",{className:"flex flex-1 items-center",children:se("div",{className:"relative h-0.5 w-full "+(t===i?"bg-primary":"bg-primary/30"),style:{zIndex:9999},children:t===i&&0!==i&&se("div",{className:"absolute h-2 w-2 rounded-full bg-primary",style:{top:"-3px",left:"-4px"}})})},t))})]})})(),n.map((e,t)=>se("div",{className:ut,children:a.map((n,r)=>{const l=new Date(o);return l.setDate(o.getDate()+r),se("div",{className:"df-time-grid-cell flex-1 relative border-r border-gray-200 dark:border-gray-700 select-none snap-start "+(r!==a.length-1||!d&&ne?"":"border-r-0"),style:J,onClick:()=>{const e=new Date(o);e.setDate(o.getDate()+r),null==N||N(e)},onDblClick:t=>{null==v||v(t,r,e.hour)},onTouchStart:t=>y(t,r,e.hour),onTouchEnd:b,onTouchMove:x,onDragOver:w,onDrop:t=>{D(t,l,e.hour)},onContextMenu:t=>((e,t,n)=>{if(e.preventDefault(),d)return;const r=new Date(o);if(r.setDate(o.getDate()+t),h.current){const t=h.current.getBoundingClientRect(),n=(e.clientY-t.top)/_+z,a=Math.floor(n),o=Math.floor(60*(n-a)),l=15*Math.round(o/15),i=60===l?a+1:a,s=60===l?0:l;r.setHours(i,s,0,0)}else r.setHours(n,0,0,0);te({x:e.clientX,y:e.clientY,date:r})})(t,r,e.hour)},`${t}-${r}`)})},t)),se("div",{className:`${kt} flex`,children:a.map((e,t)=>se("div",{className:`relative flex-1 ${t!==a.length-1||!d&&ne?"border-r":""} border-gray-200 dark:border-gray-700`,style:J},`24-${t}`))}),a.map((t,n)=>{const r=a.length,s=K(n,l),u=[];return s.forEach(e=>{const t=nr(e,o);if(t.length>0){const r=t.find(e=>e.dayIndex===n);r&&u.push({event:e,segmentInfo:Object.assign(Object.assign({},r),{dayIndex:n})})}else u.push({event:e})}),l.forEach(e=>{if(e.allDay||e.day===n)return;const t=nr(e,o).find(e=>e.dayIndex===n);t&&u.push({event:e,segmentInfo:Object.assign(Object.assign({},t),{dayIndex:n})})}),se("div",{className:"pointer-events-none absolute top-0",style:{left:`calc(${100/r*n}%)`,width:100/r+"%",height:"100%"},children:u.map(({event:t,segmentInfo:a})=>{const o=i.get(n),l=null==o?void 0:o.get(t.id);return se(pr,{event:t,layout:l,viewType:exports.ViewType.WEEK,calendarRef:p,columnsPerRow:r,isBeingDragged:C&&(null==E?void 0:E.eventId)===t.id&&"move"===(null==E?void 0:E.mode),hourHeight:_,firstHour:z,onMoveStart:T,onResizeStart:k,onEventUpdate:S,onEventDelete:M,newlyCreatedEventId:I,onDetailPanelOpen:()=>R(null),selectedEventId:H,detailPanelEventId:O,onEventSelect:t=>{A(t),e.state.highlightedEventId&&(e.highlightEvent(null),Q.current=null)},onEventLongPress:e=>{(d||c)&&A(e)},onDetailPanelToggle:e=>P(e),customDetailPanelContent:L,customEventDetailDialog:$,multiDaySegmentInfo:a,app:e,isMobile:d,isSlidingView:j,enableTouch:c},a?`${t.id}-seg-${n}`:t.id)})},`events-day-${n}`)})]})]})})]}),ee&&se(Jn,{x:ee.x,y:ee.y,date:ee.date,viewType:exports.ViewType.WEEK,onClose:()=>te(null),app:e,onCreateEvent:()=>{if(v){const e=new Date(o);e.setHours(0,0,0,0);const t=new Date(ee.date);t.setHours(0,0,0,0);const n=t.getTime()-e.getTime(),r=Math.round(n/864e5),a=ee.date.getHours()+ee.date.getMinutes()/60,l={preventDefault:()=>{},stopPropagation:()=>{},clientX:ee.x,clientY:ee.y};v(l,r,a)}}})]})},ga=({app:e,config:t,customDetailPanelContent:n,customEventDetailDialog:a,calendarRef:o,selectedEventId:l,onEventSelect:i,onDateChange:s,detailPanelEventId:d,onDetailPanelToggle:c})=>{var u;const{t:h,getWeekDaysLabels:g,locale:m}=nt(),p=e.getCurrentDate(),f=r.useMemo(()=>p,[p.getTime()]),v=e.getEvents(),{screenSize:y}=et(),x="desktop"!==y,D=r.useRef(null),[E,C]=r.useState(!1),{hourHeight:T=ea.HOUR_HEIGHT,firstHour:k=ea.FIRST_HOUR,lastHour:N=ea.LAST_HOUR,allDayHeight:I=ea.ALL_DAY_HEIGHT,showAllDay:R=!0,timeFormat:H="24h",secondaryTimeZone:A}=t,O=A&&"mobile"!==y?88:"mobile"===y?48:80,P=T,L=k,$=N,j=I,Y=!R;r.useEffect(()=>{C("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const V=e.getCustomMobileEventRenderer()||On,_="desktop"!==y,U=_?2:7,B=_,Z=null!==(u=t.startOfWeek)&&void 0!==u?u:1,G=B?"300%":"100%",K=r.useMemo(()=>Qr(f,Z),[f,Z]),[X,J]=r.useState(()=>{const e=new Date(f);return e.setHours(0,0,0,0),e});r.useEffect(()=>{B&&J(e=>{const t=new Date(f);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})},[f,B,U]);const Q=B?X:K,ee=B?3*U:7,ne=r.useMemo(()=>{if(!B)return Q;const e=new Date(Q);return e.setDate(e.getDate()-U),e},[Q,B,U]),[re,ae]=r.useState(null),[oe,le]=r.useState(null),[ie,de]=r.useState(null),ce=void 0===l?oe:l,ue=void 0===d?ie:d,he=e=>{i?i(e):le(e)},ge=e=>{c?c(e):de(e)},[me,pe]=r.useState(null),[fe,ve]=r.useState(!1),[ye,be]=r.useState(null),xe=r.useRef(null),[we,De]=r.useState(0),[Ee,Ce]=r.useState(!1),Te=r.useRef(null),ke=r.useRef(null),Se=r.useRef(null),Me=r.useRef(null),Ne=r.useRef(null),Ie=r.useRef({x:0,y:0}),Re=r.useRef(!1),He=r.useRef(0);r.useEffect(()=>{if(!B)return;const t=ke.current;if(!t)return;const n=e=>{Ie.current={x:e.touches[0].clientX,y:e.touches[0].clientY},Re.current=!1,He.current=0,Ce(!1)},r=e=>{if(Ee)return;const n=e.touches[0].clientX-Ie.current.x,r=e.touches[0].clientY-Ie.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))`;Se.current&&(Se.current.style.transition="none",Se.current.style.transform=o),Ne.current&&(Ne.current.style.transition="none",Ne.current.style.transform=o),He.current=a}},a=()=>{var n;if(!Re.current)return void(He.current=0);const r=He.current,a=((null===(n=Ne.current)||void 0===n?void 0:n.clientWidth)||t.clientWidth)/ee;r>100?(Ce(!0),De(a),setTimeout(()=>{const t=new Date(X);t.setDate(t.getDate()-1),J(t),e.setCurrentDate(t),De(0),He.current=0,Ce(!1)},300)):r<-100?(Ce(!0),De(-a),setTimeout(()=>{const t=new Date(X);t.setDate(t.getDate()+1),J(t),e.setCurrentDate(t),De(0),He.current=0,Ce(!1)},300)):(Ce(!0),De(0),He.current=0,setTimeout(()=>{Ce(!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)}},[B,e,Q,Ee,U,ee]);const Ae=r.useMemo(()=>((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=w(e.start);n.setHours(0,0,0,0);const a=w(e.end);return a.setHours(23,59,59,999),a>=t&&n<=r}).map(e=>{const r=w(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})})})(v,ne,ee),[v,ne,ee]),Oe=r.useRef(e.state.highlightedEventId);r.useEffect(()=>{if(e.state.highlightedEventId!==Oe.current)if(e.state.highlightedEventId){he(e.state.highlightedEventId);const t=Ae.find(t=>t.id===e.state.highlightedEventId);if(t&&!t.allDay){const e=S(t.start),n=ke.current;if(n){const t=(e-L)*P;requestAnimationFrame(()=>{n.scrollTo({top:Math.max(0,t-100),behavior:"smooth"})})}}}else he(null);Oe.current=e.state.highlightedEventId},[e.state.highlightedEventId,Ae,L,P]);const Pe=r.useMemo(()=>((e,t,n=7)=>{const r=tr(e,t,n).filter(e=>e.event.allDay);r.sort((e,t)=>{const n=w(e.event.start).getTime(),r=w(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})(Ae,ne,ee),[Ae,ne,ee]),Le=r.useMemo(()=>{const e=B?Pe.filter(e=>e.endDayIndex>=U&&e.startDayIndex<=2*U-1):Pe;if(0===e.length)return j;const t=Math.max(...e.map(e=>e.row));return j+t*j},[Pe,j,B,U]),$e=r.useMemo(()=>((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=nr(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,l=Object.assign(Object.assign({},e),{start:b(M(q(t,a),n.startHour)),end:b(M(q(t,a),r)),day:a});o.push(l)}}else e.day===a&&o.push(e)});const l=Jr.calculateDayEventLayouts(o,{viewType:"week"});r.set(a,l)}return r})(Ae,ne,ee),[Ae,ne,ee]),{handleMoveStart:je,handleCreateStart:Ye,handleResizeStart:Fe,handleCreateAllDayEvent:Ve,dragState:_e,isDragging:ze}=aa(e,{calendarRef:o,allDayRowRef:R?Te:void 0,timeGridRef:D,viewType:exports.ViewType.WEEK,onEventsUpdate:(t,n,r)=>{const a=t(Ae),o=new Set(a.map(e=>e.id)),l=Ae.filter(e=>!o.has(e.id)),i=new Set(Ae.map(e=>e.id)),s=a.filter(e=>!i.has(e.id)),d=a.filter(e=>{if(!i.has(e.id))return!1;const t=Ae.find(t=>t.id===e.id);return t&&te(t,e)});e.applyEventsChanges({delete:l.map(e=>e.id),add:s,update:d.map(e=>({id:e.id,updates:e}))},n,r)},onEventCreate:t=>{x?(be(t),ve(!0)):(e.addEvent(t),pe(t.id))},onEventEdit:()=>{},currentWeekStart:ne,events:Ae,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:b(a),end:b(o),calendarId:"blue",allDay:!1},i=[...r.filter(t=>t.day===e&&!t.allDay),l];return Jr.calculateDayEventLayouts(i,{viewType:"week"}).get("-1")||null})(e,t,n,Ae),calculateDragLayout:(e,t,n,r)=>((e,t,n,r,a)=>{const o=a.map(a=>{if(a.id!==e.id)return a;const o=w(a.start),l=M(o,n),i=M(o,r),s=b(l),d=b(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:Jr.calculateDayEventLayouts(o,{viewType:"week"}).get(e.id)||null})(e,t,n,r,Ae),TIME_COLUMN_WIDTH:O,isMobile:x,gridWidth:G,displayDays:ee}),{handleDrop:We,handleDragOver:Ue}=ta({app:e,onEventCreated:e=>{pe(e.id)}}),Be=r.useMemo(()=>B?Array.from({length:ee},(e,t)=>{const n=new Date(ne);return n.setDate(n.getDate()+t),n.toLocaleDateString(m,{weekday:"short"})}):g(m,"short",Z),[m,g,B,ne,ee,Z]),Ze=r.useMemo(()=>{if(!x)return[];const e=m.split("-")[0].toLowerCase();return"zh"===e||"ja"===e?g(m,"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)})},[x,m,g,Be]),Ge=r.useMemo(()=>h("allDay"),[h]),Ke=Array.from({length:24},(e,t)=>({hour:t+L,label:F(t+L,0,H)})),qe=r.useMemo(()=>A?z(Ke,A,H):void 0,[A,H,L]),Xe=r.useMemo(()=>A?W(Intl.DateTimeFormat().resolvedOptions().timeZone):void 0,[A]),Je=r.useMemo(()=>A?W(A):void 0,[A]),Qe=r.useMemo(()=>{const e=new Date;return e.setHours(0,0,0,0),Be.map((t,n)=>{const r=new Date(ne);r.setDate(ne.getDate()+n);const a=new Date(r);return a.setHours(0,0,0,0),{date:r.getDate(),month:r.toLocaleString(m,{month:"short"}),fullDate:new Date(r),isToday:a.getTime()===e.getTime()}})},[ne,Be,m]),tt=r.useMemo(()=>{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(m,{month:"short"}),fullDate:new Date(a),isToday:o.getTime()===e.getTime(),isCurrent:o.getTime()===new Date(f).setHours(0,0,0,0),dayName:a.toLocaleDateString(m,{weekday:"short"})}})},[K,m,f]);r.useEffect(()=>{if(!B)return Se.current&&(Se.current.style.transform="",Se.current.style.transition=""),void(Ne.current&&(Ne.current.style.transform="",Ne.current.style.transition=""));const e=Ee?"transform 0.3s ease-out":"none",t=`translateX(calc(calc(-100% / 3) + ${we}px))`;Se.current&&(Se.current.style.transition=e,Se.current.style.transform=t),Ne.current&&(Ne.current.style.transition=e,Ne.current.style.transform=t)},[we,Ee,B]);const rt=t=>{e.updateEvent(t.id,t)},at=t=>{e.deleteEvent(t)},ot=r.useMemo(()=>{const e=new Date;e.setHours(0,0,0,0);const t=new Date(ne);t.setHours(0,0,0,0);const n=new Date(t);return n.setDate(t.getDate()+ee),e>=t&&e<n},[ne,ee]);return r.useLayoutEffect(()=>{if(t.scrollToCurrentTime&&ke.current){const e=ke.current,t=new Date,n=t.getHours()+t.getMinutes()/60,r=e.clientHeight;e.scrollTop=Math.max(0,(n-L)*P-r/2)}},[]),r.useEffect(()=>{ae(new Date);const e=setInterval(()=>ae(new Date),6e4);return()=>clearInterval(e)},[]),se("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:[se(vr,{calendar:e,viewType:exports.ViewType.WEEK,currentDate:f,onPrevious:()=>{if(B){const t=new Date(f);t.setDate(t.getDate()-1),J(e=>{const t=new Date(e);return t.setDate(t.getDate()-1),t}),e.setCurrentDate(t)}else e.goToPrevious()},onNext:()=>{if(B){const t=new Date(f);t.setDate(t.getDate()+1),J(e=>{const t=new Date(e);return t.setDate(t.getDate()+1),t}),e.setCurrentDate(t)}else e.goToNext()},onToday:()=>e.goToToday()}),se(ua,{app:e,weekDaysLabels:Be,mobileWeekDaysLabels:Ze,weekDates:Qe,fullWeekDates:tt,isSlidingView:B,mobilePageStart:X,currentWeekStart:ne,gridWidth:G,allDayAreaHeight:Le,organizedAllDaySegments:Pe,allDayLabelText:Ge,isMobile:x,isTouch:E,showAllDay:R,calendarRef:o,allDayRowRef:Te,topFrozenContentRef:Se,ALL_DAY_HEIGHT:j,HOUR_HEIGHT:P,FIRST_HOUR:L,dragState:_e,isDragging:ze,secondaryTimeSlots:qe,primaryTzLabel:Xe,secondaryTzLabel:Je,handleMoveStart:je,handleResizeStart:Fe,handleEventUpdate:rt,handleEventDelete:at,onDateChange:s,newlyCreatedEventId:me,setNewlyCreatedEventId:pe,selectedEventId:ce,setSelectedEventId:he,detailPanelEventId:ue,setDetailPanelEventId:ge,handleCreateAllDayEvent:Ve,handleDragOver:Ue,handleDrop:We,customDetailPanelContent:n,customEventDetailDialog:a}),se(ha,{app:e,timeSlots:Ke,weekDaysLabels:Be,currentWeekStart:ne,currentWeekEvents:Ae,eventLayouts:$e,gridWidth:G,isMobile:x,isSlidingView:B,isTouch:E,scrollerRef:ke,timeGridRef:D,leftFrozenContentRef:Me,swipeContentRef:Ne,calendarRef:o,handleScroll:e=>{const{scrollLeft:t}=e.currentTarget;if(Se.current){const e=B?"calc(-100% / 3)":"0px",n=B?`${we}px`:`-${t}px`;Se.current.style.transform=`translateX(calc(${e} + ${n}))`,Se.current.style.transition=B&&Ee?"transform 0.3s ease-out":"none"}},handleCreateStart:Ye,handleTouchStart:(e,t,n)=>{if(!x&&!E)return;const r=e.touches[0],a=r.clientX,o=r.clientY,l=e.currentTarget;xe.current=setTimeout(()=>{null==Ye||Ye({preventDefault:()=>{},stopPropagation:()=>{},touches:[{clientX:a,clientY:o}],changedTouches:[{clientX:a,clientY:o}],target:l,currentTarget:l,cancelable:!0},t,n)},500)},handleTouchEnd:()=>{xe.current&&(clearTimeout(xe.current),xe.current=null)},handleTouchMove:()=>{xe.current&&(clearTimeout(xe.current),xe.current=null)},handleDragOver:Ue,handleDrop:We,dragState:_e,isDragging:ze,handleMoveStart:je,handleResizeStart:Fe,handleEventUpdate:rt,handleEventDelete:at,onDateChange:s,newlyCreatedEventId:me,setNewlyCreatedEventId:pe,selectedEventId:ce,setSelectedEventId:he,detailPanelEventId:ue,setDetailPanelEventId:ge,customDetailPanelContent:n,customEventDetailDialog:a,isCurrentWeek:ot,currentTime:re,HOUR_HEIGHT:P,FIRST_HOUR:L,LAST_HOUR:$,showStartOfDayLabel:Y,timeFormat:H,secondaryTimeSlots:qe}),se(V,{isOpen:fe,onClose:()=>{ve(!1),be(null)},onSave:t=>{v.some(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),ve(!1),be(null)},draftEvent:ye,app:e,timeFormat:H})]})},ma={showWeekends:!0,showAllDay:!0,startOfWeek:1,scrollToCurrentTime:!0,hourHeight:72,firstHour:0,lastHour:24,allDayHeight:28,timeFormat:"24h"},pa=(e={})=>{const n=Object.assign(Object.assign({},ma),e),r=e=>t.h(la,{viewType:exports.ViewType.WEEK,originalComponent:ga,app:e.app,config:n,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 r.displayName="WeekViewAdapter",{type:exports.ViewType.WEEK,component:r,config:n}},fa=n.memo(({currentMonth:t,currentYear:n,newlyCreatedEventId:a,screenSize:o,isScrolling:l,isDragging:i,showWeekNumbers:s,showMonthIndicator:d=!0,item:c,weekHeight:u,events:h,dragState:g,calendarRef:m,onEventUpdate:p,onEventDelete:f,onMoveStart:v,onCreateStart:y,onResizeStart:b,onDetailPanelOpen:x,onMoreEventsClick:D,onChangeView:E,onSelectDate:C,selectedEventId:T,onEventSelect:k,onEventLongPress:M,detailPanelEventId:I,onDetailPanelToggle:R,customDetailPanelContent:H,customEventDetailDialog:A,onCalendarDrop:O,onCalendarDragOver:P,app:L,enableTouch:$})=>{const{t:j,locale:Y}=nt(),[F,V]=r.useState(!1),_=r.useRef(null),z=r.useRef(null),W=r.useRef(null),[U,B]=r.useState(null),Z=r.useMemo(()=>{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]);r.useEffect(()=>l?(V(!0),_.current&&(clearTimeout(_.current),_.current=null),()=>{_.current&&(clearTimeout(_.current),_.current=null)}):F?(_.current=setTimeout(()=>{V(!1),_.current=null},100),()=>{_.current&&(clearTimeout(_.current),_.current=null)}):void 0,[l,F]);const{weekData:G}=c,K=G.days.find(e=>1===e.day),q=`${u}px`,X=r.useMemo(()=>Me(),[]),J=r.useMemo(()=>tr(h,G.startDate),[h,G.startDate]),Q=r.useMemo(()=>((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 ae.warn("Event missing start or end date:",t);const o=w(t.start),l=w(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(let a=o.getTime();a<=s.getTime();a+=864e5){const o=new Date(a);if(o<n)continue;const l=e.Temporal.PlainDate.from({year:o.getFullYear(),month:o.getMonth()+1,day:o.getDate()});r.push(Object.assign(Object.assign({},t),{start:l,end:l,day:i.getDay()}))}}else r.push(Object.assign(Object.assign({},t),{start:t.start,end:t.end,day:o.getDay()}))}),r})(h,G.startDate),[h,G.startDate]),ee=r.useMemo(()=>{const e=new Map;return G.days.forEach(t=>{const n=t.date.toDateString();e.set(n,Q.filter(e=>{if(!e.start||!e.end)return w(e.start).toDateString()===n;const t=w(e.start),r=w(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},[Q,G.days]),te=r.useMemo(()=>(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,l=!(e.endDayIndex<a.startDayIndex||e.startDayIndex>a.endDayIndex);if(n&&l){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})(J),[J]),ne=r.useMemo(()=>te.flat(),[te]),re=r.useMemo(()=>{const e=Array.from({length:7}).fill(0);return te.forEach((t,n)=>{t.forEach(t=>{for(let r=t.startDayIndex;r<=t.endDayIndex;r++)e[r]=Math.max(e[r],n+1)})}),e},[te]),oe=r.useMemo(()=>{const e=Array.from({length:7},()=>new Set);return te.forEach((t,n)=>{t.forEach(t=>{for(let r=t.startDayIndex;r<=t.endDayIndex;r++)r>=0&&r<7&&e[r].add(n)})}),e},[te]),le=r.useMemo(()=>{var e;for(let t=0;t<G.days.length;t++){const n=G.days[t],r=(null!==(e=ee.get(n.date.toDateString()))&&void 0!==e?e:[]).filter(e=>{if(!e.allDay)return!0;return!ne.some(t=>t.originalEventId===e.id)}),a=oe[t],o=re[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)>Z.maxSlots)return Z.maxSlotsWithMore}return Z.maxSlots},[G.days,ee,ne,re,oe,Z.maxSlots,Z.maxSlotsWithMore]),ie=r.useMemo(()=>Math.max(0,17*te.length),[te]),de=(e,r)=>{var l,d;const c=e.date.toLocaleDateString(Y,{month:Y.startsWith("zh")||Y.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:S(e.start)-S(t.start)))(null!==(l=ee.get(e.date.toDateString()))&&void 0!==l?l:[]),h=u.filter(e=>{if(!e.allDay)return!0;return!ne.some(t=>t.originalEventId===e.id)}),w=oe[r],F=(null!==(d=re[r])&&void 0!==d?d:0)-1,V=[];for(let e=0;e<=F;e++)w.has(e)||V.push(e);const _=h.length,U=Math.max(0,_-V.length),G=Math.max(F+1,0)+U,K=G>Z.maxSlots,J=K?Z.maxSlotsWithMore:Z.maxSlots,Q=V.filter(e=>e<J).length,te=Math.max(0,J-Math.max(F+1,0)),ae=Math.min(_,Q+te),le=h.slice(0,ae),ie=_-ae,de=[];let ce=0;const ue=Math.min(J,G);for(let t=0;t<ue;t++)if(w.has(t))de.push(se("div",{className:"shrink-0",style:{height:"17px",minHeight:"17px"}},`placeholder-layer-${t}-${e.date.getTime()}`));else if(ce<le.length){const e=le[ce];de.push(se(pr,{event:e,isAllDay:!!e.allDay,viewType:exports.ViewType.MONTH,isBeingDragged:i&&g.eventId===e.id&&"move"===g.mode,calendarRef:m,hourHeight:72,firstHour:0,onEventUpdate:p,onEventDelete:f,onMoveStart:v,onResizeStart:b,onDetailPanelOpen:x,onEventSelect:k,onEventLongPress:M,newlyCreatedEventId:a,selectedEventId:T,detailPanelEventId:I,onDetailPanelToggle:R,customDetailPanelContent:H,customEventDetailDialog:A,app:L,isMobile:"desktop"!==o,enableTouch:$},`${e.id}-${e.day}-${S(e.start)}-${ce}`)),ce++}return se("div",{className:Pt("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===r?X?"last:border-r":"border-r-0":""),style:{height:q},"data-date":(he=e.date,`${he.getFullYear()}-${String(he.getMonth()+1).padStart(2,"0")}-${String(he.getDate()).padStart(2,"0")}`),onClick:()=>null==C?void 0:C(e.date),onDblClick:t=>null==y?void 0:y(t,e.date),onTouchStart:t=>{if("mobile"!==o&&!$)return;const n=t.touches[0],r=n.clientX,a=n.clientY;W.current={x:r,y:a},z.current=setTimeout(()=>{null==y||y(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"!==o&&B({x:e.clientX,y:e.clientY,date:t})})(t,e.date),children:[se("div",{className:"df-month-date-number-container flex items-center justify-end text-right px-2 h-[33px] relative z-20",children:[s&&0===r&&"mobile"!==o&&se("span",{className:"mr-auto ml-1 text-[10px] font-medium text-gray-400 dark:text-gray-500",children:N(e.date)}),se("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"===o?e.date.toLocaleDateString(Y,{month:"short",day:"numeric"}):e.day})]}),se("div",{className:"flex-1 overflow-hidden px-1",children:[de,K&&se("div",{className:Pt("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"===o?"text-left font-normal":"text-center font-medium"),onClick:t=>{t.stopPropagation(),D?D(e.date):(null==C||C(e.date),null==E||E(exports.ViewType.DAY))},children:["+",ie,"desktop"===o?` ${j("more")}`:""]})]})]},`day-${e.date.getTime()}`);var he},ce=r.useMemo(()=>K?K.date.toLocaleDateString(Y,{month:"long",year:"numeric"}):"",[K,Y]);return se("div",{className:"relative border-b border-gray-200 select-none dark:border-gray-700",style:{height:q},children:[d&&K&&se("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 ${F?"pointer-events-auto opacity-100":"pointer-events-none opacity-0"} `,style:{transition:"opacity 0.5s ease",maxWidth:"fit-content"},onContextMenu:e=>e.preventDefault(),children:se("span",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:ce})}),se("div",{className:"flex h-full flex-col",children:se("div",{className:"calendar-week relative h-full",children:[se("div",{className:"grid h-full grid-cols-7",children:G.days.map((e,t)=>de(e,t))}),te.length>0&&se("div",{className:"pointer-events-none absolute right-0 left-0",style:{top:"33px",height:`${ie}px`,zIndex:10},children:te.slice(0,le).map((e,t)=>se("div",{className:"absolute inset-0",children:e.map(e=>se(pr,{event:e.event,isAllDay:!0,segment:e,segmentIndex:t,viewType:exports.ViewType.MONTH,isMultiDay:!0,calendarRef:m,hourHeight:72,firstHour:0,onEventUpdate:p,onEventDelete:f,onMoveStart:v,onResizeStart:b,isBeingDragged:i&&g.eventId===e.event.id&&"move"===g.mode,isBeingResized:i&&g.eventId===e.event.id&&"resize"===g.mode,newlyCreatedEventId:a,onDetailPanelOpen:x,selectedEventId:T,onEventSelect:k,onEventLongPress:M,detailPanelEventId:I,onDetailPanelToggle:R,customDetailPanelContent:H,customEventDetailDialog:A,app:L,isMobile:"desktop"!==o,enableTouch:$},e.id))},`layer-${t}`))})]})}),U&&se(Jn,{x:U.x,y:U.y,date:U.date,viewType:exports.ViewType.MONTH,onClose:()=>B(null),app:L,onCreateEvent:()=>{if(y){const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:U.x,clientY:U.y};y(e,U.date)}}})]})});fa.displayName="WeekComponent";const va=({app:e,config:t,customDetailPanelContent:n,customEventDetailDialog:a,calendarRef:o,selectedEventId:l,onEventSelect:i,detailPanelEventId:s,onDetailPanelToggle:d})=>{var c;const{getWeekDaysLabels:g,getMonthLabels:m,locale:p}=nt(),f=e.getCurrentDate(),v=e.getEvents(),y=null!==(c=t.startOfWeek)&&void 0!==c?c:1,b=e.getCalendars().map(e=>e.id+e.colors.lineColor).join("-"),x=r.useRef(null),D=r.useMemo(()=>{const e=x.current;return e&&e.length===v.length&&e.every((e,t)=>e===v[t])?e:(x.current=v,v)},[v]),E=r.useMemo(()=>{const e=new Map,t=e=>{const t=new Date(e);t.setHours(0,0,0,0);const n=(t.getDay()-y+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 D.forEach(e=>{if(!e.start)return;const r=w(e.start),a=e.end?w(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},[D,y]),{screenSize:C}=et(),[T,k]=r.useState(!1);r.useEffect(()=>{k("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const S=e.getCustomMobileEventRenderer()||On,[M,N]=r.useState(119),[I,R]=r.useState(!1),H=r.useRef(M),A=r.useRef([]),[O,P]=r.useState(null),[L,$]=r.useState(!1),[j,Y]=r.useState(null),[F,V]=r.useState(null),[_,z]=r.useState(null),W=void 0===l?F:l,U=void 0===s?_:s,B=r.useCallback(e=>{i?i(e):V(e)},[i]),K=r.useCallback(e=>{d?d(e):z(e)},[d]),q=r.useRef(e.state.highlightedEventId);r.useEffect(()=>{e.state.highlightedEventId?B(e.state.highlightedEventId):q.current&&B(null),q.current=e.state.highlightedEventId},[e.state.highlightedEventId]);const X=r.useMemo(()=>{const e=(f.getDay()-y+7)%7,t=new Date(f);return t.setDate(f.getDate()-e),t.setHours(0,0,0,0),t},[f,y]),{handleMoveStart:J,handleCreateStart:Q,handleResizeStart:ee,dragState:ne,isDragging:re}=aa(e,{calendarRef:o,viewType:exports.ViewType.MONTH,onEventsUpdate:(t,n,r)=>{const a=t(D),o=new Set(a.map(e=>e.id)),l=D.filter(e=>!o.has(e.id)),i=new Set(D.map(e=>e.id)),s=a.filter(e=>!i.has(e.id)),d=a.filter(e=>{if(!i.has(e.id))return!1;const t=D.find(t=>t.id===e.id);return t&&te(t,e)});e.applyEventsChanges({delete:l.map(e=>e.id),add:s,update:d.map(e=>({id:e.id,updates:e}))},n,r)},onEventCreate:t=>{"desktop"===C?e.addEvent(t):(Y(t),$(!0))},onEventEdit:e=>{P(e.id)},currentWeekStart:X,events:D}),{handleDrop:ae,handleDragOver:oe}=ta({app:e,onEventCreated:e=>{P(e.id)}}),le=r.useMemo(()=>g(p,"short",y),[p,g,y]),{currentMonth:ie,currentYear:de,isScrolling:ce,virtualData:ue,weeksData:he,scrollElementRef:ge,isNavigating:me,handleScroll:pe,handlePreviousMonth:fe,handleNextMonth:ve,handleToday:ye,setScrollTop:be}=(({currentDate:e,weekHeight:t,onCurrentMonthChange:n,initialWeeksToLoad:a=104,locale:o="en-US",startOfWeek:l=1,isEnabled:i=!0})=>{const s=r.useRef(null),d=r.useCallback((e,t)=>{const n=new Date(t,e,1),r=o.startsWith("zh")||o.startsWith("ja");return n.toLocaleDateString(o,{month:r?"short":"long"})},[o]),c=r.useMemo(()=>{const t=new Date(e);return t.setDate(1),t.setHours(0,0,0,0),G(t,a,l)},[e,a,l]),g=r.useMemo(()=>{const n=new Date(e);n.setDate(1),n.setHours(0,0,0,0);const r=c.findIndex(e=>e.days.some(e=>e.date.toDateString()===n.toDateString()));return r>0?r*t:0},[c,e,t]),[m,p]=r.useState(g),[f,v]=r.useState(600),[y,b]=r.useState(d(e.getMonth(),e.getFullYear())),[x,w]=r.useState(e.getFullYear()),[D,E]=r.useState(!1),[C,T]=r.useState(c),[k,S]=r.useState(!1),M=r.useRef(!1),[N,I]=r.useState(!1),R=r.useRef(e),H=r.useRef(null),A=r.useRef(null),O=r.useRef(new h),P=r.useRef(0),L=r.useRef(0),$=r.useRef(!1),j=r.useCallback(e=>{e&&(H.current=e)},[]),Y=r.useCallback(e=>{let t=O.current.get(e);return t||(t=Z(e),O.current.set(e,t)),t},[]),F=r.useCallback((e,n=26)=>{$.current||($.current=!0,setTimeout(()=>{try{if("future"===e){const e=C.at(-1),t=[];for(let r=1;r<=n;r++){const n=new Date(e.startDate);n.setDate(n.getDate()+7*r),t.push(Y(n))}T(e=>[...e,...t])}else{const e=C[0],r=[];for(let t=n;t>=1;t--){const n=new Date(e.startDate);n.setDate(n.getDate()-7*t),r.push(Y(n))}const a=r.length*t;T(e=>[...r,...e]),requestAnimationFrame(()=>{p(e=>e+a),H.current&&(H.current.scrollTop+=a)})}}finally{setTimeout(()=>{$.current=!1},200)}},0))},[C,Y,t]),V=r.useMemo(()=>{const e=C.length*t,n=Math.floor(m/t);let r=Math.max(0,n);r=Math.min(r,Math.max(0,C.length-6));const a=Math.min(C.length-1,r+6-1),o=Math.max(0,r-15),l=Math.min(C.length-1,a+15),i=[];for(let e=o;e<=l;e++)i.push({index:e,weekData:C[e],top:e*t,height:t});return{totalHeight:e,visibleItems:i,displayStartIndex:r}},[m,f,t,C]),_=r.useCallback(e=>{if(k||D||0===e.length||!N)return;const t=m+f/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=`${d(e.month,e.year)}-${e.year}`;a[t]=(a[t]||0)+1});let o="",l=0,i=0;Object.entries(a).forEach(([e,t])=>{if(t>i){i=t;const[n,r]=e.split("-");o=n,l=Number.parseInt(r,10)}}),o&&l&&(s.current?o===s.current.month&&l===s.current.year&&(s.current=null,o===y&&l===x||(b(o),w(l),null==n||n(o,l))):o===y&&l===x||(b(o),w(l),null==n||n(o,l)))},[f,y,x,k,D,n,m,N]),z=r.useCallback(e=>{const n=performance.now();if(n-P.current<u.SCROLL_THROTTLE)return;P.current=n;const r=e.currentTarget,a=r.scrollTop;L.current=a,p(a),k||requestAnimationFrame(()=>{const{scrollHeight:e,clientHeight:n}=r;a+n>e-10*t&&!$.current&&F("future",26),a<10*t&&!$.current&&F("past",26)}),E(!0),A.current&&clearTimeout(A.current),A.current=setTimeout(()=>{E(!1)},u.SCROLL_DEBOUNCE)},[t,F,k]),W=r.useCallback((e,n=!0)=>{if(!H.current)return;S(!0),M.current=!0;const r=()=>{setTimeout(()=>{S(!1),M.current=!1},n?500:200)},a=C.findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(-1!==a){const e=a*t;return H.current.scrollTo({top:e,behavior:n?"smooth":"auto"}),void r()}const o=(e.getDay()-l+7)%7,i=new Date(e);i.setDate(e.getDate()-o),i.setHours(0,0,0,0);const s=C[0],d=C.at(-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(Y(t))}const o=a.length*t;T(e=>[...a,...e]),requestAnimationFrame(()=>{const l=[...a,...C].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(H.current&&-1!==l){const e=l*t;H.current.scrollTop+=o,p(e=>e+o),setTimeout(()=>{H.current&&H.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(Y(t))}T(e=>[...e,...a]),requestAnimationFrame(()=>{const o=[...C,...a].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(H.current&&-1!==o){const e=o*t;H.current.scrollTo({top:e,behavior:n?"smooth":"auto"})}r()})}else r()},[C,t,Y]),U=r.useCallback(()=>{const e=C[V.displayStartIndex].days[0].date,t=new Date(e.getFullYear(),e.getMonth()-1,1);W(t)},[V.displayStartIndex,C,W]),B=r.useCallback(()=>{const e=C[V.displayStartIndex].days[0].date,t=new Date(e.getFullYear(),e.getMonth()+1,1);W(t)},[V.displayStartIndex,C,W]),K=r.useCallback(()=>{const e=new Date,r=d(e.getMonth(),e.getFullYear()),a=e.getFullYear(),o=new Date(a,e.getMonth(),1);s.current={month:r,year:a},b(r),w(a),null==n||n(r,a);const l=C.findIndex(e=>e.days.some(e=>e.date.toDateString()===o.toDateString()));if(-1===l)S(!0),M.current=!0,requestAnimationFrame(()=>{W(o,!0),setTimeout(()=>{M.current=!1,S(!1)},200)});else{const e=l*t,n=H.current;n&&(S(!0),M.current=!0,requestAnimationFrame(()=>{p(e),requestAnimationFrame(()=>{n&&(n.scrollTop=e,setTimeout(()=>{M.current=!1,S(!1)},200))})}))}},[C,t,n,W]);return r.useEffect(()=>{_(V.visibleItems)},[V.visibleItems,_]),r.useEffect(()=>{const t=R.current,r=t.getMonth(),a=t.getFullYear(),o=e.getMonth(),l=e.getFullYear();if(r!==o||a!==l){const t=6,r=V.displayStartIndex,a=Math.min(C.length-1,r+t-1);let i=!1;for(let t=r;t<=a;t++){const n=C[t];if(n&&n.days.some(t=>t.date.toDateString()===e.toDateString())){i=!0;break}}if(!i){const e=new Date(l,o,1),t=d(o,l);s.current={month:t,year:l},b(t),w(l),null==n||n(t,l),W(e,!0)}}R.current=e},[e,n,W,V,C,d]),r.useEffect(()=>{const e=H.current;if(!e)return;const t=new ResizeObserver(([e])=>{v(e.contentRect.height)});return t.observe(e),()=>t.disconnect()},[]),r.useEffect(()=>{const e=H.current;e&&!N&&i&&requestAnimationFrame(()=>{e&&g>0?(e.scrollTop=g,p(g),I(!0)):e&&I(!0)})},[N,g,i]),r.useEffect(()=>()=>{A.current&&clearTimeout(A.current)},[]),{scrollTop:m,containerHeight:f,currentMonth:y,currentYear:x,isScrolling:D,isNavigating:k,virtualData:V,scrollElementRef:H,handleScroll:z,scrollToDate:W,handlePreviousMonth:U,handleNextMonth:B,handleToday:K,setScrollTop:p,setContainerHeight:v,setCurrentMonth:b,setCurrentYear:w,setIsScrolling:E,cache:O.current,scrollElementRefCallback:j,weeksData:C}})({currentDate:f,weekHeight:M,onCurrentMonthChange:(t,n)=>{const r=p.startsWith("zh")||p.startsWith("ja"),a=m(p,r?"short":"long").indexOf(t);a>=0&&e.setVisibleMonth(new Date(n,a,1))},initialWeeksToLoad:156,locale:p,startOfWeek:y,isEnabled:I}),xe=r.useRef(0),[we,De]=r.useState(0),Ee=r.useMemo(()=>we-6*M,[we,M]),{visibleWeeks:Ce,startIndex:Te}=r.useMemo(()=>{var e,t;const{visibleItems:n,displayStartIndex:r}=ue,a=n.findIndex(e=>e.index===r);if(-1===a)return A.current.length>0?{visibleWeeks:A.current,startIndex:xe.current}:{visibleWeeks:[],startIndex:r};const o=Math.max(0,a-2),l=n.slice(o,a+8),i=null!==(t=null===(e=n[o])||void 0===e?void 0:e.index)&&void 0!==t?t:r;return l.length>=6&&(A.current=l,xe.current=i),{visibleWeeks:l,startIndex:i}},[ue]),ke=r.useMemo(()=>Te*M,[Te,M]),Se=r.useRef(!0),Me=r.useRef(!1),Ne=((e,t)=>{const[n,a]=r.useState(e);return r.useEffect(()=>{const n=setTimeout(()=>{a(e)},t);return()=>{clearTimeout(n)}},[e,t]),n})(ue.displayStartIndex,250);r.useEffect(()=>{me&&(Me.current=!0)},[me]),r.useEffect(()=>{if(Se.current)return void(Se.current=!1);const t=he[Ne];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,he,Ne]);const Ie=r.useMemo(()=>{const e=ue.totalHeight,t=Te*M+Ce.length*M+Ee;return Math.max(0,e-t)},[ue.totalHeight,Te,M,Ee,Ce.length]);r.useEffect(()=>{const e=ge.current;if(!e)return;const t=new ResizeObserver(t=>{for(const n of t){const t=n.contentRect.height;if(De(t),t>0){const n=Math.max(80,Math.ceil(t/6));if(n!==H.current){const t=e.scrollTop;if(t>0){const r=Math.round(t/H.current)*n;e.scrollTop=r,be(r)}N(n),H.current=n}}}});return t.observe(e),()=>{t.disconnect()}},[ge,be]),r.useEffect(()=>{const e=window.innerHeight-150,t=Math.max(80,Math.ceil(e/6));N(t),H.current=t,R(!0)},[]);const Re=r.useCallback(t=>{e.updateEvent(t.id,t)},[e]),He=r.useCallback(t=>{e.deleteEvent(t)},[e]),Ae=t=>{e.changeView(t)},Oe=r.useCallback(()=>P(null),[]),Pe=r.useCallback(t=>{const n=e.getReadOnlyConfig().viewable;if(("desktop"!==C||T)&&t&&n){const e=D.find(e=>e.id===t);if(e)return Y(e),void $(!0)}B(t)},[C,T,D,B,e]),Le=r.useCallback(e=>{("desktop"!==C||T)&&B(e)},[C,T,B]);return se("div",{className:rt,children:[se(vr,{calendar:e,viewType:exports.ViewType.MONTH,currentDate:f,customTitle:p.startsWith("zh")||p.startsWith("ja")?`${de}年${ie}`:`${ie} ${de}`,onPrevious:()=>{e.goToPrevious(),fe()},onNext:()=>{e.goToNext(),ve()},onToday:()=>{e.goToToday(),ye()}}),se("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:se("div",{className:"grid grid-cols-7 px-2",children:le.map((e,t)=>se("div",{className:"text-right text-gray-500 dark:text-gray-400 text-sm py-2 pr-2 select-none",children:e},`${e}-${t}`))})}),se("div",{ref:ge,className:it,style:{overflow:"hidden auto",visibility:I?"visible":"hidden"},onScroll:pe,children:[se("div",{style:{height:ke}}),Ce.map((r,l)=>{var i;const s=null!==(i=E.get(r.weekData.startDate.getTime()))&&void 0!==i?i:[],d=5===l?Object.assign(Object.assign({},r),{height:r.height+Ee}):r,c=!(!1===t.showMonthIndicator||!r.weekData.days.some(e=>1===e.day))&&ce;return se(fa,{item:d,weekHeight:M,showWeekNumbers:t.showWeekNumbers,showMonthIndicator:t.showMonthIndicator,currentMonth:ie,currentYear:de,screenSize:C,isScrolling:c,calendarRef:o,events:s,onEventUpdate:Re,onEventDelete:He,onMoveStart:J,onCreateStart:Q,onResizeStart:ee,isDragging:re,dragState:ne,newlyCreatedEventId:O,onDetailPanelOpen:Oe,onMoreEventsClick:e.onMoreEventsClick,onChangeView:Ae,onSelectDate:e.selectDate,selectedEventId:W,onEventSelect:Pe,onEventLongPress:Le,detailPanelEventId:U,onDetailPanelToggle:K,customDetailPanelContent:n,customEventDetailDialog:a,onCalendarDrop:ae,onCalendarDragOver:oe,calendarSignature:b,app:e,enableTouch:T},`week-${r.weekData.startDate.getTime()}`)}),se("div",{style:{height:Ie}})]}),se(S,{isOpen:L,onClose:()=>{$(!1),Y(null)},onSave:t=>{D.some(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),$(!1),Y(null)},draftEvent:j,app:e})]})},ya={showWeekNumbers:!1,showMonthIndicator:!0,startOfWeek:1},ba=(e={})=>{const n=Object.assign(Object.assign({},ya),e),r=e=>t.h(la,{viewType:exports.ViewType.MONTH,originalComponent:va,app:e.app,config:n,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 r.displayName="MonthViewAdapter",{type:exports.ViewType.MONTH,component:r,config:n}};const xa=n.memo(({date:e,isToday:t,locale:n,onSelectDate:r,onCreateStart:a,onMoreEventsClick:o,moreCount:l=0,onContextMenu:i})=>{const{t:s}=nt(),d=e.getDate(),c=1===d,u=e.toLocaleDateString(n,{month:"short"}).toUpperCase();return se("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==i||i(t,e)},"data-date":`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,children:[se("div",{className:"flex h-6 shrink-0 items-center px-1 py-1",children:[c&&se("span",{className:"rounded-sm bg-primary px-1 py-0.5 text-[9px] leading-none font-bold text-primary-foreground",children:u}),se("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})]}),l>0&&se("div",{className:"absolute bottom-0.5 left-1 z-20",children:se("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:["+",l," ",s("more")]})})]})});xa.displayName="YearDayCell";const wa=n.memo(({rowDays:e,events:t,columnsPerRow:n,app:a,calendarRef:o,locale:l,isDragging:i,dragState:s,onMoveStart:d,onResizeStart:c,onCreateStart:u,selectedEventId:h,onEventSelect:g,onMoreEventsClick:m,newlyCreatedEventId:p,onDetailPanelOpen:f,detailPanelEventId:v,onDetailPanelToggle:y,customDetailPanelContent:b,customEventDetailDialog:x,onContextMenu:D})=>{const E=new Date;E.setHours(0,0,0,0);const C=(e,t)=>{e.preventDefault(),e.stopPropagation(),D({x:e.clientX,y:e.clientY,date:t})},T=r.useMemo(()=>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(),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=w(e.start),n=e.end?w(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=w(e.start).getTime(),r=e.end?w(e.end).getTime():n,a=w(t.start).getTime(),o=r-n,l=(t.end?w(t.end).getTime():a)-a;return o!==l?l-o:n-a});const s=[],d=[];return i.forEach(e=>{const a=w(e.start),i=e.end?w(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 p=Math.round((u-o)/864e5);g=p<t.length?p: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,v=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:v,visualRowIndex:y})}),s}(t,e,n),[t,e,n]),{visibleSegments:k,moreCounts:S}=r.useMemo(()=>{const t=Array.from({length:e.length}).fill(0);T.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 T.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}},[T,e.length]);return se("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()===E.getTime();return se(xa,{date:e,isToday:n,locale:l,onSelectDate:e=>{a.selectDate(e)},onCreateStart:u,onMoreEventsClick:m,moreCount:S[t],onContextMenu:C},e.getTime())}),se("div",{className:"pointer-events-none absolute inset-0",style:{top:26,bottom:0,left:0,right:0},onContextMenu:e=>e.preventDefault(),children:se("div",{className:"relative h-full w-full",children:k.map(e=>se("div",{className:"pointer-events-auto",children:se(pr,{event:e.event,isAllDay:!!e.event.allDay,viewType:exports.ViewType.YEAR,yearSegment:e,columnsPerRow:n,isBeingDragged:i&&s.eventId===e.event.id,selectedEventId:h,onMoveStart:d,onResizeStart:c,onEventSelect:g,onDetailPanelToggle:y,newlyCreatedEventId:p,onDetailPanelOpen:f,calendarRef:o,app:a,detailPanelEventId:v,customDetailPanelContent:b,customEventDetailDialog:x,firstHour:0,hourHeight:0,onEventUpdate:e=>a.updateEvent(e.id,e),onEventDelete:e=>a.deleteEvent(e)})},e.id))})})]})});wa.displayName="YearRowComponent";const Da=({app:t,calendarRef:n,customDetailPanelContent:a,customEventDetailDialog:o,config:l,selectedEventId:i,onEventSelect:s,detailPanelEventId:d,onDetailPanelToggle:c})=>{var u;const{t:h,locale:g}=nt(),m=t.getCurrentDate(),p=m.getFullYear(),f=t.getEvents(),v=r.useRef(null),[y,b]=r.useState(()=>"undefined"!=typeof window?Math.max(1,Math.floor(window.innerWidth/80)):7),[x,D]=r.useState(!1),[E,C]=r.useState(null),[T,k]=r.useState(null),S=void 0===i?E:i,M=void 0===d?T:d,N=e=>{s?s(e):C(e)},I=e=>{c?c(e):k(e)},[R,H]=r.useState(null),[A,O]=r.useState(null);r.useEffect(()=>{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]"),l=t.closest("[data-calendar-picker-dropdown]"),i=t.closest(".df-context-menu");n||r||a||o||l||i||(N(null),I(null),O(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const P=r.useRef(null);r.useEffect(()=>{const e=v.current;if(!e)return;const t=new ResizeObserver(e=>{P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{const t=e[0].contentRect.width,n=Math.floor(t/80);b(Math.max(1,n)),D(!0)},60)});return t.observe(e),()=>{t.disconnect(),P.current&&clearTimeout(P.current)}},[]);const L=r.useRef(t.state.highlightedEventId);r.useEffect(()=>{t.state.highlightedEventId?N(t.state.highlightedEventId):L.current&&N(null),L.current=t.state.highlightedEventId},[t.state.highlightedEventId]);const{handleMoveStart:$,handleResizeStart:j,handleCreateStart:Y,dragState:F,isDragging:V}=aa(t,{calendarRef:n,viewType:exports.ViewType.YEAR,onEventsUpdate:(e,n,r)=>{const a=e(f).filter(e=>{const t=f.find(t=>t.id===e.id);return t&&te(t,e)});a.length>0&&t.applyEventsChanges({update:a.map(e=>({id:e.id,updates:e}))},n,r)},currentWeekStart:new Date,events:f,onEventCreate:e=>{t.addEvent(e)},onEventEdit:e=>{H(e.id)}}),_=null!==(u=null==l?void 0:l.showTimedEventsInYearView)&&void 0!==u&&u,z=r.useCallback((n,r)=>{if(_)null==Y||Y(n,r);else{const n=e.Temporal.PlainDate.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate()}),a={id:`event-${Date.now()}`,title:h("newEvent")||"New Event",start:n,end:n,allDay:!0,calendarId:t.getCalendarRegistry().getDefaultCalendarId()||"default"};t.addEvent(a),H(a.id)}},[_,Y,t,h]),W=r.useMemo(()=>{const e=[],t=new Date(p,0,1),n=new Date(p,11,31);for(let r=t.getTime();r<=n.getTime();r+=864e5)e.push(new Date(r));return e},[p]),U=r.useMemo(()=>function(e,t){const n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}(W,y),[W,y]),B=r.useMemo(()=>{const e=new Date(p,0,1),t=new Date(p,11,31,23,59,59);return f.filter(n=>{if(!n.start)return!1;if(!_&&!n.allDay)return!1;const r=w(n.start),a=n.end?w(n.end):r;return r<=t&&a>=e})},[f,p,_]);return se("div",{className:rt,onContextMenu:e=>e.preventDefault(),children:[se(vr,{calendar:t,viewType:exports.ViewType.YEAR,currentDate:m,customTitle:g.startsWith("zh")||g.startsWith("ja")?`${p}年`:`${p}`,onPrevious:()=>{const e=new Date(m);e.setFullYear(e.getFullYear()-1),t.setCurrentDate(e)},onNext:()=>{const e=new Date(m);e.setFullYear(e.getFullYear()+1),t.setCurrentDate(e)},onToday:()=>{t.goToToday()}}),se("div",{ref:v,className:`${it} ${st}`,style:{overflow:"hidden auto"},children:se("div",{className:"flex w-full flex-col border-t border-l border-gray-100 dark:border-gray-800",style:{opacity:x?1:0,transition:"opacity 0.2s ease"},children:U.map((e,r)=>se(wa,{rowDays:e,events:B,columnsPerRow:y,app:t,calendarRef:n,locale:g,isDragging:V,dragState:F,onMoveStart:$,onResizeStart:j,onCreateStart:z,selectedEventId:S,onEventSelect:N,onMoreEventsClick:t.onMoreEventsClick,newlyCreatedEventId:R,onDetailPanelOpen:()=>H(null),detailPanelEventId:M,onDetailPanelToggle:I,customDetailPanelContent:a,customEventDetailDialog:o,onContextMenu:O},r))})}),A&&se(Jn,{x:A.x,y:A.y,date:A.date,viewType:exports.ViewType.YEAR,onClose:()=>O(null),app:t,onCreateEvent:()=>{if(A&&A.date){const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:A.x,clientY:A.y};z(e,A.date)}}})]})};function Ea(e,t,n,r=1){const a=new Date(n,t,1),o=new Date(n,t+1,0).getDate(),l=(a.getDay()-r+7)%7,i=a.getTime(),s=new Date(n,t,o,23,59,59,999).getTime(),d=e.filter(e=>{if(!e.start)return!1;const t=w(e.start),n=e.end?w(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>=i});d.sort((e,t)=>{const n=w(e.start).getTime(),r=e.end?w(e.end).getTime():n,a=w(t.start).getTime(),o=r-n,l=(t.end?w(t.end).getTime():a)-a;return o!==l?l-o:n-a});const c=[],u=[];d.forEach(e=>{const r=w(e.start),a=e.end?w(e.end):r,o=new Date(Math.max(r.getTime(),i)),d=new Date(Math.min(a.getTime(),s)),h=o.getDate(),g=d.getDate(),m=l+(h-1),p=l+(g-1),f=r.getMonth()===t&&r.getFullYear()===n,v=a.getMonth()===t&&a.getFullYear()===n;let y=0;for(;;){let e=!1;u[y]||(u[y]=[]);for(let t=m;t<=p;t++)if(u[y][t]){e=!0;break}if(!e){for(let e=m;e<=p;e++)u[y][e]=!0;break}y++}c.push({id:`${e.id}_month_${t}`,event:e,startCellIndex:m,endCellIndex:p,isFirstSegment:f,isLastSegment:v,visualRowIndex:y,monthIndex:t})});const h=c.length>0?Math.max(...c.map(e=>e.visualRowIndex)):-1;return{segments:c,maxVisualRow:h}}const Ca=({app:t,calendarRef:n,customDetailPanelContent:a,customEventDetailDialog:o,config:l,selectedEventId:i,onEventSelect:s,detailPanelEventId:d,onDetailPanelToggle:c})=>{var u,h;const{t:g,locale:m,getWeekDaysLabels:p}=nt(),f=t.getCurrentDate(),v=f.getFullYear(),y=t.getEvents(),b=new Date;b.setHours(0,0,0,0);const x=null!==(u=null==l?void 0:l.startOfWeek)&&void 0!==u?u:1,D=r.useRef(null),E=r.useRef(null),C=r.useRef(null),[T,k]=r.useState(0),[S,M]=r.useState(0),[N,I]=r.useState(null),[R,H]=r.useState(null),A=void 0===i?N:i,O=void 0===d?R:d,P=e=>{s?s(e):I(e)},L=e=>{c?c(e):H(e)},[$,j]=r.useState(null),[Y,F]=r.useState(null);r.useEffect(()=>{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||(P(null),L(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const V=r.useMemo(()=>{let e=0;for(let t=0;t<12;t++){const n=new Date(v,t,1),r=new Date(v,t+1,0).getDate(),a=(n.getDay()-x+7)%7+r;a>e&&(e=a)}return e},[v,x]),{handleMoveStart:_,handleResizeStart:z,handleCreateStart:W,dragState:U,isDragging:B}=aa(t,{calendarRef:n,viewType:exports.ViewType.YEAR,onEventsUpdate:(e,n,r)=>{const a=e(y).filter(e=>{const t=y.find(t=>t.id===e.id);return t&&te(t,e)});a.length>0&&t.applyEventsChanges({update:a.map(e=>({id:e.id,updates:e}))},n,r)},currentWeekStart:new Date,events:y,onEventCreate:e=>{t.addEvent(e)},onEventEdit:e=>{j(e.id)}}),Z=null!==(h=null==l?void 0:l.showTimedEventsInYearView)&&void 0!==h&&h,G=r.useCallback((n,r)=>{if(Z)null==W||W(n,r);else{const n=e.Temporal.PlainDate.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate()}),a={id:`event-${Date.now()}`,title:g("newEvent")||"New Event",start:n,end:n,allDay:!0};t.addEvent(a),j(a.id)}},[Z,W,t]),K=r.useMemo(()=>{const e=p(m,"short",x).map(e=>{if(m.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<V;n++)t.push(e[n%7]);return t},[m,p,V,x]),q=r.useMemo(()=>{const e=new Date(v,0,1),t=new Date(v,11,31,23,59,59);return y.filter(n=>{if(!n.start)return!1;if(!Z&&!n.allDay)return!1;const r=w(n.start),a=n.end?w(n.end):r;return r<=t&&a>=e})},[y,v,Z]),X=r.useMemo(()=>{const e=[];for(let t=0;t<12;t++){const n=new Date(v,t,1),r=new Date(v,t+1,0).getDate(),a=(n.getDay()-x+7)%7,o=[];for(let e=0;e<a;e++)o.push(null);for(let e=1;e<=r;e++)o.push(new Date(v,t,e));for(;o.length<V;)o.push(null);const l=n.toLocaleDateString(m,{month:"short"}),i=l.charAt(0).toUpperCase()+l.slice(1).toLowerCase(),{segments:s,maxVisualRow:d}=Ea(q,t,v,x),c=d+1,u=Math.max(60,20+18*c);e.push({monthIndex:t,monthName:i,days:o,eventSegments:s,minHeight:u})}return e},[v,m,V,q,x]),J=r.useCallback(e=>{const t=e.currentTarget;D.current&&(D.current.scrollLeft=t.scrollLeft),E.current&&(E.current.scrollTop=t.scrollTop)},[]);r.useEffect(()=>{const e=()=>{if(C.current){const e=C.current,t=e.offsetHeight-e.clientHeight,n=e.offsetWidth-e.clientWidth;M(e=>e===t?e:t),k(e=>e===n?e:n)}},t=C.current;if(!t)return;e();const n=new ResizeObserver(()=>{e()});return n.observe(t),()=>{n.disconnect()}},[X]);return se("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:[se("div",{className:"col-span-2",children:se(vr,{calendar:t,viewType:exports.ViewType.YEAR,currentDate:f,customTitle:m.startsWith("zh")||m.startsWith("ja")?`${v}年`:`${v}`,onPrevious:()=>{const e=new Date(f);e.setFullYear(e.getFullYear()-1),t.setCurrentDate(e)},onNext:()=>{const e=new Date(f);e.setFullYear(e.getFullYear()+1),t.setCurrentDate(e)},onToday:()=>{t.goToToday()}})}),se("div",{className:"z-30 border-r border-b border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900"}),se("div",{ref:D,className:"overflow-hidden border-b border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900",children:se("div",{className:"flex",style:{minWidth:`calc(1352px + ${T}px)`},children:[se("div",{className:"grid flex-1",style:{gridTemplateColumns:`repeat(${V}, minmax(0, 1fr))`,minWidth:"1352px"},children:K.map((e,t)=>{const n=(t+x)%7;return se("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}`)})}),T>0&&se("div",{className:"shrink-0 bg-gray-50 dark:bg-gray-900",style:{width:`${T}px`}})]})}),se("div",{ref:E,className:"overflow-hidden border-r border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-900",children:se("div",{className:"flex min-h-full flex-col",children:[X.map(e=>se("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)),S>0&&se("div",{className:"shrink-0 bg-white dark:bg-gray-900",style:{height:`${S}px`}})]})}),se("div",{ref:C,className:`overflow-auto ${st}`,onScroll:J,children:se("div",{className:"flex min-h-full flex-col",style:{minWidth:"1352px"},children:X.map(e=>se("div",{className:"relative shrink-0 grow",style:{minHeight:`${e.minHeight}px`},children:[se("div",{className:"absolute inset-0 z-0 grid",style:{gridTemplateColumns:`repeat(${V}, minmax(0, 1fr))`},children:e.days.map((n,r)=>{const a=(r+x)%7,o=0===a||6===a;if(!n)return se("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 l=(e=>e.getTime()===b.getTime())(n);return se("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=>G(e,n),onContextMenu:e=>((e,t)=>{e.preventDefault(),e.stopPropagation(),F({x:e.clientX,y:e.clientY,date:t})})(e,n),children:se("span",{className:`flex h-5 w-5 items-center justify-center rounded-full text-[10px] font-medium ${l?"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&&se("div",{className:"pointer-events-none absolute inset-0 z-20",style:{top:20},children:se("div",{className:"relative h-full w-full",children:e.eventSegments.map(e=>se("div",{className:"pointer-events-auto",children:se(pr,{event:e.event,isAllDay:!!e.event.allDay,viewType:exports.ViewType.YEAR,yearSegment:e,columnsPerRow:V,isBeingDragged:B&&U.eventId===e.event.id,selectedEventId:A,onMoveStart:_,onResizeStart:z,onEventSelect:P,onDetailPanelToggle:L,newlyCreatedEventId:$,onDetailPanelOpen:()=>j(null),calendarRef:n,app:t,detailPanelEventId:O,customDetailPanelContent:a,customEventDetailDialog:o,firstHour:0,hourHeight:0,onEventUpdate:e=>t.updateEvent(e.id,e),onEventDelete:e=>t.deleteEvent(e)})},e.id))})})]},e.monthIndex))})}),Y&&se(Jn,{x:Y.x,y:Y.y,date:Y.date,viewType:exports.ViewType.YEAR,onClose:()=>F(null),app:t,onCreateEvent:()=>{const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:Y.x,clientY:Y.y};G(e,Y.date)}})]})},Ta=e=>{var t;return se("fixed-week"===((null===(t=e.config)||void 0===t?void 0:t.mode)||"year-canvas")?Ca:Da,Object.assign({},e))},ka={startOfWeek:1};const Sa={enableAutoRecalculate:!0,enableValidation:!0,defaultEvents:[],maxEventsPerDay:50};function Ma(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}Object.defineProperty(exports,"createPortal",{enumerable:!0,get:function(){return n.createPortal}}),exports.BlossomColorPicker=pn,exports.CalendarApp=le,exports.CalendarRegistry=H,exports.CalendarRenderer=class{constructor(e,t){this.app=e,this.container=null,this.unsubscribe=null,this.renderRequested=!1,this.extraProps={},this.customRenderingStore=new Wn(t),t&&this.app.setOverrides(t),this.unsubscribe=e.subscribe(()=>this.requestRender())}setProps(e){re(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&&(t.render(null,this.container),this.container=null),this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null)}getCustomRenderingStore(){return this.customRenderingStore}render(){this.container&&t.render(t.h(hn.Provider,{value:this.customRenderingStore},t.h(zn,Object.assign({app:this.app},this.extraProps))),this.container)}},exports.Check=zt,exports.ChevronRight=$t,exports.ChevronsUpDown=Wt,exports.ContentSlot=mn,exports.ContextMenu=Un,exports.ContextMenuColorPicker=({selectedColor:e,onSelect:t,onCustomColor:n})=>{const{t:r}=nt();return se("div",{children:[se("div",{className:"grid grid-cols-7 gap-2 p-1 px-3",children:Xn.map(n=>se("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&&se("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")})]})},exports.ContextMenuItem=Bn,exports.ContextMenuLabel=({children:e})=>se("div",{className:"px-3 py-0.5 text-[12px] font-semibold text-slate-950 dark:text-slate-50",children:e}),exports.ContextMenuSeparator=Zn,exports.CreateCalendarDialog=yn,exports.CustomRenderingStore=Wn,exports.DefaultColorPicker=fn,exports.LAYOUT_CONFIG={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},exports.LOCALES=i,exports.LocaleContext=tt,exports.LocaleProvider=on,exports.MiniCalendar=Rn,exports.PanelRightClose=({className:e,width:t=24,height:n=24})=>se("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:[se("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),se("path",{d:"M15 3v18"}),se("path",{d:"m8 9 3 3-3 3"})]}),exports.PanelRightOpen=({className:e,width:t=24,height:n=24})=>se("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:[se("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),se("path",{d:"M15 3v18"}),se("path",{d:"m10 15-3-3 3-3"})]}),exports.Plus=Vt,exports.TIME_STEP=.25,exports.VIRTUAL_MONTH_SCROLL_CONFIG=u,exports.WeekDataCache=h,exports.addDays=function(e,t){const n=new Date(e);return n.setDate(n.getDate()+t),n},exports.buildParseRegExp=De,exports.calculateDayIndex=J,exports.calendarPickerDropdown=Tt,exports.cancelButton="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)",exports.capitalize=tn,exports.clipboardStore=je,exports.conditionalTheme=(e,t,n)=>e?t:n,exports.convertDateEvent=function(e,t,n,r,a=!1,o){return He(Object.assign({id:e,title:t,start:n,end:r,allDay:a},o))},exports.convertDateEventWithTimeZone=function(e,t,n,r,a,o){return Ae(Object.assign({id:e,title:t,start:n,end:r,timeZone:a},o))},exports.convertToDayFlowEvent=qe,exports.createAllDayEvent=function(e,t,n,r){return He(Object.assign({id:e,title:t,start:n,end:n,allDay:!0},r))},exports.createDateWithHour=M,exports.createDayView=sa,exports.createEvent=He,exports.createEventWithDate=(e,t)=>{var n,r;const a=q(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:X(a,o),end:X(a,o)})},exports.createEventWithPlainDateTime=(t,n)=>{var r,a;const o=q(n,null!==(r=t.day)&&void 0!==r?r:0);if(null!==(a=t.allDay)&&void 0!==a&&a){const n=e.Temporal.PlainDate.from({year:o.getFullYear(),month:o.getMonth()+1,day:o.getDate()});return Object.assign(Object.assign({},t),{start:n,end:n})}const l=e.Temporal.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:l,end:l})},exports.createEventWithRealDate=(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:X(a,o),end:X(a,o)})},exports.createEventWithZonedDateTime=(t,n,r)=>{var a,o;const l=q(n,null!==(a=t.day)&&void 0!==a?a:0);if(null!==(o=t.allDay)&&void 0!==o&&o){const n=e.Temporal.PlainDate.from({year:l.getFullYear(),month:l.getMonth()+1,day:l.getDate()});return Object.assign(Object.assign({},t),{start:n,end:n})}const i=e.Temporal.ZonedDateTime.from({year:l.getFullYear(),month:l.getMonth()+1,day:l.getDate(),hour:l.getHours(),minute:l.getMinutes(),second:l.getSeconds(),millisecond:l.getMilliseconds(),timeZone:r});return Object.assign(Object.assign({},t),{start:i,end:i})},exports.createEvents=function(e){return e.map(e=>He(e))},exports.createEventsPlugin=function(e={}){const t=Object.assign(Object.assign({},Sa),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=Ma(n.getCurrentDate()),t=Q(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 l=Object.assign(Object.assign({},o),a);if(t.enableValidation){const e=r.validateEvent(l);if(e.length>0)throw new Error(`Event validation failed: ${e.join(", ")}`)}if(n.updateEvent(e,a),t.enableAutoRecalculate){const e=Ma(n.getCurrentDate()),t=Q(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=w(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=w(n.start),a=w(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)=>Q(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}},exports.createMonthView=ba,exports.createStandardViews=function(e){return[sa(null==e?void 0:e.day),pa(null==e?void 0:e.week),ba(null==e?void 0:e.month)]},exports.createTemporalWithHour=D,exports.createTimedEvent=function(e,t,n,r,a){return He(Object.assign({id:e,title:t,start:n,end:r},a))},exports.createTimezoneEvent=Ae,exports.createTimezoneEvents=function(e){return e.map(e=>Ae(e))},exports.createWeekView=pa,exports.createYearView=(e={})=>{const n=Object.assign(Object.assign({},ka),e),r=e=>t.h(la,{viewType:exports.ViewType.YEAR,originalComponent:Ta,app:e.app,config:n,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 r.displayName="YearViewAdapter",{type:exports.ViewType.YEAR,component:r,config:n}},exports.dateToPlainDate=me,exports.dateToPlainDateTime=pe,exports.dateToZonedDateTime=fe,exports.daysBetween=function(t,n){const r=t=>{if(y(t))return t;if("function"==typeof t.toPlainDate)return t.toPlainDate();const n=t;return e.Temporal.PlainDate.from({year:n.year,month:n.month,day:n.day})},a=r(t),o=r(n);return a.until(o).days},exports.daysDifference=k,exports.downloadICS=function(e,t={}){const n=Je(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.append(l),l.click(),l.remove(),URL.revokeObjectURL(o)},exports.en=l,exports.escapeICSValue=ze,exports.extractHourFromDate=S,exports.extractHourFromTemporal=function(e){if(e instanceof Date)return e.getHours()+e.getMinutes()/60;if(ce(e))return 0;const t=e;return t.hour+t.minute/60},exports.extractVEvents=Ge,exports.foldLine=Ue,exports.formatDate=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}`},exports.formatDateConsistent=de,exports.formatDateToICSTimestamp=_e,exports.formatEventTimeRange=_,exports.formatICSDate=Ve,exports.formatMonthYear=e=>`${["January","February","March","April","May","June","July","August","September","October","November","December"][e.getMonth()]} ${e.getFullYear()}`,exports.formatProperty=Be,exports.formatTemporal=ke,exports.formatTime=F,exports.generateDayData=U,exports.generateICS=Je,exports.generateSecondaryTimeSlots=z,exports.generateUniKey=ne,exports.generateVEvent=Ze,exports.generateWeekData=Z,exports.generateWeekRange=G,exports.generateWeeksData=(e,t=3)=>{const n=5*t,{monday:r}=v(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(Z(t))}return a},exports.getAllDayEventsForDay=(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=w(t.start);a.setHours(0,0,0,0);const o=w(t.end);return o.setHours(0,0,0,0),r>=a&&r<=o}),exports.getCalendarColorsForHex=P,exports.getCurrentWeekDates=(e=1)=>{const t=new Date,n=new Date,r=(t.getDay()-e+7)%7;return m.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()}})},exports.getDateByDayIndex=q,exports.getDateObj=Oe,exports.getDayIndexByDate=(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)},exports.getEndOfDay=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(23,59,59,999),t}return T(e)},exports.getEndOfTemporal=T,exports.getEventBgColor=L,exports.getEventEndHour=V,exports.getEventTextColor=$,exports.getEventsForDay=K,exports.getEventsForWeek=(e,t)=>{const n=new Date(t);return n.setDate(t.getDate()+6),n.setHours(23,59,59,999),e.filter(e=>{const r=w(e.start);return r>=t&&r<=n}).map(e=>{const n=J(w(e.start),t);return Object.assign(Object.assign({},e),{day:n})})},exports.getIntlLabel=en,exports.getLineColor=Y,exports.getMonthLabels=rn,exports.getMonthYearOfWeek=B,exports.getPlainDate=ve,exports.getSearchHeaderInfo=Le,exports.getSelectedBgColor=j,exports.getStartOfDay=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(0,0,0,0),t}return C(e)},exports.getStartOfTemporal=C,exports.getTestEvents=function(){const t=new Date,n=t.getDay(),r=new Date(t),a=0===n?-6:1-n;return r.setDate(t.getDate()+a),r.setHours(0,0,0,0),[{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.Temporal.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()}),end:e.Temporal.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.Temporal.ZonedDateTime.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate(),hour:a,minute:o,timeZone:e.Temporal.Now.timeZoneId()}),end:e.Temporal.ZonedDateTime.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate(),hour:l,minute:i,timeZone:e.Temporal.Now.timeZoneId()}),allDay:!1,calendarId:t.calendarId,day:t.day}})},exports.getTimezoneDisplayLabel=W,exports.getWeekDaysLabels=nn,exports.getWeekNumber=N,exports.getWeekRange=v,exports.getZoneId=Ce,exports.groupSearchResults=$e,exports.hasEventChanged=te,exports.importICSFile=function(e,t){return a.__awaiter(this,void 0,void 0,function*(){try{const n=yield e.text();if(!n)throw new Error("File content is empty");return Xe(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}}})},exports.isDate=function(e){return e instanceof Date},exports.isDeepEqual=re,exports.isEventDeepEqual=ee,exports.isEventInWeek=(e,t)=>{const n=J(e,t);return n>=0&&n<=6},exports.isMultiDayEvent=(e,t)=>!I(e,t),exports.isMultiDayTemporalEvent=function(e,t){return!E(e,t)},exports.isPlainDate=ce,exports.isPlainDateTime=ue,exports.isSameDay=I,exports.isSamePlainDate=E,exports.isSameTemporal=function(e,t){if(e instanceof Date&&t instanceof Date)return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate();const n=ve(e),r=ve(t);return n.equals(r)},exports.isValidLocale=d,exports.isZonedDateTime=he,exports.mergeClasses=(...e)=>e.filter(Boolean).join(" "),exports.mergeFormatTemplate=xe,exports.monthNames=p,exports.normalizeCssWidth=function(e,t="240px"){return"number"==typeof e?`${e}px`:"string"==typeof e&&e.trim().length>0?e:t},exports.normalizeDate=Pe,exports.normalizeLocale=s,exports.normalizeToZoned=Te,exports.now=function(t=e.Temporal.Now.timeZoneId()){return e.Temporal.Now.zonedDateTimeISO(t)},exports.pad=be,exports.pad2=Ye,exports.parseICS=Xe,exports.parseICSDate=Fe,exports.parseTemporalString=Ee,exports.parseVEventLines=Ke,exports.plainDateTimeToDate=function(e){return new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second||0,e.millisecond||0)},exports.plainDateToDate=function(e){return new Date(e.year,e.month-1,e.day)},exports.recalculateEventDays=Q,exports.registerDragImplementation=function(e){na=e},exports.registerLocale=function(e){const t=e.code.split("-")[0].toLowerCase();i[t]=e},exports.registerSidebarImplementation=function(e){Yn=e},exports.resolveAppliedTheme=Ne,exports.roundToTimeStep=e=>.25*Math.round(e/.25),exports.scrollbarTakesSpace=Me,exports.setHourInTemporal=function(e,t){const n=Math.floor(t),r=Math.round(60*(t-n));return he(e),e.with({hour:n,minute:r,second:0,millisecond:0})},exports.shortMonthNames=f,exports.sidebarContainer="df-sidebar flex h-full flex-col border-r border-gray-200 dark:border-gray-700 bg-white dark:bg-slate-900",exports.sidebarHeader="df-sidebar-header flex items-center px-2 py-1",exports.sidebarHeaderTitle="df-sidebar-header-title text-sm font-semibold text-gray-700 dark:text-gray-200",exports.sidebarHeaderToggle="df-sidebar-header-toggle flex h-8 w-8 items-center justify-center rounded hover:bg-gray-100 dark:hover:bg-slate-800",exports.t=an,exports.temporalToDate=ge,exports.themeClasses={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"},exports.themeCn=(e,t,n)=>`${e} ${t} ${n.split(" ").filter(Boolean).map(e=>`dark:${e}`).join(" ")}`.trim(),exports.today=function(t=e.Temporal.Now.timeZoneId()){return e.Temporal.Now.plainDateISO(t)},exports.unescapeICSValue=We,exports.updateEventDateAndDay=(t,n,r)=>{const a=q(r,n);return Object.assign(Object.assign({},t),{day:n,start:t.allDay?e.Temporal.PlainDate.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate()}):e.Temporal.ZonedDateTime.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate(),hour:a.getHours(),minute:a.getMinutes(),timeZone:e.Temporal.Now.timeZoneId()}),end:t.allDay?e.Temporal.PlainDate.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate()}):e.Temporal.ZonedDateTime.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate(),hour:a.getHours(),minute:a.getMinutes(),timeZone:e.Temporal.Now.timeZoneId()})})},exports.updateEventWithRealDate=(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:X(a,o),end:X(a,o)})},exports.useDragForView=aa,exports.useLocale=nt,exports.useSidebarBridge=Vn,exports.weekDays=m,exports.weekDaysFullName=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],exports.zonedDateTimeToDate=x;
|