@dayflow/core 3.3.3 → 3.3.4

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/dist/index.js CHANGED
@@ -1 +1 @@
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}?\nDoing so will move all the events from {sourceName} to {targetName} and {sourceName} will be deleted.\nThis 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",subscribeCalendar:"Subscribe to Calendar",subscribeCalendarTitle:"Enter the URL of the calendar you want to subscribe to.",calendarUrl:"Calendar URL",calendarUrlPlaceholder:"https://example.com/calendar.ics",subscribe:"Subscribe",fetchingCalendar:"Fetching calendar...",subscribeError:"Failed to fetch calendar. Please check the URL and try again."}},s={en:l};function i(e){const t=e.split("-")[0].toLowerCase();return t in s?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(),s=a.getMonth()+1,i=a.getDate();return t.map(t=>{try{const a=t.hour%24,d=e.Temporal.ZonedDateTime.from({year:l,month:s,day:i,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 s=new Date(l);s.setDate(s.getDate()-7*a);for(let e=0;e<t;e++){const t=new Date(s);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),s=new Date(a);s.setDate(s.getDate()+7),this.emitVisibleRange(l,s,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),s=new Date(l),i=new Date(l);i.setDate(i.getDate()+42),this.emitVisibleRange(s,i,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 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)?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)}void 0!==e.allDaySortComparator&&e.allDaySortComparator!==this.state.allDaySortComparator&&(this.state.allDaySortComparator=e.allDaySortComparator,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:[],allDaySortComparator:e.allDaySortComparator},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 se=0;function ie(e,n,r,a,o,l){n||(n={});var s,i,d=n;if("ref"in d)for(i in d={},n)"ref"==i?s=n[i]:d[i]=n[i];var c={type:e,props:d,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--se,__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 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),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 e.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}},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,s,i,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!==(s=M.nanosecond)&&void 0!==s?s: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===(i=null==a?void 0:a.timeZone)||void 0===i?void 0:i.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="",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}},$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 s=a.match(/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})$/);if(s){const t={year:Number.parseInt(s[1],10),month:Number.parseInt(s[2],10),day:Number.parseInt(s[3],10),hour:Number.parseInt(s[4],10),minute:Number.parseInt(s[5],10),second:Number.parseInt(s[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);let s;if(e.allDay){const t=(ce(e.end)?e.end:e.end.toPlainDate()).add({days:1});s={value:`${t.year}${Ye(t.month)}${Ye(t.day)}`,params:{VALUE:"DATE"}}}else s=Ve(e.end,!1);if(a.push(Be("DTSTART",l.value,l.params)),a.push(Be("DTEND",s.value,s.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(";"),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=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: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=>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:s}=n,i=o?`${l}${ne()}`:t.uid,d=Fe(t.dtstart,t.dtstartParams,s);let c;c=t.dtend?Fe(t.dtend,t.dtendParams,s):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=s||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.subtract({days:1}).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:i,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")}const Qe=e=>{const t=w(e.start);t.setHours(0,0,0,0);const n=w(e.end);return n.setHours(0,0,0,0),{startDay:t,endDay:n,isMultiDay:n.getTime()>t.getTime()}},et=(e,t,n)=>{const r=Qe(e),a=Qe(t);if(r.isMultiDay!==a.isMultiDay)return r.isMultiDay?-1:1;if(r.isMultiDay&&a.isMultiDay){const e=r.startDay.getTime()-a.startDay.getTime();if(0!==e)return e;const t=a.endDay.getTime()-r.endDay.getTime();if(0!==t)return t}if(n){const r=n(e,t);if(0!==r)return r}return r.startDay.getTime()-a.startDay.getTime()},tt=(e,t)=>{const n=new Map;return e.forEach(e=>{const{isMultiDay:t,startDay:r}=Qe(e),a=n.get(e.calendarId);a?t&&(a.hasMultiDay=!0,a.earliestMultiDayStart=Math.min(a.earliestMultiDayStart,r.getTime())):n.set(e.calendarId,{hasMultiDay:t,earliestMultiDayStart:t?r.getTime():Number.POSITIVE_INFINITY})}),(e,r)=>{var a,o,l,s,i,d;const c=n.get(e.calendarId),u=n.get(r.calendarId);if((null!==(a=null==c?void 0:c.hasMultiDay)&&void 0!==a&&a)!==(null!==(o=null==u?void 0:u.hasMultiDay)&&void 0!==o&&o))return(null==c?void 0:c.hasMultiDay)?-1:1;if(null!==(l=null==c?void 0:c.hasMultiDay)&&void 0!==l&&l&&null!==(s=null==u?void 0:u.hasMultiDay)&&void 0!==s&&s&&e.calendarId!==r.calendarId){const e=(null!==(i=null==c?void 0:c.earliestMultiDayStart)&&void 0!==i?i:Number.POSITIVE_INFINITY)-(null!==(d=null==u?void 0:u.earliestMultiDayStart)&&void 0!==d?d:Number.POSITIVE_INFINITY);if(0!==e)return e}return e.calendarId,r.calendarId,et(e,r,t)}};let nt=null;const rt=()=>{const[e,t]=r.useState(()=>nt||{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};nt=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},at=t.createContext({locale:"en-US",t:e=>e,getWeekDaysLabels:()=>[],getMonthLabels:()=>[],isDefault:!0});function ot(){return r.useContext(at)}const lt="df-month-view h-full flex flex-col select-none",st="p-2 flex justify-between",it="text-2xl font-bold text-gray-900 dark:text-gray-100",dt="df-date-number inline-flex items-center justify-center h-6 w-6 rounded-full text-sm mt-1 select-none",ct="flex-1 overflow-auto will-change-scroll overscroll-contain",ut="scrollbar-hide",ht="df-time-slot relative h-[4.5rem] flex",gt="df-time-label absolute top-0 -translate-y-1/2 right-2 text-[12px] text-gray-500 dark:text-gray-400 select-none",mt="df-time-grid-row h-[4.5rem] border-t flex",pt="df-current-time-line absolute left-0 top-0 w-full flex pointer-events-none",ft="df-current-time-label ml-2 text-primary-foreground text-xs font-bold px-1.5 bg-primary rounded-sm",vt="df-all-day-row flex items-center border-b",yt="rounded-xl my-0.5",bt="rounded-sm",xt="df-event-title font-medium text-xs truncate pr-1",wt="df-month-event-color-bar inline-block w-0.75 h-3 mr-1 shrink-0 rounded-full",Dt="h-3 w-3 mr-1",Et="resize-handle absolute right-0 top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20",Ct="bg-primary rounded-full text-primary-foreground",Tt="df-nav-button df-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",kt="h-4 w-4 transition-transform group-hover:scale-110",St="df-event-detail-panel fixed shadow-lg border rounded-lg",Mt="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 df-animate-in df-fade-in df-zoom-in-95",Nt="df-time-grid-boundary h-3 border-t relative",It="absolute top-0 -translate-y-1/2 text-[12px] text-gray-500 dark:text-gray-400",Rt="flex h-7 w-7 items-center justify-center rounded hover:bg-gray-100 dark:hover:bg-slate-800 transition-colors",Ht="text-gray-500 dark:text-gray-400",At="text-gray-600 dark:text-gray-300",Ot="text-xs",Pt="text-sm",Lt="flex flex-col",$t="mr-1",jt=(...e)=>e.filter(Boolean).join(" "),Yt=({className:e,width:t=24,height:n=24})=>ie("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:ie("path",{d:"m15 18-6-6 6-6"})}),Ft=({className:e,width:t=24,height:n=24})=>ie("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:ie("path",{d:"m9 18 6-6-6-6"})}),Vt=({className:e,width:t=24,height:n=24})=>ie("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:[ie("path",{d:"m11 17-5-5 5-5"}),ie("path",{d:"m18 17-5-5 5-5"})]}),_t=({className:e,width:t=24,height:n=24})=>ie("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:[ie("path",{d:"m6 17 5-5-5-5"}),ie("path",{d:"m13 17 5-5-5-5"})]}),zt=({className:e,width:t=24,height:n=24})=>ie("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:ie("path",{d:"m6 9 6 6 6-6"})}),Wt=({className:e,width:t=24,height:n=24})=>ie("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:[ie("path",{d:"M5 12h14"}),ie("path",{d:"M12 5v14"})]}),Ut=({className:e,width:t=24,height:n=24})=>ie("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:[ie("circle",{cx:"11",cy:"11",r:"8"}),ie("path",{d:"m21 21-4.3-4.3"})]}),Bt=({className:e,width:t=24,height:n=24})=>ie("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:ie("path",{d:"M20 6 9 17l-5-5"})}),Zt=({className:e,width:t=24,height:n=24})=>ie("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:[ie("path",{d:"m7 15 5 5 5-5"}),ie("path",{d:"m7 9 5-5 5 5"})]}),Gt=({className:e,width:t=24,height:n=24})=>ie("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:[ie("path",{d:"M18 6 6 18"}),ie("path",{d:"m6 6 12 12"})]}),Kt=({className:e,width:t=24,height:n=24})=>ie("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:[ie("path",{d:"M8 2v4"}),ie("path",{d:"M16 2v4"}),ie("rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}),ie("path",{d:"M3 10h18"}),ie("path",{d:"M8 14h.01"}),ie("path",{d:"M12 14h.01"}),ie("path",{d:"M16 14h.01"}),ie("path",{d:"M8 18h.01"}),ie("path",{d:"M12 18h.01"}),ie("path",{d:"M16 18h.01"})]}),qt=({className:e,width:t=24,height:n=24})=>ie("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:[ie("path",{d:"M18 8L22 12L18 16"}),ie("path",{d:"M2 12H22"})]}),Xt=({className:e,width:t=24,height:n=24})=>ie("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:ie("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),Jt=({className:e,width:t=24,height:n=24})=>ie("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:[ie("rect",{width:"18",height:"14",x:"3",y:"8",rx:"2"}),ie("path",{d:"M12 5a3 3 0 1 0-3 3"}),ie("path",{d:"M12 5a3 3 0 1 1 3 3"}),ie("path",{d:"M3 12h18"}),ie("path",{d:"M12 22V8"})]}),Qt=({className:e,width:t=24,height:n=24})=>ie("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:ie("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"})}),en=({className:e,width:t=24,height:n=24})=>ie("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:[ie("path",{d:"M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z"}),ie("circle",{cx:"12",cy:"10",r:"3"})]}),tn=({className:e,width:t=24,height:n=24})=>ie("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:ie("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"})}),nn=({className:e,width:t=24,height:n=24})=>ie("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:[ie("path",{d:"m12 19-7-7 7-7"}),ie("path",{d:"M19 12H5"})]});function rn(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 an(e){return e.charAt(0).toUpperCase()+e.slice(1)}const on=(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},ln=(e,t="long")=>{const n=[];for(let r=0;r<12;r++){const a=new Date(2024,r,1);try{n.push(a.toLocaleDateString(e,{month:t}))}catch(e){n.push(a.toLocaleDateString("en-US",{month:t}))}}return n};function sn(e,t="en-US"){var n;if(["today","day","week","month","year"].includes(e)){const n=rn(e,t);if(n)return an(n)}const r=i(t),a=s[r],o=null===(n=null==a?void 0:a.messages)||void 0===n?void 0:n[e];if(o)return o;const l=s.en.messages;return(null==l?void 0:l[e])||e}const dn=({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,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:sn(n,e);return r&&Object.entries(r).forEach(([e,t])=>{i=i.replaceAll(new RegExp(`{${e}}`,"g"),t)}),i},getWeekDaysLabels:on,getMonthLabels:ln,isDefault:!1}},[a,t]);return ie(at.Provider,{value:o,children:n})},cn=({calendar:e,mode:t="buttons"})=>{const[n,a]=r.useState(!1),o=r.useRef(null),{t:l}=ot(),s=Array.from(e.state.views.keys()),i=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]),s.length<=1?null:ie("div","select"===t?{className:"relative inline-block",ref:o,children:[ie("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:[ie("span",{className:"text-gray-900 dark:text-gray-100",children:l(i)}),ie("span",{className:`${Ht} transition-transform duration-200 ${n?"rotate-180":""}`,children:ie(zt,{width:16,height:16})})]}),n&&ie("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 df-animate-in",children:ie("div",{className:"p-1",role:"listbox",children:s.map(t=>ie("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 "+(i===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":i===t,children:l(t)},t))})}),ie("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 .df-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:s.map(t=>ie("button",{type:"button",className:"h-6 rounded-md px-4 text-sm font-medium transition-all duration-200 focus:outline-none "+(i===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))})},un=({calendar:e,switcherMode:t="buttons",onAddCalendar:n,onSearchChange:a,onSearchClick:o,searchValue:l="",isSearchOpen:s=!1,isEditable:i=!0,safeAreaLeft:d})=>{const c="buttons"===t,u=e.state.currentView===exports.ViewType.DAY,{screenSize:h}=rt(),g="mobile"===h,{t:m}=ot(),p=r.useCallback(e=>{const t=e.currentTarget.value;t!==l&&(null==a||a(t))},[a,l]);return ie("div",{className:"df-header flex shrink-0 items-center justify-between border-b pt-1 pr-2 transition-colors duration-200 "+(u||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:[ie("div",{className:"df-header-left mb-1 flex items-center",children:n&&i&&ie("button",{type:"button",id:"dayflow-add-event-btn",onClick:n,className:Rt,title:g?m("newEvent")||"New Event":m("createCalendar")||"Add Calendar",children:ie(Wt,{className:`h-4 w-4 ${Ht}`})})}),ie("div",{className:"df-header-mid flex flex-1 justify-center",children:c&&ie(cn,{mode:t,calendar:e})}),ie("div",{className:"df-header-right mb-1 flex items-center justify-end gap-3 pb-1",children:[!c&&ie(cn,{mode:t,calendar:e}),ie("button",{type:"button",onClick:o,className:`md:hidden ${Rt}`,title:m("search")||"Search",children:ie(Ut,{width:16,height:16})}),ie("div",{className:"group relative hidden md:block",children:[ie("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3",children:ie("span",{className:"text-gray-400 transition-colors group-focus-within:text-primary",children:ie(Ut,{width:16,height:16})})}),ie("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&&ie("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:ie("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[ie("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ie("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]})]})},hn=t.createContext(void 0),gn=({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=Ne(i),n="auto"===a?t:i;e.classList.remove("light","dark"),e.classList.add(n),"auto"===a?delete e.dataset.dayflowThemeOverride:e.dataset.dayflowThemeOverride=n,e.dataset.theme=n},[i,a,l]),r.useEffect(()=>{n&&n(a,i)},[a,i,n]);const c=r.useMemo(()=>({theme:a,effectiveTheme:i,setTheme:d}),[a,i,d]);return ie(hn.Provider,{value:c,children:e})},mn=()=>{const e=r.useContext(hn);if(void 0===e)throw new Error("useTheme must be used within a ThemeProvider");return e},pn=t.createContext(null);let fn=0;function vn({generatorName:e,generatorArgs:t,defaultContent:n,store:a}){const o=r.useRef(null),l=r.useContext(pn),s=a||l,i=r.useRef(null),[,d]=r.useState(0);i.current||(i.current="df-slot-"+fn++),r.useEffect(()=>{if(!o.current||!s||!e)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,e]),r.useEffect(()=>{if(!s||!i.current||!e)return;const n=i.current;s.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==s?void 0:s.isOverridden(e));return ie("div",{ref:o,className:"df-content-slot "+(c||u?"flex h-full flex-1 flex-col":""),children:!h&&n})}const yn=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]),ie("div",{ref:t,className:e.className})},bn=({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 ie("div",{className:"flex justify-center",children:ie(yn,{defaultValue:a,coreSize:36,petalSize:32,initialExpanded:!0,openOnHover:!1,onChange:e=>t({hex:e.hex},!0),onCollapse:n})})},xn=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],wn=({onClose:e,onCreate:a,app:l})=>{const{t:s}=ot(),{effectiveTheme:i}=mn(),[d,c]=r.useState(""),u=l.state.overrides.includes("createCalendarDialogColorPicker"),[h,g]=r.useState(xn[Math.floor(Math.random()*xn.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"===i,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(ie("div",{className:"df-portal fixed inset-0 z-10000 flex items-center justify-center bg-black/50",children:ie("div",{className:"df-animate-in df-fade-in df-zoom-in-95 w-full max-w-sm rounded-lg bg-white p-6 shadow-xl dark:bg-gray-900",onClick:e=>e.stopPropagation(),children:[ie("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white "+(u?"mb-4":"mb-6"),children:s("createCalendar")}),ie("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:s}=P(r),i={id:ne(),name:d.trim(),colors:l,darkColors:s,isVisible:!0,isDefault:!1};a(i),e()},children:[u?ie(t.Fragment,{children:[ie("div",{className:"mb-4",children:ie("div",{className:"flex items-center gap-3",children:[ie("div",{className:"h-9 w-9 rounded-md border border-gray-200 shadow-sm dark:border-gray-600",style:{backgroundColor:h}}),ie("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:s("calendarNamePlaceholder"),autoFocus:!0})]})}),ie("div",{className:"mb-6",children:[ie("div",{className:"mb-4 grid grid-cols-7 gap-4",children:xn.map(e=>ie("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))}),ie("div",{className:"relative",children:[ie("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:s("customColor")}),m&&ie("div",{className:"fixed inset-0 z-10001 flex items-center justify-center bg-black/40 backdrop-blur-sm",onClick:E,children:ie("div",{className:"df-animate-in df-fade-in df-zoom-in-95 relative",onClick:e=>e.stopPropagation(),children:ie(vn,{generatorName:"createCalendarDialogColorPicker",generatorArgs:{color:h,onChange:w,onAccept:D,onCancel:E,styles:T},defaultContent:ie("div",{className:"rounded-lg border border-slate-200 bg-white p-4 shadow-2xl dark:border-slate-700 dark:bg-gray-900",children:[ie(bn,{color:h,onChange:w}),ie("div",{className:"mt-4 flex justify-end gap-2 border-t pt-3 dark:border-slate-700",children:[ie("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:s("cancel")}),ie("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"})]})]})})})})]})]})]}):ie("div",{className:"mb-8 flex items-center gap-4",children:[ie("div",{className:"flex-1",children:ie("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:s("calendarNamePlaceholder"),autoFocus:!0})}),ie("div",{className:"relative h-9 w-9 shrink-0",children:ie("div",{className:"absolute inset-0 flex items-center justify-center",children:ie(yn,{defaultValue:y,coreSize:36,petalSize:32,openOnHover:!1,onChange:e=>x(e),onCollapse:e=>x(e),className:"z-50"})})})]}),ie("div",{className:"flex justify-end space-x-2",children:[ie("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:s("cancel")}),ie("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:s("create")})]})]})]})}),document.body)},Dn=(t,n)=>e.Temporal.PlainDate.compare(t,n),En=({calendarDays:e,visibleMonth:n,startDate:r,endDate:a,weekDayLabels:o,disabled:l,onDaySelect:s})=>ie(t.Fragment,{children:[ie("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=>ie("span",{children:e},e))}),ie("div",{className:"grid grid-cols-7 gap-1 px-1",children:e.map(e=>{const t=e.month!==n.month,o=0===Dn(e,r),i=0===Dn(e,a),d=Dn(e,r)>=0&&Dn(e,a)<=0;return ie("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":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())})})]}),Cn=({visibleMonth:e,monthLabels:t,disabled:n,onMonthChange:r,onYearChange:a})=>ie("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:[ie("div",{className:"flex items-center gap-1",children:[ie("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:ie(Vt,{width:14,height:12})}),ie("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:ie(Yt,{width:14,height:12})})]}),ie("div",{className:"text-sm font-semibold text-slate-700 dark:text-gray-300",children:[t[e.month-1]," ",e.year]}),ie("div",{className:"flex items-center gap-1",children:[ie("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:ie(Ft,{width:14,height:12})}),ie("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:ie(_t,{width:14,height:12})})]})]}),Tn=Array.from({length:24},(e,t)=>t),kn=Array.from({length:60},(e,t)=>t),Sn=({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=kn.includes(i)?kn:[...kn,i].toSorted((e,t)=>e-t);return ie("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:[ie("div",{className:"flex justify-center border-b border-slate-100 dark:border-gray-600",children:ie("div",{className:"py-1.5 text-base text-slate-700 dark:text-gray-300",children:[s.hour.toString().padStart(2,"0"),":",s.minute.toString().padStart(2,"0")]})}),ie("div",{className:"flex p-1",children:[ie("div",{className:"w-14",children:ie("div",{className:`h-72 overflow-y-auto ${ut} 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:Tn.map(e=>{const t=e===s.hour;return ie("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)})})}),ie("div",{className:"w-14",children:ie("div",{className:`h-72 overflow-y-auto ${ut} 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===i;return ie("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)})})})]})]})},Mn=({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 ie("div",{ref:d,style:v(),"data-range-picker-popup":"true",children:ie("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:i?"100%":void 0},children:[ie("div",{className:"flex gap-1",children:[ie("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:[ie(Cn,{visibleMonth:e,monthLabels:t,disabled:s,onMonthChange:u,onYearChange:h}),ie(En,{calendarDays:r,visibleMonth:e,startDate:y,endDate:b,weekDayLabels:n,disabled:s,onDaySelect:g})]}),l&&ie("div",{className:"flex flex-1 justify-end sm:w-32",children:ie(Sn,{focusedField:o,draftRange:a,disabled:s,onHourSelect:m,onMinuteSelect:p,timeListRefs:c})})]}),ie("div",{className:"flex justify-end",children:ie("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"})})]})})},Nn=({value:t,format:a="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]),b=r.useMemo(()=>ln(f,"short"),[f]),x=r.useMemo(()=>on(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=>{s&&s(e,[ke(e[0],a,w),ke(e[1],a,w)])},[w,a,s]),ee=r.useCallback(e=>{i&&i(e,[ke(e[0],a,w),ke(e[1],a,w)])},[w,a,i]),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 s=Ce(t);return e.Temporal.ZonedDateTime.from({timeZone:s,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 s=Te(a[0],Ce(l),l);return[e.Temporal.ZonedDateTime.compare(s,l)>0?l:s,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]),se=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 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]),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 ie("div",{className:"relative max-w-100",ref:_,children:[ie("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:[ie("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:ie("input",{type:"text",name:"range-start",value:I[0],onChange:se("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})}),ie(qt,{className:"text-slate-400 dark:text-gray-500"}),ie("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:ie("input",{type:"text",name:"range-end",value:I[1],onChange:se("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(ie(Mn,{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(ie(Mn,{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))]})},In=({options:e,value:t,onChange:a,registry:o,variant:l="desktop",disabled:s=!1})=>{const[i,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 i&&(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)}},[i]);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=()=>i&&"undefined"!=typeof window?"mobile"===l?n.createPortal(ie("div",{"data-calendar-picker-dropdown":"true",style:c,className:Mt,children:e.map(e=>ie("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:[ie("div",{className:"mr-3 flex min-w-0 flex-1 items-center",children:[ie("div",{className:"mr-2 flex w-5 justify-center",children:e.value===t&&ie(Bt,{className:"h-4 w-4 text-primary"})}),ie("span",{className:"truncate text-sm text-gray-700 dark:text-gray-200",children:e.label})]}),ie("span",{className:"h-3 w-3 shrink-0 rounded-full",style:{backgroundColor:p(e.value)}})]},e.value))}),document.body):n.createPortal(ie("ul",{"data-calendar-picker-dropdown":"true",style:c,className:"df-animate-in df-fade-in df-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=>ie("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?ie("span",{className:"mr-2 text-sm text-primary",children:ie(Bt,{width:12,height:12})}):ie("div",{className:"mr-2 h-3 w-3 text-sm",children:" "}),ie("span",{className:"mr-2 h-3 w-3 shrink-0 rounded-sm",style:{backgroundColor:p(e.value)}}),ie("span",{className:"text-sm whitespace-nowrap text-gray-700 dark:text-gray-200",children:e.label})]},e.value))}),document.body):null;return ie("div","mobile"===l?{className:"relative inline-block",ref:h,children:[ie("button",{type:"button",ref:g,disabled:s,onClick:e=>{e.stopPropagation(),s||d(!i)},className:"flex items-center space-x-2 rounded-md bg-gray-100 px-3 py-1.5 transition-colors dark:bg-gray-700 "+(s?"cursor-default opacity-50":""),children:[ie("span",{className:"h-3 w-3 rounded-full",style:{backgroundColor:p(t)}}),ie("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-200",children:(null==v?void 0:v.label)||t}),ie(Zt,{className:"h-4 w-4 text-gray-400"})]}),y()]}:{className:"relative inline-block",ref:h,children:[ie("button",{ref:g,type:"button",onClick:e=>{e.stopPropagation(),d(!i)},className:"flex h-8 items-center space-x-2 rounded-md bg-gray-100 px-2 py-1 transition-colors hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",children:[ie("span",{className:"h-4 w-4 shrink-0 rounded-sm",style:{backgroundColor:p(t)}}),ie(Zt,{className:"h-4 w-4 text-gray-600 dark:text-gray-300"})]}),y()]})},Rn=({event:t,isOpen:a,onEventUpdate:o,onEventDelete:l,onClose:s,app:i})=>{var d;const[c,u]=r.useState(t),{t:h}=ot();r.useEffect(()=>{u(t)},[t]);const g=r.useMemo(()=>(i?i.getCalendarRegistry():O()).getVisible().map(e=>({label:e.name,value:e.id})),[i,null==i?void 0:i.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==i?void 0:i.state.readOnly),b=!1!==(null==i?void 0:i.getReadOnlyConfig().viewable);if(!a||!b)return null;if("undefined"==typeof window||"undefined"==typeof document)return null;const x=ie("div",{className:"df-portal fixed inset-0 flex items-center justify-center",style:{pointerEvents:"auto",zIndex:9998},"data-event-detail-dialog":"true",children:[ie("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&&s()}}),ie("div",{className:"df-dialog-container relative shadow-2xl border rounded-lg p-6 max-w-md w-full mx-4",children:[ie("button",{type:"button",onClick:s,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:ie("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:ie("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),ie("div",{children:[ie("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:h("eventTitle")}),ie("div",{className:"mb-4 flex items-center justify-between gap-3",children:[ie("div",{className:"flex-1",children:ie("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&&ie(In,{options:g,value:c.calendarId||"blue",onChange:e=>{u(Object.assign(Object.assign({},c),{calendarId:e}))},registry:null==i?void 0:i.getCalendarRegistry()})]}),c.allDay?ie("div",{className:"mb-4",children:[ie("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:h("dateRange")}),ie(Nn,{value:[c.start,c.end],format:"YYYY-MM-DD",showTime:!1,timeZone:p,matchTriggerWidth:!0,disabled:!v,onChange:f,onOk:f,locale:null==i?void 0:i.state.locale})]}):ie("div",{className:"mb-4",children:[ie("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:h("timeRange")}),ie(Nn,{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==i?void 0:i.state.locale})]}),ie("div",{className:"mb-4",children:[ie("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:h("note")}),ie("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&&ie("div",{className:"flex space-x-2",children:[c.allDay?ie("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")}):ie("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")}),ie("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),s()},children:h("delete")}),ie("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),s()},disabled:!m,children:h("save")})]})]})]})]}),w=document.body;return w?n.createPortal(x,w):null},Hn=e=>e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}),An=({app:e,anchorRef:t,onClose:a,isOpen:o})=>{const{t:l}=ot(),[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)&&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(!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([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 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(ie("div",{ref:m,className:"df-portal 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?"df-animate-in df-fade-in df-zoom-in-95 duration-100":""),style:{top:p.top,left:p.left,visibility:u?"visible":"hidden"},children:[ie("div",{className:"p-4 pb-2",children:[ie("div",{className:"mb-2 text-xs font-semibold tracking-wider text-gray-500 uppercase dark:text-gray-400",children:l("quickCreateEvent")||"Quick Create Event"}),ie("div",{className:"relative",children:ie("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:s,onChange:e=>i(e.target.value)})})]}),ie("div",{className:"max-h-75 flex-1 overflow-y-auto px-2 py-1",children:[0===E.length&&s&&ie("div",{className:"px-4 py-3 text-center text-sm text-gray-400",children:l("noSuggestions")||"Type to create"}),E.map((e,t)=>{return ie("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:[ie("div",{className:"mr-3 h-8 w-1 shrink-0 rounded-full",style:{backgroundColor:e.color}}),ie("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[ie("div",{className:"truncate text-sm font-medium text-gray-900 dark:text-gray-100",children:e.title}),ie("div",{className:"flex",children:ie("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")})}),ie("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:(n=e.start,r=e.end,`${Hn(n)} - ${Hn(r)}`)})]})]},`${e.type}-${t}`);var n,r})]}),ie("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},On=({visibleMonth:e,currentDate:t,showHeader:n=!1,onMonthChange:a,onDateSelect:o})=>{const{locale:l}=ot(),s=r.useMemo(()=>(new Date).toDateString(),[]),i=t.toDateString(),d=r.useMemo(()=>on(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 ie("div",{className:"px-3 py-3",children:[n?ie("div",{className:"mb-3 flex items-center justify-between",children:[ie("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:ie(Yt,{className:"h-4 w-4"})}),ie("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:c}),ie("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:ie(Ft,{className:"h-4 w-4"})})]}):"",ie("div",{className:"df-mini-calendar-grid grid grid-cols-7 gap-1 text-xs justify-items-center",children:[d.map((e,t)=>ie("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=>ie("button",{type:"button",className:` df-mini-calendar-day text-center py-1 rounded text-xs h-6 w-6 ${e.isToday?Ct: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()))]})]})},Pn=({checked:e,onChange:t,disabled:n})=>ie("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:ie("div",{className:"h-5 w-5 transform rounded-full bg-white shadow-md transition-transform "+(e?"translate-x-5":"")})}),Ln=({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)},x=(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 ie("div",{className:"relative mt-2 flex h-56 overflow-hidden rounded-lg",children:[ie("style",{children:"\n .no-scrollbar::-webkit-scrollbar { display: none; }\n .no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }\n "}),ie("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:[ie("div",{style:{height:96}}),o.map((n,r)=>ie("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*s,behavior:"smooth"})},children:ie("div",{className:"w-10 text-center text-xl transition-colors duration-200 "+(n===i?"font-bold text-black dark:text-white":"text-gray-400 dark:text-gray-500"),style:x(r,h),children:n.toString().padStart(2,"0")})},`h-${r}-${n}`)),ie("div",{style:{height:96}})]}),ie("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:[ie("div",{style:{height:96}}),l.map((n,r)=>ie("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*s,behavior:"smooth"})},children:ie("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}`)),ie("div",{style:{height:96}})]}),ie("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"})]})},$n=({isOpen:e,onClose:t,onSave:a,onEventDelete:o,draftEvent:l,app:s,timeFormat:i="24h"})=>{const{locale:d,t:c}=ot(),u=s.getReadOnlyConfig(),h=!s.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=s.getEvents().some(e=>e.id===l.id);Y(e)}},[e,l,s]);const V=s.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(ie("div",{className:"df-portal pointer-events-none fixed inset-0 z-10000 flex items-end",children:[ie("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}),ie("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?"df-animate-slide-down":"df-animate-slide-up"),onClick:e=>e.stopPropagation(),children:[ie("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:[ie("button",{type:"button",onClick:t,className:"px-2 py-1 text-gray-500 hover:text-gray-700",children:c("cancel")}),ie("span",{className:"text-lg font-semibold",children:c(!h&&j?"viewEvent":j?"editEvent":"newEvent")}),h&&ie("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&&ie("span",{className:"w-12"})]}),ie("div",{className:"flex-1 space-y-4 overflow-y-auto p-4",children:[ie("div",{className:"rounded-lg bg-white px-4 py-3 dark:bg-gray-900",children:ie("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&&ie("div",{className:"relative flex items-center justify-between rounded-lg bg-white px-4 py-3 dark:bg-gray-900",children:[ie("span",{className:"text-gray-700 dark:text-gray-300",children:c("calendar")}),ie(In,{options:_,value:f,onChange:h?v:()=>{},registry:s.getCalendarRegistry(),variant:"mobile",disabled:!h})]}),ie("div",{className:"flex items-center justify-between rounded-lg bg-white px-4 py-3 dark:bg-gray-900",children:[ie("span",{className:"text-gray-700 dark:text-gray-300",children:c("allDay")}),ie(Pn,{checked:y,onChange:h?x:()=>{},disabled:!h})]}),ie("div",{className:"overflow-hidden rounded-lg bg-white dark:bg-gray-900",children:[ie("div",{className:"flex items-center justify-between border-b border-gray-100 px-4 py-3 last:border-0 dark:border-gray-800",children:[ie("span",{className:"text-gray-700 dark:text-gray-300",children:c("starts")}),ie("div",{className:"flex space-x-2",children:[ie("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&&ie("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,i)})]})]}),ie("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("start-date"===H?"max-h-100":"max-h-0"),children:ie("div",{className:"",children:ie(On,{currentDate:D,visibleMonth:M,onDateSelect:e=>B("start",e),onMonthChange:e=>Z("start",e),showHeader:!0})})}),ie("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("start-time"===H?"max-h-75":"max-h-0"),children:ie("div",{className:"",children:ie(Ln,{date:D,onChange:e=>{const t=C.getTime()-D.getTime();E(e),T(new Date(e.getTime()+t))},timeFormat:i})})})]}),ie("div",{className:"overflow-hidden rounded-lg bg-white dark:bg-gray-900",children:[ie("div",{className:"flex items-center justify-between border-b border-gray-100 px-4 py-3 last:border-0 dark:border-gray-800",children:[ie("span",{className:"text-gray-700 dark:text-gray-300",children:c("ends")}),ie("div",{className:"flex space-x-2",children:[ie("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&&ie("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,i)})]})]}),ie("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("end-date"===H?"max-h-100":"max-h-0"),children:ie("div",{className:"",children:ie(On,{currentDate:C,visibleMonth:I,onDateSelect:e=>B("end",e),onMonthChange:e=>Z("end",e),showHeader:!0})})}),ie("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("end-time"===H?"max-h-75":"max-h-0"),children:ie("div",{className:"",children:ie(Ln,{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:i})})})]}),ie("div",{className:"rounded-lg bg-white px-4 py-3 dark:bg-gray-900",children:ie("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&&ie("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)},jn=()=>ie("svg",{className:"h-12 w-12 text-gray-300 dark:text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:ie("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),Yn=({loading:e,results:t,keyword:n,onResultClick:a,emptyText:o})=>{const{t:l,locale:s}=ot(),i=r.useMemo(()=>Pe(new Date),[]),d=r.useMemo(()=>$e(t,i),[t,i]),c=e=>Oe(e);return e?ie("div",{className:"flex h-40 flex-col items-center justify-center text-gray-500",children:[ie(Xt,{className:"mb-2 h-8 w-8 animate-spin"}),ie("span",{children:"Loading..."})]}):0===t.length?n?ie("div",{className:"flex h-40 flex-col items-center justify-center text-gray-500",children:[ie(jn,{}),ie("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:ie("div",{className:"space-y-6",children:d.map(e=>{const{title:t,colorClass:n}=Le(e.date,i,s,l);return ie("div",{children:[ie("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}),ie("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 ie("div",{children:[ie("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:ie("div",{className:"flex items-stretch gap-3",children:[ie("div",{className:"w-1 shrink-0 rounded-full",style:{backgroundColor:e.color||"#3b82f6"}}),ie("div",{className:"flex min-w-0 flex-1 items-start justify-between",children:[ie("div",{className:"truncate pr-2 text-sm font-medium text-black dark:text-white",children:e.title}),ie("div",{className:"flex shrink-0 flex-col items-end text-xs leading-tight",children:[ie("div",{className:"text-black dark:text-white",children:o}),i&&ie("div",{className:"text-gray-500 dark:text-gray-400",children:i})]})]})]})}),ie("div",{className:"mx-2 border-b border-gray-200 dark:border-gray-700"})]},e.id)})})]},e.date.getTime())})})},Fn=({isOpen:e,onClose:t,keyword:a,onSearchChange:o,results:l,loading:s,onResultClick:i,emptyText:d})=>{const c=r.useRef(null),{t:u}=ot();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(ie("div",{className:"df-portal fixed inset-0 z-9999 bg-white dark:bg-gray-900 flex flex-col",children:[ie("div",{className:"flex items-center p-2 border-b border-gray-200 dark:border-gray-700 gap-2",children:[ie("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:ie(nn,{className:"h-6 w-6"})}),ie("div",{className:"relative flex-1",children:[ie("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&&ie("button",{type:"button",onClick:()=>{""!==a&&o("")},className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400",children:ie(Gt,{className:"h-4 w-4"})})]})]}),ie("div",{className:"flex-1 overflow-y-auto p-2 select-none",children:ie(Yn,{loading:s,results:l,keyword:a,onResultClick:e=>{null==i||i(e)},emptyText:d})})]}),document.body):null},Vn=({isOpen:e,loading:t,results:n,keyword:r,onResultClick:a,emptyText:o})=>ie("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:ie("div",{className:"min-w-64 flex-1 overflow-y-auto",children:ie(Yn,{loading:t,results:n,keyword:r,onResultClick:a,emptyText:o})})});let _n=null;const zn={enabled:!1,width:"0px",isCollapsed:!1,toggleCollapsed:()=>{},miniWidth:"0px",content:null,extraContent:null,safeAreaLeft:0};function Wn(e){return _n&&e.hasPlugin("sidebar")?_n(e):zn}const Un=({locale:e,messages:t,children:n})=>ot().isDefault?ie(dn,{locale:e,messages:t,children:n}):n,Bn=({app:e,customDetailPanelContent:o,customEventDetailDialog:l,meta:s,customMessages:i,search:d,titleBarSlot:c,collapsedSafeAreaLeft:u})=>{const h=r.useContext(pn),{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,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 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),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)}}),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),i&&d(!1)},[e,i]),p=r.useCallback(()=>{o(""),d(!0)},[]),f=r.useCallback(()=>{s(!1),o(""),e.highlightEvent(null)},[e]),v=r.useCallback(()=>{d(!1),o(""),e.highlightEvent(null)},[e]);return{searchKeyword:n,setSearchKeyword:o,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()?Rn: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]),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:y(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),D=Wn(e),E=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:ne(),title:"",start:b(t),end:b(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,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:s,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()||$n;return ie(gn,{initialTheme:C,onThemeChange:k,children:ie(Un,{locale:e.state.locale,messages:i,children:ie("div",{className:"df-calendar-container relative flex flex-row overflow-hidden select-none",children:[ie(vn,{store:h,generatorName:"titleBarSlot",generatorArgs:R,defaultContent:c&&("function"==typeof c?c(R):c)}),D.enabled&&ie("aside",{className:"absolute top-0 bottom-0 left-0 z-0 h-full",style:{width:D.width},children:D.content}),ie("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(un,L),ie("div",{className:"relative flex-1 overflow-hidden",ref:N,children:[ie("div",{className:"calendar-renderer relative flex h-full flex-row",children:[ie("div",{className:"h-full flex-1 overflow-hidden",children:ie($,Object.assign({},I))}),ie(Vn,{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})]}),ie(Fn,{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})]})]}),ie(An,{app:e,anchorRef:E.quickCreateAnchorRef,isOpen:E.isQuickCreateOpen,onClose:()=>E.setIsQuickCreateOpen(!1)}),ie(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&&ie(wn,{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 ie(vn,{store:h,generatorName:"eventDetailDialog",generatorArgs:x.dialogProps,defaultContent:a?null:n.createPortal(t.h(e,x.dialogProps),r)})})()]})})})};class Zn{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 Gn=n.forwardRef(({x:e,y:t,onClose:a,children:o,className:l},s)=>{const i=r.useRef(null);r.useEffect(()=>{const e=()=>a(),t=e=>{if(i.current&&!i.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(ie("div",{ref:e=>{i.current=e,"function"==typeof s?s(e):s&&"current"in s&&(s.current=e)},className:`df-portal df-animate-in df-fade-in df-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)});Gn.displayName="ContextMenu";const Kn=({onClick:e,children:t,icon:n,danger:r,disabled:a})=>ie("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-[var(--df-color-primary)] hover:text-[var(--df-color-primary-foreground)] focus:bg-[var(--df-color-primary)] focus:text-[var(--df-color-primary-foreground)]"} ${r?"text-destructive hover:bg-destructive hover:text-destructive-foreground focus:bg-destructive focus:text-destructive-foreground":"text-[var(--df-color-foreground)]"}`,onClick:t=>{t.stopPropagation(),a||e()},"data-disabled":a,children:[n&&ie("span",{className:"mr-2 h-4 w-4",children:n}),t]}),qn=()=>ie("div",{className:"-mx-1 my-1 h-px bg-slate-200 dark:bg-slate-800"}),Xn=({children:e})=>{const[n,a]=r.useState(!1),o=r.useRef(null);return r.useEffect(()=>()=>{o.current&&clearTimeout(o.current)},[]),ie("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)})},Jn=({children:e,icon:t,isOpen:n})=>ie("div",{className:"relative flex cursor-default items-center rounded-sm px-3 py-0.5 text-[12px] text-[var(--df-color-foreground)] transition-colors outline-none select-none hover:bg-[var(--df-color-primary)] hover:text-[var(--df-color-primary-foreground)] focus:bg-[var(--df-color-primary)] focus:text-[var(--df-color-primary-foreground)] "+(n?"bg-[var(--df-color-primary)] text-[var(--df-color-primary-foreground)]":""),children:[t&&ie("span",{className:"mr-2 h-4 w-4",children:t}),ie("span",{className:"grow text-left",children:e}),ie(Ft,{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?ie("div",{ref:n,className:"df-portal df-animate-in df-fade-in df-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},er=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],tr=({x:t,y:n,date:r,onClose:o,app:l,onCreateEvent:s,viewType:i})=>{const{t:d}=ot(),c=je.hasEvent();return ie(Gn,{x:t,y:n,onClose:o,className:"df-context-menu",children:[ie(Kn,{onClick:()=>{s(),o()},children:d("newEvent")||"New Event"}),ie(Kn,{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),s=ge(o.end).getTime()-l.getTime(),i=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()+(s>0?s:36e5)),m=Object.assign(Object.assign({},i),{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,i),o()}),disabled:!c,children:d("pasteHere")||"Paste Here"})]})},nr=({event:e,x:n,y:r,onClose:o,app:l})=>{var s;const{t:i}=ot(),d=l.getCalendars(),c=l.callbacks,u=null===(s=null==c?void 0:c.renderEventContextMenu)||void 0===s?void 0:s.call(c,e,o);return ie(Gn,{x:n,y:r,onClose:o,children:[ie(Xn,{children:[ie(Jn,{children:i("calendars")||"Calendars"}),ie(Qn,{children:d.map(t=>{const n=t.id===e.calendarId;return ie(Kn,{onClick:()=>{return n=t.id,l.updateEvent(e.id,{calendarId:n}),void o();var n},children:ie("div",{className:"flex w-full items-center",children:[ie("div",{className:"w-4 shrink-0",children:n&&ie(Bt,{className:"h-3 w-3 text-primary"})}),ie("div",{className:"flex min-w-0 items-center gap-1.5",children:[ie("div",{className:"h-3 w-3 shrink-0 rounded-sm",style:{backgroundColor:t.colors.lineColor}}),ie("span",{className:"truncate "+(n?"font-semibold":""),children:t.name})]})]})},t.id)})})]}),ie(qn,{}),ie(Kn,{onClick:()=>{l.deleteEvent(e.id),o()},danger:!0,children:i("delete")||"Delete"}),ie(Kn,{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:i("cut")||"Cut"}),ie(Kn,{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:i("copy")||"Copy"}),u&&ie(t.Fragment,{children:[ie(qn,{}),u]})]})},rr=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("假期")?ie(Jt,{className:"h-3 w-3"}):t.includes("birthday")||t.includes("anniversary")||t.includes("生日")?ie(Qt,{className:"h-3 w-3"}):t.includes("conference")||t.includes("meeting")||t.includes("会议")||t.includes("研讨")?ie(tn,{className:"h-3 w-3"}):t.includes("trip")||t.includes("travel")||t.includes("旅行")?ie(en,{className:"h-3 w-3"}):ie(Kt,{className:"h-3 w-3"})},ar=(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),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){if(!(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=k(s,d)>0;if(!c&&e.allDay){if(s<t||s>a)return;const o=Math.floor((s.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=s;let h;if(e.allDay)h=new Date(i),h.setHours(23,59,59,999);else{0!==l.getHours()||0!==l.getMinutes()||0!==l.getSeconds()?(h=new Date(i),h.setHours(23,59,59,999)):(h=new Date(i),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},or=(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 s=k(o,l);if(0===s)return[];const i=0!==a.getHours()||0!==a.getMinutes()||0!==a.getSeconds()||0!==a.getMilliseconds(),d=a.getTime()-r.getTime();if(!e.allDay&&1===s&&!i&&d<864e5)return[];const c=i?s:Math.max(0,s-1),u=[];for(let e=0;e<=c;e++){const l=new Date(o);l.setDate(o.getDate()+e);const s=Math.floor((l.getTime()-t.getTime())/864e5);if(s<0||s>n-1)continue;const d=0===e,h=e===c,g=d?r.getHours()+r.getMinutes()/60:0,m=h&&i?a.getHours()+a.getMinutes()/60:24;u.push({dayIndex:s,startHour:g,endHour:m,isFirst:d,isLast:h})}return u},lr=n.memo(({segment:e,segmentIndex:n,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,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)&&i&&h?ie("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(),i(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 ie("div",{className:"pointer-events-auto flex w-full min-w-0 items-center",children:[e.isFirstSegment&&rr(e.event)&&ie("div",{className:"mr-1 shrink-0",children:ie("div",{className:"flex items-center justify-center rounded-full p-0.5 text-white",style:{backgroundColor:Y(n),width:"12px",height:"12px"},children:rr(e.event)})}),ie("div",{className:"min-w-0 flex-1",children:ie("div",{className:"truncate text-xs",children:t()})}),e.isLastSegment&&"single"!==e.segmentType&&ie("div",{className:"ml-1 shrink-0 text-white/80 dark:text-white/90",children:ie("div",{className:"h-1.5 w-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 ie("div",{className:"pointer-events-auto relative flex w-full min-w-0 items-center",children:[ie("div",{className:wt,style:{backgroundColor:Y(n)}}),ie("div",{className:"flex min-w-0 flex-1 items-center",children:ie("span",{className:`block overflow-hidden whitespace-nowrap ${c?"df-mobile-mask-fade":"truncate"} text-xs font-medium`,children:s})}),e.isFirstSegment&&!c&&ie("span",{className:"text-xs font-medium whitespace-nowrap "+(1===i?"ml-2":""),style:d,children:o}),e.isLastSegment&&!e.event.allDay&&24!==a&&!c&&ie("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 ie("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==s||s(t,e.event))},onMouseUp:()=>{v(!1)},onMouseLeave:()=>{v(!1)},onTouchStart:t=>{if(!s||!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&&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&&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&&ie(t.Fragment,{children:[e.isFirstSegment&&ie("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==i||i(t,e.event,"left")}}),e.isLastSegment&&ie("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==i||i(t,e.event,"right")}})]}),E("left"),ie("div",{className:"min-w-0 flex-1",style:{cursor:o?"ew-resize":"pointer"},children:p?p(C()):C()}),E("right")]});var M});lr.displayName="MultiDayEvent";const sr=({event:e,isEditable:n,onResizeStart:r,isMultiDay:a,segment:o,isSlidingView:l,renderSlot:s})=>{const i=!1!==e.icon,d="boolean"==typeof e.icon?null:e.icon,c=(()=>{if(!l||!a||!o)return{};if(o.startDayIndex<2&&o.endDayIndex>=2){return{paddingLeft:`calc(${(2-o.startDayIndex)/(o.endDayIndex-o.startDayIndex+1)*100}% + 0.75rem)`}}return{}})(),u=ie("div",{className:"flex h-full flex-1 items-center overflow-hidden",children:[i&&(d?ie("div",{className:"mr-1 shrink-0",children:d}):ie(Kt,{className:Dt})),ie("div",{className:`${xt} pr-1`,style:{lineHeight:"1.2"},children:e.title})]});return ie("div",{className:"absolute inset-0 flex items-center overflow-hidden pl-3 px-1 group py-0",style:c,children:[s?s(u):u,r&&n&&ie(t.Fragment,{children:[ie("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(),r(t,e,"left")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}),ie("div",{className:Et,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),r(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]})]})},ir=({event:e,isEventSelected:t})=>{const n=!1!==e.icon,r="boolean"==typeof e.icon?null:e.icon;return ie("div",{className:"text-xs px-1 rounded truncate cursor-pointer flex items-center",children:[n&&(r?ie("div",{className:`${$t} shrink-0`,children:r}):e.title.toLowerCase().includes("easter")||e.title.toLowerCase().includes("holiday")?ie("span",{className:`inline-block ${$t} shrink-0 ${t?"text-yellow-200":"text-yellow-600"}`,children:"⭐"}):ie(Kt,{className:`${Dt} ${t?"text-white":""}`})),ie("span",{className:"truncate "+(t?"text-white":""),children:e.title})]})},dr=({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 ie("div",{className:"text-xs cursor-pointer flex items-center justify-between px-0.5",children:[ie("div",{className:"flex min-w-0 flex-1 items-center",children:[ie("div",{style:{backgroundColor:Y(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())},className:wt}),ie("span",{className:`block overflow-hidden whitespace-nowrap ${a?"df-mobile-mask-fade":"truncate"} ${n?"text-white":""}`,children:e.title})]}),!r&&!a&&ie("span",{className:`${Ot} ml-1 shrink-0 ${n?"text-white":""}`,style:n?void 0:{opacity:.8},children:o})]})},cr=({event:e,app:n,multiDaySegmentInfo:r,isEditable:a,isTouchEnabled:o,isEventSelected:l,onResizeStart:s,timeFormat:i="24h",renderSlot:d})=>{const c=r?r.startHour:S(e.start),u=r?r.endHour:V(e),h=u-c,g=!r||r.isFirst,m=!r||r.isLast,p=e.calendarId||"blue",f=ie(t.Fragment,{children:[ie("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())}}),ie("div",{className:"flex h-full flex-col overflow-hidden pl-3 "+(V(e)-S(e.start)<=.25?"px-1 py-0":"p-1"),children:[ie("div",{className:`${xt} pr-1`,style:{lineHeight:h<=.25?"1.2":"normal"},children:e.title}),h>.5&&ie("div",{className:"df-event-time text-xs opacity-80 truncate",children:r?`${F(c,0,i)} - ${F(u,0,i)}`:_(e,i)})]})]});return ie(t.Fragment,{children:[d?d(f):f,s&&a&&ie(t.Fragment,{children:[g&&ie("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")}),m&&ie("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")}),!g&&m&&r&&ie("div",{className:Et,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),s(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]}),o&&l&&s&&a&&ie(t.Fragment,{children:[ie("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(p,null==n?void 0:n.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),s(t,e,"top")}}),ie("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(p,null==n?void 0:n.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),s(t,e,"bottom")}})]})]})},ur=({event:e,segment:n,isEditable:r,onMoveStart:a,onResizeStart:o,renderSlot:l})=>{const s=!!e.allDay,i=e.calendarId||"blue",d=Y(i),c=s?rr(e):null,{isFirstSegment:u,isLastSegment:h}=n,g=t=>{const n="left"===t,a=n?u:h;return e.allDay&&a&&o&&r?ie("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(s){const t=()=>n.isFirstSegment?e.title:"···";return ie("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&&rr(e)&&ie("div",{className:"df-year-event-icon mr-1 shrink-0",children:ie("div",{className:"flex items-center justify-center rounded-full p-0.5 text-white",style:{backgroundColor:Y(i),width:"12px",height:"12px"},children:rr(e)})}),ie("div",{className:"min-w-0 flex-1",children:ie("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&&ie("div",{className:"ml-1 shrink-0 text-white/80 dark:text-white/90",children:ie("div",{className:"h-1.5 w-1.5 rounded-full bg-white/60 dark:bg-white/80"})})]})}const t=n.isFirstSegment?e.title:"";return ie("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:[!s&&ie("span",{style:{backgroundColor:d},className:"df-year-event-indicator inline-block h-3 w-0.75 shrink-0 rounded-full"}),s&&c&&ie("div",{className:"df-year-event-icon flex shrink-0 scale-75 items-center justify-center opacity-80",children:c}),ie("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 ie(t.Fragment,{children:[g("left"),l?l(m()):m(),g("right")]})};const hr=({event:e,viewType:t,isAllDay:n,isMultiDay:r,segment:a,yearSegment:o,segmentIndex:l,isBeingDragged:s,isBeingResized:i,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 ie(lr,{segment:a,segmentIndex:null!=l?l:0,isDragging:s||d,isResizing:i,isSelected:d,onMoveStart:b,onResizeStart:x,isMobile:f,isDraggable:h,isEditable:u,viewable:g,isPopping:c,renderSlot:e=>ie(vn,{store:D,generatorName:S,generatorArgs:E,defaultContent:e})});if(k&&o)return ie(ur,{event:e,segment:o,isEditable:u,onMoveStart:b,onResizeStart:x,renderSlot:e=>ie(vn,{store:D,generatorName:S,generatorArgs:E,defaultContent:e})});if(T){const t=e.allDay?ie(ir,{event:e,isEventSelected:d}):ie(dr,{event:e,app:y,isEventSelected:d,hideTime:p,isMobile:f});return ie(vn,{store:D,generatorName:S,generatorArgs:E,defaultContent:t})}const M=e=>ie(vn,{store:D,generatorName:S,generatorArgs:E,defaultContent:e});return n?ie(sr,{event:e,isEditable:u,onResizeStart:x,isMultiDay:r,segment:a,isSlidingView:v,renderSlot:M}):ie(cr,{event:e,app:y,multiDaySegmentInfo:w,isEditable:u,isTouchEnabled:m,isEventSelected:d,onResizeStart:x,timeFormat:C,renderSlot:M})},gr=({event:t,position:a,panelRef:o,isAllDay:l,eventVisibility:s,calendarRef:i,selectedEventElementRef:d,onEventUpdate:c,onEventDelete:u,app:h})=>{var g;const{effectiveTheme:m}=mn(),p=Ne(m),{t:f}=ot(),[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"===s){const n=null===(e=i.current)||void 0===e?void 0:e.querySelector(".df-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"===s){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&&i.current){const e=d.current.getBoundingClientRect(),n=i.current.querySelector(".df-calendar-content");if(n){const r=n.getBoundingClientRect(),l=Math.max(e.top,r.top),s=Math.min(e.bottom,r.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-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=ie("div",{ref:o,className:`${St} 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:[ie("div",{style:M}),ie("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:f("eventTitle")}),ie("div",{className:"mb-3 flex items-center justify-between gap-3",children:[ie("div",{className:"flex-1",children:ie("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&&ie(In,{options:E,value:t.calendarId||"blue",onChange:e=>{c(Object.assign(Object.assign({},t),{calendarId:e}))},registry:null==h?void 0:h.getCalendarRegistry()})]}),ie("div",l?{className:"mb-3",children:[ie("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:f("dateRange")}),ie(Nn,{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:[ie("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:f("timeRange")}),ie(Nn,{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})]}),ie("div",{className:"mb-3",children:[ie("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:f("note")}),ie("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&&ie("div",{className:"flex space-x-2",children:[ie("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(),n=y(t.end)?t.end:t.end.toPlainDate();c(Object.assign(Object.assign({},t),{allDay:!0,start:e,end:n}))},children:f("setAsAllDay")}),ie("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},mr=({event:e,position:t,panelRef:r,isAllDay:a,eventVisibility:o,calendarRef:l,selectedEventElementRef:s,onEventUpdate:i,onEventDelete:d,onClose:c,contentRenderer:u})=>{const{effectiveTheme:h}=mn(),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(".df-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&&s.current&&l.current){const e=s.current.getBoundingClientRect(),a=l.current.querySelector(".df-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=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=ie("div",{ref:r,className:`${St} 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:[ie("div",{style:f}),ie(u,{event:e,isAllDay:a,onEventUpdate:i,onEventDelete:d,onClose:c})]});return n.createPortal(v,document.body)},pr=({showDetailPanel:e,customEventDetailDialog:t,detailPanelPosition:n,event:r,detailPanelRef:a,isAllDay:o,eventVisibility:l,calendarRef:s,selectedEventElementRef:i,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:s,selectedEventElementRef:i,onEventUpdate:d,onEventDelete:c,onClose:u};return(null==h?void 0:h.isOverridden("eventDetailContent"))?ie(mr,Object.assign({},f,{contentRenderer:g})):m?ie(mr,Object.assign({},f,{contentRenderer:m})):ie(gr,Object.assign({},f,{app:p}))},fr=(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},vr=(e,t,n,r,a)=>{let o="df-event calendar-event select-none pointer-events-auto";const l=e===exports.ViewType.DAY,s=e===exports.ViewType.MONTH,i=e===exports.ViewType.YEAR;l?o+=" df-day-event flex flex-col":s||i?i&&(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 yt;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 yt};if(i)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(s){let e=`\n ${o}\n ${t?d():bt}\n `;return n||(e+=" mb-[2px] last:mb-0"),e}return`\n ${o}\n shadow-sm\n ${t?d():bt}\n `},yr=({event:e,layout:n,isAllDay:a=!1,allDayHeight:o=28,calendarRef:l,isBeingDragged:s=!1,isBeingResized:i=!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(pn),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:se,isPressed:de,setIsPressed:ce,handleTouchStart:ue,handleTouchMove:he,handleTouchEnd:ge}=(({event:e,isTouchEnabled:t,onMoveStart:n,onEventLongPress:a,onDetailPanelToggle:o,canOpenDetail:l,app:s,multiDaySegmentInfo:i,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,s=o.clientY,u=r.currentTarget;v.current={x:l,y:s},f.current=setTimeout(()=>{var t;a?a(e.id):g(!0);const r={preventDefault:()=>{},stopPropagation:()=>{},currentTarget:u,touches:[{clientX:l,clientY:s}],cancelable:!1};if(i){const a=Object.assign(Object.assign({},e),{day:null!==(t=i.dayIndex)&&void 0!==t?t:e.day,_segmentInfo:i});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(),s&&s.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||s,[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=fr(t,r),l=n===exports.ViewType.DAY?1:7,s=(a.width-o)/l,i=e-a.left-o,d=Math.floor(i/s);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=fr(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:s,eventRef:i,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||!s.current||!d.current)return;const e=s.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=fr(s,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,s;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=i.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!==(s=null==n?void 0:n.left)&&void 0!==s?s: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})})})},[s,e.day,e.start,e.end,h,C,g,m,n,a,l,v,y,u,E,T,o,p,b,x,c,d,i]);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:s,firstHour:i,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(!s.current||n||E||C)return void t();const r=s.current.querySelector(".df-calendar-content");if(!r)return void t();const a=l?l.startHour:S(e.start),o=l?l.endHour:V(e),c=(a-i)*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-i)*d-g/2,p=r.scrollHeight-g;r.scrollTo({top:Math.max(0,Math.min(p,m)),behavior:"smooth"}),setTimeout(()=>t(),300)}),[s,n,E,C,l,e.start,e.end,i,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,s,i;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!==(s=null==o?void 0:o.endDayIndex)&&void 0!==s?s:6))}else b(null!==(i=e.day)&&void 0!==i?i: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,s;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!==(s=e.day)&&void 0!==s?s: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:se,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:s,columnsPerRow:i,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&&s&&i){const{startCellIndex:e,endCellIndex:t,visualRowIndex:n}=s,r=2;return{position:"absolute",left:`calc(${e/i*100}% + ${r}px)`,top:18*n+"px",width:`calc(${(t-e+1)/i*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=i||7,n=(l.endDayIndex-l.startDayIndex+1)/t*100,r=l.startDayIndex/t*100,a=2,o=l.isFirstSegment?a:0,s=o+(l.isLastSegment?a:0);Object.assign(e,{width:s>0?`calc(${n}% - ${s}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=fr(y,b),a=C?1:i||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 s=D(n);s&&(l=s.left,o=s.width);let d=null===(N=y.current)||void 0===N?void 0:N.querySelector(".df-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:s,multiDaySegmentInfo:i,firstHour:d,hourHeight:c,updatePanelPosition:u,eventVisibility:h,setEventVisibility:g})=>{const m=s===exports.ViewType.MONTH,p=s===exports.ViewType.YEAR,f=r.useCallback(()=>{if(!t||!n||!a.current||!o.current||l||m||p)return;const r=o.current.querySelector(".df-calendar-content");if(!r)return;const s=i?i.startHour:S(e.start),f=i?i.endHour:V(e),v=(s-d)*c,y=v+Math.max((f-s)*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,i,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(".df-calendar-content");if(!a)return;const s=()=>f(),i=()=>{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",s)}),window.addEventListener("scroll",s,!0),window.addEventListener("resize",i);let h=null;return o.current&&(h=new ResizeObserver(()=>{i()}),h.observe(o.current)),f(),()=>{d.forEach(e=>{e.removeEventListener("scroll",s)}),window.removeEventListener("scroll",s,!0),window.removeEventListener("resize",i),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: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:K,detailPanelRef:q,eventId:e.id,isEventSelected:!Me&&me,showDetailPanel:te,onEventSelect:T,onDetailPanelToggle:M,setIsSelected:se,setActiveDayIndex:ve});const Ne=r.useCallback(()=>{T&&T(null),J.current=null,se(!1),null==M||M(null)},[T,M,se]),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:s,segment:u,layout:n}),[e,d,a,A,me,s,u,n]),He=r.useCallback(()=>ie(vn,{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 ie(t.Fragment,{children:[ie("div",{ref:K,"data-event-id":e.id,className:`${vr(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:ie(hr,{event:e,viewType:d,isAllDay:a,isMultiDay:c,segment:u,yearSegment:h,segmentIndex:m,isBeingDragged:s,isBeingResized:i,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&&ie("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:9998,pointerEvents:"none"}}),ie(pr,{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&&ie(nr,{event:e,x:U.x,y:U.y,onClose:()=>B(null),app:H,onDetailPanelToggle:M,detailPanelKey:Q})]})},br=({handlePreviousMonth:e,handleToday:t,handleNextMonth:n})=>{const{t:r}=ot();return ie("div",{className:"df-navigation flex items-center gap-1",children:[ie("button",{type:"button",className:Tt,onClick:e,"aria-label":"Previous month",children:ie(Yt,{className:kt})}),ie("button",{type:"button",className:"df-today-button df-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")}),ie("button",{type:"button",className:Tt,onClick:n,"aria-label":"Next month",children:ie(Ft,{className:kt})})]})},xr=({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}=ot(),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 ie("div",{className:st,style:{position:"relative"},onContextMenu:e=>e.preventDefault(),children:[ie("div",{className:"flex-1",children:ie("div","year"===e&&i?{style:{position:"relative",overflow:"hidden",height:"1.5em"},children:[ie("h1",{className:it,style:{position:"absolute",top:0,left:0,transform:`translateY(-${d}px)`,willChange:"transform"},children:i}),c&&ie("h1",{className:it,style:{position:"absolute",top:0,left:0,transform:`translateY(${u}px)`,willChange:"transform"},children:c})]}:{children:[ie("div",{className:`${it} text-gray-900 dark:text-white`,children:m}),p&&ie("div",{className:"mt-3 leading-6 text-gray-600 dark:text-gray-400",children:p})]})}),g&&n&&r&&a&&ie("div",{className:"flex items-center gap-2",children:ie(br,{handlePreviousMonth:n,handleNextMonth:r,handleToday:a})})]})};function wr(e,t,n,r,a){if(r||0!==e.button)return;let o=!0;const l={move(r){if(!o)return;Math.hypot(r.clientX-e.clientX,r.clientY-e.clientY)>=5&&(o=!1,document.removeEventListener("mousemove",l.move),document.removeEventListener("mouseup",l.up),null==a||a(e,t,n),document.dispatchEvent(new MouseEvent("mousemove",{clientX:r.clientX,clientY:r.clientY,bubbles:!0,cancelable:!1})))},up(){o=!1,document.removeEventListener("mousemove",l.move),document.removeEventListener("mouseup",l.up)}};document.addEventListener("mousemove",l.move),document.addEventListener("mouseup",l.up)}function Dr(){document.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0,cancelable:!1}))}const Er=({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: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}=ot(),ne=r.useRef(e.state.highlightedEventId),[re,ae]=r.useState(null),oe=r.useMemo(()=>Me(),[]),le=()=>{var e;const t=null===(e=O.current)||void 0===e?void 0:e.querySelector(".df-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},se=e=>{var t;const n=null===(t=O.current)||void 0===t?void 0:t.querySelector(".df-calendar-content");if(!n)return null;const r=n.getBoundingClientRect(),a=n.scrollTop||0;return U+(e-r.top+a-le())/W},de=(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=O.current)||void 0===r?void 0:r.querySelector(".df-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(".df-calendar-content"))||void 0===l?void 0:l.scrollTop)||0,r=le(),a=(e.clientY-t.top+n-r)/W+U,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)}}ae({x:e.clientX,y:e.clientY,date:s})};return ie("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:[ie("div",{className:`relative ${Lt} h-full`,children:[ie("div",{onContextMenu:e=>e.preventDefault(),style:{paddingRight:j||!oe?"0px":"15px"},children:ie(xr,{calendar:e,viewType:exports.ViewType.DAY,currentDate:t})}),ie("div",Z?{className:jt(vt,"relative items-stretch border-t border-gray-200 dark:border-gray-700"),ref:P,style:{paddingRight:j||!oe?"0px":"0.6875rem"},onContextMenu:e=>de(e,!0),children:[ie("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")}),ie("div",{className:jt("relative flex flex-1 self-stretch",!j&&oe?"border-r border-gray-200 dark:border-gray-700":""),children:ie("div",{className:"relative w-full",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=>ie(yr,{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),ne.current=null))},onEventLongPress:e=>{(j||Y)&&g(e)},customDetailPanelContent:H,customEventDetailDialog:A,app:e,isMobile:j,enableTouch:Y},t.id))})})]}:{className:!j&&oe?"pr-2.75":""}),ie("div",{className:"relative overflow-y-auto df-calendar-content df-day-time-grid",style:{position:"relative",scrollbarGutter:"stable"},children:ie("div",{className:"relative flex",children:[c&&u&&(()=>{const e=u,t=e.getHours()+e.getMinutes()/60;if(t<U||t>B)return null;return ie("div",{className:pt,style:{top:`${(t-U)*W}px`,width:"100%",height:0,zIndex:20,marginTop:ee?"2rem":"0.75rem"},children:[ie("div",{className:"flex w-12 items-center md:w-20",children:[ie("div",{className:"relative flex w-full items-center"}),ie("div",{className:ft,children:F(t,0,K,!1)})]}),ie("div",{className:"flex flex-1 items-center",children:ie("div",{className:"df-current-time-bar h-0.5 w-full bg-primary relative"})})]})})(),ie("div",{className:"df-time-column flex-shrink-0 "+(ee?"w-20 md:w-22":"w-12 md:w-20"),onContextMenu:e=>e.preventDefault(),children:[ie("div",{className:ee?"h-8":"h-3",children:ee&&ie("div",{className:"flex items-center justify-evenly gap-1 pt-1 pr-1 pb-0.5",children:[ie("span",{className:"text-[9px]select-none text-gray-500 md:text-[10px] dark:text-gray-400",children:J}),ie("span",{className:"text-[9px] text-gray-500 md:text-[10px] dark:text-gray-400",children:X})]})}),i.map((e,t)=>{var n;return ie("div",{className:ht,children:ie("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:[ie("span",{className:"text-[10px] md:text-[12px]",children:G&&0===t?"":null!==(n=null==q?void 0:q[t])&&void 0!==n?n:""}),ie("span",{className:"text-[10px] text-gray-500 md:text-[12px] dark:text-gray-400",children:G&&0===t?"":e.label})]}:{className:`${gt} text-[10px] md:text-[12px]`,children:G&&0===t?"":e.label})},t)})]}),ie("div",{className:"grow select-none",children:[ie("div",{className:jt(Nt,!j&&oe?"border-r":"","border-t-0"),style:ee?{height:"2rem"}:void 0,children:ie("div",{className:`${It} -left-9.5`,style:{top:"auto",bottom:"-0.625rem"},children:G?F(U,0,K):""})}),ie("div",{className:"relative",style:{WebkitTouchCallout:"none"},ref:L,children:[i.map((e,r)=>ie("div",{className:jt(mt,!j&&oe?"border-r":""),onClick:()=>null==R?void 0:R(t),onMouseDown:e=>{const r=se(e.clientY);if(null===r)return;wr(e,Math.floor((t.getTime()-n.getTime())/864e5),r,Y,D)},onDblClick:e=>{const r=se(e.clientY);if(null===r)return;const a=Math.floor((t.getTime()-n.getTime())/864e5);null==D||D(e,a,r),Dr()},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(".df-calendar-content"))||void 0===r?void 0:r.getBoundingClientRect();if(!l)return;const s=(null===(o=null===(a=O.current)||void 0===a?void 0:a.querySelector(".df-calendar-content"))||void 0===o?void 0:o.scrollTop)||0,i=le(),d=e.clientY-l.top+s-i,c=Math.floor(U+d/W);M(e,t,c)},onContextMenu:e=>de(e,!1)},r)),ie("div",{className:jt(Nt,!j&&oe?"border-r":""),children:ie("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:[ie("span",{children:null!==(Q=null==q?void 0:q[0])&&void 0!==Q?Q:""}),ie("span",{children:F(0,0,K)})]}:{className:`${It} -left-9.5`,children:F(0,0,K)})}),ie("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 ie(yr,{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),ne.current=null))},onEventLongPress:e=>{(j||Y)&&g(e)},customDetailPanelContent:H,customEventDetailDialog:A,app:e,isMobile:j,enableTouch:Y},t.id)})})]})]})]})})]}),re&&ie(tr,{x:re.x,y:re.y,date:re.date,viewType:exports.ViewType.DAY,onClose:()=>ae(null),app:e,onCreateEvent:()=>{if(D){const e=Math.floor((t.getTime()-n.getTime())/864e5);if(0===re.date.getHours()&&0===re.date.getMinutes())null==E||E({clientX:re.x,clientY:re.y},e);else{const t=re.date.getHours()+re.date.getMinutes()/60,n={preventDefault:()=>{},stopPropagation:()=>{},clientX:re.x,clientY:re.y};D(n,e,t)}}}})]})},Cr=({app:e,currentDate:t,visibleMonth:n,currentDayEvents:r,selectedEvent:a,setSelectedEvent:o,handleMonthChange:l,handleDateSelect:s,switcherMode:i,timeFormat:d="24h"})=>{const{t:c,locale:u}=ot(),h=[...r].toSorted((e,t)=>e.allDay&&!t.allDay?-1:!e.allDay&&t.allDay?1:0);return ie("div",{className:"df-right-panel hidden flex-none md:block w-[30%] bg-white dark:bg-gray-900",onContextMenu:e=>e.preventDefault(),children:ie("div",{className:`${Lt} h-full`,children:[ie("div",{className:"df-mini-calendar px-2 border-b border-gray-200 dark:border-gray-700",children:ie("div",{children:[ie("div",{className:"flex items-center justify-end gap-2",children:[ie("div",{className:st,style:{position:"relative"},children:ie("div",{children:ie("h1",{className:it,children:" "})})}),ie(br,{handlePreviousMonth:()=>e.goToPrevious(),handleNextMonth:()=>e.goToNext(),handleToday:()=>e.goToToday()})]}),ie(On,{visibleMonth:n,currentDate:t,showHeader:!0,onMonthChange:l,onDateSelect:s})]})}),ie("div",{className:"flex-1 overflow-y-auto",children:ie("div",{className:"p-4",children:[ie("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?ie("p",{className:`${Ht} ${Pt}`,children:c("noEvents")}):ie("div",{className:"space-y-2",children:h.map(t=>ie("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:[ie("div",{className:`font-medium ${Pt}`,children:t.title}),!t.allDay&&ie("div",{className:`${Ot} ${At}`,children:[F(S(t.start),0,d)," ","- ",F(V(t),0,d)]}),t.allDay&&ie("div",{className:`${Ot} ${At}`,children:c("allDay")})]},t.id))})]})})]})})},Tr={PARALLEL_THRESHOLD:.25,NESTED_THRESHOLD:.5,INDENT_STEP_PERCENT:2.5,MIN_WIDTH:25,MARGIN_BETWEEN:1,EDGE_MARGIN_PERCENT:.9};function kr(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 Sr(e){var t;return null!==(t=e._startHour)&&void 0!==t?t:S(e.start)}function Mr(e){var t;return null!==(t=e._endHour)&&void 0!==t?t:V(e)}function Nr(e,t){return e.day===t.day&&!e.allDay&&!t.allDay&&(Sr(e)<Mr(t)&&Sr(t)<Mr(e))}function Ir(e,t){const n=Mr(e)-Sr(e);if(n<1.25)return!1;const r=Sr(e)+.4*n,a=Sr(t)>=r,o=Nr(e,t);return a&&o}function Rr(e,t,n=Tr){if(!Nr(e,t))return!1;const r=Math.abs(Sr(e)-Sr(t));return r<=n.PARALLEL_THRESHOLD||(r>n.PARALLEL_THRESHOLD&&r<n.NESTED_THRESHOLD||function(e,t){return!(!Nr(e,t)||!Ir(e,t)&&!Ir(t,e))}(e,t))}function Hr(e,t){const n=Sr(e)<=Sr(t)&&Mr(e)>=Mr(t),r=Sr(e)<=Sr(t)&&Sr(t)<Mr(e)&&Nr(e,t);return n||r}function Ar(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(Sr(r)-Sr(t))<=Tr.PARALLEL_THRESHOLD&&(a.push(t),n.add(t.id))}a.sort((e,t)=>Sr(e)-Sr(t));const o={events:a,startHour:Math.min(...a.map(e=>Sr(e))),endHour:Math.max(...a.map(e=>Mr(e)))};t.push(o)}return t.sort((e,t)=>e.startHour-t.startHour),t}function Or(e){return"day"===e?.5:2.5}function Pr(e){const t=Mr(e)-Sr(e);return Math.max(.1,Math.min(1,t/4))}function Lr(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(Rr(e[t],e[n],Tr))return!0;return!1}function $r(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:Pr(e.event)}),0===e.children.length)return;const u=[...e.children].toSorted((e,t)=>Mr(t.event)-Sr(t.event)-(Mr(e.event)-Sr(e.event)));1===u.length?$r(u[0],d,c,r,a):Lr(u.map(e=>e.event))?jr(u,d,c,r,a):u.forEach(e=>$r(e,d,c,r,a))}function jr(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=>$r(e,t,n,r,a));let h=Tr.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:Pr(e.event)}),e.children.length>0){const t=[...e.children].toSorted((e,t)=>Mr(t.event)-Sr(t.event)-(Mr(e.event)-Sr(e.event)));1===t.length?$r(t[0],n,g,r,a):Lr(t.map(e=>e.event))?jr(t,n,g,r,a):t.forEach(e=>$r(e,n,g,r,a))}})}function Yr(e,t,n={}){const r=100-("day"===n.viewType?0:Tr.EDGE_MARGIN_PERCENT);if(1===e.length)$r(e[0],0,r,t,n);else if(e.length>1){const a=e.length,o=(r-Tr.MARGIN_BETWEEN*(a-1))/a;e.forEach((e,r)=>{$r(e,r*(o+Tr.MARGIN_BETWEEN),Math.max(o,Tr.MIN_WIDTH),t,n)})}}function Fr(e){let t=0;for(const n of e.children)t+=1+Fr(n);return t}function Vr(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:Fr(e)})).toSorted((e,t)=>t.load-e.load)}function _r(e){return!(e.length<2)&&e[0].load-e.at(-1).load>=2}function zr(e,t){t.parentId=e.id,e.children.includes(t.id)||e.children.push(t.id)}function Wr(e,t){e.parent&&(e.parent.children=e.parent.children.filter(t=>t!==e));const n=t.children.find(t=>Hr(t.event,e.event));n?(e.parent=n,e.depth=n.depth+1,n.children.push(e),zr(n.event,e.event)):(e.parent=t,e.depth=t.depth+1,t.children.push(e),zr(t.event,e.event))}function Ur(e,t){0===e.children.length?t.push(e):e.children.forEach(e=>Ur(e,t))}function Br(e,t){const n=[];return Ur(e,n),n.find(e=>Hr(t.event,e.event))||n[0]||null}function Zr(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=Br(n.node,r.node);if(!a)break;Wr(a,r.node),n.load--,r.load++,t++}}function Gr(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(Nr(n,e)&&Math.abs(Sr(e)-Sr(n))<Tr.NESTED_THRESHOLD)return!0;return!1}(e,t))return!1;if(n<Tr.NESTED_THRESHOLD)return!1;for(const n of e.events)for(const e of t.events)if(Hr(n,e))return!0;return!1}function Kr(e,t,n){const r=t.events.filter(t=>Hr(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&&Rr(e,r,Tr)})}));return a.sort((t,n)=>t.load!==n.load?t.load-n.load:t.hasParallelSibling!==n.hasParallelSibling?t.hasParallelSibling?-1:1:Math.abs(Sr(e)-Sr(t.parent))-Math.abs(Sr(e)-Sr(n.parent))),a[0].parent}function qr(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=Mr(e)-Sr(e),l=a.flatMap(e=>e.children);return o>Math.max(...l.map(e=>{const t=n.find(t=>t.id===e);return t?Mr(t)-Sr(t):0}),0)?a[0]:a.at(-1)||null}function Xr(e,t){t.parentId=e.id,e.children.includes(t.id)||e.children.push(t.id)}function Jr(e){let t=0;for(const n of e.children)t+=1+Jr(n);return t}function Qr(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 ea(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,s=null;for(const e of o){const t=Jr(e);t<l&&(l=t,s=e)}return s?s.event:null}function ta(e,t,n){const r=[];if(1===e.length){const a=Kr(e[0],t,n);return a&&(r.push({child:e[0],parent:a}),Xr(a,e[0])),r}const a=t.events.filter(t=>e.every(e=>Hr(t,e)));if(0===a.length){for(const a of e){const o=Kr(a,t,n);if(o)r.push({child:a,parent:o}),Xr(o,a);else{const t=e.find(e=>e.id!==a.id&&Nr(e,a));if(t){const e=ea(t,Qr(n));e&&(r.push({child:a,parent:e}),Xr(e,a))}}}return r}const o=[...e].toSorted((e,t)=>Mr(t)-Sr(t)-(Mr(e)-Sr(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}),Xr(n,e)}}else for(const e of o){const t=qr(e,a,o);t&&(r.push({child:e,parent:t}),Xr(t,e))}return r}function na(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(Gr(d,{events:l,startHour:o.startHour,endHour:o.endHour})){const e=ta(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=Vr(e[n].events.map(e=>t.find(t=>t.event.id===e.id)),t);_r(r)&&Zr(r)}}(e,n),o}const ra={calculateDayEventLayouts(e,t={}){const n=e.map(kr);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)||Nr(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:Tr.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{Yr(na(Ar([...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}},aa=(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},oa={HOUR_HEIGHT:72,FIRST_HOUR:0,LAST_HOUR:24,ALL_DAY_HEIGHT:28};function la(t){const{app:n,onEventCreated:a}=t,{t:o}=ot(),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,s)=>{if(t.preventDefault(),!t.dataTransfer)return null;const i=t.dataTransfer.getData("application/x-dayflow-calendar");if(!i)return null;try{const t=JSON.parse(i);let d,c,u=!1;s?(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 sa=null;const ia={handleMoveStart:()=>{},handleCreateStart:()=>{},handleResizeStart:void 0,handleCreateAllDayEvent:()=>{},dragState:{active:!1,mode:null,eventId:null,targetDate:null,startDate:null,endDate:null},isDragging:!1};function da(e,t){return sa?sa(e,t):ia}const ca=({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}=rt(),m="desktop"!==g,[p,f]=r.useState(!1),{hourHeight:v=oa.HOUR_HEIGHT,firstHour:y=oa.FIRST_HOUR,lastHour:x=oa.LAST_HOUR,allDayHeight:D=oa.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()||$n,[A,O]=r.useState(null),[P,L]=r.useState(null),[$,j]=r.useState(null),Y=void 0===s?P:s,V=void 0===c?$:c,_=r.useMemo(()=>Y&&h.find(e=>e.id===Y)||null,[Y,h]),U=e=>{i?i(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(".df-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),se=r.useRef(null),de=r.useMemo(()=>aa(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,s=!1;return t<n&&(o=b(n),s=!0),a>r&&(l=b(r),s=!0),Object.assign(Object.assign({},e),{start:s?o:e.start,end:s?l:e.end,day:0})})})(ce,Q),[ce,Q]),he=r.useMemo(()=>ra.calculateDayEventLayouts(ue,{viewType:"day"}),[ue]),ge=r.useMemo(()=>((e,t)=>{const n=e.filter(e=>e.allDay);if(t)n.sort(t);else{const e=new Map;n.forEach(t=>{e.has(t.calendarId)||e.set(t.calendarId,e.size)}),n.sort(tt(n,(t,n)=>{var r,a;return(null!==(r=e.get(t.calendarId))&&void 0!==r?r:0)-(null!==(a=e.get(n.calendarId))&&void 0!==a?a:0)}))}const r=[],a=[];return n.forEach(e=>{let t=0,n=!1;for(;!n;)r[t]?r[t].some(t=>{const n=w(e.start),r=w(e.end),a=w(t.start);return n<=w(t.end)&&a<=r})?t++:(r[t].push(e),a.push(Object.assign(Object.assign({},e),{row:t})),n=!0):(r[t]=[e],a.push(Object.assign(Object.assign({},e),{row:t})),n=!0)}),a})(ce,e.state.allDaySortComparator),[ce,e.state.allDaySortComparator]),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}=da(e,{calendarRef:o,allDayRowRef:E?le:void 0,timeGridRef:se,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)),s=new Set(ce.map(e=>e.id)),i=a.filter(e=>!s.has(e.id)),d=a.filter(e=>{if(!s.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:i,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 s=[...a,{id:"-1",title:"Temp",day:0,start:b(o),end:b(l),calendarId:"blue",allDay:!1}];return ra.calculateDayEventLayouts(s,{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),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:b(i),end:b(d),day:0})];return 0===c.length?null:ra.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}=la({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(".df-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)},[]),ie("div",{className:"df-day-view flex h-full bg-gray-50 dark:bg-gray-800",children:[ie(Er,{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,s;const i=null===(n=null===(e=o.current)||void 0===e?void 0:e.querySelector(".df-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(".df-calendar-content"),c=d?d.scrollTop:0,u=a-i.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:se,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}),ie(Cr,{app:e,currentDate:Q,visibleMonth:ee,currentDayEvents:ce,selectedEvent:_,setSelectedEvent:e=>U(e?e.id:null),handleMonthChange:ae,handleDateSelect:Se,switcherMode:l,timeFormat:C}),ie(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})]})},ua=({originalComponent:e,app:t,config:n,customDetailPanelContent:a,customEventDetailDialog:o,calendarRef:l,switcherMode:s,meta:i,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:s,meta:i,selectedEventId:d,detailPanelEventId:c,onEventSelect:u,onDetailPanelToggle:g}),[t,f,v,y,b,x,w,D,E,C,a,o,l,s,i,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 ie(e,Object.assign({},k))},ha={showAllDay:!0,scrollToCurrentTime:!0,hourHeight:72,firstHour:0,lastHour:24,allDayHeight:28,timeFormat:"24h"},ga=(e={})=>{const n=Object.assign(Object.assign({},ha),e),r=e=>t.h(ua,{viewType:exports.ViewType.DAY,originalComponent:ca,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}},ma=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)},pa=({app:e,fullWeekDates:n=[],mobilePageStart:r,onDateChange:a})=>ie("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:[ie("div",{className:"mb-1 grid grid-cols-7",children:n.map((e,t)=>ie("div",{className:"flex justify-center",children:ie("span",{className:"text-[10px] font-medium "+(e.isToday?"text-primary":"text-gray-500"),children:ma(e.dayName)})},`label-${t}`))}),ie("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)`,s=`calc(${1/7*100}% + 32px)`;return ie(t.Fragment,{children:[ie("div",{className:"absolute rounded-full bg-gray-100 transition-all duration-300 dark:bg-gray-800",style:{left:l,top:0,width:s,height:"32px"}}),n.map((t,n)=>{const r=t.isCurrent,l=n>=o&&n<o+2;return ie("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:ie("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&&ie("div",{className:"absolute bottom-1 h-1 w-1 rounded-full bg-primary"})]})},`date-${n}`)})]})})()})]}),fa=({app:e,weekDaysLabels:n,mobileWeekDaysLabels:a,weekDates:o,fullWeekDates:l,isSlidingView:s,mobilePageStart:i,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 ie("div",{className:"flex w-full flex-col",children:[s&&l&&i&&ie(pa,{app:e,fullWeekDates:l,mobilePageStart:i,onDateChange:H}),ie("div",{className:`flex flex-none ${f?"border-b border-gray-200 dark:border-gray-700":""} relative z-10`,onContextMenu:e=>e.preventDefault(),children:[f&&ie("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:[ie("div",{className:"flex flex-1 items-center border-b border-gray-200 transition-all duration-300 ease-in-out dark:border-gray-700 "+(s?"hidden":""),children:G&&ie("div",{className:"flex w-full items-center justify-evenly gap-0.5 pt-2 pb-0.5",children:[ie("span",{className:"text-[9px] text-gray-500 select-none md:text-[10px] dark:text-gray-400",children:k}),ie("span",{className:"text-[9px] text-gray-500 select-none md:text-[10px] dark:text-gray-400",children:T})]})}),ie("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})]}),ie("div",{className:"relative flex-1 overflow-hidden transition-[min-height] duration-300 ease-in-out",style:{scrollbarGutter:"stable",minHeight:f?`${u+(s?0:36)}px`:"auto"},children:ie("div",{ref:b,className:"flex flex-col",style:{width:c,minWidth:"100%",transform:s?"translateX(calc(-100% / 3))":void 0},children:[!s&&ie("div",{className:"df-week-header flex border-b",style:{marginRight:Z?"-50px":"0px",paddingRight:Z?"50px":"0px"},children:n.map((e,n)=>ie("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:ie(t.Fragment,m?{children:[ie("div",{className:"text-[12px] leading-tight font-medium text-gray-500",children:a[n]}),ie("div",{className:`${dt} h-7 w-7 text-base font-medium ${o[n].isToday?Ct:""}`,children:o[n].date})]}:{children:[ie("div",{className:"mt-1 mr-1 inline-flex items-center justify-center text-sm",children:e}),ie("div",{className:`${dt} ${o[n].isToday?Ct:""}`,children:o[n].date})]})},n))}),f&&ie("div",{className:`${vt} relative border-none transition-[min-height] duration-300 ease-in-out`,ref:y,style:{minHeight:`${u}px`},children:ie("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),ie("div",{className:"df-all-day-cell flex-1 border-r 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}`)}),ie("div",{className:"pointer-events-none absolute inset-0",children:h.map(t=>ie(yr,{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:s,enableTouch:p},t.event.id))})]})})]})}),U&&ie(tr,{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)}})]})]})},va=({app:e,timeSlots:n,weekDaysLabels:a,currentWeekStart:o,currentWeekEvents:l,eventLayouts:s,gridWidth:i,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(),[]),re=e=>{if(!h.current)return z;const t=h.current.getBoundingClientRect();return z+(e-t.top)/_};return ie("div",{className:"relative flex flex-1 overflow-hidden",children:[ie("div",{ref:u,className:"df-calendar-content relative flex-1 overflow-auto "+("300%"===i?"overflow-x-hidden":"snap-x snap-mandatory"),style:{display:"grid",gridTemplateColumns:"auto 1fr"},onScroll:f,children:[ie("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:[ie("div",{className:"relative h-3",children:X?ie(t.Fragment,{children:ie("div",{className:"absolute right-0 -bottom-1 flex w-full items-center justify-evenly select-none",children:[ie("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:""}),ie("span",{className:"text-[10px] text-gray-500 md:text-[12px] dark:text-gray-400",children:U?F(z,0,B):""})]})}):ie("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 ie("div",{className:ht,children:ie("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:[ie("span",{className:"text-[10px] md:text-[12px]",children:U&&0===t?"":null!==(n=null==Z?void 0:Z[t])&&void 0!==n?n:""}),ie("span",{className:"text-[10px] md:text-[12px]",children:U&&0===t?"":e.label})]}:{className:`${gt} text-[10px] md:text-[12px]`,children:U&&0===t?"":e.label})},t)}),ie("div",{className:"relative",children:ie("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:[ie("span",{className:"text-[10px] md:text-[12px]",children:null!==(q=null==Z?void 0:Z[0])&&void 0!==q?q:""}),ie("span",{className:"text-[10px] md:text-[12px]",children:F(0,0,B)})]}:{className:`${gt} 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 ie("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:ie("div",{className:ft,children:F(t,0,B,!1)})})})()]}),ie("div",{ref:m,className:"flex",style:{width:i,minWidth:"100%",transform:j?"translateX(calc(-100% / 3))":void 0},children:ie("div",{className:"grow",children:[ie("div",{className:`${Nt} flex border-t-0`,children:a.map((e,t)=>ie("div",{className:`relative flex-1 ${t!==a.length-1||!d&&ne?"border-r":""} border-gray-200 dark:border-gray-700`,style:J},`top-${t}`))}),ie("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(),s=Math.round(l/864e5);return ie("div",{className:pt,style:{top:`${(t-z)*_}px`,width:"100%",height:0,zIndex:20},children:[ie("div",{className:"flex w-0 items-center"}),ie("div",{className:"flex flex-1",children:a.map((e,t)=>ie("div",{className:"flex flex-1 items-center",children:ie("div",{className:"relative h-0.5 w-full "+(t===s?"bg-primary":"bg-primary/30"),style:{zIndex:9999},children:t===s&&0!==s&&ie("div",{className:"absolute h-2 w-2 rounded-full bg-primary",style:{top:"-3px",left:"-4px"}})})},t))})]})})(),n.map((e,t)=>ie("div",{className:mt,children:a.map((n,r)=>{const l=new Date(o);return l.setDate(o.getDate()+r),ie("div",{className:"df-time-grid-cell flex-1 relative border-r 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)},onMouseDown:e=>{wr(e,r,re(e.clientY),c,v)},onDblClick:e=>{null==v||v(e,r,re(e.clientY)),Dr()},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),s=60===l?a+1:a,i=60===l?0:l;r.setHours(s,i,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)),ie("div",{className:`${Nt} flex`,children:a.map((e,t)=>ie("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,i=K(n,l),u=[];return i.forEach(e=>{const t=or(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=or(e,o).find(e=>e.dayIndex===n);t&&u.push({event:e,segmentInfo:Object.assign(Object.assign({},t),{dayIndex:n})})}),ie("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=s.get(n),l=null==o?void 0:o.get(t.id);return ie(yr,{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&&ie(tr,{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)}}})]})},ya=({app:e,config:t,customDetailPanelContent:n,customEventDetailDialog:a,calendarRef:o,selectedEventId:l,onEventSelect:s,onDateChange:i,detailPanelEventId:d,onDetailPanelToggle:c})=>{var u;const{t:h,getWeekDaysLabels:g,locale:m}=ot(),p=e.getCurrentDate(),f=r.useMemo(()=>p,[p.getTime()]),v=e.getEvents(),{screenSize:y}=rt(),x="desktop"!==y,D=r.useRef(null),[E,C]=r.useState(!1),{hourHeight:T=oa.HOUR_HEIGHT,firstHour:k=oa.FIRST_HOUR,lastHour:N=oa.LAST_HOUR,allDayHeight:I=oa.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()||$n,_="desktop"!==y,U=_?2:7,B=_,Z=null!==(u=t.startOfWeek)&&void 0!==u?u:1,G=B?"300%":"100%",K=r.useMemo(()=>aa(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),[se,de]=r.useState(null),ce=void 0===l?oe:l,ue=void 0===d?se:d,he=e=>{s?s(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,r)=>{const a=ar(e,t,n).filter(e=>e.event.allDay);if(r)a.sort((e,t)=>r(e.event,t.event));else{const e=new Map;a.forEach(t=>{const n=t.event.calendarId;e.has(n)||e.set(n,e.size)});const t=tt(a.map(e=>e.event),(t,n)=>{var r,a;return(null!==(r=e.get(t.calendarId))&&void 0!==r?r:0)-(null!==(a=e.get(n.calendarId))&&void 0!==a?a:0)});a.sort((e,n)=>t(e.event,n.event))}const o=[];return a.forEach(e=>{let t=0,n=!1;for(;!n;){let r=!1;for(const n of o)if(n.row===t&&!(e.endDayIndex<n.startDayIndex||e.startDayIndex>n.endDayIndex)){r=!0;break}r?t++:n=!0}o.push(Object.assign(Object.assign({},e),{row:t}))}),o})(Ae,ne,ee,e.state.allDaySortComparator),[Ae,ne,ee,e.state.allDaySortComparator]),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=or(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=ra.calculateDayEventLayouts(o,{viewType:"week"});r.set(a,l)}return r})(Ae,ne,ee),[Ae,ne,ee]),je=r.useCallback((t,n,r)=>{const a=t(Ae),o=new Set(a.map(e=>e.id)),l=Ae.filter(e=>!o.has(e.id)),s=new Set(Ae.map(e=>e.id)),i=a.filter(e=>!s.has(e.id)),d=a.filter(e=>{if(!s.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:i,update:d.map(e=>({id:e.id,updates:e}))},n,r)},[Ae,e]),Ye=r.useCallback(t=>{x?(be(t),ve(!0)):(e.addEvent(t),pe(t.id))},[x,e]),Fe=r.useCallback(()=>{},[]),Ve=r.useCallback((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},s=[...r.filter(t=>t.day===e&&!t.allDay),l];return ra.calculateDayEventLayouts(s,{viewType:"week"}).get("-1")||null})(e,t,n,Ae),[Ae]),_e=r.useCallback((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),s=M(o,r),i=b(l),d=b(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:ra.calculateDayEventLayouts(o,{viewType:"week"}).get(e.id)||null})(e,t,n,r,Ae),[Ae]),ze=r.useMemo(()=>({calendarRef:o,allDayRowRef:R?Te:void 0,timeGridRef:D,viewType:exports.ViewType.WEEK,onEventsUpdate:je,onEventCreate:Ye,onEventEdit:Fe,currentWeekStart:ne,events:Ae,calculateNewEventLayout:Ve,calculateDragLayout:_e,TIME_COLUMN_WIDTH:O,isMobile:x,gridWidth:G,displayDays:ee}),[o,R,je,Ye,Fe,ne,Ae,Ve,_e,O,x,G,ee]),{handleMoveStart:We,handleCreateStart:Ue,handleResizeStart:Be,handleCreateAllDayEvent:Ze,dragState:Ge,isDragging:Ke}=da(e,ze),{handleDrop:qe,handleDragOver:Xe}=la({app:e,onEventCreated:e=>{pe(e.id)}}),Je=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]),Qe=r.useMemo(()=>{if(!x)return[];const e=m.split("-")[0].toLowerCase();return"zh"===e||"ja"===e?g(m,"narrow"):Je.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,Je]),et=r.useMemo(()=>h("allDay"),[h]),nt=Array.from({length:24},(e,t)=>({hour:t+L,label:F(t+L,0,H)})),at=r.useMemo(()=>A?z(nt,A,H):void 0,[A,H,L]),lt=r.useMemo(()=>A?W(Intl.DateTimeFormat().resolvedOptions().timeZone):void 0,[A]),st=r.useMemo(()=>A?W(A):void 0,[A]),it=r.useMemo(()=>{const e=new Date;return e.setHours(0,0,0,0),Je.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,Je,m]),dt=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 ct=t=>{e.updateEvent(t.id,t)},ut=t=>{e.deleteEvent(t)},ht=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)},[]),ie("div",{className:"df-calendar relative flex flex-col w-full overflow-hidden h-full select-none df-week-view",children:[ie(xr,{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()}),ie(fa,{app:e,weekDaysLabels:Je,mobileWeekDaysLabels:Qe,weekDates:it,fullWeekDates:dt,isSlidingView:B,mobilePageStart:X,currentWeekStart:ne,gridWidth:G,allDayAreaHeight:Le,organizedAllDaySegments:Pe,allDayLabelText:et,isMobile:x,isTouch:E,showAllDay:R,calendarRef:o,allDayRowRef:Te,topFrozenContentRef:Se,ALL_DAY_HEIGHT:j,HOUR_HEIGHT:P,FIRST_HOUR:L,dragState:Ge,isDragging:Ke,secondaryTimeSlots:at,primaryTzLabel:lt,secondaryTzLabel:st,handleMoveStart:We,handleResizeStart:Be,handleEventUpdate:ct,handleEventDelete:ut,onDateChange:i,newlyCreatedEventId:me,setNewlyCreatedEventId:pe,selectedEventId:ce,setSelectedEventId:he,detailPanelEventId:ue,setDetailPanelEventId:ge,handleCreateAllDayEvent:Ze,handleDragOver:Xe,handleDrop:qe,customDetailPanelContent:n,customEventDetailDialog:a}),ie(va,{app:e,timeSlots:nt,weekDaysLabels:Je,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:Ue,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==Ue||Ue({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:Xe,handleDrop:qe,dragState:Ge,isDragging:Ke,handleMoveStart:We,handleResizeStart:Be,handleEventUpdate:ct,handleEventDelete:ut,onDateChange:i,newlyCreatedEventId:me,setNewlyCreatedEventId:pe,selectedEventId:ce,setSelectedEventId:he,detailPanelEventId:ue,setDetailPanelEventId:ge,customDetailPanelContent:n,customEventDetailDialog:a,isCurrentWeek:ht,currentTime:re,HOUR_HEIGHT:P,FIRST_HOUR:L,LAST_HOUR:$,showStartOfDayLabel:Y,timeFormat:H,secondaryTimeSlots:at}),ie(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})]})},ba={showWeekends:!0,showAllDay:!0,startOfWeek:1,scrollToCurrentTime:!0,hourHeight:72,firstHour:0,lastHour:24,allDayHeight:28,timeFormat:"24h"},xa=(e={})=>{const n=Object.assign(Object.assign({},ba),e),r=e=>t.h(ua,{viewType:exports.ViewType.WEEK,originalComponent:ya,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}},wa=17,Da=n.memo(({currentMonth:t,currentYear:n,newlyCreatedEventId:a,screenSize:o,isScrolling:l,isDragging:s,showWeekNumbers:i,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}=ot(),[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/wa)),maxSlotsWithMore:Math.min(4,Math.max(0,Math.floor(t/wa)))}},[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(()=>ar(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),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(!t.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||t.allDay)if(c&&t.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(let a=o.getTime();a<=i.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:s.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,t)=>{const n=t||tt(e.map(e=>e.event),(()=>{const t=new Map;return e.forEach(e=>{const n=e.event.calendarId;t.has(n)||t.set(n,t.size)}),(e,n)=>{var r,a;return(null!==(r=t.get(e.calendarId))&&void 0!==r?r:0)-(null!==(a=t.get(n.calendarId))&&void 0!==a?a:0)}})()),r=[...e].toSorted((e,t)=>{if(n){const r=n(e.event,t.event);if(0!==r)return r}const r=e.endDayIndex-e.startDayIndex+1,a=t.endDayIndex-t.startDayIndex+1;return e.startDayIndex>t.startDayIndex?1:r!==a?a-r:e.startDayIndex-t.startDayIndex}),a=[];r.forEach(e=>{var t;let n=0,r=!1;for(;!r;){let o=!1;for(const r of a){const a=Math.abs((null!==(t=r.yPosition)&&void 0!==t?t:0)-n)<16,l=!(e.endDayIndex<r.startDayIndex||e.startDayIndex>r.endDayIndex);if(a&&l){o=!0;break}}o?n+=16:r=!0}a.push(Object.assign(Object.assign({},e),{yPosition:n}))});const o=[];return a.forEach(e=>{var t;const n=Math.floor((null!==(t=e.yPosition)&&void 0!==t?t:0)/16);o[n]||(o[n]=[]),o[n].push(e)}),o.forEach(e=>{e.sort((e,t)=>{if(n){const r=n(e.event,t.event);if(0!==r)return r}return e.startDayIndex-t.startDayIndex})}),o})(J,L.state.allDaySortComparator),[J,L.state.allDaySortComparator]),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(()=>Math.min(te.length,Z.maxSlots),[te.length,Z.maxSlots]),se=r.useMemo(()=>Math.max(0,le*wa),[le]),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;let Q=0;te.slice(J).forEach(e=>{e.forEach(e=>{e.startDayIndex<=r&&e.endDayIndex>=r&&Q++})});const ae=V.filter(e=>e<J).length,se=Math.max(0,J-Math.max(F+1,0)),de=Math.min(_,ae+se),ce=h.slice(0,de),ue=Q+(_-de),he=K&&le>J,ge=(le-J)*wa,me=[];let pe=0;const fe=Math.min(J,G);for(let t=0;t<fe;t++)if(w.has(t))me.push(ie("div",{className:"shrink-0",style:{height:"17px",minHeight:"17px"}},`placeholder-layer-${t}-${e.date.getTime()}`));else if(pe<ce.length){const e=ce[pe];me.push(ie(yr,{event:e,isAllDay:!!e.allDay,viewType:exports.ViewType.MONTH,isBeingDragged:s&&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)}-${pe}`)),pe++}return ie("div",{className:jt("df-month-day-cell relative flex flex-col border-r",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":(ve=e.date,`${ve.getFullYear()}-${String(ve.getMonth()+1).padStart(2,"0")}-${String(ve.getDate()).padStart(2,"0")}`),onClick:()=>c&&(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:[ie("div",{className:"df-month-date-number-container flex items-center justify-end text-right px-2 h-[33px] relative z-20",children:[i&&0===r&&"mobile"!==o&&ie("span",{className:"mr-auto ml-1 text-[10px] font-medium text-gray-400 dark:text-gray-500",children:N(e.date)}),ie("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})]}),ie("div",{className:"relative flex-1 overflow-hidden px-1",children:[he&&ie("div",{className:"pointer-events-none absolute right-0 left-0 z-[15] bg-white dark:bg-gray-900",style:{top:J*wa+"px",height:`${ge}px`}}),me,K&&ie("div",{className:jt("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","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:["+",ue,"desktop"===o?` ${j("more")}`:""]})]})]},`day-${e.date.getTime()}`);var ve},ce=r.useMemo(()=>K?K.date.toLocaleDateString(Y,{month:"long",year:"numeric"}):"",[K,Y]);return ie("div",{className:"relative border-b border-gray-200 select-none dark:border-gray-700",style:{height:q},children:[d&&K&&ie("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:ie("span",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:ce})}),ie("div",{className:"flex h-full flex-col",children:ie("div",{className:"calendar-week relative h-full",children:[ie("div",{className:"grid h-full grid-cols-7",children:G.days.map((e,t)=>de(e,t))}),te.length>0&&ie("div",{className:"pointer-events-none absolute right-0 left-0",style:{top:"33px",height:`${se}px`,zIndex:10},children:te.slice(0,le).map((e,t)=>ie("div",{className:"absolute inset-0",children:e.map(e=>ie(yr,{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:s&&g.eventId===e.event.id&&"move"===g.mode,isBeingResized:s&&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&&ie(tr,{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)}}})]})});Da.displayName="WeekComponent";const Ea=({app:e,config:t,customDetailPanelContent:n,customEventDetailDialog:a,calendarRef:o,selectedEventId:l,onEventSelect:s,detailPanelEventId:i,onDetailPanelToggle:d})=>{var c,g,m;const{getWeekDaysLabels:p,getMonthLabels:f,locale:v}=ot(),y=e.getCurrentDate(),b=e.getEvents(),x=null!==(c=t.startOfWeek)&&void 0!==c?c:1,D=!0===(null===(g=t.scroll)||void 0===g?void 0:g.disabled),E=D&&"fade"===(null===(m=t.scroll)||void 0===m?void 0:m.transition),[C,T]=r.useState(y),[k,S]=r.useState(!1),[M,N]=r.useState("forward"),I=r.useRef(y),R=r.useRef(null),H=y.getFullYear(),A=y.getMonth();r.useEffect(()=>{if(!E)return;if(H===I.current.getFullYear()&&A===I.current.getMonth())return;const e=y>I.current;return I.current=y,N(e?"forward":"backward"),R.current&&clearTimeout(R.current),S(!0),R.current=setTimeout(()=>{T(y),S(!1)},300),()=>{R.current&&clearTimeout(R.current)}},[H,A,E]);const O=r.useMemo(()=>E?((e,t)=>{const n=new Date(e.getFullYear(),e.getMonth(),1),r=(n.getDay()-t+7)%7,a=new Date(n);a.setDate(n.getDate()-r),a.setHours(0,0,0,0);const o=[];for(let e=0;e<6;e++){const t=new Date(a);t.setDate(a.getDate()+7*e),o.push(Z(t))}return o})(C,x):[],[E,C,x]),P=r.useMemo(()=>({opacity:k?0:1,transform:k?`translateX(${"forward"===M?"-6%":"6%"})`:"translateX(0)",transition:"opacity 300ms ease, transform 300ms ease"}),[k,M]),L=e.getCalendars().map(e=>e.id+e.colors.lineColor).join("-"),$=r.useRef(null),j=r.useMemo(()=>{const e=$.current;return e&&e.length===b.length&&e.every((e,t)=>e===b[t])?e:($.current=b,b)},[b]),Y=r.useMemo(()=>{const e=new Map,t=e=>{const t=new Date(e);t.setHours(0,0,0,0);const n=(t.getDay()-x+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 j.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 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},[j,x]),{screenSize:F}=rt(),[V,_]=r.useState(!1);r.useEffect(()=>{_("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const z=e.getCustomMobileEventRenderer()||$n,[W,U]=r.useState(119),[B,K]=r.useState(!1),q=r.useRef(W),X=r.useRef([]),[J,Q]=r.useState(null),[ee,ne]=r.useState(!1),[re,ae]=r.useState(null),[oe,le]=r.useState(null),[se,de]=r.useState(null),ce=void 0===l?oe:l,ue=void 0===i?se:i,he=r.useCallback(e=>{s?s(e):le(e)},[s]),ge=r.useCallback(e=>{d?d(e):de(e)},[d]),me=r.useRef(e.state.highlightedEventId);r.useEffect(()=>{e.state.highlightedEventId?he(e.state.highlightedEventId):me.current&&he(null),me.current=e.state.highlightedEventId},[e.state.highlightedEventId]);const pe=r.useMemo(()=>{const e=(y.getDay()-x+7)%7,t=new Date(y);return t.setDate(y.getDate()-e),t.setHours(0,0,0,0),t},[y,x]),{handleMoveStart:fe,handleCreateStart:ve,handleResizeStart:ye,dragState:be,isDragging:xe}=da(e,{calendarRef:o,viewType:exports.ViewType.MONTH,onEventsUpdate:(t,n,r)=>{const a=t(j),o=new Set(a.map(e=>e.id)),l=j.filter(e=>!o.has(e.id)),s=new Set(j.map(e=>e.id)),i=a.filter(e=>!s.has(e.id)),d=a.filter(e=>{if(!s.has(e.id))return!1;const t=j.find(t=>t.id===e.id);return t&&te(t,e)});e.applyEventsChanges({delete:l.map(e=>e.id),add:i,update:d.map(e=>({id:e.id,updates:e}))},n,r)},onEventCreate:t=>{"desktop"===F?e.addEvent(t):(ae(t),ne(!0))},onEventEdit:e=>{Q(e.id)},currentWeekStart:pe,events:j}),{handleDrop:we,handleDragOver:De}=la({app:e,onEventCreated:e=>{Q(e.id)}}),Ee=r.useMemo(()=>p(v,"short",x),[v,p,x]),{currentMonth:Ce,currentYear:Te,isScrolling:ke,virtualData:Se,weeksData:Me,scrollElementRef:Ne,isNavigating:Ie,handleScroll:Re,handlePreviousMonth:He,handleNextMonth:Ae,handleToday:Oe,setScrollTop:Pe}=(({currentDate:e,weekHeight:t,onCurrentMonthChange:n,initialWeeksToLoad:a=104,locale:o="en-US",startOfWeek:l=1,isEnabled:s=!0,snapToMonth:i=!1})=>{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]),g=r.useMemo(()=>{const t=new Date(e);return t.setDate(1),t.setHours(0,0,0,0),G(t,a,l)},[e,a,l]),m=r.useMemo(()=>{const n=new Date(e);n.setDate(1),n.setHours(0,0,0,0);const r=g.findIndex(e=>e.days.some(e=>e.date.toDateString()===n.toDateString()));return r>0?r*t:0},[g,e,t]),[p,f]=r.useState(m),[v,y]=r.useState(600),[b,x]=r.useState(c(e.getMonth(),e.getFullYear())),[w,D]=r.useState(e.getFullYear()),[E,C]=r.useState(!1),[T,k]=r.useState(g),[S,M]=r.useState(!1),N=r.useRef(!1),[I,R]=r.useState(!1),H=r.useRef(e),A=r.useRef(null),O=r.useRef(null),P=r.useRef(new h),L=r.useRef(0),$=r.useRef(0),j=r.useRef(!1),Y=r.useCallback(e=>{e&&(A.current=e)},[]),F=r.useCallback(e=>{let t=P.current.get(e);return t||(t=Z(e),P.current.set(e,t)),t},[]),V=r.useCallback((e,n=26)=>{j.current||(j.current=!0,setTimeout(()=>{try{if("future"===e){const e=T.at(-1),t=[];for(let r=1;r<=n;r++){const n=new Date(e.startDate);n.setDate(n.getDate()+7*r),t.push(F(n))}k(e=>[...e,...t])}else{const e=T[0],r=[];for(let t=n;t>=1;t--){const n=new Date(e.startDate);n.setDate(n.getDate()-7*t),r.push(F(n))}const a=r.length*t;k(e=>[...r,...e]),requestAnimationFrame(()=>{f(e=>e+a),A.current&&(A.current.scrollTop+=a)})}}finally{setTimeout(()=>{j.current=!1},200)}},0))},[T,F,t]),_=r.useMemo(()=>{const e=T.length*t,n=Math.floor(p/t);let r=Math.max(0,n);r=Math.min(r,Math.max(0,T.length-6));const a=Math.min(T.length-1,r+6-1),o=Math.max(0,r-15),l=Math.min(T.length-1,a+15),s=[];for(let e=o;e<=l;e++)s.push({index:e,weekData:T[e],top:e*t,height:t});return{totalHeight:e,visibleItems:s,displayStartIndex:r}},[p,v,t,T]),z=r.useCallback(e=>{if(S||E||0===e.length||!I)return;const t=p+v/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=Number.parseInt(r,10)}}),o&&l&&(d.current?o===d.current.month&&l===d.current.year&&(d.current=null,o===b&&l===w||(x(o),D(l),null==n||n(o,l))):o===b&&l===w||(x(o),D(l),null==n||n(o,l)))},[v,b,w,S,E,n,p,I]),W=r.useCallback(e=>{const n=performance.now();if(n-L.current<u.SCROLL_THROTTLE)return;L.current=n;const r=e.currentTarget,a=r.scrollTop;$.current=a,f(a),S||requestAnimationFrame(()=>{const{scrollHeight:e,clientHeight:n}=r;a+n>e-10*t&&!j.current&&V("future",26),a<10*t&&!j.current&&V("past",26)}),C(!0),O.current&&clearTimeout(O.current),O.current=setTimeout(()=>{C(!1)},u.SCROLL_DEBOUNCE)},[t,V,S]),U=r.useCallback((e,n=!0)=>{if(!A.current)return;M(!0),N.current=!0;const r=()=>{setTimeout(()=>{M(!1),N.current=!1},n?500:200)},a=T.findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(-1!==a){const e=a*t;return A.current.scrollTo({top:e,behavior:n?"smooth":"auto"}),void r()}const o=(e.getDay()-l+7)%7,s=new Date(e);s.setDate(e.getDate()-o),s.setHours(0,0,0,0);const i=T[0],d=T.at(-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(F(t))}const o=a.length*t;k(e=>[...a,...e]),requestAnimationFrame(()=>{const l=[...a,...T].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(A.current&&-1!==l){const e=l*t;A.current.scrollTop+=o,f(e=>e+o),setTimeout(()=>{A.current&&A.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(F(t))}k(e=>[...e,...a]),requestAnimationFrame(()=>{const o=[...T,...a].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(A.current&&-1!==o){const e=o*t;A.current.scrollTo({top:e,behavior:n?"smooth":"auto"})}r()})}else r()},[T,t,F]),B=r.useCallback(()=>{var e;const t=_.displayStartIndex,n=Math.min(T.length-1,t+5),r={};for(let a=t;a<=n;a++)null===(e=T[a])||void 0===e||e.days.forEach(e=>{const t=`${e.month}-${e.year}`;r[t]=(r[t]||0)+1});let a=0,o=0,l=0;for(const[e,t]of Object.entries(r))t>l&&(l=t,[a,o]=e.split("-").map(Number));const s=new Date(o,a-1,1);U(s)},[_.displayStartIndex,T,U]),K=r.useCallback(()=>{var e;const t=_.displayStartIndex,n=Math.min(T.length-1,t+5),r={};for(let a=t;a<=n;a++)null===(e=T[a])||void 0===e||e.days.forEach(e=>{const t=`${e.month}-${e.year}`;r[t]=(r[t]||0)+1});let a=0,o=0,l=0;for(const[e,t]of Object.entries(r))t>l&&(l=t,[a,o]=e.split("-").map(Number));const s=new Date(o,a+1,1);U(s)},[_.displayStartIndex,T,U]),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},x(r),D(a),null==n||n(r,a);const l=T.findIndex(e=>e.days.some(e=>e.date.toDateString()===o.toDateString()));if(-1===l)M(!0),N.current=!0,requestAnimationFrame(()=>{U(o,!0),setTimeout(()=>{N.current=!1,M(!1)},200)});else{const e=l*t,n=A.current;n&&(M(!0),N.current=!0,requestAnimationFrame(()=>{f(e),requestAnimationFrame(()=>{n&&(n.scrollTop=e,setTimeout(()=>{N.current=!1,M(!1)},200))})}))}},[T,t,n,U]);return r.useEffect(()=>{z(_.visibleItems)},[_.visibleItems,z]),r.useEffect(()=>{const t=H.current,r=t.getMonth(),a=t.getFullYear(),o=e.getMonth(),l=e.getFullYear();if(r!==o||a!==l){const e=6,t=_.displayStartIndex,r=Math.min(T.length-1,t+e-1),a={};for(let e=t;e<=r;e++){const t=T[e];t&&t.days.forEach(e=>{const t=`${e.month}-${e.year}`;a[t]=(a[t]||0)+1})}let s="",i=0;for(const[e,t]of Object.entries(a))t>i&&(i=t,s=e);if(s!==`${o}-${l}`){const e=new Date(l,o,1),t=c(o,l);d.current={month:t,year:l},x(t),D(l),null==n||n(t,l),U(e,!0)}}H.current=e},[e,n,U,_,T,c]),r.useEffect(()=>{const e=A.current;if(!e)return;const t=new ResizeObserver(([e])=>{y(e.contentRect.height)});return t.observe(e),()=>t.disconnect()},[]),r.useEffect(()=>{const e=A.current;e&&!I&&s&&requestAnimationFrame(()=>{e&&m>0?(e.scrollTop=m,f(m),R(!0)):e&&R(!0)})},[I,m,s]),r.useEffect(()=>{var e;if(!i||E||S||!I)return;const n=Math.floor(p/t),r=Math.min(T.length-1,n+5),a={};for(let t=n;t<=r;t++)null===(e=T[t])||void 0===e||e.days.forEach(e=>{const t=`${e.month}-${e.year}`;a[t]=(a[t]||0)+1});let o=0,l=0,s=0;for(const[e,t]of Object.entries(a))t>s&&(s=t,[o,l]=e.split("-").map(Number));const d=new Date(l,o,1),c=T.findIndex(e=>e.days.some(e=>e.date.toDateString()===d.toDateString()));if(-1===c)return;const u=c*t;if(Math.abs(u-p)>5){const e=setTimeout(()=>{U(d,!0)},200);return()=>clearTimeout(e)}},[E,i,S,I,p,t,T,U]),r.useEffect(()=>()=>{O.current&&clearTimeout(O.current)},[]),{scrollTop:p,containerHeight:v,currentMonth:b,currentYear:w,isScrolling:E,isNavigating:S,virtualData:_,scrollElementRef:A,handleScroll:W,scrollToDate:U,handlePreviousMonth:B,handleNextMonth:K,handleToday:q,setScrollTop:f,setContainerHeight:y,setCurrentMonth:x,setCurrentYear:D,setIsScrolling:C,cache:P.current,scrollElementRefCallback:Y,weeksData:T}})({currentDate:y,weekHeight:W,onCurrentMonthChange:(t,n)=>{const r=v.startsWith("zh")||v.startsWith("ja"),a=f(v,r?"short":"long").indexOf(t);a>=0&&e.setVisibleMonth(new Date(n,a,1))},initialWeeksToLoad:156,locale:v,startOfWeek:x,isEnabled:B,snapToMonth:t.snapToMonth}),Le=r.useRef(0),[$e,je]=r.useState(0),Ye=r.useMemo(()=>$e-6*W,[$e,W]),{visibleWeeks:Fe,startIndex:Ve}=r.useMemo(()=>{var e,t;const{visibleItems:n,displayStartIndex:r}=Se,a=n.findIndex(e=>e.index===r);if(-1===a)return X.current.length>0?{visibleWeeks:X.current,startIndex:Le.current}:{visibleWeeks:[],startIndex:r};const o=Math.max(0,a-2),l=n.slice(o,a+8),s=null!==(t=null===(e=n[o])||void 0===e?void 0:e.index)&&void 0!==t?t:r;return l.length>=6&&(X.current=l,Le.current=s),{visibleWeeks:l,startIndex:s}},[Se]),_e=r.useMemo(()=>Ve*W,[Ve,W]),ze=r.useRef(!0),We=r.useRef(!1),Ue=((e,t)=>{const[n,a]=r.useState(e);return r.useEffect(()=>{const n=setTimeout(()=>{a(e)},t);return()=>{clearTimeout(n)}},[e,t]),n})(Se.displayStartIndex,250);r.useEffect(()=>{Ie&&(We.current=!0)},[Ie]),r.useEffect(()=>{if(ze.current)return void(ze.current=!1);const t=Me[Ue];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,We.current?"navigation":"scroll"),We.current=!1},[e,Me,Ue]);const Be=r.useMemo(()=>{const e=Se.totalHeight,t=Ve*W+Fe.length*W+Ye;return Math.max(0,e-t)},[Se.totalHeight,Ve,W,Ye,Fe.length]);r.useEffect(()=>{const e=Ne.current;if(!e)return;const t=new ResizeObserver(t=>{for(const n of t){const t=n.contentRect.height;if(je(t),t>0){const n=Math.max(80,Math.ceil(t/6));if(n!==q.current){const t=e.scrollTop;if(t>0){const r=Math.round(t/q.current)*n;e.scrollTop=r,Pe(r)}U(n),q.current=n}}}});return t.observe(e),()=>{t.disconnect()}},[Ne,Pe]),r.useEffect(()=>{const e=window.innerHeight-150,t=Math.max(80,Math.ceil(e/6));U(t),q.current=t,K(!0)},[]),r.useEffect(()=>{if(E||!D)return;const e=Ne.current;if(!e)return;const t=e=>e.preventDefault();return e.addEventListener("wheel",t,{passive:!1}),e.addEventListener("touchmove",t,{passive:!1}),()=>{e.removeEventListener("wheel",t),e.removeEventListener("touchmove",t)}},[E,D,Ne]);const Ze=r.useCallback(t=>{e.updateEvent(t.id,t)},[e]),Ge=r.useCallback(t=>{e.deleteEvent(t)},[e]),Ke=t=>{e.changeView(t)},qe=r.useCallback(()=>Q(null),[]),Xe=r.useCallback(t=>{const n=e.getReadOnlyConfig().viewable;if(("desktop"!==F||V)&&t&&n){const e=j.find(e=>e.id===t);if(e)return ae(e),void ne(!0)}he(t)},[F,V,j,he,e]),Je=r.useCallback(e=>{("desktop"!==F||V)&&he(e)},[F,V,he]);return ie("div",{className:lt,children:[ie(xr,{calendar:e,viewType:exports.ViewType.MONTH,currentDate:y,customTitle:(()=>{const e=v.startsWith("zh")||v.startsWith("ja");if(E){const t=v.startsWith("zh")||v.startsWith("ja"),n=f(v,t?"short":"long")[C.getMonth()],r=C.getFullYear();return e?`${r}年${n}`:`${n} ${r}`}return e?`${Te}年${Ce}`:`${Ce} ${Te}`})(),onPrevious:()=>{e.goToPrevious(),E||He()},onNext:()=>{e.goToNext(),E||Ae()},onToday:()=>{e.goToToday(),E||Oe()}}),ie("div",{className:"df-week-header-row sticky top-0 z-10 border-b",onContextMenu:e=>e.preventDefault(),children:ie("div",{className:"grid grid-cols-7 px-2",children:Ee.map((e,t)=>ie("div",{className:"text-right text-gray-500 dark:text-gray-400 text-sm py-2 pr-2 select-none",children:e},`${e}-${t}`))})}),ie("div",E?{ref:Ne,className:ct,style:{overflow:"hidden",visibility:B?"visible":"hidden"},children:ie("div",{style:P,children:O.map((r,l)=>{var s;const i=null!==(s=Y.get(r.startDate.getTime()))&&void 0!==s?s:[],d={index:l,weekData:r,top:l*W,height:W},c=5===l?Object.assign(Object.assign({},d),{height:d.height+Ye}):d;return ie(Da,{item:c,weekHeight:W,showWeekNumbers:t.showWeekNumbers,showMonthIndicator:!1,currentMonth:"",currentYear:0,screenSize:F,isScrolling:!1,calendarRef:o,events:i,onEventUpdate:Ze,onEventDelete:Ge,onMoveStart:fe,onCreateStart:ve,onResizeStart:ye,isDragging:xe,dragState:be,newlyCreatedEventId:J,onDetailPanelOpen:qe,onMoreEventsClick:e.onMoreEventsClick,onChangeView:Ke,onSelectDate:e.selectDate,selectedEventId:ce,onEventSelect:Xe,onEventLongPress:Je,detailPanelEventId:ue,onDetailPanelToggle:ge,customDetailPanelContent:n,customEventDetailDialog:a,onCalendarDrop:we,onCalendarDragOver:De,calendarSignature:L,app:e,enableTouch:V},`week-${r.startDate.getTime()}`)})})}:{ref:Ne,className:ct,style:{overflow:"hidden auto",overscrollBehavior:"contain",visibility:B?"visible":"hidden"},onScroll:Re,children:[ie("div",{style:{height:_e}}),Fe.map((r,l)=>{var s;const i=null!==(s=Y.get(r.weekData.startDate.getTime()))&&void 0!==s?s:[],d=5===l?Object.assign(Object.assign({},r),{height:r.height+Ye}):r,c=!(!1===t.showMonthIndicator||!r.weekData.days.some(e=>1===e.day))&&ke;return ie(Da,{item:d,weekHeight:W,showWeekNumbers:t.showWeekNumbers,showMonthIndicator:t.showMonthIndicator,currentMonth:Ce,currentYear:Te,screenSize:F,isScrolling:c,calendarRef:o,events:i,onEventUpdate:Ze,onEventDelete:Ge,onMoveStart:fe,onCreateStart:ve,onResizeStart:ye,isDragging:xe,dragState:be,newlyCreatedEventId:J,onDetailPanelOpen:qe,onMoreEventsClick:e.onMoreEventsClick,onChangeView:Ke,onSelectDate:e.selectDate,selectedEventId:ce,onEventSelect:Xe,onEventLongPress:Je,detailPanelEventId:ue,onDetailPanelToggle:ge,customDetailPanelContent:n,customEventDetailDialog:a,onCalendarDrop:we,onCalendarDragOver:De,calendarSignature:L,app:e,enableTouch:V},`week-${r.weekData.startDate.getTime()}`)}),ie("div",{style:{height:Be}})]}),ie(z,{isOpen:ee,onClose:()=>{ne(!1),ae(null)},onSave:t=>{j.some(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),ne(!1),ae(null)},draftEvent:re,app:e})]})},Ca={showWeekNumbers:!1,showMonthIndicator:!0,startOfWeek:1},Ta=(e={})=>{const n=Object.assign(Object.assign({},Ca),e),r=e=>t.h(ua,{viewType:exports.ViewType.MONTH,originalComponent:Ea,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 ka=n.memo(({date:e,isToday:t,locale:n,onSelectDate:r,onCreateStart:a,onMoreEventsClick:o,moreCount:l=0,onContextMenu:s})=>{const{t:i}=ot(),d=e.getDate(),c=1===d,u=e.toLocaleDateString(n,{month:"short"}).toUpperCase();return ie("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==s||s(t,e)},"data-date":`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,children:[ie("div",{className:"flex h-6 shrink-0 items-center px-1 py-1",children:[c&&ie("span",{className:"rounded-sm bg-primary px-1 py-0.5 text-[9px] leading-none font-bold text-primary-foreground",children:u}),ie("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&&ie("div",{className:"absolute bottom-0.5 left-1 z-20",children:ie("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," ",i("more")]})})]})});ka.displayName="YearDayCell";const Sa=n.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: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,r){if(0===t.length)return[];const a=t[0],o=t.at(-1),l=new Date(a.getFullYear(),a.getMonth(),a.getDate()).getTime(),s=new Date(o.getFullYear(),o.getMonth(),o.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<=s&&a>=l});if(r)i.sort(r);else{const e=new Map;i.forEach(t=>{e.has(t.calendarId)||e.set(t.calendarId,e.size)}),i.sort((t,n)=>{var r,a;return(null!==(r=e.get(t.calendarId))&&void 0!==r?r:0)-(null!==(a=e.get(n.calendarId))&&void 0!==a?a:0)})}const d=[],c=[];return i.forEach(e=>{const r=w(e.start),o=e.end?w(e.end):r,i=new Date(r.getFullYear(),r.getMonth(),r.getDate()).getTime(),u=new Date(o.getFullYear(),o.getMonth(),o.getDate()).getTime();let h=-1,g=-1;const m=Math.round((i-l)/864e5);h=m>=0?m:0;const p=Math.round((u-l)/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=i>=l,v=u<=s;let y=0;for(;;){let e=!1;c[y]||(c[y]=[]);for(let t=h;t<=g;t++)if(c[y][t]){e=!0;break}if(!e){for(let e=h;e<=g;e++)c[y][e]=!0;break}y++}d.push({id:`${e.id}_${a.getTime()}`,event:e,startCellIndex:h,endCellIndex:g,isFirstSegment:f,isLastSegment:v,visualRowIndex:y})}),d}(t,e,n,a.state.allDaySortComparator),[t,e,n,a.state.allDaySortComparator]),{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),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 ie("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 ie(ka,{date:e,isToday:n,locale:l,onSelectDate:e=>{a.selectDate(e)},onCreateStart:u,onMoreEventsClick:m,moreCount:S[t],onContextMenu:C},e.getTime())}),ie("div",{className:"pointer-events-none absolute inset-0",style:{top:26,bottom:0,left:0,right:0},onContextMenu:e=>e.preventDefault(),children:ie("div",{className:"relative h-full w-full",children:k.map(e=>ie("div",{className:"pointer-events-auto",children:ie(yr,{event:e.event,isAllDay:!!e.event.allDay,viewType:exports.ViewType.YEAR,yearSegment:e,columnsPerRow:n,isBeingDragged:s&&i.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))})})]})});Sa.displayName="YearRowComponent";const Ma=({app:t,calendarRef:n,customDetailPanelContent:a,customEventDetailDialog:o,config:l,selectedEventId:s,onEventSelect:i,detailPanelEventId:d,onDetailPanelToggle:c})=>{var u;const{t:h,locale:g}=ot(),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===s?E:s,M=void 0===d?T:d,N=e=>{i?i(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]"),s=t.closest(".df-context-menu");n||r||a||o||l||s||(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}=da(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 ie("div",{className:lt,onContextMenu:e=>e.preventDefault(),children:[ie(xr,{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()}}),ie("div",{ref:v,className:`${ct} ${ut}`,style:{overflow:"hidden auto"},children:ie("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)=>ie(Sa,{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&&ie(tr,{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 Na(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,s=a.getTime(),i=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<=i&&a>=s});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(),s)),d=new Date(Math.min(a.getTime(),i)),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 Ia=({app:t,calendarRef:n,customDetailPanelContent:a,customEventDetailDialog:o,config:l,selectedEventId:s,onEventSelect:i,detailPanelEventId:d,onDetailPanelToggle:c})=>{var u,h;const{t:g,locale:m,getWeekDaysLabels:p}=ot(),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===s?N:s,O=void 0===d?R:d,P=e=>{i?i(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}=da(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"}),s=l.charAt(0).toUpperCase()+l.slice(1).toLowerCase(),{segments:i,maxVisualRow:d}=Na(q,t,v,x),c=d+1,u=Math.max(60,20+18*c);e.push({monthIndex:t,monthName:s,days:o,eventSegments:i,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 ie("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:[ie("div",{className:"col-span-2",children:ie(xr,{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()}})}),ie("div",{className:"z-30 border-r border-b border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900"}),ie("div",{ref:D,className:"overflow-hidden border-b border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900",children:ie("div",{className:"flex",style:{minWidth:`calc(1352px + ${T}px)`},children:[ie("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 ie("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&&ie("div",{className:"shrink-0 bg-gray-50 dark:bg-gray-900",style:{width:`${T}px`}})]})}),ie("div",{ref:E,className:"overflow-hidden border-r border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-900",children:ie("div",{className:"flex min-h-full flex-col",children:[X.map(e=>ie("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&&ie("div",{className:"shrink-0 bg-white dark:bg-gray-900",style:{height:`${S}px`}})]})}),ie("div",{ref:C,className:`overflow-auto ${ut}`,onScroll:J,children:ie("div",{className:"flex min-h-full flex-col",style:{minWidth:"1352px"},children:X.map(e=>ie("div",{className:"relative shrink-0 grow",style:{minHeight:`${e.minHeight}px`},children:[ie("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 ie("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 ie("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:ie("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&&ie("div",{className:"pointer-events-none absolute inset-0 z-20",style:{top:20},children:ie("div",{className:"relative h-full w-full",children:e.eventSegments.map(e=>ie("div",{className:"pointer-events-auto",children:ie(yr,{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&&ie(tr,{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)}})]})},Ra=({date:e,events:a,anchorEl:o,position:l,onClose:s,locale:i,app:d,customContent:c})=>{const u=r.useRef(null);r.useEffect(()=>{const e=e=>{const t=e.target;!u.current||u.current.contains(t)||o.contains(t)||s()},t=e=>{"Escape"===e.key&&s()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[o,s]);const h=d.getCalendars(),g=new Map(h.map(e=>[e.id,e])),m=e.toLocaleDateString(i,{weekday:"long",month:"long",day:"numeric"}),p=ie(t.Fragment,{children:[ie("div",{className:"border-b border-gray-100 px-4 py-3 dark:border-gray-700",children:ie("div",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:m})}),ie("div",{className:"max-h-60 overflow-y-auto py-1",children:0===a.length?ie("div",{className:"px-4 py-3 text-center text-xs text-gray-400",children:"No events"}):a.map(e=>{var t,n;const r=e.calendarId?g.get(e.calendarId):void 0,a=null!==(n=null===(t=null==r?void 0:r.colors)||void 0===t?void 0:t.lineColor)&&void 0!==n?n:"#3b82f6";let o="";if(!e.allDay&&e.start){if(o=w(e.start).toLocaleTimeString(i,{hour:"2-digit",minute:"2-digit",hour12:!1}),e.end){o+=` – ${w(e.end).toLocaleTimeString(i,{hour:"2-digit",minute:"2-digit",hour12:!1})}`}}return ie("div",{className:"flex items-start gap-2.5 rounded px-3 py-1.5 hover:bg-gray-50 dark:hover:bg-gray-800",children:[ie("div",{className:"mt-1.5 h-2 w-2 shrink-0 rounded-full",style:{backgroundColor:a}}),ie("div",{className:"min-w-0 flex-1",children:[ie("div",{className:"truncate text-xs font-medium text-gray-900 dark:text-gray-100",children:e.title}),o&&ie("div",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:o})]})]},e.id)})})]});return n.createPortal(ie("div",{ref:u,"data-grid-day-popup":!0,className:"animate-in fade-in zoom-in-95 fixed z-50 w-64 overflow-hidden rounded-xl border border-gray-200 bg-white shadow-xl duration-100 dark:border-gray-700 dark:bg-gray-900",style:{top:l.top,left:l.left},children:c?c(e,a):p}),document.body)};function Ha(e,t,n){const r=new Map,a=new Date(t,0,1);a.setHours(0,0,0,0);const o=new Date(t,11,31,23,59,59,999);for(const l of e){if(!l.start)continue;if(!n&&!l.allDay)continue;const e=w(l.start),s=l.end?w(l.end):new Date(e);if(e.setHours(0,0,0,0),s.setHours(0,0,0,0),e>o||s<a)continue;const i=e<a?new Date(a):new Date(e),d=s>o?new Date(t,11,31):new Date(s);i.setHours(0,0,0,0),d.setHours(0,0,0,0);const c=864e5,u=i.getTime(),h=Math.round((d.getTime()-u)/c);for(let e=0;e<=h;e++){const t=new Date(u+e*c),n=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`,a=r.get(n);a?a.push(l):r.set(n,[l])}}return r}function Aa(e){const t=e.getBoundingClientRect(),n=window.innerWidth,r=window.innerHeight;let a=t.right+8;a+256>n-8&&(a=t.left-256-8),a=Math.max(8,Math.min(a,n-256-8));let o=t.top;return o+220>r-8&&(o=r-220-8),o=Math.max(8,o),{top:o,left:a}}const Oa=({app:e,config:t})=>{var n,a,o;const{locale:l,getWeekDaysLabels:s}=ot(),i=e.getCurrentDate(),d=i.getFullYear(),c=e.getEvents(),u=null!==(n=null==t?void 0:t.startOfWeek)&&void 0!==n?n:1,h=null!==(a=null==t?void 0:t.showTimedEventsInYearView)&&void 0!==a&&a,g=null!==(o=null==t?void 0:t.gridHeatmapLevels)&&void 0!==o?o:5,m=r.useMemo(()=>{const e=new Date;return e.setHours(0,0,0,0),e},[]),[p,f]=r.useState(null);r.useEffect(()=>{if(!p)return;const e=e=>{const t=e.target;t.closest("[data-grid-day-popup]")||t.closest("[data-grid-day-cell]")||f(null)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[p]);const v=r.useMemo(()=>Ha(c,d,h),[c,d,h]),y=r.useMemo(()=>Ha(c,d,!0),[c,d]),b=r.useMemo(()=>s(l,"narrow",u).map(e=>l.startsWith("zh")?e.at(-1):e.charAt(0).toUpperCase()),[l,s,u]),x=r.useMemo(()=>{const e=[];for(let t=0;t<12;t++){const n=new Date(d,t,1),r=new Date(d,t+1,0).getDate(),a=[];for(let e=(n.getDay()-u+7)%7-1;e>=0;e--)a.push({date:new Date(d,t,-e),isCurrentMonth:!1});for(let e=1;e<=r;e++)a.push({date:new Date(d,t,e),isCurrentMonth:!0});let o=1;for(;a.length<42;)a.push({date:new Date(d,t+1,o++),isCurrentMonth:!1});const s=n.toLocaleDateString(l,{month:"long"}),i=s.charAt(0).toUpperCase()+s.slice(1);e.push({monthIndex:t,monthName:i,cells:a})}return e},[d,l,u]),w=r.useCallback((n,r,a)=>{var o,l;const s=null!==(o=null==t?void 0:t.gridDateClick)&&void 0!==o?o:"popup";if("function"==typeof s){const e=`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,"0")}-${String(r.getDate()).padStart(2,"0")}`;return void s(r,null!==(l=y.get(e))&&void 0!==l?l:[])}if("popup"===s){const e=n.currentTarget;p&&p.date.getTime()===r.getTime()&&p.monthIndex===a?f(null):f({date:r,monthIndex:a,anchorEl:e,position:Aa(e)})}else"day-view"===s&&(e.setCurrentDate(r),e.changeView(exports.ViewType.DAY))},[t,e,p,y]),D=r.useCallback(n=>{var r,a;const o=null!==(r=null==t?void 0:t.gridDateDoubleClick)&&void 0!==r?r:"day-view";if("function"==typeof o){const e=`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}-${String(n.getDate()).padStart(2,"0")}`;return void o(n,null!==(a=y.get(e))&&void 0!==a?a:[])}"day-view"===o&&(f(null),e.setCurrentDate(n),e.changeView(exports.ViewType.DAY))},[t,e,y]),E=r.useMemo(()=>{var e;if(!p)return[];const t=`${p.date.getFullYear()}-${String(p.date.getMonth()+1).padStart(2,"0")}-${String(p.date.getDate()).padStart(2,"0")}`;return null!==(e=y.get(t))&&void 0!==e?e:[]},[p,y]);return ie("div",{className:lt,children:[ie(xr,{calendar:e,viewType:exports.ViewType.YEAR,currentDate:i,customTitle:l.startsWith("zh")||l.startsWith("ja")?`${d}年`:`${d}`,onPrevious:()=>{const t=new Date(i);t.setFullYear(t.getFullYear()-1),e.setCurrentDate(t)},onNext:()=>{const t=new Date(i);t.setFullYear(t.getFullYear()+1),e.setCurrentDate(t)},onToday:()=>e.goToToday()}),ie("div",{className:"grid min-h-0 flex-1 gap-3 p-3",style:{gridTemplateColumns:"repeat(4, 1fr)",gridTemplateRows:"repeat(3, 1fr)"},children:x.map(e=>ie("div",{className:"df-year-grid-month flex h-full min-h-0 flex-col rounded-lg border border-gray-100 bg-white p-2 dark:border-gray-800 dark:bg-gray-900",children:[ie("div",{className:"mb-1 shrink-0 text-xs font-semibold text-gray-900 dark:text-gray-100",children:e.monthName}),ie("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:ie("div",{className:"grid h-full w-full gap-px",style:{gridTemplateColumns:"repeat(7, 1fr)",gridTemplateRows:"repeat(7, 1fr)"},children:[b.map((e,t)=>ie("div",{className:"flex items-center justify-center text-[9px] font-medium text-gray-400 dark:text-gray-500",children:e},t)),e.cells.map(({date:t,isCurrentMonth:n},r)=>{var a,o;const l=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`,s=n&&null!==(o=null===(a=v.get(l))||void 0===a?void 0:a.length)&&void 0!==o?o:0;var i,d;return ie("div",{"data-grid-day-cell":!0,className:"cursor-pointer rounded-sm transition-colors hover:opacity-80",style:n?(d=g,0===(i=s)?{}:{backgroundColor:`var(--heat-${Math.min(i,d)})`}):{},onClick:n=>w(n,t,e.monthIndex),onDblClick:()=>D(t),children:ie("div",{className:"flex h-full w-full items-center justify-center",children:ie("span",{className:"flex h-4 w-4 items-center justify-center rounded-full text-[9px] font-medium "+(t.getTime()===m.getTime()?"bg-primary font-bold text-primary-foreground":n?s>0?s>=4?"text-white":"text-gray-800 dark:text-gray-100":"text-gray-500 dark:text-gray-400":"text-gray-300 dark:text-gray-600"),children:t.getDate()})})},`${e.monthIndex}-${r}`)})]})})]},e.monthIndex))}),p&&ie(Ra,{date:p.date,events:E,anchorEl:p.anchorEl,position:p.position,onClose:()=>f(null),locale:l,app:e,customContent:null==t?void 0:t.gridPopupContent})]})},Pa=e=>{var t;const n=(null===(t=e.config)||void 0===t?void 0:t.mode)||"year-canvas";return"fixed-week"===n?ie(Ia,Object.assign({},e)):"grid"===n?ie(Oa,{app:e.app,config:e.config}):ie(Ma,Object.assign({},e))},La={startOfWeek:1};const $a={enableAutoRecalculate:!0,enableValidation:!0,defaultEvents:[],maxEventsPerDay:50};function ja(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.AudioLines=({className:e,width:t=24,height:n=24})=>ie("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:[ie("path",{d:"M4 11a9 9 0 0 1 9 9"}),ie("path",{d:"M4 4a16 16 0 0 1 16 16"}),ie("circle",{cx:"5",cy:"19",r:"1"})]}),exports.BlossomColorPicker=yn,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 Zn(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(pn.Provider,{value:this.customRenderingStore},t.h(Bn,Object.assign({app:this.app},this.extraProps))),this.container)}},exports.Check=Bt,exports.ChevronDown=zt,exports.ChevronRight=Ft,exports.ChevronsUpDown=Zt,exports.ContentSlot=vn,exports.ContextMenu=Gn,exports.ContextMenuColorPicker=({selectedColor:e,onSelect:t,onCustomColor:n})=>{const{t:r}=ot();return ie("div",{children:[ie("div",{className:"grid grid-cols-7 gap-2 p-1 px-3",children:er.map(n=>ie("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&&ie("div",{className:"mt-1 flex cursor-pointer items-center rounded-sm px-3 py-0.5 text-[12px] text-[var(--df-color-foreground)] transition-colors hover:bg-[var(--df-color-primary)] hover:text-[var(--df-color-primary-foreground)]",onClick:e=>{e.stopPropagation(),n()},children:r("customColor")})]})},exports.ContextMenuItem=Kn,exports.ContextMenuLabel=({children:e})=>ie("div",{className:"px-3 py-0.5 text-[12px] font-semibold text-slate-950 dark:text-slate-50",children:e}),exports.ContextMenuSeparator=qn,exports.CreateCalendarDialog=wn,exports.CustomRenderingStore=Zn,exports.DefaultColorPicker=bn,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=s,exports.LocaleContext=at,exports.LocaleProvider=dn,exports.MiniCalendar=On,exports.PanelRightClose=({className:e,width:t=24,height:n=24})=>ie("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:[ie("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),ie("path",{d:"M15 3v18"}),ie("path",{d:"m8 9 3 3-3 3"})]}),exports.PanelRightOpen=({className:e,width:t=24,height:n=24})=>ie("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:[ie("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),ie("path",{d:"M15 3v18"}),ie("path",{d:"m10 15-3-3 3-3"})]}),exports.Plus=Wt,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=Mt,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=an,exports.clipboardStore=je,exports.compareAllDayDisplayPriority=et,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.createAllDayDisplayComparator=tt,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=ga,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 s=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:s,end:s})},exports.createEvents=function(e){return e.map(e=>He(e))},exports.createEventsPlugin=function(e={}){const t=Object.assign(Object.assign({},$a),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=ja(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=ja(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=Ta,exports.createStandardViews=function(e){return[ga(null==e?void 0:e.day),xa(null==e?void 0:e.week),Ta(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=xa,exports.createYearView=(e={})=>{const n=Object.assign(Object.assign({},La),e),r=e=>t.h(ua,{viewType:exports.ViewType.YEAR,originalComponent:Pa,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.getAllDayRangeMetrics=Qe,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=rn,exports.getLineColor=Y,exports.getMonthLabels=ln,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),s=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:s,timeZone:e.Temporal.Now.timeZoneId()}),allDay:!1,calendarId:t.calendarId,day:t.day}})},exports.getTimezoneDisplayLabel=W,exports.getWeekDaysLabels=on,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=i,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){sa=e},exports.registerLocale=function(e){const t=e.code.split("-")[0].toLowerCase();s[t]=e},exports.registerSidebarImplementation=function(e){_n=e},exports.resolveAppliedTheme=Ne,exports.restoreTimedDragFromAllDayTransition=({wasOriginallyAllDay:e,mouseHour:t,hourOffset:n,duration:r,originalStartHour:a,originalEndHour:o,firstHour:l,lastHour:s,minDuration:i,roundToTimeStep:d})=>{const c=e?1:Math.max(i,r||o-a||1);let u=d(e?t:t+(null!=n?n:0));return u=Math.max(l,Math.min(s-c,u)),{startHour:u,endHour:u+c,duration:c,hourOffset:e?0:null!=n?n:0}},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",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.sortAllDayByTitle=(e,t)=>e.title.localeCompare(t.title),exports.t=sn,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=da,exports.useLocale=ot,exports.useSidebarBridge=Wn,exports.weekDays=m,exports.weekDaysFullName=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],exports.zonedDateTimeToDate=x;
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}?\nDoing so will move all the events from {sourceName} to {targetName} and {sourceName} will be deleted.\nThis 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",subscribeCalendar:"Subscribe to Calendar",subscribeCalendarTitle:"Enter the URL of the calendar you want to subscribe to.",calendarUrl:"Calendar URL",calendarUrlPlaceholder:"https://example.com/calendar.ics",subscribe:"Subscribe",fetchingCalendar:"Fetching calendar...",subscribeError:"Failed to fetch calendar. Please check the URL and try again."}},s={en:l};function i(e){const t=e.split("-")[0].toLowerCase();return t in s?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",c.RESOURCE="resource";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 D(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 w(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 w(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=D(e.start),r=D(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},z=(e,t="24h")=>{const n=S(e.start),r=V(e);return`${F(n,0,t)} - ${F(r,0,t)}`},_=(t,n,r="24h",a=new Date)=>{const o=e.Temporal.Now.timeZoneId(),l=a.getFullYear(),s=a.getMonth()+1,i=a.getDate();return t.map(t=>{try{const a=t.hour%24,d=e.Temporal.ZonedDateTime.from({year:l,month:s,day:i,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 s=new Date(l);s.setDate(s.getDate()-7*a);for(let e=0;e<t;e++){const t=new Date(s);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=D(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)=>D(e.start).getTime()!==D(t.start).getTime()||D(e.end).getTime()!==D(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),s=new Date(a);s.setDate(s.getDate()+7),this.emitVisibleRange(l,s,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),s=new Date(l),i=new Date(l);i.setDate(i.getDate()+42),this.emitVisibleRange(s,i,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 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)?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)}void 0!==e.allDaySortComparator&&e.allDaySortComparator!==this.state.allDaySortComparator&&(this.state.allDaySortComparator=e.allDaySortComparator,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:[],allDaySortComparator:e.allDaySortComparator},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 se=0;function ie(e,n,r,a,o,l){n||(n={});var s,i,d=n;if("ref"in d)for(i in d={},n)"ref"==i?s=n[i]:d[i]=n[i];var c={type:e,props:d,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--se,__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 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`)},De=e=>e.replaceAll(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),we=e=>{let t,n=0,r="^";for(;null!==(t=ye.exec(e));){r+=De(e.slice(n,t.index));const a=t[0];r+=`(?<${a}>\\d{${"YYYY"===a?4:2}})`,n=t.index+a.length}return r+=De(e.slice(n))+"$",new RegExp(r)},Ee=(t,n,r,a)=>{const o=t.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 e.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}},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,s,i,d,c,u,h,g,m,p,f,v,y,b,x,D,w,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!==(s=M.nanosecond)&&void 0!==s?s: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===(i=null==a?void 0:a.timeZone)||void 0===i?void 0:i.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!==(D=null!==(x=null==a?void 0:a.second)&&void 0!==x?x:null==r?void 0:r.second)&&void 0!==D?D:0,millisecond:null!==(E=null!==(w=null==a?void 0:a.millisecond)&&void 0!==w?w: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.dfThemeOverride,t.dataset.dfTheme,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):D(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="",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}},$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 s=a.match(/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})$/);if(s){const t={year:Number.parseInt(s[1],10),month:Number.parseInt(s[2],10),day:Number.parseInt(s[3],10),hour:Number.parseInt(s[4],10),minute:Number.parseInt(s[5],10),second:Number.parseInt(s[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 ze(e){return`${e.getUTCFullYear()}${Ye(e.getUTCMonth()+1)}${Ye(e.getUTCDate())}T${Ye(e.getUTCHours())}${Ye(e.getUTCMinutes())}${Ye(e.getUTCSeconds())}Z`}function _e(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:${ze(new Date)}`);const l=Ve(e.start,e.allDay);let s;if(e.allDay){const t=(ce(e.end)?e.end:e.end.toPlainDate()).add({days:1});s={value:`${t.year}${Ye(t.month)}${Ye(t.day)}`,params:{VALUE:"DATE"}}}else s=Ve(e.end,!1);if(a.push(Be("DTSTART",l.value,l.params)),a.push(Be("DTEND",s.value,s.params)),a.push(Be("SUMMARY",_e(e.title))),e.description&&a.push(Be("DESCRIPTION",_e(e.description))),(null===(n=e.meta)||void 0===n?void 0:n.location)&&a.push(Be("LOCATION",_e(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(_e).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(";"),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=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: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=>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:s}=n,i=o?`${l}${ne()}`:t.uid,d=Fe(t.dtstart,t.dtstartParams,s);let c;c=t.dtend?Fe(t.dtend,t.dtendParams,s):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=s||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.subtract({days:1}).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:i,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:${_e(n)}`];return e.forEach(e=>{a.push(...Ze(e))}),a.push("END:VCALENDAR"),a.join("\r\n")}const Qe=e=>{const t=D(e.start);t.setHours(0,0,0,0);const n=D(e.end);return n.setHours(0,0,0,0),{startDay:t,endDay:n,isMultiDay:n.getTime()>t.getTime()}},et=(e,t,n)=>{const r=Qe(e),a=Qe(t);if(r.isMultiDay!==a.isMultiDay)return r.isMultiDay?-1:1;if(r.isMultiDay&&a.isMultiDay){const e=r.startDay.getTime()-a.startDay.getTime();if(0!==e)return e;const t=a.endDay.getTime()-r.endDay.getTime();if(0!==t)return t}if(n){const r=n(e,t);if(0!==r)return r}return r.startDay.getTime()-a.startDay.getTime()},tt=(e,t)=>{const n=new Map;return e.forEach(e=>{const{isMultiDay:t,startDay:r}=Qe(e),a=n.get(e.calendarId);a?t&&(a.hasMultiDay=!0,a.earliestMultiDayStart=Math.min(a.earliestMultiDayStart,r.getTime())):n.set(e.calendarId,{hasMultiDay:t,earliestMultiDayStart:t?r.getTime():Number.POSITIVE_INFINITY})}),(e,r)=>{var a,o,l,s,i,d;const c=n.get(e.calendarId),u=n.get(r.calendarId);if((null!==(a=null==c?void 0:c.hasMultiDay)&&void 0!==a&&a)!==(null!==(o=null==u?void 0:u.hasMultiDay)&&void 0!==o&&o))return(null==c?void 0:c.hasMultiDay)?-1:1;if(null!==(l=null==c?void 0:c.hasMultiDay)&&void 0!==l&&l&&null!==(s=null==u?void 0:u.hasMultiDay)&&void 0!==s&&s&&e.calendarId!==r.calendarId){const e=(null!==(i=null==c?void 0:c.earliestMultiDayStart)&&void 0!==i?i:Number.POSITIVE_INFINITY)-(null!==(d=null==u?void 0:u.earliestMultiDayStart)&&void 0!==d?d:Number.POSITIVE_INFINITY);if(0!==e)return e}return e.calendarId,r.calendarId,et(e,r,t)}};let nt=null;const rt=()=>{const[e,t]=r.useState(()=>nt||{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};nt=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},at=t.createContext({locale:"en-US",t:e=>e,getWeekDaysLabels:()=>[],getMonthLabels:()=>[],isDefault:!0});function ot(){return r.useContext(at)}const lt="df-month-view h-full flex flex-col select-none",st="p-2 flex justify-between",it="text-2xl font-bold text-gray-900 dark:text-gray-100",dt="df-date-number inline-flex items-center justify-center h-6 w-6 rounded-full text-sm mt-1 select-none",ct="flex-1 overflow-auto will-change-scroll overscroll-contain",ut="scrollbar-hide",ht="df-time-slot relative h-[4.5rem] flex",gt="df-time-label absolute top-0 -translate-y-1/2 right-2 text-[12px] text-gray-500 dark:text-gray-400 select-none",mt="df-time-grid-row h-[4.5rem] border-t flex",pt="df-current-time-line absolute left-0 top-0 w-full flex pointer-events-none",ft="df-current-time-label ml-2 text-primary-foreground text-xs font-bold px-1.5 bg-primary rounded-sm",vt="df-all-day-row flex items-center border-b",yt="rounded-xl my-0.5",bt="rounded-sm",xt="df-event-title font-medium text-xs truncate pr-1",Dt="df-month-event-color-bar inline-block w-0.75 h-3 mr-1 shrink-0 rounded-full",wt="h-3 w-3 mr-1",Et="resize-handle absolute left-0 top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20",Ct="resize-handle absolute right-0 top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20",Tt="bg-primary rounded-full text-primary-foreground",kt="df-nav-button df-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",St="h-4 w-4 transition-transform group-hover:scale-110",Mt="df-event-detail-panel fixed shadow-lg border rounded-lg",Nt="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 df-animate-in df-fade-in df-zoom-in-95",It="df-time-grid-boundary h-3 border-t relative",Rt="absolute top-0 -translate-y-1/2 text-[12px] text-gray-500 dark:text-gray-400",Ht="flex h-7 w-7 items-center justify-center rounded hover:bg-gray-100 dark:hover:bg-slate-800 transition-colors",At="text-gray-500 dark:text-gray-400",Ot="text-gray-600 dark:text-gray-300",Pt="text-xs",Lt="text-sm",$t="flex flex-col",jt="mr-1",Yt=(...e)=>e.filter(Boolean).join(" "),Ft=({className:e,width:t=24,height:n=24})=>ie("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:ie("path",{d:"m15 18-6-6 6-6"})}),Vt=({className:e,width:t=24,height:n=24})=>ie("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:ie("path",{d:"m9 18 6-6-6-6"})}),zt=({className:e,width:t=24,height:n=24})=>ie("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:[ie("path",{d:"m11 17-5-5 5-5"}),ie("path",{d:"m18 17-5-5 5-5"})]}),_t=({className:e,width:t=24,height:n=24})=>ie("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:[ie("path",{d:"m6 17 5-5-5-5"}),ie("path",{d:"m13 17 5-5-5-5"})]}),Wt=({className:e,width:t=24,height:n=24})=>ie("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:ie("path",{d:"m6 9 6 6 6-6"})}),Ut=({className:e,width:t=24,height:n=24})=>ie("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:[ie("path",{d:"M5 12h14"}),ie("path",{d:"M12 5v14"})]}),Bt=({className:e,width:t=24,height:n=24})=>ie("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:[ie("circle",{cx:"11",cy:"11",r:"8"}),ie("path",{d:"m21 21-4.3-4.3"})]}),Zt=({className:e,width:t=24,height:n=24})=>ie("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:ie("path",{d:"M20 6 9 17l-5-5"})}),Gt=({className:e,width:t=24,height:n=24})=>ie("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:[ie("path",{d:"m7 15 5 5 5-5"}),ie("path",{d:"m7 9 5-5 5 5"})]}),Kt=({className:e,width:t=24,height:n=24})=>ie("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:[ie("path",{d:"M18 6 6 18"}),ie("path",{d:"m6 6 12 12"})]}),qt=({className:e,width:t=24,height:n=24})=>ie("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:[ie("path",{d:"M8 2v4"}),ie("path",{d:"M16 2v4"}),ie("rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}),ie("path",{d:"M3 10h18"}),ie("path",{d:"M8 14h.01"}),ie("path",{d:"M12 14h.01"}),ie("path",{d:"M16 14h.01"}),ie("path",{d:"M8 18h.01"}),ie("path",{d:"M12 18h.01"}),ie("path",{d:"M16 18h.01"})]}),Xt=({className:e,width:t=24,height:n=24})=>ie("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:[ie("path",{d:"M18 8L22 12L18 16"}),ie("path",{d:"M2 12H22"})]}),Jt=({className:e,width:t=24,height:n=24})=>ie("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:ie("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),Qt=({className:e,width:t=24,height:n=24})=>ie("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:[ie("rect",{width:"18",height:"14",x:"3",y:"8",rx:"2"}),ie("path",{d:"M12 5a3 3 0 1 0-3 3"}),ie("path",{d:"M12 5a3 3 0 1 1 3 3"}),ie("path",{d:"M3 12h18"}),ie("path",{d:"M12 22V8"})]}),en=({className:e,width:t=24,height:n=24})=>ie("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:ie("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"})}),tn=({className:e,width:t=24,height:n=24})=>ie("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:[ie("path",{d:"M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z"}),ie("circle",{cx:"12",cy:"10",r:"3"})]}),nn=({className:e,width:t=24,height:n=24})=>ie("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:ie("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"})}),rn=({className:e,width:t=24,height:n=24})=>ie("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:[ie("path",{d:"m12 19-7-7 7-7"}),ie("path",{d:"M19 12H5"})]});function an(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 on(e){return e.charAt(0).toUpperCase()+e.slice(1)}const ln=(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},sn=(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 dn(e,t="en-US"){var n;if(["today","day","week","month","year"].includes(e)){const n=an(e,t);if(n)return on(n)}const r=i(t),a=s[r],o=null===(n=null==a?void 0:a.messages)||void 0===n?void 0:n[e];if(o)return o;const l=s.en.messages;return(null==l?void 0:l[e])||e}const cn=({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,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:dn(n,e);return r&&Object.entries(r).forEach(([e,t])=>{i=i.replaceAll(new RegExp(`{${e}}`,"g"),t)}),i},getWeekDaysLabels:ln,getMonthLabels:sn,isDefault:!1}},[a,t]);return ie(at.Provider,{value:o,children:n})},un=(e,t,n)=>{var r;const a=null===(r=t.state.views.get(e))||void 0===r?void 0:r.label;if(a)return a;const o=n(e);return o!==e?o:e.split(/[-_]/g).map(e=>e?e.charAt(0).toUpperCase()+e.slice(1):e).join(" ")},hn=({calendar:e,mode:t="buttons"})=>{const[n,a]=r.useState(!1),o=r.useRef(null),{t:l}=ot(),s=Array.from(e.state.views.keys()),i=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]),s.length<=1?null:ie("div","select"===t?{className:"relative inline-block",ref:o,children:[ie("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:[ie("span",{className:"text-gray-900 dark:text-gray-100",children:un(i,e,l)}),ie("span",{className:`${At} transition-transform duration-200 ${n?"rotate-180":""}`,children:ie(Wt,{width:16,height:16})})]}),n&&ie("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 df-animate-in",children:ie("div",{className:"p-1",role:"listbox",children:s.map(t=>ie("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 "+(i===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":i===t,children:un(t,e,l)},t))})}),ie("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 .df-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:s.map(t=>ie("button",{type:"button",className:"h-6 rounded-md px-4 text-sm font-medium transition-all duration-200 focus:outline-none "+(i===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:un(t,e,l)},t))})},gn=({calendar:e,switcherMode:t="buttons",onAddCalendar:n,onSearchChange:a,onSearchClick:o,searchValue:l="",isSearchOpen:s=!1,isEditable:i=!0,safeAreaLeft:d})=>{const c="buttons"===t,u=e.state.currentView===exports.ViewType.DAY,{screenSize:h}=rt(),g="mobile"===h,{t:m}=ot(),p=r.useCallback(e=>{const t=e.currentTarget.value;t!==l&&(null==a||a(t))},[a,l]);return ie("div",{className:"df-header flex shrink-0 items-center justify-between border-b pt-1 pr-2 transition-colors duration-200 "+(u||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:[ie("div",{className:"df-header-left mb-1 flex items-center",children:n&&i&&ie("button",{type:"button",id:"dayflow-add-event-btn",onClick:n,className:Ht,title:g?m("newEvent")||"New Event":m("createCalendar")||"Add Calendar",children:ie(Ut,{className:`h-4 w-4 ${At}`})})}),ie("div",{className:"df-header-mid flex flex-1 justify-center",children:c&&ie(hn,{mode:t,calendar:e})}),ie("div",{className:"df-header-right mb-1 flex items-center justify-end gap-3 pb-1",children:[!c&&ie(hn,{mode:t,calendar:e}),ie("button",{type:"button",onClick:o,className:`md:hidden ${Ht}`,title:m("search")||"Search",children:ie(Bt,{width:16,height:16})}),ie("div",{className:"group relative hidden md:block",children:[ie("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3",children:ie("span",{className:"text-gray-400 transition-colors group-focus-within:text-primary",children:ie(Bt,{width:16,height:16})})}),ie("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&&ie("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:ie("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[ie("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ie("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]})]})},mn=t.createContext(void 0),pn=({children:e,initialTheme:t="light",onThemeChange:n})=>{const[a,o]=r.useState(t),[l,s]=r.useState(()=>"undefined"!=typeof window&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"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)};return e.addEventListener?e.addEventListener("change",t):e.addListener&&e.addListener(t),()=>{e.removeEventListener?e.removeEventListener("change",t):e.removeListener&&e.removeListener(t)}},[]),r.useLayoutEffect(()=>{if("undefined"==typeof document)return;const e=document.documentElement,t=Ne(i),n="auto"===a?t:i;e.classList.contains(n)||(e.classList.remove("light","dark"),e.classList.add(n)),"auto"===a?e.dataset.dfThemeOverride&&delete e.dataset.dfThemeOverride:e.dataset.dfThemeOverride!==n&&(e.dataset.dfThemeOverride=n),e.dataset.dfTheme!==n&&(e.dataset.dfTheme=n)},[i,a,l]),r.useEffect(()=>{n&&n(a,i)},[a,i,n]);const c=r.useMemo(()=>({theme:a,effectiveTheme:i,setTheme:d}),[a,i,d]);return ie(mn.Provider,{value:c,children:e})},fn=()=>{const e=r.useContext(mn);if(void 0===e)throw new Error("useTheme must be used within a ThemeProvider");return e},vn=t.createContext(null);let yn=0;function bn({generatorName:e,generatorArgs:t,defaultContent:n,store:a}){const o=r.useRef(null),l=r.useContext(vn),s=a||l,i=r.useRef(null),[,d]=r.useState(0);i.current||(i.current="df-slot-"+yn++),r.useEffect(()=>{if(!o.current||!s||!e)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,e]),r.useEffect(()=>{if(!s||!i.current||!e)return;const n=i.current;s.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==s?void 0:s.isOverridden(e));return ie("div",{ref:o,className:"df-content-slot "+(c||u?"flex h-full flex-1 flex-col":""),children:!h&&n})}const xn=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]),ie("div",{ref:t,className:e.className})},Dn=({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 ie("div",{className:"flex justify-center",children:ie(xn,{defaultValue:a,coreSize:36,petalSize:32,initialExpanded:!0,openOnHover:!1,onChange:e=>t({hex:e.hex},!0),onCollapse:n})})},wn=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],En=({onClose:e,onCreate:a,app:l})=>{const{t:s}=ot(),{effectiveTheme:i}=fn(),[d,c]=r.useState(""),u=l.state.overrides.includes("createCalendarDialogColorPicker"),[h,g]=r.useState(wn[Math.floor(Math.random()*wn.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),D=e=>{g(e.hex)},w=()=>{p(!1)},E=()=>{g(f),p(!1)},C="dark"===i,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(ie("div",{className:"df-portal fixed inset-0 z-10000 flex items-center justify-center bg-black/50",children:ie("div",{className:"df-animate-in df-fade-in df-zoom-in-95 w-full max-w-sm rounded-lg bg-white p-6 shadow-xl dark:bg-gray-900",onClick:e=>e.stopPropagation(),children:[ie("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white "+(u?"mb-4":"mb-6"),children:s("createCalendar")}),ie("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:s}=P(r),i={id:ne(),name:d.trim(),colors:l,darkColors:s,isVisible:!0,isDefault:!1};a(i),e()},children:[u?ie(t.Fragment,{children:[ie("div",{className:"mb-4",children:ie("div",{className:"flex items-center gap-3",children:[ie("div",{className:"h-9 w-9 rounded-md border border-gray-200 shadow-sm dark:border-gray-600",style:{backgroundColor:h}}),ie("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:s("calendarNamePlaceholder"),autoFocus:!0})]})}),ie("div",{className:"mb-6",children:[ie("div",{className:"mb-4 grid grid-cols-7 gap-4",children:wn.map(e=>ie("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))}),ie("div",{className:"relative",children:[ie("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:s("customColor")}),m&&ie("div",{className:"fixed inset-0 z-10001 flex items-center justify-center bg-black/40 backdrop-blur-sm",onClick:E,children:ie("div",{className:"df-animate-in df-fade-in df-zoom-in-95 relative",onClick:e=>e.stopPropagation(),children:ie(bn,{generatorName:"createCalendarDialogColorPicker",generatorArgs:{color:h,onChange:D,onAccept:w,onCancel:E,styles:T},defaultContent:ie("div",{className:"rounded-lg border border-slate-200 bg-white p-4 shadow-2xl dark:border-slate-700 dark:bg-gray-900",children:[ie(Dn,{color:h,onChange:D}),ie("div",{className:"mt-4 flex justify-end gap-2 border-t pt-3 dark:border-slate-700",children:[ie("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:s("cancel")}),ie("button",{type:"button",onClick:w,className:"rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm hover:opacity-90",children:"OK"})]})]})})})})]})]})]}):ie("div",{className:"mb-8 flex items-center gap-4",children:[ie("div",{className:"flex-1",children:ie("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:s("calendarNamePlaceholder"),autoFocus:!0})}),ie("div",{className:"relative h-9 w-9 shrink-0",children:ie("div",{className:"absolute inset-0 flex items-center justify-center",children:ie(xn,{defaultValue:y,coreSize:36,petalSize:32,openOnHover:!1,onChange:e=>x(e),onCollapse:e=>x(e),className:"z-50"})})})]}),ie("div",{className:"flex justify-end space-x-2",children:[ie("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:s("cancel")}),ie("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:s("create")})]})]})]})}),document.body)},Cn=(t,n)=>e.Temporal.PlainDate.compare(t,n),Tn=({calendarDays:e,visibleMonth:n,startDate:r,endDate:a,weekDayLabels:o,disabled:l,onDaySelect:s})=>ie(t.Fragment,{children:[ie("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=>ie("span",{children:e},e))}),ie("div",{className:"grid grid-cols-7 gap-1 px-1",children:e.map(e=>{const t=e.month!==n.month,o=0===Cn(e,r),i=0===Cn(e,a),d=Cn(e,r)>=0&&Cn(e,a)<=0;return ie("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":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())})})]}),kn=({visibleMonth:e,monthLabels:t,disabled:n,onMonthChange:r,onYearChange:a})=>ie("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:[ie("div",{className:"flex items-center gap-1",children:[ie("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:ie(zt,{width:14,height:12})}),ie("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:ie(Ft,{width:14,height:12})})]}),ie("div",{className:"text-sm font-semibold text-slate-700 dark:text-gray-300",children:[t[e.month-1]," ",e.year]}),ie("div",{className:"flex items-center gap-1",children:[ie("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:ie(Vt,{width:14,height:12})}),ie("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:ie(_t,{width:14,height:12})})]})]}),Sn=Array.from({length:24},(e,t)=>t),Mn=Array.from({length:60},(e,t)=>t),Nn=({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=Mn.includes(i)?Mn:[...Mn,i].toSorted((e,t)=>e-t);return ie("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:[ie("div",{className:"flex justify-center border-b border-slate-100 dark:border-gray-600",children:ie("div",{className:"py-1.5 text-base text-slate-700 dark:text-gray-300",children:[s.hour.toString().padStart(2,"0"),":",s.minute.toString().padStart(2,"0")]})}),ie("div",{className:"flex p-1",children:[ie("div",{className:"w-14",children:ie("div",{className:`h-72 overflow-y-auto ${ut} 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:Sn.map(e=>{const t=e===s.hour;return ie("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)})})}),ie("div",{className:"w-14",children:ie("div",{className:`h-72 overflow-y-auto ${ut} 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===i;return ie("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)})})})]})]})},In=({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 ie("div",{ref:d,style:v(),"data-range-picker-popup":"true",children:ie("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:i?"100%":void 0},children:[ie("div",{className:"flex gap-1",children:[ie("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:[ie(kn,{visibleMonth:e,monthLabels:t,disabled:s,onMonthChange:u,onYearChange:h}),ie(Tn,{calendarDays:r,visibleMonth:e,startDate:y,endDate:b,weekDayLabels:n,disabled:s,onDaySelect:g})]}),l&&ie("div",{className:"flex flex-1 justify-end sm:w-32",children:ie(Nn,{focusedField:o,draftRange:a,disabled:s,onHourSelect:m,onMinuteSelect:p,timeListRefs:c})})]}),ie("div",{className:"flex justify-end",children:ie("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"})})]})})},Rn=({value:t,format:a="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]),b=r.useMemo(()=>sn(f,"short"),[f]),x=r.useMemo(()=>ln(f,"narrow"),[f]),D=r.useMemo(()=>v?"object"==typeof l&&(null==l?void 0:l.format)?l.format:o:"",[v,l,o]),w=r.useMemo(()=>xe(a,D),[a,D]),E=r.useMemo(()=>we(w),[w]),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,D),ke(C[1],a,D)]),H=r.useRef([ke(C[0],a,D),ke(C[1],a,D)]),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),z=r.useRef(null),_=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,D),r=ke(t,a,D),[o,l]=H.current;o===n&&l===r||(H.current=[n,r],R([n,r]))},[K,q,X,J,a,D]),r.useEffect(()=>{if(!L)return;const e=e=>{var t,n;const r=e.target;if(null===(t=z.current)||void 0===t?void 0:t.contains(r))return;if(null===(n=_.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=>{s&&s(e,[ke(e[0],a,D),ke(e[1],a,D)])},[D,a,s]),ee=r.useCallback(e=>{i&&i(e,[ke(e[0],a,D),ke(e[1],a,D)])},[D,a,i]),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 s=Ce(t);return e.Temporal.ZonedDateTime.from({timeZone:s,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 s=Te(a[0],Ce(l),l);return[e.Temporal.ZonedDateTime.compare(s,l)>0?l:s,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,D),t}),!1},[T,D,a,E,te]),se=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,D);return void R(e=>{const r=[...e];return r[t]=n,r})}const r=t.relatedTarget;r&&(null===(n=z.current)||void 0===n?void 0:n.contains(r))||le(e,t.currentTarget.value)},[le,c,L,a,D]),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||!z.current)return e;const t=z.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]),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(!z.current)return{};const e=z.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 ie("div",{className:"relative max-w-100",ref:z,children:[ie("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:[ie("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:ie("input",{type:"text",name:"range-start",value:I[0],onChange:se("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:w,autoComplete:"off",disabled:c})}),ie(Xt,{className:"text-slate-400 dark:text-gray-500"}),ie("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:ie("input",{type:"text",name:"range-end",value:I[1],onChange:se("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:w,autoComplete:"off",disabled:c})})]}),L&&(g?n.createPortal(ie(In,{visibleMonth:O,monthLabels:b,weekDayLabels:x,calendarDays:me,draftRange:T,focusedField:M,isTimeEnabled:!!v,disabled:c,matchTriggerWidth:m,popupRef:_,timeListRefs:W,onMonthChange:he,onYearChange:ge,onDaySelect:ne,onHourSelect:re,onMinuteSelect:ae,onOk:ue,getPopupStyle:ye}),g()):n.createPortal(ie(In,{visibleMonth:O,monthLabels:b,weekDayLabels:x,calendarDays:me,draftRange:T,focusedField:M,isTimeEnabled:!!v,disabled:c,matchTriggerWidth:m,popupRef:_,timeListRefs:W,onMonthChange:he,onYearChange:ge,onDaySelect:ne,onHourSelect:re,onMinuteSelect:ae,onOk:ue,getPopupStyle:ye}),document.body))]})},Hn=({options:e,value:t,onChange:a,registry:o,variant:l="desktop",disabled:s=!1})=>{const[i,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 i&&(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)}},[i]);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=()=>i&&"undefined"!=typeof window?"mobile"===l?n.createPortal(ie("div",{"data-calendar-picker-dropdown":"true",style:c,className:Nt,children:e.map(e=>ie("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:[ie("div",{className:"mr-3 flex min-w-0 flex-1 items-center",children:[ie("div",{className:"mr-2 flex w-5 justify-center",children:e.value===t&&ie(Zt,{className:"h-4 w-4 text-primary"})}),ie("span",{className:"truncate text-sm text-gray-700 dark:text-gray-200",children:e.label})]}),ie("span",{className:"h-3 w-3 shrink-0 rounded-full",style:{backgroundColor:p(e.value)}})]},e.value))}),document.body):n.createPortal(ie("ul",{"data-calendar-picker-dropdown":"true",style:c,className:"df-animate-in df-fade-in df-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=>ie("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?ie("span",{className:"mr-2 text-sm text-primary",children:ie(Zt,{width:12,height:12})}):ie("div",{className:"mr-2 h-3 w-3 text-sm",children:" "}),ie("span",{className:"mr-2 h-3 w-3 shrink-0 rounded-sm",style:{backgroundColor:p(e.value)}}),ie("span",{className:"text-sm whitespace-nowrap text-gray-700 dark:text-gray-200",children:e.label})]},e.value))}),document.body):null;return ie("div","mobile"===l?{className:"relative inline-block",ref:h,children:[ie("button",{type:"button",ref:g,disabled:s,onClick:e=>{e.stopPropagation(),s||d(!i)},className:"flex items-center space-x-2 rounded-md bg-gray-100 px-3 py-1.5 transition-colors dark:bg-gray-700 "+(s?"cursor-default opacity-50":""),children:[ie("span",{className:"h-3 w-3 rounded-full",style:{backgroundColor:p(t)}}),ie("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-200",children:(null==v?void 0:v.label)||t}),ie(Gt,{className:"h-4 w-4 text-gray-400"})]}),y()]}:{className:"relative inline-block",ref:h,children:[ie("button",{ref:g,type:"button",onClick:e=>{e.stopPropagation(),d(!i)},className:"flex h-8 items-center space-x-2 rounded-md bg-gray-100 px-2 py-1 transition-colors hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",children:[ie("span",{className:"h-4 w-4 shrink-0 rounded-sm",style:{backgroundColor:p(t)}}),ie(Gt,{className:"h-4 w-4 text-gray-600 dark:text-gray-300"})]}),y()]})},An=({event:t,isOpen:a,onEventUpdate:o,onEventDelete:l,onClose:s,app:i})=>{var d;const[c,u]=r.useState(t),{t:h}=ot();r.useEffect(()=>{u(t)},[t]);const g=r.useMemo(()=>(i?i.getCalendarRegistry():O()).getVisible().map(e=>({label:e.name,value:e.id})),[i,null==i?void 0:i.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==i?void 0:i.state.readOnly),b=!1!==(null==i?void 0:i.getReadOnlyConfig().viewable);if(!a||!b)return null;if("undefined"==typeof window||"undefined"==typeof document)return null;const x=ie("div",{className:"df-portal fixed inset-0 flex items-center justify-center",style:{pointerEvents:"auto",zIndex:9998},"data-event-detail-dialog":"true",children:[ie("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&&s()}}),ie("div",{className:"df-dialog-container relative shadow-2xl border rounded-lg p-6 max-w-md w-full mx-4",children:[ie("button",{type:"button",onClick:s,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:ie("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:ie("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),ie("div",{children:[ie("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:h("eventTitle")}),ie("div",{className:"mb-4 flex items-center justify-between gap-3",children:[ie("div",{className:"flex-1",children:ie("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&&ie(Hn,{options:g,value:c.calendarId||"blue",onChange:e=>{u(Object.assign(Object.assign({},c),{calendarId:e}))},registry:null==i?void 0:i.getCalendarRegistry()})]}),c.allDay?ie("div",{className:"mb-4",children:[ie("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:h("dateRange")}),ie(Rn,{value:[c.start,c.end],format:"YYYY-MM-DD",showTime:!1,timeZone:p,matchTriggerWidth:!0,disabled:!v,onChange:f,onOk:f,locale:null==i?void 0:i.state.locale})]}):ie("div",{className:"mb-4",children:[ie("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:h("timeRange")}),ie(Rn,{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==i?void 0:i.state.locale})]}),ie("div",{className:"mb-4",children:[ie("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:h("note")}),ie("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&&ie("div",{className:"flex space-x-2",children:[c.allDay?ie("button",{type:"button",className:"rounded-lg bg-primary/10 px-3 py-2 text-xs font-medium text-primary transition hover:bg-primary/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")}):ie("button",{type:"button",className:"rounded-lg bg-primary/10 px-3 py-2 text-xs font-medium text-primary transition hover:bg-primary/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")}),ie("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),s()},children:h("delete")}),ie("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),s()},disabled:!m,children:h("save")})]})]})]})]}),D=document.body;return D?n.createPortal(x,D):null},On=e=>e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}),Pn=({app:e,anchorRef:t,onClose:a,isOpen:o})=>{const{t:l}=ot(),[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)&&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,D]=r.useState(0),w=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:w.start,end:w.end});const c=new Set([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:w.start,end:w.end})}),t},[s,e,w]);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;D(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 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(ie("div",{ref:m,className:"df-portal 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?"df-animate-in df-fade-in df-zoom-in-95 duration-100":""),style:{top:p.top,left:p.left,visibility:u?"visible":"hidden"},children:[ie("div",{className:"p-4 pb-2",children:[ie("div",{className:"mb-2 text-xs font-semibold tracking-wider text-gray-500 uppercase dark:text-gray-400",children:l("quickCreateEvent")||"Quick Create Event"}),ie("div",{className:"relative",children:ie("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:s,onChange:e=>i(e.target.value)})})]}),ie("div",{className:"max-h-75 flex-1 overflow-y-auto px-2 py-1",children:[0===E.length&&s&&ie("div",{className:"px-4 py-3 text-center text-sm text-gray-400",children:l("noSuggestions")||"Type to create"}),E.map((e,t)=>{return ie("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:[ie("div",{className:"mr-3 h-8 w-1 shrink-0 rounded-full",style:{backgroundColor:e.color}}),ie("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[ie("div",{className:"truncate text-sm font-medium text-gray-900 dark:text-gray-100",children:e.title}),ie("div",{className:"flex",children:ie("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")})}),ie("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:(n=e.start,r=e.end,`${On(n)} - ${On(r)}`)})]})]},`${e.type}-${t}`);var n,r})]}),ie("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},Ln=({visibleMonth:e,currentDate:t,showHeader:n=!1,onMonthChange:a,onDateSelect:o})=>{const{locale:l}=ot(),s=r.useMemo(()=>(new Date).toDateString(),[]),i=t.toDateString(),d=r.useMemo(()=>ln(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 ie("div",{className:"px-3 py-3",children:[n?ie("div",{className:"mb-3 flex items-center justify-between",children:[ie("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:ie(Ft,{className:"h-4 w-4"})}),ie("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:c}),ie("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:ie(Vt,{className:"h-4 w-4"})})]}):"",ie("div",{className:"df-mini-calendar-grid grid grid-cols-7 gap-1 text-xs justify-items-center",children:[d.map((e,t)=>ie("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=>ie("button",{type:"button",className:` df-mini-calendar-day text-center py-1 rounded text-xs h-6 w-6 ${e.isToday?Tt: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()))]})]})},$n=({checked:e,onChange:t,disabled:n})=>ie("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:ie("div",{className:"h-5 w-5 transform rounded-full bg-white shadow-md transition-transform "+(e?"translate-x-5":"")})}),jn=({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)},x=(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 ie("div",{className:"relative mt-2 flex h-56 overflow-hidden rounded-lg",children:[ie("style",{children:"\n .no-scrollbar::-webkit-scrollbar { display: none; }\n .no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }\n "}),ie("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:[ie("div",{style:{height:96}}),o.map((n,r)=>ie("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*s,behavior:"smooth"})},children:ie("div",{className:"w-10 text-center text-xl transition-colors duration-200 "+(n===i?"font-bold text-black dark:text-white":"text-gray-400 dark:text-gray-500"),style:x(r,h),children:n.toString().padStart(2,"0")})},`h-${r}-${n}`)),ie("div",{style:{height:96}})]}),ie("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:[ie("div",{style:{height:96}}),l.map((n,r)=>ie("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*s,behavior:"smooth"})},children:ie("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}`)),ie("div",{style:{height:96}})]}),ie("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"})]})},Yn=({isOpen:e,onClose:t,onSave:a,onEventDelete:o,draftEvent:l,app:s,timeFormat:i="24h"})=>{const{locale:d,t:c}=ot(),u=s.getReadOnlyConfig(),h=!s.state.readOnly,g=!1!==u.viewable,[m,p]=r.useState(""),[f,v]=r.useState(""),[y,x]=r.useState(!1),[w,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=s.getEvents().some(e=>e.id===l.id);Y(e)}},[e,l,s]);const V=s.getCalendars(),z=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=D(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=D(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 _=r.useMemo(()=>{if(!e||!l)return!1;let t=new Date(w),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,w,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(w.getHours(),w.getMinutes());const n=e.getTime()-w.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(ie("div",{className:"df-portal pointer-events-none fixed inset-0 z-10000 flex items-end",children:[ie("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}),ie("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?"df-animate-slide-down":"df-animate-slide-up"),onClick:e=>e.stopPropagation(),children:[ie("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:[ie("button",{type:"button",onClick:t,className:"px-2 py-1 text-gray-500 hover:text-gray-700",children:c("cancel")}),ie("span",{className:"text-lg font-semibold",children:c(!h&&j?"viewEvent":j?"editEvent":"newEvent")}),h&&ie("button",{type:"button",onClick:()=>{if(!l)return;let e=new Date(w),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:!_,className:"px-2 py-1 font-bold transition-colors "+(_?"text-primary":"cursor-not-allowed text-gray-400 opacity-50"),children:c(j?"done":"create")}),!h&&ie("span",{className:"w-12"})]}),ie("div",{className:"flex-1 space-y-4 overflow-y-auto p-4",children:[ie("div",{className:"rounded-lg bg-white px-4 py-3 dark:bg-gray-900",children:ie("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&&ie("div",{className:"relative flex items-center justify-between rounded-lg bg-white px-4 py-3 dark:bg-gray-900",children:[ie("span",{className:"text-gray-700 dark:text-gray-300",children:c("calendar")}),ie(Hn,{options:z,value:f,onChange:h?v:()=>{},registry:s.getCalendarRegistry(),variant:"mobile",disabled:!h})]}),ie("div",{className:"flex items-center justify-between rounded-lg bg-white px-4 py-3 dark:bg-gray-900",children:[ie("span",{className:"text-gray-700 dark:text-gray-300",children:c("allDay")}),ie($n,{checked:y,onChange:h?x:()=>{},disabled:!h})]}),ie("div",{className:"overflow-hidden rounded-lg bg-white dark:bg-gray-900",children:[ie("div",{className:"flex items-center justify-between border-b border-gray-100 px-4 py-3 last:border-0 dark:border-gray-800",children:[ie("span",{className:"text-gray-700 dark:text-gray-300",children:c("starts")}),ie("div",{className:"flex space-x-2",children:[ie("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(w)}),!y&&ie("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(w.getHours()+w.getMinutes()/60,0,i)})]})]}),ie("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("start-date"===H?"max-h-100":"max-h-0"),children:ie("div",{className:"",children:ie(Ln,{currentDate:w,visibleMonth:M,onDateSelect:e=>B("start",e),onMonthChange:e=>Z("start",e),showHeader:!0})})}),ie("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("start-time"===H?"max-h-75":"max-h-0"),children:ie("div",{className:"",children:ie(jn,{date:w,onChange:e=>{const t=C.getTime()-w.getTime();E(e),T(new Date(e.getTime()+t))},timeFormat:i})})})]}),ie("div",{className:"overflow-hidden rounded-lg bg-white dark:bg-gray-900",children:[ie("div",{className:"flex items-center justify-between border-b border-gray-100 px-4 py-3 last:border-0 dark:border-gray-800",children:[ie("span",{className:"text-gray-700 dark:text-gray-300",children:c("ends")}),ie("div",{className:"flex space-x-2",children:[ie("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&&ie("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,i)})]})]}),ie("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("end-date"===H?"max-h-100":"max-h-0"),children:ie("div",{className:"",children:ie(Ln,{currentDate:C,visibleMonth:I,onDateSelect:e=>B("end",e),onMonthChange:e=>Z("end",e),showHeader:!0})})}),ie("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("end-time"===H?"max-h-75":"max-h-0"),children:ie("div",{className:"",children:ie(jn,{date:C,onChange:e=>{if(e<w){const t=C.getTime()-w.getTime();T(e),E(new Date(e.getTime()-t))}else T(e)},timeFormat:i})})})]}),ie("div",{className:"rounded-lg bg-white px-4 py-3 dark:bg-gray-900",children:ie("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&&ie("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)},Fn=()=>ie("svg",{className:"h-12 w-12 text-gray-300 dark:text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:ie("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),Vn=({loading:e,results:t,keyword:n,onResultClick:a,emptyText:o})=>{const{t:l,locale:s}=ot(),i=r.useMemo(()=>Pe(new Date),[]),d=r.useMemo(()=>$e(t,i),[t,i]),c=e=>Oe(e);return e?ie("div",{className:"flex h-40 flex-col items-center justify-center text-gray-500",children:[ie(Jt,{className:"mb-2 h-8 w-8 animate-spin"}),ie("span",{children:"Loading..."})]}):0===t.length?n?ie("div",{className:"flex h-40 flex-col items-center justify-center text-gray-500",children:[ie(Fn,{}),ie("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:ie("div",{className:"space-y-6",children:d.map(e=>{const{title:t,colorClass:n}=Le(e.date,i,s,l);return ie("div",{children:[ie("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}),ie("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 ie("div",{children:[ie("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:ie("div",{className:"flex items-stretch gap-3",children:[ie("div",{className:"w-1 shrink-0 rounded-full",style:{backgroundColor:e.color||"#3b82f6"}}),ie("div",{className:"flex min-w-0 flex-1 items-start justify-between",children:[ie("div",{className:"truncate pr-2 text-sm font-medium text-black dark:text-white",children:e.title}),ie("div",{className:"flex shrink-0 flex-col items-end text-xs leading-tight",children:[ie("div",{className:"text-black dark:text-white",children:o}),i&&ie("div",{className:"text-gray-500 dark:text-gray-400",children:i})]})]})]})}),ie("div",{className:"mx-2 border-b border-gray-200 dark:border-gray-700"})]},e.id)})})]},e.date.getTime())})})},zn=({isOpen:e,onClose:t,keyword:a,onSearchChange:o,results:l,loading:s,onResultClick:i,emptyText:d})=>{const c=r.useRef(null),{t:u}=ot();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(ie("div",{className:"df-portal fixed inset-0 z-9999 bg-white dark:bg-gray-900 flex flex-col",children:[ie("div",{className:"flex items-center p-2 border-b border-gray-200 dark:border-gray-700 gap-2",children:[ie("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:ie(rn,{className:"h-6 w-6"})}),ie("div",{className:"relative flex-1",children:[ie("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&&ie("button",{type:"button",onClick:()=>{""!==a&&o("")},className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400",children:ie(Kt,{className:"h-4 w-4"})})]})]}),ie("div",{className:"flex-1 overflow-y-auto p-2 select-none",children:ie(Vn,{loading:s,results:l,keyword:a,onResultClick:e=>{null==i||i(e)},emptyText:d})})]}),document.body):null},_n=({isOpen:e,loading:t,results:n,keyword:r,onResultClick:a,emptyText:o})=>ie("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:ie("div",{className:"min-w-64 flex-1 overflow-y-auto",children:ie(Vn,{loading:t,results:n,keyword:r,onResultClick:a,emptyText:o})})});let Wn=null;const Un={enabled:!1,width:"0px",isCollapsed:!1,toggleCollapsed:()=>{},miniWidth:"0px",content:null,extraContent:null,safeAreaLeft:0};function Bn(e){return Wn&&e.hasPlugin("sidebar")?Wn(e):Un}const Zn=({locale:e,messages:t,children:n})=>ot().isDefault?ie(cn,{locale:e,messages:t,children:n}):n,Gn=({app:e,customDetailPanelContent:o,customEventDetailDialog:l,meta:s,customMessages:i,search:d,titleBarSlot:c,collapsedSafeAreaLeft:u})=>{const h=r.useContext(vn),{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,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 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),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)}}),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):D(t.start),e.setCurrentDate(n),e.highlightEvent(t.id),i&&d(!1)},[e,i]),p=r.useCallback(()=>{o(""),d(!0)},[]),f=r.useCallback(()=>{s(!1),o(""),e.highlightEvent(null)},[e]),v=r.useCallback(()=>{d(!1),o(""),e.highlightEvent(null)},[e]);return{searchKeyword:n,setSearchKeyword:o,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()?An: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]),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:y(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),w=Bn(e),E=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:ne(),title:"",start:b(t),end:b(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,w.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:s,selectedEventId:m,onEventSelect:M,onDateChange:S,detailPanelEventId:x.detailPanelEventId,onDetailPanelToggle:x.setDetailPanelEventId},R=r.useMemo(()=>({isCollapsed:w.isCollapsed,toggleCollapsed:w.toggleCollapsed}),[w.isCollapsed,w.toggleCollapsed]),H=void 0!==u,A=H?"0px":w.miniWidth,O=H&&w.isCollapsed?u:w.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()||Yn;return ie(pn,{initialTheme:C,onThemeChange:k,children:ie(Zn,{locale:e.state.locale,messages:i,children:ie("div",{className:"df-calendar-container relative flex flex-row overflow-hidden select-none",children:[ie(bn,{store:h,generatorName:"titleBarSlot",generatorArgs:R,defaultContent:c&&("function"==typeof c?c(R):c)}),w.enabled&&ie("aside",{className:"absolute top-0 bottom-0 left-0 z-0 h-full",style:{width:w.width},children:w.content}),ie("div",{className:"relative z-10 flex h-full flex-1 flex-col overflow-hidden border-l bg-white transition-all duration-200 ease-in-out dark:bg-gray-900 "+(w.isCollapsed?"border-gray-200 shadow-xl dark:border-gray-700":"border-transparent"),style:{marginLeft:w.enabled?w.isCollapsed?A:w.width:0},children:[!1===P?null:"function"==typeof P?P(L):t.h(gn,L),ie("div",{className:"relative flex-1 overflow-hidden",ref:N,children:[ie("div",{className:"calendar-renderer relative flex h-full flex-row",children:[ie("div",{className:"h-full flex-1 overflow-hidden",children:ie($,Object.assign({},I))}),ie(_n,{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})]}),ie(zn,{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})]})]}),ie(Pn,{app:e,anchorRef:E.quickCreateAnchorRef,isOpen:E.isQuickCreateOpen,onClose:()=>E.setIsQuickCreateOpen(!1)}),ie(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}),w.extraContent,E.isCreateCalendarOpen&&ie(En,{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 ie(bn,{store:h,generatorName:"eventDetailDialog",generatorArgs:x.dialogProps,defaultContent:a?null:n.createPortal(t.h(e,x.dialogProps),r)})})()]})})})};class Kn{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 qn=n.forwardRef(({x:e,y:t,onClose:a,children:o,className:l},s)=>{const i=r.useRef(null);r.useEffect(()=>{const e=()=>a(),t=e=>{if(i.current&&!i.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(ie("div",{ref:e=>{i.current=e,"function"==typeof s?s(e):s&&"current"in s&&(s.current=e)},className:`df-portal df-animate-in df-fade-in df-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)});qn.displayName="ContextMenu";const Xn=({onClick:e,children:t,icon:n,danger:r,disabled:a})=>ie("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-[var(--df-color-primary)] hover:text-[var(--df-color-primary-foreground)] focus:bg-[var(--df-color-primary)] focus:text-[var(--df-color-primary-foreground)]"} ${r?"text-destructive hover:bg-destructive hover:text-destructive-foreground focus:bg-destructive focus:text-destructive-foreground":"text-[var(--df-color-foreground)]"}`,onClick:t=>{t.stopPropagation(),a||e()},"data-disabled":a,children:[n&&ie("span",{className:"mr-2 h-4 w-4",children:n}),t]}),Jn=()=>ie("div",{className:"-mx-1 my-1 h-px bg-slate-200 dark:bg-slate-800"}),Qn=({children:e})=>{const[n,a]=r.useState(!1),o=r.useRef(null);return r.useEffect(()=>()=>{o.current&&clearTimeout(o.current)},[]),ie("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)})},er=({children:e,icon:t,isOpen:n})=>ie("div",{className:"relative flex cursor-default items-center rounded-sm px-3 py-0.5 text-[12px] text-[var(--df-color-foreground)] transition-colors outline-none select-none hover:bg-[var(--df-color-primary)] hover:text-[var(--df-color-primary-foreground)] focus:bg-[var(--df-color-primary)] focus:text-[var(--df-color-primary-foreground)] "+(n?"bg-[var(--df-color-primary)] text-[var(--df-color-primary-foreground)]":""),children:[t&&ie("span",{className:"mr-2 h-4 w-4",children:t}),ie("span",{className:"grow text-left",children:e}),ie(Vt,{className:"ml-auto h-4 w-4 "+(n?"text-white opacity-100":"opacity-60")})]}),tr=({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?ie("div",{ref:n,className:"df-portal df-animate-in df-fade-in df-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},nr=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],rr=({x:t,y:n,date:r,onClose:o,app:l,onCreateEvent:s,viewType:i})=>{const{t:d}=ot(),c=je.hasEvent();return ie(qn,{x:t,y:n,onClose:o,className:"df-context-menu",children:[ie(Xn,{onClick:()=>{s(),o()},children:d("newEvent")||"New Event"}),ie(Xn,{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),s=ge(o.end).getTime()-l.getTime(),i=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()+(s>0?s:36e5)),m=Object.assign(Object.assign({},i),{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,i),o()}),disabled:!c,children:d("pasteHere")||"Paste Here"})]})},ar=({event:e,x:n,y:r,onClose:o,app:l})=>{var s;const{t:i}=ot(),d=l.getCalendars(),c=l.callbacks,u=null===(s=null==c?void 0:c.renderEventContextMenu)||void 0===s?void 0:s.call(c,e,o);return ie(qn,{x:n,y:r,onClose:o,children:[ie(Qn,{children:[ie(er,{children:i("calendars")||"Calendars"}),ie(tr,{children:d.map(t=>{const n=t.id===e.calendarId;return ie(Xn,{onClick:()=>{return n=t.id,l.updateEvent(e.id,{calendarId:n}),void o();var n},children:ie("div",{className:"flex w-full items-center",children:[ie("div",{className:"w-4 shrink-0",children:n&&ie(Zt,{className:"h-3 w-3 text-primary"})}),ie("div",{className:"flex min-w-0 items-center gap-1.5",children:[ie("div",{className:"h-3 w-3 shrink-0 rounded-sm",style:{backgroundColor:t.colors.lineColor}}),ie("span",{className:"truncate "+(n?"font-semibold":""),children:t.name})]})]})},t.id)})})]}),ie(Jn,{}),ie(Xn,{onClick:()=>{l.deleteEvent(e.id),o()},danger:!0,children:i("delete")||"Delete"}),ie(Xn,{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:i("cut")||"Cut"}),ie(Xn,{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:i("copy")||"Copy"}),u&&ie(t.Fragment,{children:[ie(Jn,{}),u]})]})},or=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("假期")?ie(Qt,{className:"h-3 w-3"}):t.includes("birthday")||t.includes("anniversary")||t.includes("生日")?ie(en,{className:"h-3 w-3"}):t.includes("conference")||t.includes("meeting")||t.includes("会议")||t.includes("研讨")?ie(nn,{className:"h-3 w-3"}):t.includes("trip")||t.includes("travel")||t.includes("旅行")?ie(tn,{className:"h-3 w-3"}):ie(qt,{className:"h-3 w-3"})},lr=(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=D(e.start),l=D(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){if(!(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=k(s,d)>0;if(!c&&e.allDay){if(s<t||s>a)return;const o=Math.floor((s.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=s;let h;if(e.allDay)h=new Date(i),h.setHours(23,59,59,999);else{0!==l.getHours()||0!==l.getMinutes()||0!==l.getSeconds()?(h=new Date(i),h.setHours(23,59,59,999)):(h=new Date(i),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 w=k(u,h)+1;r.push({id:`${e.id}-week-${t.getTime()}`,originalEventId:e.id,event:e,startDayIndex:p,endDayIndex:f,segmentType:x,totalDays:w,segmentIndex:0,isFirstSegment:v,isLastSegment:y})}),r},sr=(e,t,n=7)=>{if(e.allDay)return[];const r=D(e.start),a=D(e.end),o=new Date(r);o.setHours(0,0,0,0);const l=new Date(a);l.setHours(0,0,0,0);const s=k(o,l);if(0===s)return[];const i=0!==a.getHours()||0!==a.getMinutes()||0!==a.getSeconds()||0!==a.getMilliseconds(),d=a.getTime()-r.getTime();if(!e.allDay&&1===s&&!i&&d<864e5)return[];const c=i?s:Math.max(0,s-1),u=[];for(let e=0;e<=c;e++){const l=new Date(o);l.setDate(o.getDate()+e);const s=Math.floor((l.getTime()-t.getTime())/864e5);if(s<0||s>n-1)continue;const d=0===e,h=e===c,g=d?r.getHours()+r.getMinutes()/60:0,m=h&&i?a.getHours()+a.getMinutes()/60:24;u.push({dayIndex:s,startHour:g,endHour:m,isFirst:d,isLast:h})}return u},ir=n.memo(({segment:e,segmentIndex:n,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,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)`,D=r.useRef(null),w=r.useRef(null),E=t=>{const n="left"===t;return(n?e.isFirstSegment:e.isLastSegment)&&i&&h?ie("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(),i(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 ie("div",{className:"pointer-events-auto flex w-full min-w-0 items-center",children:[e.isFirstSegment&&or(e.event)&&ie("div",{className:"mr-1 shrink-0",children:ie("div",{className:"flex items-center justify-center rounded-full p-0.5 text-white",style:{backgroundColor:Y(n),width:"12px",height:"12px"},children:or(e.event)})}),ie("div",{className:"min-w-0 flex-1",children:ie("div",{className:"truncate text-xs",children:t()})}),e.isLastSegment&&"single"!==e.segmentType&&ie("div",{className:"ml-1 shrink-0 text-white/80 dark:text-white/90",children:ie("div",{className:"h-1.5 w-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 ie("div",{className:"pointer-events-auto relative flex w-full min-w-0 items-center",children:[ie("div",{className:Dt,style:{backgroundColor:Y(n)}}),ie("div",{className:"flex min-w-0 flex-1 items-center",children:ie("span",{className:`block overflow-hidden whitespace-nowrap ${c?"df-mobile-mask-fade":"truncate"} text-xs font-medium`,children:s})}),e.isFirstSegment&&!c&&ie("span",{className:"text-xs font-medium whitespace-nowrap "+(1===i?"ml-2":""),style:d,children:o}),e.isLastSegment&&!e.event.allDay&&24!==a&&!c&&ie("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 ie("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==s||s(t,e.event))},onMouseUp:()=>{v(!1)},onMouseLeave:()=>{v(!1)},onTouchStart:t=>{if(!s||!c||!u&&!g)return;t.stopPropagation(),v(!0);const n=t.touches[0],r=n.clientX,a=n.clientY,o=t.currentTarget;w.current={x:r,y:a},D.current=setTimeout(()=>{d&&d(e.event.id);u&&s({preventDefault:()=>{},stopPropagation:()=>{},currentTarget:o,touches:[{clientX:r,clientY:a}],cancelable:!1},e.event),D.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},onTouchMove:e=>{if(D.current&&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(D.current),D.current=null,w.current=null,v(!1))}},onTouchEnd:()=>{v(!1),D.current&&(clearTimeout(D.current),D.current=null),w.current=null},title:`${e.event.title} (${de(e.event.start)} - ${de(e.event.end)})`,children:[c&&l&&h&&ie(t.Fragment,{children:[e.isFirstSegment&&ie("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==i||i(t,e.event,"left")}}),e.isLastSegment&&ie("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==i||i(t,e.event,"right")}})]}),E("left"),ie("div",{className:"min-w-0 flex-1",style:{cursor:o?"ew-resize":"pointer"},children:p?p(C()):C()}),E("right")]});var M});ir.displayName="MultiDayEvent";const dr=({event:e,isEditable:n,onResizeStart:r,isMultiDay:a,segment:o,isSlidingView:l,renderSlot:s})=>{const i=!1!==e.icon,d="boolean"==typeof e.icon?null:e.icon,c=(()=>{if(!l||!a||!o)return{};if(o.startDayIndex<2&&o.endDayIndex>=2){return{paddingLeft:`calc(${(2-o.startDayIndex)/(o.endDayIndex-o.startDayIndex+1)*100}% + 0.75rem)`}}return{}})(),u=ie("div",{className:"flex h-full flex-1 items-center overflow-hidden",children:[i&&(d?ie("div",{className:"mr-1 shrink-0",children:d}):ie(qt,{className:wt})),ie("div",{className:`${xt} pr-1`,style:{lineHeight:"1.2"},children:e.title})]});return ie("div",{className:"absolute inset-0 flex items-center overflow-hidden pl-3 px-1 group py-0",style:c,children:[s?s(u):u,r&&n&&ie(t.Fragment,{children:[ie("div",{className:Et,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),r(t,e,"left")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}),ie("div",{className:Ct,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),r(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]})]})},cr=({event:e,isEventSelected:t})=>{const n=!1!==e.icon,r="boolean"==typeof e.icon?null:e.icon;return ie("div",{className:"text-xs px-1 rounded truncate cursor-pointer flex items-center",children:[n&&(r?ie("div",{className:`${jt} shrink-0`,children:r}):e.title.toLowerCase().includes("easter")||e.title.toLowerCase().includes("holiday")?ie("span",{className:`inline-block ${jt} shrink-0 ${t?"text-yellow-200":"text-yellow-600"}`,children:"⭐"}):ie(qt,{className:`${wt} ${t?"text-white":""}`})),ie("span",{className:"truncate "+(t?"text-white":""),children:e.title})]})},ur=({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 ie("div",{className:"text-xs cursor-pointer flex items-center justify-between px-0.5",children:[ie("div",{className:"flex min-w-0 flex-1 items-center",children:[ie("div",{style:{backgroundColor:Y(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())},className:Dt}),ie("span",{className:`block overflow-hidden whitespace-nowrap ${a?"df-mobile-mask-fade":"truncate"} ${n?"text-white":""}`,children:e.title})]}),!r&&!a&&ie("span",{className:`${Pt} ml-1 shrink-0 ${n?"text-white":""}`,style:n?void 0:{opacity:.8},children:o})]})},hr=({event:e,app:n,multiDaySegmentInfo:r,isEditable:a,isTouchEnabled:o,isEventSelected:l,onResizeStart:s,timeFormat:i="24h",resizeHandleOrientation:d="vertical",renderSlot:c})=>{const u=r?r.startHour:S(e.start),h=r?r.endHour:V(e),g=h-u,m=!r||r.isFirst,p=!r||r.isLast,f=e.calendarId||"blue",v=ie(t.Fragment,{children:[ie("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())}}),ie("div",{className:"flex h-full flex-col overflow-hidden pl-3 "+(V(e)-S(e.start)<=.25?"px-1 py-0":"p-1"),children:[ie("div",{className:`${xt} pr-1`,style:{lineHeight:g<=.25?"1.2":"normal"},children:e.title}),g>.5&&ie("div",{className:"df-event-time text-xs opacity-80 truncate",children:r?`${F(u,0,i)} - ${F(h,0,i)}`:z(e,i)})]})]});return ie(t.Fragment,{children:[c?c(v):v,s&&a&&"vertical"===d&&ie(t.Fragment,{children:[m&&ie("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")}),p&&ie("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")}),!m&&p&&r&&ie("div",{className:Ct,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),s(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]}),o&&l&&s&&a&&"vertical"===d&&ie(t.Fragment,{children:[ie("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(f,null==n?void 0:n.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),s(t,e,"top")}}),ie("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(f,null==n?void 0:n.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),s(t,e,"bottom")}})]}),s&&a&&"horizontal"===d&&ie(t.Fragment,{children:[ie("div",{className:Et,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),s(t,e,"left")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}),ie("div",{className:Ct,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),s(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]})]})},gr=({event:e,segment:n,isEditable:r,onMoveStart:a,onResizeStart:o,renderSlot:l})=>{const s=!!e.allDay,i=e.calendarId||"blue",d=Y(i),c=s?or(e):null,{isFirstSegment:u,isLastSegment:h}=n,g=t=>{const n="left"===t,a=n?u:h;return e.allDay&&a&&o&&r?ie("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(s){const t=()=>n.isFirstSegment?e.title:"···";return ie("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&&or(e)&&ie("div",{className:"df-year-event-icon mr-1 shrink-0",children:ie("div",{className:"flex items-center justify-center rounded-full p-0.5 text-white",style:{backgroundColor:Y(i),width:"12px",height:"12px"},children:or(e)})}),ie("div",{className:"min-w-0 flex-1",children:ie("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&&ie("div",{className:"ml-1 shrink-0 text-white/80 dark:text-white/90",children:ie("div",{className:"h-1.5 w-1.5 rounded-full bg-white/60 dark:bg-white/80"})})]})}const t=n.isFirstSegment?e.title:"";return ie("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:[!s&&ie("span",{style:{backgroundColor:d},className:"df-year-event-indicator inline-block h-3 w-0.75 shrink-0 rounded-full"}),s&&c&&ie("div",{className:"df-year-event-icon flex shrink-0 scale-75 items-center justify-center opacity-80",children:c}),ie("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 ie(t.Fragment,{children:[g("left"),l?l(m()):m(),g("right")]})};const mr=({event:e,viewType:t,isAllDay:n,isMultiDay:r,segment:a,yearSegment:o,segmentIndex:l,isBeingDragged:s,isBeingResized:i,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:D,customRenderingStore:w,eventContentSlotArgs:E,timeFormat:C="24h",renderVisualContent:T,resizeHandleOrientation:k})=>{const S=t===exports.ViewType.MONTH,M=t===exports.ViewType.YEAR,N=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}(w,t,n),I=e=>T?T(e):e;if(S&&r&&a)return ie(ir,{segment:a,segmentIndex:null!=l?l:0,isDragging:s||d,isResizing:i,isSelected:d,onMoveStart:b,onResizeStart:x,isMobile:f,isDraggable:h,isEditable:u,viewable:g,isPopping:c,renderSlot:e=>ie(bn,{store:w,generatorName:N,generatorArgs:E,defaultContent:I(e)})});if(M&&o)return ie(gr,{event:e,segment:o,isEditable:u,onMoveStart:b,onResizeStart:x,renderSlot:e=>ie(bn,{store:w,generatorName:N,generatorArgs:E,defaultContent:I(e)})});if(S){const t=e.allDay?ie(cr,{event:e,isEventSelected:d}):ie(ur,{event:e,app:y,isEventSelected:d,hideTime:p,isMobile:f});return ie(bn,{store:w,generatorName:N,generatorArgs:E,defaultContent:I(t)})}const R=e=>ie(bn,{store:w,generatorName:N,generatorArgs:E,defaultContent:I(e)});return n?ie(dr,{event:e,isEditable:u,onResizeStart:x,isMultiDay:r,segment:a,isSlidingView:v,renderSlot:R}):ie(hr,{event:e,app:y,multiDaySegmentInfo:D,isEditable:u,isTouchEnabled:m,isEventSelected:d,onResizeStart:x,timeFormat:C,resizeHandleOrientation:k,renderSlot:R})},pr=({event:t,position:a,panelRef:o,isAllDay:l,eventVisibility:s,calendarRef:i,selectedEventElementRef:d,onEventUpdate:c,onEventDelete:u,app:h})=>{var g;const{effectiveTheme:m}=fn(),p=Ne(m),{t:f}=ot(),[v,b]=r.useState(t.title),[x,D]=r.useState(null!==(g=t.description)&&void 0!==g?g:"");r.useEffect(()=>{b(t.title)},[t.title]),r.useEffect(()=>{var e;D(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 w=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"===s){const n=null===(e=i.current)||void 0===e?void 0:e.querySelector(".df-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"===s){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&&i.current){const e=d.current.getBoundingClientRect(),n=i.current.querySelector(".df-calendar-content");if(n){const r=n.getBoundingClientRect(),l=Math.max(e.top,r.top),s=Math.min(e.bottom,r.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-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=ie("div",{ref:o,className:`${Mt} 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:[ie("div",{style:M}),ie("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:f("eventTitle")}),ie("div",{className:"mb-3 flex items-center justify-between gap-3",children:[ie("div",{className:"flex-1",children:ie("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&&ie(Hn,{options:E,value:t.calendarId||"blue",onChange:e=>{c(Object.assign(Object.assign({},t),{calendarId:e}))},registry:null==h?void 0:h.getCalendarRegistry()})]}),ie("div",l?{className:"mb-3",children:[ie("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:f("dateRange")}),ie(Rn,{value:[t.start,t.end],format:"YYYY-MM-DD",showTime:!1,timeZone:w,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:[ie("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:f("timeRange")}),ie(Rn,{value:[t.start,t.end],timeZone:w,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})]}),ie("div",{className:"mb-3",children:[ie("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:f("note")}),ie("textarea",{id:`event-note-${t.id}`,name:"note",value:x,readOnly:!T,disabled:!T,onChange:e=>D(e.target.value),onInput:e=>D(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&&ie("div",{className:"flex space-x-2",children:[ie("button",l?{type:"button",className:"rounded bg-primary px-2 py-1 text-xs font-medium text-primary-foreground transition hover:bg-primary/90",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/90",onClick:()=>{const e=y(t.start)?t.start:t.start.toPlainDate(),n=y(t.end)?t.end:t.end.toPlainDate();c(Object.assign(Object.assign({},t),{allDay:!0,start:e,end:n}))},children:f("setAsAllDay")}),ie("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},fr=({event:e,position:t,panelRef:r,isAllDay:a,eventVisibility:o,calendarRef:l,selectedEventElementRef:s,onEventUpdate:i,onEventDelete:d,onClose:c,contentRenderer:u})=>{const{effectiveTheme:h}=fn(),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(".df-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&&s.current&&l.current){const e=s.current.getBoundingClientRect(),a=l.current.querySelector(".df-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=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=ie("div",{ref:r,className:`${Mt} 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:[ie("div",{style:f}),ie(u,{event:e,isAllDay:a,onEventUpdate:i,onEventDelete:d,onClose:c})]});return n.createPortal(v,document.body)},vr=({showDetailPanel:e,customEventDetailDialog:t,detailPanelPosition:n,event:r,detailPanelRef:a,isAllDay:o,eventVisibility:l,calendarRef:s,selectedEventElementRef:i,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:s,selectedEventElementRef:i,onEventUpdate:d,onEventDelete:c,onClose:u};return(null==h?void 0:h.isOverridden("eventDetailContent"))?ie(fr,Object.assign({},f,{contentRenderer:g})):m?ie(fr,Object.assign({},f,{contentRenderer:m})):ie(pr,Object.assign({},f,{app:p}))},yr=(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},br=(e,t,n,r,a)=>{let o="df-event calendar-event select-none pointer-events-auto";const l=e===exports.ViewType.DAY,s=e===exports.ViewType.MONTH,i=e===exports.ViewType.YEAR;l?o+=" df-day-event flex flex-col":s||i?i&&(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 yt;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 yt};if(i)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(s){let e=`\n ${o}\n ${t?d():bt}\n `;return n||(e+=" mb-[2px] last:mb-0"),e}return`\n ${o}\n shadow-sm\n ${t?d():bt}\n `},xr=({event:e,layout:n,isAllDay:a=!1,allDayHeight:o=28,calendarRef:l,isBeingDragged:s=!1,isBeingResized:i=!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:D,onEventDelete:w,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",styleOverride:z,className:_,disableDefaultStyle:W=!1,renderVisualContent:U,resizeHandleOrientation:B})=>{const Z=r.useContext(vn),G=null!=P?P:A,K=d===exports.ViewType.YEAR,[q,X]=r.useState(null),[J,Q]=r.useState(!1),ee=r.useRef(null),te=r.useRef(null),ne=r.useRef(null),re=r.useRef(null),ae=c&&u?`${e.id}::${u.id}`:void 0===(null==R?void 0:R.dayIndex)?K&&h?h.id:e.id:`${e.id}::day-${R.dayIndex}`,oe=y===ae,le=oe&&!I,se=null==H?void 0:H.getReadOnlyConfig(),de=!(null==H?void 0:H.state.readOnly),ce=!1!==(null==se?void 0:se.viewable),ue=!1!==(null==se?void 0:se.draggable),{isSelected:he,setIsSelected:ge,isPressed:me,setIsPressed:pe,handleTouchStart:fe,handleTouchMove:ve,handleTouchEnd:ye}=(({event:e,isTouchEnabled:t,onMoveStart:n,onEventLongPress:a,onDetailPanelToggle:o,canOpenDetail:l,app:s,multiDaySegmentInfo:i,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,s=o.clientY,u=r.currentTarget;v.current={x:l,y:s},f.current=setTimeout(()=>{var t;a?a(e.id):g(!0);const r={preventDefault:()=>{},stopPropagation:()=>{},currentTarget:u,touches:[{clientX:l,clientY:s}],cancelable:!1};if(i){const a=Object.assign(Object.assign({},e),{day:null!==(t=i.dayIndex)&&void 0!==t?t:e.day,_segmentInfo:i});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(),s&&s.onEventClick(e),l?null==o||o(u):null==o||o(null)),v.current=null}}})({event:e,isTouchEnabled:G,onMoveStart:b,onEventLongPress:k,onDetailPanelToggle:M,canOpenDetail:ce,app:H,multiDaySegmentInfo:R,isMultiDay:c,segment:u,detailPanelKey:ae}),[be,xe]=r.useState("visible"),De=e=>{re.current=e},we=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,ae,re.current,R,u),[e,y,ae,R,u]),Ee=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=yr(t,r),l=n===exports.ViewType.DAY?1:7,s=(a.width-o)/l,i=e-a.left-o,d=Math.floor(i/s);return Number.isFinite(d)?Math.max(0,Math.min(l-1,d)):null})(e,l,d,A),[l,d,A]),Ce=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=yr(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:Te,setDetailPanelPosition:ke,updatePanelPosition:Se}=(({event:e,viewType:t,isMultiDay:n,segment:a,yearSegment:o,multiDaySegmentInfo:l,calendarRef:s,eventRef:i,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[D,w]=r.useState(null),E=t===exports.ViewType.DAY,C=t===exports.ViewType.MONTH,T=t===exports.ViewType.YEAR,k=r.useCallback(()=>{if(!c.current||!s.current||!d.current)return;const e=s.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=yr(s,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,s;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=i.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!==(s=null==n?void 0:n.left)&&void 0!==s?s: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 D=g-b.right,E=b.left-e.left;v=D>=p+20?b.right+10:E>=p+20?b.left-p-10:D>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,w(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})})})},[s,e.day,e.start,e.end,h,C,g,m,n,a,l,v,y,u,E,T,o,p,b,x,c,d,i]);return r.useEffect(()=>{!f||D||u||(w({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>k()))},[f,D,k,u]),{detailPanelPosition:D,setDetailPanelPosition:w,updatePanelPosition:k}})({event:e,viewType:d,isMultiDay:c,segment:u,yearSegment:h,multiDaySegmentInfo:R,calendarRef:l,eventRef:ee,detailPanelRef:te,selectedEventElementRef:ne,isMobile:A,eventVisibility:be,firstHour:f,hourHeight:p,columnsPerRow:g,showDetailPanel:oe,detailPanelEventId:y,detailPanelKey:ae,getActiveDayIdx:we,getDayMetricsWrapper:Ce}),{handleClick:Me,handleDoubleClick:Ne,handleContextMenu:Ie,hasPendingSelection:Re}=(({event:e,viewType:t,isAllDay:n,isMultiDay:a,segment:o,multiDaySegmentInfo:l,calendarRef:s,firstHour:i,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:D,selectedEventElementRef:w})=>{const E=t===exports.ViewType.MONTH,C=t===exports.ViewType.YEAR,T=r.useRef(null),[k,M]=r.useState(!1),N=r.useCallback(()=>{T.current&&(clearTimeout(T.current),T.current=null,M(!1))},[]);r.useEffect(()=>()=>N(),[N]);const I=r.useCallback(()=>new Promise(t=>{if(!s.current||n||E||C)return void t();const r=s.current.querySelector(".df-calendar-content");if(!r)return void t();const a=l?l.startHour:S(e.start),o=l?l.endHour:V(e),c=(a-i)*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-i)*d-g/2,p=r.scrollHeight-g;r.scrollTo({top:Math.max(0,Math.min(p,m)),behavior:"smooth"}),setTimeout(()=>t(),300)}),[s,n,E,C,l,e.start,e.end,i,d]),R=r.useCallback(t=>{N(),t.preventDefault(),t.stopPropagation(),m&&m(e.id),y({x:t.clientX,y:t.clientY})},[N,e.id,m,y]),H=r.useCallback(t=>{var n,r,s;if(a){const a=x(t);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!==(s=e.day)&&void 0!==s?s:null);g&&g.onEventClick(e),m?m(e.id):u&&f(!0),null==p||p(null),v(null)},[a,x,b,null==l?void 0:l.dayIndex,e,o,g,m,u,f,p,v]),A=r.useCallback(t=>{var n,r,l,s,i;if(N(),t.preventDefault(),t.stopPropagation(),!u)return;let d=t.currentTarget;if(a){const e=d.querySelector("div");e&&(d=e)}if(w.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!==(s=null==o?void 0:o.endDayIndex)&&void 0!==s?s:6))}else b(null!==(i=e.day)&&void 0!==i?i:null);I().then(()=>{f(!0),C&&(null==m||m(e.id)),c||(null==p||p(h),v({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>D()))})},[N,u,a,w,x,b,null==o?void 0:o.startDayIndex,null==o?void 0:o.endDayIndex,e.day,I,f,C,c,p,h,v,D]);return{handleClick:r.useCallback(e=>{e.preventDefault(),e.stopPropagation();const t=e.clientX;if(C&&!c)return N(),M(!0),void(T.current=setTimeout(()=>{H(t),T.current=null,M(!1)},180));H(t)},[N,C,c,H]),handleDoubleClick:A,handleContextMenu:R,hasPendingSelection:k,scrollEventToCenter:I}})({event:e,viewType:d,isAllDay:a,isMultiDay:c,segment:u,multiDaySegmentInfo:R,calendarRef:l,firstHour:f,hourHeight:p,isMobile:A,canOpenDetail:ce,detailPanelKey:ae,app:H,onEventSelect:T,onDetailPanelToggle:M,setIsSelected:ge,setDetailPanelPosition:ke,setContextMenuPosition:X,setActiveDayIndex:De,getClickedDayIdx:Ee,updatePanelPosition:Se,selectedEventElementRef:ne}),He=(void 0===v?he:v===e.id)||Re||!G&&me||s,{calculateEventStyle:Ae}=(({event:e,layout:t,isAllDay:n,allDayHeight:r,viewType:a,isMultiDay:o,segment:l,yearSegment:s,columnsPerRow:i,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:D,getDayMetricsWrapper:w,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&&s&&i){const{startCellIndex:e,endCellIndex:t,visualRowIndex:n}=s,r=2;return{position:"absolute",left:`calc(${e/i*100}% + ${r}px)`,top:18*n+"px",width:`calc(${(t-e+1)/i*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=i||7,n=(l.endDayIndex-l.startDayIndex+1)/t*100,r=l.startDayIndex/t*100,a=2,o=l.isFirstSegment?a:0,s=o+(l.isLastSegment?a:0);Object.assign(e,{width:s>0?`calc(${n}% - ${s}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=D(),r=yr(y,b),a=C?1:i||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 s=w(n);s&&(l=s.left,o=s.width);let d=null===(N=y.current)||void 0===N?void 0:N.querySelector(".df-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=w(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:He,showDetailPanel:oe,isPopping:J,isDraggable:ue,canOpenDetail:ce,eventVisibility:be,calendarRef:l,isMobile:A,eventRef:ee,getActiveDayIdx:we,getDayMetricsWrapper:Ce,multiDaySegmentInfo:R});(({event:e,isEventSelected:t,showDetailPanel:n,eventRef:a,calendarRef:o,isAllDay:l,viewType:s,multiDaySegmentInfo:i,firstHour:d,hourHeight:c,updatePanelPosition:u,eventVisibility:h,setEventVisibility:g})=>{const m=s===exports.ViewType.MONTH,p=s===exports.ViewType.YEAR,f=r.useCallback(()=>{if(!t||!n||!a.current||!o.current||l||m||p)return;const r=o.current.querySelector(".df-calendar-content");if(!r)return;const s=i?i.startHour:S(e.start),f=i?i.endHour:V(e),v=(s-d)*c,y=v+Math.max((f-s)*c,c/4),b=r.getBoundingClientRect(),x=r.scrollTop,D=x+b.height,w=b.bottom<0,E=b.top>window.innerHeight;let C=h;w?C="sticky-top":E?C="sticky-bottom":"visible"===h?y<x?C="sticky-top":v>D-20&&(C="sticky-bottom"):"sticky-top"===h?y>=x&&(C="visible"):"sticky-bottom"===h&&v<=D-20&&(C="visible"),C!==h&&g(C),u()},[t,n,o,l,m,e.start,e.end,d,c,u,i,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(".df-calendar-content");if(!a)return;const s=()=>f(),i=()=>{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",s)}),window.addEventListener("scroll",s,!0),window.addEventListener("resize",i);let h=null;return o.current&&(h=new ResizeObserver(()=>{i()}),h.observe(o.current)),f(),()=>{d.forEach(e=>{e.removeEventListener("scroll",s)}),window.removeEventListener("scroll",s,!0),window.removeEventListener("resize",i),h&&h.disconnect()}},[t,n,l,f,u,o])})({event:e,isEventSelected:He,showDetailPanel:oe,eventRef:ee,calendarRef:l,isAllDay:a,viewType:d,multiDaySegmentInfo:R,firstHour:f,hourHeight:p,updatePanelPosition:Se,eventVisibility:be,setEventVisibility:xe});const Oe=oe&&!!I;(({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:ee,detailPanelRef:te,eventId:e.id,isEventSelected:!Oe&&He,showDetailPanel:le,onEventSelect:T,onDetailPanelToggle:M,setIsSelected:ge,setActiveDayIndex:De});const Pe=r.useCallback(()=>{T&&T(null),re.current=null,ge(!1),null==M||M(null)},[T,M,ge]),Le=r.useMemo(()=>({event:e,isAllDay:a,onEventUpdate:D,onEventDelete:w,onClose:Pe}),[e,a,D,w,Pe]),$e=r.useMemo(()=>({event:e,viewType:d,isAllDay:a,isMobile:A,isSelected:He,isDragging:s,segment:u,layout:n}),[e,d,a,A,He,s,u,n]),je=r.useCallback(()=>ie(bn,{store:Z,generatorName:"eventDetailContent",generatorArgs:Le}),[Z,Le]);r.useEffect(()=>{if((null==H?void 0:H.state.highlightedEventId)===e.id){Q(!0);const e=setTimeout(()=>{Q(!1)},300);return()=>{clearTimeout(e),Q(!1)}}},[null==H?void 0:H.state.highlightedEventId,e.id]),r.useEffect(()=>{const t=c&&(null==u?void 0:u.isFirstSegment)||K&&(null==h?void 0:h.isFirstSegment)||!c&&!K;E===e.id&&!oe&&t&&setTimeout(()=>{null==M||M(ae),null==C||C()},50)},[E,e.id,oe,c,u,K,h,M,C,ae]);const Ye=e.calendarId||"blue",Fe=null==H?void 0:H.getCalendarRegistry();return ie(t.Fragment,{children:[ie("div",{ref:ee,"data-event-id":e.id,className:`${br(d,a,c,u,h)} ${a&&E===e.id?"df-all-day-event-animate":""} ${null!=_?_:""}`,style:Object.assign(Object.assign(Object.assign({},W?{}:Ae()),{backgroundColor:He?j(Ye,Fe):L(Ye,Fe),color:He?"#fff":$(Ye,Fe)}),z),onClick:Me,onContextMenu:Ie,onDblClick:Ne,onMouseDown:t=>{var n;if(G||pe(!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:()=>!G&&pe(!1),onMouseLeave:()=>!G&&pe(!1),onTouchStart:fe,onTouchMove:ve,onTouchEnd:ye,children:ie(mr,{event:e,viewType:d,isAllDay:a,isMultiDay:c,segment:u,yearSegment:h,segmentIndex:m,isBeingDragged:s,isBeingResized:i,isEventSelected:He,isPopping:J,isEditable:de,isDraggable:ue,canOpenDetail:ce,isTouchEnabled:G,hideTime:Y,isMobile:A,isSlidingView:O,app:H,onMoveStart:b,onResizeStart:x,multiDaySegmentInfo:R,customRenderingStore:Z,eventContentSlotArgs:$e,timeFormat:F,renderVisualContent:U,resizeHandleOrientation:B})}),oe&&!I&&ie("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:9998,pointerEvents:"none"}}),ie(vr,{showDetailPanel:oe,customEventDetailDialog:I,detailPanelPosition:Te,event:e,detailPanelRef:te,isAllDay:a,eventVisibility:be,calendarRef:l,selectedEventElementRef:ne,onEventUpdate:D,onEventDelete:w,handlePanelClose:Pe,customRenderingStore:Z,contentSlotRenderer:je,customDetailPanelContent:N,app:H}),q&&H&&ie(ar,{event:e,x:q.x,y:q.y,onClose:()=>X(null),app:H,onDetailPanelToggle:M,detailPanelKey:ae})]})},Dr=({handlePreviousMonth:e,handleToday:t,handleNextMonth:n})=>{const{t:r}=ot();return ie("div",{className:"df-navigation flex items-center gap-1",children:[ie("button",{type:"button",className:kt,onClick:e,"aria-label":"Previous month",children:ie(Ft,{className:St})}),ie("button",{type:"button",className:"df-today-button df-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")}),ie("button",{type:"button",className:kt,onClick:n,"aria-label":"Next month",children:ie(Vt,{className:St})})]})},wr=({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}=ot(),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 ie("div",{className:st,style:{position:"relative"},onContextMenu:e=>e.preventDefault(),children:[ie("div",{className:"flex-1",children:ie("div","year"===e&&i?{style:{position:"relative",overflow:"hidden",height:"1.5em"},children:[ie("h1",{className:it,style:{position:"absolute",top:0,left:0,transform:`translateY(-${d}px)`,willChange:"transform"},children:i}),c&&ie("h1",{className:it,style:{position:"absolute",top:0,left:0,transform:`translateY(${u}px)`,willChange:"transform"},children:c})]}:{children:[ie("div",{className:`${it} text-gray-900 dark:text-white`,children:m}),p&&ie("div",{className:"mt-3 leading-6 text-gray-600 dark:text-gray-400",children:p})]})}),g&&n&&r&&a&&ie("div",{className:"flex items-center gap-2",children:ie(Dr,{handlePreviousMonth:n,handleNextMonth:r,handleToday:a})})]})};function Er(e,t,n,r,a){if(r||0!==e.button)return;let o=!0;const l={move(r){if(!o)return;Math.hypot(r.clientX-e.clientX,r.clientY-e.clientY)>=5&&(o=!1,document.removeEventListener("mousemove",l.move),document.removeEventListener("mouseup",l.up),null==a||a(e,t,n),document.dispatchEvent(new MouseEvent("mousemove",{clientX:r.clientX,clientY:r.clientY,bubbles:!0,cancelable:!1})))},up(){o=!1,document.removeEventListener("mousemove",l.move),document.removeEventListener("mouseup",l.up)}};document.addEventListener("mousemove",l.move),document.addEventListener("mouseup",l.up)}function Cr(){document.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0,cancelable:!1}))}const Tr=({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:x,handleResizeStart:D,handleCreateStart:w,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:z,ALL_DAY_HEIGHT:_,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}=ot(),ne=r.useRef(e.state.highlightedEventId),[re,ae]=r.useState(null),oe=r.useMemo(()=>Me(),[]),le=()=>{var e;const t=null===(e=O.current)||void 0===e?void 0:e.querySelector(".df-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},se=e=>{var t;const n=null===(t=O.current)||void 0===t?void 0:t.querySelector(".df-calendar-content");if(!n)return null;const r=n.getBoundingClientRect(),a=n.scrollTop||0;return U+(e-r.top+a-le())/W},de=(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=O.current)||void 0===r?void 0:r.querySelector(".df-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(".df-calendar-content"))||void 0===l?void 0:l.scrollTop)||0,r=le(),a=(e.clientY-t.top+n-r)/W+U,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)}}ae({x:e.clientX,y:e.clientY,date:s})};return ie("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:[ie("div",{className:`relative ${$t} h-full`,children:[ie("div",{onContextMenu:e=>e.preventDefault(),style:{paddingRight:j||!oe?"0px":"15px"},children:ie(wr,{calendar:e,viewType:exports.ViewType.DAY,currentDate:t})}),ie("div",Z?{className:Yt(vt,"relative items-stretch border-t border-gray-200 dark:border-gray-700"),ref:P,style:{paddingRight:j||!oe?"0px":"0.6875rem"},onContextMenu:e=>de(e,!0),children:[ie("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")}),ie("div",{className:Yt("relative flex flex-1 self-stretch",!j&&oe?"border-r border-gray-200 dark:border-gray-700":""),children:ie("div",{className:"relative w-full",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=>ie(xr,{event:t,isAllDay:!0,viewType:exports.ViewType.DAY,segmentIndex:t.row,allDayHeight:_,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),z(!0)):(g(t),e.state.highlightedEventId&&(e.highlightEvent(null),ne.current=null))},onEventLongPress:e=>{(j||Y)&&g(e)},customDetailPanelContent:H,customEventDetailDialog:A,app:e,isMobile:j,enableTouch:Y},t.id))})})]}:{className:!j&&oe?"pr-2.75":""}),ie("div",{className:"relative overflow-y-auto df-calendar-content df-day-time-grid",style:{position:"relative",scrollbarGutter:"stable"},children:ie("div",{className:"relative flex",children:[c&&u&&(()=>{const e=u,t=e.getHours()+e.getMinutes()/60;if(t<U||t>B)return null;return ie("div",{className:pt,style:{top:`${(t-U)*W}px`,width:"100%",height:0,zIndex:20,marginTop:ee?"2rem":"0.75rem"},children:[ie("div",{className:"flex w-12 items-center md:w-20",children:[ie("div",{className:"relative flex w-full items-center"}),ie("div",{className:ft,children:F(t,0,K,!1)})]}),ie("div",{className:"flex flex-1 items-center",children:ie("div",{className:"df-current-time-bar h-0.5 w-full bg-primary relative"})})]})})(),ie("div",{className:"df-time-column flex-shrink-0 "+(ee?"w-20 md:w-22":"w-12 md:w-20"),onContextMenu:e=>e.preventDefault(),children:[ie("div",{className:ee?"h-8":"h-3",children:ee&&ie("div",{className:"flex items-center justify-evenly gap-1 pt-1 pr-1 pb-0.5",children:[ie("span",{className:"text-[9px]select-none text-gray-500 md:text-[10px] dark:text-gray-400",children:J}),ie("span",{className:"text-[9px] text-gray-500 md:text-[10px] dark:text-gray-400",children:X})]})}),i.map((e,t)=>{var n;return ie("div",{className:ht,children:ie("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:[ie("span",{className:"text-[10px] md:text-[12px]",children:G&&0===t?"":null!==(n=null==q?void 0:q[t])&&void 0!==n?n:""}),ie("span",{className:"text-[10px] text-gray-500 md:text-[12px] dark:text-gray-400",children:G&&0===t?"":e.label})]}:{className:`${gt} text-[10px] md:text-[12px]`,children:G&&0===t?"":e.label})},t)})]}),ie("div",{className:"grow select-none",children:[ie("div",{className:Yt(It,!j&&oe?"border-r":"","border-t-0"),style:ee?{height:"2rem"}:void 0,children:ie("div",{className:`${Rt} -left-9.5`,style:{top:"auto",bottom:"-0.625rem"},children:G?F(U,0,K):""})}),ie("div",{className:"relative",style:{WebkitTouchCallout:"none"},ref:L,children:[i.map((e,r)=>ie("div",{className:Yt(mt,!j&&oe?"border-r":""),onClick:()=>null==R?void 0:R(t),onMouseDown:e=>{const r=se(e.clientY);if(null===r)return;Er(e,Math.floor((t.getTime()-n.getTime())/864e5),r,Y,w)},onDblClick:e=>{const r=se(e.clientY);if(null===r)return;const a=Math.floor((t.getTime()-n.getTime())/864e5);null==w||w(e,a,r),Cr()},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(".df-calendar-content"))||void 0===r?void 0:r.getBoundingClientRect();if(!l)return;const s=(null===(o=null===(a=O.current)||void 0===a?void 0:a.querySelector(".df-calendar-content"))||void 0===o?void 0:o.scrollTop)||0,i=le(),d=e.clientY-l.top+s-i,c=Math.floor(U+d/W);M(e,t,c)},onContextMenu:e=>de(e,!1)},r)),ie("div",{className:Yt(It,!j&&oe?"border-r":""),children:ie("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:[ie("span",{children:null!==(Q=null==q?void 0:q[0])&&void 0!==Q?Q:""}),ie("span",{children:F(0,0,K)})]}:{className:`${Rt} -left-9.5`,children:F(0,0,K)})}),ie("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 ie(xr,{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:D,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),z(!0)):(g(t),e.state.highlightedEventId&&(e.highlightEvent(null),ne.current=null))},onEventLongPress:e=>{(j||Y)&&g(e)},customDetailPanelContent:H,customEventDetailDialog:A,app:e,isMobile:j,enableTouch:Y},t.id)})})]})]})]})})]}),re&&ie(rr,{x:re.x,y:re.y,date:re.date,viewType:exports.ViewType.DAY,onClose:()=>ae(null),app:e,onCreateEvent:()=>{if(w){const e=Math.floor((t.getTime()-n.getTime())/864e5);if(0===re.date.getHours()&&0===re.date.getMinutes())null==E||E({clientX:re.x,clientY:re.y},e);else{const t=re.date.getHours()+re.date.getMinutes()/60,n={preventDefault:()=>{},stopPropagation:()=>{},clientX:re.x,clientY:re.y};w(n,e,t)}}}})]})},kr=({app:e,currentDate:t,visibleMonth:n,currentDayEvents:r,selectedEvent:a,setSelectedEvent:o,handleMonthChange:l,handleDateSelect:s,switcherMode:i,timeFormat:d="24h"})=>{const{t:c,locale:u}=ot(),h=[...r].toSorted((e,t)=>e.allDay&&!t.allDay?-1:!e.allDay&&t.allDay?1:0);return ie("div",{className:"df-right-panel hidden flex-none md:block w-[30%] bg-white dark:bg-gray-900",onContextMenu:e=>e.preventDefault(),children:ie("div",{className:`${$t} h-full`,children:[ie("div",{className:"df-mini-calendar px-2 border-b border-gray-200 dark:border-gray-700",children:ie("div",{children:[ie("div",{className:"flex items-center justify-end gap-2",children:[ie("div",{className:st,style:{position:"relative"},children:ie("div",{children:ie("h1",{className:it,children:" "})})}),ie(Dr,{handlePreviousMonth:()=>e.goToPrevious(),handleNextMonth:()=>e.goToNext(),handleToday:()=>e.goToToday()})]}),ie(Ln,{visibleMonth:n,currentDate:t,showHeader:!0,onMonthChange:l,onDateSelect:s})]})}),ie("div",{className:"flex-1 overflow-y-auto",children:ie("div",{className:"p-4",children:[ie("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?ie("p",{className:`${At} ${Lt}`,children:c("noEvents")}):ie("div",{className:"space-y-2",children:h.map(t=>ie("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:[ie("div",{className:`font-medium ${Lt}`,children:t.title}),!t.allDay&&ie("div",{className:`${Pt} ${Ot}`,children:[F(S(t.start),0,d)," ","- ",F(V(t),0,d)]}),t.allDay&&ie("div",{className:`${Pt} ${Ot}`,children:c("allDay")})]},t.id))})]})})]})})},Sr={PARALLEL_THRESHOLD:.25,NESTED_THRESHOLD:.5,INDENT_STEP_PERCENT:2.5,MIN_WIDTH:25,MARGIN_BETWEEN:1,EDGE_MARGIN_PERCENT:.9};function Mr(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 Nr(e){var t;return null!==(t=e._startHour)&&void 0!==t?t:S(e.start)}function Ir(e){var t;return null!==(t=e._endHour)&&void 0!==t?t:V(e)}function Rr(e,t){return e.day===t.day&&!e.allDay&&!t.allDay&&(Nr(e)<Ir(t)&&Nr(t)<Ir(e))}function Hr(e,t){const n=Ir(e)-Nr(e);if(n<1.25)return!1;const r=Nr(e)+.4*n,a=Nr(t)>=r,o=Rr(e,t);return a&&o}function Ar(e,t,n=Sr){if(!Rr(e,t))return!1;const r=Math.abs(Nr(e)-Nr(t));return r<=n.PARALLEL_THRESHOLD||(r>n.PARALLEL_THRESHOLD&&r<n.NESTED_THRESHOLD||function(e,t){return!(!Rr(e,t)||!Hr(e,t)&&!Hr(t,e))}(e,t))}function Or(e,t){const n=Nr(e)<=Nr(t)&&Ir(e)>=Ir(t),r=Nr(e)<=Nr(t)&&Nr(t)<Ir(e)&&Rr(e,t);return n||r}function Pr(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(Nr(r)-Nr(t))<=Sr.PARALLEL_THRESHOLD&&(a.push(t),n.add(t.id))}a.sort((e,t)=>Nr(e)-Nr(t));const o={events:a,startHour:Math.min(...a.map(e=>Nr(e))),endHour:Math.max(...a.map(e=>Ir(e)))};t.push(o)}return t.sort((e,t)=>e.startHour-t.startHour),t}function Lr(e){return"day"===e?.5:2.5}function $r(e){const t=Ir(e)-Nr(e);return Math.max(.1,Math.min(1,t/4))}function jr(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(Ar(e[t],e[n],Sr))return!0;return!1}function Yr(e,t,n,r,a={}){const o=Lr(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*Lr(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:$r(e.event)}),0===e.children.length)return;const u=[...e.children].toSorted((e,t)=>Ir(t.event)-Nr(t.event)-(Ir(e.event)-Nr(e.event)));1===u.length?Yr(u[0],d,c,r,a):jr(u.map(e=>e.event))?Fr(u,d,c,r,a):u.forEach(e=>Yr(e,d,c,r,a))}function Fr(e,t,n,r,a={}){const o=e.length,l=e[0].depth,s=l*Lr(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=>Yr(e,t,n,r,a));let h=Sr.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:$r(e.event)}),e.children.length>0){const t=[...e.children].toSorted((e,t)=>Ir(t.event)-Nr(t.event)-(Ir(e.event)-Nr(e.event)));1===t.length?Yr(t[0],n,g,r,a):jr(t.map(e=>e.event))?Fr(t,n,g,r,a):t.forEach(e=>Yr(e,n,g,r,a))}})}function Vr(e,t,n={}){const r=100-("day"===n.viewType?0:Sr.EDGE_MARGIN_PERCENT);if(1===e.length)Yr(e[0],0,r,t,n);else if(e.length>1){const a=e.length,o=(r-Sr.MARGIN_BETWEEN*(a-1))/a;e.forEach((e,r)=>{Yr(e,r*(o+Sr.MARGIN_BETWEEN),Math.max(o,Sr.MIN_WIDTH),t,n)})}}function zr(e){let t=0;for(const n of e.children)t+=1+zr(n);return t}function _r(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:zr(e)})).toSorted((e,t)=>t.load-e.load)}function Wr(e){return!(e.length<2)&&e[0].load-e.at(-1).load>=2}function Ur(e,t){t.parentId=e.id,e.children.includes(t.id)||e.children.push(t.id)}function Br(e,t){e.parent&&(e.parent.children=e.parent.children.filter(t=>t!==e));const n=t.children.find(t=>Or(t.event,e.event));n?(e.parent=n,e.depth=n.depth+1,n.children.push(e),Ur(n.event,e.event)):(e.parent=t,e.depth=t.depth+1,t.children.push(e),Ur(t.event,e.event))}function Zr(e,t){0===e.children.length?t.push(e):e.children.forEach(e=>Zr(e,t))}function Gr(e,t){const n=[];return Zr(e,n),n.find(e=>Or(t.event,e.event))||n[0]||null}function Kr(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=Gr(n.node,r.node);if(!a)break;Br(a,r.node),n.load--,r.load++,t++}}function qr(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(Rr(n,e)&&Math.abs(Nr(e)-Nr(n))<Sr.NESTED_THRESHOLD)return!0;return!1}(e,t))return!1;if(n<Sr.NESTED_THRESHOLD)return!1;for(const n of e.events)for(const e of t.events)if(Or(n,e))return!0;return!1}function Xr(e,t,n){const r=t.events.filter(t=>Or(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&&Ar(e,r,Sr)})}));return a.sort((t,n)=>t.load!==n.load?t.load-n.load:t.hasParallelSibling!==n.hasParallelSibling?t.hasParallelSibling?-1:1:Math.abs(Nr(e)-Nr(t.parent))-Math.abs(Nr(e)-Nr(n.parent))),a[0].parent}function Jr(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=Ir(e)-Nr(e),l=a.flatMap(e=>e.children);return o>Math.max(...l.map(e=>{const t=n.find(t=>t.id===e);return t?Ir(t)-Nr(t):0}),0)?a[0]:a.at(-1)||null}function Qr(e,t){t.parentId=e.id,e.children.includes(t.id)||e.children.push(t.id)}function ea(e){let t=0;for(const n of e.children)t+=1+ea(n);return t}function ta(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 na(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,s=null;for(const e of o){const t=ea(e);t<l&&(l=t,s=e)}return s?s.event:null}function ra(e,t,n){const r=[];if(1===e.length){const a=Xr(e[0],t,n);return a&&(r.push({child:e[0],parent:a}),Qr(a,e[0])),r}const a=t.events.filter(t=>e.every(e=>Or(t,e)));if(0===a.length){for(const a of e){const o=Xr(a,t,n);if(o)r.push({child:a,parent:o}),Qr(o,a);else{const t=e.find(e=>e.id!==a.id&&Rr(e,a));if(t){const e=na(t,ta(n));e&&(r.push({child:a,parent:e}),Qr(e,a))}}}return r}const o=[...e].toSorted((e,t)=>Ir(t)-Nr(t)-(Ir(e)-Nr(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}),Qr(n,e)}}else for(const e of o){const t=Jr(e,a,o);t&&(r.push({child:e,parent:t}),Qr(t,e))}return r}function aa(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(qr(d,{events:l,startHour:o.startHour,endHour:o.endHour})){const e=ra(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=_r(e[n].events.map(e=>t.find(t=>t.event.id===e.id)),t);Wr(r)&&Kr(r)}}(e,n),o}const oa={calculateDayEventLayouts(e,t={}){const n=e.map(Mr);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)||Rr(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:Sr.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{Vr(aa(Pr([...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}},la=(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},sa={HOUR_HEIGHT:72,FIRST_HOUR:0,LAST_HOUR:24,ALL_DAY_HEIGHT:28};function ia(t){const{app:n,onEventCreated:a}=t,{t:o}=ot(),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,s)=>{if(t.preventDefault(),!t.dataTransfer)return null;const i=t.dataTransfer.getData("application/x-dayflow-calendar");if(!i)return null;try{const t=JSON.parse(i);let d,c,u=!1;s?(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 da=null;const ca={handleMoveStart:()=>{},handleCreateStart:()=>{},handleResizeStart:void 0,handleCreateAllDayEvent:()=>{},dragState:{active:!1,mode:null,eventId:null,targetDate:null,startDate:null,endDate:null},isDragging:!1};function ua(e,t){return da?da(e,t):ca}const ha=({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}=rt(),m="desktop"!==g,[p,f]=r.useState(!1),{hourHeight:v=sa.HOUR_HEIGHT,firstHour:y=sa.FIRST_HOUR,lastHour:x=sa.LAST_HOUR,allDayHeight:w=sa.ALL_DAY_HEIGHT,showAllDay:E=!0,timeFormat:C="24h",secondaryTimeZone:T}=t,k=v,M=y,N=x,I=w,R=!E;r.useEffect(()=>{f("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const H=e.getCustomMobileEventRenderer()||Yn,[A,O]=r.useState(null),[P,L]=r.useState(null),[$,j]=r.useState(null),Y=void 0===s?P:s,V=void 0===c?$:c,z=r.useMemo(()=>Y&&h.find(e=>e.id===Y)||null,[Y,h]),U=e=>{i?i(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(".df-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),se=r.useRef(null),de=r.useMemo(()=>la(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=D(e.start),n=D(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=D(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=D(e.start),a=D(e.end);let o=e.start,l=e.end,s=!1;return t<n&&(o=b(n),s=!0),a>r&&(l=b(r),s=!0),Object.assign(Object.assign({},e),{start:s?o:e.start,end:s?l:e.end,day:0})})})(ce,Q),[ce,Q]),he=r.useMemo(()=>oa.calculateDayEventLayouts(ue,{viewType:"day"}),[ue]),ge=r.useMemo(()=>((e,t)=>{const n=e.filter(e=>e.allDay);if(t)n.sort(t);else{const e=new Map;n.forEach(t=>{e.has(t.calendarId)||e.set(t.calendarId,e.size)}),n.sort(tt(n,(t,n)=>{var r,a;return(null!==(r=e.get(t.calendarId))&&void 0!==r?r:0)-(null!==(a=e.get(n.calendarId))&&void 0!==a?a:0)}))}const r=[],a=[];return n.forEach(e=>{let t=0,n=!1;for(;!n;)r[t]?r[t].some(t=>{const n=D(e.start),r=D(e.end),a=D(t.start);return n<=D(t.end)&&a<=r})?t++:(r[t].push(e),a.push(Object.assign(Object.assign({},e),{row:t})),n=!0):(r[t]=[e],a.push(Object.assign(Object.assign({},e),{row:t})),n=!0)}),a})(ce,e.state.allDaySortComparator),[ce,e.state.allDaySortComparator]),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}=ua(e,{calendarRef:o,allDayRowRef:E?le:void 0,timeGridRef:se,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)),s=new Set(ce.map(e=>e.id)),i=a.filter(e=>!s.has(e.id)),d=a.filter(e=>{if(!s.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:i,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 s=[...a,{id:"-1",title:"Temp",day:0,start:b(o),end:b(l),calendarId:"blue",allDay:!1}];return oa.calculateDayEventLayouts(s,{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),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:b(i),end:b(d),day:0})];return 0===c.length?null:oa.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:De,handleDragOver:we}=ia({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?_(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(".df-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)},[]),ie("div",{className:"df-day-view flex h-full bg-gray-50 dark:bg-gray-800",children:[ie(Tr,{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,s;const i=null===(n=null===(e=o.current)||void 0===e?void 0:e.querySelector(".df-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(".df-calendar-content"),c=d?d.scrollTop:0,u=a-i.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:we,handleDrop:De,handleEventUpdate:t=>{e.updateEvent(t.id,t)},handleEventDelete:t=>{e.deleteEvent(t)},onDateChange:d,customDetailPanelContent:n,customEventDetailDialog:a,calendarRef:o,allDayRowRef:le,timeGridRef:se,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}),ie(kr,{app:e,currentDate:Q,visibleMonth:ee,currentDayEvents:ce,selectedEvent:z,setSelectedEvent:e=>U(e?e.id:null),handleMonthChange:ae,handleDateSelect:Se,switcherMode:l,timeFormat:C}),ie(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})]})},ga=({originalComponent:e,app:t,config:n,customDetailPanelContent:a,customEventDetailDialog:o,calendarRef:l,switcherMode:s,meta:i,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]),D=r.useCallback(e=>{m?m.add(e):t.addEvent(e)},[m,t]),w=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:D,onDateChange:w,onViewChange:E,config:C,customDetailPanelContent:a,customEventDetailDialog:o,calendarRef:l,switcherMode:s,meta:i,selectedEventId:d,detailPanelEventId:c,onEventSelect:u,onDetailPanelToggle:g}),[t,f,v,y,b,x,D,w,E,C,a,o,l,s,i,d,c,u,g]),k=r.useMemo(()=>{const e={currentDate:f,events:y,setEvents:e=>{y.forEach(e=>x(e.id)),e.forEach(e=>D(e))},updateEvent:b,deleteEvent:x,addEvent:D,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)}w(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)}w(e)},goToToday:()=>{w(new Date)},changeView:E,selectDate:w};return Object.assign(Object.assign({calendar:e},T),{eventsService:m,dragService:p})},[f,y,v,b,x,D,w,E,T,m,p]);return ie(e,Object.assign({},k))},ma={showAllDay:!0,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(ga,{viewType:exports.ViewType.DAY,originalComponent:ha,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}},fa=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)},va=({app:e,fullWeekDates:n=[],mobilePageStart:r,onDateChange:a})=>ie("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:[ie("div",{className:"mb-1 grid grid-cols-7",children:n.map((e,t)=>ie("div",{className:"flex justify-center",children:ie("span",{className:"text-[10px] font-medium "+(e.isToday?"text-primary":"text-gray-500"),children:fa(e.dayName)})},`label-${t}`))}),ie("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)`,s=`calc(${1/7*100}% + 32px)`;return ie(t.Fragment,{children:[ie("div",{className:"absolute rounded-full bg-gray-100 transition-all duration-300 dark:bg-gray-800",style:{left:l,top:0,width:s,height:"32px"}}),n.map((t,n)=>{const r=t.isCurrent,l=n>=o&&n<o+2;return ie("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:ie("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&&ie("div",{className:"absolute bottom-1 h-1 w-1 rounded-full bg-primary"})]})},`date-${n}`)})]})})()})]}),ya=({app:e,weekDaysLabels:n,mobileWeekDaysLabels:a,weekDates:o,fullWeekDates:l,isSlidingView:s,mobilePageStart:i,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:D,FIRST_HOUR:w,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:z,customEventDetailDialog:_})=>{const W={flexShrink:0},[U,B]=r.useState(null),Z=r.useMemo(()=>Me(),[]),G=!!S&&S.length>0&&!m;return ie("div",{className:"flex w-full flex-col",children:[s&&l&&i&&ie(va,{app:e,fullWeekDates:l,mobilePageStart:i,onDateChange:H}),ie("div",{className:`flex flex-none ${f?"border-b border-gray-200 dark:border-gray-700":""} relative z-10`,onContextMenu:e=>e.preventDefault(),children:[f&&ie("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:[ie("div",{className:"flex flex-1 items-center border-b border-gray-200 transition-all duration-300 ease-in-out dark:border-gray-700 "+(s?"hidden":""),children:G&&ie("div",{className:"flex w-full items-center justify-evenly gap-0.5 pt-2 pb-0.5",children:[ie("span",{className:"text-[9px] text-gray-500 select-none md:text-[10px] dark:text-gray-400",children:k}),ie("span",{className:"text-[9px] text-gray-500 select-none md:text-[10px] dark:text-gray-400",children:T})]})}),ie("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})]}),ie("div",{className:"relative flex-1 overflow-hidden transition-[min-height] duration-300 ease-in-out",style:{scrollbarGutter:"stable",minHeight:f?`${u+(s?0:36)}px`:"auto"},children:ie("div",{ref:b,className:"flex flex-col",style:{width:c,minWidth:"100%",transform:s?"translateX(calc(-100% / 3))":void 0},children:[!s&&ie("div",{className:"df-week-header flex border-b",style:{marginRight:Z?"-50px":"0px",paddingRight:Z?"50px":"0px"},children:n.map((e,n)=>ie("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:ie(t.Fragment,m?{children:[ie("div",{className:"text-[12px] leading-tight font-medium text-gray-500",children:a[n]}),ie("div",{className:`${dt} h-7 w-7 text-base font-medium ${o[n].isToday?Tt:""}`,children:o[n].date})]}:{children:[ie("div",{className:"mt-1 mr-1 inline-flex items-center justify-center text-sm",children:e}),ie("div",{className:`${dt} ${o[n].isToday?Tt:""}`,children:o[n].date})]})},n))}),f&&ie("div",{className:`${vt} relative border-none transition-[min-height] duration-300 ease-in-out`,ref:y,style:{minHeight:`${u}px`},children:ie("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),ie("div",{className:"df-all-day-cell flex-1 border-r 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}`)}),ie("div",{className:"pointer-events-none absolute inset-0",children:h.map(t=>ie(xr,{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:D,firstHour:w,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:z,customEventDetailDialog:_,app:e,isMobile:m,isSlidingView:s,enableTouch:p},t.event.id))})]})})]})}),U&&ie(rr,{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)}})]})]})},ba=({app:e,timeSlots:n,weekDaysLabels:a,currentWeekStart:o,currentWeekEvents:l,eventLayouts:s,gridWidth:i,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:D,handleDrop:w,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:z,FIRST_HOUR:_,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(),[]),re=e=>{if(!h.current)return _;const t=h.current.getBoundingClientRect();return _+(e-t.top)/z};return ie("div",{className:"relative flex flex-1 overflow-hidden",children:[ie("div",{ref:u,className:"df-calendar-content relative flex-1 overflow-auto "+("300%"===i?"overflow-x-hidden":"snap-x snap-mandatory"),style:{display:"grid",gridTemplateColumns:"auto 1fr"},onScroll:f,children:[ie("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:[ie("div",{className:"relative h-3",children:X?ie(t.Fragment,{children:ie("div",{className:"absolute right-0 -bottom-1 flex w-full items-center justify-evenly select-none",children:[ie("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:""}),ie("span",{className:"text-[10px] text-gray-500 md:text-[12px] dark:text-gray-400",children:U?F(_,0,B):""})]})}):ie("div",{className:"absolute right-2 -bottom-1 text-[10px] text-gray-500 select-none md:text-[12px] dark:text-gray-400",children:U?F(_,0,B):""})}),n.map((e,t)=>{var n;return ie("div",{className:ht,children:ie("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:[ie("span",{className:"text-[10px] md:text-[12px]",children:U&&0===t?"":null!==(n=null==Z?void 0:Z[t])&&void 0!==n?n:""}),ie("span",{className:"text-[10px] md:text-[12px]",children:U&&0===t?"":e.label})]}:{className:`${gt} text-[10px] md:text-[12px]`,children:U&&0===t?"":e.label})},t)}),ie("div",{className:"relative",children:ie("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:[ie("span",{className:"text-[10px] md:text-[12px]",children:null!==(q=null==Z?void 0:Z[0])&&void 0!==q?q:""}),ie("span",{className:"text-[10px] md:text-[12px]",children:F(0,0,B)})]}:{className:`${gt} text-[10px] md:text-[12px]`,children:F(0,0,B)})}),Y&&V&&(()=>{const e=V,t=e.getHours()+e.getMinutes()/60;if(t<_||t>W)return null;return ie("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:ie("div",{className:ft,children:F(t,0,B,!1)})})})()]}),ie("div",{ref:m,className:"flex",style:{width:i,minWidth:"100%",transform:j?"translateX(calc(-100% / 3))":void 0},children:ie("div",{className:"grow",children:[ie("div",{className:`${It} flex border-t-0`,children:a.map((e,t)=>ie("div",{className:`relative flex-1 ${t!==a.length-1||!d&&ne?"border-r":""} border-gray-200 dark:border-gray-700`,style:J},`top-${t}`))}),ie("div",{ref:h,className:"relative",children:[Y&&V&&(()=>{const e=V,t=e.getHours()+e.getMinutes()/60;if(t<_||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(),s=Math.round(l/864e5);return ie("div",{className:pt,style:{top:`${(t-_)*z}px`,width:"100%",height:0,zIndex:20},children:[ie("div",{className:"flex w-0 items-center"}),ie("div",{className:"flex flex-1",children:a.map((e,t)=>ie("div",{className:"flex flex-1 items-center",children:ie("div",{className:"relative h-0.5 w-full "+(t===s?"bg-primary":"bg-primary/30"),style:{zIndex:9999},children:t===s&&0!==s&&ie("div",{className:"absolute h-2 w-2 rounded-full bg-primary",style:{top:"-3px",left:"-4px"}})})},t))})]})})(),n.map((e,t)=>ie("div",{className:mt,children:a.map((n,r)=>{const l=new Date(o);return l.setDate(o.getDate()+r),ie("div",{className:"df-time-grid-cell flex-1 relative border-r 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)},onMouseDown:e=>{Er(e,r,re(e.clientY),c,v)},onDblClick:e=>{null==v||v(e,r,re(e.clientY)),Cr()},onTouchStart:t=>y(t,r,e.hour),onTouchEnd:b,onTouchMove:x,onDragOver:D,onDrop:t=>{w(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),s=60===l?a+1:a,i=60===l?0:l;r.setHours(s,i,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)),ie("div",{className:`${It} flex`,children:a.map((e,t)=>ie("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,i=K(n,l),u=[];return i.forEach(e=>{const t=sr(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=sr(e,o).find(e=>e.dayIndex===n);t&&u.push({event:e,segmentInfo:Object.assign(Object.assign({},t),{dayIndex:n})})}),ie("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=s.get(n),l=null==o?void 0:o.get(t.id);return ie(xr,{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:z,firstHour:_,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&&ie(rr,{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)}}})]})},xa=({app:e,config:t,customDetailPanelContent:n,customEventDetailDialog:a,calendarRef:o,selectedEventId:l,onEventSelect:s,onDateChange:i,detailPanelEventId:d,onDetailPanelToggle:c})=>{var u;const{t:h,getWeekDaysLabels:g,locale:m}=ot(),p=e.getCurrentDate(),f=r.useMemo(()=>p,[p.getTime()]),v=e.getEvents(),{screenSize:y}=rt(),x="desktop"!==y,w=r.useRef(null),[E,C]=r.useState(!1),{hourHeight:T=sa.HOUR_HEIGHT,firstHour:k=sa.FIRST_HOUR,lastHour:N=sa.LAST_HOUR,allDayHeight:I=sa.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()||Yn,z="desktop"!==y,U=z?2:7,B=z,Z=null!==(u=t.startOfWeek)&&void 0!==u?u:1,G=B?"300%":"100%",K=r.useMemo(()=>la(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),[se,de]=r.useState(null),ce=void 0===l?oe:l,ue=void 0===d?se:d,he=e=>{s?s(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),[De,we]=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),we(a),setTimeout(()=>{const t=new Date(X);t.setDate(t.getDate()-1),J(t),e.setCurrentDate(t),we(0),He.current=0,Ce(!1)},300)):r<-100?(Ce(!0),we(-a),setTimeout(()=>{const t=new Date(X);t.setDate(t.getDate()+1),J(t),e.setCurrentDate(t),we(0),He.current=0,Ce(!1)},300)):(Ce(!0),we(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=D(e.start);n.setHours(0,0,0,0);const a=D(e.end);return a.setHours(23,59,59,999),a>=t&&n<=r}).map(e=>{const r=D(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,r)=>{const a=lr(e,t,n).filter(e=>e.event.allDay);if(r)a.sort((e,t)=>r(e.event,t.event));else{const e=new Map;a.forEach(t=>{const n=t.event.calendarId;e.has(n)||e.set(n,e.size)});const t=tt(a.map(e=>e.event),(t,n)=>{var r,a;return(null!==(r=e.get(t.calendarId))&&void 0!==r?r:0)-(null!==(a=e.get(n.calendarId))&&void 0!==a?a:0)});a.sort((e,n)=>t(e.event,n.event))}const o=[];return a.forEach(e=>{let t=0,n=!1;for(;!n;){let r=!1;for(const n of o)if(n.row===t&&!(e.endDayIndex<n.startDayIndex||e.startDayIndex>n.endDayIndex)){r=!0;break}r?t++:n=!0}o.push(Object.assign(Object.assign({},e),{row:t}))}),o})(Ae,ne,ee,e.state.allDaySortComparator),[Ae,ne,ee,e.state.allDaySortComparator]),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=sr(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=oa.calculateDayEventLayouts(o,{viewType:"week"});r.set(a,l)}return r})(Ae,ne,ee),[Ae,ne,ee]),je=r.useCallback((t,n,r)=>{const a=t(Ae),o=new Set(a.map(e=>e.id)),l=Ae.filter(e=>!o.has(e.id)),s=new Set(Ae.map(e=>e.id)),i=a.filter(e=>!s.has(e.id)),d=a.filter(e=>{if(!s.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:i,update:d.map(e=>({id:e.id,updates:e}))},n,r)},[Ae,e]),Ye=r.useCallback(t=>{x?(be(t),ve(!0)):(e.addEvent(t),pe(t.id))},[x,e]),Fe=r.useCallback(()=>{},[]),Ve=r.useCallback((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},s=[...r.filter(t=>t.day===e&&!t.allDay),l];return oa.calculateDayEventLayouts(s,{viewType:"week"}).get("-1")||null})(e,t,n,Ae),[Ae]),ze=r.useCallback((e,t,n,r)=>((e,t,n,r,a)=>{const o=a.map(a=>{if(a.id!==e.id)return a;const o=D(a.start),l=M(o,n),s=M(o,r),i=b(l),d=b(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:oa.calculateDayEventLayouts(o,{viewType:"week"}).get(e.id)||null})(e,t,n,r,Ae),[Ae]),_e=r.useMemo(()=>({calendarRef:o,allDayRowRef:R?Te:void 0,timeGridRef:w,viewType:exports.ViewType.WEEK,onEventsUpdate:je,onEventCreate:Ye,onEventEdit:Fe,currentWeekStart:ne,events:Ae,calculateNewEventLayout:Ve,calculateDragLayout:ze,TIME_COLUMN_WIDTH:O,isMobile:x,gridWidth:G,displayDays:ee}),[o,R,je,Ye,Fe,ne,Ae,Ve,ze,O,x,G,ee]),{handleMoveStart:We,handleCreateStart:Ue,handleResizeStart:Be,handleCreateAllDayEvent:Ze,dragState:Ge,isDragging:Ke}=ua(e,_e),{handleDrop:qe,handleDragOver:Xe}=ia({app:e,onEventCreated:e=>{pe(e.id)}}),Je=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]),Qe=r.useMemo(()=>{if(!x)return[];const e=m.split("-")[0].toLowerCase();return"zh"===e||"ja"===e?g(m,"narrow"):Je.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,Je]),et=r.useMemo(()=>h("allDay"),[h]),nt=Array.from({length:24},(e,t)=>({hour:t+L,label:F(t+L,0,H)})),at=r.useMemo(()=>A?_(nt,A,H):void 0,[A,H,L]),lt=r.useMemo(()=>A?W(Intl.DateTimeFormat().resolvedOptions().timeZone):void 0,[A]),st=r.useMemo(()=>A?W(A):void 0,[A]),it=r.useMemo(()=>{const e=new Date;return e.setHours(0,0,0,0),Je.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,Je,m]),dt=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) + ${De}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)},[De,Ee,B]);const ct=t=>{e.updateEvent(t.id,t)},ut=t=>{e.deleteEvent(t)},ht=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)},[]),ie("div",{className:"df-calendar relative flex flex-col w-full overflow-hidden h-full select-none df-week-view",children:[ie(wr,{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()}),ie(ya,{app:e,weekDaysLabels:Je,mobileWeekDaysLabels:Qe,weekDates:it,fullWeekDates:dt,isSlidingView:B,mobilePageStart:X,currentWeekStart:ne,gridWidth:G,allDayAreaHeight:Le,organizedAllDaySegments:Pe,allDayLabelText:et,isMobile:x,isTouch:E,showAllDay:R,calendarRef:o,allDayRowRef:Te,topFrozenContentRef:Se,ALL_DAY_HEIGHT:j,HOUR_HEIGHT:P,FIRST_HOUR:L,dragState:Ge,isDragging:Ke,secondaryTimeSlots:at,primaryTzLabel:lt,secondaryTzLabel:st,handleMoveStart:We,handleResizeStart:Be,handleEventUpdate:ct,handleEventDelete:ut,onDateChange:i,newlyCreatedEventId:me,setNewlyCreatedEventId:pe,selectedEventId:ce,setSelectedEventId:he,detailPanelEventId:ue,setDetailPanelEventId:ge,handleCreateAllDayEvent:Ze,handleDragOver:Xe,handleDrop:qe,customDetailPanelContent:n,customEventDetailDialog:a}),ie(ba,{app:e,timeSlots:nt,weekDaysLabels:Je,currentWeekStart:ne,currentWeekEvents:Ae,eventLayouts:$e,gridWidth:G,isMobile:x,isSlidingView:B,isTouch:E,scrollerRef:ke,timeGridRef:w,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?`${De}px`:`-${t}px`;Se.current.style.transform=`translateX(calc(${e} + ${n}))`,Se.current.style.transition=B&&Ee?"transform 0.3s ease-out":"none"}},handleCreateStart:Ue,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==Ue||Ue({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:Xe,handleDrop:qe,dragState:Ge,isDragging:Ke,handleMoveStart:We,handleResizeStart:Be,handleEventUpdate:ct,handleEventDelete:ut,onDateChange:i,newlyCreatedEventId:me,setNewlyCreatedEventId:pe,selectedEventId:ce,setSelectedEventId:he,detailPanelEventId:ue,setDetailPanelEventId:ge,customDetailPanelContent:n,customEventDetailDialog:a,isCurrentWeek:ht,currentTime:re,HOUR_HEIGHT:P,FIRST_HOUR:L,LAST_HOUR:$,showStartOfDayLabel:Y,timeFormat:H,secondaryTimeSlots:at}),ie(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})]})},Da={showWeekends:!0,showAllDay:!0,startOfWeek:1,scrollToCurrentTime:!0,hourHeight:72,firstHour:0,lastHour:24,allDayHeight:28,timeFormat:"24h"},wa=(e={})=>{const n=Object.assign(Object.assign({},Da),e),r=e=>t.h(ga,{viewType:exports.ViewType.WEEK,originalComponent:xa,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}},Ea=17,Ca=n.memo(({currentMonth:t,currentYear:n,newlyCreatedEventId:a,screenSize:o,isScrolling:l,isDragging:s,showWeekNumbers:i,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:w,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}=ot(),[F,V]=r.useState(!1),z=r.useRef(null),_=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=Math.min(4,Math.floor(e/Ea)),n=e-20,r=Math.min(4,Math.max(0,Math.floor(n/Ea)));return{maxSlots:t,maxSlotsWithMore:t>0?Math.min(r,t-1):r}},[u]);r.useEffect(()=>l?(V(!0),z.current&&(clearTimeout(z.current),z.current=null),()=>{z.current&&(clearTimeout(z.current),z.current=null)}):F?(z.current=setTimeout(()=>{V(!1),z.current=null},100),()=>{z.current&&(clearTimeout(z.current),z.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(()=>lr(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=D(t.start),l=D(t.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(!t.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||t.allDay)if(c&&t.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(let a=o.getTime();a<=i.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:s.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 D(e.start).toDateString()===n;const t=D(e.start),r=D(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,t)=>{const n=t||tt(e.map(e=>e.event),(()=>{const t=new Map;return e.forEach(e=>{const n=e.event.calendarId;t.has(n)||t.set(n,t.size)}),(e,n)=>{var r,a;return(null!==(r=t.get(e.calendarId))&&void 0!==r?r:0)-(null!==(a=t.get(n.calendarId))&&void 0!==a?a:0)}})()),r=[...e].toSorted((e,t)=>{if(n){const r=n(e.event,t.event);if(0!==r)return r}const r=e.endDayIndex-e.startDayIndex+1,a=t.endDayIndex-t.startDayIndex+1;return e.startDayIndex>t.startDayIndex?1:r!==a?a-r:e.startDayIndex-t.startDayIndex}),a=[];r.forEach(e=>{var t;let n=0,r=!1;for(;!r;){let o=!1;for(const r of a){const a=Math.abs((null!==(t=r.yPosition)&&void 0!==t?t:0)-n)<16,l=!(e.endDayIndex<r.startDayIndex||e.startDayIndex>r.endDayIndex);if(a&&l){o=!0;break}}o?n+=16:r=!0}a.push(Object.assign(Object.assign({},e),{yPosition:n}))});const o=[];return a.forEach(e=>{var t;const n=Math.floor((null!==(t=e.yPosition)&&void 0!==t?t:0)/16);o[n]||(o[n]=[]),o[n].push(e)}),o.forEach(e=>{e.sort((e,t)=>{if(n){const r=n(e.event,t.event);if(0!==r)return r}return e.startDayIndex-t.startDayIndex})}),o})(J,L.state.allDaySortComparator),[J,L.state.allDaySortComparator]),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(()=>{const{maxSlots:e,maxSlotsWithMore:t}=Z,n=G.days.map((n,r)=>{var a,o;const l=(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!==(a=ee.get(n.date.toDateString()))&&void 0!==a?a:[]),s=l.filter(e=>{if(!e.allDay)return!0;return!ne.some(t=>t.originalEventId===e.id)}),i=(null!==(o=re[r])&&void 0!==o?o:0)-1,d=oe[r],c=[];for(let e=0;e<=i;e++)d.has(e)||c.push(e);const u=s.length,h=Math.max(0,u-c.length),g=Math.max(i+1,0)+h,m=g>e;return{totalSlotsNeeded:g,hasMore:m,limit:m?t:e,timedEventsOnly:s,gapLayers:c,occupiedLayers:d,maxOccupiedLayer:i}}),r=new Set;return te.forEach((e,t)=>{e.forEach(e=>{for(let a=e.startDayIndex;a<=e.endDayIndex;a++)if(a>=0&&a<7&&t>=n[a].limit){r.add(e.id);break}})}),n.map((n,a)=>{let o=!1;ne.forEach(e=>{e.startDayIndex<=a&&e.endDayIndex>=a&&r.has(e.id)&&(o=!0)});const l=n.hasMore||o,s=l?t:e;return Object.assign(Object.assign({},n),{hasMore:l,limit:s,segmentIsHidden:r})})},[Z,G.days,ee,ne,re,oe,te]),se=r.useMemo(()=>Math.min(te.length,Z.maxSlots),[te.length,Z.maxSlots]),de=r.useMemo(()=>Math.max(0,se*Ea),[se]),ce=(e,r)=>{const l=e.date.toLocaleDateString(Y,{month:Y.startsWith("zh")||Y.startsWith("ja")?"short":"long"})===t&&e.year===n,{hasMore:d,limit:c,timedEventsOnly:u,gapLayers:h,occupiedLayers:D,maxOccupiedLayer:F,totalSlotsNeeded:V}=le[r];let z=0;te.slice(c).forEach(e=>{e.forEach(e=>{e.startDayIndex<=r&&e.endDayIndex>=r&&z++})}),te.slice(0,c).forEach(e=>{e.forEach(e=>{e.startDayIndex<=r&&e.endDayIndex>=r&&le[r].segmentIsHidden.has(e.id)&&z++})});const U=h.filter(e=>e<c).length,Z=te.slice(0,c).filter(e=>e.some(e=>e.startDayIndex<=r&&e.endDayIndex>=r&&le[r].segmentIsHidden.has(e.id))).length,G=Math.max(0,c-Math.max(F+1,0)),K=Math.min(u.length,U+G+Z),J=u.slice(0,K),Q=z+(u.length-K),ee=d&&se>c,ne=(se-c)*Ea,re=[];let ae=0;const oe=Math.min(c,V);for(let t=0;t<oe;t++)if(D.has(t)&&!te[t].some(e=>e.startDayIndex<=r&&e.endDayIndex>=r&&le[r].segmentIsHidden.has(e.id)))re.push(ie("div",{className:"shrink-0",style:{height:"17px",minHeight:"17px"}},`placeholder-layer-${t}-${e.date.getTime()}`));else if(ae<J.length){const e=J[ae];re.push(ie(xr,{event:e,isAllDay:!!e.allDay,viewType:exports.ViewType.MONTH,isBeingDragged:s&&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)}-${ae}`)),ae++}return ie("div",{className:Yt("df-month-day-cell relative flex flex-col border-r",l?"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":(de=e.date,`${de.getFullYear()}-${String(de.getMonth()+1).padStart(2,"0")}-${String(de.getDate()).padStart(2,"0")}`),onClick:()=>l&&(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},_.current=setTimeout(()=>{null==y||y(t,e.date),_.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},onTouchMove:e=>{if(_.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(_.current),_.current=null)}},onTouchEnd:()=>{_.current&&(clearTimeout(_.current),_.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:[ie("div",{className:"df-month-date-number-container flex items-center justify-end text-right px-2 h-[33px] relative z-20",children:[i&&0===r&&"mobile"!==o&&ie("span",{className:"mr-auto ml-1 text-[10px] font-medium text-gray-400 dark:text-gray-500",children:N(e.date)}),ie("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":l?"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})]}),ie("div",{className:"pointer-events-none relative flex-1 overflow-hidden px-1",children:[ee&&ie("div",{className:"pointer-events-none absolute right-0 left-0 z-[100] bg-white dark:bg-gray-900",style:{top:c*Ea+"px",height:`${ne}px`}}),re,d&&ie("div",{className:Yt("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","desktop"===o?"text-left font-normal":"text-center font-medium","pointer-events-auto","z-[100]"),onClick:t=>{t.stopPropagation(),w?w(e.date):(null==C||C(e.date),null==E||E(exports.ViewType.DAY))},children:["+",Q,"desktop"===o?` ${j("more")}`:""]})]})]},`day-${e.date.getTime()}`);var de},ue=r.useMemo(()=>K?K.date.toLocaleDateString(Y,{month:"long",year:"numeric"}):"",[K,Y]);return ie("div",{className:"relative border-b border-gray-200 select-none dark:border-gray-700",style:{height:q},children:[d&&K&&ie("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:ie("span",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:ue})}),ie("div",{className:"flex h-full flex-col",children:ie("div",{className:"calendar-week relative h-full",children:[ie("div",{className:"grid h-full grid-cols-7",children:G.days.map((e,t)=>ce(e,t))}),te.length>0&&ie("div",{className:"pointer-events-none absolute right-0 left-0",style:{top:"33px",height:`${de}px`},children:te.slice(0,se).map((e,t)=>ie("div",{className:"absolute inset-0",children:e.filter(e=>!le[0].segmentIsHidden.has(e.id)).map(e=>ie(xr,{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:s&&g.eventId===e.event.id&&"move"===g.mode,isBeingResized:s&&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&&ie(rr,{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)}}})]})});Ca.displayName="WeekComponent";const Ta=({app:e,config:t,customDetailPanelContent:n,customEventDetailDialog:a,calendarRef:o,selectedEventId:l,onEventSelect:s,detailPanelEventId:i,onDetailPanelToggle:d})=>{var c,g,m;const{getWeekDaysLabels:p,getMonthLabels:f,locale:v}=ot(),y=e.getCurrentDate(),b=e.getEvents(),x=null!==(c=t.startOfWeek)&&void 0!==c?c:1,w=!0===(null===(g=t.scroll)||void 0===g?void 0:g.disabled),E=w&&"fade"===(null===(m=t.scroll)||void 0===m?void 0:m.transition),[C,T]=r.useState(y),[k,S]=r.useState(!1),[M,N]=r.useState("forward"),I=r.useRef(y),R=r.useRef(null),H=y.getFullYear(),A=y.getMonth();r.useEffect(()=>{if(!E)return;if(H===I.current.getFullYear()&&A===I.current.getMonth())return;const e=y>I.current;return I.current=y,N(e?"forward":"backward"),R.current&&clearTimeout(R.current),S(!0),R.current=setTimeout(()=>{T(y),S(!1)},300),()=>{R.current&&clearTimeout(R.current)}},[H,A,E]);const O=r.useMemo(()=>E?((e,t)=>{const n=new Date(e.getFullYear(),e.getMonth(),1),r=(n.getDay()-t+7)%7,a=new Date(n);a.setDate(n.getDate()-r),a.setHours(0,0,0,0);const o=[];for(let e=0;e<6;e++){const t=new Date(a);t.setDate(a.getDate()+7*e),o.push(Z(t))}return o})(C,x):[],[E,C,x]),P=r.useMemo(()=>({opacity:k?0:1,transform:k?`translateX(${"forward"===M?"-6%":"6%"})`:"translateX(0)",transition:"opacity 300ms ease, transform 300ms ease"}),[k,M]),L=e.getCalendars().map(e=>e.id+e.colors.lineColor).join("-"),$=r.useRef(null),j=r.useMemo(()=>{const e=$.current;return e&&e.length===b.length&&e.every((e,t)=>e===b[t])?e:($.current=b,b)},[b]),Y=r.useMemo(()=>{const e=new Map,t=e=>{const t=new Date(e);t.setHours(0,0,0,0);const n=(t.getDay()-x+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 j.forEach(e=>{if(!e.start)return;const r=D(e.start),a=e.end?D(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},[j,x]),{screenSize:F}=rt(),[V,z]=r.useState(!1);r.useEffect(()=>{z("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const _=e.getCustomMobileEventRenderer()||Yn,[W,U]=r.useState(119),[B,K]=r.useState(!1),q=r.useRef(W),X=r.useRef([]),[J,Q]=r.useState(null),[ee,ne]=r.useState(!1),[re,ae]=r.useState(null),[oe,le]=r.useState(null),[se,de]=r.useState(null),ce=void 0===l?oe:l,ue=void 0===i?se:i,he=r.useCallback(e=>{s?s(e):le(e)},[s]),ge=r.useCallback(e=>{d?d(e):de(e)},[d]),me=r.useRef(e.state.highlightedEventId);r.useEffect(()=>{e.state.highlightedEventId?he(e.state.highlightedEventId):me.current&&he(null),me.current=e.state.highlightedEventId},[e.state.highlightedEventId]);const pe=r.useMemo(()=>{const e=(y.getDay()-x+7)%7,t=new Date(y);return t.setDate(y.getDate()-e),t.setHours(0,0,0,0),t},[y,x]),{handleMoveStart:fe,handleCreateStart:ve,handleResizeStart:ye,dragState:be,isDragging:xe}=ua(e,{calendarRef:o,viewType:exports.ViewType.MONTH,onEventsUpdate:(t,n,r)=>{const a=t(j),o=new Set(a.map(e=>e.id)),l=j.filter(e=>!o.has(e.id)),s=new Set(j.map(e=>e.id)),i=a.filter(e=>!s.has(e.id)),d=a.filter(e=>{if(!s.has(e.id))return!1;const t=j.find(t=>t.id===e.id);return t&&te(t,e)});e.applyEventsChanges({delete:l.map(e=>e.id),add:i,update:d.map(e=>({id:e.id,updates:e}))},n,r)},onEventCreate:t=>{"desktop"===F?e.addEvent(t):(ae(t),ne(!0))},onEventEdit:e=>{Q(e.id)},currentWeekStart:pe,events:j,isMobile:"desktop"!==F}),{handleDrop:De,handleDragOver:we}=ia({app:e,onEventCreated:e=>{Q(e.id)}}),Ee=r.useMemo(()=>p(v,"short",x),[v,p,x]),{currentMonth:Ce,currentYear:Te,isScrolling:ke,virtualData:Se,weeksData:Me,scrollElementRef:Ne,isNavigating:Ie,handleScroll:Re,handlePreviousMonth:He,handleNextMonth:Ae,handleToday:Oe,setScrollTop:Pe}=(({currentDate:e,weekHeight:t,onCurrentMonthChange:n,initialWeeksToLoad:a=104,locale:o="en-US",startOfWeek:l=1,isEnabled:s=!0,snapToMonth:i=!1})=>{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]),g=r.useMemo(()=>{const t=new Date(e);return t.setDate(1),t.setHours(0,0,0,0),G(t,a,l)},[e,a,l]),m=r.useMemo(()=>{const n=new Date(e);n.setDate(1),n.setHours(0,0,0,0);const r=g.findIndex(e=>e.days.some(e=>e.date.toDateString()===n.toDateString()));return r>0?r*t:0},[g,e,t]),[p,f]=r.useState(m),[v,y]=r.useState(600),[b,x]=r.useState(c(e.getMonth(),e.getFullYear())),[D,w]=r.useState(e.getFullYear()),[E,C]=r.useState(!1),[T,k]=r.useState(g),[S,M]=r.useState(!1),N=r.useRef(!1),[I,R]=r.useState(!1),H=r.useRef(e),A=r.useRef(null),O=r.useRef(null),P=r.useRef(new h),L=r.useRef(0),$=r.useRef(0),j=r.useRef(!1),Y=r.useCallback(e=>{e&&(A.current=e)},[]),F=r.useCallback(e=>{let t=P.current.get(e);return t||(t=Z(e),P.current.set(e,t)),t},[]),V=r.useCallback((e,n=26)=>{j.current||(j.current=!0,setTimeout(()=>{try{if("future"===e){const e=T.at(-1),t=[];for(let r=1;r<=n;r++){const n=new Date(e.startDate);n.setDate(n.getDate()+7*r),t.push(F(n))}k(e=>[...e,...t])}else{const e=T[0],r=[];for(let t=n;t>=1;t--){const n=new Date(e.startDate);n.setDate(n.getDate()-7*t),r.push(F(n))}const a=r.length*t;k(e=>[...r,...e]),requestAnimationFrame(()=>{f(e=>e+a),A.current&&(A.current.scrollTop+=a)})}}finally{setTimeout(()=>{j.current=!1},200)}},0))},[T,F,t]),z=r.useMemo(()=>{const e=T.length*t,n=Math.floor(p/t);let r=Math.max(0,n);r=Math.min(r,Math.max(0,T.length-6));const a=Math.min(T.length-1,r+6-1),o=Math.max(0,r-15),l=Math.min(T.length-1,a+15),s=[];for(let e=o;e<=l;e++)s.push({index:e,weekData:T[e],top:e*t,height:t});return{totalHeight:e,visibleItems:s,displayStartIndex:r}},[p,v,t,T]),_=r.useCallback(e=>{if(S||E||0===e.length||!I)return;const t=p+v/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=Number.parseInt(r,10)}}),o&&l&&(d.current?o===d.current.month&&l===d.current.year&&(d.current=null,o===b&&l===D||(x(o),w(l),null==n||n(o,l))):o===b&&l===D||(x(o),w(l),null==n||n(o,l)))},[v,b,D,S,E,n,p,I]),W=r.useCallback(e=>{const n=performance.now();if(n-L.current<u.SCROLL_THROTTLE)return;L.current=n;const r=e.currentTarget,a=r.scrollTop;$.current=a,f(a),S||requestAnimationFrame(()=>{const{scrollHeight:e,clientHeight:n}=r;a+n>e-10*t&&!j.current&&V("future",26),a<10*t&&!j.current&&V("past",26)}),C(!0),O.current&&clearTimeout(O.current),O.current=setTimeout(()=>{C(!1)},u.SCROLL_DEBOUNCE)},[t,V,S]),U=r.useCallback((e,n=!0)=>{if(!A.current)return;M(!0),N.current=!0;const r=()=>{setTimeout(()=>{M(!1),N.current=!1},n?500:200)},a=T.findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(-1!==a){const e=a*t;return A.current.scrollTo({top:e,behavior:n?"smooth":"auto"}),void r()}const o=(e.getDay()-l+7)%7,s=new Date(e);s.setDate(e.getDate()-o),s.setHours(0,0,0,0);const i=T[0],d=T.at(-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(F(t))}const o=a.length*t;k(e=>[...a,...e]),requestAnimationFrame(()=>{const l=[...a,...T].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(A.current&&-1!==l){const e=l*t;A.current.scrollTop+=o,f(e=>e+o),setTimeout(()=>{A.current&&A.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(F(t))}k(e=>[...e,...a]),requestAnimationFrame(()=>{const o=[...T,...a].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(A.current&&-1!==o){const e=o*t;A.current.scrollTo({top:e,behavior:n?"smooth":"auto"})}r()})}else r()},[T,t,F]),B=r.useCallback(()=>{var e;const t=z.displayStartIndex,n=Math.min(T.length-1,t+5),r={};for(let a=t;a<=n;a++)null===(e=T[a])||void 0===e||e.days.forEach(e=>{const t=`${e.month}-${e.year}`;r[t]=(r[t]||0)+1});let a=0,o=0,l=0;for(const[e,t]of Object.entries(r))t>l&&(l=t,[a,o]=e.split("-").map(Number));const s=new Date(o,a-1,1);U(s)},[z.displayStartIndex,T,U]),K=r.useCallback(()=>{var e;const t=z.displayStartIndex,n=Math.min(T.length-1,t+5),r={};for(let a=t;a<=n;a++)null===(e=T[a])||void 0===e||e.days.forEach(e=>{const t=`${e.month}-${e.year}`;r[t]=(r[t]||0)+1});let a=0,o=0,l=0;for(const[e,t]of Object.entries(r))t>l&&(l=t,[a,o]=e.split("-").map(Number));const s=new Date(o,a+1,1);U(s)},[z.displayStartIndex,T,U]),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},x(r),w(a),null==n||n(r,a);const l=T.findIndex(e=>e.days.some(e=>e.date.toDateString()===o.toDateString()));if(-1===l)M(!0),N.current=!0,requestAnimationFrame(()=>{U(o,!0),setTimeout(()=>{N.current=!1,M(!1)},200)});else{const e=l*t,n=A.current;n&&(M(!0),N.current=!0,requestAnimationFrame(()=>{f(e),requestAnimationFrame(()=>{n&&(n.scrollTop=e,setTimeout(()=>{N.current=!1,M(!1)},200))})}))}},[T,t,n,U]);return r.useEffect(()=>{_(z.visibleItems)},[z.visibleItems,_]),r.useEffect(()=>{const t=H.current,r=t.getMonth(),a=t.getFullYear(),o=e.getMonth(),l=e.getFullYear();if(r!==o||a!==l){const e=6,t=z.displayStartIndex,r=Math.min(T.length-1,t+e-1),a={};for(let e=t;e<=r;e++){const t=T[e];t&&t.days.forEach(e=>{const t=`${e.month}-${e.year}`;a[t]=(a[t]||0)+1})}let s="",i=0;for(const[e,t]of Object.entries(a))t>i&&(i=t,s=e);if(s!==`${o}-${l}`){const e=new Date(l,o,1),t=c(o,l);d.current={month:t,year:l},x(t),w(l),null==n||n(t,l),U(e,!0)}}H.current=e},[e,n,U,z,T,c]),r.useEffect(()=>{const e=A.current;if(!e)return;const t=new ResizeObserver(([e])=>{y(e.contentRect.height)});return t.observe(e),()=>t.disconnect()},[]),r.useEffect(()=>{const e=A.current;e&&!I&&s&&requestAnimationFrame(()=>{e&&m>0?(e.scrollTop=m,f(m),R(!0)):e&&R(!0)})},[I,m,s]),r.useEffect(()=>{var e;if(!i||E||S||!I)return;const n=Math.floor(p/t),r=Math.min(T.length-1,n+5),a={};for(let t=n;t<=r;t++)null===(e=T[t])||void 0===e||e.days.forEach(e=>{const t=`${e.month}-${e.year}`;a[t]=(a[t]||0)+1});let o=0,l=0,s=0;for(const[e,t]of Object.entries(a))t>s&&(s=t,[o,l]=e.split("-").map(Number));const d=new Date(l,o,1),c=T.findIndex(e=>e.days.some(e=>e.date.toDateString()===d.toDateString()));if(-1===c)return;const u=c*t;if(Math.abs(u-p)>5){const e=setTimeout(()=>{U(d,!0)},200);return()=>clearTimeout(e)}},[E,i,S,I,p,t,T,U]),r.useEffect(()=>()=>{O.current&&clearTimeout(O.current)},[]),{scrollTop:p,containerHeight:v,currentMonth:b,currentYear:D,isScrolling:E,isNavigating:S,virtualData:z,scrollElementRef:A,handleScroll:W,scrollToDate:U,handlePreviousMonth:B,handleNextMonth:K,handleToday:q,setScrollTop:f,setContainerHeight:y,setCurrentMonth:x,setCurrentYear:w,setIsScrolling:C,cache:P.current,scrollElementRefCallback:Y,weeksData:T}})({currentDate:y,weekHeight:W,onCurrentMonthChange:(t,n)=>{const r=v.startsWith("zh")||v.startsWith("ja"),a=f(v,r?"short":"long").indexOf(t);a>=0&&e.setVisibleMonth(new Date(n,a,1))},initialWeeksToLoad:156,locale:v,startOfWeek:x,isEnabled:B,snapToMonth:t.snapToMonth}),Le=r.useRef(0),[$e,je]=r.useState(0),Ye=r.useMemo(()=>$e-6*W,[$e,W]),{visibleWeeks:Fe,startIndex:Ve}=r.useMemo(()=>{var e,t;const{visibleItems:n,displayStartIndex:r}=Se,a=n.findIndex(e=>e.index===r);if(-1===a)return X.current.length>0?{visibleWeeks:X.current,startIndex:Le.current}:{visibleWeeks:[],startIndex:r};const o=Math.max(0,a-2),l=n.slice(o,a+8),s=null!==(t=null===(e=n[o])||void 0===e?void 0:e.index)&&void 0!==t?t:r;return l.length>=6&&(X.current=l,Le.current=s),{visibleWeeks:l,startIndex:s}},[Se]),ze=r.useMemo(()=>Ve*W,[Ve,W]),_e=r.useRef(!0),We=r.useRef(!1),Ue=((e,t)=>{const[n,a]=r.useState(e);return r.useEffect(()=>{const n=setTimeout(()=>{a(e)},t);return()=>{clearTimeout(n)}},[e,t]),n})(Se.displayStartIndex,250);r.useEffect(()=>{Ie&&(We.current=!0)},[Ie]),r.useEffect(()=>{if(_e.current)return void(_e.current=!1);const t=Me[Ue];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,We.current?"navigation":"scroll"),We.current=!1},[e,Me,Ue]);const Be=r.useMemo(()=>{const e=Se.totalHeight,t=Ve*W+Fe.length*W+Ye;return Math.max(0,e-t)},[Se.totalHeight,Ve,W,Ye,Fe.length]);r.useEffect(()=>{const e=Ne.current;if(!e)return;const t=new ResizeObserver(t=>{for(const n of t){const t=n.contentRect.height;if(je(t),t>0){const n=Math.max(80,Math.ceil(t/6));if(n!==q.current){const t=e.scrollTop;if(t>0){const r=Math.round(t/q.current)*n;e.scrollTop=r,Pe(r)}U(n),q.current=n}}}});return t.observe(e),()=>{t.disconnect()}},[Ne,Pe]),r.useEffect(()=>{const e=window.innerHeight-150,t=Math.max(80,Math.ceil(e/6));U(t),q.current=t,K(!0)},[]),r.useEffect(()=>{if(E||!w)return;const e=Ne.current;if(!e)return;const t=e=>e.preventDefault();return e.addEventListener("wheel",t,{passive:!1}),e.addEventListener("touchmove",t,{passive:!1}),()=>{e.removeEventListener("wheel",t),e.removeEventListener("touchmove",t)}},[E,w,Ne]);const Ze=r.useCallback(t=>{e.updateEvent(t.id,t)},[e]),Ge=r.useCallback(t=>{e.deleteEvent(t)},[e]),Ke=t=>{e.changeView(t)},qe=r.useCallback(()=>Q(null),[]),Xe=r.useCallback(t=>{const n=e.getReadOnlyConfig().viewable;if(("desktop"!==F||V)&&t&&n){const e=j.find(e=>e.id===t);if(e)return ae(e),void ne(!0)}he(t)},[F,V,j,he,e]),Je=r.useCallback(e=>{("desktop"!==F||V)&&he(e)},[F,V,he]);return ie("div",{className:lt,children:[ie(wr,{calendar:e,viewType:exports.ViewType.MONTH,currentDate:y,customTitle:(()=>{const e=v.startsWith("zh")||v.startsWith("ja");if(E){const t=v.startsWith("zh")||v.startsWith("ja"),n=f(v,t?"short":"long")[C.getMonth()],r=C.getFullYear();return e?`${r}年${n}`:`${n} ${r}`}return e?`${Te}年${Ce}`:`${Ce} ${Te}`})(),onPrevious:()=>{e.goToPrevious(),E||He()},onNext:()=>{e.goToNext(),E||Ae()},onToday:()=>{e.goToToday(),E||Oe()}}),ie("div",{className:"df-week-header-row sticky top-0 z-10 border-b",onContextMenu:e=>e.preventDefault(),children:ie("div",{className:"grid grid-cols-7 px-2",children:Ee.map((e,t)=>ie("div",{className:"text-right text-gray-500 dark:text-gray-400 text-sm py-2 pr-2 select-none",children:e},`${e}-${t}`))})}),ie("div",E?{ref:Ne,className:ct,style:{overflow:"hidden",visibility:B?"visible":"hidden"},children:ie("div",{style:P,children:O.map((r,l)=>{var s;const i=null!==(s=Y.get(r.startDate.getTime()))&&void 0!==s?s:[],d={index:l,weekData:r,top:l*W,height:W},c=5===l?Object.assign(Object.assign({},d),{height:d.height+Ye}):d;return ie(Ca,{item:c,weekHeight:W,showWeekNumbers:t.showWeekNumbers,showMonthIndicator:!1,currentMonth:"",currentYear:0,screenSize:F,isScrolling:!1,calendarRef:o,events:i,onEventUpdate:Ze,onEventDelete:Ge,onMoveStart:fe,onCreateStart:ve,onResizeStart:ye,isDragging:xe,dragState:be,newlyCreatedEventId:J,onDetailPanelOpen:qe,onMoreEventsClick:e.onMoreEventsClick,onChangeView:Ke,onSelectDate:e.selectDate,selectedEventId:ce,onEventSelect:Xe,onEventLongPress:Je,detailPanelEventId:ue,onDetailPanelToggle:ge,customDetailPanelContent:n,customEventDetailDialog:a,onCalendarDrop:De,onCalendarDragOver:we,calendarSignature:L,app:e,enableTouch:V},`week-${r.startDate.getTime()}`)})})}:{ref:Ne,className:ct,style:{overflow:"hidden auto",overscrollBehavior:"contain",visibility:B?"visible":"hidden"},onScroll:Re,children:[ie("div",{style:{height:ze}}),Fe.map((r,l)=>{var s;const i=null!==(s=Y.get(r.weekData.startDate.getTime()))&&void 0!==s?s:[],d=5===l?Object.assign(Object.assign({},r),{height:r.height+Ye}):r,c=!(!1===t.showMonthIndicator||!r.weekData.days.some(e=>1===e.day))&&ke;return ie(Ca,{item:d,weekHeight:W,showWeekNumbers:t.showWeekNumbers,showMonthIndicator:t.showMonthIndicator,currentMonth:Ce,currentYear:Te,screenSize:F,isScrolling:c,calendarRef:o,events:i,onEventUpdate:Ze,onEventDelete:Ge,onMoveStart:fe,onCreateStart:ve,onResizeStart:ye,isDragging:xe,dragState:be,newlyCreatedEventId:J,onDetailPanelOpen:qe,onMoreEventsClick:e.onMoreEventsClick,onChangeView:Ke,onSelectDate:e.selectDate,selectedEventId:ce,onEventSelect:Xe,onEventLongPress:Je,detailPanelEventId:ue,onDetailPanelToggle:ge,customDetailPanelContent:n,customEventDetailDialog:a,onCalendarDrop:De,onCalendarDragOver:we,calendarSignature:L,app:e,enableTouch:V},`week-${r.weekData.startDate.getTime()}`)}),ie("div",{style:{height:Be}})]}),ie(_,{isOpen:ee,onClose:()=>{ne(!1),ae(null)},onSave:t=>{j.some(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),ne(!1),ae(null)},draftEvent:re,app:e})]})},ka={showWeekNumbers:!1,showMonthIndicator:!0,startOfWeek:1},Sa=(e={})=>{const n=Object.assign(Object.assign({},ka),e),r=e=>t.h(ga,{viewType:exports.ViewType.MONTH,originalComponent:Ta,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 Ma=n.memo(({date:e,isToday:t,locale:n,onSelectDate:r,onCreateStart:a,onMoreEventsClick:o,moreCount:l=0,onContextMenu:s})=>{const{t:i}=ot(),d=e.getDate(),c=1===d,u=e.toLocaleDateString(n,{month:"short"}).toUpperCase();return ie("div",{className:`relative flex flex-col border-r border-b border-gray-100 dark:border-gray-800 ${c?"border-l-2 border-l-[var(--df-color-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==s||s(t,e)},"data-date":`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,children:[ie("div",{className:"flex h-6 shrink-0 items-center px-1 py-1",children:[c&&ie("span",{className:"rounded-sm bg-primary px-1 py-0.5 text-[9px] leading-none font-bold text-primary-foreground",children:u}),ie("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&&ie("div",{className:"absolute bottom-0.5 left-1 z-20",children:ie("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," ",i("more")]})})]})});Ma.displayName="YearDayCell";const Na=n.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:x,onContextMenu:w})=>{const E=new Date;E.setHours(0,0,0,0);const C=r.useCallback((e,t)=>{e.preventDefault(),e.stopPropagation(),w({x:e.clientX,y:e.clientY,date:t})},[w]),T=r.useCallback(e=>{a.selectDate(e)},[a]),k=r.useMemo(()=>function(e,t,n,r){if(0===t.length)return[];const a=t[0],o=t.at(-1);if(!a||!o)return[];const l=new Date(a.getFullYear(),a.getMonth(),a.getDate()).getTime(),s=new Date(o.getFullYear(),o.getMonth(),o.getDate(),23,59,59,999).getTime(),i=e.map(e=>{const t=D(e.start),n=e.end?D(e.end):t;return{event:e,startMs:new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),endMs:new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime()}}).filter(e=>e.startMs<=s&&e.endMs>=l);if(0===i.length)return[];const d=tt(i.map(e=>e.event),r);i.sort((e,t)=>{const n=!!e.event.allDay;return n!==!!t.event.allDay?n?-1:1:d(e.event,t.event)});const c=[],u=[];return i.forEach(({event:e,startMs:t,endMs:r})=>{let a=Math.round((t-l)/864e5),o=Math.round((r-l)/864e5);a=Math.max(0,Math.min(a,n-1)),o=Math.max(0,Math.min(o,n-1));const i=t>=l,d=r<=s;let h=0;for(;;){u[h]||(u[h]=[]);let e=!1;for(let t=a;t<=o;t++)if(u[h][t]){e=!0;break}if(!e){for(let e=a;e<=o;e++)u[h][e]=!0;break}h++}c.push({id:`${e.id}::year-${l}`,event:e,startCellIndex:a,endCellIndex:o,isFirstSegment:i,isLastSegment:d,visualRowIndex:h})}),c}(t,e,n,a.state.allDaySortComparator),[t,e,n,a.state.allDaySortComparator]),{visibleSegments:S,moreCounts:M}=r.useMemo(()=>{const t=Array.from({length:e.length}).fill(0);k.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 k.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}},[k,e.length]);return ie("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 ie(Ma,{date:e,isToday:n,locale:l,onSelectDate:T,onCreateStart:u,onMoreEventsClick:m,moreCount:M[t],onContextMenu:C},e.getTime())}),ie("div",{className:"pointer-events-none absolute inset-0",style:{top:26,bottom:0,left:0,right:0},onContextMenu:e=>e.preventDefault(),children:ie("div",{className:"relative h-full w-full",children:S.map(e=>ie("div",{className:"pointer-events-auto",children:ie(xr,{event:e.event,isAllDay:!!e.event.allDay,viewType:exports.ViewType.YEAR,yearSegment:e,columnsPerRow:n,isBeingDragged:s&&i.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))})})]})});Na.displayName="YearRowComponent";const Ia=({app:t,calendarRef:n,customDetailPanelContent:a,customEventDetailDialog:o,config:l,selectedEventId:s,onEventSelect:i,detailPanelEventId:d,onDetailPanelToggle:c})=>{var u;const{t:h,locale:g}=ot(),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,w]=r.useState(!1),[E,C]=r.useState(()=>"undefined"!=typeof window&&window.innerWidth<768),[T,k]=r.useState(null),[S,M]=r.useState(null),N=void 0===s?T:s,I=void 0===d?S:d,[R,H]=r.useState(null),A=r.useCallback(e=>{i?i(e):k(e)},[i]),O=r.useCallback(e=>{c?c(e):M(e)},[c]),P=r.useCallback(()=>{H(null)},[]),[L,$]=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]"),s=t.closest(".df-context-menu");n||r||a||o||l||s||(A(null),O(null),$(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const j=r.useRef(null);r.useEffect(()=>{const e=v.current;if(!e)return;const t=new ResizeObserver(e=>{j.current&&clearTimeout(j.current),j.current=setTimeout(()=>{const t=e[0].contentRect.width,n=Math.floor(t/80);b(Math.max(1,n)),C(t<768),w(!0)},60)});return t.observe(e),()=>{t.disconnect(),j.current&&clearTimeout(j.current)}},[]);const Y=r.useRef(t.state.highlightedEventId);r.useEffect(()=>{t.state.highlightedEventId?A(t.state.highlightedEventId):Y.current&&A(null),Y.current=t.state.highlightedEventId},[t.state.highlightedEventId]);const{handleMoveStart:F,handleResizeStart:V,handleCreateStart:z,dragState:_,isDragging:W}=ua(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)},isMobile:E}),U=null!==(u=null==l?void 0:l.showTimedEventsInYearView)&&void 0!==u&&u,B=r.useCallback((n,r)=>{if(U)null==z||z(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)}},[U,z,t,h]),Z=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]),G=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]),K=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(!U&&!n.allDay)return!1;const r=D(n.start),a=n.end?D(n.end):r;return r<=t&&a>=e})},[f,p,U]),q=r.useMemo(()=>{const e=K.map(e=>{const t=D(e.start),n=e.end?D(e.end):t;return{event:e,startMs:new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),endMs:new Date(n.getFullYear(),n.getMonth(),n.getDate(),23,59,59,999).getTime()}});return G.map(t=>{if(0===t.length)return[];const n=t[0],r=t.at(-1);if(!n||!r)return[];const a=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime(),o=new Date(r.getFullYear(),r.getMonth(),r.getDate(),23,59,59,999).getTime();return e.filter(e=>e.startMs<=o&&e.endMs>=a).map(e=>e.event)})},[G,K]);return ie("div",{className:lt,onContextMenu:e=>e.preventDefault(),children:[ie(wr,{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()}}),ie("div",{ref:v,className:`${ct} ${ut}`,style:{overflow:"hidden auto"},children:ie("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:G.map((e,r)=>ie(Na,{rowDays:e,events:q[r],columnsPerRow:y,app:t,calendarRef:n,locale:g,isDragging:W,dragState:_,onMoveStart:F,onResizeStart:V,onCreateStart:B,selectedEventId:N,onEventSelect:A,onMoreEventsClick:t.onMoreEventsClick,newlyCreatedEventId:R,onDetailPanelOpen:P,detailPanelEventId:I,onDetailPanelToggle:O,customDetailPanelContent:a,customEventDetailDialog:o,onContextMenu:$},r))})}),L&&ie(rr,{x:L.x,y:L.y,date:L.date,viewType:exports.ViewType.YEAR,onClose:()=>$(null),app:t,onCreateEvent:()=>{if(L&&L.date){const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:L.x,clientY:L.y};B(e,L.date)}}})]})};function Ra(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,s=a.getTime(),i=new Date(n,t,o,23,59,59,999).getTime(),d=e.filter(e=>!!e.start).map(e=>{const t=D(e.start),n=e.end?D(e.end):t,r=new Date(t.getFullYear(),t.getMonth(),t.getDate()),a=new Date(n.getFullYear(),n.getMonth(),n.getDate());return{event:e,startMs:r.getTime(),endMs:a.getTime(),eventStartDay:r,eventEndDay:a}}).filter(e=>e.startMs<=i&&e.endMs>=s);if(0===d.length)return{segments:[],maxVisualRow:-1};const c=tt(d.map(e=>e.event));d.sort((e,t)=>{const n=!!e.event.allDay;return n!==!!t.event.allDay?n?-1:1:c(e.event,t.event)});const u=[],h=[];d.forEach(({event:e,startMs:r,endMs:a,eventStartDay:o,eventEndDay:d})=>{const c=Math.max(r,s),g=Math.min(a,i),m=new Date(c).getDate(),p=new Date(g).getDate(),f=l+(m-1),v=l+(p-1),y=o.getMonth()===t&&o.getFullYear()===n,b=d.getMonth()===t&&d.getFullYear()===n;let x=0;for(;;){h[x]||(h[x]=[]);let e=!1;for(let t=f;t<=v;t++)if(h[x][t]){e=!0;break}if(!e){for(let e=f;e<=v;e++)h[x][e]=!0;break}x++}u.push({id:`${e.id}::month-${t}`,event:e,startCellIndex:f,endCellIndex:v,isFirstSegment:y,isLastSegment:b,visualRowIndex:x,monthIndex:t})});const g=u.length>0?Math.max(...u.map(e=>e.visualRowIndex)):-1;return{segments:u,maxVisualRow:g}}const Ha=({app:t,calendarRef:n,customDetailPanelContent:a,customEventDetailDialog:o,config:l,selectedEventId:s,onEventSelect:i,detailPanelEventId:d,onDetailPanelToggle:c})=>{var u,h;const{t:g,locale:m,getWeekDaysLabels:p}=ot(),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,w=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===s?N:s,O=void 0===d?R:d,P=e=>{i?i(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:z,handleResizeStart:_,handleCreateStart:W,dragState:U,isDragging:B}=ua(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,g]),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=D(n.start),a=n.end?D(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"}),s=l.charAt(0).toUpperCase()+l.slice(1).toLowerCase(),{segments:i,maxVisualRow:d}=Ra(q,t,v,x),c=d+1,u=Math.max(60,20+18*c);e.push({monthIndex:t,monthName:s,days:o,eventSegments:i,minHeight:u})}return e},[v,m,V,q,x]),J=r.useCallback(e=>{const t=e.currentTarget;w.current&&(w.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 ie("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:[ie("div",{className:"col-span-2",children:ie(wr,{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()}})}),ie("div",{className:"z-30 border-r border-b border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900"}),ie("div",{ref:w,className:"overflow-hidden border-b border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900",children:ie("div",{className:"flex",style:{minWidth:`calc(1352px + ${T}px)`},children:[ie("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 ie("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&&ie("div",{className:"shrink-0 bg-gray-50 dark:bg-gray-900",style:{width:`${T}px`}})]})}),ie("div",{ref:E,className:"overflow-hidden border-r border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-900",children:ie("div",{className:"flex min-h-full flex-col",children:[X.map(e=>ie("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&&ie("div",{className:"shrink-0 bg-white dark:bg-gray-900",style:{height:`${S}px`}})]})}),ie("div",{ref:C,className:`overflow-auto ${ut}`,onScroll:J,children:ie("div",{className:"flex min-h-full flex-col",style:{minWidth:"1352px"},children:X.map(e=>ie("div",{className:"relative shrink-0 grow",style:{minHeight:`${e.minHeight}px`},children:[ie("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 ie("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 ie("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:ie("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&&ie("div",{className:"pointer-events-none absolute inset-0 z-20",style:{top:20},children:ie("div",{className:"relative h-full w-full",children:e.eventSegments.map(e=>ie("div",{className:"pointer-events-auto",children:ie(xr,{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:z,onResizeStart:_,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&&ie(rr,{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)}})]})},Aa=({date:e,events:a,anchorEl:o,position:l,onClose:s,locale:i,app:d,customContent:c})=>{const{t:u}=ot(),h=r.useRef(null);r.useEffect(()=>{const e=e=>{const t=e.target;!h.current||h.current.contains(t)||o.contains(t)||s()},t=e=>{"Escape"===e.key&&s()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[o,s]);const g=d.getCalendars(),m=new Map(g.map(e=>[e.id,e])),p=e.toLocaleDateString(i,{weekday:"long",month:"long",day:"numeric"}),f=ie(t.Fragment,{children:[ie("div",{className:"border-b border-gray-100 px-4 py-3 dark:border-gray-700",children:ie("div",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:p})}),ie("div",{className:"max-h-60 overflow-y-auto py-1",children:0===a.length?ie("div",{className:"px-4 py-3 text-center text-xs text-gray-400",children:"No events"}):a.map(e=>{var t,n;const r=e.calendarId?m.get(e.calendarId):void 0,a=null!==(n=null===(t=null==r?void 0:r.colors)||void 0===t?void 0:t.lineColor)&&void 0!==n?n:"#3b82f6";let o="";if(!e.allDay&&e.start){if(o=D(e.start).toLocaleTimeString(i,{hour:"2-digit",minute:"2-digit",hour12:!1}),e.end){o+=` – ${D(e.end).toLocaleTimeString(i,{hour:"2-digit",minute:"2-digit",hour12:!1})}`}}return ie("div",{className:"flex items-start gap-2.5 rounded px-3 py-1.5 hover:bg-gray-50 dark:hover:bg-gray-800",children:[ie("div",{className:"mt-1.5 h-2 w-2 shrink-0 rounded-full",style:{backgroundColor:a}}),ie("div",{className:"min-w-0 flex-1",children:[ie("div",{className:"truncate text-xs font-medium text-gray-900 dark:text-gray-100",children:e.title}),e.allDay&&ie("div",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:u("allDay")}),o&&ie("div",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:o})]})]},e.id)})})]});return n.createPortal(ie("div",{ref:h,"data-grid-day-popup":!0,className:"animate-in fade-in zoom-in-95 fixed z-50 w-64 overflow-hidden rounded-xl border border-gray-200 bg-white shadow-xl duration-100 dark:border-gray-700 dark:bg-gray-900",style:{top:l.top,left:l.left},children:c?c(e,a):f}),document.body)};function Oa(e,t,n){const r=new Map,a=new Date(t,0,1);a.setHours(0,0,0,0);const o=new Date(t,11,31,23,59,59,999);for(const l of e){if(!l.start)continue;if(!n&&!l.allDay)continue;const e=D(l.start),s=l.end?D(l.end):new Date(e);if(e.setHours(0,0,0,0),s.setHours(0,0,0,0),e>o||s<a)continue;const i=e<a?new Date(a):new Date(e),d=s>o?new Date(t,11,31):new Date(s);i.setHours(0,0,0,0),d.setHours(0,0,0,0);const c=864e5,u=i.getTime(),h=Math.round((d.getTime()-u)/c);for(let e=0;e<=h;e++){const t=new Date(u+e*c),n=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`,a=r.get(n);a?a.push(l):r.set(n,[l])}}return r}function Pa(e){const t=e.getBoundingClientRect(),n=window.innerWidth,r=window.innerHeight;let a=t.right+8;a+256>n-8&&(a=t.left-256-8),a=Math.max(8,Math.min(a,n-256-8));let o=t.top;return o+220>r-8&&(o=r-220-8),o=Math.max(8,o),{top:o,left:a}}const La=({app:e,config:t})=>{var n,a,o;const{locale:l,getWeekDaysLabels:s}=ot(),i=e.getCurrentDate(),d=i.getFullYear(),c=e.getEvents(),u=null!==(n=null==t?void 0:t.startOfWeek)&&void 0!==n?n:1,h=null!==(a=null==t?void 0:t.showTimedEventsInYearView)&&void 0!==a&&a,g=null!==(o=null==t?void 0:t.gridHeatmapLevels)&&void 0!==o?o:5,m=r.useMemo(()=>{const e=new Date;return e.setHours(0,0,0,0),e},[]),[p,f]=r.useState(null);r.useEffect(()=>{if(!p)return;const e=e=>{const t=e.target;t.closest("[data-grid-day-popup]")||t.closest("[data-grid-day-cell]")||f(null)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[p]);const v=r.useMemo(()=>Oa(c,d,h),[c,d,h]),y=r.useMemo(()=>Oa(c,d,!0),[c,d]),b=r.useMemo(()=>s(l,"narrow",u).map(e=>l.startsWith("zh")?e.at(-1):e.charAt(0).toUpperCase()),[l,s,u]),x=r.useMemo(()=>{const e=[];for(let t=0;t<12;t++){const n=new Date(d,t,1),r=new Date(d,t+1,0).getDate(),a=[];for(let e=(n.getDay()-u+7)%7-1;e>=0;e--)a.push({date:new Date(d,t,-e),isCurrentMonth:!1});for(let e=1;e<=r;e++)a.push({date:new Date(d,t,e),isCurrentMonth:!0});let o=1;for(;a.length<42;)a.push({date:new Date(d,t+1,o++),isCurrentMonth:!1});const s=n.toLocaleDateString(l,{month:"long"}),i=s.charAt(0).toUpperCase()+s.slice(1);e.push({monthIndex:t,monthName:i,cells:a})}return e},[d,l,u]),D=r.useCallback((n,r,a)=>{var o,l;const s=null!==(o=null==t?void 0:t.gridDateClick)&&void 0!==o?o:"popup";if("function"==typeof s){const e=`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,"0")}-${String(r.getDate()).padStart(2,"0")}`;return void s(r,null!==(l=y.get(e))&&void 0!==l?l:[])}if("popup"===s){const e=n.currentTarget;p&&p.date.getTime()===r.getTime()&&p.monthIndex===a?f(null):f({date:r,monthIndex:a,anchorEl:e,position:Pa(e)})}else"day-view"===s&&(e.setCurrentDate(r),e.changeView(exports.ViewType.DAY))},[t,e,p,y]),w=r.useCallback(n=>{var r,a;const o=null!==(r=null==t?void 0:t.gridDateDoubleClick)&&void 0!==r?r:"day-view";if("function"==typeof o){const e=`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}-${String(n.getDate()).padStart(2,"0")}`;return void o(n,null!==(a=y.get(e))&&void 0!==a?a:[])}"day-view"===o&&(f(null),e.setCurrentDate(n),e.changeView(exports.ViewType.DAY))},[t,e,y]),E=r.useMemo(()=>{var e;if(!p)return[];const t=`${p.date.getFullYear()}-${String(p.date.getMonth()+1).padStart(2,"0")}-${String(p.date.getDate()).padStart(2,"0")}`;return[...null!==(e=y.get(t))&&void 0!==e?e:[]].toSorted((e,t)=>{const n=!!e.allDay;return n!==!!t.allDay?n?-1:1:0})},[p,y]);return ie("div",{className:lt,children:[ie(wr,{calendar:e,viewType:exports.ViewType.YEAR,currentDate:i,customTitle:l.startsWith("zh")||l.startsWith("ja")?`${d}年`:`${d}`,onPrevious:()=>{const t=new Date(i);t.setFullYear(t.getFullYear()-1),e.setCurrentDate(t)},onNext:()=>{const t=new Date(i);t.setFullYear(t.getFullYear()+1),e.setCurrentDate(t)},onToday:()=>e.goToToday()}),ie("div",{className:"grid min-h-0 flex-1 gap-3 p-3",style:{gridTemplateColumns:"repeat(4, 1fr)",gridTemplateRows:"repeat(3, 1fr)"},children:x.map(e=>ie("div",{className:"df-year-grid-month flex h-full min-h-0 flex-col rounded-lg border border-gray-100 bg-white p-2 dark:border-gray-800 dark:bg-gray-900",children:[ie("div",{className:"mb-1 shrink-0 text-xs font-semibold text-gray-900 dark:text-gray-100",children:e.monthName}),ie("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:ie("div",{className:"grid h-full w-full gap-px",style:{gridTemplateColumns:"repeat(7, 1fr)",gridTemplateRows:"repeat(7, 1fr)"},children:[b.map((e,t)=>ie("div",{className:"flex items-center justify-center text-[9px] font-medium text-gray-400 dark:text-gray-500",children:e},t)),e.cells.map(({date:t,isCurrentMonth:n},r)=>{var a,o;const l=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`,s=n&&null!==(o=null===(a=v.get(l))||void 0===a?void 0:a.length)&&void 0!==o?o:0;var i,d;return ie("div",{"data-grid-day-cell":!0,className:"cursor-pointer rounded-sm transition-colors hover:opacity-80",style:n?(d=g,0===(i=s)?{}:{backgroundColor:`var(--heat-${Math.min(i,d)})`}):{},onClick:n=>D(n,t,e.monthIndex),onDblClick:()=>w(t),children:ie("div",{className:"flex h-full w-full items-center justify-center",children:ie("span",{className:"flex h-4 w-4 items-center justify-center rounded-full text-[9px] font-medium "+(t.getTime()===m.getTime()?"bg-primary font-bold text-primary-foreground":n?s>0?s>=4?"text-white":"text-gray-800 dark:text-gray-100":"text-gray-500 dark:text-gray-400":"text-gray-300 dark:text-gray-600"),children:t.getDate()})})},`${e.monthIndex}-${r}`)})]})})]},e.monthIndex))}),p&&ie(Aa,{date:p.date,events:E,anchorEl:p.anchorEl,position:p.position,onClose:()=>f(null),locale:l,app:e,customContent:null==t?void 0:t.gridPopupContent})]})},$a=e=>{var t;const n=(null===(t=e.config)||void 0===t?void 0:t.mode)||"year-canvas";return"fixed-week"===n?ie(Ha,Object.assign({},e)):"grid"===n?ie(La,{app:e.app,config:e.config}):ie(Ia,Object.assign({},e))},ja={startOfWeek:1};const Ya={enableAutoRecalculate:!0,enableValidation:!0,defaultEvents:[],maxEventsPerDay:50};function Fa(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.AudioLines=({className:e,width:t=24,height:n=24})=>ie("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:[ie("path",{d:"M4 11a9 9 0 0 1 9 9"}),ie("path",{d:"M4 4a16 16 0 0 1 16 16"}),ie("circle",{cx:"5",cy:"19",r:"1"})]}),exports.BlossomColorPicker=xn,exports.CalendarApp=le,exports.CalendarEvent=xr,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 Kn(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(vn.Provider,{value:this.customRenderingStore},t.h(Gn,Object.assign({app:this.app},this.extraProps))),this.container)}},exports.Check=Zt,exports.ChevronDown=Wt,exports.ChevronRight=Vt,exports.ChevronsUpDown=Gt,exports.ContentSlot=bn,exports.ContextMenu=qn,exports.ContextMenuColorPicker=({selectedColor:e,onSelect:t,onCustomColor:n})=>{const{t:r}=ot();return ie("div",{children:[ie("div",{className:"grid grid-cols-7 gap-2 p-1 px-3",children:nr.map(n=>ie("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&&ie("div",{className:"mt-1 flex cursor-pointer items-center rounded-sm px-3 py-0.5 text-[12px] text-[var(--df-color-foreground)] transition-colors hover:bg-[var(--df-color-primary)] hover:text-[var(--df-color-primary-foreground)]",onClick:e=>{e.stopPropagation(),n()},children:r("customColor")})]})},exports.ContextMenuItem=Xn,exports.ContextMenuLabel=({children:e})=>ie("div",{className:"px-3 py-0.5 text-[12px] font-semibold text-slate-950 dark:text-slate-50",children:e}),exports.ContextMenuSeparator=Jn,exports.CreateCalendarDialog=En,exports.CustomRenderingStore=Kn,exports.DefaultColorPicker=Dn,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=s,exports.LocaleContext=at,exports.LocaleProvider=cn,exports.MiniCalendar=Ln,exports.PanelRightClose=({className:e,width:t=24,height:n=24})=>ie("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:[ie("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),ie("path",{d:"M15 3v18"}),ie("path",{d:"m8 9 3 3-3 3"})]}),exports.PanelRightOpen=({className:e,width:t=24,height:n=24})=>ie("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:[ie("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),ie("path",{d:"M15 3v18"}),ie("path",{d:"m10 15-3-3 3-3"})]}),exports.Plus=Ut,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=we,exports.calculateDayIndex=J,exports.calendarPickerDropdown=Nt,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=on,exports.clipboardStore=je,exports.compareAllDayDisplayPriority=et,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.createAllDayDisplayComparator=tt,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=pa,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 s=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:s,end:s})},exports.createEvents=function(e){return e.map(e=>He(e))},exports.createEventsPlugin=function(e={}){const t=Object.assign(Object.assign({},Ya),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=Fa(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=Fa(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=D(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=D(n.start),a=D(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=Sa,exports.createStandardViews=function(e){return[pa(null==e?void 0:e.day),wa(null==e?void 0:e.week),Sa(null==e?void 0:e.month)]},exports.createTemporalWithHour=w,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=wa,exports.createYearView=(e={})=>{const n=Object.assign(Object.assign({},ja),e),r=e=>t.h(ga,{viewType:exports.ViewType.YEAR,originalComponent:$a,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=_e,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=ze,exports.formatEventTimeRange=z,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=_,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=D(t.start);a.setHours(0,0,0,0);const o=D(t.end);return o.setHours(0,0,0,0),r>=a&&r<=o}),exports.getAllDayRangeMetrics=Qe,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=D(e.start);return r>=t&&r<=n}).map(e=>{const n=J(D(e.start),t);return Object.assign(Object.assign({},e),{day:n})})},exports.getIntlLabel=an,exports.getLineColor=Y,exports.getMonthLabels=sn,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),s=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:s,timeZone:e.Temporal.Now.timeZoneId()}),allDay:!1,calendarId:t.calendarId,day:t.day}})},exports.getTimezoneDisplayLabel=W,exports.getWeekDaysLabels=ln,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=i,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){da=e},exports.registerLocale=function(e){const t=e.code.split("-")[0].toLowerCase();s[t]=e},exports.registerSidebarImplementation=function(e){Wn=e},exports.resolveAppliedTheme=Ne,exports.restoreTimedDragFromAllDayTransition=({wasOriginallyAllDay:e,mouseHour:t,hourOffset:n,duration:r,originalStartHour:a,originalEndHour:o,firstHour:l,lastHour:s,minDuration:i,roundToTimeStep:d})=>{const c=e?1:Math.max(i,r||o-a||1);let u=d(e?t:t+(null!=n?n:0));return u=Math.max(l,Math.min(s-c,u)),{startHour:u,endHour:u+c,duration:c,hourOffset:e?0:null!=n?n:0}},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",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.sortAllDayByTitle=(e,t)=>e.title.localeCompare(t.title),exports.t=dn,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=ua,exports.useLocale=ot,exports.useSidebarBridge=Bn,exports.weekDays=m,exports.weekDaysFullName=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],exports.zonedDateTimeToDate=x;