@dayflow/core 3.4.0 → 3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/dist/index.d.ts +10 -3
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("tslib"),t=require("temporal-polyfill"),n=require("preact"),r=require("preact/compat"),a=require("preact/hooks"),o=require("@dayflow/blossom-color-picker");const i={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."}},l={en:i};function s(e){const t=e.split("-")[0].toLowerCase();return t in l?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;function m(e){var n;if(!e||"object"!=typeof e)return!1;if(e instanceof Date)return!1;if(e instanceof t.Temporal.PlainDate)return!0;const r=e;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 f(e,n=t.Temporal.Now.timeZoneId()){return t.Temporal.Instant.fromEpochMilliseconds(e.getTime()).toZonedDateTimeISO(n)}function p(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 v(e,n){if(e instanceof Date)return e;if(m(e))return function(e,n=t.Temporal.Now.timeZoneId()){if("function"==typeof e.toZonedDateTime)try{return p(e.toZonedDateTime({timeZone:n,plainTime:t.Temporal.PlainTime.from({hour:0,minute:0})}))}catch(e){}return new Date(e.year,e.month-1,e.day)}(e,n);if(e&&"object"==typeof e&&"hour"in e&&!("timeZone"in e)){const t=e;return new Date(t.year,t.month-1,t.day,t.hour,t.minute,t.second||0,t.millisecond||0)}if(e&&"object"==typeof e&&"year"in e){return p(e)}return new Date(e)}function y(e,n){const r=Math.floor(n),a=Math.round(60*(n-r));if(m(e))return t.Temporal.PlainDateTime.from({year:e.year,month:e.month,day:e.day,hour:r,minute:a});if("function"==typeof e.with)return e.with({hour:r,minute:a,second:0,millisecond:0});const o=e;return t.Temporal.PlainDateTime.from({year:o.year,month:o.month,day:o.day,hour:r,minute:a})}function b(e,n){if(e instanceof Date&&n instanceof Date)return e.toDateString()===n.toDateString();const r=e=>{if(e instanceof Date)return n=e,t.Temporal.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()});var n;if(m(e))return e;if("function"==typeof e.toPlainDate)return e.toPlainDate();const r=e;return t.Temporal.PlainDate.from({year:r.year,month:r.month,day:r.day})},a=r(e),o=r(n);return 0===t.Temporal.PlainDate.compare(a,o)}function x(e,n=t.Temporal.Now.timeZoneId()){if("function"==typeof e.toZonedDateTime){return(m(e)?e:e.toPlainDate()).toZonedDateTime({timeZone:n,plainTime:t.Temporal.PlainTime.from({hour:0,minute:0})})}const r=e;return(m(e)?e:t.Temporal.PlainDate.from({year:r.year,month:r.month,day:r.day})).toZonedDateTime({timeZone:n,plainTime:t.Temporal.PlainTime.from({hour:0,minute:0})})}function w(e,n=t.Temporal.Now.timeZoneId()){if("function"==typeof e.toZonedDateTime){return(m(e)?e:e.toPlainDate()).toZonedDateTime({timeZone:n,plainTime:t.Temporal.PlainTime.from({hour:23,minute:59,second:59,millisecond:999})})}const r=e;return(m(e)?e:t.Temporal.PlainDate.from({year:r.year,month:r.month,day:r.day})).toZonedDateTime({timeZone:n,plainTime:t.Temporal.PlainTime.from({hour:23,minute:59,second:59,millisecond:999})})}function D(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)}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.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.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.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.KARACHI="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.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 E=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(m(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)},C=(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 y(e,t)},T=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)},k=(e,n)=>{if(e instanceof Date&&n instanceof Date)return e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate();return b(e instanceof Date?t.Temporal.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()}):m(e)?e:e.toPlainDate(),n instanceof Date?t.Temporal.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()}):m(n)?n:n.toPlainDate())},S=[{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 M{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)}):S.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=M.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 N=new M;function I(){return N}function R(e){const t=S.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 O=(e,t)=>(t||I()).resolveColors(e).eventColor,H=(e,t)=>(t||I()).resolveColors(e).textColor,A=(e,t)=>(t||I()).resolveColors(e).eventSelectedColor,P=(e,t)=>(t||I()).resolveColors(e).lineColor;const L=new class{constructor(){var e,t;this.isDevelopment="production"!==(null===(t=null===(e=globalThis.process)||void 0===e?void 0:e.env)||void 0===t?void 0:t.NODE_ENV)}formatMessage(e,t,...n){if(!this.isDevelopment)return;const r=(new Date).toISOString(),a=`[DayFlow ${e.toUpperCase()}] ${r}:`;switch(e){case"log":console.log(a,t,...n);break;case"warn":console.warn(a,t,...n);break;case"error":console.error(a,t,...n);break;case"debug":console.debug(a,t,...n)}}log(e,...t){this.formatMessage("log",e,...t)}warn(e,...t){this.formatMessage("warn",e,...t)}error(e,...t){this.formatMessage("error",e,...t)}debug(e,...t){this.formatMessage("debug",e,...t)}},$=new Map;function j(e){try{return new Intl.DateTimeFormat("en",{timeZone:e}).resolvedOptions().timeZone}catch(e){return}}function Y(e){if(!e||"string"!=typeof e)return;const t=e.trim();if(!t)return;const n=$.get(t);if(n)return n;const r=j(t);if(r)return $.set(t,r),r;const a=Object.values(exports.TimeZone).find(e=>e.toLowerCase()===t.toLowerCase());if(a){const e=j(a);return e?($.set(t,e),e):($.set(t,a),a)}if("function"==typeof Intl.supportedValuesOf){const e=Intl.supportedValuesOf("timeZone").find(e=>e.toLowerCase()===t.toLowerCase());if(e)return $.set(t,e),e}const o=j(t.split("/").map(e=>e.split("_").map(e=>e?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():e).join("_")).join("/"));if(o)return $.set(t,o),o;const i=j(t.split("/").map((e,t)=>0===t?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():e).join("/"));return i?($.set(t,i),i):t}function F(e){return null!==e&&"object"==typeof e&&!("hour"in e)&&"year"in e&&"month"in e&&"day"in e&&!(e instanceof Date)}function V(e){return null!==e&&"object"==typeof e&&"hour"in e&&!("timeZone"in e)&&!("timeZoneId"in e)&&"year"in e&&!(e instanceof Date)}function Z(e){return null!==e&&"object"==typeof e&&("timeZone"in e||"timeZoneId"in e)&&"year"in e&&!(e instanceof Date)}function _(e){if(e instanceof Date)return e;if(F(e))return new Date(e.year,e.month-1,e.day);if(V(e))return new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second||0,e.millisecond||0);if(Z(e))try{if("function"==typeof e.toInstant){const t=e.toInstant();return new Date(t.epochMilliseconds)}return"number"==typeof e.epochMilliseconds?new Date(e.epochMilliseconds):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 z(e,n){if(e instanceof Date)return e;if(!n)return _(e);const r=Y(n);if(!r)return _(e);try{if(Z(e)){const n=("function"==typeof e.withTimeZone?e:t.Temporal.ZonedDateTime.from(e)).withTimeZone(r);return new Date(n.year,n.month-1,n.day,n.hour,n.minute,n.second||0,n.millisecond||0)}if(V(e)){const n="function"==typeof e.toZonedDateTime?e:t.Temporal.PlainDateTime.from(e),a=n.toZonedDateTime(t.Temporal.Now.timeZoneId()).withTimeZone(r);return new Date(a.year,a.month-1,a.day,a.hour,a.minute,a.second||0,a.millisecond||0)}}catch(e){L.error("Failed to shift visual timezone:",e)}return _(e)}function U(e,n){if(!n)return e;const r=Y(n);if(!r)return e;try{if(Z(e)){return("function"==typeof e.withTimeZone?e:t.Temporal.ZonedDateTime.from(e)).withTimeZone(r)}if(V(e)){return("function"==typeof e.toZonedDateTime?e:t.Temporal.PlainDateTime.from(e)).toZonedDateTime(t.Temporal.Now.timeZoneId()).withTimeZone(r)}}catch(e){L.error("Failed to shift visual temporal:",e)}return e}function W(e){return t.Temporal.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()})}function B(e){return t.Temporal.PlainDateTime.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),millisecond:e.getMilliseconds()})}function G(e,n=t.Temporal.Now.timeZoneId()){return t.Temporal.ZonedDateTime.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),millisecond:e.getMilliseconds(),timeZone:n})}function K(e){return e instanceof Date?W(e):F(e)?e:(V(e),e.toPlainDate())}const q=e=>new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second,Math.floor(e.millisecond)),X=(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")}`},J=e=>{if(!e.end)return 0;const t=E(e.end);if(e.allDay||!e.start)return t;const n=v(e.start),r=v(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},Q=(e,t="24h")=>{const n=E(e.start),r=J(e);return`${X(n,0,t)} - ${X(r,0,t)}`},ee=(e,n,r="24h",a=new Date,o)=>{const i=Y(n);if(!i)return e.map(()=>"");const l=null!=o?o:t.Temporal.Now.timeZoneId(),s=a.getFullYear(),d=a.getMonth()+1,c=a.getDate();return e.map(e=>{try{const n=e.hour%24,a=t.Temporal.ZonedDateTime.from({year:s,month:d,day:c,hour:n,minute:0,second:0,timeZone:l}).withTimeZone(i);return X(a.hour,a.minute,r)}catch(e){return""}})},te=(e,t=new Date)=>{var n,r;const a=Y(e);if(!a)return"";try{return null!==(r=null===(n=new Intl.DateTimeFormat("en",{timeZone:a,timeZoneName:"short"}).formatToParts(t).find(e=>"timeZoneName"===e.type))||void 0===n?void 0:n.value)&&void 0!==r?r:a}catch(e){return a}},ne=e=>{var n;const r=null!==(n=e?Y(e):void 0)&&void 0!==n?n:t.Temporal.Now.timeZoneId();return q(t.Temporal.Now.zonedDateTimeISO(r))},re=e=>{var n;const r=null!==(n=e?Y(e):void 0)&&void 0!==n?n:t.Temporal.Now.timeZoneId(),a=t.Temporal.Now.plainDateISO(r);return new Date(a.year,a.month-1,a.day)},ae=e=>{var n;const r=null!==(n=e?Y(e):void 0)&&void 0!==n?n:t.Temporal.Now.timeZoneId(),a=t.Temporal.Now.zonedDateTimeISO(r).add({hours:1}).with({minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});return{start:q(a),end:q(a.add({hours:1}))}},oe=(e,n,r)=>{var a,o;const i=v(e);if(Z(n)){const e=null!==(a=Y(r))&&void 0!==a?a:t.Temporal.Now.timeZoneId(),o=(e=>{var n;const r=e;return r.timeZoneId||("string"==typeof r.timeZone?r.timeZone:null===(n=r.timeZone)||void 0===n?void 0:n.id)||t.Temporal.Now.timeZoneId()})(n);return G(i,e).toInstant().toZonedDateTimeISO(o)}return V(n)?B(i):Z(e)?e:G(i,null!==(o=Y(r))&&void 0!==o?o:t.Temporal.Now.timeZoneId())},ie=(e,t,n)=>t.allDay?Object.assign(Object.assign({},t),{allDay:!0,start:F(t.start)?t.start:W(v(t.start)),end:F(t.end)?t.end:W(v(t.end))}):Object.assign(Object.assign({},t),{allDay:!1,start:oe(t.start,e.allDay?t.start:e.start,n),end:oe(t.end,e.allDay?t.end:e.end,n)}),le=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],se=["January","February","March","April","May","June","July","August","September","October","November","December"],de=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],ce=(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}},ue=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:se[r],shortMonthName:de[r],isToday:o.getDate()===n&&o.getMonth()===r&&o.getFullYear()===a}},he=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:se[a],monthIndex:a,year:o}},ge=e=>{const t=[],n=new Date(e);for(let e=0;e<7;e++){const e=new Date(n);t.push(ue(e)),n.setDate(n.getDate()+1)}return{days:t,startDate:new Date(e),monthYear:he(t)}};function me(e,t,n=1){const r=[],a=Math.floor(t/2),o=(e.getDay()-n+7)%7,i=new Date(e);i.setDate(e.getDate()-o),i.setHours(0,0,0,0);const l=new Date(i);l.setDate(l.getDate()-7*a);for(let e=0;e<t;e++){const t=new Date(l);t.setDate(t.getDate()+7*e),r.push(ge(t))}return r}const fe=(e,t)=>t.filter(t=>t.day===e&&!t.allDay),pe=(e,t)=>{const n=new Date(e);return n.setDate(e.getDate()+t),n},ve=(e,n)=>n?t.Temporal.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()}):t.Temporal.ZonedDateTime.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),millisecond:e.getMilliseconds(),timeZone:t.Temporal.Now.timeZoneId()}),ye=(e,t)=>{const n=new Date(e);n.setHours(0,0,0,0);const r=new Date(t);r.setHours(0,0,0,0);const a=n.getTime()-r.getTime();return Math.floor(a/864e5)},be=(e,t)=>e.map(e=>{const n=v(e.start),r=ye(n,t);return Object.assign(Object.assign({},e),{day:r})}),xe=(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()),we=(e,t)=>v(e.start).getTime()!==v(t.start).getTime()||v(e.end).getTime()!==v(t.end).getTime()||e.title!==t.title||e.day!==t.day||!!e.allDay!=!!t.allDay;function De(){return Date.now().toString(36)+Math.random().toString(36).slice(2,8)}function Ee(e,t){if(e===t)return!0;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;const a=e,o=t;for(const e of n)if(!r.includes(e)||!Ee(a[e],o[e]))return!1;return!0}class Ce{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=Ce.normalizeChanges(this.pendingChanges);return this.isInTransaction=!1,this.pendingChanges=[],t.length>0?null===(e=this.onEventBatchChange)||void 0===e?void 0:e.call(this,t):void 0}createEvent(e){if(this.events.has(e.id))throw new Error(`Event with ID ${e.id} already exists.`);return 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);return this.events.set(e,r),this.emitChange({type:"update",before:n,after:r})}deleteEvent(e){const t=this.events.get(e);if(t)return 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;if(!this.isInTransaction)return null===(t=this.onEventChange)||void 0===t?void 0:t.call(this,e);this.pendingChanges.push(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 Te{constructor(e,t,n,r,a,o){this.state=e,this.registry=t,this.getCallbacks=n,this.notify=r,this.triggerRender=a,this.undoStack=[],this.pendingSnapshot=null,this.pendingChangeSource=null,this.externalEvents=new Map,this.MAX_UNDO_STACK=50,this.store=new Ce(o),this.setupStoreListeners()}setupStoreListeners(){this.store.onEventChange=e=>{var t,n,r,a;this.syncExternalEventsToState();let o=null;return"create"===e.type?o=null===(n=(t=this.getCallbacks()).onEventCreate)||void 0===n?void 0:n.call(t,e.event):"update"===e.type&&(o=null===(a=(r=this.getCallbacks()).onEventUpdate)||void 0===a?void 0:a.call(r,e.after)),this.triggerRender(),this.notify(),null!=o?o:void 0},this.store.onEventBatchChange=e=>{var t,n;this.syncExternalEventsToState();let r=null;return"drag"!==this.pendingChangeSource&&"resize"!==this.pendingChangeSource&&(r=null===(n=(t=this.getCallbacks()).onEventBatchChange)||void 0===n?void 0:n.call(t,e)),this.pendingChangeSource=null,this.triggerRender(),this.notify(),null!=r?r:void 0}}getStore(){return this.store}pushToUndo(e){this.undoStack.push({type:"events_snapshot",data:e||[...this.state.events]}),this.undoStack.length>this.MAX_UNDO_STACK&&this.undoStack.shift()}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 Ce(this.state.events),this.setupStoreListeners(),this.triggerRender(),this.notify())}applyEventsChanges(e,t,n){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){L.warn(`Failed to update event ${e}:`,t)}}),e.add&&e.add.forEach(e=>{try{this.store.createEvent(e)}catch(t){L.warn(`Failed to create event ${e.id}:`,t)}}),this.store.endTransaction()}addEvent(e){this.pendingSnapshot=null,this.pushToUndo(),this.store.createEvent(e)}addExternalEvents(e,t){const n=t.map(t=>Object.assign(Object.assign({},t),{calendarId:e}));this.externalEvents.set(e,n),this.syncExternalEventsToState(),this.notify()}syncExternalEventsToState(){const e=this.store.getAllEvents(),t=new Map;if(e.forEach(e=>t.set(e.id,e)),this.externalEvents.size>0)for(const e of this.externalEvents.values())e.forEach(e=>t.set(e.id,e));this.state.events=Array.from(t.values())}updateEvent(t,n,r,a){return e.__awaiter(this,void 0,void 0,function*(){if(a&&(this.pendingChangeSource=a),r?this.pendingSnapshot||(this.pendingSnapshot=[...this.state.events]):this.pendingSnapshot?(this.pushToUndo(this.pendingSnapshot),this.pendingSnapshot=null):this.pushToUndo(),r){const e=this.state.events.findIndex(e=>e.id===t);if(-1===e)throw new Error(`Event with id ${t} not found`);const r=Object.assign(Object.assign({},this.state.events[e]),n);return this.state.events=[...this.state.events.slice(0,e),r,...this.state.events.slice(e+1)],void this.notify()}yield this.store.updateEvent(t,n)})}deleteEvent(t){return e.__awaiter(this,void 0,void 0,function*(){var e,n;yield null===(n=(e=this.getCallbacks()).onEventDelete)||void 0===n?void 0:n.call(e,t),this.pendingSnapshot=null,this.pushToUndo(),yield this.store.deleteEvent(t)})}getAllEvents(){return[...this.state.events]}getEvents(){const e=this.state.events||[],t=new Set(this.registry.getAll().filter(e=>!1!==e.isVisible).map(e=>e.id));return e.filter(e=>!!e.calendarId&&t.has(e.calendarId))}onEventClick(e){var t,n;null===(n=(t=this.getCallbacks()).onEventClick)||void 0===n||n.call(t,e)}onMoreEventsClick(e){var t,n;null===(n=(t=this.getCallbacks()).onMoreEventsClick)||void 0===n||n.call(t,e)}highlightEvent(e){var t,n;this.state.highlightedEventId!==e&&(this.state.highlightedEventId=e,null===(n=(t=this.getCallbacks()).onRender)||void 0===n||n.call(t),this.notify())}selectEvent(e){var t,n;this.state.selectedEventId!==e&&(this.state.selectedEventId=e,null===(n=(t=this.getCallbacks()).onRender)||void 0===n||n.call(t),this.notify())}dismissUI(){var e,t;null===(t=(e=this.getCallbacks()).onDismissUI)||void 0===t||t.call(e),this.notify()}}class ke{constructor(e,t,n,r){this.state=e,this.getCallbacks=t,this.notify=n,this.visibleMonth=new Date(r.getFullYear(),r.getMonth(),1)}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.getCallbacks()).onViewChange)||void 0===n||n.call(t,e),this.handleVisibleRangeChange("viewChange"),this.notify()}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}emitVisibleRange(e,t,n="navigation"){var r,a;null===(a=(r=this.getCallbacks()).onVisibleRangeChange)||void 0===a||a.call(r,new Date(e),new Date(t),n)}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}=ce(this.state.currentDate,r),i=new Date(a),l=new Date(a);l.setDate(l.getDate()+7),this.emitVisibleRange(i,l,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:i}=ce(t,n),l=new Date(i),s=new Date(i);s.setDate(s.getDate()+42),this.emitVisibleRange(l,s,e);break}case exports.ViewType.YEAR:{const t=new Date(this.state.currentDate.getFullYear(),0,1);t.setHours(0,0,0,0);const n=new Date(this.state.currentDate.getFullYear(),11,31);n.setDate(n.getDate()+1),this.emitVisibleRange(t,n,e);break}}}setCurrentDate(e){var t,n;this.state.currentDate=new Date(e),null===(n=(t=this.getCallbacks()).onDateChange)||void 0===n||n.call(t,this.state.currentDate),this.setVisibleMonth(this.state.currentDate),this.handleVisibleRangeChange("navigation"),this.notify()}getCurrentDate(){return new Date(this.state.currentDate)}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.getCallbacks()).onVisibleMonthChange)||void 0===n||n.call(t,new Date(this.visibleMonth)),this.notify())}getVisibleMonth(){return new Date(this.visibleMonth)}goToToday(){const e=t.Temporal.Now.plainDateISO(this.state.timeZone),n=new Date(e.year,e.month-1,e.day);this.setCurrentDate(n)}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)}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)}selectDate(e){var t,n;this.setCurrentDate(e),null===(n=(t=this.getCallbacks()).onDateChange)||void 0===n||n.call(t,new Date(e))}}class Se{constructor(e,t){this.state=e,this.notify=t}install(e,t){this.state.plugins.has(e.name)?L.warn(`Plugin ${e.name} is already installed`):(this.state.plugins.set(e.name,e),e.install(t))}getPlugin(e){const t=this.state.plugins.get(e);return null==t?void 0:t.api}hasPlugin(e){return this.state.plugins.has(e)}getPluginConfig(e){const t=this.state.plugins.get(e);return(null==t?void 0:t.config)||{}}updatePluginConfig(e,t){const n=this.state.plugins.get(e);n&&(n.config=Object.assign(Object.assign({},n.config),t),this.notify())}}class Me{constructor(n){var r,a,o,i,l;this.subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e)),this.notify=()=>{this.listeners.forEach(e=>e(this))},this.triggerRender=()=>{var e,t;null===(t=(e=this.callbacks).onRender)||void 0===t||t.call(e),this.notify()},this.changeView=e=>this.navigation.changeView(e),this.getCurrentView=()=>this.navigation.getCurrentView(),this.emitVisibleRange=(e,t,n)=>this.navigation.emitVisibleRange(e,t,n),this.handleVisibleRangeChange=e=>this.navigation.handleVisibleRangeChange(e),this.setCurrentDate=e=>this.navigation.setCurrentDate(e),this.getCurrentDate=()=>this.navigation.getCurrentDate(),this.setVisibleMonth=e=>this.navigation.setVisibleMonth(e),this.getVisibleMonth=()=>this.navigation.getVisibleMonth(),this.goToToday=()=>this.navigation.goToToday(),this.goToPrevious=()=>this.navigation.goToPrevious(),this.goToNext=()=>this.navigation.goToNext(),this.selectDate=e=>this.navigation.selectDate(e),this.undo=()=>this.eventManager.undo(),this.applyEventsChanges=(e,t,n)=>this.eventManager.applyEventsChanges(e,t,n),this.addEvent=e=>this.eventManager.addEvent(e),this.addExternalEvents=(e,t)=>this.eventManager.addExternalEvents(e,t),this.updateEvent=(e,t,n,r)=>this.eventManager.updateEvent(e,t,n,r),this.deleteEvent=e=>this.eventManager.deleteEvent(e),this.getAllEvents=()=>this.eventManager.getAllEvents(),this.getEvents=()=>this.eventManager.getEvents(),this.onEventClick=e=>this.eventManager.onEventClick(e),this.onMoreEventsClick=e=>this.eventManager.onMoreEventsClick(e),this.highlightEvent=e=>this.eventManager.highlightEvent(e),this.selectEvent=e=>this.eventManager.selectEvent(e),this.dismissUI=()=>this.eventManager.dismissUI(),this.getReadOnlyConfig=e=>function(e,t,n,r){var a,o;let i=!0,l=!0;if(!0===e?(i=!1,l=!1):!1!==e&&(i=null===(a=e.draggable)||void 0===a||a,l=null===(o=e.viewable)||void 0===o||o),t&&(i||l)){let e=t;const a=r.find(e=>e.id===t);(null==a?void 0:a.calendarId)&&(e=a.calendarId);const o=n.get(e);o&&(!0===o.readOnly&&(i=!1),o.subscription&&void 0===o.readOnly&&(i=!1))}return{draggable:i,viewable:l}}(this.state.readOnly,e,this.calendarRegistry,this.state.events),this.canMutateFromUI=e=>function(e,t,n,r){if(!1!==e)return!1;if(t){let e=t;const a=r.find(e=>e.id===t);(null==a?void 0:a.calendarId)&&(e=a.calendarId);const o=n.get(e);if(o){if(void 0!==o.readOnly)return!o.readOnly;if(o.subscription)return!1}}return!0}(this.state.readOnly,e,this.calendarRegistry,this.state.events),this.getCalendars=()=>this.calendarRegistry.getAll(),this.reorderCalendars=(e,t)=>{this.calendarRegistry.reorder(e,t),this.triggerRender()},this.setCalendarVisibility=(e,t)=>{this.calendarRegistry.setVisibility(e,t),this.triggerRender()},this.setAllCalendarsVisibility=e=>{this.calendarRegistry.setAllVisibility(e),this.triggerRender()},this.updateCalendar=(e,t,n)=>{var r,a;if(this.calendarRegistry.updateCalendar(e,t),n)return void this.notify();const o=this.calendarRegistry.get(e);o&&(null===(a=(r=this.callbacks).onCalendarUpdate)||void 0===a||a.call(r,o)),this.triggerRender()},this.createCalendar=t=>e.__awaiter(this,void 0,void 0,function*(){var e,n;this.calendarRegistry.register(t),yield null===(n=(e=this.callbacks).onCalendarCreate)||void 0===n?void 0:n.call(e,t),this.triggerRender()}),this.deleteCalendar=t=>e.__awaiter(this,void 0,void 0,function*(){var e,n;this.calendarRegistry.unregister(t),yield null===(n=(e=this.callbacks).onCalendarDelete)||void 0===n?void 0:n.call(e,t),this.triggerRender()}),this.mergeCalendars=(t,n)=>e.__awaiter(this,void 0,void 0,function*(){var e,r;const a=this.eventManager.getStore(),o=a.getAllEvents().filter(e=>e.calendarId===t);this.eventManager.pushToUndo(),a.beginTransaction(),o.forEach(e=>a.updateEvent(e.id,{calendarId:n})),yield a.endTransaction(),yield this.deleteCalendar(t),yield null===(r=(e=this.callbacks).onCalendarMerge)||void 0===r?void 0:r.call(e,t,n)}),this.getPlugin=e=>this.pluginManager.getPlugin(e),this.hasPlugin=e=>this.pluginManager.hasPlugin(e),this.getPluginConfig=e=>this.pluginManager.getPluginConfig(e),this.updatePluginConfig=(e,t)=>this.pluginManager.updatePluginConfig(e,t),this.setTheme=e=>{this.calendarRegistry.setTheme(e),this.themeChangeListeners.forEach(t=>t(e)),this.triggerRender()},this.getTheme=()=>this.calendarRegistry.getTheme(),this.subscribeThemeChange=e=>(this.themeChangeListeners.add(e),()=>this.unsubscribeThemeChange(e)),this.unsubscribeThemeChange=e=>{this.themeChangeListeners.delete(e)},this.getViewConfig=e=>{const t=this.state.views.get(e);return(null==t?void 0:t.config)||{}},this.getCalendarRegistry=()=>this.calendarRegistry,this.getUseEventDetailDialog=()=>this.useEventDetailDialog,this.getCustomMobileEventRenderer=()=>this.customMobileEventRenderer,this.getCalendarHeaderConfig=()=>this.useCalendarHeader,this.setOverrides=e=>{this.state.overrides=e,this.triggerRender()},this.updateConfig=e=>{var t,n;let r=!1;if(void 0!==e.customMobileEventRenderer&&e.customMobileEventRenderer!==this.customMobileEventRenderer&&(this.customMobileEventRenderer=e.customMobileEventRenderer,r=!0),void 0!==e.useEventDetailDialog&&e.useEventDetailDialog!==this.useEventDetailDialog&&(this.useEventDetailDialog=e.useEventDetailDialog,r=!0),void 0!==e.useCalendarHeader&&e.useCalendarHeader!==this.useCalendarHeader&&(this.useCalendarHeader=e.useCalendarHeader,r=!0),void 0===e.readOnly||Ee(e.readOnly,this.state.readOnly)||(this.state.readOnly=e.readOnly,r=!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,r=!0),void 0!==e.locale){const t=Me.resolveLocale(e.locale);Ee(t,this.state.locale)||(this.state.locale=t,r=!0)}if(void 0!==e.allDaySortComparator&&e.allDaySortComparator!==this.state.allDaySortComparator&&(this.state.allDaySortComparator=e.allDaySortComparator,r=!0),void 0!==e.timeZone){const t=null!==(n=Y(e.timeZone))&&void 0!==n?n:Intl.DateTimeFormat().resolvedOptions().timeZone;t!==this.state.timeZone&&(this.state.timeZone=t,r=!0)}if(void 0!==e.views){const t=new Map(this.state.views);let n=!1;e.views.forEach(e=>{const r=t.get(e.type);r&&Ee(e.config,r.config)||(t.set(e.type,e),n=!0)}),n&&(this.state.views=t,r=!0)}if(void 0!==e.calendars){let t=!1;for(const n of e.calendars){const e=this.calendarRegistry.get(n.id);e&&e.source!==n.source&&(this.calendarRegistry.updateCalendar(n.id,{source:n.source}),t=!0)}t&&(r=!0)}r&&this.triggerRender()};const s=null!==(r=Y(n.timeZone))&&void 0!==r?r:Intl.DateTimeFormat().resolvedOptions().timeZone,d=(()=>{const e=t.Temporal.Now.plainDateISO(s);return new Date(e.year,e.month-1,e.day)})();var c;this.state={currentView:n.defaultView||exports.ViewType.WEEK,currentDate:n.initialDate||d,events:n.events||[],switcherMode:n.switcherMode||"buttons",plugins:new Map,views:new Map,locale:Me.resolveLocale(n.locale),highlightedEventId:null,selectedEventId:null,readOnly:n.readOnly||!1,overrides:[],allDaySortComparator:n.allDaySortComparator,timeZone:s},this.callbacks=n.callbacks||{},this.themeChangeListeners=new Set,this.listeners=new Set,this.calendarRegistry=new M(n.calendars,n.defaultCalendar,(null===(a=n.theme)||void 0===a?void 0:a.mode)||"light"),c=this.calendarRegistry,N=c,this.eventManager=new Te(this.state,this.calendarRegistry,()=>this.callbacks,this.notify,this.triggerRender,n.events||[]),this.navigation=new ke(this.state,()=>this.callbacks,this.notify,this.state.currentDate),this.pluginManager=new Se(this.state,this.notify),this.useEventDetailDialog=null!==(o=n.useEventDetailDialog)&&void 0!==o&&o,this.useCalendarHeader=null===(i=n.useCalendarHeader)||void 0===i||i,this.customMobileEventRenderer=n.customMobileEventRenderer,n.views.forEach(e=>this.state.views.set(e.type,e)),null===(l=n.plugins)||void 0===l||l.forEach(e=>this.pluginManager.install(e,this)),this.handleVisibleRangeChange("initial")}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"}get timeZone(){return this.state.timeZone}}var Ne=0;function Ie(e,t,r,a,o,i){t||(t={});var l,s,d=t;if("ref"in d)for(s in d={},t)"ref"==s?l=t[s]:d[s]=t[s];var c={type:e,props:d,key:r,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Ne,__i:-1,__u:0,__source:o,__self:i};if("function"==typeof e&&(l=e.defaultProps))for(s in l)void 0===d[s]&&(d[s]=l[s]);return n.options.vnode&&n.options.vnode(c),c}const Re=e=>{if(!e)return"";let n,r,a;e instanceof Date?(a=e.getFullYear(),r=e.getMonth()+1,n=e.getDate()):m(e)?(a=e.year,r=e.month,n=e.day):(!function(e){if(!e||"object"!=typeof e)return!1;if(e instanceof Date)return!1;const n=e;t.Temporal.ZonedDateTime}(e),a=e.year,r=e.month,n=e.day);const o=String(r).padStart(2,"0");return`${String(n).padStart(2,"0")}/${o}/${a}`},Oe=/(YYYY|YY|MM|DD|HH|mm)/g,He=e=>e.toString().padStart(2,"0"),Ae=(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`)},Pe=e=>e.replaceAll(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),Le=e=>{let t,n=0,r="^";for(;null!==(t=Oe.exec(e));){r+=Pe(e.slice(n,t.index));const a=t[0];r+=`(?<${a}>\\d{${"YYYY"===a?4:2}})`,n=t.index+a.length}return r+=Pe(e.slice(n))+"$",new RegExp(r)},$e=(e,n,r,a)=>{const o=e.trim();if(!o)return null;const i=o.match(n),l=null==i?void 0:i.groups;if(!l)return null;const s=l.YYYY?Number(l.YYYY):l.YY?Number(l.YY)+2e3:r.year,d=l.MM?Number(l.MM):r.month,c=l.DD?Number(l.DD):r.day,u=l.HH?Number(l.HH):r.hour,h=l.mm?Number(l.mm):r.minute;try{return t.Temporal.ZonedDateTime.from({timeZone:a,year:s,month:d,day:c,hour:u,minute:h,second:r.second,millisecond:r.millisecond,microsecond:r.microsecond,nanosecond:r.nanosecond})}catch(e){return null}},je=e=>{const n=e;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:t.Temporal.Now.timeZoneId()},Ye=(e,n,r)=>{var a,o,i,l,s,d,c,u,h,g,m,f,p,v,y,b,x,w,D,E,C,T,k,S;if(!e){const e=null!=n?n:r?je(r):t.Temporal.Now.timeZoneId();return null!=r?r:t.Temporal.Now.zonedDateTimeISO(e)}if(F(e)){const r=null!=n?n:t.Temporal.Now.timeZoneId(),a=`${e.year}-${He(e.month)}-${He(e.day)}T00:00:00[${r}]`;return t.Temporal.ZonedDateTime.from(a)}const M=e;if("hour"in M&&!("timeZoneId"in M)){const r=null!=n?n:t.Temporal.Now.timeZoneId();if("function"==typeof M.toZonedDateTime)try{return e.toZonedDateTime(r)}catch(e){}return t.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!==(i=M.microsecond)&&void 0!==i?i:0,nanosecond:null!==(l=M.nanosecond)&&void 0!==l?l:0})}try{return t.Temporal.ZonedDateTime.from(e)}catch(e){const a=M,o=null!==(h=null!==(u=null!==(c=null!==(d="string"==typeof(null==a?void 0:a.timeZone)?a.timeZone:null===(s=null==a?void 0:a.timeZone)||void 0===s?void 0:s.id)&&void 0!==d?d:null==a?void 0:a.timeZoneId)&&void 0!==c?c:n)&&void 0!==u?u:r?je(r):void 0)&&void 0!==h?h:t.Temporal.Now.timeZoneId();if("function"==typeof(null==a?void 0:a.toZonedDateTime))try{return a.toZonedDateTime({timeZone:o})}catch(e){}const i=null!=r?r:t.Temporal.Now.zonedDateTimeISO(o);return t.Temporal.ZonedDateTime.from({timeZone:o,year:null!==(g=null==a?void 0:a.year)&&void 0!==g?g:i.year,month:null!==(m=null==a?void 0:a.month)&&void 0!==m?m:i.month,day:null!==(f=null==a?void 0:a.day)&&void 0!==f?f:i.day,hour:null!==(v=null!==(p=null==a?void 0:a.hour)&&void 0!==p?p: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})}},Fe=(e,t,n)=>{const r=Ae(t,n),a={YYYY:e.year.toString(),YY:He(e.year%100),MM:He(e.month),DD:He(e.day),HH:He(e.hour),mm:He(e.minute)};return r.replace(Oe,e=>{var t;return null!==(t=a[e])&&void 0!==t?t:e})};let Ve=null;function Ze(){if("undefined"==typeof document)return!1;if(null!==Ve)return Ve;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(),Ve=r,r}const _e=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 ze(e,n=!1){if(e instanceof t.Temporal.PlainDate||e instanceof t.Temporal.PlainDateTime)return e;if(e instanceof Date)return n?W(e):B(e);throw new Error("Invalid time type: "+typeof e)}function Ue(e,n){if(e instanceof t.Temporal.ZonedDateTime)return e;if(e instanceof Date)return G(e,n);throw new Error("Invalid time type: "+typeof e)}function We(e){var t;const n=ze(e.start,e.allDay),r=ze(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 Be(e){const t=Ue(e.start,e.timeZone),n=Ue(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 Ge=e=>{try{return e instanceof Date?e:"string"==typeof e?new Date(e):v(e)}catch(e){return new Date}},Ke=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},qe=(e,t,n,r)=>{const a=e.getTime()-t.getTime(),o=Math.round(a/864e5);let i="",l="text-gray-500 dark:text-gray-400";if(0===o)i=r("today")||"Today",l="df-text-primary";else if(1===o||2===o)try{const e=new Intl.RelativeTimeFormat(n,{numeric:"auto"}).format(o,"day");i=e.charAt(0).toUpperCase()+e.slice(1),l="text-black dark:text-white"}catch(t){i=e.toLocaleDateString(n,{weekday:"long"})}else i=e.toLocaleDateString(n,{year:"numeric",month:"long",day:"numeric",weekday:"long"});return{title:i,colorClass:l}},Xe=(e,t)=>{const n=new Map;e.forEach(e=>{var t;const r=Ge(e.start),a=Ke(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 Qe(e){return String(e).padStart(2,"0")}function et(e,n,r){const a=e.trim(),o=/^(\d{4})(\d{2})(\d{2})$/,i=/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z$/;if("DATE"===(null==n?void 0:n.value)||o.test(a)){const e=a.match(o);if(e)return t.Temporal.PlainDate.from({year:Number.parseInt(e[1],10),month:Number.parseInt(e[2],10),day:Number.parseInt(e[3],10)})}if(i.test(a)){const e=a.match(i);if(e){const n=t.Temporal.Instant.from(`${e[1]}-${e[2]}-${e[3]}T${e[4]}:${e[5]}:${e[6]}Z`),a=r||t.Temporal.Now.timeZoneId();return n.toZonedDateTimeISO(a)}}const l=a.match(/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})$/);if(l){const e={year:Number.parseInt(l[1],10),month:Number.parseInt(l[2],10),day:Number.parseInt(l[3],10),hour:Number.parseInt(l[4],10),minute:Number.parseInt(l[5],10),second:Number.parseInt(l[6],10)};return(null==n?void 0:n.tzid)?t.Temporal.ZonedDateTime.from(Object.assign(Object.assign({},e),{timeZone:n.tzid})):t.Temporal.PlainDateTime.from(e)}throw new Error(`Invalid ICS date format: ${e}`)}function tt(e,t=!1){if(t||F(e)){const t=F(e)?e:e.toPlainDate();return{value:`${t.year}${Qe(t.month)}${Qe(t.day)}`,params:{VALUE:"DATE"}}}if(Z(e)){const t=e.toInstant().toZonedDateTimeISO("UTC");return{value:`${t.year}${Qe(t.month)}${Qe(t.day)}T${Qe(t.hour)}${Qe(t.minute)}${Qe(t.second)}Z`}}if(V(e))return{value:`${e.year}${Qe(e.month)}${Qe(e.day)}T${Qe(e.hour)}${Qe(e.minute)}${Qe(e.second)}`};throw new Error("Unsupported Temporal type")}function nt(e){return`${e.getUTCFullYear()}${Qe(e.getUTCMonth()+1)}${Qe(e.getUTCDate())}T${Qe(e.getUTCHours())}${Qe(e.getUTCMinutes())}${Qe(e.getUTCSeconds())}Z`}function rt(e){return e?e.replaceAll("\\","\\\\").replaceAll(";","\\;").replaceAll(",","\\,").replaceAll("\n","\\n"):""}function at(e){return e?e.replaceAll("\\,",",").replaceAll("\\;",";").replaceAll(/\\[nN]/g,"\n").replaceAll("\\\\","\\"):""}function ot(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 it(e,t,n){let r=e;return n&&Object.entries(n).forEach(([e,t])=>{r+=`;${e}=${t}`}),r+=`:${t}`,ot(r)}function lt(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:${nt(new Date)}`);const i=tt(e.start,e.allDay);let l;if(e.allDay){const t=(F(e.end)?e.end:e.end.toPlainDate()).add({days:1});l={value:`${t.year}${Qe(t.month)}${Qe(t.day)}`,params:{VALUE:"DATE"}}}else l=tt(e.end,!1);if(a.push(it("DTSTART",i.value,i.params)),a.push(it("DTEND",l.value,l.params)),a.push(it("SUMMARY",rt(e.title))),e.description&&a.push(it("DESCRIPTION",rt(e.description))),(null===(n=e.meta)||void 0===n?void 0:n.location)&&a.push(it("LOCATION",rt(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(rt).join(",");a.push(it("CATEGORIES",t))}return a.push("END:VEVENT"),a}function st(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 dt(e){const t={};for(const n of e){const e=n.indexOf(":");if(-1===e)continue;const r=n.slice(0,e),a=n.slice(e+1),[o,...i]=r.split(";"),l=o.trim().toUpperCase(),s={};switch(i.forEach(e=>{const[t,n]=e.split("=");t&&n&&(s[t.trim().toUpperCase()]=n.trim())}),l){case"UID":t.uid=a.trim();break;case"SUMMARY":t.summary=at(a);break;case"DESCRIPTION":t.description=at(a);break;case"LOCATION":t.location=at(a);break;case"DTSTART":t.dtstart=a.trim(),t.dtstartParams={value:s.VALUE,tzid:s.TZID};break;case"DTEND":t.dtend=a.trim(),t.dtendParams={value:s.VALUE,tzid:s.TZID};break;case"CATEGORIES":t.categories=a.split(",").map(e=>at(e.trim()))}}if(!t.dtstart)throw new Error("Missing DTSTART in VEVENT");return t.uid||(t.uid=De()),t}function ct(e,n){var r;const{calendarId:a="default",generateNewIds:o=!0,idPrefix:i="ics-",defaultTimeZone:l}=n,s=o?`${i}${De()}`:e.uid,d=et(e.dtstart,e.dtstartParams,l);let c;c=e.dtend?et(e.dtend,e.dtendParams,l):F(d)?d.add({days:1}):d.add({hours:1});const u="DATE"===(null===(r=e.dtstartParams)||void 0===r?void 0:r.value)||F(d),h=l||t.Temporal.Now.timeZoneId();let g,m;if(F(d))g=d;else if(V(d))try{g=d.toZonedDateTime(h)}catch(e){g=t.Temporal.ZonedDateTime.from(Object.assign(Object.assign({},d),{timeZone:h}))}else g=d;if(F(c))m=c.subtract({days:1});else if(V(c))try{m=c.toZonedDateTime(h)}catch(e){m=t.Temporal.ZonedDateTime.from(Object.assign(Object.assign({},c),{timeZone:h}))}else m=c;return{id:s,calendarId:a,title:e.summary||"(No Title)",description:e.description,start:g,end:m,allDay:u,meta:{location:e.location,originalUid:e.uid,categories:e.categories}}}function ut(e,t={}){const n={success:!1,events:[],errors:[],totalParsed:0,totalImported:0};try{const r=e.replaceAll(/(\r\n|\n|\r)[ \t]/g,""),a=st(r.split(/\r\n|\n|\r/));n.totalParsed=a.length,a.forEach((e,r)=>{try{const r=ct(dt(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 ht(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:${rt(n)}`];return e.forEach(e=>{a.push(...lt(e))}),a.push("END:VCALENDAR"),a.join("\r\n")}const gt=e=>{const t=v(e.start);t.setHours(0,0,0,0);const n=v(e.end);return n.setHours(0,0,0,0),{startDay:t,endDay:n,isMultiDay:n.getTime()>t.getTime()}},mt=(e,t,n)=>{const r=gt(e),a=gt(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()},ft=(e,t)=>{const n=new Map;return e.forEach(e=>{const{isMultiDay:t,startDay:r}=gt(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,i,l,s,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!==(i=null==c?void 0:c.hasMultiDay)&&void 0!==i&&i&&null!==(l=null==u?void 0:u.hasMultiDay)&&void 0!==l&&l&&e.calendarId!==r.calendarId){const e=(null!==(s=null==c?void 0:c.earliestMultiDayStart)&&void 0!==s?s: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,mt(e,r,t)}};let pt=null;const vt=()=>{const[e,t]=a.useState(()=>pt||{weekHeight:u.WEEK_HEIGHT,screenSize:"desktop",weeksPerView:6});return a.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};pt=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},yt=n.createContext({locale:"en-US",t:e=>e,getWeekDaysLabels:()=>[],getMonthLabels:()=>[],isDefault:!0});function bt(){return a.useContext(yt)}const xt="df-month-view h-full flex flex-col select-none",wt="p-2 flex justify-between",Dt="text-2xl font-bold text-gray-900 dark:text-gray-100",Et="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",Tt="df-scrollbar-hide",kt="df-time-slot relative h-[4.5rem] flex",St="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",Nt="df-current-time-line absolute left-0 top-0 w-full flex pointer-events-none",It="df-current-time-label ml-2 df-fill-primary text-xs font-bold px-1.5 rounded-sm",Rt="df-all-day-row flex items-center border-b",Ot="rounded-xl my-0.5",Ht="rounded-sm",At="df-event-title font-medium text-xs truncate pr-1",Pt="df-month-event-color-bar inline-block w-0.75 h-3 mr-1 shrink-0 rounded-full",Lt="h-3 w-3 mr-1",$t="resize-handle absolute left-0 top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20",jt="resize-handle absolute right-0 top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20",Yt="df-fill-primary rounded-full",Ft="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",Vt="h-4 w-4 transition-transform group-hover:scale-110",Zt="df-event-detail-panel df-portal fixed shadow-lg border rounded-lg",_t="df-portal 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",zt="df-time-grid-boundary h-3 border-t relative",Ut="absolute top-0 -translate-y-1/2 text-[12px] text-gray-500 dark:text-gray-400",Wt="flex h-7 w-7 items-center justify-center rounded hover:bg-gray-100 dark:hover:bg-slate-800 transition-colors",Bt="text-gray-500 dark:text-gray-400",Gt="text-gray-600 dark:text-gray-300",Kt="text-xs",qt="text-sm",Xt="flex flex-col",Jt="mr-1",Qt=(...e)=>e.filter(Boolean).join(" "),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:"m15 18-6-6 6-6"})}),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:"m9 18 6-6-6-6"})}),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:"m11 17-5-5 5-5"}),Ie("path",{d:"m18 17-5-5 5-5"})]}),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:"m6 17 5-5-5-5"}),Ie("path",{d:"m13 17 5-5-5-5"})]}),an=({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"})}),on=({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"})]}),ln=({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"})]}),sn=({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"})}),dn=({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"})]}),cn=({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"})]}),un=({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"})]}),hn=({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"})]}),gn=({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"})}),mn=({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"})]}),fn=({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"})}),pn=({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"})]}),vn=({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"})}),yn=({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 bn(e,t){var n,r,a,o,i;try{if("today"===e){return null!==(r=null===(n=new Intl.RelativeTimeFormat(t,{numeric:"auto"}).formatToParts(0,"day").find(e=>"literal"===e.type))||void 0===n?void 0:n.value)&&void 0!==r?r:null}if("week"===e){return null!==(o=null===(a=new Intl.RelativeTimeFormat(t,{numeric:"always"}).formatToParts(1,"week").find(e=>"unit"===e.type))||void 0===a?void 0:a.value)&&void 0!==o?o:null}return null!==(i=new Intl.DisplayNames(t,{type:"dateTimeField"}).of(e))&&void 0!==i?i:null}catch(e){return null}}function xn(e){return e.charAt(0).toUpperCase()+e.slice(1)}const wn=(e,t="short",n=1)=>{const r=[],a=new Date(2024,0,7);for(let o=0;o<7;o++){const i=new Date(a);i.setDate(a.getDate()+n+o);try{r.push(i.toLocaleDateString(e,{weekday:t}))}catch(e){r.push(i.toLocaleDateString("en-US",{weekday:t}))}}return r},Dn=(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 En(e,t="en-US"){var n;if(["today","day","week","month","year"].includes(e)){const n=bn(e,t);if(n)return xn(n)}const r=s(t),a=l[r],o=null===(n=null==a?void 0:a.messages)||void 0===n?void 0:n[e];if(o)return o;const i=l.en.messages;return(null==i?void 0:i[e])||e}const Cn=({locale:e="en-US",messages:t,children:n})=>{const r=a.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=a.useMemo(()=>{const e=r.code;return{locale:e,t:(n,a)=>{var o,i,l;let s=null!==(l=null!==(o=null==t?void 0:t[n])&&void 0!==o?o:null===(i=r.messages)||void 0===i?void 0:i[n])&&void 0!==l?l:En(n,e);return a&&Object.entries(a).forEach(([e,t])=>{s=s.replaceAll(new RegExp(`{${e}}`,"g"),t)}),s},getWeekDaysLabels:wn,getMonthLabels:Dn,isDefault:!1}},[r,t]);return Ie(yt.Provider,{value:o,children:n})},Tn=(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(" ")},kn=({calendar:e,mode:t="buttons"})=>{const[n,r]=a.useState(!1),o=a.useRef(null),{t:i}=bt(),l=Array.from(e.state.views.keys()),s=e.state.currentView;return a.useEffect(()=>{const e=e=>{o.current&&!o.current.contains(e.target)&&r(!1)};if(n)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[n]),l.length<=1?null:Ie("div","select"===t?{className:"relative inline-block",ref:o,children:[Ie("button",{type:"button",onClick:()=>r(!n),className:"flex h-7 min-w-30 items-center justify-between gap-2 rounded-lg border border-gray-200 bg-white px-3 text-sm font-medium shadow-sm transition-all duration-200 hover:bg-gray-50 focus:outline-none dark:border-gray-600 dark:bg-gray-800 dark:hover:bg-gray-700","aria-expanded":n,"aria-haspopup":"listbox",children:[Ie("span",{className:"text-gray-900 dark:text-gray-100",children:Tn(s,e,i)}),Ie("span",{className:`${Bt} transition-transform duration-200 ${n?"rotate-180":""}`,children:Ie(an,{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:l.map(t=>Ie("button",{type:"button",onClick:()=>{e.changeView(t),r(!1),e.triggerRender()},className:"w-full rounded px-3 py-0.5 text-left text-sm transition-colors duration-150 focus:outline-none "+(s===t?"df-tint-primary font-medium":"text-gray-700 hover:bg-gray-50 dark:text-gray-300 dark:hover:bg-gray-700"),role:"option","aria-selected":s===t,children:Tn(t,e,i)},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:"inline-flex h-7 items-center gap-1 rounded-lg bg-gray-100 p-0.5 dark:bg-gray-800",children:l.map(t=>Ie("button",{type:"button",className:"h-6 rounded-md px-4 text-sm font-medium transition-all duration-200 focus:outline-none "+(s===t?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-gray-100":"text-gray-600 hover:bg-gray-50 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-100"),onClick:()=>{e.changeView(t),e.triggerRender()},children:Tn(t,e,i)},t))})},Sn=({calendar:e,switcherMode:t="buttons",onAddCalendar:n,onSearchChange:r,onSearchClick:o,searchValue:i="",isSearchOpen:l=!1,isEditable:s=!0,safeAreaLeft:d})=>{const c="buttons"===t,u=e.state.currentView===exports.ViewType.DAY,{screenSize:h}=vt(),g="mobile"===h,{t:m}=bt(),f=a.useCallback(e=>{const t=e.currentTarget.value;t!==i&&(null==r||r(t))},[r,i]);return Ie("div",{className:"df-header flex shrink-0 items-center justify-between border-b py-1 pr-2 transition-colors duration-200 "+(u||l?"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 flex items-center",children:n&&s&&Ie("button",{type:"button",id:"dayflow-add-event-btn",onClick:n,className:Wt,title:g?m("newEvent")||"New Event":m("createCalendar")||"Add Calendar",children:Ie(on,{className:`h-4 w-4 ${Bt}`})})}),Ie("div",{className:"df-header-mid flex flex-1 items-center justify-center",children:c&&Ie(kn,{mode:t,calendar:e})}),Ie("div",{className:"df-header-right flex items-center justify-end gap-3",children:[!c&&Ie(kn,{mode:t,calendar:e}),Ie("button",{type:"button",onClick:o,className:`md:hidden ${Wt}`,title:m("search")||"Search",children:Ie(ln,{width:16,height:16})}),Ie("div",{className:"df-search-group 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:"df-search-focus-within-primary text-gray-400 transition-colors",children:Ie(ln,{width:16,height:16})})}),Ie("input",{id:"dayflow-search-input",type:"text",placeholder:m("search")||"Search",value:i,onChange:f,className:"pl-9 pr-8 py-1 h-7 text-sm border border-slate-200 dark:border-gray-600 rounded-lg text-gray-900 dark:text-gray-100 placeholder-gray-500 dark:placeholder-gray-400 focus:outline-none focus:ring-1 df-focus-ring transition resize-none w-48"}),i&&Ie("button",{type:"button",onClick:()=>{null==r||r("")},className:"absolute inset-y-0 right-0 flex items-center pr-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",children: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=n.createContext(void 0),Nn=({children:e,initialTheme:t="light",onThemeChange:n})=>{const[r,o]=a.useState(t),[i,l]=a.useState(()=>"undefined"!=typeof window&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),s="auto"===r?i:r;a.useEffect(()=>{o(t)},[t]);const d=a.useCallback(e=>{o(e)},[]);a.useEffect(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-color-scheme: dark)"),t=e=>{const t=e.matches?"dark":"light";l(t)};return e.addEventListener?e.addEventListener("change",t):e.addListener&&e.addListener(t),()=>{e.removeEventListener?e.removeEventListener("change",t):e.removeListener&&e.removeListener(t)}},[]),a.useLayoutEffect(()=>{if("undefined"==typeof document)return;const e=document.documentElement,t=_e(s),n="auto"===r?t:s;e.classList.contains(n)||(e.classList.remove("light","dark"),e.classList.add(n)),"auto"===r?e.dataset.dfThemeOverride&&delete e.dataset.dfThemeOverride:e.dataset.dfThemeOverride!==n&&(e.dataset.dfThemeOverride=n),e.dataset.dfTheme!==n&&(e.dataset.dfTheme=n)},[s,r,i]),a.useEffect(()=>{n&&n(r,s)},[r,s,n]);const c=a.useMemo(()=>({theme:r,effectiveTheme:s,setTheme:d}),[r,s,d]);return Ie(Mn.Provider,{value:c,children:e})},In=()=>{const e=a.useContext(Mn);if(void 0===e)throw new Error("useTheme must be used within a ThemeProvider");return e},Rn=n.createContext(null);let On=0;function Hn({generatorName:e,generatorArgs:t,defaultContent:n,store:r}){const o=a.useRef(null),i=a.useContext(Rn),l=r||i,s=a.useRef(null),[,d]=a.useState(0);s.current||(s.current="df-slot-"+On++),a.useEffect(()=>{if(!o.current||!l||!e)return;const n=s.current;l.register({id:n,containerEl:o.current,generatorName:e,generatorArgs:t});const r=l.subscribe(()=>{d(e=>e+1)});return()=>{l.unregister(n),r()}},[l,e]),a.useEffect(()=>{if(!l||!s.current||!e)return;const n=s.current;l.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==l?void 0:l.isOverridden(e));return Ie("div",{ref:o,className:"df-content-slot "+(c||u?"flex h-full flex-1 flex-col":""),children:!h&&n})}const An=t=>{const n=a.useRef(null),r=a.useRef(null);return a.useEffect(()=>{if(n.current){const a=e.__rest(t,[]);r.current=new o.BlossomColorPicker(n.current,a),a.initialExpanded&&r.current.expand()}return()=>{r.current&&(r.current.destroy(),r.current=null)}},[]),a.useEffect(()=>{if(r.current){const n=e.__rest(t,[]);r.current.setOptions(n)}},[t]),Ie("div",{ref:n,className:t.className})},Pn=({color:e,onChange:t,onClose:n})=>{const r=a.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(An,{defaultValue:r,coreSize:36,petalSize:32,initialExpanded:!0,openOnHover:!1,onChange:e=>t({hex:e.hex},!0),onCollapse:n})})},Ln=t=>{var{children:r,onClick:o,loading:i,loadingText:l,disabled:s,className:d,type:c="button"}=t,u=e.__rest(t,["children","onClick","loading","loadingText","disabled","className","type"]);const[h,g]=a.useState(!1),m=i||h,f=Ie(n.Fragment,{children:[m&&Ie("svg",{className:"mr-2 h-4 w-4 animate-spin",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[Ie("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),Ie("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),Ie("span",{className:"inline-flex items-center",children:m&&l?l:r})]}),p=Object.assign(Object.assign({},u),{disabled:s||m,onClick:t=>e.__awaiter(void 0,void 0,void 0,function*(){if(!m&&o){const e=o(t);if(e&&"object"==typeof e&&"then"in e){g(!0);try{yield e}finally{g(!1)}}}}),className:`relative inline-flex items-center justify-center transition-all ${d} ${m?"cursor-not-allowed opacity-70":""}`});return Ie("button","submit"===c?Object.assign({},p,{type:"submit",children:f}):"reset"===c?Object.assign({},p,{type:"reset",children:f}):Object.assign({},p,{type:"button",children:f}))},$n=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],jn=({onClose:t,onCreate:i,app:l})=>{const{t:s}=bt(),{effectiveTheme:d}=In(),[c,u]=a.useState(""),[h,g]=a.useState(!1),m=l.state.overrides.includes("createCalendarDialogColorPicker"),[f,p]=a.useState($n[Math.floor(Math.random()*$n.length)]),[v,y]=a.useState(!1),[b,x]=a.useState(""),w=a.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}},[]),[D,E]=a.useState(null),C=e=>{p(e.hex)},T=()=>{y(!1)},k=()=>{p(b),y(!1)},S="dark"===d,M={default:{picker:{background:S?"#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:S?"1px solid #4b5563":"1px solid #e5e7eb"},head:{background:S?"#1e293b":"#ffffff",borderBottom:S?"1px solid #4b5563":"1px solid #e5e7eb",boxShadow:"none"},body:{background:S?"#1e293b":"#ffffff"},controls:{border:S?"1px solid #4b5563":"1px solid #e5e7eb"},input:{background:S?"#374151":"#ffffff",color:S?"#f3f4f6":"#1f2937",border:S?"1px solid #4b5563":"1px solid #e5e7eb",boxShadow:"none"},previews:{border:S?"1px solid #4b5563":"1px solid #e5e7eb"},actions:{borderTop:S?"1px solid #4b5563":"1px solid #e5e7eb"}}};return"undefined"==typeof window?null:r.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 "+(m?"mb-4":"mb-6"),children:s("createCalendar")}),Ie("form",{onSubmit:n=>e.__awaiter(void 0,void 0,void 0,function*(){var e;if(n.preventDefault(),c.trim()&&!h){g(!0);try{let n;n=m?f:null!==(e=null==D?void 0:D.hex)&&void 0!==e?e:o.hslToHex(w.hue,w.saturation,w.lightness);const{colors:r,darkColors:a}=R(n),l={id:De(),name:c.trim(),colors:r,darkColors:a,isVisible:!0,isDefault:!1};yield i(l),t()}finally{g(!1)}}}),children:[m?Ie(n.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:f}}),Ie("input",{id:"custom-calendar-name",name:"calendar-name",type:"text",value:c,onChange:e=>u(e.target.value),className:"df-focus-ring w-full flex-1 rounded-lg border border-slate-200 px-3 py-1.5 text-sm text-gray-900 shadow-sm transition focus:ring-2 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:$n.map(e=>Ie("button",{type:"button",className:"df-focus-ring-only h-7 w-7 rounded-full border border-gray-200 transition-transform hover:scale-110 focus:ring-2 focus:ring-offset-2 focus:outline-none dark:border-gray-600 dark:focus:ring-offset-slate-800 "+(f===e?"df-ring-primary-solid scale-110 ring-2 ring-offset-2 dark:ring-offset-slate-800":""),style:{backgroundColor:e},onClick:()=>p(e)},e))}),Ie("div",{className:"relative",children:[Ie("button",{type:"button",onClick:()=>{x(f),y(!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")}),v&&Ie("div",{className:"fixed inset-0 z-10001 flex items-center justify-center bg-black/40 backdrop-blur-sm",onClick:k,children:Ie("div",{className:"df-animate-in df-fade-in df-zoom-in-95 relative",onClick:e=>e.stopPropagation(),children:Ie(Hn,{generatorName:"createCalendarDialogColorPicker",generatorArgs:{color:f,onChange:C,onAccept:T,onCancel:k,styles:M},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(Pn,{color:f,onChange:C}),Ie("div",{className:"mt-4 flex justify-end gap-2 border-t pt-3 dark:border-slate-700",children:[Ie("button",{type:"button",onClick:k,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:T,className:"df-fill-primary rounded-md px-3 py-1.5 text-xs font-medium 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:c,onChange:e=>u(e.target.value),className:"df-focus-ring w-full rounded-lg border border-slate-200 px-3 py-1.5 text-sm text-gray-900 shadow-sm transition focus:ring-2 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(An,{defaultValue:w,coreSize:36,petalSize:32,openOnHover:!1,onChange:e=>E(e),onCollapse:e=>E(e),className:"z-50"})})})]}),Ie("div",{className:"flex justify-end space-x-2",children:[Ie("button",{type:"button",onClick:t,disabled:h,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(Ln,{type:"submit",disabled:!c.trim(),loading:h,className:"df-fill-primary df-hover-primary-solid rounded px-2 py-1 text-xs font-medium transition disabled:opacity-50",children:s("create")})]})]})]})}),document.body)},Yn=(e,n)=>t.Temporal.PlainDate.compare(e,n),Fn=({calendarDays:e,visibleMonth:t,startDate:r,endDate:a,weekDayLabels:o,disabled:i,onDaySelect:l})=>Ie(n.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 n=e.month!==t.month,o=0===Yn(e,r),s=0===Yn(e,a),d=Yn(e,r)>=0&&Yn(e,a)<=0;return Ie("button",{type:"button",disabled:i,onClick:()=>l(e),className:`flex h-9 w-9 items-center justify-center rounded-md text-sm transition ${o||s?"df-fill-primary font-semibold":d?"df-tint-primary":n?"text-slate-300 dark:text-gray-600":"text-slate-700 dark:text-gray-300 df-hover-primary"}`,children:e.day},e.toString())})})]}),Vn=({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(nn,{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(en,{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(tn,{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(rn,{width:14,height:12})})]})]}),Zn=Array.from({length:24},(e,t)=>t),_n=Array.from({length:60},(e,t)=>t),zn=({focusedField:e,draftRange:t,disabled:n,onHourSelect:r,onMinuteSelect:a,timeListRefs:o})=>{const i=e,l=t["start"===i?0:1],s=l.minute,d=_n.includes(s)?_n:[..._n,s].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:[l.hour.toString().padStart(2,"0"),":",l.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 ${Tt} rounded-md border border-slate-100 bg-white dark:border-gray-600 dark:bg-gray-700`,role:"listbox","aria-label":"Hour",ref:e=>{o.current&&o.current[i]&&(o.current[i].hour=e)},children:Zn.map(e=>{const t=e===l.hour;return Ie("button",{type:"button",role:"option","aria-selected":t,disabled:n,onClick:()=>r(i,e),className:"flex h-8 w-full items-center justify-center text-sm transition "+(t?"df-fill-primary font-semibold":"df-hover-primary text-slate-600 dark:text-gray-300"),"data-active":t?"true":void 0,children:He(e)},e)})})}),Ie("div",{className:"w-14",children:Ie("div",{className:`h-72 overflow-y-auto ${Tt} rounded-md border border-slate-100 bg-white dark:border-gray-600 dark:bg-gray-700`,role:"listbox","aria-label":"Minute",ref:e=>{o.current&&o.current[i]&&(o.current[i].minute=e)},children:d.map(e=>{const t=e===s;return Ie("button",{type:"button",role:"option","aria-selected":t,disabled:n,onClick:()=>a(i,e),className:"flex h-8 w-full items-center justify-center text-sm transition "+(t?"df-fill-primary font-semibold":"df-hover-primary text-slate-600 dark:text-gray-300"),"data-active":t?"true":void 0,children:He(e)},e)})})})]})]})},Un=({visibleMonth:e,monthLabels:t,weekDayLabels:n,calendarDays:r,draftRange:a,focusedField:o,isTimeEnabled:i,disabled:l,matchTriggerWidth:s,popupRef:d,timeListRefs:c,onMonthChange:u,onYearChange:h,onDaySelect:g,onHourSelect:m,onMinuteSelect:f,onOk:p,getPopupStyle:v})=>{const y=a[0].toPlainDate(),b=a[1].toPlainDate();return Ie("div",{ref:d,className:"df-range-picker",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:s?"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(Vn,{visibleMonth:e,monthLabels:t,disabled:l,onMonthChange:u,onYearChange:h}),Ie(Fn,{calendarDays:r,visibleMonth:e,startDate:y,endDate:b,weekDayLabels:n,disabled:l,onDaySelect:g})]}),i&&Ie("div",{className:"flex flex-1 justify-end sm:w-32",children:Ie(zn,{focusedField:o,draftRange:a,disabled:l,onHourSelect:m,onMinuteSelect:f,timeListRefs:c})})]}),Ie("div",{className:"flex justify-end",children:Ie("button",{type:"button",onClick:p,disabled:l,className:"df-fill-primary df-hover-primary-solid inline-flex items-center rounded-full px-4 py-1.5 text-sm font-semibold shadow-sm transition disabled:cursor-not-allowed disabled:opacity-50",children:"OK"})})]})})},Wn=({value:e,format:n="YYYY-MM-DD HH:mm",showTimeFormat:o="HH:mm",showTime:i=!0,onChange:l,onOk:s,timeZone:d,disabled:c=!1,placement:u="bottomLeft",autoAdjustOverflow:h=!0,getPopupContainer:g,matchTriggerWidth:f=!1,locale:p="en-US"})=>{const v=a.useMemo(()=>"string"==typeof p?p:(null==p?void 0:p.code)||"en-US",[p]),y=a.useMemo(()=>void 0===i||("object"==typeof i||Boolean(i)),[i]),b=a.useMemo(()=>Dn(v,"short"),[v]),x=a.useMemo(()=>wn(v,"narrow"),[v]),w=a.useMemo(()=>y?"object"==typeof i&&(null==i?void 0:i.format)?i.format:o:"",[y,i,o]),D=a.useMemo(()=>Ae(n,w),[n,w]),E=a.useMemo(()=>Le(D),[D]),C=a.useMemo(()=>{const n=null!=d?d:m(e[0])?m(e[1])?t.Temporal.Now.timeZoneId():je(e[1]):je(e[0]),r=Ye(e[0],n).withTimeZone(n);return[r,Ye(e[1],n,r).withTimeZone(n)]},[e,d]),[T,k]=a.useState(C),S=a.useRef(C),[M,N]=a.useState("start"),[I,R]=a.useState([Fe(C[0],n,w),Fe(C[1],n,w)]),O=a.useRef([Fe(C[0],n,w),Fe(C[1],n,w)]),H=a.useRef(C),[A,P]=a.useState(C[0].toPlainDate().with({day:1})),[L,$]=a.useState(!1),j=a.useCallback(e=>{$(e)},[]),[Y,F]=a.useState(u),V=a.useRef(u),Z=a.useRef(null),_=a.useRef(null),z=a.useRef({start:{hour:null,minute:null},end:{hour:null,minute:null}}),U=a.useRef(!1),W=a.useRef(!1);a.useEffect(()=>{O.current=I},[I]),a.useEffect(()=>{H.current=T},[T]),a.useEffect(()=>{const e=S.current,n=0!==t.Temporal.ZonedDateTime.compare(e[0],C[0])||e[0].timeZoneId!==C[0].timeZoneId,r=0!==t.Temporal.ZonedDateTime.compare(e[1],C[1])||e[1].timeZoneId!==C[1].timeZoneId;(n||r)&&k(C),S.current=C},[C]),a.useEffect(()=>{P(C[0].toPlainDate().with({day:1}))},[C[0]]);const B=a.useCallback((e,t,n=0)=>{var r;if(!e||!t)return;const a=e.getBoundingClientRect(),o=t.getBoundingClientRect().top-a.top+e.scrollTop-n,i=(null===(r=window.matchMedia)||void 0===r?void 0:r.call(window,"(prefers-reduced-motion: reduce)").matches)?"auto":"smooth";Math.abs(e.scrollTop-o)>1&&e.scrollTo({top:o,behavior:i})},[]),G=a.useCallback(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=z.current[e];["hour","minute"].forEach(e=>{const n=t[e];if(!n)return;const r=n.querySelector('[data-active="true"]');r&&B(n,r,0)})})})},[B]);a.useEffect(()=>{L&&y&&G(M)},[M,L,G,y]);const K=T[0].epochMilliseconds,q=T[0].offsetNanoseconds,X=T[1].epochMilliseconds,J=T[1].offsetNanoseconds;a.useEffect(()=>{if(W.current)return;const[e,t]=H.current,r=Fe(e,n,w),a=Fe(t,n,w),[o,i]=O.current;o===r&&i===a||(O.current=[r,a],R([r,a]))},[K,q,X,J,n,w]),a.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)};return document.addEventListener("pointerdown",e,!0),()=>{document.removeEventListener("pointerdown",e,!0)}},[L]),a.useEffect(()=>{L||(N("start"),U.current||k(C),U.current=!1)},[L,C]);const Q=a.useCallback(e=>{l&&l(e,[Fe(e[0],n,w),Fe(e[1],n,w)])},[w,n,l]),ee=a.useCallback(e=>{s&&s(e,[Fe(e[0],n,w),Fe(e[1],n,w)])},[w,n,s]),te=a.useCallback((e,n)=>{k(r=>{const a=[...r];if("start"===e){const e=Ye(a[1],je(n),n),r=t.Temporal.ZonedDateTime.compare(n,e)>0?n:e;return[n,r]}const o=Ye(a[0],je(n),n);return[t.Temporal.ZonedDateTime.compare(o,n)>0?n:o,n]})},[]),ne=e=>{if(c)return;const n=(e,n)=>{var r,a,o,i;const l=je(e);return t.Temporal.ZonedDateTime.from({timeZone:l,year:n.year,month:n.month,day:n.day,hour:e.hour,minute:e.minute,second:null!==(r=e.second)&&void 0!==r?r:0,millisecond:null!==(a=e.millisecond)&&void 0!==a?a:0,microsecond:null!==(o=e.microsecond)&&void 0!==o?o:0,nanosecond:null!==(i=e.nanosecond)&&void 0!==i?i:0})};if("start"===M){const t=n(T[0],e),r=T[1].epochMilliseconds-T[0].epochMilliseconds,a=t.add({milliseconds:r});return void k([t,a])}const r=n(T[1],e),a=T[1].epochMilliseconds-T[0].epochMilliseconds;if(t.Temporal.ZonedDateTime.compare(r,T[0])<0){const t=n(T[0],e),r=t.add({milliseconds:a});return void k([t,r])}const o=[T[0],r];k(o),P(r.toPlainDate().with({day:1}))},re=a.useCallback((e,n)=>{if(c)return;const r="start"===e?0:1;k(a=>{const o=a[r],i=o.with({hour:n,minute:o.minute,second:0,millisecond:0,microsecond:0,nanosecond:0});if("start"===e){const e=Ye(a[1],je(i),i);return[i,t.Temporal.ZonedDateTime.compare(i,e)>0?i:e]}const l=Ye(a[0],je(i),i);return[t.Temporal.ZonedDateTime.compare(l,i)>0?i:l,i]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=z.current[e].hour;if(!t)return;const n=t.querySelector('[data-active="true"]');n&&B(t,n,0)})})},[c]),ae=a.useCallback((e,n)=>{if(c)return;const r="start"===e?0:1;k(a=>{const o=a[r].with({minute:n,second:0,millisecond:0,microsecond:0,nanosecond:0});if("start"===e){const e=Ye(a[1],je(o),o);return[o,t.Temporal.ZonedDateTime.compare(o,e)>0?o:e]}const i=Ye(a[0],je(o),o);return[t.Temporal.ZonedDateTime.compare(i,o)>0?o:i,o]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=z.current[e].minute;if(!t)return;const n=t.querySelector('[data-active="true"]');n&&B(t,n,0)})})},[c]),oe=a.useCallback((e,t)=>{const n="start"===e?0:1;R(e=>{const r=[...e];return r[n]=t,r})},[]),ie=a.useCallback((e,t)=>{const r="start"===e?0:1,a=T[r],o=je(a),i=$e(t,E,a,o);if(i){te(e,i);const t=i.toPlainDate().with({day:1});return P(t),"start"===e&&N("end"),!0}return R(e=>{const t=[...e];return t[r]=Fe(T[r],n,w),t}),!1},[T,w,n,E,te]),le=a.useCallback(e=>t=>{const n=t.currentTarget.value;W.current=!0,oe(e,n);const r="start"===e?0:1,a=H.current[r],o=je(a),i=$e(n,E,a,o);if(i){te(e,i);const t=i.toPlainDate().with({day:1});P(t),G(e)}},[oe,E,te,G]),se=a.useCallback(e=>t=>{var r;if(c)return;if(W.current=!1,L){const t="start"===e?0:1,r=Fe(H.current[t],n,w);return void R(e=>{const n=[...e];return n[t]=r,n})}const a=t.relatedTarget;a&&(null===(r=Z.current)||void 0===r?void 0:r.contains(a))||ie(e,t.currentTarget.value)},[ie,c,L,n,w]),de=a.useCallback(e=>t=>{"Enter"===t.key&&(t.preventDefault(),W.current=!1,ie(e,t.currentTarget.value)),"Escape"===t.key&&t.currentTarget.blur()},[ie]),ce=()=>{U.current=!0,Q(T),ee(T),j(!1)},ue=e=>{P(t=>t.add({months:e}).with({day:1}))},he=e=>{P(t=>t.add({years:e}).with({day:1}))},ge=a.useMemo(()=>{const e=A,t=e.dayOfWeek%7,n=e.subtract({days:t});return Array.from({length:42},(e,t)=>n.add({days:t}))},[A]),me=a.useCallback((e=u)=>{if(!h||!Z.current)return e;const t=Z.current.getBoundingClientRect(),n=f?t.width:480,r=window.innerHeight-t.bottom,a=t.top,o=window.innerWidth-t.left,i=t.right;let l=e;return l.startsWith("bottom")&&r<500&&a>r?l=l.replace("bottom","top"):l.startsWith("top")&&a<500&&r>a&&(l=l.replace("top","bottom")),l.endsWith("Left")&&o<n&&i>o?l=l.replace("Left","Right"):l.endsWith("Right")&&i<n&&o>i&&(l=l.replace("Right","Left")),l},[h,f,u]),fe=a.useCallback(()=>{const e=me();V.current!==e&&(V.current=e,F(e))},[me]),pe=e=>{if(c)return;N(e);const t=T["start"===e?0:1].toPlainDate().with({day:1});P(t);const n=me();V.current!==n&&(V.current=n,F(n)),j(!0)};a.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 ve=()=>{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,f&&(t.width=`${e.width}px`),t};return Ie("div",{className:"df-range-picker relative w-full min-w-0",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-white text-slate-400 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-500":L?"df-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:le("start"),onFocus:()=>pe("start"),onClick:()=>pe("start"),onBlur:se("start"),onKeyDown:de("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?"df-text-primary bg-white dark:bg-gray-700":"border-transparent bg-transparent text-slate-700 dark:text-gray-300"),placeholder:D,autoComplete:"off",disabled:c})}),Ie(hn,{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:le("end"),onFocus:()=>pe("end"),onClick:()=>pe("end"),onBlur:se("end"),onKeyDown:de("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?"df-text-primary bg-white dark:bg-gray-700":"border-transparent bg-transparent text-slate-700 dark:text-gray-300"),placeholder:D,autoComplete:"off",disabled:c})})]}),L&&(g?r.createPortal(Ie(Un,{visibleMonth:A,monthLabels:b,weekDayLabels:x,calendarDays:ge,draftRange:T,focusedField:M,isTimeEnabled:!!y,disabled:c,matchTriggerWidth:f,popupRef:_,timeListRefs:z,onMonthChange:ue,onYearChange:he,onDaySelect:ne,onHourSelect:re,onMinuteSelect:ae,onOk:ce,getPopupStyle:ve}),g()):r.createPortal(Ie(Un,{visibleMonth:A,monthLabels:b,weekDayLabels:x,calendarDays:ge,draftRange:T,focusedField:M,isTimeEnabled:!!y,disabled:c,matchTriggerWidth:f,popupRef:_,timeListRefs:z,onMonthChange:ue,onYearChange:he,onDaySelect:ne,onHourSelect:re,onMinuteSelect:ae,onOk:ce,getPopupStyle:ve}),document.body))]})},Bn=({options:e,value:t,onChange:n,registry:o,variant:i="desktop",disabled:l=!1})=>{const[s,d]=a.useState(!1),[c,u]=a.useState({}),h=a.useRef(null),g=a.useRef(null),m=()=>{if(g.current){const e=g.current.getBoundingClientRect(),t="mobile"===i,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)}};a.useEffect(()=>{const e=e=>{!h.current||h.current.contains(e.target)||e.target.closest("[data-calendar-picker-dropdown]")||d(!1)};return s&&(m(),window.addEventListener("mousedown",e),window.addEventListener("scroll",m,!0),window.addEventListener("resize",m)),()=>{window.removeEventListener("mousedown",e),window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",m)}},[s]);const f=e=>(o||I()).resolveColors(e).lineColor,p=(e,t)=>{e.stopPropagation(),n(t),d(!1)},v=e.find(e=>e.value===t),y=()=>s&&"undefined"!=typeof window?"mobile"===i?r.createPortal(Ie("div",{"data-calendar-picker-dropdown":"true",style:c,className:_t,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=>p(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(sn,{className:"df-text-primary h-4 w-4"})}),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:f(e.value)}})]},e.value))}),document.body):r.createPortal(Ie("ul",{"data-calendar-picker-dropdown":"true",style:c,className:"df-portal 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=>p(t,e.value),children:[t===e.value?Ie("span",{className:"df-text-primary mr-2 text-sm",children:Ie(sn,{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:f(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"===i?{className:"relative inline-block",ref:h,children:[Ie("button",{type:"button",ref:g,disabled:l,onClick:e=>{e.stopPropagation(),l||d(!s)},className:"flex items-center space-x-2 rounded-md bg-gray-100 px-3 py-1.5 transition-colors dark:bg-gray-700 "+(l?"cursor-default opacity-50":""),children:[Ie("span",{className:"h-3 w-3 rounded-full",style:{backgroundColor:f(t)}}),Ie("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-200",children:(null==v?void 0:v.label)||t}),Ie(dn,{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(!s)},className:"flex h-8 items-center space-x-2 rounded-md bg-gray-100 px-2 py-1 transition-colors hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",children:[Ie("span",{className:"h-4 w-4 shrink-0 rounded-sm",style:{backgroundColor:f(t)}}),Ie(dn,{className:"h-4 w-4 text-gray-600 dark:text-gray-300"})]}),y()]})},Gn=({event:n,isOpen:o,onEventUpdate:i,onEventDelete:l,onClose:s,app:d})=>{var c,u;const[h,g]=a.useState(n),[f,p]=a.useState(!1),[v,y]=a.useState(!1),b=a.useRef(n.id),{t:x}=bt();a.useEffect(()=>{g(n),b.current!==n.id&&(p(!1),y(!1),b.current=n.id)},[n]);const w=a.useMemo(()=>(d?d.getCalendarRegistry():I()).getVisible().map(e=>({label:e.name,value:e.id})),[d,null==d?void 0:d.getCalendars()]),D=a.useMemo(()=>!xe(n,h),[n,h]),E=a.useMemo(()=>{var e;return null!==(e=null==d?void 0:d.timeZone)&&void 0!==e?e:t.Temporal.Now.timeZoneId()},[d]),C=e=>{const[t,n]=e;g(Object.assign(Object.assign({},h),{start:t.toPlainDate(),end:n.toPlainDate()}))},T=null!==(c=null==d?void 0:d.canMutateFromUI(n.id))&&void 0!==c&&c,k=null==d?void 0:d.getReadOnlyConfig(n.id),S=!1!==(null==k?void 0:k.viewable),M=f||v,N=!a.useMemo(()=>{if(!n.calendarId)return!1;const e=null==d?void 0:d.getCalendarRegistry().get(n.calendarId);return!!(null==e?void 0:e.subscription)},[d,n.calendarId])||""!==(h.description||"").trim();if(!o||!S)return null;if("undefined"==typeof window||"undefined"==typeof document)return null;const R=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,disabled:M,className:"absolute top-4 right-4 text-gray-400 transition hover:text-gray-600 disabled:opacity-50 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:x("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-${h.id}`,name:"title",type:"text",value:h.title,readOnly:!T||M,disabled:!T||M,onChange:e=>{g(Object.assign(Object.assign({},h),{title:e.target.value}))},className:"df-focus-ring w-full rounded-lg border border-slate-200 px-3 py-1.5 text-sm text-gray-900 shadow-sm transition focus:ring-2 focus:outline-none disabled:opacity-50 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100"})}),T&&Ie(Bn,{options:w,value:h.calendarId||"blue",disabled:M,onChange:e=>{g(Object.assign(Object.assign({},h),{calendarId:e}))},registry:null==d?void 0:d.getCalendarRegistry()})]}),h.allDay?Ie("div",{className:"mb-4",children:[Ie("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:x("dateRange")}),Ie(Wn,{value:[h.start,h.end],format:"YYYY-MM-DD",showTime:!1,timeZone:E,matchTriggerWidth:!0,disabled:!T||M,onChange:C,onOk:C,locale:null==d?void 0:d.state.locale})]}):Ie("div",{className:"mb-4",children:[Ie("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:x("timeRange")}),Ie(Wn,{value:[h.start,h.end],timeZone:E,disabled:!T||M,onChange:e=>{const[t,n]=e;g(Object.assign(Object.assign({},h),{start:t,end:n}))},onOk:e=>{const[t,n]=e;g(Object.assign(Object.assign({},h),{start:t,end:n}))},locale:null==d?void 0:d.state.locale})]}),N&&Ie("div",{className:"mb-4",children:[Ie("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:x("note")}),Ie("textarea",{id:`event-dialog-note-${h.id}`,name:"note",value:null!==(u=h.description)&&void 0!==u?u:"",readOnly:!T||M,disabled:!T||M,onChange:e=>g(Object.assign(Object.assign({},h),{description:e.target.value})),rows:4,className:"df-focus-ring w-full resize-none rounded-lg border border-slate-200 px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:ring-2 focus:outline-none disabled:opacity-50 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",placeholder:x("addNotePlaceholder")})]}),T&&Ie("div",{className:"flex space-x-2",children:[h.allDay?Ie("button",{type:"button",disabled:M,className:"df-tint-primary df-hover-primary-md rounded-lg px-3 py-2 text-xs font-medium transition disabled:opacity-50",onClick:()=>{var e;const n=m(h.start)?h.start:h.start.toPlainDate(),r=null!==(e=null==d?void 0:d.timeZone)&&void 0!==e?e:t.Temporal.Now.timeZoneId(),a=t.Temporal.ZonedDateTime.from({year:n.year,month:n.month,day:n.day,hour:9,minute:0,timeZone:r}),o=t.Temporal.ZonedDateTime.from({year:n.year,month:n.month,day:n.day,hour:10,minute:0,timeZone:r});g(Object.assign(Object.assign({},h),{allDay:!1,start:a,end:o}))},children:x("setAsTimed")}):Ie("button",{type:"button",disabled:M,className:"df-tint-primary df-hover-primary-md rounded-lg px-3 py-2 text-xs font-medium transition disabled:opacity-50",onClick:()=>{const e=m(h.start)?h.start:h.start.toPlainDate();g(Object.assign(Object.assign({},h),{allDay:!0,start:e,end:e}))},children:x("setAsAllDay")}),Ie(Ln,{type:"button",disabled:M,className:"df-fill-destructive df-hover-destructive rounded-lg border border-border px-3 py-2 text-xs font-medium transition disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>e.__awaiter(void 0,void 0,void 0,function*(){if(!f&&!v){y(!0);try{yield l(n.id),s()}finally{y(!1)}}}),loading:v,children:x("delete")}),Ie(Ln,{type:"button",className:"df-fill-primary ml-auto rounded-lg px-3 py-2 text-xs font-medium transition "+(D?"df-shadow-primary df-hover-primary-solid shadow-lg":"cursor-not-allowed opacity-50 grayscale-[0.5]"),onClick:()=>e.__awaiter(void 0,void 0,void 0,function*(){if(!f&&!v){p(!0);try{yield i(ie(n,h,null==d?void 0:d.timeZone)),s()}finally{p(!1)}}}),disabled:!D||M,loading:f,children:x("save")})]})]})]})]}),O=document.body;return O?r.createPortal(R,O):null},Kn=e=>e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}),qn=({app:e,anchorRef:t,onClose:n,isOpen:o})=>{const{t:i}=bt(),[l,s]=a.useState(""),[d,c]=a.useState(0),[u,h]=a.useState(!1),g=a.useRef(null),m=a.useRef(null);a.useEffect(()=>{o||h(!1)},[o]),a.useEffect(()=>{o&&(setTimeout(()=>{var e;return null===(e=g.current)||void 0===e?void 0:e.focus()},50),s(""),c(0))},[o]),a.useEffect(()=>{const e=e=>{o&&m.current&&!m.current.contains(e.target)&&t.current&&!t.current.contains(e.target)&&n()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[o,n,t]);const[f,p]=a.useState({top:0,left:0}),[v,y]=a.useState("top"),[b,x]=a.useState(0),w=a.useMemo(()=>ae(e.timeZone),[e.timeZone,o]),D=a.useMemo(()=>{if(!l.trim())return[];const t=[],n=e.getCalendars(),r=e.getAllEvents(),a=l.toLowerCase(),o=r.find(e=>e.title.toLowerCase()===a);let i=null==o?void 0:o.calendarId;if(!i){const e=n.filter(e=>!1!==e.isVisible);if(e.length>0){const t=Math.floor(Math.random()*e.length);i=e[t].id}else n.length>0&&(i=n[0].id)}const s=n.find(e=>e.id===i),d=(null==s?void 0:s.colors.lineColor)||"#3b82f6";t.push({type:"new",title:l,calendarId:i||"",color:d,start:w.start,end:w.end});const c=new Set([l.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},[l,e,w]);a.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,i=window.innerWidth;a<o?a=o:a+r>i-o&&(a=i-r-o);const l=e.left+e.width/2;x(l-a);let s=0,d="top";e.top<n+20?(d="bottom",s=e.bottom+12):(d="top",s=e.top-12-n),y(d),p({top:s,left:a}),h(!0)}},[o,t,D]);const E=t=>{if(!t.calendarId)return;const r=De(),a={id:r,title:t.title,start:G(t.start,e.timeZone),end:G(t.end,e.timeZone),calendarId:t.calendarId,allDay:!1};e.addEvent(a),e.setCurrentDate(t.start),e.highlightEvent(r),n()};return a.useEffect(()=>{if(!o)return;const e=e=>{"ArrowDown"===e.key?(e.preventDefault(),c(e=>(e+1)%D.length)):"ArrowUp"===e.key?(e.preventDefault(),c(e=>(e-1+D.length)%D.length)):"Enter"===e.key&&(e.preventDefault(),D[d]&&E(D[d]))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[o,D,d]),o?r.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:f.top,left:f.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:i("quickCreateEvent")||"Quick Create Event"}),Ie("div",{className:"relative",children:Ie("input",{ref:g,type:"text",className:"df-focus-ring w-full rounded-lg border border-slate-200 px-3 py-1.5 text-sm text-gray-900 shadow-sm transition focus:ring-2 focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",placeholder:i("quickCreatePlaceholder")||"Enter title (e.g. Code review)",value:l,onChange:e=>s(e.target.value)})})]}),Ie("div",{className:"max-h-75 flex-1 overflow-y-auto px-2 py-1",children:[0===D.length&&l&&Ie("div",{className:"px-4 py-3 text-center text-sm text-gray-400",children:i("noSuggestions")||"Type to create"}),D.map((e,t)=>{return Ie("div",{className:"flex cursor-pointer items-center rounded-lg px-4 py-2 transition-colors "+(t===d?"df-tint-primary df-dark-tint-primary-md df-ring-primary ring-1 ring-inset":"hover:bg-gray-50 dark:hover:bg-slate-700/50"),onClick:()=>E(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?i("today"):i("tomorrow")})}),Ie("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:(n=e.start,r=e.end,`${Kn(n)} - ${Kn(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:b}})]}),document.body):null},Xn=({visibleMonth:e,currentDate:n,showHeader:r=!1,onMonthChange:o,onDateSelect:i,events:l=[],showEventDots:s=!1,calendarRegistry:d,timeZone:c})=>{const{locale:u}=bt(),h=a.useMemo(()=>{const e=c?t.Temporal.Now.plainDateISO(c):t.Temporal.Now.plainDateISO();return new Date(e.year,e.month-1,e.day).toDateString()},[c]),g=n.toDateString(),m=a.useMemo(()=>wn(u,"narrow"),[u]),f=a.useMemo(()=>e.toLocaleDateString(u,{month:"long",year:"numeric"}),[e,u]),p=a.useMemo(()=>{if(!s||!(null==l?void 0:l.length))return null;const e=new Map;return l.forEach(t=>{var n;const r=z(t.start,c),a=t.end?z(t.end,c):r,o=new Date(r);o.setHours(0,0,0,0);const i=new Date(a);i.setHours(0,0,0,0);let l=new Date(i);if(!t.allDay){0!==a.getHours()||0!==a.getMinutes()||0!==a.getSeconds()||0!==a.getMilliseconds()||l.setDate(l.getDate()-1)}l<o&&(l=new Date(o));const s=P(t.calendarId||"default",d).toLowerCase();for(let t=new Date(o);t<=l;t=new Date(t.getTime()+864e5)){const r=t.toDateString(),a=null!==(n=e.get(r))&&void 0!==n?n:[];!a.includes(s)&&a.length<4&&e.set(r,[...a,s])}}),e},[s,l,c,d]),v=a.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),i=o.toDateString();a.push({date:o.getDate(),fullDate:o,isCurrentMonth:o.getMonth()===n,isToday:i===h,isSelected:i===g})}return a},[e,g,h]);return Ie("div",{className:"px-3 py-3",children:[r?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:()=>o(-1),"aria-label":"Previous month",children:Ie(en,{className:"h-4 w-4"})}),Ie("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:f}),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:()=>o(1),"aria-label":"Next month",children:Ie(tn,{className:"h-4 w-4"})})]}):"",Ie("div",{className:"df-mini-calendar-grid grid grid-cols-7 gap-1 text-xs justify-items-center",children:[m.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}`)),v.map(e=>{var t;const n=null!==(t=null==p?void 0:p.get(e.fullDate.toDateString()))&&void 0!==t?t:[];return Ie("button",{type:"button",className:` df-mini-calendar-day text-center py-1 rounded text-xs h-6 w-6 ${e.isToday?Yt:e.isSelected?"df-fill-secondary rounded-full font-medium":e.isCurrentMonth?"text-gray-900 dark:text-gray-100":"text-gray-400 dark:text-gray-600"} relative flex flex-col items-center justify-center pt-1 pb-1`,onClick:()=>i(e.fullDate),children:[Ie("span",{className:"z-10",children:e.date}),s&&n.length>0&&Ie("div",{className:"absolute bottom-0.5 flex gap-px",children:n.slice(0,4).map((e,t)=>Ie("div",{"data-mini-calendar-dot":"true",className:"h-1 w-1 rounded-full",style:{backgroundColor:e}},`${e}-${t}`))})]},e.fullDate.getTime())})]})]})},Jn=({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":"")})}),Qn=({date:e,onChange:t})=>{const n=Array.from({length:24},(e,t)=>t),r=Array.from({length:12},(e,t)=>5*t),o=[...n,...n,...n],i=[...r,...r,...r],l=32,s=e.getHours(),d=5*Math.round(e.getMinutes()/5),c=(24+s)*l,u=(12+d/5)*l,[h,g]=a.useState(c),[m,f]=a.useState(u),p=a.useRef(null),v=a.useRef(null),y=a.useRef(null);a.useEffect(()=>{p.current&&(p.current.scrollTop=c,g(c)),v.current&&(v.current.scrollTop=u,f(u))},[c,u]);const b=(n,r)=>{const a=n.currentTarget;let s=a.scrollTop;if("hour"===r){const e=768;s<320?(s+=e,a.scrollTop=s):s>1600&&(s-=e,a.scrollTop=s),g(s)}else{const e=384;s<160?(s+=e,a.scrollTop=s):s>800&&(s-=e,a.scrollTop=s),f(s)}y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{((n,r)=>{const a=Math.round(r/l);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=i[a];if(void 0!==n&&5*Math.round(e.getMinutes()/5)!==n){const r=new Date(e);r.setMinutes(n),t(r)}}})(r,s)},150)},x=(e,t)=>{const n=96+e*l+16-(t+112),r=Math.min(Math.abs(n)/112,1);return{transform:`perspective(500px) rotateX(${-(n/112*80)}deg) scale(${1-.4*r})`,opacity:1-.7*r,transition:"transform 0.1s ease-out, opacity 0.1s ease-out"}};return 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:p,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=p.current)||void 0===a||a.scrollTo({top:r*l,behavior:"smooth"})},children:Ie("div",{className:"w-10 text-center text-xl transition-colors duration-200 "+(n===s?"font-bold text-black dark:text-white":"text-gray-400 dark:text-gray-500"),style:x(r,h),children:n.toString().padStart(2,"0")})},`h-${r}-${n}`)),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}}),i.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*l,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"})]})},er=({isOpen:e,onClose:t,onSave:n,onEventDelete:o,draftEvent:i,app:l,timeFormat:s="24h"})=>{const{locale:d,t:c}=bt(),u=l.getReadOnlyConfig(null==i?void 0:i.id),h=l.canMutateFromUI(null==i?void 0:i.id),g=!1!==u.viewable,[m,p]=a.useState(""),y=!a.useMemo(()=>{if(!(null==i?void 0:i.calendarId))return!1;const e=l.getCalendarRegistry().get(i.calendarId);return!!(null==e?void 0:e.subscription)},[l,null==i?void 0:i.calendarId])||""!==m.trim(),[b,x]=a.useState(""),[w,D]=a.useState(""),[E,C]=a.useState(!1),[T,k]=a.useState(new Date),[S,M]=a.useState(new Date),[N,I]=a.useState(new Date),[R,O]=a.useState(new Date),[H,A]=a.useState(null),[P,L]=a.useState(e),[$,j]=a.useState(!1),[Y,F]=a.useState(!1);a.useEffect(()=>{if(!e){j(!0);const e=setTimeout(()=>{L(!1),j(!1)},300);return()=>clearTimeout(e)}L(!0),j(!1)},[e]),a.useEffect(()=>{if(e&&i){const e=l.getEvents().some(e=>e.id===i.id);F(e)}},[e,i,l]);const V=l.getCalendars(),Z=V.map(e=>({label:e.name,value:e.id}));a.useEffect(()=>{if(e&&V.length>0){V.some(e=>e.id===w)||"blue"!==w&&""!==w||D(V[0].id)}},[V,e,w]),a.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]),a.useEffect(()=>{var t,n;if(e&&i){if(x(i.title||""),D(i.calendarId||(null===(t=V[0])||void 0===t?void 0:t.id)||"blue"),C(i.allDay||!1),i.start)try{const e=v(i.start);k(e),I(e)}catch(e){console.error("Failed to parse start date",e);const t=new Date;k(t),I(t)}if(i.end)try{const e=v(i.end);M(e),O(e)}catch(e){console.error("Failed to parse end date",e);const t=new Date;M(t),O(t)}}else if(e&&!i){D((null===(n=V[0])||void 0===n?void 0:n.id)||"blue");const e=new Date;e.setMinutes(0,0,0),k(e),I(e),M(new Date(e.getTime()+36e5)),O(e)}},[e,i]);const _=a.useMemo(()=>{if(!e||!i)return!1;const t=new Date(T),n=new Date(S),r=Object.assign(Object.assign({},i),{title:b,calendarId:w,allDay:E,description:m,start:E?W(t):f(t,l.timeZone),end:E?W(n):f(n,l.timeZone)});return!xe(i,ie(i,r,l.timeZone))},[e,i,b,w,E,T,S,m]);if(!P||!g)return null;const z=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(T.getHours(),T.getMinutes());const n=e.getTime()-T.getTime();k(e);const r=new Date(S.getTime()+n);M(r)}else{const e=new Date(t);e.setHours(S.getHours(),S.getMinutes()),M(e)}},G=(e,t)=>{"start"===e?I(e=>{const n=new Date(e);return n.setMonth(e.getMonth()+t),n}):O(e=>{const n=new Date(e);return n.setMonth(e.getMonth()+t),n})};return r.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 "+($?"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 "+($?"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&&Y?"viewEvent":Y?"editEvent":"newEvent")}),h&&Ie("button",{type:"button",onClick:()=>{if(!i)return;const e=new Date(T),t=new Date(S),r=Object.assign(Object.assign({},i),{title:b,calendarId:w,allDay:E,start:E?W(e):f(e,l.timeZone),end:E?W(t):f(t,l.timeZone)});n(ie(i,r,l.timeZone))},disabled:!_,className:"px-2 py-1 font-bold transition-colors "+(_?"df-text-primary":"cursor-not-allowed text-gray-400 opacity-50"),children:c(Y?"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:b,onChange:e=>h&&x(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(Bn,{options:Z,value:w,onChange:h?D:()=>{},registry:l.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(Jn,{checked:E,onChange:h?C:()=>{},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?"df-text-primary bg-gray-200 dark:bg-gray-700 dark:text-white":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"),onClick:()=>h&&z("start-date"),disabled:!h,children:U(T)}),!E&&Ie("button",{type:"button",className:"rounded-md px-3 py-1 transition-colors "+("start-time"===H?"df-text-primary bg-gray-200 dark:bg-gray-700 dark:text-white":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"),onClick:()=>h&&z("start-time"),disabled:!h,children:X(T.getHours()+T.getMinutes()/60,0,s)})]})]}),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(Xn,{currentDate:T,visibleMonth:N,onDateSelect:e=>B("start",e),onMonthChange:e=>G("start",e),showHeader:!0,events:l.getEvents(),calendarRegistry:l.getCalendarRegistry(),timeZone:l.timeZone})})}),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(Qn,{date:T,onChange:e=>{const t=S.getTime()-T.getTime();k(e),M(new Date(e.getTime()+t))},timeFormat:s})})})]}),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?"df-text-primary bg-gray-200 dark:bg-gray-700 dark:text-white":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"),onClick:()=>h&&z("end-date"),disabled:!h,children:U(S)}),!E&&Ie("button",{type:"button",className:"rounded-md px-3 py-1 transition-colors "+("end-time"===H?"df-text-primary bg-gray-200 dark:bg-gray-700 dark:text-white":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"),onClick:()=>h&&z("end-time"),disabled:!h,children:X(S.getHours()+S.getMinutes()/60,0,s)})]})]}),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(Xn,{currentDate:S,visibleMonth:R,onDateSelect:e=>B("end",e),onMonthChange:e=>G("end",e),showHeader:!0,events:l.getEvents(),calendarRegistry:l.getCalendarRegistry(),timeZone:l.timeZone})})}),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(Qn,{date:S,onChange:e=>{if(e<T){const t=S.getTime()-T.getTime();M(e),k(new Date(e.getTime()-t))}else M(e)},timeFormat:s})})})]}),y&&Ie("div",{className:"rounded-lg bg-white px-4 py-3 dark:bg-gray-900",children:Ie("textarea",{placeholder:c("notesPlaceholder"),value:m,onChange:e=>h&&p(e.currentTarget.value),readOnly:!h,className:"min-h-20 w-full bg-transparent text-base placeholder-gray-400 focus:outline-none"})}),h&&Y&&o&&i&&Ie("button",{type:"button",onClick:()=>o(i.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)},tr=()=>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"})}),nr=({loading:e,results:t,keyword:n,onResultClick:r,emptyText:o})=>{const{t:i,locale:l}=bt(),s=a.useMemo(()=>Ke(new Date),[]),d=a.useMemo(()=>Xe(t,s),[t,s]),c=e=>Ge(e);return e?Ie("div",{className:"flex h-40 flex-col items-center justify-center text-gray-500",children:[Ie(gn,{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(tr,{}),Ie("span",{className:"mt-2 text-sm",children:"string"==typeof o?o:o&&"object"==typeof o?o[l]||o.en||"No results found":i("noResults")||"No results found"})]}):null:Ie("div",{className:"space-y-6",children:d.map(e=>{const{title:t,colorClass:n}=qe(e.date,s,l,i);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),a={hour:"2-digit",minute:"2-digit"},o=e.allDay?i("allDay")||"All Day":t.toLocaleTimeString(l,a),s=e.allDay?"":n.toLocaleTimeString(l,a);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==r?void 0:r(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}),s&&Ie("div",{className:"text-gray-500 dark:text-gray-400",children:s})]})]})]})}),Ie("div",{className:"mx-2 border-b border-gray-200 dark:border-gray-700"})]},e.id)})})]},e.date.getTime())})})},rr=({isOpen:e,onClose:t,keyword:n,onSearchChange:o,results:i,loading:l,onResultClick:s,emptyText:d})=>{const c=a.useRef(null),{t:u}=bt();return a.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?r.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(yn,{className:"h-6 w-6"})}),Ie("div",{className:"relative flex-1",children:[Ie("input",{ref:c,type:"text",placeholder:u("search")||"Search",value:n,onChange:e=>{const t=e.target.value;t!==n&&o(t)},className:"df-focus-ring-only w-full rounded-full border-none bg-gray-100 py-2 pr-10 pl-3 text-gray-900 focus:ring-2 focus:outline-none dark:bg-gray-800 dark:text-gray-100"}),n&&Ie("button",{type:"button",onClick:()=>{""!==n&&o("")},className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400",children:Ie(cn,{className:"h-4 w-4"})})]})]}),Ie("div",{className:"flex-1 overflow-y-auto p-2 select-none",children:Ie(nr,{loading:l,results:i,keyword:n,onResultClick:e=>{null==s||s(e)},emptyText:d})})]}),document.body):null},ar=({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(nr,{loading:t,results:n,keyword:r,onResultClick:a,emptyText:o})})});let or=null;const ir={enabled:!1,width:"0px",isCollapsed:!1,toggleCollapsed:()=>{},miniWidth:"0px",content:null,extraContent:null,safeAreaLeft:0};function lr(e){return or&&e.hasPlugin("sidebar")?or(e):ir}const sr=({locale:e,messages:t,children:n})=>bt().isDefault?Ie(Cn,{locale:e,messages:t,children:n}):n,dr=({app:t,customDetailPanelContent:o,customEventDetailDialog:i,meta:l,customMessages:s,search:d,titleBarSlot:c,collapsedSafeAreaLeft:u})=>{const h=a.useContext(Rn),{tick:g,selectedEventId:f}=function(e){const[t,n]=a.useState(0),[r,o]=a.useState(null);return a.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:r}}(t),{isMobile:p}=function(){const[e,t]=a.useState(!1);return a.useEffect(()=>{const e=()=>{t(window.matchMedia("(max-width: 768px)").matches)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),{isMobile:e}}(),y=function(t,n){const[r,o]=a.useState(""),[i,l]=a.useState(!1),[s,d]=a.useState(!1),[c,u]=a.useState(!1),[h,g]=a.useState([]),m=a.useRef(""),f=a.useRef(!1);a.useEffect(()=>{t.state.highlightedEventId&&t.selectEvent(t.state.highlightedEventId)},[t.state.highlightedEventId,t]),a.useEffect(()=>{f.current&&!i&&null!==t.state.highlightedEventId&&t.highlightEvent(null),f.current=i},[i,t]),a.useEffect(()=>{var a;if(!r.trim())return l(!1),g([]),m.current.trim()&&null!==t.state.highlightedEventId&&t.highlightEvent(null),void(m.current=r);const o=null!==(a=null==n?void 0:n.debounceDelay)&&void 0!==a?a:300,i=setTimeout(()=>e.__awaiter(this,void 0,void 0,function*(){var e;u(!0),l(!0);try{let a=[];if(null==n?void 0:n.customSearch){const e=t.getEvents().map(e=>{var n;return Object.assign(Object.assign({},e),{color:(null===(n=t.getCalendarRegistry().get(e.calendarId||""))||void 0===n?void 0:n.colors.lineColor)||t.getCalendarRegistry().resolveColors().lineColor})});a=n.customSearch({keyword:r,events:e})}else if(null==n?void 0:n.onSearch)a=yield n.onSearch(r);else{const e=r.toLowerCase();a=t.getEvents().filter(t=>t.title.toLowerCase().includes(e)||t.description&&t.description.toLowerCase().includes(e)).map(e=>{var n;return Object.assign(Object.assign({},e),{color:(null===(n=t.getCalendarRegistry().get(e.calendarId||""))||void 0===n?void 0:n.colors.lineColor)||t.getCalendarRegistry().resolveColors().lineColor})})}g(a),null===(e=null==n?void 0:n.onSearchStateChange)||void 0===e||e.call(n,{keyword:r,loading:!1,results:a})}catch(e){console.error("Search failed",e),g([])}finally{u(!1)}}),o);return m.current=r,()=>clearTimeout(i)},[r,n,t]);const p=a.useCallback((e,r="desktop")=>{const a=()=>{let n;n=e.start instanceof Date?e.start:"string"==typeof e.start?new Date(e.start):v(e.start),t.setCurrentDate(n),t.highlightEvent(e.id),s&&d(!1)},o=()=>{"mobile"===r?d(!1):l(!1),t.highlightEvent(null)};(null==n?void 0:n.onResultClick)?n.onResultClick({event:e,app:t,source:r,defaultAction:a,closeSearch:o}):a()},[t,s,n]),y=a.useCallback(()=>{o(""),d(!0)},[]),b=a.useCallback(()=>{l(!1),o(""),t.highlightEvent(null)},[t]),x=a.useCallback(()=>{d(!1),o(""),t.highlightEvent(null)},[t]);return{searchKeyword:r,setSearchKeyword:o,isSearchOpen:i,setIsSearchOpen:l,isMobileSearchOpen:s,setIsMobileSearchOpen:d,searchLoading:c,searchResults:h,handleSearchResultClick:p,handleSearchClick:y,handleSearchClose:b,handleMobileSearchClose:x}}(t,d),b=i||(t.getUseEventDetailDialog()?Gn:void 0),x=function(t,n,r){const[o,i]=a.useState(null),l=a.useRef(null);a.useEffect(()=>{i(null),l.current=null},[t]);const s=a.useCallback(()=>{i(null),l.current=null,t.selectEvent(null)},[t]),d=a.useCallback(e=>t.updateEvent(e.id,e),[t]),c=a.useCallback(n=>e.__awaiter(this,void 0,void 0,function*(){yield t.deleteEvent(n),i(null),t.selectEvent(null)}),[t]),u=a.useMemo(()=>{var e;if(!n||!o)return null;const r=o.split("::")[0],a=t.getEvents().find(e=>e.id===r);a&&(l.current=a);const i=null!=a?a:(null===(e=l.current)||void 0===e?void 0:e.id)===r?l.current:null;return i?{event:i,isOpen:!0,isAllDay:m(i.start),onEventUpdate:d,onEventDelete:c,onClose:s,app:t}:null},[r,o,n,s,d,c,t]);return{detailPanelEventId:o,setDetailPanelEventId:i,dialogProps:u}}(t,b,g),w=lr(t),D=function(e,t,n){const[r,o]=a.useState(!1),i=a.useRef(null),[l,s]=a.useState(!1),[d,c]=a.useState(null),[u,h]=a.useState(!1),g=a.useCallback(()=>{h(!0)},[]),m=a.useCallback(a=>{var l,d;if(e.canMutateFromUI()){if(t){const{start:t,end:n}=ae(e.timeZone),r={id:De(),title:"",start:G(t,e.timeZone),end:G(n,e.timeZone),calendarId:(null===(l=e.getCalendars().find(e=>!1!==e.isVisible))||void 0===l?void 0:l.id)||(null===(d=e.getCalendars()[0])||void 0===d?void 0:d.id)};return c(r),void s(!0)}n?r?o(!1):(i.current=a.currentTarget,o(!0)):g()}},[t,r,e,n,g]);return{isQuickCreateOpen:r,setIsQuickCreateOpen:o,quickCreateAnchorRef:i,isMobileDrawerOpen:l,setIsMobileDrawerOpen:s,mobileDraftEvent:d,setMobileDraftEvent:c,handleAddButtonClick:m,isCreateCalendarOpen:u,setIsCreateCalendarOpen:h}}(t,p,w.enabled),[E,C]=a.useState(()=>t.getTheme());a.useEffect(()=>t.subscribeThemeChange(e=>C(e)),[t]);const T=a.useCallback(e=>t.setTheme(e),[t]);a.useEffect(()=>{const e=t.callbacks,n=e.onDismissUI;return e.onDismissUI=()=>{x.detailPanelEventId&&x.setDetailPanelEventId(null),D.isMobileDrawerOpen&&D.setIsMobileDrawerOpen(!1),null==n||n()},()=>{e.onDismissUI=n}},[t,x,D]),a.useEffect(()=>{if(!p||!x.detailPanelEventId)return;const e=x.detailPanelEventId.split("::")[0],n=t.getEvents().find(t=>t.id===e);n&&(D.setMobileDraftEvent(n),D.setIsMobileDrawerOpen(!0)),x.setDetailPanelEventId(null)},[x.detailPanelEventId,p]);const k=a.useCallback(e=>{t.setCurrentDate(e),t.selectEvent(null)},[t]),S=a.useCallback(e=>t.selectEvent(e),[t]),M=a.useRef(null),N={app:t,config:t.getCurrentView().config||{},customDetailPanelContent:o,customEventDetailDialog:b,switcherMode:t.state.switcherMode,calendarRef:M,meta:l,selectedEventId:f,onEventSelect:S,onDateChange:k,detailPanelEventId:x.detailPanelEventId,onDetailPanelToggle:x.setDetailPanelEventId},I=a.useMemo(()=>({isCollapsed:w.isCollapsed,toggleCollapsed:w.toggleCollapsed}),[w.isCollapsed,w.toggleCollapsed]),R=void 0!==u,O=R?"0px":w.miniWidth,H=R&&w.isCollapsed?u:w.safeAreaLeft,A=t.getCalendarHeaderConfig(),P=Object.assign({calendar:t,switcherMode:t.state.switcherMode,onAddCalendar:D.handleAddButtonClick,onSearchChange:y.setSearchKeyword,onSearchClick:y.handleSearchClick,searchValue:y.searchKeyword,isSearchOpen:y.isSearchOpen,isEditable:t.canMutateFromUI()},H>0?{safeAreaLeft:H}:{}),L=t.getCurrentView().component,$=t.getCustomMobileEventRenderer()||er;return Ie(Nn,{initialTheme:E,onThemeChange:T,children:Ie(sr,{locale:t.state.locale,messages:s,children:Ie("div",{className:"df-calendar-container relative flex flex-row overflow-hidden select-none",children:[Ie(Hn,{store:h,generatorName:"titleBarSlot",generatorArgs:I,defaultContent:c&&("function"==typeof c?c(I):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?O:w.width:0},children:[!1===A?null:"function"==typeof A?A(P):n.h(Sn,P),Ie("div",{className:"relative flex-1 overflow-hidden",ref:M,children:[Ie("div",{className:"calendar-renderer relative flex h-full flex-row",children:[Ie("div",{className:"h-full flex-1 overflow-hidden",children:Ie(L,Object.assign({},N))}),Ie(ar,{isOpen:y.isSearchOpen,onClose:y.handleSearchClose,loading:y.searchLoading,results:y.searchResults,keyword:y.searchKeyword,onResultClick:e=>y.handleSearchResultClick(e,"desktop"),emptyText:null==d?void 0:d.emptyText})]}),Ie(rr,{isOpen:y.isMobileSearchOpen,onClose:y.handleMobileSearchClose,keyword:y.searchKeyword,onSearchChange:y.setSearchKeyword,results:y.searchResults,loading:y.searchLoading,onResultClick:e=>y.handleSearchResultClick(e,"mobile"),emptyText:null==d?void 0:d.emptyText})]})]}),Ie(qn,{app:t,anchorRef:D.quickCreateAnchorRef,isOpen:D.isQuickCreateOpen,onClose:()=>D.setIsQuickCreateOpen(!1)}),Ie($,{isOpen:D.isMobileDrawerOpen,onClose:()=>{D.setIsMobileDrawerOpen(!1),D.setMobileDraftEvent(null)},onSave:e=>{t.getEvents().some(t=>t.id===e.id)?t.updateEvent(e.id,e):t.addEvent(e),D.setIsMobileDrawerOpen(!1),D.setMobileDraftEvent(null)},onEventDelete:e=>{t.deleteEvent(e),D.setIsMobileDrawerOpen(!1),D.setMobileDraftEvent(null)},draftEvent:D.mobileDraftEvent,app:t}),w.extraContent,D.isCreateCalendarOpen&&Ie(jn,{app:t,onClose:()=>D.setIsCreateCalendarOpen(!1),onCreate:n=>e.__awaiter(void 0,void 0,void 0,function*(){yield t.createCalendar(n),D.setIsCreateCalendarOpen(!1)})}),(()=>{if(!x.dialogProps)return null;const e=b,t="undefined"==typeof document?null:document.body;if(!t)return null;const a=null==h?void 0:h.isOverridden("eventDetailDialog");return Ie(Hn,{store:h,generatorName:"eventDetailDialog",generatorArgs:x.dialogProps,defaultContent:a?null:r.createPortal(n.h(e,x.dialogProps),t)})})()]})})})};class cr{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 ur=r.forwardRef(({x:e,y:t,onClose:n,children:o,className:i},l)=>{const s=a.useRef(null);a.useEffect(()=>{const e=()=>n(),t=e=>{if(s.current&&!s.current.contains(e.target)){if(e.target.closest("[data-submenu-content]"))return;n()}};window.dispatchEvent(new CustomEvent("dayflow-close-all-menus")),window.addEventListener("dayflow-close-all-menus",e),document.body.addEventListener("mousedown",t,{capture:!0}),document.body.addEventListener("contextmenu",t,{capture:!0});const r=e=>{"Escape"===e.key&&n()};window.addEventListener("keydown",r);const a=()=>n();return window.addEventListener("scroll",a,!0),window.addEventListener("resize",a),()=>{window.removeEventListener("dayflow-close-all-menus",e),document.body.removeEventListener("mousedown",t,{capture:!0}),document.body.removeEventListener("contextmenu",t,{capture:!0}),window.removeEventListener("keydown",r),window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",a)}},[n]);const d={top:t,left:e};return r.createPortal(Ie("div",{ref:e=>{s.current=e,"function"==typeof l?l(e):l&&"current"in l&&(l.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 ${i||""}`,style:d,onContextMenu:e=>e.preventDefault(),"data-context-menu-root":"true",children:o}),document.body)});ur.displayName="ContextMenu";const hr=({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?"df-text-destructive df-hover-fill-destructive df-focus-fill-destructive":"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]}),gr=()=>Ie("div",{className:"-mx-1 my-1 h-px bg-slate-200 dark:bg-slate-800"}),mr=({children:e})=>{const[t,r]=a.useState(!1),o=a.useRef(null);return a.useEffect(()=>()=>{o.current&&clearTimeout(o.current)},[]),Ie("div",{className:"relative",onMouseEnter:()=>{o.current&&(clearTimeout(o.current),o.current=null),r(!0)},onMouseLeave:()=>{o.current=setTimeout(()=>{r(!1)},100)},children:(Array.isArray(e)?e:[e]).map(e=>n.isValidElement(e)?n.cloneElement(e,{isOpen:t}):e)})},fr=({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(tn,{className:"ml-auto h-4 w-4 "+(n?"text-white opacity-100":"opacity-60")})]}),pr=({children:e,isOpen:t})=>{const n=a.useRef(null),[r,o]=a.useState("right");return a.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"===r?"100%":"auto",right:"left"===r?"100%":"auto",marginLeft:"right"===r?"0.25rem":0,marginRight:"left"===r?"0.25rem":0},"data-submenu-content":"true",children:e}):null},vr=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],yr=({x:t,y:n,date:r,onClose:a,app:o,onCreateEvent:i,viewType:l})=>{const{t:s}=bt();if(!o.canMutateFromUI())return null;const d=Je.hasEvent();return Ie(ur,{x:t,y:n,onClose:a,className:"df-context-menu",children:[Ie(hr,{onClick:()=>{i(),a()},children:s("newEvent")||"New Event"}),Ie(hr,{onClick:()=>e.__awaiter(void 0,void 0,void 0,function*(){yield((t,n,r)=>e.__awaiter(void 0,void 0,void 0,function*(){if(Je.hasEvent())try{let e=Je.getEvent();if(!e){const t=yield navigator.clipboard.readText();t&&(e=JSON.parse(t))}if(e&&"object"==typeof e&&"title"in e){const a=e,o=_(a.start),i=_(a.end).getTime()-o.getTime(),l=e,s=new Date(n),d=r===exports.ViewType.MONTH||r===exports.ViewType.YEAR,c=0===s.getHours()&&0===s.getMinutes(),u=0!==o.getHours()||0!==o.getMinutes();!a.allDay&&(d||c&&u)&&s.setHours(o.getHours(),o.getMinutes(),o.getSeconds(),o.getMilliseconds());const h=new Date(s.getTime()+(i>0?i:36e5)),g=Object.assign(Object.assign({},l),{title:a.title,id:De(),start:a.allDay?W(s):G(s,t.timeZone),end:a.allDay?W(h):G(h,t.timeZone),calendarId:a.calendarId&&t.getCalendarRegistry().has(a.calendarId)?a.calendarId:t.getCalendarRegistry().getDefaultCalendarId()||"default"});t.addEvent(g)}}catch(e){console.error("Failed to paste event:",e)}}))(o,r,l),a()}),disabled:!d,children:s("pasteHere")||"Paste Here"})]})},br=({event:t,x:r,y:a,onClose:o,app:i})=>{var l;const{t:s}=bt();if(!i.canMutateFromUI(t.id))return null;const d=i.getCalendars(),c=i.callbacks,u=null===(l=null==c?void 0:c.renderEventContextMenu)||void 0===l?void 0:l.call(c,t,o);return Ie(ur,{x:r,y:a,onClose:o,children:[Ie(mr,{children:[Ie(fr,{children:s("calendars")||"Calendars"}),Ie(pr,{children:d.map(e=>{const n=e.id===t.calendarId;return Ie(hr,{onClick:()=>{return n=e.id,i.updateEvent(t.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(sn,{className:"df-text-primary h-3 w-3"})}),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:e.colors.lineColor}}),Ie("span",{className:"truncate "+(n?"font-semibold":""),children:e.name})]})]})},e.id)})})]}),Ie(gr,{}),Ie(hr,{onClick:()=>{i.deleteEvent(t.id),o()},danger:!0,children:s("delete")||"Delete"}),Ie(hr,{onClick:()=>e.__awaiter(void 0,void 0,void 0,function*(){try{const e=JSON.stringify(t,null,2);yield navigator.clipboard.writeText(e),Je.setEvent(t),i.deleteEvent(t.id)}catch(e){console.error("Failed to cut event: ",e)}o()}),children:s("cut")||"Cut"}),Ie(hr,{onClick:()=>e.__awaiter(void 0,void 0,void 0,function*(){try{const e=JSON.stringify(t,null,2);yield navigator.clipboard.writeText(e),Je.setEvent(t)}catch(e){console.error("Failed to copy event: ",e)}o()}),children:s("copy")||"Copy"}),u&&Ie(n.Fragment,{children:[Ie(gr,{}),u]})]})},xr=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(mn,{className:"h-3 w-3"}):t.includes("birthday")||t.includes("anniversary")||t.includes("生日")?Ie(fn,{className:"h-3 w-3"}):t.includes("conference")||t.includes("meeting")||t.includes("会议")||t.includes("研讨")?Ie(vn,{className:"h-3 w-3"}):t.includes("trip")||t.includes("travel")||t.includes("旅行")?Ie(pn,{className:"h-3 w-3"}):Ie(un,{className:"h-3 w-3"})},wr=(e,t,n=7,r)=>{const a=[],o=new Date(t);return o.setDate(t.getDate()+(n-1)),o.setHours(23,59,59,999),e.forEach(e=>{const i=z(e.start,r),l=e.end?z(e.end,r):i,s=new Date(i);s.setHours(0,0,0,0);const d=new Date(l);d.setHours(0,0,0,0);let c=new Date(d);if(!e.allDay){if(!(0!==l.getHours()||0!==l.getMinutes()||0!==l.getSeconds())){const e=l.getTime()-i.getTime();e>0&&e<864e5&&(c=new Date(d),c.setDate(c.getDate()-1))}}const u=D(s,c)>0;if(!u&&e.allDay){if(s<t||s>o)return;const r=Math.floor((s.getTime()-t.getTime())/864e5);return void(r>=0&&r<=n-1&&a.push({id:`${e.id}-week-${t.getTime()}`,originalEventId:e.id,event:e,startDayIndex:r,endDayIndex:r,segmentType:"single",totalDays:1,segmentIndex:0,isFirstSegment:!0,isLastSegment:!0}))}if(!u)return;const h=s;let g;if(e.allDay)g=new Date(d),g.setHours(23,59,59,999);else{0!==l.getHours()||0!==l.getMinutes()||0!==l.getSeconds()?(g=new Date(d),g.setHours(23,59,59,999)):(g=new Date(d),g.setTime(g.getTime()-1))}if(g<t||h>o)return;const m=h<t?t:h,f=g>o?o:g,p=Math.max(0,Math.floor((m.getTime()-t.getTime())/864e5)),v=Math.min(n-1,Math.floor((f.getTime()-t.getTime())/864e5)),y=h>=t,b=g<=o,x=0===p||v===n-1;let w;w=y&&b?"single":y?x&&v===n-1?"start-week-end":"start":b?x&&0===p?"end-week-start":"end":"middle";const E=D(h,g)+1;a.push({id:`${e.id}-week-${t.getTime()}`,originalEventId:e.id,event:e,startDayIndex:p,endDayIndex:v,segmentType:w,totalDays:E,segmentIndex:0,isFirstSegment:y,isLastSegment:b})}),a},Dr=(e,t,n=7,r)=>{if(e.allDay)return[];const a=z(e.start,r),o=e.end?z(e.end,r):a,i=new Date(a);i.setHours(0,0,0,0);const l=new Date(o);l.setHours(0,0,0,0);const s=D(i,l);if(0===s)return[];const d=0!==o.getHours()||0!==o.getMinutes()||0!==o.getSeconds()||0!==o.getMilliseconds(),c=o.getTime()-a.getTime();if(!e.allDay&&1===s&&!d&&c<864e5)return[];const u=d?s:Math.max(0,s-1),h=[];for(let e=0;e<=u;e++){const r=new Date(i);r.setDate(i.getDate()+e);const l=Math.floor((r.getTime()-t.getTime())/864e5);if(l<0||l>n-1)continue;const s=0===e,c=e===u,g=s?a.getHours()+a.getMinutes()/60:0,m=c&&d?o.getHours()+o.getMinutes()/60:24;h.push({dayIndex:l,startHour:g,endHour:m,isFirst:s,isLast:c})}return h},Er=r.memo(({segment:e,segmentIndex:t,isDragging:r,isResizing:o=!1,isSelected:i=!1,onMoveStart:l,onResizeStart:s,onEventLongPress:d,isMobile:c=!1,isDraggable:u=!0,isEditable:h=!0,viewable:g=!0,isPopping:m,renderSlot:f,appTimeZone:p})=>{const[v,y]=a.useState(!1),b=a.useMemo(()=>{if(!p||e.event.allDay)return e.event;const t=U(e.event.start,p),n=e.event.end?U(e.event.end,p):void 0;return Object.assign(Object.assign({},e.event),{start:t,end:n})},[e.event,p]),x=17*t,w=`calc(${e.startDayIndex/7*100}% + 2px)`,D=`calc(${(e.endDayIndex-e.startDayIndex+1)/7*100}% - 4px)`,C=a.useRef(null),T=a.useRef(null),k=t=>{const n="left"===t;return(n?e.isFirstSegment:e.isLastSegment)&&s&&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(),s(t,e.event,n?"left":"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}):null},S=()=>{const t=b.allDay,n=b.calendarId||"blue",r=E(b.start),a=J(b),o=X(r),i=X(a);if(t){const t=()=>e.isFirstSegment?b.title:"middle"===e.segmentType||e.isLastSegment&&e.totalDays>1?"···":b.title;return Ie("div",{className:"pointer-events-auto flex w-full min-w-0 items-center",children:[e.isFirstSegment&&xr(b)&&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:P(n),width:"12px",height:"12px"},children:xr(b)})}),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 l=e.isFirstSegment||e.isLastSegment?b.title:"···",s=e.endDayIndex-e.startDayIndex+1,d=s>1?{position:"absolute",right:`calc(${s>1?(s-1)/s*100:0}% + 2px)`,top:"50%",transform:"translateY(-50%)"}:void 0;return Ie("div",{className:"pointer-events-auto relative flex w-full min-w-0 items-center",children:[Ie("div",{className:Pt,style:{backgroundColor:P(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:l})}),e.isFirstSegment&&!c&&Ie("span",{className:"text-xs font-medium whitespace-nowrap "+(1===s?"ml-2":""),style:d,children:o}),e.isLastSegment&&!b.allDay&&24!==a&&!c&&Ie("span",{className:"ml-auto text-xs font-medium whitespace-nowrap",children:`ends ${i}`})]})},M=e.event.calendarId||"blue",N=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:w,width:D,top:`${x}px`,height:"16px",borderRadius:(I=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"}[I]),pointerEvents:"auto",zIndex:10,transform:m?"scale(1.02)":"scale(1)",transition:"transform 0.5s cubic-bezier(0.22, 1, 0.36, 1)",willChange:"transform"},i||r||v?{backgroundColor:A(M),color:"#fff"}:{backgroundColor:O(M),color:H(M)}),{cursor:u||g?"pointer":"default"}),"data-segment-days":N,onMouseDown:t=>{if(!u&&!g)return;t.preventDefault(),t.stopPropagation(),y(!0);!t.target.closest(".resize-handle")&&u&&(null==l||l(t,e.event))},onMouseUp:()=>{y(!1)},onMouseLeave:()=>{y(!1)},onTouchStart:t=>{if(!l||!c||!u&&!g)return;t.stopPropagation(),y(!0);const n=t.touches[0],r=n.clientX,a=n.clientY,o=t.currentTarget;T.current={x:r,y:a},C.current=setTimeout(()=>{d&&d(e.event.id);u&&l({preventDefault:()=>{},stopPropagation:()=>{},currentTarget:o,touches:[{clientX:r,clientY:a}],cancelable:!1},e.event),C.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},onTouchMove:e=>{if(C.current&&T.current){const t=Math.abs(e.touches[0].clientX-T.current.x),n=Math.abs(e.touches[0].clientY-T.current.y);(t>10||n>10)&&(clearTimeout(C.current),C.current=null,T.current=null,y(!1))}},onTouchEnd:()=>{y(!1),C.current&&(clearTimeout(C.current),C.current=null),T.current=null},title:`${b.title} (${Re(b.start)} - ${Re(b.end)})`,children:[c&&i&&h&&Ie(n.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:P(M)},onTouchStart:t=>{t.stopPropagation(),null==s||s(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:P(M)},onTouchStart:t=>{t.stopPropagation(),null==s||s(t,e.event,"right")}})]}),k("left"),Ie("div",{className:"min-w-0 flex-1",style:{cursor:o?"ew-resize":"pointer"},children:f?f(S()):S()}),k("right")]});var I});Er.displayName="MultiDayEvent";const Cr=({event:e,isEditable:t,onResizeStart:r,isMultiDay:a,segment:o,isSlidingView:i,renderSlot:l})=>{const s=!1!==e.icon,d="boolean"==typeof e.icon?null:e.icon,c=(()=>{if(!i||!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:[s&&(d?Ie("div",{className:"mr-1 shrink-0",children:d}):Ie(un,{className:Lt})),Ie("div",{className:`${At} 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:[l?l(u):u,r&&t&&Ie(n.Fragment,{children:[Ie("div",{className:$t,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),r(t,e,"left")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}),Ie("div",{className:jt,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),r(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]})]})},Tr=({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(un,{className:`${Lt} ${t?"text-white":""}`})),Ie("span",{className:"truncate "+(t?"text-white":""),children:e.title})]})},kr=({event:e,app:t,isEventSelected:n,hideTime:r,isMobile:a})=>{const o=`${Math.floor(E(e.start)).toString().padStart(2,"0")}:${Math.round(E(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:P(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())},className:Pt}),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:`${Kt} ml-1 shrink-0 ${n?"text-white":""}`,style:n?void 0:{opacity:.8},children:o})]})},Sr=({event:e,app:t,multiDaySegmentInfo:r,isEditable:a,isTouchEnabled:o,isEventSelected:i,onResizeStart:l,timeFormat:s="24h",resizeHandleOrientation:d="vertical",renderSlot:c})=>{const u=r?r.startHour:E(e.start),h=r?r.endHour:J(e),g=h-u,m=!r||r.isFirst,f=!r||r.isLast,p=e.calendarId||"blue",v=!r&&g<=.25?"px-1 py-0":"p-1",y=Ie(n.Fragment,{children:[Ie("div",{className:"df-event-color-bar absolute left-1 top-1 bottom-1 w-[3px] rounded-full",style:{backgroundColor:P(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())}}),Ie("div",{className:`flex h-full flex-col overflow-hidden pl-3 ${v}`,children:[Ie("div",{className:`${At} 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?`${X(u,0,s)} - ${X(h,0,s)}`:Q(e,s)})]})]});return Ie(n.Fragment,{children:[c?c(y):y,l&&a&&"vertical"===d&&Ie(n.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=>l(t,e,"top")}),f&&Ie("div",{className:"absolute bottom-0 left-0 w-full h-1.5 cursor-ns-resize z-10 rounded-b-sm",onMouseDown:t=>l(t,e,"bottom")}),!m&&f&&r&&Ie("div",{className:jt,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),l(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]}),o&&i&&l&&a&&"vertical"===d&&Ie(n.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:P(p,null==t?void 0:t.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),l(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:P(p,null==t?void 0:t.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),l(t,e,"bottom")}})]}),l&&a&&"horizontal"===d&&Ie(n.Fragment,{children:[Ie("div",{className:$t,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),l(t,e,"left")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}),Ie("div",{className:jt,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),l(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]})]})},Mr=({event:e,segment:t,isEditable:r,onMoveStart:a,onResizeStart:o,renderSlot:i})=>{const l=!!e.allDay,s=e.calendarId||"blue",d=P(s),c=l?xr(e):null,{isFirstSegment:u,isLastSegment:h}=t,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(l){const n=()=>t.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:[t.isFirstSegment&&xr(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:P(s),width:"12px",height:"12px"},children:xr(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:n()})}),t.isLastSegment&&!t.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 n=t.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:[!l&&Ie("span",{style:{backgroundColor:d},className:"df-year-event-indicator inline-block h-3 w-0.75 shrink-0 rounded-full"}),l&&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:n})]})};return Ie(n.Fragment,{children:[g("left"),i?i(m()):m(),g("right")]})};const Nr=({event:e,viewType:t,isAllDay:n,isMultiDay:r,segment:a,yearSegment:o,segmentIndex:i,isBeingDragged:l,isBeingResized:s,isEventSelected:d,isPopping:c,isEditable:u,isDraggable:h,canOpenDetail:g,isTouchEnabled:m,hideTime:f,isMobile:p,isSlidingView:v,app:y,onMoveStart:b,onResizeStart:x,multiDaySegmentInfo:w,customRenderingStore:D,eventContentSlotArgs:E,timeFormat:C="24h",appTimeZone:T,renderVisualContent:k,resizeHandleOrientation:S})=>{const M=t===exports.ViewType.MONTH,N=t===exports.ViewType.YEAR,I=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),R=e=>k?k(e):e;if(M&&r&&a)return Ie(Er,{segment:a,segmentIndex:null!=i?i:0,isDragging:l||d,isResizing:s,isSelected:d,onMoveStart:b,onResizeStart:x,isMobile:p,isDraggable:h,isEditable:u,viewable:g,isPopping:c,appTimeZone:T,renderSlot:e=>Ie(Hn,{store:D,generatorName:I,generatorArgs:E,defaultContent:R(e)})});if(N&&o)return Ie(Mr,{event:e,segment:o,isEditable:u,onMoveStart:b,onResizeStart:x,renderSlot:e=>Ie(Hn,{store:D,generatorName:I,generatorArgs:E,defaultContent:R(e)})});if(M){const t=e.allDay?Ie(Tr,{event:e,isEventSelected:d}):Ie(kr,{event:e,app:y,isEventSelected:d,hideTime:f,isMobile:p});return Ie(Hn,{store:D,generatorName:I,generatorArgs:E,defaultContent:R(t)})}const O=e=>Ie(Hn,{store:D,generatorName:I,generatorArgs:E,defaultContent:R(e)});return n?Ie(Cr,{event:e,isEditable:u,onResizeStart:x,isMultiDay:r,segment:a,isSlidingView:v,renderSlot:O}):Ie(Sr,{event:e,app:y,multiDaySegmentInfo:w,isEditable:u,isTouchEnabled:m,isEventSelected:d,onResizeStart:x,timeFormat:C,resizeHandleOrientation:S,renderSlot:O})},Ir=({event:n,position:o,panelRef:i,isAllDay:l,eventVisibility:s,calendarRef:d,selectedEventElementRef:c,onEventUpdate:u,onEventDelete:h,onClose:g,app:f})=>{var p,v;const{effectiveTheme:y}=In(),b=_e(y),{t:x}=bt(),[w,D]=a.useState(n),[E,C]=a.useState(!1),T=a.useRef(n),k=a.useRef(n),S=a.useRef(!1),M=a.useCallback(()=>{if(S.current)return;const e=T.current,t=k.current;if(xe(e,t))return;const n=ie(e,t,null==f?void 0:f.timeZone);T.current=n,k.current=n;const r=u(n);r&&Promise.resolve(r).catch(e=>{L.error("Failed to commit deferred event detail panel update",e)})},[null==f?void 0:f.timeZone,u]),N=a.useCallback(e=>{if(!xe(k.current,e)&&(k.current=e,D(e),f)){const t=f.updateEvent(e.id,e,!0);t&&Promise.resolve(t).catch(e=>{L.error("Failed to apply pending event detail panel update",e)})}},[f]);a.useEffect(()=>{if(!(T.current.id===n.id))return M(),S.current=!1,T.current=n,k.current=n,void D(n);xe(T.current,k.current)&&(T.current=n,k.current=n,D(n))},[n,M]),a.useEffect(()=>()=>{M()},[M]);const R=a.useMemo(()=>{var e;return null!==(e=null==f?void 0:f.timeZone)&&void 0!==e?e:t.Temporal.Now.timeZoneId()},[f]),O=a.useMemo(()=>(f?f.getCalendarRegistry():I()).getVisible().map(e=>({label:e.name,value:e.id})),[f,null==f?void 0:f.getCalendars()]),H="dark"===b||"undefined"!=typeof document&&document.documentElement.classList.contains("dark"),A=null!==(p=null==f?void 0:f.canMutateFromUI(n.id))&&void 0!==p&&p,P=null==f?void 0:f.getReadOnlyConfig(n.id),$=!1!==(null==P?void 0:P.viewable),j=!!w.allDay,Y=!a.useMemo(()=>{if(!n.calendarId)return!1;const e=null==f?void 0:f.getCalendarRegistry().get(n.calendarId);return!!(null==e?void 0:e.subscription)},[f,n.calendarId])||""!==(w.description||"").trim();if(!$)return null;const F=H?"#1f2937":"white",V=H?"rgb(55, 65, 81)":"rgb(229, 231, 235)",Z=(()=>{var e;let t={};if("sticky-top"===s){const n=null===(e=d.current)||void 0===e?void 0:e.querySelector(".df-calendar-content");if(n){const e=n.getBoundingClientRect().top+3-o.top;t=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:F,transform:"rotate(45deg)",transformOrigin:"center",top:e-6+"px",borderRight:""+(o.isSunday?`1px solid ${V}`:"none"),borderTop:""+(o.isSunday?`1px solid ${V}`:"none"),borderLeft:""+(o.isSunday?"none":`1px solid ${V}`),borderBottom:""+(o.isSunday?"none":`1px solid ${V}`)},o.isSunday?{right:"-6px"}:{left:"-6px"})}}else if("sticky-bottom"===s){const e=i.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:F,transform:"rotate(45deg)",transformOrigin:"center",top:`${n}px`,left:o.isSunday?void 0:"-6px",right:o.isSunday?"-6px":void 0,borderRight:""+(o.isSunday?`1px solid ${V}`:"none"),borderTop:""+(o.isSunday?`1px solid ${V}`:"none"),borderLeft:""+(o.isSunday?"none":`1px solid ${V}`),borderBottom:""+(o.isSunday?"none":`1px solid ${V}`)}}else if(o&&c.current&&d.current){const e=c.current.getBoundingClientRect(),n=d.current.querySelector(".df-calendar-content");if(n){const r=n.getBoundingClientRect(),a=Math.max(e.top,r.top),l=Math.min(e.bottom,r.bottom),s=Math.max(0,l-a);let d;d=s===e.height?e.top+e.height/2:s>0?a+s/2:e.top+e.height/2;const c=d-o.top,u=i.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:F,transform:"rotate(45deg)",transformOrigin:"center",top:m-6+"px",borderRight:""+(o.isSunday?`1px solid ${V}`:"none"),borderTop:""+(o.isSunday?`1px solid ${V}`:"none"),borderLeft:""+(o.isSunday?"none":`1px solid ${V}`),borderBottom:""+(o.isSunday?"none":`1px solid ${V}`)},o.isSunday?{right:"-6px"}:{left:"-6px"})}}return t})(),_=Ie("div",{ref:i,className:`${Zt} p-4`,"data-event-detail-panel":"true","data-event-id":n.id,style:{top:`${o.top}px`,left:`${o.left}px`,zIndex:9999,pointerEvents:"auto"},children:[Ie("div",{style:Z}),Ie("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:x("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-${w.id}`,name:"title",type:"text",value:w.title,readOnly:!A||E,disabled:!A||E,onChange:e=>N(Object.assign(Object.assign({},w),{title:e.target.value})),onInput:e=>N(Object.assign(Object.assign({},w),{title:e.target.value})),className:"df-focus-ring w-full rounded-lg border border-slate-200 px-3 py-1.5 text-sm text-gray-900 shadow-sm transition focus:ring-2 focus:outline-none disabled:opacity-50 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100"})}),A&&Ie(Bn,{options:O,value:w.calendarId||"blue",disabled:E,onChange:e=>{N(Object.assign(Object.assign({},w),{calendarId:e}))},registry:null==f?void 0:f.getCalendarRegistry()})]}),Ie("div",j?{className:"mb-3",children:[Ie("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:x("dateRange")}),Ie(Wn,{value:[w.start,w.end],format:"YYYY-MM-DD",showTime:!1,timeZone:R,matchTriggerWidth:!0,disabled:!A||E,onChange:e=>{if(E)return;const[t,n]=e;N(Object.assign(Object.assign({},w),{start:t.toPlainDate(),end:n.toPlainDate()}))},locale:null==f?void 0:f.state.locale})]}:{className:"mb-3",children:[Ie("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:x("timeRange")}),Ie(Wn,{value:[w.start,w.end],timeZone:R,disabled:!A||E,onChange:e=>{if(E)return;const[t,n]=e;N(Object.assign(Object.assign({},w),{start:t,end:n}))},locale:null==f?void 0:f.state.locale})]}),Y&&Ie("div",{className:"mb-3",children:[Ie("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:x("note")}),Ie("textarea",{id:`event-note-${w.id}`,name:"note",value:null!==(v=w.description)&&void 0!==v?v:"",readOnly:!A||E,disabled:!A||E,onChange:e=>N(Object.assign(Object.assign({},w),{description:e.target.value})),onInput:e=>N(Object.assign(Object.assign({},w),{description:e.target.value})),rows:3,className:"df-focus-ring w-full resize-none rounded-lg border border-slate-200 px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:ring-2 focus:outline-none disabled:opacity-50 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",placeholder:x("addNotePlaceholder")})]}),A&&Ie("div",{className:"flex space-x-2",children:[Ie(Ln,j?{type:"button",className:"df-fill-primary df-hover-primary-solid rounded px-2 py-1 text-xs font-medium transition",onClick:()=>{var e;if(E)return;const n=m(w.start)?w.start:w.start.toPlainDate(),r=null!==(e=null==f?void 0:f.timeZone)&&void 0!==e?e:t.Temporal.Now.timeZoneId(),a=t.Temporal.ZonedDateTime.from({year:n.year,month:n.month,day:n.day,hour:9,minute:0,timeZone:r}),o=t.Temporal.ZonedDateTime.from({year:n.year,month:n.month,day:n.day,hour:10,minute:0,timeZone:r});N(Object.assign(Object.assign({},w),{allDay:!1,start:a,end:o}))},loading:E,children:x("setAsTimed")}:{type:"button",className:"df-fill-primary df-hover-primary-solid rounded px-2 py-1 text-xs font-medium transition",onClick:()=>{if(E)return;const e=m(w.start)?w.start:w.start.toPlainDate(),t=m(w.end)?w.end:w.end.toPlainDate();N(Object.assign(Object.assign({},w),{allDay:!0,start:e,end:t}))},loading:E,children:x("setAsAllDay")}),Ie(Ln,{type:"button",className:"df-fill-destructive df-hover-destructive rounded px-2 py-1 text-xs font-medium transition",onClick:()=>e.__awaiter(void 0,void 0,void 0,function*(){if(!E){S.current=!0,C(!0);try{yield h(w.id)}finally{C(!1)}}}),loading:E,children:x("delete")})]})]});if("undefined"==typeof window||"undefined"==typeof document)return null;const z=document.body;return z?r.createPortal(_,z):null},Rr=({event:e,position:t,panelRef:n,isAllDay:a,eventVisibility:o,calendarRef:i,selectedEventElementRef:l,onEventUpdate:s,onEventDelete:d,onClose:c,contentRenderer:u})=>{const{effectiveTheme:h}=In(),g=_e(h),m="dark"===g?"#1f2937":"white",f="dark"===g?"rgb(55, 65, 81)":"rgb(229, 231, 235)",p=(()=>{var e;let r={};if("sticky-top"===o){const n=null===(e=i.current)||void 0===e?void 0:e.querySelector(".df-calendar-content");if(n){const e=n.getBoundingClientRect().top+3-t.top;r=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:m,transform:"rotate(45deg)",transformOrigin:"center",top:e-6+"px",borderRight:""+(t.isSunday?`1px solid ${f}`:"none"),borderTop:""+(t.isSunday?`1px solid ${f}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${f}`),borderBottom:""+(t.isSunday?"none":`1px solid ${f}`)},t.isSunday?{right:"-6px"}:{left:"-6px"})}}else if("sticky-bottom"===o){const e=n.current;let a=200;if(e){const t=e.getBoundingClientRect(),n=window.getComputedStyle(e),r=Number.parseInt(n.paddingBottom,10)||0,o=Number.parseInt(n.borderBottomWidth,10)||0;a=t.height-r-o-6+11}r={position:"absolute",width:"12px",height:"12px",backgroundColor:m,transform:"rotate(45deg)",transformOrigin:"center",top:`${a}px`,left:t.isSunday?void 0:"-6px",right:t.isSunday?"-6px":void 0,borderRight:""+(t.isSunday?`1px solid ${f}`:"none"),borderTop:""+(t.isSunday?`1px solid ${f}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${f}`),borderBottom:""+(t.isSunday?"none":`1px solid ${f}`)}}else if(t&&l.current&&i.current){const e=l.current.getBoundingClientRect(),a=i.current.querySelector(".df-calendar-content");if(a){const o=a.getBoundingClientRect(),i=Math.max(e.top,o.top),l=Math.min(e.bottom,o.bottom),s=Math.max(0,l-i);let d;d=s===e.height?e.top+e.height/2:s>0?i+s/2:e.top+e.height/2;const c=d-t.top,u=n.current;let h=228;if(u){const e=u.getBoundingClientRect(),t=window.getComputedStyle(u),n=Number.parseInt(t.paddingBottom,10)||0,r=Number.parseInt(t.borderBottomWidth,10)||0;h=e.height-n-r+11}const g=12,p=Math.max(g,Math.min(h,c));r=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:m,transform:"rotate(45deg)",transformOrigin:"center",top:p-6+"px",borderRight:""+(t.isSunday?`1px solid ${f}`:"none"),borderTop:""+(t.isSunday?`1px solid ${f}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${f}`),borderBottom:""+(t.isSunday?"none":`1px solid ${f}`)},t.isSunday?{right:"-6px"}:{left:"-6px"})}}return r})(),v=Ie("div",{ref:n,className:`${Zt} 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:p}),Ie(u,{event:e,isAllDay:a,onEventUpdate:s,onEventDelete:d,onClose:c})]});return r.createPortal(v,document.body)},Or=({showDetailPanel:e,customEventDetailDialog:t,detailPanelPosition:n,event:r,detailPanelRef:a,isAllDay:o,eventVisibility:i,calendarRef:l,selectedEventElementRef:s,onEventUpdate:d,onEventDelete:c,handlePanelClose:u,customRenderingStore:h,contentSlotRenderer:g,customDetailPanelContent:m,app:f})=>{if(!e)return null;if(t)return null;if(!n)return null;const p={event:r,position:n,panelRef:a,isAllDay:o,eventVisibility:i,calendarRef:l,selectedEventElementRef:s,onEventUpdate:d,onEventDelete:c,onClose:u};return(null==h?void 0:h.isOverridden("eventDetailContent"))?Ie(Rr,Object.assign({},p,{contentRenderer:g})):m?Ie(Rr,Object.assign({},p,{contentRenderer:m})):Ie(Ir,Object.assign({},p,{app:f}))},Hr=(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},Ar=(e,t,n,r,a)=>{let o="df-event calendar-event select-none pointer-events-auto";const i=e===exports.ViewType.DAY,l=e===exports.ViewType.MONTH,s=e===exports.ViewType.YEAR;i?o+=" df-day-event flex flex-col":l||s?s&&(o+=" df-year-event transition-colors group px-1 overflow-hidden whitespace-nowrap cursor-pointer"):o+=" df-week-event flex flex-col";const d=()=>{if(n&&r){const{segmentType:e}=r;if("single"===e||"start"===e)return Ot;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 Ot};if(s)return`${o} ${(()=>{if(a){const{isFirstSegment:e,isLastSegment:t}=a;return e&&t?"rounded":e?"rounded-l rounded-r-none":t?"rounded-r rounded-l-none":"rounded-none"}return"rounded"})()}`;if(l){let e=`\n ${o}\n ${t?d():Ht}\n `;return n||(e+=" mb-[2px] last:mb-0"),e}return`\n ${o}\n shadow-sm\n ${t?d():Ht}\n `},Pr="transform 0.5s cubic-bezier(0.22, 1, 0.36, 1)",Lr=({event:e,layout:t,isAllDay:r=!1,allDayHeight:o=28,calendarRef:i,isBeingDragged:l=!1,isBeingResized:s=!1,viewType:d,isMultiDay:c=!1,segment:u,yearSegment:h,columnsPerRow:g,segmentIndex:m=0,hourHeight:f,firstHour:p,selectedEventId:v,detailPanelEventId:y,onMoveStart:b,onResizeStart:x,onEventUpdate:w,onEventDelete:D,newlyCreatedEventId:C,onDetailPanelOpen:T,onEventSelect:k,onEventLongPress:S,onDetailPanelToggle:M,customDetailPanelContent:N,customEventDetailDialog:I,multiDaySegmentInfo:R,app:P,isMobile:L=!1,isSlidingView:$=!1,enableTouch:j,hideTime:Y,timeFormat:F="24h",styleOverride:V,className:Z,disableDefaultStyle:_=!1,renderVisualContent:z,resizeHandleOrientation:W,appTimeZone:B})=>{var G;const K=a.useContext(Rn),q=null!=j?j:L,X=d===exports.ViewType.YEAR,Q=a.useMemo(()=>{if(!B||e.allDay)return e;const t=U(e.start,B),n=e.end?U(e.end,B):void 0;return Object.assign(Object.assign({},e),{start:t,end:n})},[e,B]),[ee,te]=a.useState(null),[ne,re]=a.useState(!1),ae=a.useRef(null),oe=a.useRef(null),ie=a.useRef(null),le=a.useRef(null),se=c&&u?`${e.id}::${u.id}`:void 0===(null==R?void 0:R.dayIndex)?X&&h?h.id:e.id:`${e.id}::day-${R.dayIndex}`,de=y===se,ce=de&&!I,ue=null==P?void 0:P.getReadOnlyConfig(e.id),he=null!==(G=null==P?void 0:P.canMutateFromUI(e.id))&&void 0!==G&&G,ge=!1!==(null==ue?void 0:ue.viewable),me=!1!==(null==ue?void 0:ue.draggable),{isSelected:fe,setIsSelected:pe,isPressed:ve,setIsPressed:ye,handleTouchStart:be,handleTouchMove:xe,handleTouchEnd:we}=(({event:e,isTouchEnabled:t,onMoveStart:n,onEventLongPress:r,onDetailPanelToggle:o,canOpenDetail:i,app:l,multiDaySegmentInfo:s,isMultiDay:d,segment:c,detailPanelKey:u})=>{const[h,g]=a.useState(!1),[m,f]=a.useState(!1),p=a.useRef(null),v=a.useRef(null);return{isSelected:h,setIsSelected:g,isPressed:m,setIsPressed:f,handleTouchStart:a=>{if(!n||!t)return;f(!0);const o=a.touches[0],i=o.clientX,l=o.clientY,u=a.currentTarget;v.current={x:i,y:l},p.current=setTimeout(()=>{var t;r?r(e.id):g(!0);const a={preventDefault:()=>{},stopPropagation:()=>{},currentTarget:u,touches:[{clientX:i,clientY:l}],cancelable:!1};if(s){const r=Object.assign(Object.assign({},e),{day:null!==(t=s.dayIndex)&&void 0!==t?t:e.day,_segmentInfo:s});n(a,r)}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(a,t)}else n(a,e);p.current=null,v.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},handleTouchMove:e=>{if(p.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(p.current),p.current=null,v.current=null,f(!1))}},handleTouchEnd:n=>{f(!1),p.current&&(clearTimeout(p.current),p.current=null),t&&v.current&&(n.preventDefault(),n.stopPropagation(),l&&l.onEventClick(e),i?null==o||o(u):null==o||o(null)),v.current=null}}})({event:e,isTouchEnabled:q,onMoveStart:b,onEventLongPress:S,onDetailPanelToggle:M,canOpenDetail:ge,app:P,multiDaySegmentInfo:R,isMultiDay:c,segment:u,detailPanelKey:se}),[De,Ee]=a.useState("visible"),Ce=e=>{le.current=e},Te=a.useCallback(()=>((e,t,n,r,a,o)=>{var i;if(null!==r)return r;if(t===n){const e=n.split("::").at(-1);if(e&&e.startsWith("day-")){const t=Number(e.replace("day-",""));if(!Number.isNaN(t))return t}}return void 0!==(null==a?void 0:a.dayIndex)?a.dayIndex:o?o.startDayIndex:null!==(i=e.day)&&void 0!==i?i:0})(e,y||void 0,se,le.current,R,u),[e,y,se,R,u]),ke=a.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=Hr(t,r),i=n===exports.ViewType.DAY?1:7,l=(a.width-o)/i,s=e-a.left-o,d=Math.floor(s/l);return Number.isFinite(d)?Math.max(0,Math.min(i-1,d)):null})(e,i,d,L),[i,d,L]),Se=a.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=Hr(t,r);if(n===exports.ViewType.DAY){const e=a.width-o;return{left:a.left+o,width:e}}const i=(a.width-o)/7;return{left:a.left+o+e*i,width:i}})(e,i,d,L),[i,d,L]),{detailPanelPosition:Me,setDetailPanelPosition:Ne,updatePanelPosition:Re}=(({event:e,viewType:t,isMultiDay:n,segment:r,yearSegment:o,multiDaySegmentInfo:i,calendarRef:l,eventRef:s,detailPanelRef:d,selectedEventElementRef:c,isMobile:u,eventVisibility:h,firstHour:g,hourHeight:m,columnsPerRow:f,showDetailPanel:p,detailPanelEventId:v,detailPanelKey:y,getActiveDayIdx:b,getDayMetricsWrapper:x})=>{const[w,D]=a.useState(null),E=t===exports.ViewType.DAY,C=t===exports.ViewType.MONTH,T=t===exports.ViewType.YEAR,k=a.useCallback(()=>{if(!c.current||!l.current||!d.current)return;const e=l.current.getBoundingClientRect(),t=b(),a=x(t);let o,i;if(a)o=a.left,i=a.width;else if(C)i=e.width/7,o=e.left+t*i;else{const n=Hr(l,u);i=(e.width-n)/7,o=e.left+n+t*i}const g=Math.min(window.innerWidth,e.right),m=Math.min(window.innerHeight,e.bottom);requestAnimationFrame(()=>{var a,i,l;if(!d.current)return;if(!c.current)return;const u=d.current.getBoundingClientRect(),f=u.width,p=u.height;let v,y,b;if("sticky-top"===h||"sticky-bottom"===h){const e=null===(a=s.current)||void 0===a?void 0:a.getBoundingClientRect();if(!e)return;b=e}else b=c.current.getBoundingClientRect();if(C&&n&&r){const n=x(t),r=null!==(i=null==n?void 0:n.width)&&void 0!==i?i:e.width/7,a=null!==(l=null==n?void 0:n.left)&&void 0!==l?l: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>=f+20?b.right+10:E>=f+20?b.left-f-10:w>E?Math.max(e.left+10,g-f-10):e.left+10;const k=b.top-p/2+b.height/2,S=Math.max(10,e.top+10),M=m-10;y=k<S?S:k+p>M?M-p: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})})})},[l,e.day,e.start,e.end,h,C,g,m,n,r,i,v,y,u,E,T,o,f,b,x,c,d,s]);return a.useEffect(()=>{!p||w||u||(D({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>k()))},[p,w,k,u]),{detailPanelPosition:w,setDetailPanelPosition:D,updatePanelPosition:k}})({event:e,viewType:d,isMultiDay:c,segment:u,yearSegment:h,multiDaySegmentInfo:R,calendarRef:i,eventRef:ae,detailPanelRef:oe,selectedEventElementRef:ie,isMobile:L,eventVisibility:De,firstHour:p,hourHeight:f,columnsPerRow:g,showDetailPanel:de,detailPanelEventId:y,detailPanelKey:se,getActiveDayIdx:Te,getDayMetricsWrapper:Se}),{handleClick:Oe,handleDoubleClick:He,handleContextMenu:Ae,hasPendingSelection:Pe}=(({event:e,timingEvent:t,viewType:n,isAllDay:r,isMultiDay:o,segment:i,multiDaySegmentInfo:l,calendarRef:s,firstHour:d,hourHeight:c,isMobile:u,canOpenDetail:h,detailPanelKey:g,app:m,onEventSelect:f,onDetailPanelToggle:p,setIsSelected:v,setDetailPanelPosition:y,setContextMenuPosition:b,setActiveDayIndex:x,getClickedDayIdx:w,updatePanelPosition:D,selectedEventElementRef:C})=>{const T=n===exports.ViewType.MONTH,k=n===exports.ViewType.YEAR,S=null!=t?t:e,M=a.useRef(null),[N,I]=a.useState(!1),R=a.useCallback(()=>{M.current&&(clearTimeout(M.current),M.current=null,I(!1))},[]);a.useEffect(()=>()=>R(),[R]);const O=a.useCallback(()=>new Promise(e=>{if(!s.current||r||T||k)return void e();const t=s.current.querySelector(".df-calendar-content");if(!t)return void e();const n=l?l.startHour:E(S.start),a=l?l.endHour:J(S),o=(n-d)*c,i=o+Math.max((a-n)*c,c/4),u=t.scrollTop,h=t.clientHeight;if(o>=u&&i<=u+h)return void e();const g=((n+a)/2-d)*c-h/2,m=t.scrollHeight-h;t.scrollTo({top:Math.max(0,Math.min(m,g)),behavior:"smooth"}),setTimeout(()=>e(),300)}),[s,r,T,k,l,S.start,S.end,d,c]),H=a.useCallback(t=>{R(),t.preventDefault(),t.stopPropagation(),m&&!m.canMutateFromUI(e.id)||(f&&f(e.id),b({x:t.clientX,y:t.clientY}))},[m,R,e.id,f,b]),A=a.useCallback(t=>{var n,r,a;if(o){const a=w(t);x(null===a?null!==(r=null!==(n=null==l?void 0:l.dayIndex)&&void 0!==n?n:e.day)&&void 0!==r?r:null:i?Math.min(Math.max(a,i.startDayIndex),i.endDayIndex):a)}else x(null!==(a=e.day)&&void 0!==a?a:null);m&&m.onEventClick(e),f?f(e.id):h&&v(!0),null==p||p(null),y(null)},[o,w,x,null==l?void 0:l.dayIndex,e,i,m,f,h,v,p,y]),P=a.useCallback(t=>{var n,r,a,l,s;if(R(),t.preventDefault(),t.stopPropagation(),!h)return;let d=t.currentTarget;if(o){const e=d.querySelector("div");e&&(d=e)}if(C.current=d,o){const o=w(t.clientX);x(null===o?null!==(r=null!==(n=null==i?void 0:i.startDayIndex)&&void 0!==n?n:e.day)&&void 0!==r?r:0:Math.min(Math.max(o,null!==(a=null==i?void 0:i.startDayIndex)&&void 0!==a?a:0),null!==(l=null==i?void 0:i.endDayIndex)&&void 0!==l?l:6))}else x(null!==(s=e.day)&&void 0!==s?s:null);O().then(()=>{v(!0),null==f||f(e.id),u||(null==p||p(g),y({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>D()))})},[R,h,o,C,w,x,null==i?void 0:i.startDayIndex,null==i?void 0:i.endDayIndex,e.day,O,v,k,u,p,g,y,D]);return{handleClick:a.useCallback(e=>{e.preventDefault(),e.stopPropagation();const t=e.clientX;if(k&&!u)return R(),I(!0),void(M.current=setTimeout(()=>{A(t),M.current=null,I(!1)},180));A(t)},[R,k,u,A]),handleDoubleClick:P,handleContextMenu:H,hasPendingSelection:N,scrollEventToCenter:O}})({event:e,timingEvent:Q,viewType:d,isAllDay:r,isMultiDay:c,segment:u,multiDaySegmentInfo:R,calendarRef:i,firstHour:p,hourHeight:f,isMobile:L,canOpenDetail:ge,detailPanelKey:se,app:P,onEventSelect:k,onDetailPanelToggle:M,setIsSelected:pe,setDetailPanelPosition:Ne,setContextMenuPosition:te,setActiveDayIndex:Ce,getClickedDayIdx:ke,updatePanelPosition:Re,selectedEventElementRef:ie}),Le=(void 0===v?fe:v===e.id)||Pe||!q&&ve||l,{calculateEventStyle:$e}=(({event:e,timingEvent:t,layout:n,isAllDay:r,allDayHeight:a,viewType:o,isMultiDay:i,segment:l,yearSegment:s,columnsPerRow:d,segmentIndex:c,hourHeight:u,firstHour:h,isEventSelected:g,showDetailPanel:m,isPopping:f,isDraggable:p,canOpenDetail:v,eventVisibility:y,calendarRef:b,isMobile:x,eventRef:w,getActiveDayIdx:D,getDayMetricsWrapper:C,multiDaySegmentInfo:T})=>{const k=o===exports.ViewType.DAY,S=o===exports.ViewType.MONTH,M=o===exports.ViewType.YEAR,N=null!=t?t:e;return{calculateEventStyle:()=>{var e,t,o,I,R,O,H,A;if(M&&s&&d){const{startCellIndex:e,endCellIndex:t,visualRowIndex:n}=s,r=2;return{position:"absolute",left:`calc(${e/d*100}% + ${r}px)`,top:18*n+"px",width:`calc(${(t-e+1)/d*100}% - ${2*r}px)`,height:"16px",opacity:1,zIndex:g||m?1e3:1,transform:f?"scale(1.05)":"scale(1)",transition:Pr,cursor:p||v?"pointer":"default"}}if(S)return i&&l?{opacity:1,zIndex:g||m?1e3:1,cursor:p||v?"pointer":"default"}:{opacity:1,zIndex:g||m?1e3:1,transform:f?"scale(1.05)":"scale(1)",transition:Pr,cursor:p||v?"pointer":"default"};if(r){const e={height:a-4+"px",opacity:1,zIndex:g||m?1e3:1,transform:f?"scale(1.05)":"scale(1)",transition:Pr,cursor:p||v?"pointer":"default"},t=c*a;if(Object.assign(e,{top:`${t}px`}),k)Object.assign(e,{width:"100%",left:"0px",right:"2px",position:"absolute"});else if(i&&l){const t=d||7,n=(l.endDayIndex-l.startDayIndex+1)/t*100,r=l.startDayIndex/t*100,a=2,o=l.isFirstSegment?a:0,i=o+(l.isLastSegment?a:0);Object.assign(e,{width:i>0?`calc(${n}% - ${i}px)`:`${n}%`,left:o>0?`calc(${r}% + ${o}px)`:`${r}%`,position:"absolute",pointerEvents:"auto"})}else Object.assign(e,{width:"100%",left:"0px",position:"relative"});return e}const P=T?T.startHour:E(N.start),L=T?T.endHour:J(N),$={top:(P-h)*u+3+"px",height:Math.max((L-P)*u,u/4)-4+"px",position:"absolute",opacity:1,zIndex:g||m?1e3:null!==(e=null==n?void 0:n.zIndex)&&void 0!==e?e:1,transform:f?"scale(1.05)":"scale(1)",transition:Pr,cursor:p||v?"pointer":"default"};if(g&&m&&("sticky-top"===y||"sticky-bottom"===y)){const e=null===(t=b.current)||void 0===t?void 0:t.getBoundingClientRect();if(e){const t=D(),r=Hr(b,x),a=k?1:d||7;let i=(e.width-r)/a,l=e.left+r+(k?0:t*i);S&&(i=e.width/7,l=e.left+t*i);const s=C(t);s&&(l=s.left,i=s.width);let c=null===(o=b.current)||void 0===o?void 0:o.querySelector(".df-calendar-content");c||(c=null===(I=b.current)||void 0===I?void 0:I.querySelector(".calendar-renderer"));const u=null==c?void 0:c.getBoundingClientRect(),h=null===(O=null===(R=w.current)||void 0===R?void 0:R.parentElement)||void 0===O?void 0:O.getBoundingClientRect();let g,m;if(h&&h.width>0)n?(g=h.left+n.left/100*h.width,m=k?n.width/100*h.width:(n.width-1)/100*h.width):(g=h.left,m=k?h.width:h.width-3);else{const e=C(t),r=null!==(H=null==e?void 0:e.left)&&void 0!==H?H:l,a=null!==(A=null==e?void 0:e.width)&&void 0!==A?A:i;g=r,m=a-3,n&&(g=r+n.left/100*a,m=k?n.width/100*a:(n.width-1)/100*a)}if("sticky-top"===y){let t=u?u.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:`${g}px`,width:`${m}px`,height:"6px",zIndex:1e3,overflow:"hidden"}}let f=u?u.bottom:e.bottom;return f=Math.min(f,window.innerHeight),f=Math.min(f,e.bottom),f=Math.max(f,e.top+6),f=Math.max(f,6),{position:"fixed",top:f-6+"px",left:`${g}px`,width:`${m}px`,height:"6px",zIndex:1e3,overflow:"hidden"}}}if(n&&!r){const e=k?`${n.width}%`:n.width-1+"%";return Object.assign(Object.assign({},$),{left:`${n.left}%`,width:e,right:"auto"})}return Object.assign(Object.assign({},$),{left:"0px",right:k?"0px":"3px"})}}})({event:e,timingEvent:Q,layout:t,isAllDay:r,allDayHeight:o,viewType:d,isMultiDay:c,segment:u,yearSegment:h,columnsPerRow:g,segmentIndex:m,hourHeight:f,firstHour:p,isEventSelected:Le,showDetailPanel:de,isPopping:ne,isDraggable:me,canOpenDetail:ge,eventVisibility:De,calendarRef:i,isMobile:L,eventRef:ae,getActiveDayIdx:Te,getDayMetricsWrapper:Se,multiDaySegmentInfo:R});(({event:e,timingEvent:t,isEventSelected:n,showDetailPanel:r,eventRef:o,calendarRef:i,isAllDay:l,viewType:s,multiDaySegmentInfo:d,firstHour:c,hourHeight:u,updatePanelPosition:h,eventVisibility:g,setEventVisibility:m})=>{const f=s===exports.ViewType.MONTH,p=s===exports.ViewType.YEAR,v=null!=t?t:e,y=a.useCallback(()=>{if(!n||!r||!o.current||!i.current||l||f||p)return;const e=i.current.querySelector(".df-calendar-content");if(!e)return;const t=d?d.startHour:E(v.start),a=d?d.endHour:J(v),s=(t-c)*u,y=s+Math.max((a-t)*u,u/4),b=e.getBoundingClientRect(),x=e.scrollTop,w=x+b.height,D=b.bottom<0,C=b.top>window.innerHeight;let T=g;D?T="sticky-top":C?T="sticky-bottom":"visible"===g?y<x?T="sticky-top":s>w-20&&(T="sticky-bottom"):"sticky-top"===g?y>=x&&(T="visible"):"sticky-bottom"===g&&s<=w-20&&(T="visible"),T!==g&&m(T),h()},[n,r,i,l,f,v.start,v.end,c,u,h,d,g,m]);a.useEffect(()=>{var e,t;if(!n||!r||l)return;const a=null===(e=i.current)||void 0===e?void 0:e.querySelector(".df-calendar-content");if(!a)return;const o=()=>y(),s=()=>{y(),h()},d=[a];let c=null===(t=i.current)||void 0===t?void 0:t.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",o)}),window.addEventListener("scroll",o,!0),window.addEventListener("resize",s);let u=null;return i.current&&(u=new ResizeObserver(()=>{s()}),u.observe(i.current)),y(),()=>{d.forEach(e=>{e.removeEventListener("scroll",o)}),window.removeEventListener("scroll",o,!0),window.removeEventListener("resize",s),u&&u.disconnect()}},[n,r,l,y,h,i])})({event:e,timingEvent:Q,isEventSelected:Le,showDetailPanel:de,eventRef:ae,calendarRef:i,isAllDay:r,viewType:d,multiDaySegmentInfo:R,firstHour:p,hourHeight:f,updatePanelPosition:Re,eventVisibility:De,setEventVisibility:Ee});const je=de&&!!I;(({eventRef:e,detailPanelRef:t,eventId:n,isEventSelected:r,showDetailPanel:o,onEventSelect:i,onDetailPanelToggle:l,setIsSelected:s,setActiveDayIndex:d})=>{a.useEffect(()=>{if(!r&&!o)return;const a=a=>{var c,u;const h=a.target,g=null===(c=e.current)||void 0===c?void 0:c.contains(h),m=null!==h.closest(`[data-event-id="${n}"]`),f=null===(u=t.current)||void 0===u?void 0:u.contains(h),p=h.closest("[data-event-detail-dialog]"),v=h.closest("[data-range-picker-popup]"),y=h.closest("[data-calendar-picker-dropdown]");o?g||m||f||p||v||y||(null==i||i(null),d(null),s(!1),null==l||l(null)):!r||g||m||p||v||y||(null==i||i(null),d(null),s(!1),null==l||l(null))};return document.addEventListener("mousedown",a),()=>{document.removeEventListener("mousedown",a)}},[r,o,i,l,n])})({eventRef:ae,detailPanelRef:oe,eventId:e.id,isEventSelected:!je&&Le,showDetailPanel:ce,onEventSelect:k,onDetailPanelToggle:M,setIsSelected:pe,setActiveDayIndex:Ce});const Ye=a.useCallback(()=>{k&&k(null),le.current=null,pe(!1),null==M||M(null)},[k,M,pe]),Fe=a.useMemo(()=>({event:e,isAllDay:r,onEventUpdate:w,onEventDelete:D,onClose:Ye}),[e,r,w,D,Ye]),Ve=a.useMemo(()=>({event:e,viewType:d,isAllDay:r,isMobile:L,isSelected:Le,isDragging:l,segment:u,layout:t}),[e,d,r,L,Le,l,u,t]),Ze=a.useCallback(()=>Ie(Hn,{store:K,generatorName:"eventDetailContent",generatorArgs:Fe}),[K,Fe]);a.useEffect(()=>{if((null==P?void 0:P.state.highlightedEventId)===e.id){re(!0);const e=setTimeout(()=>{re(!1)},650);return()=>{clearTimeout(e),re(!1)}}},[null==P?void 0:P.state.highlightedEventId,e.id]),a.useEffect(()=>{he||te(null)},[he]),a.useEffect(()=>{const t=c&&(null==u?void 0:u.isFirstSegment)||X&&(null==h?void 0:h.isFirstSegment)||!c&&!X;C===e.id&&!de&&t&&setTimeout(()=>{null==M||M(se),null==T||T()},50)},[C,e.id,de,c,u,X,h,M,T,se]);const _e=e.calendarId||"blue",ze=null==P?void 0:P.getCalendarRegistry();return Ie(n.Fragment,{children:[Ie("div",{ref:ae,"data-event-id":e.id,className:`${Ar(d,r,c,u,h)} ${r&&C===e.id?"df-all-day-event-animate":""} ${null!=Z?Z:""}`,style:Object.assign(Object.assign(Object.assign({},_?{}:$e()),{backgroundColor:Le?A(_e,ze):O(_e,ze),color:Le?"#fff":H(_e,ze)}),V),onClick:Oe,onContextMenu:Ae,onDblClick:He,onMouseDown:t=>{var n;if(q||ye(!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:()=>!q&&ye(!1),onMouseLeave:()=>!q&&ye(!1),onTouchStart:be,onTouchMove:xe,onTouchEnd:we,children:Ie(Nr,{event:Q,viewType:d,isAllDay:r,isMultiDay:c,segment:u,yearSegment:h,segmentIndex:m,isBeingDragged:l,isBeingResized:s,isEventSelected:Le,isPopping:ne,isEditable:he,isDraggable:me,canOpenDetail:ge,isTouchEnabled:q,hideTime:Y,isMobile:L,isSlidingView:$,app:P,onMoveStart:b,onResizeStart:x,multiDaySegmentInfo:R,customRenderingStore:K,eventContentSlotArgs:Ve,timeFormat:F,appTimeZone:B,renderVisualContent:z,resizeHandleOrientation:W})}),de&&!I&&Ie("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:9998,pointerEvents:"none"}}),Ie(Or,{showDetailPanel:de,customEventDetailDialog:I,detailPanelPosition:Me,event:e,detailPanelRef:oe,isAllDay:r,eventVisibility:De,calendarRef:i,selectedEventElementRef:ie,onEventUpdate:w,onEventDelete:D,handlePanelClose:Ye,customRenderingStore:K,contentSlotRenderer:Ze,customDetailPanelContent:N,app:P}),ee&&P&&he&&Ie(br,{event:e,x:ee.x,y:ee.y,onClose:()=>te(null),app:P,onDetailPanelToggle:M,detailPanelKey:se})]})},$r=({handlePreviousMonth:e,handleToday:t,handleNextMonth:n})=>{const{t:r}=bt();return Ie("div",{className:"df-navigation flex items-center gap-1",children:[Ie("button",{type:"button",className:Ft,onClick:e,"aria-label":"Previous month",children:Ie(en,{className:Vt})}),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:Ft,onClick:n,"aria-label":"Next month",children:Ie(tn,{className:Vt})})]})},jr=({viewType:e,currentDate:t,onPrevious:n,onNext:r,onToday:a,customTitle:o,customSubtitle:i,showTodayBox:l,stickyYear:s,stickyYearOffset:d=0,nextYear:c,nextYearOffset:u=0})=>{const{locale:h}=bt(),g=void 0===l||l,m=o||(()=>{switch(e){case"day":return t.toLocaleDateString(h,{day:"numeric",month:"long",year:"numeric"});case"week":case"month":return t.toLocaleDateString(h,{month:"long",year:"numeric"});case"year":return t.getFullYear().toString();default:return""}})(),f="day"===e?i||("day"===e?t.toLocaleDateString(h,{weekday:"long"}):null):null;return Ie("div",{className:wt,style:{position:"relative"},onContextMenu:e=>e.preventDefault(),children:[Ie("div",{className:"flex-1",children:Ie("div","year"===e&&s?{style:{position:"relative",overflow:"hidden",height:"1.5em"},children:[Ie("h1",{className:Dt,style:{position:"absolute",top:0,left:0,transform:`translateY(-${d}px)`,willChange:"transform"},children:s}),c&&Ie("h1",{className:Dt,style:{position:"absolute",top:0,left:0,transform:`translateY(${u}px)`,willChange:"transform"},children:c})]}:{children:[Ie("div",{className:`${Dt} text-gray-900 dark:text-white`,children:m}),f&&Ie("div",{className:"mt-3 leading-6 text-gray-600 dark:text-gray-400",children:f})]})}),g&&n&&r&&a&&Ie("div",{className:"flex items-center gap-2",children:Ie($r,{handlePreviousMonth:n,handleNextMonth:r,handleToday:a})})]})};function Yr(e,t,n,r,a){if(r||0!==e.button)return;let o=!0;const i={move(r){if(!o)return;Math.hypot(r.clientX-e.clientX,r.clientY-e.clientY)>=5&&(o=!1,document.removeEventListener("mousemove",i.move),document.removeEventListener("mouseup",i.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",i.move),document.removeEventListener("mouseup",i.up)}};document.addEventListener("mousemove",i.move),document.addEventListener("mouseup",i.up)}function Fr(){document.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0,cancelable:!1}))}const Vr=({app:e,currentDate:t,currentWeekStart:n,events:r,currentDayEvents:o,organizedAllDayEvents:i,allDayAreaHeight:l,timeSlots:s,eventLayouts:d,isToday:c,currentTime:u,selectedEventId:h,setSelectedEventId:g,newlyCreatedEventId:m,setNewlyCreatedEventId:f,detailPanelEventId:p,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:O,customEventDetailDialog:H,calendarRef:A,allDayRowRef:P,timeGridRef:L,switcherMode:$,isMobile:j,isTouch:Y,setDraftEvent:F,setIsDrawerOpen:V,ALL_DAY_HEIGHT:Z,HOUR_HEIGHT:_,FIRST_HOUR:z,LAST_HOUR:U,showAllDay:W,showStartOfDayLabel:B,timeFormat:G="24h",secondaryTimeSlots:K,primaryTzLabel:q,secondaryTzLabel:J,appTimeZone:Q})=>{var ee;const te=!!K&&K.length>0&&!j,{t:ne}=bt(),re=a.useRef(e.state.highlightedEventId),[ae,oe]=a.useState(null),ie=a.useMemo(()=>Ze(),[]),le=()=>{var e;const t=null===(e=A.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=A.current)||void 0===t?void 0:t.querySelector(".df-calendar-content");if(!n)return null;const r=n.getBoundingClientRect(),a=n.scrollTop||0;return z+(e-r.top+a-le())/_},de=e.canMutateFromUI();a.useEffect(()=>{de||oe(null)},[de]);const ce=(e,n)=>{var r,a,o,i;if(e.preventDefault(),j||!de)return;const l=new Date(t);if(n)l.setHours(0,0,0,0);else{const t=null===(a=null===(r=A.current)||void 0===r?void 0:r.querySelector(".df-calendar-content"))||void 0===a?void 0:a.getBoundingClientRect();if(t){const n=(null===(i=null===(o=A.current)||void 0===o?void 0:o.querySelector(".df-calendar-content"))||void 0===i?void 0:i.scrollTop)||0,r=le(),a=(e.clientY-t.top+n-r)/_+z,s=Math.floor(a),d=Math.floor(60*(a-s)),c=15*Math.round(d/15),u=60===c?s+1:s,h=60===c?0:c;l.setHours(u,h,0,0)}}oe({x:e.clientX,y:e.clientY,date:l})};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 ${Xt} h-full`,children:[Ie("div",{onContextMenu:e=>e.preventDefault(),style:{paddingRight:j||!ie?"0px":"15px"},children:Ie(jr,{calendar:e,viewType:exports.ViewType.DAY,currentDate:t})}),Ie("div",W?{className:Qt(Rt,"relative items-stretch border-t border-gray-200 dark:border-gray-700"),ref:P,style:{paddingRight:j||!ie?"0px":"0.6875rem"},onContextMenu:e=>ce(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:ne("allDay")}),Ie("div",{className:Qt("relative flex flex-1 self-stretch",!j&&ie?"border-r border-gray-200 dark:border-gray-700":""),children:Ie("div",{className:"relative w-full",style:{minHeight:`${l}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:i.map(t=>Ie(Lr,{event:t,isAllDay:!0,viewType:exports.ViewType.DAY,segmentIndex:t.row,allDayHeight:Z,calendarRef:A,isBeingDragged:b&&(null==y?void 0:y.eventId)===t.id&&"move"===(null==y?void 0:y.mode),hourHeight:_,firstHour:z,onMoveStart:x,onEventUpdate:N,onEventDelete:I,newlyCreatedEventId:m,onDetailPanelOpen:()=>f(null),detailPanelEventId:p,onDetailPanelToggle:e=>v(e),selectedEventId:h,onEventSelect:t=>{const n=e.getReadOnlyConfig().viewable,a=e.canMutateFromUI(),o=r.find(e=>e.id===t);(j||Y)&&o&&n&&a?(F(o),V(!0)):(g(t),e.state.highlightedEventId&&(e.highlightEvent(null),re.current=null))},onEventLongPress:e=>{(j||Y)&&g(e)},customDetailPanelContent:O,customEventDetailDialog:H,app:e,isMobile:j,enableTouch:Y,appTimeZone:Q},t.id))})})]}:{className:!j&&ie?"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<z||t>U)return null;return Ie("div",{className:Nt,style:{top:`${(t-z)*_}px`,width:"100%",height:0,zIndex:20,marginTop:te?"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:It,children:X(t,0,G,!1)})]}),Ie("div",{className:"flex flex-1 items-center",children:Ie("div",{className:"df-current-time-bar h-0.5 w-full df-fill-primary relative"})})]})})(),Ie("div",{className:"df-time-column flex-shrink-0 "+(te?"w-20 md:w-22":"w-12 md:w-20"),onContextMenu:e=>e.preventDefault(),children:[Ie("div",{className:te?"h-8":"h-3",children:te&&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:q})]})}),s.map((e,t)=>{var n;return Ie("div",{className:kt,children:Ie("div",te?{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:B&&0===t?"":null!==(n=null==K?void 0:K[t])&&void 0!==n?n:""}),Ie("span",{className:"text-[10px] text-gray-500 md:text-[12px] dark:text-gray-400",children:B&&0===t?"":e.label})]}:{className:`${St} text-[10px] md:text-[12px]`,children:B&&0===t?"":e.label})},t)})]}),Ie("div",{className:"grow select-none",children:[Ie("div",{className:Qt(zt,!j&&ie?"border-r":"","border-t-0"),style:te?{height:"2rem"}:void 0,children:Ie("div",{className:`${Ut} -left-9.5`,style:{top:"auto",bottom:"-0.625rem"},children:B?X(z,0,G):""})}),Ie("div",{className:"relative",style:{WebkitTouchCallout:"none"},ref:L,children:[s.map((e,r)=>Ie("div",{className:Qt(Mt,!j&&ie?"border-r":""),onClick:()=>null==R?void 0:R(t),onMouseDown:e=>{const r=se(e.clientY);if(null===r)return;Yr(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),Fr()},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 i=null===(r=null===(n=A.current)||void 0===n?void 0:n.querySelector(".df-calendar-content"))||void 0===r?void 0:r.getBoundingClientRect();if(!i)return;const l=(null===(o=null===(a=A.current)||void 0===a?void 0:a.querySelector(".df-calendar-content"))||void 0===o?void 0:o.scrollTop)||0,s=le(),d=e.clientY-i.top+l-s,c=Math.floor(z+d/_);M(e,t,c)},onContextMenu:e=>ce(e,!1)},r)),Ie("div",{className:Qt(zt,!j&&ie?"border-r":""),children:Ie("div",te?{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!==(ee=null==K?void 0:K[0])&&void 0!==ee?ee:""}),Ie("span",{children:X(0,0,G)})]}:{className:`${Ut} -left-9.5`,children:X(0,0,G)})}),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(Lr,{event:t,layout:n,viewType:exports.ViewType.DAY,calendarRef:A,isBeingDragged:b&&(null==y?void 0:y.eventId)===t.id&&"move"===(null==y?void 0:y.mode),hourHeight:_,firstHour:z,onMoveStart:x,onResizeStart:w,onEventUpdate:N,onEventDelete:I,newlyCreatedEventId:m,onDetailPanelOpen:()=>f(null),detailPanelEventId:p,onDetailPanelToggle:e=>v(e),selectedEventId:h,onEventSelect:t=>{const n=e.getReadOnlyConfig().viewable,a=r.find(e=>e.id===t);(j||Y)&&a&&n?(F(a),V(!0)):(g(t),e.state.highlightedEventId&&(e.highlightEvent(null),re.current=null))},onEventLongPress:e=>{(j||Y)&&g(e)},customDetailPanelContent:O,customEventDetailDialog:H,app:e,isMobile:j,enableTouch:Y,appTimeZone:Q},t.id)})})]})]})]})})]}),de&&ae&&Ie(yr,{x:ae.x,y:ae.y,date:ae.date,viewType:exports.ViewType.DAY,onClose:()=>oe(null),app:e,onCreateEvent:()=>{if(D){const e=Math.floor((t.getTime()-n.getTime())/864e5);if(0===ae.date.getHours()&&0===ae.date.getMinutes())null==E||E({clientX:ae.x,clientY:ae.y},e);else{const t=ae.date.getHours()+ae.date.getMinutes()/60,n={preventDefault:()=>{},stopPropagation:()=>{},clientX:ae.x,clientY:ae.y};D(n,e,t)}}}})]})},Zr=({app:e,currentDate:t,visibleMonth:n,currentDayEvents:r,selectedEvent:a,setSelectedEvent:o,handleMonthChange:i,handleDateSelect:l,switcherMode:s,timeFormat:d="24h",showEventDots:c=!0,appTimeZone:u})=>{const{t:h,locale:g}=bt(),m=[...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:`${Xt} 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:wt,style:{position:"relative"},children:Ie("div",{children:Ie("h1",{className:Dt,children:" "})})}),Ie($r,{handlePreviousMonth:()=>e.goToPrevious(),handleNextMonth:()=>e.goToNext(),handleToday:()=>e.goToToday()})]}),Ie(Xn,{visibleMonth:n,currentDate:t,showHeader:!0,onMonthChange:i,onDateSelect:l,events:e.getEvents(),showEventDots:c,calendarRegistry:e.getCalendarRegistry(),timeZone:e.timeZone})]})}),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(g,{weekday:"long",month:"long",day:"numeric"})}),0===m.length?Ie("p",{className:`${Bt} ${qt}`,children:h("noEvents")}):Ie("div",{className:"space-y-2",children:m.map(t=>{var n;return Ie("div",{className:` p-2 cursor-pointer rounded border-l-4 transition-colors ${(null==a?void 0:a.id)===t.id?"df-border-primary df-tint-primary":"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:P(t.calendarId||"blue")},onClick:()=>{o(t),e.onEventClick(t)},children:[Ie("div",{className:`font-medium ${qt}`,children:t.title}),!t.allDay&&Ie("div",{className:`${Kt} ${Gt}`,children:[X(E(u?z(t.start,u):t.start),0,d)," ","-"," ",X(u?E(z(null!==(n=t.end)&&void 0!==n?n:t.start,u)):J(t),0,d)]}),t.allDay&&Ie("div",{className:`${Kt} ${Gt}`,children:h("allDay")})]},t.id)})})]})})]})})},_r={PARALLEL_THRESHOLD:.25,NESTED_THRESHOLD:.5,INDENT_STEP_PERCENT:2.5,MIN_WIDTH:25,MARGIN_BETWEEN:1,EDGE_MARGIN_PERCENT:.9};function zr(e){return Object.assign(Object.assign({},e),{parentId:void 0,children:[],_startHour:e.allDay?0:E(e.start),_endHour:e.allDay?0:J(e)})}function Ur(e){var t;return null!==(t=e._startHour)&&void 0!==t?t:E(e.start)}function Wr(e){var t;return null!==(t=e._endHour)&&void 0!==t?t:J(e)}function Br(e,t){return e.day===t.day&&!e.allDay&&!t.allDay&&(Ur(e)<Wr(t)&&Ur(t)<Wr(e))}function Gr(e,t){const n=Wr(e)-Ur(e);if(n<1.25)return!1;const r=Ur(e)+.4*n,a=Ur(t)>=r,o=Br(e,t);return a&&o}function Kr(e,t,n=_r){if(!Br(e,t))return!1;const r=Math.abs(Ur(e)-Ur(t));return r<=n.PARALLEL_THRESHOLD||(r>n.PARALLEL_THRESHOLD&&r<n.NESTED_THRESHOLD||function(e,t){return!(!Br(e,t)||!Gr(e,t)&&!Gr(t,e))}(e,t))}function qr(e,t){const n=Ur(e)<=Ur(t)&&Wr(e)>=Wr(t),r=Ur(e)<=Ur(t)&&Ur(t)<Wr(e)&&Br(e,t);return n||r}function Xr(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(Ur(r)-Ur(t))<=_r.PARALLEL_THRESHOLD&&(a.push(t),n.add(t.id))}a.sort((e,t)=>Ur(e)-Ur(t));const o={events:a,startHour:Math.min(...a.map(e=>Ur(e))),endHour:Math.max(...a.map(e=>Wr(e)))};t.push(o)}return t.sort((e,t)=>e.startHour-t.startHour),t}function Jr(e){return"day"===e?.5:2.5}function Qr(e){const t=Wr(e)-Ur(e);return Math.max(.1,Math.min(1,t/4))}function ea(e){if(e.length<2)return!1;for(let t=0;t<e.length;t++)for(let n=t+1;n<e.length;n++)if(Kr(e[t],e[n],_r))return!0;return!1}function ta(e,t,n,r,a={}){const o=Jr(a.viewType);let i=e.depth*o;if(e.isProcessed){const t=function(e,t){let n=e;for(;n.parent&&n.parent.depth>0;)n=n.parent;return 1===n.depth?n.depth*Jr(t):null}(e,a.viewType);null!==t&&(i=t)}const l="day"===a.viewType;let s=0;1===e.depth?s=l?.5:1.5:2===e.depth?s=l?-.01:-1:e.depth>=3&&(s=l?.55:-3.5);const d=t+i+s;let c=n-(i+s);if(d+c>t+n&&(c=t+n-d),r.set(e.event.id,{id:e.event.id,left:d,width:c,zIndex:e.depth,level:e.depth,isPrimary:0===e.depth,indentOffset:i*(a.containerWidth||320)/100,importance:Qr(e.event)}),0===e.children.length)return;const u=[...e.children].toSorted((e,t)=>Wr(t.event)-Ur(t.event)-(Wr(e.event)-Ur(e.event)));1===u.length?ta(u[0],d,c,r,a):ea(u.map(e=>e.event))?na(u,d,c,r,a):u.forEach(e=>ta(e,d,c,r,a))}function na(e,t,n,r,a={}){const o=e.length,i=e[0].depth,l=i*Jr(a.viewType),s="day"===a.viewType;let d=1===i?s?.5:1.5:2===i?s?-.01:-1:s?.55:-3.5;const c=t+l+d,u=n-(l+d);if(u<=0)return void e.forEach(e=>ta(e,t,n,r,a));let h=_r.MARGIN_BETWEEN*(1===i?s?.15:.3:s?.1:.2);const g=(u-h*(o-1))/o;e.forEach((e,t)=>{const n=c+t*(g+h);if(r.set(e.event.id,{id:e.event.id,left:n,width:g,zIndex:e.depth,level:e.depth,isPrimary:0===e.depth,indentOffset:l*(a.containerWidth||320)/100,importance:Qr(e.event)}),e.children.length>0){const t=[...e.children].toSorted((e,t)=>Wr(t.event)-Ur(t.event)-(Wr(e.event)-Ur(e.event)));1===t.length?ta(t[0],n,g,r,a):ea(t.map(e=>e.event))?na(t,n,g,r,a):t.forEach(e=>ta(e,n,g,r,a))}})}function ra(e,t,n={}){const r=100-("day"===n.viewType?0:_r.EDGE_MARGIN_PERCENT);if(1===e.length)ta(e[0],0,r,t,n);else if(e.length>1){const a=e.length,o=(r-_r.MARGIN_BETWEEN*(a-1))/a;e.forEach((e,r)=>{ta(e,r*(o+_r.MARGIN_BETWEEN),Math.max(o,_r.MIN_WIDTH),t,n)})}}function aa(e){let t=0;for(const n of e.children)t+=1+aa(n);return t}function oa(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:aa(e)})).toSorted((e,t)=>t.load-e.load)}function ia(e){return!(e.length<2)&&e[0].load-e.at(-1).load>=2}function la(e,t){t.parentId=e.id,e.children.includes(t.id)||e.children.push(t.id)}function sa(e,t){e.parent&&(e.parent.children=e.parent.children.filter(t=>t!==e));const n=t.children.find(t=>qr(t.event,e.event));n?(e.parent=n,e.depth=n.depth+1,n.children.push(e),la(n.event,e.event)):(e.parent=t,e.depth=t.depth+1,t.children.push(e),la(t.event,e.event))}function da(e,t){0===e.children.length?t.push(e):e.children.forEach(e=>da(e,t))}function ca(e,t){const n=[];return da(e,n),n.find(e=>qr(t.event,e.event))||n[0]||null}function ua(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=ca(n.node,r.node);if(!a)break;sa(a,r.node),n.load--,r.load++,t++}}function ha(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(Br(n,e)&&Math.abs(Ur(e)-Ur(n))<_r.NESTED_THRESHOLD)return!0;return!1}(e,t))return!1;if(n<_r.NESTED_THRESHOLD)return!1;for(const n of e.events)for(const e of t.events)if(qr(n,e))return!0;return!1}function ga(e,t,n){const r=t.events.filter(t=>qr(t,e));if(0===r.length)return null;if(1===r.length)return r[0];const a=r.map(t=>({parent:t,load:t.children.length,hasParallelSibling:t.children.some(t=>{const r=n.find(e=>e.id===t);return r&&Kr(e,r,_r)})}));return a.sort((t,n)=>t.load!==n.load?t.load-n.load:t.hasParallelSibling!==n.hasParallelSibling?t.hasParallelSibling?-1:1:Math.abs(Ur(e)-Ur(t.parent))-Math.abs(Ur(e)-Ur(n.parent))),a[0].parent}function ma(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=Wr(e)-Ur(e),i=a.flatMap(e=>e.children);return o>Math.max(...i.map(e=>{const t=n.find(t=>t.id===e);return t?Wr(t)-Ur(t):0}),0)?a[0]:a.at(-1)||null}function fa(e,t){t.parentId=e.id,e.children.includes(t.id)||e.children.push(t.id)}function pa(e){let t=0;for(const n of e.children)t+=1+pa(n);return t}function va(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 ya(e,t){const n=t.get(e.id);if(!n)return null;let r=n;for(;r.parent&&r.depth>1;)r=r.parent;if(1!==r.depth)return null;const a=r.parent;if(!a)return null;const o=a.children.filter(e=>1===e.depth&&e.event.id!==r.event.id);let i=1/0,l=null;for(const e of o){const t=pa(e);t<i&&(i=t,l=e)}return l?l.event:null}function ba(e,t,n){const r=[];if(1===e.length){const a=ga(e[0],t,n);return a&&(r.push({child:e[0],parent:a}),fa(a,e[0])),r}const a=t.events.filter(t=>e.every(e=>qr(t,e)));if(0===a.length){for(const a of e){const o=ga(a,t,n);if(o)r.push({child:a,parent:o}),fa(o,a);else{const t=e.find(e=>e.id!==a.id&&Br(e,a));if(t){const e=ya(t,va(n));e&&(r.push({child:a,parent:e}),fa(e,a))}}}return r}const o=[...e].toSorted((e,t)=>Wr(t)-Ur(t)-(Wr(e)-Ur(e)));if(o.length%a.length===0){const e=o.length/a.length;for(let t=0;t<a.length;t++){const n=a[t],i=o.slice(t*e,(t+1)*e);for(const e of i)r.push({child:e,parent:n}),fa(n,e)}}else for(const e of o){const t=ma(e,a,o);t&&(r.push({child:e,parent:t}),fa(t,e))}return r}function xa(e,t){const n=[],r=new Map,a=new Map;t.forEach(e=>a.set(e.id,e));for(const t of e)for(const e of t.events){const t={event:a.get(e.id),children:[],parent:null,depth:0,isProcessed:!1};n.push(t),r.set(e.id,t)}for(let n=0;n<e.length;n++){const o=e[n],i=o.events.map(e=>a.get(e.id));let l=!1;for(let s=n-1;s>=0&&!l;s--){const n=e[s],d={events:n.events.map(e=>a.get(e.id)),startHour:n.startHour,endHour:n.endHour};if(ha(d,{events:i,startHour:o.startHour,endHour:o.endHour})){const e=ba(i,d,t);for(const t of e){const e=r.get(t.child.id),n=r.get(t.parent.id);e.parent=n,e.depth=n.depth+1,n.children.push(e)}l=!0}}}const o=n.filter(e=>null===e.parent);return o.forEach(e=>{e.depth=0}),function(e,t){for(let n=e.length-1;n>=1;n--){const r=oa(e[n].events.map(e=>t.find(t=>t.event.id===e.id)),t);ia(r)&&ua(r)}}(e,n),o}const wa={calculateDayEventLayouts(e,t={}){const n=e.map(zr);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)||Br(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:_r.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{ra(xa(Xr([...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}},Da=(e,t,n=7,r)=>{const a=new Map;for(let o=0;o<n;o++){const i=[];e.forEach(e=>{var a;if(e.allDay)return;const l=Dr(e,t,n,r);if(l.length>0){const n=l.find(e=>e.dayIndex===o);if(n){const r=n.endHour>=24?23.99:n.endHour,a=Object.assign(Object.assign({},e),{start:G(C(pe(t,o),n.startHour)),end:G(C(pe(t,o),r)),day:o});i.push(a)}}else if(e.day===o){const t=e=>r?z(e,r):_(e);i.push(Object.assign(Object.assign({},e),{start:G(t(e.start),r),end:G(t(null!==(a=e.end)&&void 0!==a?a:e.start),r),day:o}))}});const l=wa.calculateDayEventLayouts(i,{viewType:"week"});a.set(o,l)}return a},Ea=(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},Ca={HOUR_HEIGHT:72,FIRST_HOUR:0,LAST_HOUR:24,ALL_DAY_HEIGHT:28};function Ta(e){const{app:n,onEventCreated:r}=e,{t:o}=bt(),i=a.useCallback(e=>{e.dataTransfer&&e.dataTransfer.types.includes("application/x-dayflow-calendar")&&(e.preventDefault(),e.dataTransfer.dropEffect="copy")},[]);return{handleDrop:a.useCallback((e,a,i,l)=>{if(e.preventDefault(),!e.dataTransfer)return null;const s=e.dataTransfer.getData("application/x-dayflow-calendar");if(!s)return null;try{const e=JSON.parse(s);let d,c,u=!1;if(l){const e=t.Temporal.PlainDate.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate()});d=e,c=e,u=!0}else if(void 0===i){const e=new Date(a);e.setHours(9,0,0,0);const t=new Date(e);t.setHours(10,0,0,0),d=G(e,n.timeZone),c=G(t,n.timeZone)}else{const e=new Date(a);e.setHours(i,0,0,0);const t=new Date(e);t.setHours(i+1,0,0,0),d=G(e,n.timeZone),c=G(t,n.timeZone)}const h={id:`event-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,title:o(u?"newAllDayCalendarEvent":"newCalendarEvent",{calendarName:e.calendarName}),description:"",start:d,end:c,calendarId:e.calendarId,allDay:u};return n.addEvent(h),null==r||r(h),h}catch(e){return console.error("Error creating event from calendar drop:",e),null}},[n,r]),handleDragOver:i}}let ka=null;const Sa={handleMoveStart:()=>{},handleCreateStart:()=>{},handleResizeStart:void 0,handleCreateAllDayEvent:()=>{},dragState:{active:!1,mode:null,eventId:null,targetDate:null,startDate:null,endDate:null},isDragging:!1};function Ma(e,t){return ka?ka(e,t):Sa}const Na=({app:e,config:t,customDetailPanelContent:n,customEventDetailDialog:r,calendarRef:o,switcherMode:i="buttons",selectedEventId:l,onEventSelect:s,onDateChange:d,detailPanelEventId:c,onDetailPanelToggle:u})=>{const h=e.getEvents(),{screenSize:g}=vt(),m="desktop"!==g,[f,p]=a.useState(!1),{hourHeight:v=Ca.HOUR_HEIGHT,firstHour:y=Ca.FIRST_HOUR,lastHour:b=Ca.LAST_HOUR,allDayHeight:x=Ca.ALL_DAY_HEIGHT,showAllDay:w=!0,timeFormat:D="24h",secondaryTimeZone:C,showEventDots:T=!0}=t,k=v,S=y,M=b,N=x,I=!w;a.useEffect(()=>{p("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const R=e.getCustomMobileEventRenderer()||er,[O,H]=a.useState(null),[A,P]=a.useState(null),[L,$]=a.useState(null),j=void 0===l?A:l,Y=void 0===c?L:c,F=a.useMemo(()=>j&&h.find(e=>e.id===j)||null,[j,h]),V=e=>{s?s(e):P(e)},[Z,U]=a.useState(null),[W,B]=a.useState(!1),[K,q]=a.useState(null),J=a.useRef(null),Q=e.getCurrentDate(),[ae,oe]=a.useState(Q),ie=a.useRef(Q.getTime());Q.getTime()!==ie.current&&(ie.current=Q.getTime(),Q.getFullYear()===ae.getFullYear()&&Q.getMonth()===ae.getMonth()||oe(Q));const le=a.useCallback(t=>{oe(n=>{const r=new Date(n.getFullYear(),n.getMonth()+t,1);return e.setVisibleMonth(r),r})},[e]),se=a.useRef(e.state.highlightedEventId);a.useEffect(()=>{var t;if(e.state.highlightedEventId!==se.current)if(e.state.highlightedEventId){V(e.state.highlightedEventId);const n=e.getEvents().find(t=>t.id===e.state.highlightedEventId);if(n&&!n.allDay){const e=E(n.start),r=null===(t=o.current)||void 0===t?void 0:t.querySelector(".df-calendar-content");if(r){const t=(e-S)*k;requestAnimationFrame(()=>{r.scrollTo({top:Math.max(0,t-100),behavior:"smooth"})})}}}else V(null);se.current=e.state.highlightedEventId},[e.state.highlightedEventId,S,k,o,e]);const de=a.useRef(null),ce=a.useRef(null),ue=a.useMemo(()=>Ea(Q),[Q]),he=e.timeZone,ge=a.useMemo(()=>((e,t,n,r)=>{const a=new Date(t);a.setHours(0,0,0,0);const o=new Date(t);o.setHours(23,59,59,999);const i=e=>r?z(e,r):_(e);return e.filter(e=>{var t;const n=i(e.start),r=i(null!==(t=e.end)&&void 0!==t?t:e.start);if(e.allDay){const e=new Date(n);e.setHours(0,0,0,0);const t=new Date(r);return t.setHours(0,0,0,0),e<=o&&t>=a}return n<o&&r>a}).map(e=>{const t=i(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,ue,he),[h,Q,ue,he]),me=a.useMemo(()=>((e,t,n)=>{const r=new Date(t);r.setHours(0,0,0,0);const a=new Date(r);a.setDate(a.getDate()+1);const o=e=>n?z(e,n):_(e);return e.filter(e=>!e.allDay).map(e=>{var t;const i=o(e.start),l=o(null!==(t=e.end)&&void 0!==t?t:e.start);let s=G(i,n),d=G(l,n);return i<r&&(s=G(r,n)),l>a&&(d=G(a,n)),Object.assign(Object.assign({},e),{start:s,end:d,day:0})})})(ge,Q,he),[ge,Q,he]),fe=a.useMemo(()=>wa.calculateDayEventLayouts(me,{viewType:"day"}),[me]),pe=a.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(ft(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=_(e.start),r=_(e.end),a=_(t.start);return n<=_(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})(ge,e.state.allDaySortComparator),[ge,e.state.allDaySortComparator]),ve=a.useMemo(()=>{if(0===pe.length)return N;return(Math.max(...pe.map(e=>e.row))+1)*N},[pe,N]),{handleMoveStart:ye,handleCreateStart:be,handleResizeStart:xe,handleCreateAllDayEvent:De,dragState:Ee,isDragging:Ce}=Ma(e,{calendarRef:o,allDayRowRef:w?de:void 0,timeGridRef:ce,viewType:exports.ViewType.DAY,onEventsUpdate:(t,n,r)=>{const a=t(ge),o=new Set(a.map(e=>e.id)),i=ge.filter(e=>!o.has(e.id)),l=new Set(ge.map(e=>e.id)),s=a.filter(e=>!l.has(e.id)),d=a.filter(e=>{if(!l.has(e.id))return!1;const t=h.find(t=>t.id===e.id);return t&&we(t,e)});e.applyEventsChanges({delete:i.map(e=>e.id),add:s,update:d.map(e=>({id:e.id,updates:e}))},void 0,r)},onEventCreate:t=>{m?(q(t),B(!0)):(e.addEvent(t),U(t.id))},onEventEdit:()=>{},currentWeekStart:ue,events:ge,calculateNewEventLayout:(e,t,n)=>((e,t,n,r,a,o)=>{const i=new Date(r),l=new Date(r);i.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:G(i,o),end:G(l,o),calendarId:"blue",allDay:!1}];return wa.calculateDayEventLayouts(s,{viewType:"day"}).get("-1")||null})(0,t,n,Q,me,he),calculateDragLayout:(e,t,n,r)=>((e,t,n,r,a,o,i)=>{const l=o.filter(t=>t.id!==e.id),s=new Date(a),d=new Date(s);d.setHours(Math.floor(n),n%1*60,0,0);const c=new Date(s);c.setHours(Math.floor(r),r%1*60,0,0);const u=[...l,Object.assign(Object.assign({},e),{start:G(d,i),end:G(c,i),day:0})];return 0===u.length?null:wa.calculateDayEventLayouts(u,{viewType:"day"}).get(e.id)||null})(e,0,n,r,Q,me,he),TIME_COLUMN_WIDTH:C&&!m?88:m?48:80,isMobile:m}),{handleDrop:Te,handleDragOver:ke}=Ta({app:e,onEventCreated:e=>{U(e.id)}}),Se=Array.from({length:24},(e,t)=>({hour:t+S,label:X(t+S,0,D)})),Me=a.useMemo(()=>C?ee(Se,C,D,Q,he):void 0,[C,D,S,Q,he]),Ne=a.useMemo(()=>C?te(he,Q):void 0,[C,he,Q]),Re=a.useMemo(()=>C?te(C,Q):void 0,[C,Q]),Oe=a.useCallback(t=>{const n=new Date(t.getFullYear(),t.getMonth(),t.getDate());e.setCurrentDate(n),oe(new Date(n.getFullYear(),n.getMonth(),1))},[e]),He=a.useMemo(()=>{const e=re(he);return Q.toDateString()===e.toDateString()},[Q,he]);return a.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=ne(he),n=e.getHours()+e.getMinutes()/60,r=t.clientHeight;t.scrollTop=Math.max(0,(n-S)*k-r/2)}}},[he,t.scrollToCurrentTime,S,k]),a.useEffect(()=>{H(ne(he));const e=setInterval(()=>H(ne(he)),6e4);return()=>clearInterval(e)},[he]),Ie("div",{className:"df-day-view flex h-full bg-gray-50 dark:bg-gray-800",children:[Ie(Vr,{app:e,currentDate:Q,currentWeekStart:ue,events:h,currentDayEvents:ge,organizedAllDayEvents:pe,allDayAreaHeight:ve,timeSlots:Se,eventLayouts:fe,isToday:He,currentTime:O,selectedEventId:j,setSelectedEventId:V,newlyCreatedEventId:Z,setNewlyCreatedEventId:U,detailPanelEventId:Y,setDetailPanelEventId:e=>{u?u(e):$(e)},dragState:Ee,isDragging:Ce,handleMoveStart:ye,handleResizeStart:xe,handleCreateStart:be,handleCreateAllDayEvent:De,handleTouchStart:(e,t)=>{if(!m&&!f)return;const n=e.touches[0],r=n.clientX,a=n.clientY,i=e.currentTarget;J.current=setTimeout(()=>{var e,n,l;const s=null===(n=null===(e=o.current)||void 0===e?void 0:e.querySelector(".df-calendar-content"))||void 0===n?void 0:n.getBoundingClientRect();if(!s)return;const d=null===(l=o.current)||void 0===l?void 0:l.querySelector(".df-calendar-content"),c=d?d.scrollTop:0,u=a-s.top+c;null==be||be({preventDefault:()=>{},stopPropagation:()=>{},touches:[{clientX:r,clientY:a}],changedTouches:[{clientX:r,clientY:a}],target:i,currentTarget:i,cancelable:!0},t,S+u/k)},500)},handleTouchEnd:()=>{J.current&&(clearTimeout(J.current),J.current=null)},handleTouchMove:()=>{J.current&&(clearTimeout(J.current),J.current=null)},handleDragOver:ke,handleDrop:Te,handleEventUpdate:t=>e.updateEvent(t.id,t),handleEventDelete:t=>e.deleteEvent(t),onDateChange:d,customDetailPanelContent:n,customEventDetailDialog:r,calendarRef:o,allDayRowRef:de,timeGridRef:ce,switcherMode:i,isMobile:m,isTouch:f,setDraftEvent:q,setIsDrawerOpen:B,ALL_DAY_HEIGHT:N,HOUR_HEIGHT:k,FIRST_HOUR:S,LAST_HOUR:M,showAllDay:w,showStartOfDayLabel:I,timeFormat:D,secondaryTimeSlots:Me,primaryTzLabel:Ne,secondaryTzLabel:Re,appTimeZone:he}),Ie(Zr,{app:e,currentDate:Q,visibleMonth:ae,currentDayEvents:ge,selectedEvent:F,setSelectedEvent:e=>V(e?e.id:null),handleMonthChange:le,handleDateSelect:Oe,switcherMode:i,timeFormat:D,showEventDots:T,appTimeZone:he}),Ie(R,{isOpen:W,onClose:()=>{B(!1),q(null)},onSave:t=>{h.some(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),B(!1),q(null)},draftEvent:K,app:e,timeFormat:D})]})},Ia=({originalComponent:e,app:t,viewType:n,config:r,customDetailPanelContent:o,customEventDetailDialog:i,calendarRef:l,switcherMode:s,meta:d,selectedEventId:c,detailPanelEventId:u,onEventSelect:h,onDateChange:g,onDetailPanelToggle:m})=>{const f=t.getPlugin("events"),p=t.getPlugin("drag"),v=t.getCurrentDate(),y=t.state.currentView,b=t.getEvents(),x=a.useCallback(e=>f?f.update(e.id,e):t.updateEvent(e.id,e),[f,t]),w=a.useCallback(e=>f?f.delete(e):t.deleteEvent(e),[f,t]),D=a.useCallback(e=>{f?f.add(e):t.addEvent(e)},[f,t]),E=a.useCallback(e=>{g?g(e):t.setCurrentDate(e)},[t,g]),C=a.useCallback(e=>{t.changeView(e)},[t]),T=a.useMemo(()=>{const e=t.getViewConfig(n);return Object.assign(Object.assign({},e),r)},[r,t.state.views,n]),k=a.useMemo(()=>({app:t,currentDate:v,currentView:y,events:b,onEventUpdate:x,onEventDelete:w,onEventCreate:D,onDateChange:E,onViewChange:C,config:T,customDetailPanelContent:o,customEventDetailDialog:i,calendarRef:l,switcherMode:s,meta:d,selectedEventId:c,detailPanelEventId:u,onEventSelect:h,onDetailPanelToggle:m}),[t,v,y,b,x,w,D,E,C,T,o,i,l,s,d,c,u,h,m]),S=a.useMemo(()=>{const e={currentDate:v,events:b,setEvents:e=>{b.forEach(e=>w(e.id)),e.forEach(e=>D(e))},updateEvent:x,deleteEvent:w,addEvent:D,goToPrevious:()=>{const e=new Date(v);switch(y){case exports.ViewType.DAY:e.setDate(e.getDate()-1);break;case exports.ViewType.WEEK:e.setDate(e.getDate()-7);break;case exports.ViewType.MONTH:e.setMonth(e.getMonth()-1)}E(e)},goToNext:()=>{const e=new Date(v);switch(y){case exports.ViewType.DAY:e.setDate(e.getDate()+1);break;case exports.ViewType.WEEK:e.setDate(e.getDate()+7);break;case exports.ViewType.MONTH:e.setMonth(e.getMonth()+1)}E(e)},goToToday:()=>{E(new Date)},changeView:C,selectDate:E};return Object.assign(Object.assign({calendar:e},k),{eventsService:f,dragService:p})},[v,b,y,x,w,D,E,C,k,f,p]);return Ie(e,Object.assign({},S))},Ra={},Oa=e=>n.h(Ia,Object.assign(Object.assign({},e),{viewType:exports.ViewType.DAY,originalComponent:Na,className:"day-view-factory"}));Oa.displayName="DayViewAdapter";const Ha=(e={})=>{const t=Object.assign(Object.assign({},Ra),e);return{type:exports.ViewType.DAY,component:Oa,config:t}},Aa=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:t=[],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:t.map((e,t)=>Ie("div",{className:"flex justify-center",children:Ie("span",{className:"text-[10px] font-medium "+(e.isToday?"df-text-primary":"text-gray-500"),children:Aa(e.dayName)})},`label-${t}`))}),Ie("div",{className:"relative grid grid-cols-7 overflow-hidden",children:(()=>{if(!r)return null;const o=t.findIndex(e=>e.fullDate.getTime()===r.getTime()),i=-1===o?"0":`calc(${(o+.5)/7*100}% - 16px)`,l=`calc(${1/7*100}% + 32px)`;return Ie(n.Fragment,{children:[Ie("div",{className:"absolute rounded-full bg-gray-100 transition-all duration-300 dark:bg-gray-800",style:{left:i,top:0,width:l,height:"32px"}}),t.map((t,n)=>{const r=t.isCurrent,i=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?"df-text-primary font-bold":i?"text-gray-900 dark:text-gray-100":"text-gray-500 dark:text-gray-400"} `,children:[t.date,t.isToday&&!r&&Ie("div",{className:"df-fill-primary absolute bottom-1 h-1 w-1 rounded-full"})]})},`date-${n}`)})]})})()})]}),La=({app:e,weekDaysLabels:t,mobileWeekDaysLabels:r,weekDates:o,fullWeekDates:i,isSlidingView:l,mobilePageStart:s,currentWeekStart:d,gridWidth:c,allDayAreaHeight:u,organizedAllDaySegments:h,allDayLabelText:g,isMobile:m,isTouch:f,showAllDay:p=!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:O,newlyCreatedEventId:H,setNewlyCreatedEventId:A,selectedEventId:P,setSelectedEventId:L,detailPanelEventId:$,setDetailPanelEventId:j,handleCreateAllDayEvent:Y,handleDragOver:F,handleDrop:V,customDetailPanelContent:Z,customEventDetailDialog:_})=>{const z={flexShrink:0},[U,W]=a.useState(null),B=a.useMemo(()=>Ze(),[]),G=!!S&&S.length>0&&!m,K=e.canMutateFromUI();a.useEffect(()=>{K||W(null)},[K]);return Ie("div",{className:"flex w-full flex-col",children:[l&&i&&s&&Ie(Pa,{app:e,fullWeekDates:i,mobilePageStart:s,onDateChange:O}),Ie("div",{className:`flex flex-none ${p?"border-b border-gray-200 dark:border-gray-700":""} relative z-10`,onContextMenu:e=>e.preventDefault(),children:[p&&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 "+(l?"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:p?`${u+(l?0:36)}px`:"auto"},children:Ie("div",{ref:b,className:"flex flex-col",style:{width:c,minWidth:"100%",transform:l?"translateX(calc(-100% / 3))":void 0},children:[!l&&Ie("div",{className:"df-week-header flex border-b",style:{marginRight:B?"-50px":"0px",paddingRight:B?"50px":"0px"},children:t.map((e,t)=>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:z,children:Ie(n.Fragment,m?{children:[Ie("div",{className:"text-[12px] leading-tight font-medium text-gray-500",children:r[t]}),Ie("div",{className:`${Et} h-7 w-7 text-base font-medium ${o[t].isToday?Yt:""}`,children:o[t].date})]}:{children:[Ie("div",{className:"mt-1 mr-1 inline-flex items-center justify-center text-sm",children:e}),Ie("div",{className:`${Et} ${o[t].isToday?Yt:""}`,children:o[t].date})]})},t))}),p&&Ie("div",{className:`${Rt} 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:[t.map((e,n)=>{const r=new Date(d);return r.setDate(d.getDate()+n),Ie("div",{className:"df-all-day-cell flex-1 border-r relative transition-[min-height] duration-300 ease-in-out "+(n!==t.length-1||!m&&B?"":"border-r-0"),style:Object.assign({minHeight:`${u}px`},z),onMouseDown:e=>null==Y?void 0:Y(e,n),onDblClick:e=>null==Y?void 0:Y(e,n),onDragOver:F,onDrop:e=>{V(e,r,void 0,!0)},onContextMenu:e=>((e,t)=>{if(e.preventDefault(),m||!K)return;const n=new Date(d);n.setDate(d.getDate()+t),n.setHours(0,0,0,0),W({x:e.clientX,y:e.clientY,date:n})})(e,n)},`allday-${n}`)}),Ie("div",{className:"pointer-events-none absolute inset-0",children:h.map(n=>Ie(Lr,{event:n.event,segment:n,segmentIndex:n.row,isAllDay:!0,isMultiDay:!0,allDayHeight:x,calendarRef:v,viewType:exports.ViewType.WEEK,columnsPerRow:t.length,isBeingDragged:C&&(null==E?void 0:E.eventId)===n.event.id&&"move"===(null==E?void 0:E.mode),hourHeight:w,firstHour:D,onMoveStart:M,onResizeStart:N,onEventUpdate:I,onEventDelete:R,newlyCreatedEventId:H,onDetailPanelOpen:()=>A(null),selectedEventId:P,detailPanelEventId:$,onEventSelect:e=>{L(e)},onEventLongPress:e=>{(m||f)&&L(e)},onDetailPanelToggle:e=>j(e),customDetailPanelContent:Z,customEventDetailDialog:_,app:e,isMobile:m,isSlidingView:l,enableTouch:f},n.event.id))})]})})]})}),K&&U&&Ie(yr,{x:U.x,y:U.y,date:U.date,viewType:exports.ViewType.WEEK,onClose:()=>W(null),app:e,onCreateEvent:()=>{const e=Math.floor((U.date.getTime()-d.getTime())/864e5);null==Y||Y({clientX:U.x,clientY:U.y},e)}})]})]})},$a=({app:e,timeSlots:t,weekDaysLabels:r,currentWeekStart:o,currentWeekEvents:i,eventLayouts:l,gridWidth:s,isMobile:d,isTouch:c,scrollerRef:u,timeGridRef:h,leftFrozenContentRef:g,swipeContentRef:m,calendarRef:f,handleScroll:p,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:O,setSelectedEventId:H,detailPanelEventId:A,setDetailPanelEventId:P,customDetailPanelContent:L,customEventDetailDialog:$,isSlidingView:j,isCurrentWeek:Y,currentTime:F,HOUR_HEIGHT:V,FIRST_HOUR:Z,LAST_HOUR:_,showStartOfDayLabel:z,timeFormat:U="24h",secondaryTimeSlots:W,appTimeZone:B})=>{var G,K;const q=!!W&&W.length>0&&!d,J={flexShrink:0},Q=a.useRef(e.state.highlightedEventId),[ee,te]=a.useState(null),ne=a.useMemo(()=>Ze(),[]),re=e.canMutateFromUI();a.useEffect(()=>{re||te(null)},[re]);const ae=e=>{if(!h.current)return Z;const t=h.current.getBoundingClientRect();return Z+(e-t.top)/V};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%"===s?"overflow-x-hidden":"snap-x snap-mandatory"),style:{display:"grid",gridTemplateColumns:"auto 1fr"},onScroll:p,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:q?Ie(n.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:z&&null!==(G=null==W?void 0:W[0])&&void 0!==G?G:""}),Ie("span",{className:"text-[10px] text-gray-500 md:text-[12px] dark:text-gray-400",children:z?X(Z,0,U):""})]})}):Ie("div",{className:"absolute right-2 -bottom-1 text-[10px] text-gray-500 select-none md:text-[12px] dark:text-gray-400",children:z?X(Z,0,U):""})}),t.map((e,t)=>{var n;return Ie("div",{className:kt,children:Ie("div",q?{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:z&&0===t?"":null!==(n=null==W?void 0:W[t])&&void 0!==n?n:""}),Ie("span",{className:"text-[10px] md:text-[12px]",children:z&&0===t?"":e.label})]}:{className:`${St} text-[10px] md:text-[12px]`,children:z&&0===t?"":e.label})},t)}),Ie("div",{className:"relative",children:Ie("div",q?{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!==(K=null==W?void 0:W[0])&&void 0!==K?K:""}),Ie("span",{className:"text-[10px] md:text-[12px]",children:X(0,0,U)})]}:{className:`${St} text-[10px] md:text-[12px]`,children:X(0,0,U)})}),Y&&F&&(()=>{const e=F,t=e.getHours()+e.getMinutes()/60;if(t<Z||t>_)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)*V}px`,transform:"translateY(-50%)",marginTop:"0.75rem"},children:Ie("div",{className:It,children:X(t,0,U,!1)})})})()]}),Ie("div",{ref:m,className:"flex",style:{width:s,minWidth:"100%",transform:j?"translateX(calc(-100% / 3))":void 0},children:Ie("div",{className:"grow",children:[Ie("div",{className:`${zt} flex border-t-0`,children:r.map((e,t)=>Ie("div",{className:`relative flex-1 ${t!==r.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&&F&&(()=>{const e=F,t=e.getHours()+e.getMinutes()/60;if(t<Z||t>_)return null;const n=new Date(e);n.setHours(0,0,0,0);const a=new Date(o);a.setHours(0,0,0,0);const i=n.getTime()-a.getTime(),l=Math.round(i/864e5);return Ie("div",{className:Nt,style:{top:`${(t-Z)*V}px`,width:"100%",height:0,zIndex:20},children:[Ie("div",{className:"flex w-0 items-center"}),Ie("div",{className:"flex flex-1",children:r.map((e,t)=>Ie("div",{className:"flex flex-1 items-center",children:Ie("div",{className:"relative h-0.5 w-full "+(t===l?"df-fill-primary":"df-tint-primary-lg"),style:{zIndex:9999},children:t===l&&0!==l&&Ie("div",{className:"df-fill-primary absolute h-2 w-2 rounded-full",style:{top:"-3px",left:"-4px"}})})},t))})]})})(),t.map((e,t)=>Ie("div",{className:Mt,children:r.map((n,a)=>{const i=new Date(o);return i.setDate(o.getDate()+a),Ie("div",{className:"df-time-grid-cell flex-1 relative border-r select-none snap-start "+(a!==r.length-1||!d&&ne?"":"border-r-0"),style:J,onClick:()=>{const e=new Date(o);e.setDate(o.getDate()+a),null==N||N(e)},onMouseDown:e=>{Yr(e,a,ae(e.clientY),c,v)},onDblClick:e=>{null==v||v(e,a,ae(e.clientY)),Fr()},onTouchStart:t=>y(t,a,e.hour),onTouchEnd:b,onTouchMove:x,onDragOver:w,onDrop:t=>{D(t,i,e.hour)},onContextMenu:t=>((e,t,n)=>{if(e.preventDefault(),d||!re)return;const r=new Date(o);if(r.setDate(o.getDate()+t),h.current){const t=h.current.getBoundingClientRect(),n=(e.clientY-t.top)/V+Z,a=Math.floor(n),o=Math.floor(60*(n-a)),i=15*Math.round(o/15),l=60===i?a+1:a,s=60===i?0:i;r.setHours(l,s,0,0)}else r.setHours(n,0,0,0);te({x:e.clientX,y:e.clientY,date:r})})(t,a,e.hour)},`${t}-${a}`)})},t)),Ie("div",{className:`${zt} flex`,children:r.map((e,t)=>Ie("div",{className:`relative flex-1 ${t!==r.length-1||!d&&ne?"border-r":""} border-gray-200 dark:border-gray-700`,style:J},`24-${t}`))}),r.map((t,n)=>{const a=r.length,s=fe(n,i),u=[];return s.forEach(e=>{const t=Dr(e,o,r.length,B);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})}),i.forEach(e=>{if(e.allDay||e.day===n)return;const t=Dr(e,o,r.length,B).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/a*n}%)`,width:100/a+"%",height:"100%"},children:u.map(({event:t,segmentInfo:r})=>{const o=l.get(n),i=null==o?void 0:o.get(t.id);return Ie(Lr,{event:t,layout:i,viewType:exports.ViewType.WEEK,calendarRef:f,columnsPerRow:a,isBeingDragged:C&&(null==E?void 0:E.eventId)===t.id&&"move"===(null==E?void 0:E.mode),hourHeight:V,firstHour:Z,onMoveStart:T,onResizeStart:k,onEventUpdate:S,onEventDelete:M,newlyCreatedEventId:I,onDetailPanelOpen:()=>R(null),selectedEventId:O,detailPanelEventId:A,onEventSelect:t=>{H(t),e.state.highlightedEventId&&(e.highlightEvent(null),Q.current=null)},onEventLongPress:e=>{(d||c)&&H(e)},onDetailPanelToggle:e=>P(e),customDetailPanelContent:L,customEventDetailDialog:$,multiDaySegmentInfo:r,app:e,isMobile:d,isSlidingView:j,enableTouch:c,appTimeZone:B},r?`${t.id}-seg-${n}`:t.id)})},`events-day-${n}`)})]})]})})]}),re&&ee&&Ie(yr,{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,i={preventDefault:()=>{},stopPropagation:()=>{},clientX:ee.x,clientY:ee.y};v(i,r,a)}}})]})},ja=({app:e,config:n,customDetailPanelContent:r,customEventDetailDialog:o,calendarRef:i,selectedEventId:l,onEventSelect:s,onDateChange:d,detailPanelEventId:c,onDetailPanelToggle:u})=>{var h;const{t:g,getWeekDaysLabels:m,locale:f}=bt(),p=e.getCurrentDate(),v=a.useMemo(()=>p,[p.getTime()]),y=e.getEvents(),{screenSize:b}=vt(),x="desktop"!==b,w=a.useRef(null),[D,T]=a.useState(!1),{hourHeight:k=Ca.HOUR_HEIGHT,firstHour:S=Ca.FIRST_HOUR,lastHour:M=Ca.LAST_HOUR,allDayHeight:N=Ca.ALL_DAY_HEIGHT,showAllDay:I=!0,timeFormat:R="24h",secondaryTimeZone:O}=n,H=O&&"mobile"!==b?88:"mobile"===b?48:80,A=k,P=S,L=M,$=N,j=!I;a.useEffect(()=>{T("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const Y=e.getCustomMobileEventRenderer()||er,F="desktop"!==b,V=F?2:7,Z=F,U=null!==(h=n.startOfWeek)&&void 0!==h?h:1,W=Z?"300%":"100%",B=a.useMemo(()=>Ea(v,U),[v,U]),[K,q]=a.useState(()=>{const e=new Date(v);return e.setHours(0,0,0,0),e});a.useEffect(()=>{Z&&q(e=>{const t=new Date(v);t.setHours(0,0,0,0);const n=new Date(e),r=new Date(e);return r.setDate(r.getDate()+V-1),t>=n&&t<=r?e:t})},[v,Z,V]);const J=Z?K:B,Q=Z?3*V:7,ae=a.useMemo(()=>{if(!Z)return J;const e=new Date(J);return e.setDate(e.getDate()-V),e},[J,Z,V]),[oe,ie]=a.useState(null),[le,se]=a.useState(null),[de,ce]=a.useState(null),ue=void 0===l?le:l,he=void 0===c?de:c,ge=e=>{s?s(e):se(e)},me=e=>{u?u(e):ce(e)},[fe,ve]=a.useState(null),[ye,be]=a.useState(!1),[xe,De]=a.useState(null),Ee=a.useRef(null),[Ce,Te]=a.useState(0),[ke,Se]=a.useState(!1),Me=a.useRef(null),Ne=a.useRef(null),Re=a.useRef(null),Oe=a.useRef(null),He=a.useRef(null),Ae=a.useRef({x:0,y:0}),Pe=a.useRef(!1),Le=a.useRef(0);a.useEffect(()=>{if(!Z)return;const t=Ne.current;if(!t)return;const n=e=>{Ae.current={x:e.touches[0].clientX,y:e.touches[0].clientY},Pe.current=!1,Le.current=0,Se(!1)},r=e=>{if(ke)return;const n=e.touches[0].clientX-Ae.current.x,r=e.touches[0].clientY-Ae.current.y;if(!Pe.current&&Math.abs(n)>10&&Math.abs(n)>Math.abs(r)&&(Pe.current=!0),Pe.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))`;Re.current&&(Re.current.style.transition="none",Re.current.style.transform=o),He.current&&(He.current.style.transition="none",He.current.style.transform=o),Le.current=a}},a=()=>{var n;if(!Pe.current)return void(Le.current=0);const r=Le.current,a=((null===(n=He.current)||void 0===n?void 0:n.clientWidth)||t.clientWidth)/Q;r>100?(Se(!0),Te(a),setTimeout(()=>{const t=new Date(K);t.setDate(t.getDate()-1),q(t),e.setCurrentDate(t),Te(0),Le.current=0,Se(!1)},300)):r<-100?(Se(!0),Te(-a),setTimeout(()=>{const t=new Date(K);t.setDate(t.getDate()+1),q(t),e.setCurrentDate(t),Te(0),Le.current=0,Se(!1)},300)):(Se(!0),Te(0),Le.current=0,setTimeout(()=>{Se(!1)},300))};return t.addEventListener("touchstart",n,{passive:!0}),t.addEventListener("touchmove",r,{passive:!1}),t.addEventListener("touchend",a,{passive:!0}),()=>{t.removeEventListener("touchstart",n),t.removeEventListener("touchmove",r),t.removeEventListener("touchend",a)}},[Z,e,J,ke,V,Q]);const $e=e.timeZone,je=a.useMemo(()=>((e,t,n=7,r)=>{const a=new Date(t);a.setDate(t.getDate()+(n-1)),a.setHours(23,59,59,999);const o=e=>r?z(e,r):_(e);return e.filter(e=>{var n;const r=o(e.start);r.setHours(0,0,0,0);const i=o(null!==(n=e.end)&&void 0!==n?n:e.start);return i.setHours(23,59,59,999),i>=t&&r<=a}).map(e=>{const r=o(e.start),a=Math.floor((r.getTime()-t.getTime())/864e5),i=Math.max(0,Math.min(n-1,a));return Object.assign(Object.assign({},e),{day:i})})})(y,ae,Q,$e),[y,ae,Q,$e]),Ye=a.useRef(e.state.highlightedEventId);a.useEffect(()=>{if(e.state.highlightedEventId!==Ye.current)if(e.state.highlightedEventId){ge(e.state.highlightedEventId);const t=je.find(t=>t.id===e.state.highlightedEventId);if(t&&!t.allDay){const e=E(t.start),n=Ne.current;if(n){const t=(e-P)*A;requestAnimationFrame(()=>{n.scrollTo({top:Math.max(0,t-100),behavior:"smooth"})})}}}else ge(null);Ye.current=e.state.highlightedEventId},[e.state.highlightedEventId,je,P,A]);const Fe=a.useMemo(()=>((e,t,n=7,r)=>{const a=wr(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=ft(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})(je,ae,Q,e.state.allDaySortComparator),[je,ae,Q,e.state.allDaySortComparator]),Ve=a.useMemo(()=>{const e=Z?Fe.filter(e=>e.endDayIndex>=V&&e.startDayIndex<=2*V-1):Fe;if(0===e.length)return $;const t=Math.max(...e.map(e=>e.row));return $+t*$},[Fe,$,Z,V]),Ze=a.useMemo(()=>Da(je,ae,Q,$e),[je,ae,Q,$e]),_e=a.useCallback((t,n,r)=>{const a=t(je),o=new Set(a.map(e=>e.id)),i=je.filter(e=>!o.has(e.id)),l=new Set(je.map(e=>e.id)),s=a.filter(e=>!l.has(e.id)),d=a.filter(e=>{if(!l.has(e.id))return!1;const t=je.find(t=>t.id===e.id);return t&&we(t,e)});e.applyEventsChanges({delete:i.map(e=>e.id),add:s,update:d.map(e=>({id:e.id,updates:e}))},n,r)},[je,e]),ze=a.useCallback(t=>{x?(De(t),be(!0)):(e.addEvent(t),ve(t.id))},[x,e]),Ue=a.useCallback(()=>{},[]),We=a.useCallback((e,t,n)=>((e,t,n,r,a,o=7,i)=>{var l;const s=pe(a,e),d=pe(a,e);s.setHours(Math.floor(t),t%1*60,0,0),d.setHours(Math.floor(n),n%1*60,0,0);const c={id:"-1",title:"Temp",day:e,start:G(s,i),end:G(d,i),calendarId:"blue",allDay:!1};return(null===(l=Da([...r,c],a,o,i).get(e))||void 0===l?void 0:l.get("-1"))||null})(e,t,n,je,ae,Q,$e),[je,ae,Q,$e]),Be=a.useCallback((e,t,n,r)=>((e,t,n,r,a,o,i=7,l)=>{var s;const d=a.map(a=>{if(a.id!==e.id)return a;const i=pe(o,t),s=C(i,n),d=C(i,r),c=G(s,l),u=G(d,l);return Object.assign(Object.assign({},a),{day:t,start:c,end:u})});return(null===(s=Da(d,o,i,l).get(t))||void 0===s?void 0:s.get(e.id))||null})(e,t,n,r,je,ae,Q,$e),[je,ae,Q,$e]),Ge=a.useMemo(()=>({calendarRef:i,allDayRowRef:I?Me:void 0,timeGridRef:w,viewType:exports.ViewType.WEEK,onEventsUpdate:_e,onEventCreate:ze,onEventEdit:Ue,currentWeekStart:ae,events:je,calculateNewEventLayout:We,calculateDragLayout:Be,TIME_COLUMN_WIDTH:H,isMobile:x,gridWidth:W,displayDays:Q}),[i,I,_e,ze,Ue,ae,je,We,Be,H,x,W,Q]),{handleMoveStart:Ke,handleCreateStart:qe,handleResizeStart:Xe,handleCreateAllDayEvent:Je,dragState:Qe,isDragging:et}=Ma(e,Ge),{handleDrop:tt,handleDragOver:nt}=Ta({app:e,onEventCreated:e=>{ve(e.id)}}),rt=a.useMemo(()=>Z?Array.from({length:Q},(e,t)=>{const n=new Date(ae);return n.setDate(n.getDate()+t),n.toLocaleDateString(f,{weekday:"short"})}):m(f,"short",U),[f,m,Z,ae,Q,U]),at=a.useMemo(()=>{if(!x)return[];const e=f.split("-")[0].toLowerCase();return"zh"===e||"ja"===e?m(f,"narrow"):rt.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,f,m,rt]),ot=a.useMemo(()=>g("allDay"),[g]),it=Array.from({length:24},(e,t)=>({hour:t+P,label:X(t+P,0,R)})),lt=a.useMemo(()=>O?ee(it,O,R,v,$e):void 0,[O,R,P,v,$e]),st=a.useMemo(()=>O?te($e,v):void 0,[O,$e,v]),dt=a.useMemo(()=>O?te(O,v):void 0,[O,v]),ct=a.useMemo(()=>{const e=t.Temporal.Now.plainDateISO($e),n=new Date(e.year,e.month-1,e.day).toDateString();return rt.map((e,t)=>{const r=new Date(ae);return r.setDate(ae.getDate()+t),{date:r.getDate(),month:r.toLocaleString(f,{month:"short"}),fullDate:new Date(r),isToday:r.toDateString()===n}})},[ae,rt,f,$e]),ut=a.useMemo(()=>{const e=t.Temporal.Now.plainDateISO($e),n=new Date(e.year,e.month-1,e.day).toDateString(),r=new Date(v.getFullYear(),v.getMonth(),v.getDate()).getTime(),a=B;return Array.from({length:7},(e,t)=>{const o=new Date(a);o.setDate(a.getDate()+t);const i=new Date(o.getFullYear(),o.getMonth(),o.getDate());return{date:o.getDate(),month:o.toLocaleString(f,{month:"short"}),fullDate:new Date(o),isToday:o.toDateString()===n,isCurrent:i.getTime()===r,dayName:o.toLocaleDateString(f,{weekday:"short"})}})},[B,f,v,$e]);a.useEffect(()=>{if(!Z)return Re.current&&(Re.current.style.transform="",Re.current.style.transition=""),void(He.current&&(He.current.style.transform="",He.current.style.transition=""));const e=ke?"transform 0.3s ease-out":"none",t=`translateX(calc(calc(-100% / 3) + ${Ce}px))`;Re.current&&(Re.current.style.transition=e,Re.current.style.transform=t),He.current&&(He.current.style.transition=e,He.current.style.transform=t)},[Ce,ke,Z]);const ht=t=>e.updateEvent(t.id,t),gt=t=>e.deleteEvent(t),mt=a.useMemo(()=>{const e=re($e);e.setHours(0,0,0,0);const t=new Date(ae);t.setHours(0,0,0,0);const n=new Date(t);return n.setDate(t.getDate()+Q),e>=t&&e<n},[ae,Q,$e]);return a.useLayoutEffect(()=>{if(n.scrollToCurrentTime&&Ne.current){const e=Ne.current,t=ne($e),n=t.getHours()+t.getMinutes()/60,r=e.clientHeight;e.scrollTop=Math.max(0,(n-P)*A-r/2)}},[$e,n.scrollToCurrentTime,P,A]),a.useEffect(()=>{ie(ne($e));const e=setInterval(()=>ie(ne($e)),6e4);return()=>clearInterval(e)},[$e]),Ie("div",{className:"df-calendar relative flex flex-col w-full overflow-hidden h-full select-none df-week-view",children:[Ie(jr,{calendar:e,viewType:exports.ViewType.WEEK,currentDate:v,onPrevious:()=>{if(Z){const t=new Date(v);t.setDate(t.getDate()-1),q(e=>{const t=new Date(e);return t.setDate(t.getDate()-1),t}),e.setCurrentDate(t)}else e.goToPrevious()},onNext:()=>{if(Z){const t=new Date(v);t.setDate(t.getDate()+1),q(e=>{const t=new Date(e);return t.setDate(t.getDate()+1),t}),e.setCurrentDate(t)}else e.goToNext()},onToday:()=>e.goToToday()}),Ie(La,{app:e,weekDaysLabels:rt,mobileWeekDaysLabels:at,weekDates:ct,fullWeekDates:ut,isSlidingView:Z,mobilePageStart:K,currentWeekStart:ae,gridWidth:W,allDayAreaHeight:Ve,organizedAllDaySegments:Fe,allDayLabelText:ot,isMobile:x,isTouch:D,showAllDay:I,calendarRef:i,allDayRowRef:Me,topFrozenContentRef:Re,ALL_DAY_HEIGHT:$,HOUR_HEIGHT:A,FIRST_HOUR:P,dragState:Qe,isDragging:et,secondaryTimeSlots:lt,primaryTzLabel:st,secondaryTzLabel:dt,handleMoveStart:Ke,handleResizeStart:Xe,handleEventUpdate:ht,handleEventDelete:gt,onDateChange:d,newlyCreatedEventId:fe,setNewlyCreatedEventId:ve,selectedEventId:ue,setSelectedEventId:ge,detailPanelEventId:he,setDetailPanelEventId:me,handleCreateAllDayEvent:Je,handleDragOver:nt,handleDrop:tt,customDetailPanelContent:r,customEventDetailDialog:o}),Ie($a,{app:e,timeSlots:it,weekDaysLabels:rt,currentWeekStart:ae,currentWeekEvents:je,eventLayouts:Ze,gridWidth:W,isMobile:x,isSlidingView:Z,isTouch:D,scrollerRef:Ne,timeGridRef:w,leftFrozenContentRef:Oe,swipeContentRef:He,calendarRef:i,handleScroll:e=>{const{scrollLeft:t}=e.currentTarget;if(Re.current){const e=Z?"calc(-100% / 3)":"0px",n=Z?`${Ce}px`:`-${t}px`;Re.current.style.transform=`translateX(calc(${e} + ${n}))`,Re.current.style.transition=Z&&ke?"transform 0.3s ease-out":"none"}},handleCreateStart:qe,handleTouchStart:(e,t,n)=>{if(!x&&!D)return;const r=e.touches[0],a=r.clientX,o=r.clientY,i=e.currentTarget;Ee.current=setTimeout(()=>{null==qe||qe({preventDefault:()=>{},stopPropagation:()=>{},touches:[{clientX:a,clientY:o}],changedTouches:[{clientX:a,clientY:o}],target:i,currentTarget:i,cancelable:!0},t,n)},500)},handleTouchEnd:()=>{Ee.current&&(clearTimeout(Ee.current),Ee.current=null)},handleTouchMove:()=>{Ee.current&&(clearTimeout(Ee.current),Ee.current=null)},handleDragOver:nt,handleDrop:tt,dragState:Qe,isDragging:et,handleMoveStart:Ke,handleResizeStart:Xe,handleEventUpdate:ht,handleEventDelete:gt,onDateChange:d,newlyCreatedEventId:fe,setNewlyCreatedEventId:ve,selectedEventId:ue,setSelectedEventId:ge,detailPanelEventId:he,setDetailPanelEventId:me,customDetailPanelContent:r,customEventDetailDialog:o,isCurrentWeek:mt,currentTime:oe,HOUR_HEIGHT:A,FIRST_HOUR:P,LAST_HOUR:L,showStartOfDayLabel:j,timeFormat:R,secondaryTimeSlots:lt,appTimeZone:$e}),Ie(Y,{isOpen:ye,onClose:()=>{be(!1),De(null)},onSave:t=>{y.some(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),be(!1),De(null)},draftEvent:xe,app:e,timeFormat:R})]})},Ya={startOfWeek:1},Fa=e=>n.h(Ia,Object.assign(Object.assign({},e),{viewType:exports.ViewType.WEEK,originalComponent:ja,className:"week-view-factory"}));Fa.displayName="WeekViewAdapter";const Va=(e={})=>{const t=Object.assign(Object.assign({},Ya),e);return{type:exports.ViewType.WEEK,component:Fa,config:t}},Za=17,_a=r.memo(({currentMonth:e,currentYear:n,newlyCreatedEventId:r,screenSize:o,isScrolling:i,isDragging:l,showWeekNumbers:s,showMonthIndicator:d=!0,item:c,weekHeight:u,events:h,dragState:g,calendarRef:m,onEventUpdate:f,onEventDelete:p,onMoveStart:v,onCreateStart:y,onResizeStart:b,onDetailPanelOpen:x,onMoreEventsClick:w,onChangeView:D,onSelectDate:C,selectedEventId:k,onEventSelect:S,onEventLongPress:M,detailPanelEventId:N,onDetailPanelToggle:I,customDetailPanelContent:R,customEventDetailDialog:O,onCalendarDrop:H,onCalendarDragOver:A,app:P,enableTouch:$,appTimeZone:j})=>{const{t:Y,locale:F}=bt(),[V,Z]=a.useState(!1),_=a.useRef(null),U=a.useRef(null),W=a.useRef(null),[B,G]=a.useState(null),K=P.canMutateFromUI();a.useEffect(()=>{K||G(null)},[K]);const q=a.useMemo(()=>{const e=u-33;if(e<=0)return{maxSlots:0,maxSlotsWithMore:0};const t=Math.floor(e/Za),n=e-20,r=Math.max(0,Math.floor(n/Za));return{maxSlots:t,maxSlotsWithMore:t>0?Math.min(r,t-1):r}},[u]);a.useEffect(()=>i?(Z(!0),_.current&&(clearTimeout(_.current),_.current=null),()=>{_.current&&(clearTimeout(_.current),_.current=null)}):V?(_.current=setTimeout(()=>{Z(!1),_.current=null},100),()=>{_.current&&(clearTimeout(_.current),_.current=null)}):void 0,[i,V]);const{weekData:X}=c,J=X.days.find(e=>1===e.day),Q=`${u}px`,ee=a.useMemo(()=>Ze(),[]),te=a.useMemo(()=>wr(h,X.startDate,7,j),[h,X.startDate,j]),ne=a.useMemo(()=>((e,n,r)=>{const a=[],o=new Date(n);return o.setDate(o.getDate()+6),o.setHours(23,59,59,999),e.forEach(e=>{if(!e.start||!e.end)return void L.warn("Event missing start or end date:",e);const i=z(e.start,r),l=e.end?z(e.end,r):i,s=new Date(i);s.setHours(0,0,0,0);const d=new Date(l);d.setHours(0,0,0,0);let c=new Date(d);if(!e.allDay&&0===l.getHours()&&0===l.getMinutes()&&0===l.getSeconds()){const e=l.getTime()-i.getTime();e>0&&e<864e5&&(c=new Date(d),c.setDate(c.getDate()-1))}const u=s.toDateString()!==c.toDateString();if(!u||e.allDay)if(u&&e.allDay){let r=new Date(i);r<n&&(r=new Date(n),r.setHours(0,0,0,0));const s=l>o?o:l;for(let o=i.getTime();o<=s.getTime();o+=864e5){const i=new Date(o);if(i<n)continue;const l=t.Temporal.PlainDate.from({year:i.getFullYear(),month:i.getMonth()+1,day:i.getDate()});a.push(Object.assign(Object.assign({},e),{start:l,end:l,day:r.getDay()}))}}else a.push(Object.assign(Object.assign({},e),{start:e.start,end:e.end,day:i.getDay()}))}),a})(h,X.startDate,j),[h,X.startDate,j]),re=a.useMemo(()=>{const e=new Map;return X.days.forEach(t=>{const n=t.date.toDateString();e.set(n,ne.filter(e=>{if(!e.start||!e.end)return z(e.start,j).toDateString()===n;const t=z(e.start,j),r=z(e.end,j);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},[ne,X.days,j]),ae=a.useMemo(()=>((e,t)=>{const n=t||ft(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,i=!(e.endDayIndex<r.startDayIndex||e.startDayIndex>r.endDayIndex);if(a&&i){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})(te,P.state.allDaySortComparator),[te,P.state.allDaySortComparator]),oe=a.useMemo(()=>ae.flat(),[ae]),ie=a.useMemo(()=>{const e=Array.from({length:7}).fill(0);return ae.forEach((t,n)=>{t.forEach(t=>{for(let r=t.startDayIndex;r<=t.endDayIndex;r++)e[r]=Math.max(e[r],n+1)})}),e},[ae]),le=a.useMemo(()=>{const e=Array.from({length:7},()=>new Set);return ae.forEach((t,n)=>{t.forEach(t=>{for(let r=t.startDayIndex;r<=t.endDayIndex;r++)r>=0&&r<7&&e[r].add(n)})}),e},[ae]),se=a.useMemo(()=>{const{maxSlots:e,maxSlotsWithMore:t}=q,n=X.days.map((n,r)=>{var a,o;const i=(e=>[...e].toSorted((e,t)=>e.allDay!==t.allDay?e.allDay?-1:1:e.allDay&&t.allDay?0:E(e.start)-E(t.start)))(null!==(a=re.get(n.date.toDateString()))&&void 0!==a?a:[]),l=i.filter(e=>{if(!e.allDay)return!0;return!oe.some(t=>t.originalEventId===e.id)}),s=(null!==(o=ie[r])&&void 0!==o?o:0)-1,d=le[r],c=[];for(let e=0;e<=s;e++)d.has(e)||c.push(e);const u=l.length,h=Math.max(0,u-c.length),g=Math.max(s+1,0)+h,m=g>e;return{totalSlotsNeeded:g,hasMore:m,limit:m?t:e,timedEventsOnly:l,gapLayers:c,occupiedLayers:d,maxOccupiedLayer:s}}),r=new Set;return ae.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;oe.forEach(e=>{e.startDayIndex<=a&&e.endDayIndex>=a&&r.has(e.id)&&(o=!0)});const i=n.hasMore||o,l=i?t:e;return Object.assign(Object.assign({},n),{hasMore:i,limit:l,segmentIsHidden:r})})},[q,X.days,re,oe,ie,le,ae]),de=a.useMemo(()=>Math.min(ae.length,q.maxSlots),[ae.length,q.maxSlots]),ce=a.useMemo(()=>Math.max(0,de*Za),[de]),ue=(t,a)=>{const i=t.date.toLocaleDateString(F,{month:F.startsWith("zh")||F.startsWith("ja")?"short":"long"})===e&&t.year===n,{hasMore:d,limit:c,timedEventsOnly:u,gapLayers:h,occupiedLayers:L,maxOccupiedLayer:V,totalSlotsNeeded:Z}=se[a];let _=0;ae.slice(c).forEach(e=>{e.forEach(e=>{e.startDayIndex<=a&&e.endDayIndex>=a&&_++})}),ae.slice(0,c).forEach(e=>{e.forEach(e=>{e.startDayIndex<=a&&e.endDayIndex>=a&&se[a].segmentIsHidden.has(e.id)&&_++})});const z=h.filter(e=>e<c).length,B=ae.slice(0,c).filter(e=>e.some(e=>e.startDayIndex<=a&&e.endDayIndex>=a&&se[a].segmentIsHidden.has(e.id))).length,q=Math.max(0,c-Math.max(V+1,0)),X=Math.min(u.length,z+q+B),J=u.slice(0,X),te=_+(u.length-X),ne=d&&de>c,re=(de-c)*Za,oe=[];let ie=0;const le=Math.min(c,Z);for(let e=0;e<le;e++)if(L.has(e)&&!ae[e].some(e=>e.startDayIndex<=a&&e.endDayIndex>=a&&se[a].segmentIsHidden.has(e.id)))oe.push(Ie("div",{className:"shrink-0",style:{height:"17px",minHeight:"17px"}},`placeholder-layer-${e}-${t.date.getTime()}`));else if(ie<J.length){const e=J[ie];oe.push(Ie(Lr,{event:e,isAllDay:!!e.allDay,viewType:exports.ViewType.MONTH,isBeingDragged:l&&g.eventId===e.id&&"move"===g.mode,calendarRef:m,hourHeight:72,firstHour:0,onEventUpdate:f,onEventDelete:p,onMoveStart:v,onResizeStart:b,onDetailPanelOpen:x,onEventSelect:S,onEventLongPress:M,newlyCreatedEventId:r,selectedEventId:k,detailPanelEventId:N,onDetailPanelToggle:I,customDetailPanelContent:R,customEventDetailDialog:O,app:P,isMobile:"desktop"!==o,enableTouch:$,appTimeZone:j},`${e.id}-${e.day}-${E(e.start)}-${ie}`)),ie++}return Ie("div",{className:Qt("df-month-day-cell relative flex flex-col border-r",i?"text-gray-800 dark:text-gray-100":"text-gray-400 dark:text-gray-600",6===a?ee?"last:border-r":"border-r-0":""),style:{height:Q},"data-date":(ce=t.date,`${ce.getFullYear()}-${String(ce.getMonth()+1).padStart(2,"0")}-${String(ce.getDate()).padStart(2,"0")}`),onClick:()=>i&&(null==C?void 0:C(t.date)),onDblClick:e=>null==y?void 0:y(e,t.date),onTouchStart:e=>{if("mobile"!==o&&!$)return;const n=e.touches[0],r=n.clientX,a=n.clientY;W.current={x:r,y:a},U.current=setTimeout(()=>{null==y||y(e,t.date),U.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},onTouchMove:e=>{if(U.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(U.current),U.current=null)}},onTouchEnd:()=>{U.current&&(clearTimeout(U.current),U.current=null),W.current=null},onDragOver:A,onDrop:e=>null==H?void 0:H(e,t.date),onContextMenu:e=>((e,t)=>{e.preventDefault(),"mobile"!==o&&K&&G({x:e.clientX,y:e.clientY,date:t})})(e,t.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:[s&&0===a&&"mobile"!==o&&Ie("span",{className:"mr-auto ml-1 text-[10px] font-medium text-gray-400 dark:text-gray-500",children:T(t.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 ${t.isToday?Yt:i?"text-gray-900 dark:text-gray-100":"text-gray-400 dark:text-gray-600"} `,children:1===t.day&&"desktop"===o?t.date.toLocaleDateString(F,{month:"short",day:"numeric"}):t.day})]}),Ie("div",{className:"pointer-events-none relative flex-1 overflow-hidden px-1",children:[ne&&Ie("div",{className:"pointer-events-none absolute right-0 left-0 z-[100] bg-white dark:bg-gray-900",style:{top:c*Za+"px",height:`${re}px`}}),oe,d&&Ie("div",{className:Qt("df-month-more-events text-xs text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 cursor-pointer hover:underline relative z-20","desktop"===o?"text-left font-normal":"text-center font-medium","pointer-events-auto","z-[100]"),onClick:e=>{e.stopPropagation(),w?w(t.date):(null==C||C(t.date),null==D||D(exports.ViewType.DAY))},children:["+",te,"desktop"===o?` ${Y("more")}`:""]})]})]},`day-${t.date.getTime()}`);var ce},he=a.useMemo(()=>J?J.date.toLocaleDateString(F,{month:"long",year:"numeric"}):"",[J,F]);return Ie("div",{className:"relative border-b border-gray-200 select-none dark:border-gray-700",style:{height:Q},children:[d&&J&&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 ${V?"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:he})}),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:X.days.map((e,t)=>ue(e,t))}),ae.length>0&&Ie("div",{className:"pointer-events-none absolute right-0 left-0",style:{top:"33px",height:`${ce}px`},children:ae.slice(0,de).map((e,t)=>Ie("div",{className:"absolute inset-0",children:e.filter(e=>!se[0].segmentIsHidden.has(e.id)).map(e=>Ie(Lr,{event:e.event,isAllDay:!0,segment:e,segmentIndex:t,viewType:exports.ViewType.MONTH,isMultiDay:!0,calendarRef:m,hourHeight:72,firstHour:0,onEventUpdate:f,onEventDelete:p,onMoveStart:v,onResizeStart:b,isBeingDragged:l&&g.eventId===e.event.id&&"move"===g.mode,isBeingResized:l&&g.eventId===e.event.id&&"resize"===g.mode,newlyCreatedEventId:r,onDetailPanelOpen:x,selectedEventId:k,onEventSelect:S,onEventLongPress:M,detailPanelEventId:N,onDetailPanelToggle:I,customDetailPanelContent:R,customEventDetailDialog:O,app:P,isMobile:"desktop"!==o,enableTouch:$,appTimeZone:j},e.id))},`layer-${t}`))})]})}),K&&B&&Ie(yr,{x:B.x,y:B.y,date:B.date,viewType:exports.ViewType.MONTH,onClose:()=>G(null),app:P,onCreateEvent:()=>{if(y){const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:B.x,clientY:B.y};y(e,B.date)}}})]})});_a.displayName="WeekComponent";const za=({app:e,config:t,customDetailPanelContent:n,customEventDetailDialog:r,calendarRef:o,selectedEventId:i,onEventSelect:l,detailPanelEventId:s,onDetailPanelToggle:d})=>{var c,g,m;const{getWeekDaysLabels:f,getMonthLabels:p,locale:v}=bt(),y=e.getCurrentDate(),b=e.getEvents(),x=null!==(c=t.startOfWeek)&&void 0!==c?c:1,w=e.timeZone,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]=a.useState(y),[k,S]=a.useState(!1),[M,N]=a.useState("forward"),I=a.useRef(y),R=a.useRef(null),O=y.getFullYear(),H=y.getMonth();a.useEffect(()=>{if(!E)return;if(O===I.current.getFullYear()&&H===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)}},[O,H,E]);const A=a.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(ge(t))}return o})(C,x):[],[E,C,x]),P=a.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("-"),$=a.useRef(null),j=a.useMemo(()=>{const e=$.current;return e&&e.length===b.length&&e.every((e,t)=>e===b[t])?e:($.current=b,b)},[b]),Y=a.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=z(e.start,w),a=e.end?z(e.end,w):r,o=new Date(r);o.setHours(0,0,0,0);const i=new Date(a);i.setHours(0,0,0,0);let l=new Date(i);if(!e.allDay){0!==a.getHours()||0!==a.getMinutes()||0!==a.getSeconds()||0!==a.getMilliseconds()||l.setDate(l.getDate()-1)}l<o&&(l=new Date(o));const s=t(o),d=t(l);let c=s.getTime();const u=d.getTime();for(;c<=u;){n(c,e);const t=new Date(c);t.setDate(t.getDate()+7),t.setHours(0,0,0,0),c=t.getTime()}}),e},[j,x,w]),{screenSize:F}=vt(),[V,Z]=a.useState(!1);a.useEffect(()=>{Z("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const _=e.getCustomMobileEventRenderer()||er,[U,W]=a.useState(()=>{if("undefined"==typeof window)return 119;const e=window.innerHeight-150;return Math.max(80,Math.ceil(e/6))}),[B,G]=a.useState(()=>"undefined"!=typeof window),K=a.useRef(U),q=a.useRef([]),[X,J]=a.useState(null),[Q,ee]=a.useState(!1),[te,ne]=a.useState(null),[re,ae]=a.useState(null),[oe,ie]=a.useState(null),le=void 0===i?re:i,se=void 0===s?oe:s,de=a.useCallback(e=>{l?l(e):ae(e)},[l]),ce=a.useCallback(e=>{d?d(e):ie(e)},[d]),ue=a.useRef(e.state.highlightedEventId);a.useEffect(()=>{e.state.highlightedEventId?de(e.state.highlightedEventId):ue.current&&de(null),ue.current=e.state.highlightedEventId},[e.state.highlightedEventId]);const he=a.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:pe,handleResizeStart:ve,dragState:ye,isDragging:be}=Ma(e,{calendarRef:o,viewType:exports.ViewType.MONTH,onEventsUpdate:(t,n,r)=>{const a=t(j),o=new Set(a.map(e=>e.id)),i=j.filter(e=>!o.has(e.id)),l=new Set(j.map(e=>e.id)),s=a.filter(e=>!l.has(e.id)),d=a.filter(e=>{if(!l.has(e.id))return!1;const t=j.find(t=>t.id===e.id);return t&&we(t,e)});e.applyEventsChanges({delete:i.map(e=>e.id),add:s,update:d.map(e=>({id:e.id,updates:e}))},n,r)},onEventCreate:t=>{"desktop"===F?e.addEvent(t):(ne(t),ee(!0))},onEventEdit:e=>{J(e.id)},currentWeekStart:he,events:j,isMobile:"desktop"!==F}),{handleDrop:xe,handleDragOver:De}=Ta({app:e,onEventCreated:e=>{J(e.id)}}),Ee=a.useMemo(()=>f(v,"short",x),[v,f,x]),{currentMonth:Ce,currentYear:Te,isScrolling:ke,virtualData:Se,weeksData:Me,scrollElementRef:Ne,isNavigating:Re,handleScroll:Oe,handlePreviousMonth:He,handleNextMonth:Ae,handleToday:Pe,setScrollTop:Le}=(({currentDate:e,weekHeight:t,onCurrentMonthChange:n,initialWeeksToLoad:r=104,locale:o="en-US",startOfWeek:i=1,isEnabled:l=!0,snapToMonth:s=!1})=>{const d=a.useRef(null),c=a.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=a.useMemo(()=>{const t=new Date(e);return t.setDate(1),t.setHours(0,0,0,0),me(t,r,i)},[e,r,i]),m=a.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]),[f,p]=a.useState(m),[v,y]=a.useState(600),[b,x]=a.useState(c(e.getMonth(),e.getFullYear())),[w,D]=a.useState(e.getFullYear()),[E,C]=a.useState(!1),[T,k]=a.useState(g),[S,M]=a.useState(!1),N=a.useRef(!1),[I,R]=a.useState(!1),O=a.useRef(e),H=a.useRef(null),A=a.useRef(null),P=a.useRef(new h),L=a.useRef(0),$=a.useRef(0),j=a.useRef(!1),Y=a.useCallback(e=>{e&&(H.current=e)},[]),F=a.useCallback(e=>{let t=P.current.get(e);return t||(t=ge(e),P.current.set(e,t)),t},[]),V=a.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(()=>{p(e=>e+a),H.current&&(H.current.scrollTop+=a)})}}finally{setTimeout(()=>{j.current=!1},200)}},0))},[T,F,t]),Z=a.useMemo(()=>{const e=T.length*t,n=Math.floor(f/t);let r=Math.max(0,n);r=Math.min(r,Math.max(0,T.length-6));const a=Math.min(T.length-1,r+6-1),o=Math.max(0,r-15),i=Math.min(T.length-1,a+15),l=[];for(let e=o;e<=i;e++)l.push({index:e,weekData:T[e],top:e*t,height:t});return{totalHeight:e,visibleItems:l,displayStartIndex:r}},[f,v,t,T]),_=a.useCallback(e=>{if(S||E||0===e.length||!I)return;const t=f+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="",i=0,l=0;Object.entries(a).forEach(([e,t])=>{if(t>l){l=t;const[n,r]=e.split("-");o=n,i=Number.parseInt(r,10)}}),o&&i&&(d.current?o===d.current.month&&i===d.current.year&&(d.current=null,o===b&&i===w||(x(o),D(i),null==n||n(o,i))):o===b&&i===w||(x(o),D(i),null==n||n(o,i)))},[v,b,w,S,E,n,f,I]),z=a.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,p(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),A.current&&clearTimeout(A.current),A.current=setTimeout(()=>{C(!1)},u.SCROLL_DEBOUNCE)},[t,V,S]),U=a.useCallback((e,n=!0)=>{if(!H.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 H.current.scrollTo({top:e,behavior:n?"smooth":"auto"}),void r()}const o=(e.getDay()-i+7)%7,l=new Date(e);l.setDate(e.getDate()-o),l.setHours(0,0,0,0);const s=T[0],d=T.at(-1);let c=0,u=!1,h=!1;l<s.startDate?(c=Math.ceil((s.startDate.getTime()-l.getTime())/6048e5),u=!0):l>d.startDate&&(c=Math.ceil((l.getTime()-d.startDate.getTime())/6048e5),h=!0);const g=Math.min(c+10,52);if(u){const a=[];for(let e=g;e>=1;e--){const t=new Date(s.startDate);t.setDate(t.getDate()-7*e),a.push(F(t))}const o=a.length*t;k(e=>[...a,...e]),requestAnimationFrame(()=>{const i=[...a,...T].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(H.current&&-1!==i){const e=i*t;H.current.scrollTop+=o,p(e=>e+o),setTimeout(()=>{H.current&&H.current.scrollTo({top:e,behavior:n?"smooth":"auto"})},50)}r()})}else if(h){const a=[];for(let e=1;e<=g;e++){const t=new Date(d.startDate);t.setDate(t.getDate()+7*e),a.push(F(t))}k(e=>[...e,...a]),requestAnimationFrame(()=>{const o=[...T,...a].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(H.current&&-1!==o){const e=o*t;H.current.scrollTo({top:e,behavior:n?"smooth":"auto"})}r()})}else r()},[T,t,F]),W=a.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,i=0;for(const[e,t]of Object.entries(r))t>i&&(i=t,[a,o]=e.split("-").map(Number));const l=new Date(o,a-1,1);U(l)},[Z.displayStartIndex,T,U]),B=a.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,i=0;for(const[e,t]of Object.entries(r))t>i&&(i=t,[a,o]=e.split("-").map(Number));const l=new Date(o,a+1,1);U(l)},[Z.displayStartIndex,T,U]),G=a.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 i=T.findIndex(e=>e.days.some(e=>e.date.toDateString()===o.toDateString()));if(-1===i)M(!0),N.current=!0,requestAnimationFrame(()=>{U(o,!0),setTimeout(()=>{N.current=!1,M(!1)},200)});else{const e=i*t,n=H.current;n&&(M(!0),N.current=!0,requestAnimationFrame(()=>{p(e),requestAnimationFrame(()=>{n&&(n.scrollTop=e,setTimeout(()=>{N.current=!1,M(!1)},200))})}))}},[T,t,n,U]);return a.useEffect(()=>{_(Z.visibleItems)},[Z.visibleItems,_]),a.useEffect(()=>{const t=O.current,r=t.getMonth(),a=t.getFullYear(),o=e.getMonth(),i=e.getFullYear();if(r!==o||a!==i){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 l="",s=0;for(const[e,t]of Object.entries(a))t>s&&(s=t,l=e);if(l!==`${o}-${i}`){const e=new Date(i,o,1),t=c(o,i);d.current={month:t,year:i},x(t),D(i),null==n||n(t,i),U(e,!0)}}O.current=e},[e,n,U,Z,T,c]),a.useEffect(()=>{const e=H.current;if(!e)return;const t=new ResizeObserver(([e])=>{y(e.contentRect.height)});return t.observe(e),()=>t.disconnect()},[]),a.useLayoutEffect(()=>{const e=H.current;e&&!I&&l&&(m>0&&(e.scrollTop=m),R(!0))},[I,m,l]),a.useEffect(()=>{var e;if(!s||E||S||!I)return;const n=Math.floor(f/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,i=0,l=0;for(const[e,t]of Object.entries(a))t>l&&(l=t,[o,i]=e.split("-").map(Number));const d=new Date(i,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-f)>5){const e=setTimeout(()=>{U(d,!0)},200);return()=>clearTimeout(e)}},[E,s,S,I,f,t,T,U]),a.useEffect(()=>()=>{A.current&&clearTimeout(A.current)},[]),{scrollTop:f,containerHeight:v,currentMonth:b,currentYear:w,isScrolling:E,isNavigating:S,virtualData:Z,scrollElementRef:H,handleScroll:z,scrollToDate:U,handlePreviousMonth:W,handleNextMonth:B,handleToday:G,setScrollTop:p,setContainerHeight:y,setCurrentMonth:x,setCurrentYear:D,setIsScrolling:C,cache:P.current,scrollElementRefCallback:Y,weeksData:T}})({currentDate:y,weekHeight:U,onCurrentMonthChange:(t,n)=>{const r=v.startsWith("zh")||v.startsWith("ja"),a=p(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}),$e=a.useRef(0),[je,Ye]=a.useState(0),Fe=a.useMemo(()=>je-6*U,[je,U]),{visibleWeeks:Ve,startIndex:Ze}=a.useMemo(()=>{var e,t;const{visibleItems:n,displayStartIndex:r}=Se,a=n.findIndex(e=>e.index===r);if(-1===a)return q.current.length>0?{visibleWeeks:q.current,startIndex:$e.current}:{visibleWeeks:[],startIndex:r};const o=Math.max(0,a-2),i=n.slice(o,a+8),l=null!==(t=null===(e=n[o])||void 0===e?void 0:e.index)&&void 0!==t?t:r;return i.length>=6&&(q.current=i,$e.current=l),{visibleWeeks:i,startIndex:l}},[Se]),_e=a.useMemo(()=>Ze*U,[Ze,U]),ze=a.useRef(!0),Ue=a.useRef(!1),We=((e,t)=>{const[n,r]=a.useState(e);return a.useEffect(()=>{const n=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(n)}},[e,t]),n})(Se.displayStartIndex,250);a.useEffect(()=>{Re&&(Ue.current=!0)},[Re]),a.useEffect(()=>{if(ze.current)return void(ze.current=!1);const t=Me[We];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,Ue.current?"navigation":"scroll"),Ue.current=!1},[e,Me,We]);const Be=a.useMemo(()=>{const e=Se.totalHeight,t=Ze*U+Ve.length*U+Fe;return Math.max(0,e-t)},[Se.totalHeight,Ze,U,Fe,Ve.length]);a.useEffect(()=>{const e=Ne.current;if(!e)return;const t=new ResizeObserver(t=>{for(const n of t){const t=n.contentRect.height;if(Ye(t),t>0){const n=Math.max(80,Math.ceil(t/6));if(n!==K.current){const t=e.scrollTop;if(t>0){const r=Math.round(t/K.current)*n;e.scrollTop=r,Le(r)}W(n),K.current=n}}}});return t.observe(e),()=>{t.disconnect()}},[Ne,Le]),a.useLayoutEffect(()=>{const e=window.innerHeight-150,t=Math.max(80,Math.ceil(e/6));W(t),K.current=t,G(!0)},[]),a.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 Ge=a.useCallback(t=>e.updateEvent(t.id,t),[e]),Ke=a.useCallback(t=>e.deleteEvent(t),[e]),qe=t=>{e.changeView(t)},Xe=a.useCallback(()=>J(null),[]),Je=a.useCallback(t=>{const n=e.getReadOnlyConfig().viewable;if(("desktop"!==F||V)&&t&&n){const e=j.find(e=>e.id===t);if(e)return ne(e),void ee(!0)}de(t)},[F,V,j,de,e]),Qe=a.useCallback(e=>{("desktop"!==F||V)&&de(e)},[F,V,de]);return Ie("div",{className:xt,children:[Ie(jr,{calendar:e,viewType:exports.ViewType.MONTH,currentDate:y,customTitle:(()=>{const e=v.startsWith("zh")||v.startsWith("ja");if(E){const t=p(v,e?"short":"long")[C.getMonth()],n=C.getFullYear();return e?`${n}年${t}`:`${t} ${n}`}return e?`${Te}年${Ce}`:`${Ce} ${Te}`})(),onPrevious:()=>{e.goToPrevious(),E||He()},onNext:()=>{e.goToNext(),E||Ae()},onToday:()=>{e.goToToday(),E||Pe()}}),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:A.map((a,i)=>{var l;const s=null!==(l=Y.get(a.startDate.getTime()))&&void 0!==l?l:[],d={index:i,weekData:a,top:i*U,height:U},c=5===i?Object.assign(Object.assign({},d),{height:d.height+Fe}):d;return Ie(_a,{item:c,weekHeight:U,showWeekNumbers:t.showWeekNumbers,showMonthIndicator:!1,currentMonth:"",currentYear:0,screenSize:F,isScrolling:!1,calendarRef:o,events:s,onEventUpdate:Ge,onEventDelete:Ke,onMoveStart:fe,onCreateStart:pe,onResizeStart:ve,isDragging:be,dragState:ye,newlyCreatedEventId:X,onDetailPanelOpen:Xe,onMoreEventsClick:e.onMoreEventsClick,onChangeView:qe,onSelectDate:e.selectDate,selectedEventId:le,onEventSelect:Je,onEventLongPress:Qe,detailPanelEventId:se,onDetailPanelToggle:ce,customDetailPanelContent:n,customEventDetailDialog:r,onCalendarDrop:xe,onCalendarDragOver:De,calendarSignature:L,app:e,enableTouch:V,appTimeZone:w},`week-${a.startDate.getTime()}`)})})}:{ref:Ne,className:Ct,style:{overflow:"hidden auto",overscrollBehavior:"contain",visibility:B?"visible":"hidden"},onScroll:Oe,children:[Ie("div",{style:{height:_e}}),Ve.map((a,i)=>{var l;const s=null!==(l=Y.get(a.weekData.startDate.getTime()))&&void 0!==l?l:[],d=5===i?Object.assign(Object.assign({},a),{height:a.height+Fe}):a,c=!(!1===t.showMonthIndicator||!a.weekData.days.some(e=>1===e.day))&&ke;return Ie(_a,{item:d,weekHeight:U,showWeekNumbers:t.showWeekNumbers,showMonthIndicator:t.showMonthIndicator,currentMonth:Ce,currentYear:Te,screenSize:F,isScrolling:c,calendarRef:o,events:s,onEventUpdate:Ge,onEventDelete:Ke,onMoveStart:fe,onCreateStart:pe,onResizeStart:ve,isDragging:be,dragState:ye,newlyCreatedEventId:X,onDetailPanelOpen:Xe,onMoreEventsClick:e.onMoreEventsClick,onChangeView:qe,onSelectDate:e.selectDate,selectedEventId:le,onEventSelect:Je,onEventLongPress:Qe,detailPanelEventId:se,onDetailPanelToggle:ce,customDetailPanelContent:n,customEventDetailDialog:r,onCalendarDrop:xe,onCalendarDragOver:De,calendarSignature:L,app:e,enableTouch:V,appTimeZone:w},`week-${a.weekData.startDate.getTime()}`)}),Ie("div",{style:{height:Be}})]}),Ie(_,{isOpen:Q,onClose:()=>{ee(!1),ne(null)},onSave:t=>{j.some(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),ee(!1),ne(null)},draftEvent:te,app:e})]})},Ua={showWeekNumbers:!1,showMonthIndicator:!0,startOfWeek:1},Wa=e=>n.h(Ia,Object.assign(Object.assign({},e),{viewType:exports.ViewType.MONTH,originalComponent:za,className:"month-view-factory"}));Wa.displayName="MonthViewAdapter";const Ba=(e={})=>{const t=Object.assign(Object.assign({},Ua),e);return{type:exports.ViewType.MONTH,component:Wa,config:t}};const Ga=r.memo(({date:e,isToday:t,locale:n,onSelectDate:r,onCreateStart:a,onMoreEventsClick:o,moreCount:i=0,onContextMenu:l})=>{const{t:s}=bt(),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-(--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==l||l(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:"df-fill-primary rounded-sm px-1 py-0.5 text-[9px] leading-none font-bold",children:u}),Ie("span",{className:"ml-auto text-[10px] font-medium "+(t?"df-fill-primary flex h-5 w-5 items-center justify-center rounded-full":"text-gray-700 dark:text-gray-300"),children:d})]}),i>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:["+",i," ",s("more")]})})]})});Ga.displayName="YearDayCell";const Ka=r.memo(({rowDays:e,events:t,columnsPerRow:n,app:r,calendarRef:o,locale:i,isDragging:l,dragState:s,onMoveStart:d,onResizeStart:c,onCreateStart:u,selectedEventId:h,onEventSelect:g,onMoreEventsClick:m,newlyCreatedEventId:f,onDetailPanelOpen:p,detailPanelEventId:v,onDetailPanelToggle:y,customDetailPanelContent:b,customEventDetailDialog:x,onContextMenu:w,appTimeZone:D})=>{const E=a.useMemo(()=>{const e=re(D);return e.setHours(0,0,0,0),e},[D]),C=a.useCallback((e,t)=>{e.preventDefault(),e.stopPropagation(),w({x:e.clientX,y:e.clientY,date:t})},[w]),T=a.useCallback(e=>{r.selectDate(e)},[r]),k=a.useMemo(()=>function(e,t,n,r,a){if(0===t.length)return[];const o=t[0],i=t.at(-1);if(!o||!i)return[];const l=new Date(o.getFullYear(),o.getMonth(),o.getDate()).getTime(),s=new Date(i.getFullYear(),i.getMonth(),i.getDate(),23,59,59,999).getTime(),d=e.map(e=>{const t=z(e.start,a),n=e.end?z(e.end,a):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===d.length)return[];const c=ft(d.map(e=>e.event),r);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=[];return d.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 c=0;for(;;){h[c]||(h[c]=[]);let e=!1;for(let t=a;t<=o;t++)if(h[c][t]){e=!0;break}if(!e){for(let e=a;e<=o;e++)h[c][e]=!0;break}c++}u.push({id:`${e.id}::year-${l}`,event:e,startCellIndex:a,endCellIndex:o,isFirstSegment:i,isLastSegment:d,visualRowIndex:c})}),u}(t,e,n,r.state.allDaySortComparator,D),[t,e,n,r.state.allDaySortComparator,D]),{visibleSegments:S,moreCounts:M}=a.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 i=Math.max(0,a.startCellIndex),l=Math.min(e.length-1,a.endCellIndex);for(let e=i;e<=l;e++){const n=t[e]>3?1:2;if(a.visualRowIndex>n){o=!1;break}}if(o)n.push(a);else for(let e=i;e<=l;e++)r[e]++}),{visibleSegments:n,moreCounts:r}},[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(Ga,{date:e,isToday:n,locale:i,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(Lr,{event:e.event,isAllDay:!!e.event.allDay,viewType:exports.ViewType.YEAR,yearSegment:e,columnsPerRow:n,isBeingDragged:l&&s.eventId===e.event.id,selectedEventId:h,onMoveStart:d,onResizeStart:c,onEventSelect:g,onDetailPanelToggle:y,newlyCreatedEventId:f,onDetailPanelOpen:p,calendarRef:o,app:r,detailPanelEventId:v,customDetailPanelContent:b,customEventDetailDialog:x,firstHour:0,hourHeight:0,onEventUpdate:e=>r.updateEvent(e.id,e),onEventDelete:e=>r.deleteEvent(e),appTimeZone:D})},e.id))})})]})});Ka.displayName="YearRowComponent";const qa=({app:e,calendarRef:n,customDetailPanelContent:r,customEventDetailDialog:o,config:i,selectedEventId:l,onEventSelect:s,detailPanelEventId:d,onDetailPanelToggle:c})=>{var u;const{t:h,locale:g}=bt(),m=e.getCurrentDate(),f=m.getFullYear(),p=e.getEvents(),v=e.timeZone,y=a.useRef(null),[b,x]=a.useState(()=>"undefined"!=typeof window?Math.max(1,Math.floor(window.innerWidth/80)):7),[w,D]=a.useState(()=>"undefined"!=typeof window),[E,C]=a.useState(()=>"undefined"!=typeof window&&window.innerWidth<768),[T,k]=a.useState(null),[S,M]=a.useState(null),N=void 0===l?T:l,I=void 0===d?S:d,[R,O]=a.useState(null),H=a.useCallback(e=>{s?s(e):k(e)},[s]),A=a.useCallback(e=>{c?c(e):M(e)},[c]),P=a.useCallback(()=>{O(null)},[]),[L,$]=a.useState(null),j=e.canMutateFromUI();a.useEffect(()=>{j||$(null)},[j]),a.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]"),i=t.closest("[data-calendar-picker-dropdown]"),l=t.closest(".df-context-menu");n||r||a||o||i||l||(H(null),A(null),$(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const Y=a.useRef(null);a.useLayoutEffect(()=>{const e=y.current;if(!e)return;const t=new ResizeObserver(e=>{Y.current&&clearTimeout(Y.current),Y.current=setTimeout(()=>{const t=e[0].contentRect.width,n=Math.floor(t/80);x(Math.max(1,n)),C(t<768),D(!0)},60)});return t.observe(e),()=>{t.disconnect(),Y.current&&clearTimeout(Y.current)}},[]);const F=a.useRef(e.state.highlightedEventId);a.useEffect(()=>{e.state.highlightedEventId?(H(e.state.highlightedEventId),requestAnimationFrame(()=>{const t=y.current;if(!t)return;const n=t.querySelector(`[data-event-id="${e.state.highlightedEventId}"]`);null==n||n.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})})):F.current&&H(null),F.current=e.state.highlightedEventId},[e.state.highlightedEventId]);const{handleMoveStart:V,handleResizeStart:Z,handleCreateStart:_,dragState:U,isDragging:W}=Ma(e,{calendarRef:n,viewType:exports.ViewType.YEAR,onEventsUpdate:(t,n,r)=>{const a=t(p).filter(e=>{const t=p.find(t=>t.id===e.id);return t&&we(t,e)});a.length>0&&e.applyEventsChanges({update:a.map(e=>({id:e.id,updates:e}))},n,r)},currentWeekStart:new Date,events:p,onEventCreate:t=>{e.addEvent(t)},onEventEdit:e=>{O(e.id)},isMobile:E}),B=null!==(u=null==i?void 0:i.showTimedEventsInYearView)&&void 0!==u&&u,G=a.useCallback((n,r)=>{if(B)null==_||_(n,r);else{const n=t.Temporal.PlainDate.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate()}),a={id:`event-${Date.now()}`,title:h("newEvent")||"New Event",start:n,end:n,allDay:!0,calendarId:e.getCalendarRegistry().getDefaultCalendarId()||"default"};e.addEvent(a),O(a.id)}},[B,_,e,h]),K=a.useMemo(()=>{const e=[],t=new Date(f,0,1),n=new Date(f,11,31);for(let r=t.getTime();r<=n.getTime();r+=864e5)e.push(new Date(r));return e},[f]),q=a.useMemo(()=>function(e,t){const n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}(K,b),[K,b]),X=a.useMemo(()=>{const e=new Date(f,0,1),t=new Date(f,11,31,23,59,59);return p.filter(n=>{if(!n.start)return!1;if(!B&&!n.allDay)return!1;const r=z(n.start,v),a=n.end?z(n.end,v):r;return r<=t&&a>=e})},[p,f,B,v]),J=a.useMemo(()=>{const e=X.map(e=>{const t=z(e.start,v),n=e.end?z(e.end,v):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 q.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)})},[q,X,v]);return Ie("div",{className:xt,onContextMenu:e=>e.preventDefault(),children:[Ie(jr,{calendar:e,viewType:exports.ViewType.YEAR,currentDate:m,customTitle:g.startsWith("zh")||g.startsWith("ja")?`${f}年`:`${f}`,onPrevious:()=>{const t=new Date(m);t.setFullYear(t.getFullYear()-1),e.setCurrentDate(t)},onNext:()=>{const t=new Date(m);t.setFullYear(t.getFullYear()+1),e.setCurrentDate(t)},onToday:()=>{e.goToToday()}}),Ie("div",{ref:y,className:`${Ct} ${Tt}`,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:w?1:0,transition:"opacity 0.2s ease"},children:q.map((t,a)=>Ie(Ka,{rowDays:t,events:J[a],columnsPerRow:b,app:e,calendarRef:n,locale:g,isDragging:W,dragState:U,onMoveStart:V,onResizeStart:Z,onCreateStart:G,selectedEventId:N,onEventSelect:H,onMoreEventsClick:e.onMoreEventsClick,newlyCreatedEventId:R,onDetailPanelOpen:P,detailPanelEventId:I,onDetailPanelToggle:A,customDetailPanelContent:r,customEventDetailDialog:o,onContextMenu:e=>{j&&$(e)},appTimeZone:v},a))})}),j&&L&&Ie(yr,{x:L.x,y:L.y,date:L.date,viewType:exports.ViewType.YEAR,onClose:()=>$(null),app:e,onCreateEvent:()=>{if(L&&L.date){const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:L.x,clientY:L.y};G(e,L.date)}}})]})};function Xa(e,t,n,r=1,a){const o=new Date(n,t,1),i=new Date(n,t+1,0).getDate(),l=(o.getDay()-r+7)%7,s=o.getTime(),d=new Date(n,t,i,23,59,59,999).getTime(),c=e.filter(e=>!!e.start).map(e=>{const t=z(e.start,a),n=e.end?z(e.end,a):t,r=new Date(t.getFullYear(),t.getMonth(),t.getDate()),o=new Date(n.getFullYear(),n.getMonth(),n.getDate());return{event:e,startMs:r.getTime(),endMs:o.getTime(),eventStartDay:r,eventEndDay:o}}).filter(e=>e.startMs<=d&&e.endMs>=s);if(0===c.length)return{segments:[],maxVisualRow:-1};const u=ft(c.map(e=>e.event));c.sort((e,t)=>{const n=!!e.event.allDay;return n!==!!t.event.allDay?n?-1:1:u(e.event,t.event)});const h=[],g=[];c.forEach(({event:e,startMs:r,endMs:a,eventStartDay:o,eventEndDay:i})=>{const c=Math.max(r,s),u=Math.min(a,d),m=new Date(c).getDate(),f=new Date(u).getDate(),p=l+(m-1),v=l+(f-1),y=o.getMonth()===t&&o.getFullYear()===n,b=i.getMonth()===t&&i.getFullYear()===n;let x=0;for(;;){g[x]||(g[x]=[]);let e=!1;for(let t=p;t<=v;t++)if(g[x][t]){e=!0;break}if(!e){for(let e=p;e<=v;e++)g[x][e]=!0;break}x++}h.push({id:`${e.id}::month-${t}`,event:e,startCellIndex:p,endCellIndex:v,isFirstSegment:y,isLastSegment:b,visualRowIndex:x,monthIndex:t})});const m=h.length>0?Math.max(...h.map(e=>e.visualRowIndex)):-1;return{segments:h,maxVisualRow:m}}const Ja=({app:e,calendarRef:n,customDetailPanelContent:r,customEventDetailDialog:o,config:i,selectedEventId:l,onEventSelect:s,detailPanelEventId:d,onDetailPanelToggle:c})=>{var u,h;const{t:g,locale:m,getWeekDaysLabels:f}=bt(),p=e.getCurrentDate(),v=p.getFullYear(),y=e.getEvents(),b=e.timeZone,x=re(b);x.setHours(0,0,0,0);const w=null!==(u=null==i?void 0:i.startOfWeek)&&void 0!==u?u:1,D=a.useRef(null),E=a.useRef(null),C=a.useRef(null),[T,k]=a.useState(0),[S,M]=a.useState(0),[N,I]=a.useState(null),[R,O]=a.useState(null),H=void 0===l?N:l,A=void 0===d?R:d,P=e=>{s?s(e):I(e)},L=e=>{c?c(e):O(e)},[$,j]=a.useState(null),[Y,F]=a.useState(null),V=e.canMutateFromUI();a.useEffect(()=>{V||F(null)},[V]),a.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]"),i=t.closest("[data-calendar-picker-dropdown]");n||r||a||o||i||(P(null),L(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const Z=a.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()-w+7)%7+r;a>e&&(e=a)}return e},[v,w]),{handleMoveStart:_,handleResizeStart:U,handleCreateStart:W,dragState:B,isDragging:G}=Ma(e,{calendarRef:n,viewType:exports.ViewType.YEAR,onEventsUpdate:(t,n,r)=>{const a=t(y).filter(e=>{const t=y.find(t=>t.id===e.id);return t&&we(t,e)});a.length>0&&e.applyEventsChanges({update:a.map(e=>({id:e.id,updates:e}))},n,r)},currentWeekStart:new Date,events:y,onEventCreate:t=>{e.addEvent(t)},onEventEdit:e=>{j(e.id)}}),K=null!==(h=null==i?void 0:i.showTimedEventsInYearView)&&void 0!==h&&h,q=a.useCallback((n,r)=>{if(K)null==W||W(n,r);else{const n=t.Temporal.PlainDate.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate()}),a={id:`event-${Date.now()}`,title:g("newEvent")||"New Event",start:n,end:n,allDay:!0};e.addEvent(a),j(a.id)}},[K,W,e,g]),X=a.useMemo(()=>{const e=f(m,"short",w).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<Z;n++)t.push(e[n%7]);return t},[m,f,Z,w]),J=a.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(!K&&!n.allDay)return!1;const r=z(n.start,b),a=n.end?z(n.end,b):r;return r<=t&&a>=e})},[y,v,K,b]),Q=a.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()-w+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<Z;)o.push(null);const i=n.toLocaleDateString(m,{month:"short"}),l=i.charAt(0).toUpperCase()+i.slice(1).toLowerCase(),{segments:s,maxVisualRow:d}=Xa(J,t,v,w,b),c=d+1,u=Math.max(60,20+18*c);e.push({monthIndex:t,monthName:l,days:o,eventSegments:s,minHeight:u})}return e},[v,m,Z,J,w,b]),ee=a.useCallback(e=>{const t=e.currentTarget;D.current&&(D.current.scrollLeft=t.scrollLeft),E.current&&(E.current.scrollTop=t.scrollTop)},[]);a.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()}},[Q]);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(jr,{calendar:e,viewType:exports.ViewType.YEAR,currentDate:p,customTitle:m.startsWith("zh")||m.startsWith("ja")?`${v}年`:`${v}`,onPrevious:()=>{const t=new Date(p);t.setFullYear(t.getFullYear()-1),e.setCurrentDate(t)},onNext:()=>{const t=new Date(p);t.setFullYear(t.getFullYear()+1),e.setCurrentDate(t)},onToday:()=>{e.goToToday()}})}),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(${Z}, minmax(0, 1fr))`,minWidth:"1352px"},children:X.map((e,t)=>{const n=(t+w)%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:[Q.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 ${Tt}`,onScroll:ee,children:Ie("div",{className:"flex min-h-full flex-col",style:{minWidth:"1352px"},children:Q.map(t=>Ie("div",{className:"relative shrink-0 grow",style:{minHeight:`${t.minHeight}px`},children:[Ie("div",{className:"absolute inset-0 z-0 grid",style:{gridTemplateColumns:`repeat(${Z}, minmax(0, 1fr))`},children:t.days.map((n,r)=>{const a=(r+w)%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-${t.monthIndex}-${r}`);const i=(e=>e.getTime()===x.getTime())(n);return Ie("div",{"data-date":`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}-${String(n.getDate()).padStart(2,"0")}`,className:`df-hover-primary-dark-md 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 ${o?"df-year-view-weekend-cell bg-blue-50 dark:bg-blue-900/30":""} `,onClick:()=>e.selectDate(n),onDblClick:e=>q(e,n),onContextMenu:e=>((e,t)=>{e.preventDefault(),e.stopPropagation(),V&&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 ${i?"df-fill-primary font-bold shadow-sm":"text-gray-700 dark:text-gray-300"} `,children:n.getDate()})},n.getTime())})}),t.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:t.eventSegments.map(t=>Ie("div",{className:"pointer-events-auto",children:Ie(Lr,{event:t.event,isAllDay:!!t.event.allDay,viewType:exports.ViewType.YEAR,yearSegment:t,columnsPerRow:Z,isBeingDragged:G&&B.eventId===t.event.id,selectedEventId:H,onMoveStart:_,onResizeStart:U,onEventSelect:P,onDetailPanelToggle:L,newlyCreatedEventId:$,onDetailPanelOpen:()=>j(null),calendarRef:n,app:e,detailPanelEventId:A,customDetailPanelContent:r,customEventDetailDialog:o,firstHour:0,hourHeight:0,onEventUpdate:t=>e.updateEvent(t.id,t),onEventDelete:t=>e.deleteEvent(t),appTimeZone:b})},t.id))})})]},t.monthIndex))})}),V&&Y&&Ie(yr,{x:Y.x,y:Y.y,date:Y.date,viewType:exports.ViewType.YEAR,onClose:()=>F(null),app:e,onCreateEvent:()=>{const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:Y.x,clientY:Y.y};q(e,Y.date)}})]})},Qa=({date:e,events:t,anchorEl:o,position:i,onClose:l,locale:s,app:d,customContent:c,appTimeZone:u})=>{const{t:h}=bt(),g=a.useRef(null);a.useEffect(()=>{const e=e=>{const t=e.target;!g.current||g.current.contains(t)||o.contains(t)||l()},t=e=>{"Escape"===e.key&&l()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[o,l]);const m=d.getCalendars(),f=new Map(m.map(e=>[e.id,e])),p=e.toLocaleDateString(s,{weekday:"long",month:"long",day:"numeric"}),v=Ie(n.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===t.length?Ie("div",{className:"px-4 py-3 text-center text-xs text-gray-400",children:"No events"}):t.map(e=>{var t,n;const r=e.calendarId?f.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=z(e.start,u).toLocaleTimeString(s,{hour:"2-digit",minute:"2-digit",hour12:!1}),e.end){o+=` – ${z(e.end,u).toLocaleTimeString(s,{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:h("allDay")}),o&&Ie("div",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:o})]})]},e.id)})})]});return r.createPortal(Ie("div",{ref:g,"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:i.top,left:i.left},children:c?c(e,t):v}),document.body)};function eo(e,t,n,r){const a=new Map,o=new Date(t,0,1);o.setHours(0,0,0,0);const i=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=z(l.start,r),s=l.end?z(l.end,r):new Date(e);if(e.setHours(0,0,0,0),s.setHours(0,0,0,0),e>i||s<o)continue;const d=e<o?new Date(o):new Date(e),c=s>i?new Date(t,11,31):new Date(s);d.setHours(0,0,0,0),c.setHours(0,0,0,0);const u=864e5,h=d.getTime(),g=Math.round((c.getTime()-h)/u);for(let e=0;e<=g;e++){const t=new Date(h+e*u),n=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`,r=a.get(n);r?r.push(l):a.set(n,[l])}}return a}function to(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 no=({app:e,config:t})=>{var n,r,o;const{locale:i,getWeekDaysLabels:l}=bt(),s=e.getCurrentDate(),d=s.getFullYear(),c=e.getEvents(),u=null!==(n=null==t?void 0:t.startOfWeek)&&void 0!==n?n:1,h=null!==(r=null==t?void 0:t.showTimedEventsInYearView)&&void 0!==r&&r,g=null!==(o=null==t?void 0:t.gridHeatmapLevels)&&void 0!==o?o:5,m=e.timeZone,f=a.useMemo(()=>{const e=re(m);return e.setHours(0,0,0,0),e},[m]),[p,v]=a.useState(null);a.useEffect(()=>{if(!p)return;const e=e=>{const t=e.target;t.closest("[data-grid-day-popup]")||t.closest("[data-grid-day-cell]")||v(null)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[p]);const y=a.useMemo(()=>eo(c,d,h,m),[c,d,h,m]),b=a.useMemo(()=>eo(c,d,!0,m),[c,d,m]),x=a.useMemo(()=>l(i,"narrow",u).map(e=>i.startsWith("zh")?e.at(-1):e.charAt(0).toUpperCase()),[i,l,u]),w=a.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 l=n.toLocaleDateString(i,{month:"long"}),s=l.charAt(0).toUpperCase()+l.slice(1);e.push({monthIndex:t,monthName:s,cells:a})}return e},[d,i,u]),D=a.useCallback((n,r,a)=>{var o,i;const l=null!==(o=null==t?void 0:t.gridDateClick)&&void 0!==o?o:"popup";if("function"==typeof l){const e=`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,"0")}-${String(r.getDate()).padStart(2,"0")}`;return void l(r,null!==(i=b.get(e))&&void 0!==i?i:[])}if("popup"===l){const e=n.currentTarget;p&&p.date.getTime()===r.getTime()&&p.monthIndex===a?v(null):v({date:r,monthIndex:a,anchorEl:e,position:to(e)})}else"day-view"===l&&(e.setCurrentDate(r),e.changeView(exports.ViewType.DAY))},[t,e,p,b]),E=a.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=b.get(e))&&void 0!==a?a:[])}"day-view"===o&&(v(null),e.setCurrentDate(n),e.changeView(exports.ViewType.DAY))},[t,e,b]),C=a.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=b.get(t))&&void 0!==e?e:[]].toSorted((e,t)=>{const n=!!e.allDay;return n!==!!t.allDay?n?-1:1:0})},[p,b]);return Ie("div",{className:xt,children:[Ie(jr,{calendar:e,viewType:exports.ViewType.YEAR,currentDate:s,customTitle:i.startsWith("zh")||i.startsWith("ja")?`${d}年`:`${d}`,onPrevious:()=>{const t=new Date(s);t.setFullYear(t.getFullYear()-1),e.setCurrentDate(t)},onNext:()=>{const t=new Date(s);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:w.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:[x.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 i=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`,l=n&&null!==(o=null===(a=y.get(i))||void 0===a?void 0:a.length)&&void 0!==o?o:0;var s,d;return Ie("div",{"data-grid-day-cell":!0,className:"cursor-pointer rounded-sm transition-colors hover:opacity-80",style:n?(d=g,0===(s=l)?{}:{backgroundColor:`var(--heat-${Math.min(s,d)})`}):{},onClick:n=>D(n,t,e.monthIndex),onDblClick:()=>E(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()===f.getTime()?"df-fill-primary font-bold":n?l>0?l>=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(Qa,{date:p.date,events:C,anchorEl:p.anchorEl,position:p.position,onClose:()=>v(null),locale:i,app:e,customContent:null==t?void 0:t.gridPopupContent,appTimeZone:m})]})},ro=e=>{var t;const n=(null===(t=e.config)||void 0===t?void 0:t.mode)||"year-canvas";return"fixed-week"===n?Ie(Ja,Object.assign({},e)):"grid"===n?Ie(no,{app:e.app,config:e.config}):Ie(qa,Object.assign({},e))},ao={},oo=e=>n.h(Ia,Object.assign(Object.assign({},e),{viewType:exports.ViewType.YEAR,originalComponent:ro,className:"year-view-factory"}));oo.displayName="YearViewAdapter";const io={enableAutoRecalculate:!0,enableValidation:!0,defaultEvents:[],maxEventsPerDay:50};function lo(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 r.createPortal}}),exports.AlertCircle=({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:"12",cy:"12",r:"10"}),Ie("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),Ie("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]}),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=An,exports.CalendarApp=Me,exports.CalendarEvent=Lr,exports.CalendarRegistry=M,exports.CalendarRenderer=class{constructor(e,t){this.app=e,this.container=null,this.unsubscribe=null,this.renderRequested=!1,this.extraProps={},this.customRenderingStore=new cr(t),t&&this.app.setOverrides(t),this.unsubscribe=e.subscribe(()=>this.requestRender())}setProps(e){Ee(this.extraProps,e)||(this.extraProps=e,this.requestRender())}requestRender(){this.renderRequested||(this.renderRequested=!0,requestAnimationFrame(()=>{this.render(),this.renderRequested=!1}))}mount(e){this.container=e,this.render()}unmount(){this.container&&(n.render(null,this.container),this.container=null),this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null)}getCustomRenderingStore(){return this.customRenderingStore}render(){this.container&&n.render(n.h(Rn.Provider,{value:this.customRenderingStore},n.h(dr,Object.assign({app:this.app},this.extraProps))),this.container)}},exports.Check=sn,exports.ChevronDown=an,exports.ChevronRight=tn,exports.ChevronsUpDown=dn,exports.ContentSlot=Hn,exports.ContextMenu=ur,exports.ContextMenuColorPicker=({selectedColor:e,onSelect:t,onCustomColor:n})=>{const{t:r}=bt();return Ie("div",{children:[Ie("div",{className:"grid grid-cols-7 gap-2 p-1 px-3",children:vr.map(n=>Ie("button",{type:"button",className:"df-focus-ring-only h-5 w-5 rounded-full border border-gray-200 transition-transform hover:scale-110 focus:ring-2 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()?"df-ring-primary-solid ring-2 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=hr,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=gr,exports.CreateCalendarDialog=jn,exports.CustomRenderingStore=cr,exports.DayflowRangePicker=Wn,exports.DefaultColorPicker=Pn,exports.DefaultEventDetailDialog=Gn,exports.DefaultEventDetailPanel=Ir,exports.EventContextMenu=br,exports.GridContextMenu=yr,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=l,exports.Loader2=gn,exports.LoadingButton=Ln,exports.LocaleContext=yt,exports.LocaleProvider=Cn,exports.MiniCalendar=Xn,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=on,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=Le,exports.calculateDayIndex=ye,exports.calendarPickerDropdown=_t,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=xn,exports.clipboardStore=Je,exports.compareAllDayDisplayPriority=mt,exports.conditionalTheme=(e,t,n)=>e?t:n,exports.convertDateEvent=function(e,t,n,r,a=!1,o){return We(Object.assign({id:e,title:t,start:n,end:r,allDay:a},o))},exports.convertDateEventWithTimeZone=function(e,t,n,r,a,o){return Be(Object.assign({id:e,title:t,start:n,end:r,timeZone:a},o))},exports.convertToDayFlowEvent=ct,exports.createAllDayDisplayComparator=ft,exports.createAllDayEvent=function(e,t,n,r){return We(Object.assign({id:e,title:t,start:n,end:n,allDay:!0},r))},exports.createDateWithHour=C,exports.createDayView=Ha,exports.createEvent=We,exports.createEventWithDate=(e,t)=>{var n,r;const a=pe(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:ve(a,o),end:ve(a,o)})},exports.createEventWithPlainDateTime=(e,n)=>{var r,a;const o=pe(n,null!==(r=e.day)&&void 0!==r?r:0);if(null!==(a=e.allDay)&&void 0!==a&&a){const n=t.Temporal.PlainDate.from({year:o.getFullYear(),month:o.getMonth()+1,day:o.getDate()});return Object.assign(Object.assign({},e),{start:n,end:n})}const i=t.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({},e),{start:i,end:i})},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:ve(a,o),end:ve(a,o)})},exports.createEventWithZonedDateTime=(e,n,r)=>{var a,o;const i=pe(n,null!==(a=e.day)&&void 0!==a?a:0);if(null!==(o=e.allDay)&&void 0!==o&&o){const n=t.Temporal.PlainDate.from({year:i.getFullYear(),month:i.getMonth()+1,day:i.getDate()});return Object.assign(Object.assign({},e),{start:n,end:n})}const l=t.Temporal.ZonedDateTime.from({year:i.getFullYear(),month:i.getMonth()+1,day:i.getDate(),hour:i.getHours(),minute:i.getMinutes(),second:i.getSeconds(),millisecond:i.getMilliseconds(),timeZone:r});return Object.assign(Object.assign({},e),{start:l,end:l})},exports.createEvents=function(e){return e.map(e=>We(e))},exports.createEventsPlugin=function(t={}){const n=Object.assign(Object.assign({},io),t);let r;const a={getAll:()=>r.getAllEvents(),getById:e=>r.getAllEvents().find(t=>t.id===e),add:e=>{if(n.enableValidation){const t=a.validateEvent(e);if(t.length>0)throw new Error(`Event validation failed: ${t.join(", ")}`)}if(n.maxEventsPerDay&&void 0!==e.day){if(a.getByDay(e.day,r.getCurrentDate()).length>=n.maxEventsPerDay)throw new Error(`Maximum events per day (${n.maxEventsPerDay}) exceeded`)}if(r.addEvent(e),n.enableAutoRecalculate){const e=lo(r.getCurrentDate());r.state.events=be(r.getAllEvents(),e)}},update:(t,o)=>e.__awaiter(this,void 0,void 0,function*(){const e=a.getById(t);if(!e)throw new Error(`Event with id ${t} not found`);const i=Object.assign(Object.assign({},e),o);if(n.enableValidation){const e=a.validateEvent(i);if(e.length>0)throw new Error(`Event validation failed: ${e.join(", ")}`)}if(yield r.updateEvent(t,o),n.enableAutoRecalculate){const e=lo(r.getCurrentDate());r.state.events=be(r.getAllEvents(),e)}}),delete:t=>e.__awaiter(this,void 0,void 0,function*(){yield r.deleteEvent(t)}),getByDate:e=>r.getAllEvents().filter(t=>{const n=v(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)=>r.getAllEvents().filter(n=>{const r=v(n.start),a=v(n.end);return r>=e&&r<=t||a>=e&&a<=t||r<=e&&a>=t}),getByDay:(e,t)=>r.getAllEvents().filter(t=>t.day===e),getAllDayEvents:(e,t)=>t.filter(t=>t.day===e&&t.allDay),recalculateEventDays:(e,t)=>be(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"),t},filterEvents:(e,t)=>e.filter(t)};return{name:"events",config:n,install:e=>{r=e},api:a}},exports.createMonthView=Ba,exports.createStandardViews=function(e){return[Ha(null==e?void 0:e.day),Va(null==e?void 0:e.week),Ba(null==e?void 0:e.month)]},exports.createTemporalWithHour=y,exports.createTimedEvent=function(e,t,n,r,a){return We(Object.assign({id:e,title:t,start:n,end:r},a))},exports.createTimezoneEvent=Be,exports.createTimezoneEvents=function(e){return e.map(e=>Be(e))},exports.createWeekView=Va,exports.createYearView=(e={})=>{const t=Object.assign(Object.assign({},ao),e);return{type:exports.ViewType.YEAR,component:oo,config:t}},exports.dateToPlainDate=W,exports.dateToPlainDateTime=B,exports.dateToZonedDateTime=G,exports.daysBetween=function(e,n){const r=e=>{if(m(e))return e;if("function"==typeof e.toPlainDate)return e.toPlainDate();const n=e;return t.Temporal.PlainDate.from({year:n.year,month:n.month,day:n.day})},a=r(e),o=r(n);return a.until(o).days},exports.daysDifference=D,exports.downloadICS=function(e,t={}){const n=ht(e,t),r=`${t.filename||"calendar"}.ics`,a=new Blob([n],{type:"text/calendar;charset=utf-8"}),o=URL.createObjectURL(a),i=document.createElement("a");i.href=o,i.setAttribute("download",r),document.body.append(i),i.click(),i.remove(),URL.revokeObjectURL(o)},exports.en=i,exports.escapeICSValue=rt,exports.extractHourFromDate=E,exports.extractHourFromTemporal=function(e){if(e instanceof Date)return e.getHours()+e.getMinutes()/60;if(F(e))return 0;const t=e;return t.hour+t.minute/60},exports.extractVEvents=st,exports.foldLine=ot,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=Re,exports.formatDateToICSTimestamp=nt,exports.formatEventTimeRange=Q,exports.formatICSDate=tt,exports.formatMonthYear=e=>`${["January","February","March","April","May","June","July","August","September","October","November","December"][e.getMonth()]} ${e.getFullYear()}`,exports.formatProperty=it,exports.formatTemporal=Fe,exports.formatTime=X,exports.generateDayData=ue,exports.generateICS=ht,exports.generateSecondaryTimeSlots=ee,exports.generateUniKey=De,exports.generateVEvent=lt,exports.generateWeekData=ge,exports.generateWeekRange=me,exports.generateWeeksData=(e,t=3)=>{const n=5*t,{monday:r}=ce(e),a=[],o=Math.floor(n/2),i=new Date(r);i.setDate(i.getDate()-7*o);for(let e=0;e<n;e++){const t=new Date(i);t.setDate(t.getDate()+7*e),a.push(ge(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=v(t.start);a.setHours(0,0,0,0);const o=v(t.end);return o.setHours(0,0,0,0),r>=a&&r<=o}),exports.getAllDayRangeMetrics=gt,exports.getCalendarColorsForHex=R,exports.getCurrentWeekDates=(e=1)=>{const t=new Date,n=new Date,r=(t.getDay()-e+7)%7;return le.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=pe,exports.getDateObj=Ge,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 w(e)},exports.getEndOfTemporal=w,exports.getEventBgColor=O,exports.getEventEndHour=J,exports.getEventTextColor=H,exports.getEventsForDay=fe,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=v(e.start);return r>=t&&r<=n}).map(e=>{const n=ye(v(e.start),t);return Object.assign(Object.assign({},e),{day:n})})},exports.getIntlLabel=bn,exports.getLineColor=P,exports.getMonthLabels=Dn,exports.getMonthYearOfWeek=he,exports.getNextHourRangeInTimeZone=ae,exports.getNowInTimeZone=ne,exports.getPlainDate=K,exports.getSearchHeaderInfo=qe,exports.getSelectedBgColor=A,exports.getStartOfDay=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(0,0,0,0),t}return x(e)},exports.getStartOfTemporal=x,exports.getTestEvents=function(){const e=new Date,n=e.getDay(),r=new Date(e),a=0===n?-6:1-n;return r.setDate(e.getDate()+a),r.setHours(0,0,0,0),[{id:"15",title:"C-早开始",day:3,startHour:8.5,endHour:10,calendarId:"teal"},{id:"16",title:"D-晚开始",day:3,startHour:9,endHour:10.5,calendarId:"red"},{id:"21",title:"A",day:0,startHour:14,endHour:16,calendarId:"blue"},{id:"22",title:"B",day:0,startHour:14.5,endHour:16,calendarId:"green"},{id:"23",title:"C",day:0,startHour:14.5,endHour:16,calendarId:"purple"},{id:"24",title:"D",day:0,startHour:15,endHour:16,calendarId:"yellow"},{id:"25",title:"E",day:0,startHour:15,endHour:16,calendarId:"red"},{id:"26",title:"F",day:0,startHour:15.5,endHour:16,calendarId:"orange"},{id:"27",title:"G",day:0,startHour:15,endHour:16,calendarId:"pink"},{id:"28",title:"H",day:0,startHour:15.5,endHour:16,calendarId:"teal"},{id:"29",title:"L",day:0,startHour:15.5,endHour:16,calendarId:"teal"},{id:"30",title:"I",day:0,startHour:15.5,endHour:16,calendarId:"blue"},{id:"99",title:"X",day:0,startHour:15.5,endHour:16,calendarId:"blue"},{id:"6",title:"假日",day:0,startHour:0,endHour:0,calendarId:"blue",allDay:!0},{id:"7",title:"研讨会",day:2,startHour:0,endHour:0,calendarId:"green",allDay:!0},{id:"8",title:"团队建设",day:4,startHour:0,endHour:0,calendarId:"purple",allDay:!0},{id:"41",title:"A",day:3,startHour:16,endHour:18.25,calendarId:"blue"},{id:"42",title:"B",day:3,startHour:16.5,endHour:18,calendarId:"green"},{id:"43",title:"C",day:3,startHour:16.75,endHour:17.75,calendarId:"purple"},{id:"44",title:"D",day:3,startHour:17,endHour:19,calendarId:"yellow"},{id:"45",title:"E",day:3,startHour:17.75,endHour:18.75,calendarId:"red"},{id:"46",title:"X",day:2,startHour:15,endHour:15.75,calendarId:"orange"},{id:"47",title:"Y",day:2,startHour:15.5,endHour:19.5,calendarId:"pink"},{id:"48",title:"Z",day:2,startHour:15,endHour:15.75,calendarId:"teal"},{id:"59",title:"Q",day:2,startHour:17,endHour:18,calendarId:"teal"},{id:"60",title:"W",day:2,startHour:15.5,endHour:18,calendarId:"teal"},{id:"31",title:"A",day:6,startHour:14,endHour:16,calendarId:"blue"},{id:"32",title:"B",day:6,startHour:14.5,endHour:16,calendarId:"green"},{id:"33",title:"C",day:6,startHour:14.5,endHour:16,calendarId:"purple"},{id:"34",title:"D",day:6,startHour:15,endHour:16,calendarId:"yellow"},{id:"35",title:"E",day:6,startHour:15.5,endHour:16.5,calendarId:"red"},{id:"36",title:"F",day:6,startHour:16.25,endHour:16.75,calendarId:"orange"},{id:"37",title:"G",day:6,startHour:16,endHour:17.25,calendarId:"pink"},{id:"51",title:"下周会议1",day:1,startHour:9,endHour:10,calendarId:"blue"},{id:"52",title:"下周会议2",day:3,startHour:14,endHour:15,calendarId:"green"},{id:"81",title:"A",day:5,startHour:14,endHour:16,calendarId:"blue"},{id:"82",title:"B",day:5,startHour:14.5,endHour:16,calendarId:"green"},{id:"83",title:"C",day:5,startHour:14.5,endHour:16,calendarId:"purple"},{id:"84",title:"D",day:5,startHour:15,endHour:16,calendarId:"yellow"},{id:"85",title:"E",day:5,startHour:15,endHour:16,calendarId:"red"},{id:"86",title:"F",day:5,startHour:15.75,endHour:17,calendarId:"orange"},{id:"87",title:"G",day:5,startHour:14.75,endHour:17.5,calendarId:"pink"}].map(e=>{const n=new Date(r);if(n.setDate(r.getDate()+e.day),e.allDay)return{id:e.id,title:e.title,start:t.Temporal.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()}),end:t.Temporal.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()}),allDay:!0,calendarId:e.calendarId,day:e.day};const a=Math.floor(e.startHour),o=Math.round(60*(e.startHour-a)),i=Math.floor(e.endHour),l=Math.round(60*(e.endHour-i));return{id:e.id,title:e.title,start:t.Temporal.ZonedDateTime.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate(),hour:a,minute:o,timeZone:t.Temporal.Now.timeZoneId()}),end:t.Temporal.ZonedDateTime.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate(),hour:i,minute:l,timeZone:t.Temporal.Now.timeZoneId()}),allDay:!1,calendarId:e.calendarId,day:e.day}})},exports.getTimezoneDisplayLabel=te,exports.getTodayInTimeZone=re,exports.getWeekDaysLabels=wn,exports.getWeekNumber=T,exports.getWeekRange=ce,exports.getZoneId=je,exports.groupSearchResults=Xe,exports.hasEventChanged=we,exports.importICSFile=function(t,n){return e.__awaiter(this,void 0,void 0,function*(){try{const e=yield t.text();if(!e)throw new Error("File content is empty");return ut(e,n)}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=Ee,exports.isEventDeepEqual=xe,exports.isEventInWeek=(e,t)=>{const n=ye(e,t);return n>=0&&n<=6},exports.isMultiDayEvent=(e,t)=>!k(e,t),exports.isMultiDayTemporalEvent=function(e,t){return!b(e,t)},exports.isPlainDate=F,exports.isPlainDateTime=V,exports.isSameDay=k,exports.isSamePlainDate=b,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=K(e),r=K(t);return n.equals(r)},exports.isValidLocale=d,exports.isZonedDateTime=Z,exports.mergeClasses=(...e)=>e.filter(Boolean).join(" "),exports.mergeFormatTemplate=Ae,exports.monthNames=se,exports.normalizeCssWidth=function(e,t="240px"){return"number"==typeof e?`${e}px`:"string"==typeof e&&e.trim().length>0?e:t},exports.normalizeDate=Ke,exports.normalizeLocale=s,exports.normalizeTimeZoneValue=Y,exports.normalizeToZoned=Ye,exports.now=function(e=t.Temporal.Now.timeZoneId()){return t.Temporal.Now.zonedDateTimeISO(e)},exports.pad=He,exports.pad2=Qe,exports.parseICS=ut,exports.parseICSDate=et,exports.parseTemporalString=$e,exports.parseVEventLines=dt,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=be,exports.registerDragImplementation=function(e){ka=e},exports.registerLocale=function(e){const t=e.code.split("-")[0].toLowerCase();l[t]=e},exports.registerSidebarImplementation=function(e){or=e},exports.resolveAppliedTheme=_e,exports.restoreTimedDragFromAllDayTransition=({wasOriginallyAllDay:e,mouseHour:t,hourOffset:n,duration:r,originalStartHour:a,originalEndHour:o,firstHour:i,lastHour:l,minDuration:s,roundToTimeStep:d})=>{const c=e?1:Math.max(s,r||o-a||1);let u=d(e?t:t+(null!=n?n:0));return u=Math.max(i,Math.min(l-c,u)),{startHour:u,endHour:u+c,duration:c,hourOffset:e?0:null!=n?n:0}},exports.restoreVisualEventToCanonical=ie,exports.restoreVisualTimedTemporalToCanonical=oe,exports.roundToTimeStep=e=>.25*Math.round(e/.25),exports.scrollbarTakesSpace=Ze,exports.setHourInTemporal=function(e,t){const n=Math.floor(t),r=Math.round(60*(t-n));return Z(e),e.with({hour:n,minute:r,second:0,millisecond:0})},exports.shortMonthNames=de,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.subscribeCalendar=function(t){return e.__awaiter(this,void 0,void 0,function*(){const e=yield fetch(t);if(!e.ok)throw new Error(`HTTP ${e.status}`);const n=yield e.text(),r=ut(n),a=n.match(/X-WR-CALNAME[^:]*:([^\r\n]+)/),o=a?a[1].trim():new URL(t).hostname,i=["#3b82f6","#10b981","#8b5cf6","#f59e0b","#ef4444","#f97316","#ec4899","#14b8a6","#6366f1","#6b7280"],l=i[Math.floor(Math.random()*i.length)],{colors:s,darkColors:d}=R(l);return{calendar:{id:De(),name:o,isVisible:!0,colors:s,darkColors:d,subscription:{url:t,status:"ready"}},events:r.events}})},exports.t=En,exports.temporalToDate=_,exports.temporalToVisualDate=z,exports.temporalToVisualTemporal=U,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:"df-focus-ring-only",input:"bg-white dark:bg-gray-700 border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100",inputFocus:"df-focus-ring",buttonPrimary:"df-fill-primary df-hover-primary-solid",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:"df-fill-destructive df-hover-destructive",buttonSuccess:"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-200 hover:bg-blue-200 dark:hover:bg-blue-800",shadow:"shadow-sm dark:shadow-gray-900/50",shadowMd:"shadow-md dark:shadow-gray-900/50",shadowLg:"shadow-lg dark:shadow-gray-900/50",divider:"border-gray-200 dark:border-gray-700"},exports.themeCn=(e,t,n)=>`${e} ${t} ${n.split(" ").filter(Boolean).map(e=>`dark:${e}`).join(" ")}`.trim(),exports.today=function(e=t.Temporal.Now.timeZoneId()){return t.Temporal.Now.plainDateISO(e)},exports.unescapeICSValue=at,exports.updateEventDateAndDay=(e,n,r)=>{const a=pe(r,n);return Object.assign(Object.assign({},e),{day:n,start:e.allDay?t.Temporal.PlainDate.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate()}):t.Temporal.ZonedDateTime.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate(),hour:a.getHours(),minute:a.getMinutes(),timeZone:t.Temporal.Now.timeZoneId()}),end:e.allDay?t.Temporal.PlainDate.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate()}):t.Temporal.ZonedDateTime.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate(),hour:a.getHours(),minute:a.getMinutes(),timeZone:t.Temporal.Now.timeZoneId()})})},exports.updateEventWithRealDate=(e,t,n)=>{var r;const a=new Date(n);a.setDate(n.getDate()+t);const o=null!==(r=e.allDay)&&void 0!==r&&r;return Object.assign(Object.assign({},e),{day:t,start:ve(a,o),end:ve(a,o)})},exports.useDragForView=Ma,exports.useLocale=bt,exports.useSidebarBridge=lr,exports.weekDays=le,exports.weekDaysFullName=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],exports.zonedDateTimeToDate=p;
|
|
1
|
+
"use strict";var e=require("tslib"),t=require("temporal-polyfill"),n=require("preact"),r=require("preact/compat"),a=require("preact/hooks"),o=require("@dayflow/blossom-color-picker");const i={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."}},l={en:i};function s(e){const t=e.split("-")[0].toLowerCase();return t in l?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;function m(e){var n;if(!e||"object"!=typeof e)return!1;if(e instanceof Date)return!1;if(e instanceof t.Temporal.PlainDate)return!0;const r=e;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 f(e,n=t.Temporal.Now.timeZoneId()){return t.Temporal.Instant.fromEpochMilliseconds(e.getTime()).toZonedDateTimeISO(n)}function p(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 v(e,n){if(e instanceof Date)return e;if(m(e))return function(e,n=t.Temporal.Now.timeZoneId()){if("function"==typeof e.toZonedDateTime)try{return p(e.toZonedDateTime({timeZone:n,plainTime:t.Temporal.PlainTime.from({hour:0,minute:0})}))}catch(e){}return new Date(e.year,e.month-1,e.day)}(e,n);if(e&&"object"==typeof e&&"hour"in e&&!("timeZone"in e)){const t=e;return new Date(t.year,t.month-1,t.day,t.hour,t.minute,t.second||0,t.millisecond||0)}if(e&&"object"==typeof e&&"year"in e){return p(e)}return new Date(e)}function y(e,n){const r=Math.floor(n),a=Math.round(60*(n-r));if(m(e))return t.Temporal.PlainDateTime.from({year:e.year,month:e.month,day:e.day,hour:r,minute:a});if("function"==typeof e.with)return e.with({hour:r,minute:a,second:0,millisecond:0});const o=e;return t.Temporal.PlainDateTime.from({year:o.year,month:o.month,day:o.day,hour:r,minute:a})}function b(e,n){if(e instanceof Date&&n instanceof Date)return e.toDateString()===n.toDateString();const r=e=>{if(e instanceof Date)return n=e,t.Temporal.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()});var n;if(m(e))return e;if("function"==typeof e.toPlainDate)return e.toPlainDate();const r=e;return t.Temporal.PlainDate.from({year:r.year,month:r.month,day:r.day})},a=r(e),o=r(n);return 0===t.Temporal.PlainDate.compare(a,o)}function x(e,n=t.Temporal.Now.timeZoneId()){if("function"==typeof e.toZonedDateTime){return(m(e)?e:e.toPlainDate()).toZonedDateTime({timeZone:n,plainTime:t.Temporal.PlainTime.from({hour:0,minute:0})})}const r=e;return(m(e)?e:t.Temporal.PlainDate.from({year:r.year,month:r.month,day:r.day})).toZonedDateTime({timeZone:n,plainTime:t.Temporal.PlainTime.from({hour:0,minute:0})})}function w(e,n=t.Temporal.Now.timeZoneId()){if("function"==typeof e.toZonedDateTime){return(m(e)?e:e.toPlainDate()).toZonedDateTime({timeZone:n,plainTime:t.Temporal.PlainTime.from({hour:23,minute:59,second:59,millisecond:999})})}const r=e;return(m(e)?e:t.Temporal.PlainDate.from({year:r.year,month:r.month,day:r.day})).toZonedDateTime({timeZone:n,plainTime:t.Temporal.PlainTime.from({hour:23,minute:59,second:59,millisecond:999})})}function D(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)}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.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.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.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.KARACHI="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.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 E=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(m(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)},C=(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 y(e,t)},T=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)},k=(e,n)=>{if(e instanceof Date&&n instanceof Date)return e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate();return b(e instanceof Date?t.Temporal.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()}):m(e)?e:e.toPlainDate(),n instanceof Date?t.Temporal.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()}):m(n)?n:n.toPlainDate())},S=[{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 M{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)}):S.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=M.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 N=new M;function I(){return N}function R(e){const t=S.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 O=(e,t)=>(t||I()).resolveColors(e).eventColor,H=(e,t)=>(t||I()).resolveColors(e).textColor,A=(e,t)=>(t||I()).resolveColors(e).eventSelectedColor,P=(e,t)=>(t||I()).resolveColors(e).lineColor;const L=new class{constructor(){var e,t;this.isDevelopment="production"!==(null===(t=null===(e=globalThis.process)||void 0===e?void 0:e.env)||void 0===t?void 0:t.NODE_ENV)}formatMessage(e,t,...n){if(!this.isDevelopment)return;const r=(new Date).toISOString(),a=`[DayFlow ${e.toUpperCase()}] ${r}:`;switch(e){case"log":console.log(a,t,...n);break;case"warn":console.warn(a,t,...n);break;case"error":console.error(a,t,...n);break;case"debug":console.debug(a,t,...n)}}log(e,...t){this.formatMessage("log",e,...t)}warn(e,...t){this.formatMessage("warn",e,...t)}error(e,...t){this.formatMessage("error",e,...t)}debug(e,...t){this.formatMessage("debug",e,...t)}},$=new Map;function j(e){try{return new Intl.DateTimeFormat("en",{timeZone:e}).resolvedOptions().timeZone}catch(e){return}}function Y(e){if(!e||"string"!=typeof e)return;const t=e.trim();if(!t)return;const n=$.get(t);if(n)return n;const r=j(t);if(r)return $.set(t,r),r;const a=Object.values(exports.TimeZone).find(e=>e.toLowerCase()===t.toLowerCase());if(a){const e=j(a);return e?($.set(t,e),e):($.set(t,a),a)}if("function"==typeof Intl.supportedValuesOf){const e=Intl.supportedValuesOf("timeZone").find(e=>e.toLowerCase()===t.toLowerCase());if(e)return $.set(t,e),e}const o=j(t.split("/").map(e=>e.split("_").map(e=>e?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():e).join("_")).join("/"));if(o)return $.set(t,o),o;const i=j(t.split("/").map((e,t)=>0===t?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():e).join("/"));return i?($.set(t,i),i):t}function F(e){return null!==e&&"object"==typeof e&&!("hour"in e)&&"year"in e&&"month"in e&&"day"in e&&!(e instanceof Date)}function V(e){return null!==e&&"object"==typeof e&&"hour"in e&&!("timeZone"in e)&&!("timeZoneId"in e)&&"year"in e&&!(e instanceof Date)}function Z(e){return null!==e&&"object"==typeof e&&("timeZone"in e||"timeZoneId"in e)&&"year"in e&&!(e instanceof Date)}function _(e){if(e instanceof Date)return e;if(F(e))return new Date(e.year,e.month-1,e.day);if(V(e))return new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second||0,e.millisecond||0);if(Z(e))try{if("function"==typeof e.toInstant){const t=e.toInstant();return new Date(t.epochMilliseconds)}return"number"==typeof e.epochMilliseconds?new Date(e.epochMilliseconds):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 z(e,n){if(e instanceof Date)return e;if(!n)return _(e);const r=Y(n);if(!r)return _(e);try{if(Z(e)){const n=("function"==typeof e.withTimeZone?e:t.Temporal.ZonedDateTime.from(e)).withTimeZone(r);return new Date(n.year,n.month-1,n.day,n.hour,n.minute,n.second||0,n.millisecond||0)}if(V(e)){const n="function"==typeof e.toZonedDateTime?e:t.Temporal.PlainDateTime.from(e),a=n.toZonedDateTime(t.Temporal.Now.timeZoneId()).withTimeZone(r);return new Date(a.year,a.month-1,a.day,a.hour,a.minute,a.second||0,a.millisecond||0)}}catch(e){L.error("Failed to shift visual timezone:",e)}return _(e)}function U(e,n){if(!n)return e;const r=Y(n);if(!r)return e;try{if(Z(e)){return("function"==typeof e.withTimeZone?e:t.Temporal.ZonedDateTime.from(e)).withTimeZone(r)}if(V(e)){return("function"==typeof e.toZonedDateTime?e:t.Temporal.PlainDateTime.from(e)).toZonedDateTime(t.Temporal.Now.timeZoneId()).withTimeZone(r)}}catch(e){L.error("Failed to shift visual temporal:",e)}return e}function W(e){return t.Temporal.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()})}function B(e){return t.Temporal.PlainDateTime.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),millisecond:e.getMilliseconds()})}function G(e,n=t.Temporal.Now.timeZoneId()){return t.Temporal.ZonedDateTime.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),millisecond:e.getMilliseconds(),timeZone:n})}function K(e){return e instanceof Date?W(e):F(e)?e:(V(e),e.toPlainDate())}const q=e=>new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second,Math.floor(e.millisecond)),X=(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")}`},J=e=>{if(!e.end)return 0;const t=E(e.end);if(e.allDay||!e.start)return t;const n=v(e.start),r=v(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},Q=(e,t="24h")=>{const n=E(e.start),r=J(e);return`${X(n,0,t)} - ${X(r,0,t)}`},ee=(e,n,r="24h",a=new Date,o)=>{const i=Y(n);if(!i)return e.map(()=>"");const l=null!=o?o:t.Temporal.Now.timeZoneId(),s=a.getFullYear(),d=a.getMonth()+1,c=a.getDate();return e.map(e=>{try{const n=e.hour%24,a=t.Temporal.ZonedDateTime.from({year:s,month:d,day:c,hour:n,minute:0,second:0,timeZone:l}).withTimeZone(i);return X(a.hour,a.minute,r)}catch(e){return""}})},te=(e,t=new Date)=>{var n,r;const a=Y(e);if(!a)return"";try{return null!==(r=null===(n=new Intl.DateTimeFormat("en",{timeZone:a,timeZoneName:"short"}).formatToParts(t).find(e=>"timeZoneName"===e.type))||void 0===n?void 0:n.value)&&void 0!==r?r:a}catch(e){return a}},ne=e=>{var n;const r=null!==(n=e?Y(e):void 0)&&void 0!==n?n:t.Temporal.Now.timeZoneId();return q(t.Temporal.Now.zonedDateTimeISO(r))},re=e=>{var n;const r=null!==(n=e?Y(e):void 0)&&void 0!==n?n:t.Temporal.Now.timeZoneId(),a=t.Temporal.Now.plainDateISO(r);return new Date(a.year,a.month-1,a.day)},ae=e=>{var n;const r=null!==(n=e?Y(e):void 0)&&void 0!==n?n:t.Temporal.Now.timeZoneId(),a=t.Temporal.Now.zonedDateTimeISO(r).add({hours:1}).with({minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});return{start:q(a),end:q(a.add({hours:1}))}},oe=(e,n,r)=>{var a,o;const i=v(e);if(Z(n)){const e=null!==(a=Y(r))&&void 0!==a?a:t.Temporal.Now.timeZoneId(),o=(e=>{var n;const r=e;return r.timeZoneId||("string"==typeof r.timeZone?r.timeZone:null===(n=r.timeZone)||void 0===n?void 0:n.id)||t.Temporal.Now.timeZoneId()})(n);return G(i,e).toInstant().toZonedDateTimeISO(o)}return V(n)?B(i):Z(e)?e:G(i,null!==(o=Y(r))&&void 0!==o?o:t.Temporal.Now.timeZoneId())},ie=(e,t,n)=>t.allDay?Object.assign(Object.assign({},t),{allDay:!0,start:F(t.start)?t.start:W(v(t.start)),end:F(t.end)?t.end:W(v(t.end))}):Object.assign(Object.assign({},t),{allDay:!1,start:oe(t.start,e.allDay?t.start:e.start,n),end:oe(t.end,e.allDay?t.end:e.end,n)}),le=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],se=["January","February","March","April","May","June","July","August","September","October","November","December"],de=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],ce=(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}},ue=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:se[r],shortMonthName:de[r],isToday:o.getDate()===n&&o.getMonth()===r&&o.getFullYear()===a}},he=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:se[a],monthIndex:a,year:o}},ge=e=>{const t=[],n=new Date(e);for(let e=0;e<7;e++){const e=new Date(n);t.push(ue(e)),n.setDate(n.getDate()+1)}return{days:t,startDate:new Date(e),monthYear:he(t)}};function me(e,t,n=1){const r=[],a=Math.floor(t/2),o=(e.getDay()-n+7)%7,i=new Date(e);i.setDate(e.getDate()-o),i.setHours(0,0,0,0);const l=new Date(i);l.setDate(l.getDate()-7*a);for(let e=0;e<t;e++){const t=new Date(l);t.setDate(t.getDate()+7*e),r.push(ge(t))}return r}const fe=(e,t)=>t.filter(t=>t.day===e&&!t.allDay),pe=(e,t)=>{const n=new Date(e);return n.setDate(e.getDate()+t),n},ve=(e,n)=>n?t.Temporal.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()}):t.Temporal.ZonedDateTime.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),millisecond:e.getMilliseconds(),timeZone:t.Temporal.Now.timeZoneId()}),ye=(e,t)=>{const n=new Date(e);n.setHours(0,0,0,0);const r=new Date(t);r.setHours(0,0,0,0);const a=n.getTime()-r.getTime();return Math.floor(a/864e5)},be=(e,t)=>e.map(e=>{const n=v(e.start),r=ye(n,t);return Object.assign(Object.assign({},e),{day:r})}),xe=(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()),we=(e,t)=>v(e.start).getTime()!==v(t.start).getTime()||v(e.end).getTime()!==v(t.end).getTime()||e.title!==t.title||e.day!==t.day||!!e.allDay!=!!t.allDay;function De(){return Date.now().toString(36)+Math.random().toString(36).slice(2,8)}function Ee(e,t){if(e===t)return!0;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;const a=e,o=t;for(const e of n)if(!r.includes(e)||!Ee(a[e],o[e]))return!1;return!0}class Ce{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=Ce.normalizeChanges(this.pendingChanges);return this.isInTransaction=!1,this.pendingChanges=[],t.length>0?null===(e=this.onEventBatchChange)||void 0===e?void 0:e.call(this,t):void 0}createEvent(e){if(this.events.has(e.id))throw new Error(`Event with ID ${e.id} already exists.`);return 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);return this.events.set(e,r),this.emitChange({type:"update",before:n,after:r})}deleteEvent(e){const t=this.events.get(e);if(t)return 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;if(!this.isInTransaction)return null===(t=this.onEventChange)||void 0===t?void 0:t.call(this,e);this.pendingChanges.push(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 Te{constructor(e,t,n,r,a,o){this.state=e,this.registry=t,this.getCallbacks=n,this.notify=r,this.triggerRender=a,this.undoStack=[],this.pendingSnapshot=null,this.pendingChangeSource=null,this.externalEvents=new Map,this.MAX_UNDO_STACK=50,this.store=new Ce(o),this.setupStoreListeners()}setupStoreListeners(){this.store.onEventChange=e=>{var t,n,r,a;this.syncExternalEventsToState();let o=null;return"create"===e.type?o=null===(n=(t=this.getCallbacks()).onEventCreate)||void 0===n?void 0:n.call(t,e.event):"update"===e.type&&(o=null===(a=(r=this.getCallbacks()).onEventUpdate)||void 0===a?void 0:a.call(r,e.after)),this.triggerRender(),this.notify(),null!=o?o:void 0},this.store.onEventBatchChange=e=>{var t,n;this.syncExternalEventsToState();let r=null;return"drag"!==this.pendingChangeSource&&"resize"!==this.pendingChangeSource&&(r=null===(n=(t=this.getCallbacks()).onEventBatchChange)||void 0===n?void 0:n.call(t,e)),this.pendingChangeSource=null,this.triggerRender(),this.notify(),null!=r?r:void 0}}getStore(){return this.store}pushToUndo(e){this.undoStack.push({type:"events_snapshot",data:e||[...this.state.events]}),this.undoStack.length>this.MAX_UNDO_STACK&&this.undoStack.shift()}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 Ce(this.state.events),this.setupStoreListeners(),this.triggerRender(),this.notify())}applyEventsChanges(e,t,n){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){L.warn(`Failed to update event ${e}:`,t)}}),e.add&&e.add.forEach(e=>{try{this.store.createEvent(e)}catch(t){L.warn(`Failed to create event ${e.id}:`,t)}}),this.store.endTransaction()}addEvent(e){this.pendingSnapshot=null,this.pushToUndo(),this.store.createEvent(e)}addExternalEvents(e,t){const n=t.map(t=>Object.assign(Object.assign({},t),{calendarId:e}));this.externalEvents.set(e,n),this.syncExternalEventsToState(),this.notify()}syncExternalEventsToState(){const e=this.store.getAllEvents(),t=new Map;if(e.forEach(e=>t.set(e.id,e)),this.externalEvents.size>0)for(const e of this.externalEvents.values())e.forEach(e=>t.set(e.id,e));this.state.events=Array.from(t.values())}updateEvent(t,n,r,a){return e.__awaiter(this,void 0,void 0,function*(){if(a&&(this.pendingChangeSource=a),r?this.pendingSnapshot||(this.pendingSnapshot=[...this.state.events]):this.pendingSnapshot?(this.pushToUndo(this.pendingSnapshot),this.pendingSnapshot=null):this.pushToUndo(),r){const e=this.state.events.findIndex(e=>e.id===t);if(-1===e)throw new Error(`Event with id ${t} not found`);const r=Object.assign(Object.assign({},this.state.events[e]),n);return this.state.events=[...this.state.events.slice(0,e),r,...this.state.events.slice(e+1)],void this.notify()}yield this.store.updateEvent(t,n)})}deleteEvent(t){return e.__awaiter(this,void 0,void 0,function*(){var e,n;yield null===(n=(e=this.getCallbacks()).onEventDelete)||void 0===n?void 0:n.call(e,t),this.pendingSnapshot=null,this.pushToUndo(),yield this.store.deleteEvent(t)})}getAllEvents(){return[...this.state.events]}getEvents(){const e=this.state.events||[],t=new Set(this.registry.getAll().filter(e=>!1!==e.isVisible).map(e=>e.id));return e.filter(e=>!!e.calendarId&&t.has(e.calendarId))}onEventClick(e){var t,n;null===(n=(t=this.getCallbacks()).onEventClick)||void 0===n||n.call(t,e)}onMoreEventsClick(e){var t,n;null===(n=(t=this.getCallbacks()).onMoreEventsClick)||void 0===n||n.call(t,e)}highlightEvent(e){var t,n;this.state.highlightedEventId!==e&&(this.state.highlightedEventId=e,null===(n=(t=this.getCallbacks()).onRender)||void 0===n||n.call(t),this.notify())}selectEvent(e){var t,n;this.state.selectedEventId!==e&&(this.state.selectedEventId=e,null===(n=(t=this.getCallbacks()).onRender)||void 0===n||n.call(t),this.notify())}dismissUI(){var e,t;null===(t=(e=this.getCallbacks()).onDismissUI)||void 0===t||t.call(e),this.notify()}}class ke{constructor(e,t,n,r){this.state=e,this.getCallbacks=t,this.notify=n,this.visibleMonth=new Date(r.getFullYear(),r.getMonth(),1)}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.getCallbacks()).onViewChange)||void 0===n||n.call(t,e),this.handleVisibleRangeChange("viewChange"),this.notify()}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}emitVisibleRange(e,t,n="navigation"){var r,a;null===(a=(r=this.getCallbacks()).onVisibleRangeChange)||void 0===a||a.call(r,new Date(e),new Date(t),n)}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}=ce(this.state.currentDate,r),i=new Date(a),l=new Date(a);l.setDate(l.getDate()+7),this.emitVisibleRange(i,l,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:i}=ce(t,n),l=new Date(i),s=new Date(i);s.setDate(s.getDate()+42),this.emitVisibleRange(l,s,e);break}case exports.ViewType.YEAR:{const t=new Date(this.state.currentDate.getFullYear(),0,1);t.setHours(0,0,0,0);const n=new Date(this.state.currentDate.getFullYear(),11,31);n.setDate(n.getDate()+1),this.emitVisibleRange(t,n,e);break}}}setCurrentDate(e){var t,n;this.state.currentDate=new Date(e),null===(n=(t=this.getCallbacks()).onDateChange)||void 0===n||n.call(t,this.state.currentDate),this.setVisibleMonth(this.state.currentDate),this.handleVisibleRangeChange("navigation"),this.notify()}getCurrentDate(){return new Date(this.state.currentDate)}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.getCallbacks()).onVisibleMonthChange)||void 0===n||n.call(t,new Date(this.visibleMonth)),this.notify())}getVisibleMonth(){return new Date(this.visibleMonth)}goToToday(){const e=t.Temporal.Now.plainDateISO(this.state.timeZone),n=new Date(e.year,e.month-1,e.day);this.setCurrentDate(n)}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)}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)}selectDate(e){var t,n;this.setCurrentDate(e),null===(n=(t=this.getCallbacks()).onDateChange)||void 0===n||n.call(t,new Date(e))}}class Se{constructor(e,t){this.state=e,this.notify=t}install(e,t){this.state.plugins.has(e.name)?L.warn(`Plugin ${e.name} is already installed`):(this.state.plugins.set(e.name,e),e.install(t))}getPlugin(e){const t=this.state.plugins.get(e);return null==t?void 0:t.api}hasPlugin(e){return this.state.plugins.has(e)}getPluginConfig(e){const t=this.state.plugins.get(e);return(null==t?void 0:t.config)||{}}updatePluginConfig(e,t){const n=this.state.plugins.get(e);n&&(n.config=Object.assign(Object.assign({},n.config),t),this.notify())}}class Me{constructor(n){var r,a,o,i,l;this.subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e)),this.notify=()=>{this.listeners.forEach(e=>e(this))},this.triggerRender=()=>{var e,t;null===(t=(e=this.callbacks).onRender)||void 0===t||t.call(e),this.notify()},this.changeView=e=>this.navigation.changeView(e),this.getCurrentView=()=>this.navigation.getCurrentView(),this.emitVisibleRange=(e,t,n)=>this.navigation.emitVisibleRange(e,t,n),this.handleVisibleRangeChange=e=>this.navigation.handleVisibleRangeChange(e),this.setCurrentDate=e=>this.navigation.setCurrentDate(e),this.getCurrentDate=()=>this.navigation.getCurrentDate(),this.setVisibleMonth=e=>this.navigation.setVisibleMonth(e),this.getVisibleMonth=()=>this.navigation.getVisibleMonth(),this.goToToday=()=>this.navigation.goToToday(),this.goToPrevious=()=>this.navigation.goToPrevious(),this.goToNext=()=>this.navigation.goToNext(),this.selectDate=e=>this.navigation.selectDate(e),this.undo=()=>this.eventManager.undo(),this.applyEventsChanges=(e,t,n)=>this.eventManager.applyEventsChanges(e,t,n),this.addEvent=e=>this.eventManager.addEvent(e),this.addExternalEvents=(e,t)=>this.eventManager.addExternalEvents(e,t),this.updateEvent=(e,t,n,r)=>this.eventManager.updateEvent(e,t,n,r),this.deleteEvent=e=>this.eventManager.deleteEvent(e),this.getAllEvents=()=>this.eventManager.getAllEvents(),this.getEvents=()=>this.eventManager.getEvents(),this.onEventClick=e=>this.eventManager.onEventClick(e),this.onMoreEventsClick=e=>this.eventManager.onMoreEventsClick(e),this.highlightEvent=e=>this.eventManager.highlightEvent(e),this.selectEvent=e=>this.eventManager.selectEvent(e),this.dismissUI=()=>this.eventManager.dismissUI(),this.getReadOnlyConfig=e=>function(e,t,n,r){var a,o;let i=!0,l=!0;if(!0===e?(i=!1,l=!1):!1!==e&&(i=null===(a=e.draggable)||void 0===a||a,l=null===(o=e.viewable)||void 0===o||o),t&&(i||l)){let e=t;const a=r.find(e=>e.id===t);(null==a?void 0:a.calendarId)&&(e=a.calendarId);const o=n.get(e);o&&(!0===o.readOnly&&(i=!1),o.subscription&&void 0===o.readOnly&&(i=!1))}return{draggable:i,viewable:l}}(this.state.readOnly,e,this.calendarRegistry,this.state.events),this.canMutateFromUI=e=>function(e,t,n,r){if(!1!==e)return!1;if(t){let e=t;const a=r.find(e=>e.id===t);(null==a?void 0:a.calendarId)&&(e=a.calendarId);const o=n.get(e);if(o){if(void 0!==o.readOnly)return!o.readOnly;if(o.subscription)return!1}}return!0}(this.state.readOnly,e,this.calendarRegistry,this.state.events),this.getCalendars=()=>this.calendarRegistry.getAll(),this.reorderCalendars=(e,t)=>{this.calendarRegistry.reorder(e,t),this.triggerRender()},this.setCalendarVisibility=(e,t)=>{this.calendarRegistry.setVisibility(e,t),this.triggerRender()},this.setAllCalendarsVisibility=e=>{this.calendarRegistry.setAllVisibility(e),this.triggerRender()},this.updateCalendar=(e,t,n)=>{var r,a;if(this.calendarRegistry.updateCalendar(e,t),n)return void this.notify();const o=this.calendarRegistry.get(e);o&&(null===(a=(r=this.callbacks).onCalendarUpdate)||void 0===a||a.call(r,o)),this.triggerRender()},this.createCalendar=t=>e.__awaiter(this,void 0,void 0,function*(){var e,n;this.calendarRegistry.register(t),yield null===(n=(e=this.callbacks).onCalendarCreate)||void 0===n?void 0:n.call(e,t),this.triggerRender()}),this.deleteCalendar=t=>e.__awaiter(this,void 0,void 0,function*(){var e,n;this.calendarRegistry.unregister(t),yield null===(n=(e=this.callbacks).onCalendarDelete)||void 0===n?void 0:n.call(e,t),this.triggerRender()}),this.mergeCalendars=(t,n)=>e.__awaiter(this,void 0,void 0,function*(){var e,r;const a=this.eventManager.getStore(),o=a.getAllEvents().filter(e=>e.calendarId===t);this.eventManager.pushToUndo(),a.beginTransaction(),o.forEach(e=>a.updateEvent(e.id,{calendarId:n})),yield a.endTransaction(),yield this.deleteCalendar(t),yield null===(r=(e=this.callbacks).onCalendarMerge)||void 0===r?void 0:r.call(e,t,n)}),this.getPlugin=e=>this.pluginManager.getPlugin(e),this.hasPlugin=e=>this.pluginManager.hasPlugin(e),this.getPluginConfig=e=>this.pluginManager.getPluginConfig(e),this.updatePluginConfig=(e,t)=>this.pluginManager.updatePluginConfig(e,t),this.setTheme=e=>{this.calendarRegistry.setTheme(e),this.themeChangeListeners.forEach(t=>t(e)),this.triggerRender()},this.getTheme=()=>this.calendarRegistry.getTheme(),this.subscribeThemeChange=e=>(this.themeChangeListeners.add(e),()=>this.unsubscribeThemeChange(e)),this.unsubscribeThemeChange=e=>{this.themeChangeListeners.delete(e)},this.getViewConfig=e=>{const t=this.state.views.get(e);return(null==t?void 0:t.config)||{}},this.getCalendarRegistry=()=>this.calendarRegistry,this.getUseEventDetailDialog=()=>this.useEventDetailDialog,this.getCustomMobileEventRenderer=()=>this.customMobileEventRenderer,this.getCalendarHeaderConfig=()=>this.useCalendarHeader,this.setOverrides=e=>{this.state.overrides=e,this.triggerRender()},this.updateConfig=e=>{var t,n;let r=!1;if(void 0!==e.customMobileEventRenderer&&e.customMobileEventRenderer!==this.customMobileEventRenderer&&(this.customMobileEventRenderer=e.customMobileEventRenderer,r=!0),void 0!==e.useEventDetailDialog&&e.useEventDetailDialog!==this.useEventDetailDialog&&(this.useEventDetailDialog=e.useEventDetailDialog,r=!0),void 0!==e.useCalendarHeader&&e.useCalendarHeader!==this.useCalendarHeader&&(this.useCalendarHeader=e.useCalendarHeader,r=!0),void 0===e.readOnly||Ee(e.readOnly,this.state.readOnly)||(this.state.readOnly=e.readOnly,r=!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,r=!0),void 0!==e.locale){const t=Me.resolveLocale(e.locale);Ee(t,this.state.locale)||(this.state.locale=t,r=!0)}if(void 0!==e.allDaySortComparator&&e.allDaySortComparator!==this.state.allDaySortComparator&&(this.state.allDaySortComparator=e.allDaySortComparator,r=!0),void 0!==e.timeZone){const t=null!==(n=Y(e.timeZone))&&void 0!==n?n:Intl.DateTimeFormat().resolvedOptions().timeZone;t!==this.state.timeZone&&(this.state.timeZone=t,r=!0)}if(void 0!==e.views){const t=new Map(this.state.views);let n=!1;e.views.forEach(e=>{const r=t.get(e.type);r&&Ee(e.config,r.config)||(t.set(e.type,e),n=!0)}),n&&(this.state.views=t,r=!0)}if(void 0!==e.calendars){let t=!1;for(const n of e.calendars){const e=this.calendarRegistry.get(n.id);e&&e.source!==n.source&&(this.calendarRegistry.updateCalendar(n.id,{source:n.source}),t=!0)}t&&(r=!0)}r&&this.triggerRender()};const s=null!==(r=Y(n.timeZone))&&void 0!==r?r:Intl.DateTimeFormat().resolvedOptions().timeZone,d=(()=>{const e=t.Temporal.Now.plainDateISO(s);return new Date(e.year,e.month-1,e.day)})();var c;this.state={currentView:n.defaultView||exports.ViewType.WEEK,currentDate:n.initialDate||d,events:n.events||[],switcherMode:n.switcherMode||"buttons",plugins:new Map,views:new Map,locale:Me.resolveLocale(n.locale),highlightedEventId:null,selectedEventId:null,readOnly:n.readOnly||!1,overrides:[],allDaySortComparator:n.allDaySortComparator,timeZone:s},this.callbacks=n.callbacks||{},this.themeChangeListeners=new Set,this.listeners=new Set,this.calendarRegistry=new M(n.calendars,n.defaultCalendar,(null===(a=n.theme)||void 0===a?void 0:a.mode)||"light"),c=this.calendarRegistry,N=c,this.eventManager=new Te(this.state,this.calendarRegistry,()=>this.callbacks,this.notify,this.triggerRender,n.events||[]),this.navigation=new ke(this.state,()=>this.callbacks,this.notify,this.state.currentDate),this.pluginManager=new Se(this.state,this.notify),this.useEventDetailDialog=null!==(o=n.useEventDetailDialog)&&void 0!==o&&o,this.useCalendarHeader=null===(i=n.useCalendarHeader)||void 0===i||i,this.customMobileEventRenderer=n.customMobileEventRenderer,n.views.forEach(e=>this.state.views.set(e.type,e)),null===(l=n.plugins)||void 0===l||l.forEach(e=>this.pluginManager.install(e,this)),this.handleVisibleRangeChange("initial")}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"}get timeZone(){return this.state.timeZone}}var Ne=0;function Ie(e,t,r,a,o,i){t||(t={});var l,s,d=t;if("ref"in d)for(s in d={},t)"ref"==s?l=t[s]:d[s]=t[s];var c={type:e,props:d,key:r,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Ne,__i:-1,__u:0,__source:o,__self:i};if("function"==typeof e&&(l=e.defaultProps))for(s in l)void 0===d[s]&&(d[s]=l[s]);return n.options.vnode&&n.options.vnode(c),c}const Re=e=>{if(!e)return"";let n,r,a;e instanceof Date?(a=e.getFullYear(),r=e.getMonth()+1,n=e.getDate()):m(e)?(a=e.year,r=e.month,n=e.day):(!function(e){if(!e||"object"!=typeof e)return!1;if(e instanceof Date)return!1;const n=e;t.Temporal.ZonedDateTime}(e),a=e.year,r=e.month,n=e.day);const o=String(r).padStart(2,"0");return`${String(n).padStart(2,"0")}/${o}/${a}`},Oe=/(YYYY|YY|MM|DD|HH|mm)/g,He=e=>e.toString().padStart(2,"0"),Ae=(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`)},Pe=e=>e.replaceAll(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),Le=e=>{let t,n=0,r="^";for(;null!==(t=Oe.exec(e));){r+=Pe(e.slice(n,t.index));const a=t[0];r+=`(?<${a}>\\d{${"YYYY"===a?4:2}})`,n=t.index+a.length}return r+=Pe(e.slice(n))+"$",new RegExp(r)},$e=(e,n,r,a)=>{const o=e.trim();if(!o)return null;const i=o.match(n),l=null==i?void 0:i.groups;if(!l)return null;const s=l.YYYY?Number(l.YYYY):l.YY?Number(l.YY)+2e3:r.year,d=l.MM?Number(l.MM):r.month,c=l.DD?Number(l.DD):r.day,u=l.HH?Number(l.HH):r.hour,h=l.mm?Number(l.mm):r.minute;try{return t.Temporal.ZonedDateTime.from({timeZone:a,year:s,month:d,day:c,hour:u,minute:h,second:r.second,millisecond:r.millisecond,microsecond:r.microsecond,nanosecond:r.nanosecond})}catch(e){return null}},je=e=>{const n=e;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:t.Temporal.Now.timeZoneId()},Ye=(e,n,r)=>{var a,o,i,l,s,d,c,u,h,g,m,f,p,v,y,b,x,w,D,E,C,T,k,S;if(!e){const e=null!=n?n:r?je(r):t.Temporal.Now.timeZoneId();return null!=r?r:t.Temporal.Now.zonedDateTimeISO(e)}if(F(e)){const r=null!=n?n:t.Temporal.Now.timeZoneId(),a=`${e.year}-${He(e.month)}-${He(e.day)}T00:00:00[${r}]`;return t.Temporal.ZonedDateTime.from(a)}const M=e;if("hour"in M&&!("timeZoneId"in M)){const r=null!=n?n:t.Temporal.Now.timeZoneId();if("function"==typeof M.toZonedDateTime)try{return e.toZonedDateTime(r)}catch(e){}return t.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!==(i=M.microsecond)&&void 0!==i?i:0,nanosecond:null!==(l=M.nanosecond)&&void 0!==l?l:0})}try{return t.Temporal.ZonedDateTime.from(e)}catch(e){const a=M,o=null!==(h=null!==(u=null!==(c=null!==(d="string"==typeof(null==a?void 0:a.timeZone)?a.timeZone:null===(s=null==a?void 0:a.timeZone)||void 0===s?void 0:s.id)&&void 0!==d?d:null==a?void 0:a.timeZoneId)&&void 0!==c?c:n)&&void 0!==u?u:r?je(r):void 0)&&void 0!==h?h:t.Temporal.Now.timeZoneId();if("function"==typeof(null==a?void 0:a.toZonedDateTime))try{return a.toZonedDateTime({timeZone:o})}catch(e){}const i=null!=r?r:t.Temporal.Now.zonedDateTimeISO(o);return t.Temporal.ZonedDateTime.from({timeZone:o,year:null!==(g=null==a?void 0:a.year)&&void 0!==g?g:i.year,month:null!==(m=null==a?void 0:a.month)&&void 0!==m?m:i.month,day:null!==(f=null==a?void 0:a.day)&&void 0!==f?f:i.day,hour:null!==(v=null!==(p=null==a?void 0:a.hour)&&void 0!==p?p: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})}},Fe=(e,t,n)=>{const r=Ae(t,n),a={YYYY:e.year.toString(),YY:He(e.year%100),MM:He(e.month),DD:He(e.day),HH:He(e.hour),mm:He(e.minute)};return r.replace(Oe,e=>{var t;return null!==(t=a[e])&&void 0!==t?t:e})};let Ve=null;function Ze(){if("undefined"==typeof document)return!1;if(null!==Ve)return Ve;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(),Ve=r,r}const _e=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 ze(e,n=!1){if(e instanceof t.Temporal.PlainDate||e instanceof t.Temporal.PlainDateTime)return e;if(e instanceof Date)return n?W(e):B(e);throw new Error("Invalid time type: "+typeof e)}function Ue(e,n){if(e instanceof t.Temporal.ZonedDateTime)return e;if(e instanceof Date)return G(e,n);throw new Error("Invalid time type: "+typeof e)}function We(e){var t;const n=ze(e.start,e.allDay),r=ze(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 Be(e){const t=Ue(e.start,e.timeZone),n=Ue(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 Ge=e=>{try{return e instanceof Date?e:"string"==typeof e?new Date(e):v(e)}catch(e){return new Date}},Ke=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},qe=(e,t,n,r)=>{const a=e.getTime()-t.getTime(),o=Math.round(a/864e5);let i="",l="text-gray-500 dark:text-gray-400";if(0===o)i=r("today")||"Today",l="df-text-primary";else if(1===o||2===o)try{const e=new Intl.RelativeTimeFormat(n,{numeric:"auto"}).format(o,"day");i=e.charAt(0).toUpperCase()+e.slice(1),l="text-black dark:text-white"}catch(t){i=e.toLocaleDateString(n,{weekday:"long"})}else i=e.toLocaleDateString(n,{year:"numeric",month:"long",day:"numeric",weekday:"long"});return{title:i,colorClass:l}},Xe=(e,t)=>{const n=new Map;e.forEach(e=>{var t;const r=Ge(e.start),a=Ke(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 Qe(e){return String(e).padStart(2,"0")}function et(e,n,r){const a=e.trim(),o=/^(\d{4})(\d{2})(\d{2})$/,i=/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z$/;if("DATE"===(null==n?void 0:n.value)||o.test(a)){const e=a.match(o);if(e)return t.Temporal.PlainDate.from({year:Number.parseInt(e[1],10),month:Number.parseInt(e[2],10),day:Number.parseInt(e[3],10)})}if(i.test(a)){const e=a.match(i);if(e){const n=t.Temporal.Instant.from(`${e[1]}-${e[2]}-${e[3]}T${e[4]}:${e[5]}:${e[6]}Z`),a=r||t.Temporal.Now.timeZoneId();return n.toZonedDateTimeISO(a)}}const l=a.match(/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})$/);if(l){const e={year:Number.parseInt(l[1],10),month:Number.parseInt(l[2],10),day:Number.parseInt(l[3],10),hour:Number.parseInt(l[4],10),minute:Number.parseInt(l[5],10),second:Number.parseInt(l[6],10)};return(null==n?void 0:n.tzid)?t.Temporal.ZonedDateTime.from(Object.assign(Object.assign({},e),{timeZone:n.tzid})):t.Temporal.PlainDateTime.from(e)}throw new Error(`Invalid ICS date format: ${e}`)}function tt(e,t=!1){if(t||F(e)){const t=F(e)?e:e.toPlainDate();return{value:`${t.year}${Qe(t.month)}${Qe(t.day)}`,params:{VALUE:"DATE"}}}if(Z(e)){const t=e.toInstant().toZonedDateTimeISO("UTC");return{value:`${t.year}${Qe(t.month)}${Qe(t.day)}T${Qe(t.hour)}${Qe(t.minute)}${Qe(t.second)}Z`}}if(V(e))return{value:`${e.year}${Qe(e.month)}${Qe(e.day)}T${Qe(e.hour)}${Qe(e.minute)}${Qe(e.second)}`};throw new Error("Unsupported Temporal type")}function nt(e){return`${e.getUTCFullYear()}${Qe(e.getUTCMonth()+1)}${Qe(e.getUTCDate())}T${Qe(e.getUTCHours())}${Qe(e.getUTCMinutes())}${Qe(e.getUTCSeconds())}Z`}function rt(e){return e?e.replaceAll("\\","\\\\").replaceAll(";","\\;").replaceAll(",","\\,").replaceAll("\n","\\n"):""}function at(e){return e?e.replaceAll("\\,",",").replaceAll("\\;",";").replaceAll(/\\[nN]/g,"\n").replaceAll("\\\\","\\"):""}function ot(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 it(e,t,n){let r=e;return n&&Object.entries(n).forEach(([e,t])=>{r+=`;${e}=${t}`}),r+=`:${t}`,ot(r)}function lt(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:${nt(new Date)}`);const i=tt(e.start,e.allDay);let l;if(e.allDay){const t=(F(e.end)?e.end:e.end.toPlainDate()).add({days:1});l={value:`${t.year}${Qe(t.month)}${Qe(t.day)}`,params:{VALUE:"DATE"}}}else l=tt(e.end,!1);if(a.push(it("DTSTART",i.value,i.params)),a.push(it("DTEND",l.value,l.params)),a.push(it("SUMMARY",rt(e.title))),e.description&&a.push(it("DESCRIPTION",rt(e.description))),(null===(n=e.meta)||void 0===n?void 0:n.location)&&a.push(it("LOCATION",rt(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(rt).join(",");a.push(it("CATEGORIES",t))}return a.push("END:VEVENT"),a}function st(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 dt(e){const t={};for(const n of e){const e=n.indexOf(":");if(-1===e)continue;const r=n.slice(0,e),a=n.slice(e+1),[o,...i]=r.split(";"),l=o.trim().toUpperCase(),s={};switch(i.forEach(e=>{const[t,n]=e.split("=");t&&n&&(s[t.trim().toUpperCase()]=n.trim())}),l){case"UID":t.uid=a.trim();break;case"SUMMARY":t.summary=at(a);break;case"DESCRIPTION":t.description=at(a);break;case"LOCATION":t.location=at(a);break;case"DTSTART":t.dtstart=a.trim(),t.dtstartParams={value:s.VALUE,tzid:s.TZID};break;case"DTEND":t.dtend=a.trim(),t.dtendParams={value:s.VALUE,tzid:s.TZID};break;case"CATEGORIES":t.categories=a.split(",").map(e=>at(e.trim()))}}if(!t.dtstart)throw new Error("Missing DTSTART in VEVENT");return t.uid||(t.uid=De()),t}function ct(e,n){var r;const{calendarId:a="default",generateNewIds:o=!0,idPrefix:i="ics-",defaultTimeZone:l}=n,s=o?`${i}${De()}`:e.uid,d=et(e.dtstart,e.dtstartParams,l);let c;c=e.dtend?et(e.dtend,e.dtendParams,l):F(d)?d.add({days:1}):d.add({hours:1});const u="DATE"===(null===(r=e.dtstartParams)||void 0===r?void 0:r.value)||F(d),h=l||t.Temporal.Now.timeZoneId();let g,m;if(F(d))g=d;else if(V(d))try{g=d.toZonedDateTime(h)}catch(e){g=t.Temporal.ZonedDateTime.from(Object.assign(Object.assign({},d),{timeZone:h}))}else g=d;if(F(c))m=c.subtract({days:1});else if(V(c))try{m=c.toZonedDateTime(h)}catch(e){m=t.Temporal.ZonedDateTime.from(Object.assign(Object.assign({},c),{timeZone:h}))}else m=c;return{id:s,calendarId:a,title:e.summary||"(No Title)",description:e.description,start:g,end:m,allDay:u,meta:{location:e.location,originalUid:e.uid,categories:e.categories}}}function ut(e,t={}){const n={success:!1,events:[],errors:[],totalParsed:0,totalImported:0};try{const r=e.replaceAll(/(\r\n|\n|\r)[ \t]/g,""),a=st(r.split(/\r\n|\n|\r/));n.totalParsed=a.length,a.forEach((e,r)=>{try{const r=ct(dt(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 ht(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:${rt(n)}`];return e.forEach(e=>{a.push(...lt(e))}),a.push("END:VCALENDAR"),a.join("\r\n")}const gt=e=>{const t=v(e.start);t.setHours(0,0,0,0);const n=v(e.end);return n.setHours(0,0,0,0),{startDay:t,endDay:n,isMultiDay:n.getTime()>t.getTime()}},mt=(e,t,n)=>{const r=gt(e),a=gt(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()},ft=(e,t)=>{const n=new Map;return e.forEach(e=>{const{isMultiDay:t,startDay:r}=gt(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,i,l,s,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!==(i=null==c?void 0:c.hasMultiDay)&&void 0!==i&&i&&null!==(l=null==u?void 0:u.hasMultiDay)&&void 0!==l&&l&&e.calendarId!==r.calendarId){const e=(null!==(s=null==c?void 0:c.earliestMultiDayStart)&&void 0!==s?s: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,mt(e,r,t)}};let pt=null;const vt=()=>{const[e,t]=a.useState(()=>pt||{weekHeight:u.WEEK_HEIGHT,screenSize:"desktop",weeksPerView:6});return a.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};pt=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},yt=n.createContext({locale:"en-US",t:e=>e,getWeekDaysLabels:()=>[],getMonthLabels:()=>[],isDefault:!0});function bt(){return a.useContext(yt)}const xt="df-month-view h-full flex flex-col select-none",wt="p-2 flex justify-between",Dt="text-2xl font-bold text-gray-900 dark:text-gray-100",Et="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",Tt="df-scrollbar-hide",kt="df-time-slot relative h-[4.5rem] flex",St="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",Nt="df-current-time-line absolute left-0 top-0 w-full flex pointer-events-none",It="df-current-time-label ml-2 df-fill-primary text-xs font-bold px-1.5 rounded-sm",Rt="df-all-day-row flex items-center border-b",Ot="rounded-xl my-0.5",Ht="rounded-sm",At="df-event-title font-medium text-xs truncate pr-1",Pt="df-month-event-color-bar inline-block w-0.75 h-3 mr-1 shrink-0 rounded-full",Lt="h-3 w-3 mr-1",$t="resize-handle absolute left-0 top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20",jt="resize-handle absolute right-0 top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20",Yt="df-fill-primary rounded-full",Ft="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",Vt="h-4 w-4 transition-transform group-hover:scale-110",Zt="df-event-detail-panel df-portal fixed shadow-lg border rounded-lg",_t="df-portal 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",zt="df-time-grid-boundary h-3 border-t relative",Ut="absolute top-0 -translate-y-1/2 text-[12px] text-gray-500 dark:text-gray-400",Wt="flex h-7 w-7 items-center justify-center rounded hover:bg-gray-100 dark:hover:bg-slate-800 transition-colors",Bt="text-gray-500 dark:text-gray-400",Gt="text-gray-600 dark:text-gray-300",Kt="text-xs",qt="text-sm",Xt="flex flex-col",Jt="mr-1",Qt=(...e)=>e.filter(Boolean).join(" "),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:"m15 18-6-6 6-6"})}),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:"m9 18 6-6-6-6"})}),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:"m11 17-5-5 5-5"}),Ie("path",{d:"m18 17-5-5 5-5"})]}),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:"m6 17 5-5-5-5"}),Ie("path",{d:"m13 17 5-5-5-5"})]}),an=({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"})}),on=({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"})]}),ln=({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"})]}),sn=({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"})}),dn=({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"})]}),cn=({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"})]}),un=({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"})]}),hn=({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"})]}),gn=({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"})}),mn=({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"})]}),fn=({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"})}),pn=({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"})]}),vn=({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"})}),yn=({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 bn(e,t){var n,r,a,o,i;try{if("today"===e){return null!==(r=null===(n=new Intl.RelativeTimeFormat(t,{numeric:"auto"}).formatToParts(0,"day").find(e=>"literal"===e.type))||void 0===n?void 0:n.value)&&void 0!==r?r:null}if("week"===e){return null!==(o=null===(a=new Intl.RelativeTimeFormat(t,{numeric:"always"}).formatToParts(1,"week").find(e=>"unit"===e.type))||void 0===a?void 0:a.value)&&void 0!==o?o:null}return null!==(i=new Intl.DisplayNames(t,{type:"dateTimeField"}).of(e))&&void 0!==i?i:null}catch(e){return null}}function xn(e){return e.charAt(0).toUpperCase()+e.slice(1)}const wn=(e,t="short",n=1)=>{const r=[],a=new Date(2024,0,7);for(let o=0;o<7;o++){const i=new Date(a);i.setDate(a.getDate()+n+o);try{r.push(i.toLocaleDateString(e,{weekday:t}))}catch(e){r.push(i.toLocaleDateString("en-US",{weekday:t}))}}return r},Dn=(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 En(e,t="en-US"){var n;if(["today","day","week","month","year"].includes(e)){const n=bn(e,t);if(n)return xn(n)}const r=s(t),a=l[r],o=null===(n=null==a?void 0:a.messages)||void 0===n?void 0:n[e];if(o)return o;const i=l.en.messages;return(null==i?void 0:i[e])||e}const Cn=({locale:e="en-US",messages:t,children:n})=>{const r=a.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=a.useMemo(()=>{const e=r.code;return{locale:e,t:(n,a)=>{var o,i,l;let s=null!==(l=null!==(o=null==t?void 0:t[n])&&void 0!==o?o:null===(i=r.messages)||void 0===i?void 0:i[n])&&void 0!==l?l:En(n,e);return a&&Object.entries(a).forEach(([e,t])=>{s=s.replaceAll(new RegExp(`{${e}}`,"g"),t)}),s},getWeekDaysLabels:wn,getMonthLabels:Dn,isDefault:!1}},[r,t]);return Ie(yt.Provider,{value:o,children:n})},Tn=(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(" ")},kn=({calendar:e,mode:t="buttons"})=>{const[n,r]=a.useState(!1),o=a.useRef(null),{t:i}=bt(),l=Array.from(e.state.views.keys()),s=e.state.currentView;return a.useEffect(()=>{const e=e=>{o.current&&!o.current.contains(e.target)&&r(!1)};if(n)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[n]),l.length<=1?null:Ie("div","select"===t?{className:"relative inline-block",ref:o,children:[Ie("button",{type:"button",onClick:()=>r(!n),className:"flex h-7 min-w-30 items-center justify-between gap-2 rounded-lg border border-gray-200 bg-white px-3 text-sm font-medium shadow-sm transition-all duration-200 hover:bg-gray-50 focus:outline-none dark:border-gray-600 dark:bg-gray-800 dark:hover:bg-gray-700","aria-expanded":n,"aria-haspopup":"listbox",children:[Ie("span",{className:"text-gray-900 dark:text-gray-100",children:Tn(s,e,i)}),Ie("span",{className:`${Bt} transition-transform duration-200 ${n?"rotate-180":""}`,children:Ie(an,{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:l.map(t=>Ie("button",{type:"button",onClick:()=>{e.changeView(t),r(!1),e.triggerRender()},className:"w-full rounded px-3 py-0.5 text-left text-sm transition-colors duration-150 focus:outline-none "+(s===t?"df-tint-primary font-medium":"text-gray-700 hover:bg-gray-50 dark:text-gray-300 dark:hover:bg-gray-700"),role:"option","aria-selected":s===t,children:Tn(t,e,i)},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:"inline-flex h-7 items-center gap-1 rounded-lg bg-gray-100 p-0.5 dark:bg-gray-800",children:l.map(t=>Ie("button",{type:"button",className:"h-6 rounded-md px-4 text-sm font-medium transition-all duration-200 focus:outline-none "+(s===t?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-gray-100":"text-gray-600 hover:bg-gray-50 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-100"),onClick:()=>{e.changeView(t),e.triggerRender()},children:Tn(t,e,i)},t))})},Sn=({calendar:e,switcherMode:t="buttons",onAddCalendar:n,onSearchChange:r,onSearchClick:o,searchValue:i="",isSearchOpen:l=!1,isEditable:s=!0,safeAreaLeft:d})=>{const c="buttons"===t,u=e.state.currentView===exports.ViewType.DAY,{screenSize:h}=vt(),g="mobile"===h,{t:m}=bt(),f=a.useCallback(e=>{const t=e.currentTarget.value;t!==i&&(null==r||r(t))},[r,i]);return Ie("div",{className:"df-header flex shrink-0 items-center justify-between border-b py-1 pr-2 transition-colors duration-200 "+(u||l?"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 flex items-center",children:n&&s&&Ie("button",{type:"button",id:"dayflow-add-event-btn",onClick:n,className:Wt,title:g?m("newEvent")||"New Event":m("createCalendar")||"Add Calendar",children:Ie(on,{className:`h-4 w-4 ${Bt}`})})}),Ie("div",{className:"df-header-mid flex flex-1 items-center justify-center",children:c&&Ie(kn,{mode:t,calendar:e})}),Ie("div",{className:"df-header-right flex items-center justify-end gap-3",children:[!c&&Ie(kn,{mode:t,calendar:e}),Ie("button",{type:"button",onClick:o,className:`md:hidden ${Wt}`,title:m("search")||"Search",children:Ie(ln,{width:16,height:16})}),Ie("div",{className:"df-search-group 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:"df-search-focus-within-primary text-gray-400 transition-colors",children:Ie(ln,{width:16,height:16})})}),Ie("input",{id:"dayflow-search-input",type:"text",placeholder:m("search")||"Search",value:i,onChange:f,className:"pl-9 pr-8 py-1 h-7 text-sm border border-slate-200 dark:border-gray-600 rounded-lg text-gray-900 dark:text-gray-100 placeholder-gray-500 dark:placeholder-gray-400 focus:outline-none focus:ring-1 df-focus-ring transition resize-none w-48"}),i&&Ie("button",{type:"button",onClick:()=>{null==r||r("")},className:"absolute inset-y-0 right-0 flex items-center pr-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",children: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=n.createContext(void 0),Nn=({children:e,initialTheme:t="light",onThemeChange:n})=>{const[r,o]=a.useState(t),[i,l]=a.useState(()=>"undefined"!=typeof window&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),s="auto"===r?i:r;a.useEffect(()=>{o(t)},[t]);const d=a.useCallback(e=>{o(e)},[]);a.useEffect(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-color-scheme: dark)"),t=e=>{const t=e.matches?"dark":"light";l(t)};return e.addEventListener?e.addEventListener("change",t):e.addListener&&e.addListener(t),()=>{e.removeEventListener?e.removeEventListener("change",t):e.removeListener&&e.removeListener(t)}},[]),a.useLayoutEffect(()=>{if("undefined"==typeof document)return;const e=document.documentElement,t=_e(s),n="auto"===r?t:s;e.classList.contains(n)||(e.classList.remove("light","dark"),e.classList.add(n)),"auto"===r?e.dataset.dfThemeOverride&&delete e.dataset.dfThemeOverride:e.dataset.dfThemeOverride!==n&&(e.dataset.dfThemeOverride=n),e.dataset.dfTheme!==n&&(e.dataset.dfTheme=n)},[s,r,i]),a.useEffect(()=>{n&&n(r,s)},[r,s,n]);const c=a.useMemo(()=>({theme:r,effectiveTheme:s,setTheme:d}),[r,s,d]);return Ie(Mn.Provider,{value:c,children:e})},In=()=>{const e=a.useContext(Mn);if(void 0===e)throw new Error("useTheme must be used within a ThemeProvider");return e},Rn=n.createContext(null);let On=0;function Hn({generatorName:e,generatorArgs:t,defaultContent:n,store:r}){const o=a.useRef(null),i=a.useContext(Rn),l=r||i,s=a.useRef(null),[,d]=a.useState(0);s.current||(s.current="df-slot-"+On++),a.useEffect(()=>{if(!o.current||!l||!e)return;const n=s.current;l.register({id:n,containerEl:o.current,generatorName:e,generatorArgs:t});const r=l.subscribe(()=>{d(e=>e+1)});return()=>{l.unregister(n),r()}},[l,e]),a.useEffect(()=>{if(!l||!s.current||!e)return;const n=s.current;l.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==l?void 0:l.isOverridden(e));return Ie("div",{ref:o,className:"df-content-slot "+(c||u?"flex h-full flex-1 flex-col":""),children:!h&&n})}const An=t=>{const n=a.useRef(null),r=a.useRef(null);return a.useEffect(()=>{if(n.current){const a=e.__rest(t,[]);r.current=new o.BlossomColorPicker(n.current,a),a.initialExpanded&&r.current.expand()}return()=>{r.current&&(r.current.destroy(),r.current=null)}},[]),a.useEffect(()=>{if(r.current){const n=e.__rest(t,[]);r.current.setOptions(n)}},[t]),Ie("div",{ref:n,className:t.className})},Pn=({color:e,onChange:t,onClose:n})=>{const r=a.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(An,{defaultValue:r,coreSize:36,petalSize:32,initialExpanded:!0,openOnHover:!1,onChange:e=>t({hex:e.hex},!0),onCollapse:n})})},Ln=t=>{var{children:r,onClick:o,loading:i,loadingText:l,disabled:s,className:d,type:c="button"}=t,u=e.__rest(t,["children","onClick","loading","loadingText","disabled","className","type"]);const[h,g]=a.useState(!1),m=i||h,f=Ie(n.Fragment,{children:[m&&Ie("svg",{className:"mr-2 h-4 w-4 animate-spin",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[Ie("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),Ie("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),Ie("span",{className:"inline-flex items-center",children:m&&l?l:r})]}),p=Object.assign(Object.assign({},u),{disabled:s||m,onClick:t=>e.__awaiter(void 0,void 0,void 0,function*(){if(!m&&o){const e=o(t);if(e&&"object"==typeof e&&"then"in e){g(!0);try{yield e}finally{g(!1)}}}}),className:`relative inline-flex items-center justify-center transition-all ${d} ${m?"cursor-not-allowed opacity-70":""}`});return Ie("button","submit"===c?Object.assign({},p,{type:"submit",children:f}):"reset"===c?Object.assign({},p,{type:"reset",children:f}):Object.assign({},p,{type:"button",children:f}))},$n=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],jn=({onClose:t,onCreate:i,app:l})=>{const{t:s}=bt(),{effectiveTheme:d}=In(),[c,u]=a.useState(""),[h,g]=a.useState(!1),m=l.state.overrides.includes("createCalendarDialogColorPicker"),[f,p]=a.useState($n[Math.floor(Math.random()*$n.length)]),[v,y]=a.useState(!1),[b,x]=a.useState(""),w=a.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}},[]),[D,E]=a.useState(null),C=e=>{p(e.hex)},T=()=>{y(!1)},k=()=>{p(b),y(!1)},S="dark"===d,M={default:{picker:{background:S?"#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:S?"1px solid #4b5563":"1px solid #e5e7eb"},head:{background:S?"#1e293b":"#ffffff",borderBottom:S?"1px solid #4b5563":"1px solid #e5e7eb",boxShadow:"none"},body:{background:S?"#1e293b":"#ffffff"},controls:{border:S?"1px solid #4b5563":"1px solid #e5e7eb"},input:{background:S?"#374151":"#ffffff",color:S?"#f3f4f6":"#1f2937",border:S?"1px solid #4b5563":"1px solid #e5e7eb",boxShadow:"none"},previews:{border:S?"1px solid #4b5563":"1px solid #e5e7eb"},actions:{borderTop:S?"1px solid #4b5563":"1px solid #e5e7eb"}}};return"undefined"==typeof window?null:r.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 "+(m?"mb-4":"mb-6"),children:s("createCalendar")}),Ie("form",{onSubmit:n=>e.__awaiter(void 0,void 0,void 0,function*(){var e;if(n.preventDefault(),c.trim()&&!h){g(!0);try{let n;n=m?f:null!==(e=null==D?void 0:D.hex)&&void 0!==e?e:o.hslToHex(w.hue,w.saturation,w.lightness);const{colors:r,darkColors:a}=R(n),l={id:De(),name:c.trim(),colors:r,darkColors:a,isVisible:!0,isDefault:!1};yield i(l),t()}finally{g(!1)}}}),children:[m?Ie(n.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:f}}),Ie("input",{id:"custom-calendar-name",name:"calendar-name",type:"text",value:c,onChange:e=>u(e.target.value),className:"df-focus-ring w-full flex-1 rounded-lg border border-slate-200 px-3 py-1.5 text-sm text-gray-900 shadow-sm transition focus:ring-2 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:$n.map(e=>Ie("button",{type:"button",className:"df-focus-ring-only h-7 w-7 rounded-full border border-gray-200 transition-transform hover:scale-110 focus:ring-2 focus:ring-offset-2 focus:outline-none dark:border-gray-600 dark:focus:ring-offset-slate-800 "+(f===e?"df-ring-primary-solid scale-110 ring-2 ring-offset-2 dark:ring-offset-slate-800":""),style:{backgroundColor:e},onClick:()=>p(e)},e))}),Ie("div",{className:"relative",children:[Ie("button",{type:"button",onClick:()=>{x(f),y(!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")}),v&&Ie("div",{className:"fixed inset-0 z-10001 flex items-center justify-center bg-black/40 backdrop-blur-sm",onClick:k,children:Ie("div",{className:"df-animate-in df-fade-in df-zoom-in-95 relative",onClick:e=>e.stopPropagation(),children:Ie(Hn,{generatorName:"createCalendarDialogColorPicker",generatorArgs:{color:f,onChange:C,onAccept:T,onCancel:k,styles:M},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(Pn,{color:f,onChange:C}),Ie("div",{className:"mt-4 flex justify-end gap-2 border-t pt-3 dark:border-slate-700",children:[Ie("button",{type:"button",onClick:k,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:T,className:"df-fill-primary rounded-md px-3 py-1.5 text-xs font-medium 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:c,onChange:e=>u(e.target.value),className:"df-focus-ring w-full rounded-lg border border-slate-200 px-3 py-1.5 text-sm text-gray-900 shadow-sm transition focus:ring-2 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(An,{defaultValue:w,coreSize:36,petalSize:32,openOnHover:!1,onChange:e=>E(e),onCollapse:e=>E(e),className:"z-50"})})})]}),Ie("div",{className:"flex justify-end space-x-2",children:[Ie("button",{type:"button",onClick:t,disabled:h,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(Ln,{type:"submit",disabled:!c.trim(),loading:h,className:"df-fill-primary df-hover-primary-solid rounded px-2 py-1 text-xs font-medium transition disabled:opacity-50",children:s("create")})]})]})]})}),document.body)},Yn=(e,n)=>t.Temporal.PlainDate.compare(e,n),Fn=({calendarDays:e,visibleMonth:t,startDate:r,endDate:a,weekDayLabels:o,disabled:i,onDaySelect:l})=>Ie(n.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 n=e.month!==t.month,o=0===Yn(e,r),s=0===Yn(e,a),d=Yn(e,r)>=0&&Yn(e,a)<=0;return Ie("button",{type:"button",disabled:i,onClick:()=>l(e),className:`flex h-9 w-9 items-center justify-center rounded-md text-sm transition ${o||s?"df-fill-primary font-semibold":d?"df-tint-primary":n?"text-slate-300 dark:text-gray-600":"text-slate-700 dark:text-gray-300 df-hover-primary"}`,children:e.day},e.toString())})})]}),Vn=({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(nn,{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(en,{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(tn,{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(rn,{width:14,height:12})})]})]}),Zn=Array.from({length:24},(e,t)=>t),_n=Array.from({length:60},(e,t)=>t),zn=({focusedField:e,draftRange:t,disabled:n,onHourSelect:r,onMinuteSelect:a,timeListRefs:o})=>{const i=e,l=t["start"===i?0:1],s=l.minute,d=_n.includes(s)?_n:[..._n,s].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:[l.hour.toString().padStart(2,"0"),":",l.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 ${Tt} rounded-md border border-slate-100 bg-white dark:border-gray-600 dark:bg-gray-700`,role:"listbox","aria-label":"Hour",ref:e=>{o.current&&o.current[i]&&(o.current[i].hour=e)},children:Zn.map(e=>{const t=e===l.hour;return Ie("button",{type:"button",role:"option","aria-selected":t,disabled:n,onClick:()=>r(i,e),className:"flex h-8 w-full items-center justify-center text-sm transition "+(t?"df-fill-primary font-semibold":"df-hover-primary text-slate-600 dark:text-gray-300"),"data-active":t?"true":void 0,children:He(e)},e)})})}),Ie("div",{className:"w-14",children:Ie("div",{className:`h-72 overflow-y-auto ${Tt} rounded-md border border-slate-100 bg-white dark:border-gray-600 dark:bg-gray-700`,role:"listbox","aria-label":"Minute",ref:e=>{o.current&&o.current[i]&&(o.current[i].minute=e)},children:d.map(e=>{const t=e===s;return Ie("button",{type:"button",role:"option","aria-selected":t,disabled:n,onClick:()=>a(i,e),className:"flex h-8 w-full items-center justify-center text-sm transition "+(t?"df-fill-primary font-semibold":"df-hover-primary text-slate-600 dark:text-gray-300"),"data-active":t?"true":void 0,children:He(e)},e)})})})]})]})},Un=({visibleMonth:e,monthLabels:t,weekDayLabels:n,calendarDays:r,draftRange:a,focusedField:o,isTimeEnabled:i,disabled:l,matchTriggerWidth:s,popupRef:d,timeListRefs:c,onMonthChange:u,onYearChange:h,onDaySelect:g,onHourSelect:m,onMinuteSelect:f,onOk:p,getPopupStyle:v})=>{const y=a[0].toPlainDate(),b=a[1].toPlainDate();return Ie("div",{ref:d,className:"df-range-picker",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:s?"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(Vn,{visibleMonth:e,monthLabels:t,disabled:l,onMonthChange:u,onYearChange:h}),Ie(Fn,{calendarDays:r,visibleMonth:e,startDate:y,endDate:b,weekDayLabels:n,disabled:l,onDaySelect:g})]}),i&&Ie("div",{className:"flex flex-1 justify-end sm:w-32",children:Ie(zn,{focusedField:o,draftRange:a,disabled:l,onHourSelect:m,onMinuteSelect:f,timeListRefs:c})})]}),Ie("div",{className:"flex justify-end",children:Ie("button",{type:"button",onClick:p,disabled:l,className:"df-fill-primary df-hover-primary-solid inline-flex items-center rounded-full px-4 py-1.5 text-sm font-semibold shadow-sm transition disabled:cursor-not-allowed disabled:opacity-50",children:"OK"})})]})})},Wn=({value:e,format:n="YYYY-MM-DD HH:mm",showTimeFormat:o="HH:mm",showTime:i=!0,onChange:l,onOk:s,timeZone:d,disabled:c=!1,placement:u="bottomLeft",autoAdjustOverflow:h=!0,getPopupContainer:g,matchTriggerWidth:f=!1,locale:p="en-US"})=>{const v=a.useMemo(()=>"string"==typeof p?p:(null==p?void 0:p.code)||"en-US",[p]),y=a.useMemo(()=>void 0===i||("object"==typeof i||Boolean(i)),[i]),b=a.useMemo(()=>Dn(v,"short"),[v]),x=a.useMemo(()=>wn(v,"narrow"),[v]),w=a.useMemo(()=>y?"object"==typeof i&&(null==i?void 0:i.format)?i.format:o:"",[y,i,o]),D=a.useMemo(()=>Ae(n,w),[n,w]),E=a.useMemo(()=>Le(D),[D]),C=a.useMemo(()=>{const n=null!=d?d:m(e[0])?m(e[1])?t.Temporal.Now.timeZoneId():je(e[1]):je(e[0]),r=Ye(e[0],n).withTimeZone(n);return[r,Ye(e[1],n,r).withTimeZone(n)]},[e,d]),[T,k]=a.useState(C),S=a.useRef(C),[M,N]=a.useState("start"),[I,R]=a.useState([Fe(C[0],n,w),Fe(C[1],n,w)]),O=a.useRef([Fe(C[0],n,w),Fe(C[1],n,w)]),H=a.useRef(C),[A,P]=a.useState(C[0].toPlainDate().with({day:1})),[L,$]=a.useState(!1),j=a.useCallback(e=>{$(e)},[]),[Y,F]=a.useState(u),V=a.useRef(u),Z=a.useRef(null),_=a.useRef(null),z=a.useRef({start:{hour:null,minute:null},end:{hour:null,minute:null}}),U=a.useRef(!1),W=a.useRef(!1);a.useEffect(()=>{O.current=I},[I]),a.useEffect(()=>{H.current=T},[T]),a.useEffect(()=>{const e=S.current,n=0!==t.Temporal.ZonedDateTime.compare(e[0],C[0])||e[0].timeZoneId!==C[0].timeZoneId,r=0!==t.Temporal.ZonedDateTime.compare(e[1],C[1])||e[1].timeZoneId!==C[1].timeZoneId;(n||r)&&k(C),S.current=C},[C]),a.useEffect(()=>{P(C[0].toPlainDate().with({day:1}))},[C[0]]);const B=a.useCallback((e,t,n=0)=>{var r;if(!e||!t)return;const a=e.getBoundingClientRect(),o=t.getBoundingClientRect().top-a.top+e.scrollTop-n,i=(null===(r=window.matchMedia)||void 0===r?void 0:r.call(window,"(prefers-reduced-motion: reduce)").matches)?"auto":"smooth";Math.abs(e.scrollTop-o)>1&&e.scrollTo({top:o,behavior:i})},[]),G=a.useCallback(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=z.current[e];["hour","minute"].forEach(e=>{const n=t[e];if(!n)return;const r=n.querySelector('[data-active="true"]');r&&B(n,r,0)})})})},[B]);a.useEffect(()=>{L&&y&&G(M)},[M,L,G,y]);const K=T[0].epochMilliseconds,q=T[0].offsetNanoseconds,X=T[1].epochMilliseconds,J=T[1].offsetNanoseconds;a.useEffect(()=>{if(W.current)return;const[e,t]=H.current,r=Fe(e,n,w),a=Fe(t,n,w),[o,i]=O.current;o===r&&i===a||(O.current=[r,a],R([r,a]))},[K,q,X,J,n,w]),a.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)};return document.addEventListener("pointerdown",e,!0),()=>{document.removeEventListener("pointerdown",e,!0)}},[L]),a.useEffect(()=>{L||(N("start"),U.current||k(C),U.current=!1)},[L,C]);const Q=a.useCallback(e=>{l&&l(e,[Fe(e[0],n,w),Fe(e[1],n,w)])},[w,n,l]),ee=a.useCallback(e=>{s&&s(e,[Fe(e[0],n,w),Fe(e[1],n,w)])},[w,n,s]),te=a.useCallback((e,n)=>{k(r=>{const a=[...r];if("start"===e){const e=Ye(a[1],je(n),n),r=t.Temporal.ZonedDateTime.compare(n,e)>0?n:e;return[n,r]}const o=Ye(a[0],je(n),n);return[t.Temporal.ZonedDateTime.compare(o,n)>0?n:o,n]})},[]),ne=e=>{if(c)return;const n=(e,n)=>{var r,a,o,i;const l=je(e);return t.Temporal.ZonedDateTime.from({timeZone:l,year:n.year,month:n.month,day:n.day,hour:e.hour,minute:e.minute,second:null!==(r=e.second)&&void 0!==r?r:0,millisecond:null!==(a=e.millisecond)&&void 0!==a?a:0,microsecond:null!==(o=e.microsecond)&&void 0!==o?o:0,nanosecond:null!==(i=e.nanosecond)&&void 0!==i?i:0})};if("start"===M){const t=n(T[0],e),r=T[1].epochMilliseconds-T[0].epochMilliseconds,a=t.add({milliseconds:r});return void k([t,a])}const r=n(T[1],e),a=T[1].epochMilliseconds-T[0].epochMilliseconds;if(t.Temporal.ZonedDateTime.compare(r,T[0])<0){const t=n(T[0],e),r=t.add({milliseconds:a});return void k([t,r])}const o=[T[0],r];k(o),P(r.toPlainDate().with({day:1}))},re=a.useCallback((e,n)=>{if(c)return;const r="start"===e?0:1;k(a=>{const o=a[r],i=o.with({hour:n,minute:o.minute,second:0,millisecond:0,microsecond:0,nanosecond:0});if("start"===e){const e=Ye(a[1],je(i),i);return[i,t.Temporal.ZonedDateTime.compare(i,e)>0?i:e]}const l=Ye(a[0],je(i),i);return[t.Temporal.ZonedDateTime.compare(l,i)>0?i:l,i]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=z.current[e].hour;if(!t)return;const n=t.querySelector('[data-active="true"]');n&&B(t,n,0)})})},[c]),ae=a.useCallback((e,n)=>{if(c)return;const r="start"===e?0:1;k(a=>{const o=a[r].with({minute:n,second:0,millisecond:0,microsecond:0,nanosecond:0});if("start"===e){const e=Ye(a[1],je(o),o);return[o,t.Temporal.ZonedDateTime.compare(o,e)>0?o:e]}const i=Ye(a[0],je(o),o);return[t.Temporal.ZonedDateTime.compare(i,o)>0?o:i,o]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=z.current[e].minute;if(!t)return;const n=t.querySelector('[data-active="true"]');n&&B(t,n,0)})})},[c]),oe=a.useCallback((e,t)=>{const n="start"===e?0:1;R(e=>{const r=[...e];return r[n]=t,r})},[]),ie=a.useCallback((e,t)=>{const r="start"===e?0:1,a=T[r],o=je(a),i=$e(t,E,a,o);if(i){te(e,i);const t=i.toPlainDate().with({day:1});return P(t),"start"===e&&N("end"),!0}return R(e=>{const t=[...e];return t[r]=Fe(T[r],n,w),t}),!1},[T,w,n,E,te]),le=a.useCallback(e=>t=>{const n=t.currentTarget.value;W.current=!0,oe(e,n);const r="start"===e?0:1,a=H.current[r],o=je(a),i=$e(n,E,a,o);if(i){te(e,i);const t=i.toPlainDate().with({day:1});P(t),G(e)}},[oe,E,te,G]),se=a.useCallback(e=>t=>{var r;if(c)return;if(W.current=!1,L){const t="start"===e?0:1,r=Fe(H.current[t],n,w);return void R(e=>{const n=[...e];return n[t]=r,n})}const a=t.relatedTarget;a&&(null===(r=Z.current)||void 0===r?void 0:r.contains(a))||ie(e,t.currentTarget.value)},[ie,c,L,n,w]),de=a.useCallback(e=>t=>{"Enter"===t.key&&(t.preventDefault(),W.current=!1,ie(e,t.currentTarget.value)),"Escape"===t.key&&t.currentTarget.blur()},[ie]),ce=()=>{U.current=!0,Q(T),ee(T),j(!1)},ue=e=>{P(t=>t.add({months:e}).with({day:1}))},he=e=>{P(t=>t.add({years:e}).with({day:1}))},ge=a.useMemo(()=>{const e=A,t=e.dayOfWeek%7,n=e.subtract({days:t});return Array.from({length:42},(e,t)=>n.add({days:t}))},[A]),me=a.useCallback((e=u)=>{if(!h||!Z.current)return e;const t=Z.current.getBoundingClientRect(),n=f?t.width:480,r=window.innerHeight-t.bottom,a=t.top,o=window.innerWidth-t.left,i=t.right;let l=e;return l.startsWith("bottom")&&r<500&&a>r?l=l.replace("bottom","top"):l.startsWith("top")&&a<500&&r>a&&(l=l.replace("top","bottom")),l.endsWith("Left")&&o<n&&i>o?l=l.replace("Left","Right"):l.endsWith("Right")&&i<n&&o>i&&(l=l.replace("Right","Left")),l},[h,f,u]),fe=a.useCallback(()=>{const e=me();V.current!==e&&(V.current=e,F(e))},[me]),pe=e=>{if(c)return;N(e);const t=T["start"===e?0:1].toPlainDate().with({day:1});P(t);const n=me();V.current!==n&&(V.current=n,F(n)),j(!0)};a.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 ve=()=>{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,f&&(t.width=`${e.width}px`),t};return Ie("div",{className:"df-range-picker relative w-full min-w-0",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-white text-slate-400 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-500":L?"df-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:le("start"),onFocus:()=>pe("start"),onClick:()=>pe("start"),onBlur:se("start"),onKeyDown:de("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?"df-text-primary bg-white dark:bg-gray-700":"border-transparent bg-transparent text-slate-700 dark:text-gray-300"),placeholder:D,autoComplete:"off",disabled:c})}),Ie(hn,{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:le("end"),onFocus:()=>pe("end"),onClick:()=>pe("end"),onBlur:se("end"),onKeyDown:de("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?"df-text-primary bg-white dark:bg-gray-700":"border-transparent bg-transparent text-slate-700 dark:text-gray-300"),placeholder:D,autoComplete:"off",disabled:c})})]}),L&&(g?r.createPortal(Ie(Un,{visibleMonth:A,monthLabels:b,weekDayLabels:x,calendarDays:ge,draftRange:T,focusedField:M,isTimeEnabled:!!y,disabled:c,matchTriggerWidth:f,popupRef:_,timeListRefs:z,onMonthChange:ue,onYearChange:he,onDaySelect:ne,onHourSelect:re,onMinuteSelect:ae,onOk:ce,getPopupStyle:ve}),g()):r.createPortal(Ie(Un,{visibleMonth:A,monthLabels:b,weekDayLabels:x,calendarDays:ge,draftRange:T,focusedField:M,isTimeEnabled:!!y,disabled:c,matchTriggerWidth:f,popupRef:_,timeListRefs:z,onMonthChange:ue,onYearChange:he,onDaySelect:ne,onHourSelect:re,onMinuteSelect:ae,onOk:ce,getPopupStyle:ve}),document.body))]})},Bn=({options:e,value:t,onChange:n,registry:o,variant:i="desktop",disabled:l=!1})=>{const[s,d]=a.useState(!1),[c,u]=a.useState({}),h=a.useRef(null),g=a.useRef(null),m=()=>{if(g.current){const e=g.current.getBoundingClientRect(),t="mobile"===i,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)}};a.useEffect(()=>{const e=e=>{!h.current||h.current.contains(e.target)||e.target.closest("[data-calendar-picker-dropdown]")||d(!1)};return s&&(m(),window.addEventListener("mousedown",e),window.addEventListener("scroll",m,!0),window.addEventListener("resize",m)),()=>{window.removeEventListener("mousedown",e),window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",m)}},[s]);const f=e=>(o||I()).resolveColors(e).lineColor,p=(e,t)=>{e.stopPropagation(),n(t),d(!1)},v=e.find(e=>e.value===t),y=()=>s&&"undefined"!=typeof window?"mobile"===i?r.createPortal(Ie("div",{"data-calendar-picker-dropdown":"true",style:c,className:_t,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=>p(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(sn,{className:"df-text-primary h-4 w-4"})}),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:f(e.value)}})]},e.value))}),document.body):r.createPortal(Ie("ul",{"data-calendar-picker-dropdown":"true",style:c,className:"df-portal 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=>p(t,e.value),children:[t===e.value?Ie("span",{className:"df-text-primary mr-2 text-sm",children:Ie(sn,{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:f(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"===i?{className:"relative inline-block",ref:h,children:[Ie("button",{type:"button",ref:g,disabled:l,onClick:e=>{e.stopPropagation(),l||d(!s)},className:"flex items-center space-x-2 rounded-md bg-gray-100 px-3 py-1.5 transition-colors dark:bg-gray-700 "+(l?"cursor-default opacity-50":""),children:[Ie("span",{className:"h-3 w-3 rounded-full",style:{backgroundColor:f(t)}}),Ie("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-200",children:(null==v?void 0:v.label)||t}),Ie(dn,{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(!s)},className:"flex h-8 items-center space-x-2 rounded-md bg-gray-100 px-2 py-1 transition-colors hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",children:[Ie("span",{className:"h-4 w-4 shrink-0 rounded-sm",style:{backgroundColor:f(t)}}),Ie(dn,{className:"h-4 w-4 text-gray-600 dark:text-gray-300"})]}),y()]})},Gn=({event:n,isOpen:o,onEventUpdate:i,onEventDelete:l,onClose:s,app:d})=>{var c,u;const[h,g]=a.useState(n),[f,p]=a.useState(!1),[v,y]=a.useState(!1),b=a.useRef(n.id),{t:x}=bt();a.useEffect(()=>{g(n),b.current!==n.id&&(p(!1),y(!1),b.current=n.id)},[n]);const w=a.useMemo(()=>(d?d.getCalendarRegistry():I()).getVisible().map(e=>({label:e.name,value:e.id})),[d,null==d?void 0:d.getCalendars()]),D=a.useMemo(()=>!xe(n,h),[n,h]),E=a.useMemo(()=>{var e;return null!==(e=null==d?void 0:d.timeZone)&&void 0!==e?e:t.Temporal.Now.timeZoneId()},[d]),C=e=>{const[t,n]=e;g(Object.assign(Object.assign({},h),{start:t.toPlainDate(),end:n.toPlainDate()}))},T=null!==(c=null==d?void 0:d.canMutateFromUI(n.id))&&void 0!==c&&c,k=null==d?void 0:d.getReadOnlyConfig(n.id),S=!1!==(null==k?void 0:k.viewable),M=f||v,N=!a.useMemo(()=>{if(!n.calendarId)return!1;const e=null==d?void 0:d.getCalendarRegistry().get(n.calendarId);return!!(null==e?void 0:e.subscription)},[d,n.calendarId])||""!==(h.description||"").trim();if(!o||!S)return null;if("undefined"==typeof window||"undefined"==typeof document)return null;const R=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,disabled:M,className:"absolute top-4 right-4 text-gray-400 transition hover:text-gray-600 disabled:opacity-50 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:x("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-${h.id}`,name:"title",type:"text",value:h.title,readOnly:!T||M,disabled:!T||M,onChange:e=>{g(Object.assign(Object.assign({},h),{title:e.target.value}))},className:"df-focus-ring w-full rounded-lg border border-slate-200 px-3 py-1.5 text-sm text-gray-900 shadow-sm transition focus:ring-2 focus:outline-none disabled:opacity-50 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100"})}),T&&Ie(Bn,{options:w,value:h.calendarId||"blue",disabled:M,onChange:e=>{g(Object.assign(Object.assign({},h),{calendarId:e}))},registry:null==d?void 0:d.getCalendarRegistry()})]}),h.allDay?Ie("div",{className:"mb-4",children:[Ie("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:x("dateRange")}),Ie(Wn,{value:[h.start,h.end],format:"YYYY-MM-DD",showTime:!1,timeZone:E,matchTriggerWidth:!0,disabled:!T||M,onChange:C,onOk:C,locale:null==d?void 0:d.state.locale})]}):Ie("div",{className:"mb-4",children:[Ie("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:x("timeRange")}),Ie(Wn,{value:[h.start,h.end],timeZone:E,disabled:!T||M,onChange:e=>{const[t,n]=e;g(Object.assign(Object.assign({},h),{start:t,end:n}))},onOk:e=>{const[t,n]=e;g(Object.assign(Object.assign({},h),{start:t,end:n}))},locale:null==d?void 0:d.state.locale})]}),N&&Ie("div",{className:"mb-4",children:[Ie("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:x("note")}),Ie("textarea",{id:`event-dialog-note-${h.id}`,name:"note",value:null!==(u=h.description)&&void 0!==u?u:"",readOnly:!T||M,disabled:!T||M,onChange:e=>g(Object.assign(Object.assign({},h),{description:e.target.value})),rows:4,className:"df-focus-ring w-full resize-none rounded-lg border border-slate-200 px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:ring-2 focus:outline-none disabled:opacity-50 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",placeholder:x("addNotePlaceholder")})]}),T&&Ie("div",{className:"flex space-x-2",children:[h.allDay?Ie("button",{type:"button",disabled:M,className:"df-tint-primary df-hover-primary-md rounded-lg px-3 py-2 text-xs font-medium transition disabled:opacity-50",onClick:()=>{var e;const n=m(h.start)?h.start:h.start.toPlainDate(),r=null!==(e=null==d?void 0:d.timeZone)&&void 0!==e?e:t.Temporal.Now.timeZoneId(),a=t.Temporal.ZonedDateTime.from({year:n.year,month:n.month,day:n.day,hour:9,minute:0,timeZone:r}),o=t.Temporal.ZonedDateTime.from({year:n.year,month:n.month,day:n.day,hour:10,minute:0,timeZone:r});g(Object.assign(Object.assign({},h),{allDay:!1,start:a,end:o}))},children:x("setAsTimed")}):Ie("button",{type:"button",disabled:M,className:"df-tint-primary df-hover-primary-md rounded-lg px-3 py-2 text-xs font-medium transition disabled:opacity-50",onClick:()=>{const e=m(h.start)?h.start:h.start.toPlainDate();g(Object.assign(Object.assign({},h),{allDay:!0,start:e,end:e}))},children:x("setAsAllDay")}),Ie(Ln,{type:"button",disabled:M,className:"df-fill-destructive df-hover-destructive rounded-lg border border-border px-3 py-2 text-xs font-medium transition disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>e.__awaiter(void 0,void 0,void 0,function*(){if(!f&&!v){y(!0);try{yield l(n.id),s()}finally{y(!1)}}}),loading:v,children:x("delete")}),Ie(Ln,{type:"button",className:"df-fill-primary ml-auto rounded-lg px-3 py-2 text-xs font-medium transition "+(D?"df-shadow-primary df-hover-primary-solid shadow-lg":"cursor-not-allowed opacity-50 grayscale-[0.5]"),onClick:()=>e.__awaiter(void 0,void 0,void 0,function*(){if(!f&&!v){p(!0);try{yield i(ie(n,h,null==d?void 0:d.timeZone)),s()}finally{p(!1)}}}),disabled:!D||M,loading:f,children:x("save")})]})]})]})]}),O=document.body;return O?r.createPortal(R,O):null},Kn=e=>e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}),qn=({app:e,anchorRef:t,onClose:n,isOpen:o})=>{const{t:i}=bt(),[l,s]=a.useState(""),[d,c]=a.useState(0),[u,h]=a.useState(!1),g=a.useRef(null),m=a.useRef(null);a.useEffect(()=>{o||h(!1)},[o]),a.useEffect(()=>{o&&(setTimeout(()=>{var e;return null===(e=g.current)||void 0===e?void 0:e.focus()},50),s(""),c(0))},[o]),a.useEffect(()=>{const e=e=>{o&&m.current&&!m.current.contains(e.target)&&t.current&&!t.current.contains(e.target)&&n()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[o,n,t]);const[f,p]=a.useState({top:0,left:0}),[v,y]=a.useState("top"),[b,x]=a.useState(0),w=a.useMemo(()=>ae(e.timeZone),[e.timeZone,o]),D=a.useMemo(()=>{if(!l.trim())return[];const t=[],n=e.getCalendars(),r=e.getAllEvents(),a=l.toLowerCase(),o=r.find(e=>e.title.toLowerCase()===a);let i=null==o?void 0:o.calendarId;if(!i){const e=n.filter(e=>!1!==e.isVisible);if(e.length>0){const t=Math.floor(Math.random()*e.length);i=e[t].id}else n.length>0&&(i=n[0].id)}const s=n.find(e=>e.id===i),d=(null==s?void 0:s.colors.lineColor)||"#3b82f6";t.push({type:"new",title:l,calendarId:i||"",color:d,start:w.start,end:w.end});const c=new Set([l.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},[l,e,w]);a.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,i=window.innerWidth;a<o?a=o:a+r>i-o&&(a=i-r-o);const l=e.left+e.width/2;x(l-a);let s=0,d="top";e.top<n+20?(d="bottom",s=e.bottom+12):(d="top",s=e.top-12-n),y(d),p({top:s,left:a}),h(!0)}},[o,t,D]);const E=t=>{if(!t.calendarId)return;const r=De(),a={id:r,title:t.title,start:G(t.start,e.timeZone),end:G(t.end,e.timeZone),calendarId:t.calendarId,allDay:!1};e.addEvent(a),e.setCurrentDate(t.start),e.highlightEvent(r),n()};return a.useEffect(()=>{if(!o)return;const e=e=>{"ArrowDown"===e.key?(e.preventDefault(),c(e=>(e+1)%D.length)):"ArrowUp"===e.key?(e.preventDefault(),c(e=>(e-1+D.length)%D.length)):"Enter"===e.key&&(e.preventDefault(),D[d]&&E(D[d]))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[o,D,d]),o?r.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:f.top,left:f.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:i("quickCreateEvent")||"Quick Create Event"}),Ie("div",{className:"relative",children:Ie("input",{ref:g,type:"text",className:"df-focus-ring w-full rounded-lg border border-slate-200 px-3 py-1.5 text-sm text-gray-900 shadow-sm transition focus:ring-2 focus:outline-none dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",placeholder:i("quickCreatePlaceholder")||"Enter title (e.g. Code review)",value:l,onChange:e=>s(e.target.value)})})]}),Ie("div",{className:"max-h-75 flex-1 overflow-y-auto px-2 py-1",children:[0===D.length&&l&&Ie("div",{className:"px-4 py-3 text-center text-sm text-gray-400",children:i("noSuggestions")||"Type to create"}),D.map((e,t)=>{return Ie("div",{className:"flex cursor-pointer items-center rounded-lg px-4 py-2 transition-colors "+(t===d?"df-tint-primary df-dark-tint-primary-md df-ring-primary ring-1 ring-inset":"hover:bg-gray-50 dark:hover:bg-slate-700/50"),onClick:()=>E(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?i("today"):i("tomorrow")})}),Ie("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:(n=e.start,r=e.end,`${Kn(n)} - ${Kn(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:b}})]}),document.body):null},Xn=({visibleMonth:e,currentDate:n,showHeader:r=!1,onMonthChange:o,onDateSelect:i,events:l=[],showEventDots:s=!1,calendarRegistry:d,timeZone:c})=>{const{locale:u}=bt(),h=a.useMemo(()=>{const e=c?t.Temporal.Now.plainDateISO(c):t.Temporal.Now.plainDateISO();return new Date(e.year,e.month-1,e.day).toDateString()},[c]),g=n.toDateString(),m=a.useMemo(()=>wn(u,"narrow"),[u]),f=a.useMemo(()=>e.toLocaleDateString(u,{month:"long",year:"numeric"}),[e,u]),p=a.useMemo(()=>{if(!s||!(null==l?void 0:l.length))return null;const e=new Map;return l.forEach(t=>{var n;const r=z(t.start,c),a=t.end?z(t.end,c):r,o=new Date(r);o.setHours(0,0,0,0);const i=new Date(a);i.setHours(0,0,0,0);let l=new Date(i);if(!t.allDay){0!==a.getHours()||0!==a.getMinutes()||0!==a.getSeconds()||0!==a.getMilliseconds()||l.setDate(l.getDate()-1)}l<o&&(l=new Date(o));const s=P(t.calendarId||"default",d).toLowerCase();for(let t=new Date(o);t<=l;t=new Date(t.getTime()+864e5)){const r=t.toDateString(),a=null!==(n=e.get(r))&&void 0!==n?n:[];!a.includes(s)&&a.length<4&&e.set(r,[...a,s])}}),e},[s,l,c,d]),v=a.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),i=o.toDateString();a.push({date:o.getDate(),fullDate:o,isCurrentMonth:o.getMonth()===n,isToday:i===h,isSelected:i===g})}return a},[e,g,h]);return Ie("div",{className:"px-3 py-3",children:[r?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:()=>o(-1),"aria-label":"Previous month",children:Ie(en,{className:"h-4 w-4"})}),Ie("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:f}),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:()=>o(1),"aria-label":"Next month",children:Ie(tn,{className:"h-4 w-4"})})]}):"",Ie("div",{className:"df-mini-calendar-grid grid grid-cols-7 gap-1 text-xs justify-items-center",children:[m.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}`)),v.map(e=>{var t;const n=null!==(t=null==p?void 0:p.get(e.fullDate.toDateString()))&&void 0!==t?t:[];return Ie("button",{type:"button",className:` df-mini-calendar-day text-center py-1 rounded text-xs h-6 w-6 ${e.isToday?Yt:e.isSelected?"df-fill-secondary rounded-full font-medium":e.isCurrentMonth?"text-gray-900 dark:text-gray-100":"text-gray-400 dark:text-gray-600"} relative flex flex-col items-center justify-center pt-1 pb-1`,onClick:()=>i(e.fullDate),children:[Ie("span",{className:"z-10",children:e.date}),s&&n.length>0&&Ie("div",{className:"absolute bottom-0.5 flex gap-px",children:n.slice(0,4).map((e,t)=>Ie("div",{"data-mini-calendar-dot":"true",className:"h-1 w-1 rounded-full",style:{backgroundColor:e}},`${e}-${t}`))})]},e.fullDate.getTime())})]})]})},Jn=({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":"")})}),Qn=({date:e,onChange:t})=>{const n=Array.from({length:24},(e,t)=>t),r=Array.from({length:12},(e,t)=>5*t),o=[...n,...n,...n],i=[...r,...r,...r],l=32,s=e.getHours(),d=5*Math.round(e.getMinutes()/5),c=(24+s)*l,u=(12+d/5)*l,[h,g]=a.useState(c),[m,f]=a.useState(u),p=a.useRef(null),v=a.useRef(null),y=a.useRef(null);a.useEffect(()=>{p.current&&(p.current.scrollTop=c,g(c)),v.current&&(v.current.scrollTop=u,f(u))},[c,u]);const b=(n,r)=>{const a=n.currentTarget;let s=a.scrollTop;if("hour"===r){const e=768;s<320?(s+=e,a.scrollTop=s):s>1600&&(s-=e,a.scrollTop=s),g(s)}else{const e=384;s<160?(s+=e,a.scrollTop=s):s>800&&(s-=e,a.scrollTop=s),f(s)}y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{((n,r)=>{const a=Math.round(r/l);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=i[a];if(void 0!==n&&5*Math.round(e.getMinutes()/5)!==n){const r=new Date(e);r.setMinutes(n),t(r)}}})(r,s)},150)},x=(e,t)=>{const n=96+e*l+16-(t+112),r=Math.min(Math.abs(n)/112,1);return{transform:`perspective(500px) rotateX(${-(n/112*80)}deg) scale(${1-.4*r})`,opacity:1-.7*r,transition:"transform 0.1s ease-out, opacity 0.1s ease-out"}};return 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:p,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=p.current)||void 0===a||a.scrollTo({top:r*l,behavior:"smooth"})},children:Ie("div",{className:"w-10 text-center text-xl transition-colors duration-200 "+(n===s?"font-bold text-black dark:text-white":"text-gray-400 dark:text-gray-500"),style:x(r,h),children:n.toString().padStart(2,"0")})},`h-${r}-${n}`)),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}}),i.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*l,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"})]})},er=({isOpen:e,onClose:t,onSave:n,onEventDelete:o,draftEvent:i,app:l,timeFormat:s="24h"})=>{const{locale:d,t:c}=bt(),u=l.getReadOnlyConfig(null==i?void 0:i.id),h=l.canMutateFromUI(null==i?void 0:i.id),g=!1!==u.viewable,[m,p]=a.useState(""),y=!a.useMemo(()=>{if(!(null==i?void 0:i.calendarId))return!1;const e=l.getCalendarRegistry().get(i.calendarId);return!!(null==e?void 0:e.subscription)},[l,null==i?void 0:i.calendarId])||""!==m.trim(),[b,x]=a.useState(""),[w,D]=a.useState(""),[E,C]=a.useState(!1),[T,k]=a.useState(new Date),[S,M]=a.useState(new Date),[N,I]=a.useState(new Date),[R,O]=a.useState(new Date),[H,A]=a.useState(null),[P,L]=a.useState(e),[$,j]=a.useState(!1),[Y,F]=a.useState(!1);a.useEffect(()=>{if(!e){j(!0);const e=setTimeout(()=>{L(!1),j(!1)},300);return()=>clearTimeout(e)}L(!0),j(!1)},[e]),a.useEffect(()=>{if(e&&i){const e=l.getEvents().some(e=>e.id===i.id);F(e)}},[e,i,l]);const V=l.getCalendars(),Z=V.map(e=>({label:e.name,value:e.id}));a.useEffect(()=>{if(e&&V.length>0){V.some(e=>e.id===w)||"blue"!==w&&""!==w||D(V[0].id)}},[V,e,w]),a.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]),a.useEffect(()=>{var t,n;if(e&&i){if(x(i.title||""),D(i.calendarId||(null===(t=V[0])||void 0===t?void 0:t.id)||"blue"),C(i.allDay||!1),i.start)try{const e=v(i.start);k(e),I(e)}catch(e){console.error("Failed to parse start date",e);const t=new Date;k(t),I(t)}if(i.end)try{const e=v(i.end);M(e),O(e)}catch(e){console.error("Failed to parse end date",e);const t=new Date;M(t),O(t)}}else if(e&&!i){D((null===(n=V[0])||void 0===n?void 0:n.id)||"blue");const e=new Date;e.setMinutes(0,0,0),k(e),I(e),M(new Date(e.getTime()+36e5)),O(e)}},[e,i]);const _=a.useMemo(()=>{if(!e||!i)return!1;const t=new Date(T),n=new Date(S),r=Object.assign(Object.assign({},i),{title:b,calendarId:w,allDay:E,description:m,start:E?W(t):f(t,l.timeZone),end:E?W(n):f(n,l.timeZone)});return!xe(i,ie(i,r,l.timeZone))},[e,i,b,w,E,T,S,m]);if(!P||!g)return null;const z=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(T.getHours(),T.getMinutes());const n=e.getTime()-T.getTime();k(e);const r=new Date(S.getTime()+n);M(r)}else{const e=new Date(t);e.setHours(S.getHours(),S.getMinutes()),M(e)}},G=(e,t)=>{"start"===e?I(e=>{const n=new Date(e);return n.setMonth(e.getMonth()+t),n}):O(e=>{const n=new Date(e);return n.setMonth(e.getMonth()+t),n})};return r.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 "+($?"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 "+($?"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&&Y?"viewEvent":Y?"editEvent":"newEvent")}),h&&Ie("button",{type:"button",onClick:()=>{if(!i)return;const e=new Date(T),t=new Date(S),r=Object.assign(Object.assign({},i),{title:b,calendarId:w,allDay:E,start:E?W(e):f(e,l.timeZone),end:E?W(t):f(t,l.timeZone)});n(ie(i,r,l.timeZone))},disabled:!_,className:"px-2 py-1 font-bold transition-colors "+(_?"df-text-primary":"cursor-not-allowed text-gray-400 opacity-50"),children:c(Y?"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:b,onChange:e=>h&&x(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(Bn,{options:Z,value:w,onChange:h?D:()=>{},registry:l.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(Jn,{checked:E,onChange:h?C:()=>{},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?"df-text-primary bg-gray-200 dark:bg-gray-700 dark:text-white":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"),onClick:()=>h&&z("start-date"),disabled:!h,children:U(T)}),!E&&Ie("button",{type:"button",className:"rounded-md px-3 py-1 transition-colors "+("start-time"===H?"df-text-primary bg-gray-200 dark:bg-gray-700 dark:text-white":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"),onClick:()=>h&&z("start-time"),disabled:!h,children:X(T.getHours()+T.getMinutes()/60,0,s)})]})]}),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(Xn,{currentDate:T,visibleMonth:N,onDateSelect:e=>B("start",e),onMonthChange:e=>G("start",e),showHeader:!0,events:l.getEvents(),calendarRegistry:l.getCalendarRegistry(),timeZone:l.timeZone})})}),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(Qn,{date:T,onChange:e=>{const t=S.getTime()-T.getTime();k(e),M(new Date(e.getTime()+t))},timeFormat:s})})})]}),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?"df-text-primary bg-gray-200 dark:bg-gray-700 dark:text-white":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"),onClick:()=>h&&z("end-date"),disabled:!h,children:U(S)}),!E&&Ie("button",{type:"button",className:"rounded-md px-3 py-1 transition-colors "+("end-time"===H?"df-text-primary bg-gray-200 dark:bg-gray-700 dark:text-white":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"),onClick:()=>h&&z("end-time"),disabled:!h,children:X(S.getHours()+S.getMinutes()/60,0,s)})]})]}),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(Xn,{currentDate:S,visibleMonth:R,onDateSelect:e=>B("end",e),onMonthChange:e=>G("end",e),showHeader:!0,events:l.getEvents(),calendarRegistry:l.getCalendarRegistry(),timeZone:l.timeZone})})}),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(Qn,{date:S,onChange:e=>{if(e<T){const t=S.getTime()-T.getTime();M(e),k(new Date(e.getTime()-t))}else M(e)},timeFormat:s})})})]}),y&&Ie("div",{className:"rounded-lg bg-white px-4 py-3 dark:bg-gray-900",children:Ie("textarea",{placeholder:c("notesPlaceholder"),value:m,onChange:e=>h&&p(e.currentTarget.value),readOnly:!h,className:"min-h-20 w-full bg-transparent text-base placeholder-gray-400 focus:outline-none"})}),h&&Y&&o&&i&&Ie("button",{type:"button",onClick:()=>o(i.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)},tr=()=>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"})}),nr=({loading:e,results:t,keyword:n,onResultClick:r,emptyText:o})=>{const{t:i,locale:l}=bt(),s=a.useMemo(()=>Ke(new Date),[]),d=a.useMemo(()=>Xe(t,s),[t,s]),c=e=>Ge(e);return e?Ie("div",{className:"flex h-40 flex-col items-center justify-center text-gray-500",children:[Ie(gn,{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(tr,{}),Ie("span",{className:"mt-2 text-sm",children:"string"==typeof o?o:o&&"object"==typeof o?o[l]||o.en||"No results found":i("noResults")||"No results found"})]}):null:Ie("div",{className:"space-y-6",children:d.map(e=>{const{title:t,colorClass:n}=qe(e.date,s,l,i);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),a={hour:"2-digit",minute:"2-digit"},o=e.allDay?i("allDay")||"All Day":t.toLocaleTimeString(l,a),s=e.allDay?"":n.toLocaleTimeString(l,a);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==r?void 0:r(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}),s&&Ie("div",{className:"text-gray-500 dark:text-gray-400",children:s})]})]})]})}),Ie("div",{className:"mx-2 border-b border-gray-200 dark:border-gray-700"})]},e.id)})})]},e.date.getTime())})})},rr=({isOpen:e,onClose:t,keyword:n,onSearchChange:o,results:i,loading:l,onResultClick:s,emptyText:d})=>{const c=a.useRef(null),{t:u}=bt();return a.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?r.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(yn,{className:"h-6 w-6"})}),Ie("div",{className:"relative flex-1",children:[Ie("input",{ref:c,type:"text",placeholder:u("search")||"Search",value:n,onChange:e=>{const t=e.target.value;t!==n&&o(t)},className:"df-focus-ring-only w-full rounded-full border-none bg-gray-100 py-2 pr-10 pl-3 text-gray-900 focus:ring-2 focus:outline-none dark:bg-gray-800 dark:text-gray-100"}),n&&Ie("button",{type:"button",onClick:()=>{""!==n&&o("")},className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400",children:Ie(cn,{className:"h-4 w-4"})})]})]}),Ie("div",{className:"flex-1 overflow-y-auto p-2 select-none",children:Ie(nr,{loading:l,results:i,keyword:n,onResultClick:e=>{null==s||s(e)},emptyText:d})})]}),document.body):null},ar=({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(nr,{loading:t,results:n,keyword:r,onResultClick:a,emptyText:o})})});let or=null;const ir={enabled:!1,width:"0px",isCollapsed:!1,toggleCollapsed:()=>{},miniWidth:"0px",content:null,extraContent:null,safeAreaLeft:0};function lr(e){return or&&e.hasPlugin("sidebar")?or(e):ir}const sr=({locale:e,messages:t,children:n})=>bt().isDefault?Ie(Cn,{locale:e,messages:t,children:n}):n,dr=({app:t,customDetailPanelContent:o,customEventDetailDialog:i,meta:l,customMessages:s,search:d,titleBarSlot:c,collapsedSafeAreaLeft:u})=>{const h=a.useContext(Rn),{tick:g,selectedEventId:f}=function(e){const[t,n]=a.useState(0),[r,o]=a.useState(null);return a.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:r}}(t),{isMobile:p}=function(){const[e,t]=a.useState(!1);return a.useEffect(()=>{const e=()=>{t(window.matchMedia("(max-width: 768px)").matches)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),{isMobile:e}}(),y=function(t,n){const[r,o]=a.useState(""),[i,l]=a.useState(!1),[s,d]=a.useState(!1),[c,u]=a.useState(!1),[h,g]=a.useState([]),m=a.useRef(""),f=a.useRef(!1);a.useEffect(()=>{t.state.highlightedEventId&&t.selectEvent(t.state.highlightedEventId)},[t.state.highlightedEventId,t]),a.useEffect(()=>{f.current&&!i&&null!==t.state.highlightedEventId&&t.highlightEvent(null),f.current=i},[i,t]),a.useEffect(()=>{var a;if(!r.trim())return l(!1),g([]),m.current.trim()&&null!==t.state.highlightedEventId&&t.highlightEvent(null),void(m.current=r);const o=null!==(a=null==n?void 0:n.debounceDelay)&&void 0!==a?a:300,i=setTimeout(()=>e.__awaiter(this,void 0,void 0,function*(){var e;u(!0),l(!0);try{let a=[];if(null==n?void 0:n.customSearch){const e=t.getEvents().map(e=>{var n;return Object.assign(Object.assign({},e),{color:(null===(n=t.getCalendarRegistry().get(e.calendarId||""))||void 0===n?void 0:n.colors.lineColor)||t.getCalendarRegistry().resolveColors().lineColor})});a=n.customSearch({keyword:r,events:e})}else if(null==n?void 0:n.onSearch)a=yield n.onSearch(r);else{const e=r.toLowerCase();a=t.getEvents().filter(t=>t.title.toLowerCase().includes(e)||t.description&&t.description.toLowerCase().includes(e)).map(e=>{var n;return Object.assign(Object.assign({},e),{color:(null===(n=t.getCalendarRegistry().get(e.calendarId||""))||void 0===n?void 0:n.colors.lineColor)||t.getCalendarRegistry().resolveColors().lineColor})})}g(a),null===(e=null==n?void 0:n.onSearchStateChange)||void 0===e||e.call(n,{keyword:r,loading:!1,results:a})}catch(e){console.error("Search failed",e),g([])}finally{u(!1)}}),o);return m.current=r,()=>clearTimeout(i)},[r,n,t]);const p=a.useCallback((e,r="desktop")=>{const a=()=>{let n;n=e.start instanceof Date?e.start:"string"==typeof e.start?new Date(e.start):v(e.start),t.setCurrentDate(n),t.highlightEvent(e.id),s&&d(!1)},o=()=>{"mobile"===r?d(!1):l(!1),t.highlightEvent(null)};(null==n?void 0:n.onResultClick)?n.onResultClick({event:e,app:t,source:r,defaultAction:a,closeSearch:o}):a()},[t,s,n]),y=a.useCallback(()=>{o(""),d(!0)},[]),b=a.useCallback(()=>{l(!1),o(""),t.highlightEvent(null)},[t]),x=a.useCallback(()=>{d(!1),o(""),t.highlightEvent(null)},[t]);return{searchKeyword:r,setSearchKeyword:o,isSearchOpen:i,setIsSearchOpen:l,isMobileSearchOpen:s,setIsMobileSearchOpen:d,searchLoading:c,searchResults:h,handleSearchResultClick:p,handleSearchClick:y,handleSearchClose:b,handleMobileSearchClose:x}}(t,d),b=i||(t.getUseEventDetailDialog()?Gn:void 0),x=function(t,n,r){const[o,i]=a.useState(null),l=a.useRef(null);a.useEffect(()=>{i(null),l.current=null},[t]);const s=a.useCallback(()=>{i(null),l.current=null,t.selectEvent(null)},[t]),d=a.useCallback(e=>t.updateEvent(e.id,e),[t]),c=a.useCallback(n=>e.__awaiter(this,void 0,void 0,function*(){yield t.deleteEvent(n),i(null),t.selectEvent(null)}),[t]),u=a.useMemo(()=>{var e;if(!n||!o)return null;const r=o.split("::")[0],a=t.getEvents().find(e=>e.id===r);a&&(l.current=a);const i=null!=a?a:(null===(e=l.current)||void 0===e?void 0:e.id)===r?l.current:null;return i?{event:i,isOpen:!0,isAllDay:m(i.start),onEventUpdate:d,onEventDelete:c,onClose:s,app:t}:null},[r,o,n,s,d,c,t]);return{detailPanelEventId:o,setDetailPanelEventId:i,dialogProps:u}}(t,b,g),w=lr(t),D=function(e,t,n){const[r,o]=a.useState(!1),i=a.useRef(null),[l,s]=a.useState(!1),[d,c]=a.useState(null),[u,h]=a.useState(!1),g=a.useCallback(()=>{h(!0)},[]),m=a.useCallback(a=>{var l,d;if(e.canMutateFromUI()){if(t){const{start:t,end:n}=ae(e.timeZone),r={id:De(),title:"",start:G(t,e.timeZone),end:G(n,e.timeZone),calendarId:(null===(l=e.getCalendars().find(e=>!1!==e.isVisible))||void 0===l?void 0:l.id)||(null===(d=e.getCalendars()[0])||void 0===d?void 0:d.id)};return c(r),void s(!0)}n?r?o(!1):(i.current=a.currentTarget,o(!0)):g()}},[t,r,e,n,g]);return{isQuickCreateOpen:r,setIsQuickCreateOpen:o,quickCreateAnchorRef:i,isMobileDrawerOpen:l,setIsMobileDrawerOpen:s,mobileDraftEvent:d,setMobileDraftEvent:c,handleAddButtonClick:m,isCreateCalendarOpen:u,setIsCreateCalendarOpen:h}}(t,p,w.enabled),[E,C]=a.useState(()=>t.getTheme());a.useEffect(()=>t.subscribeThemeChange(e=>C(e)),[t]);const T=a.useCallback(e=>t.setTheme(e),[t]);a.useEffect(()=>{const e=t.callbacks,n=e.onDismissUI;return e.onDismissUI=()=>{x.detailPanelEventId&&x.setDetailPanelEventId(null),D.isMobileDrawerOpen&&D.setIsMobileDrawerOpen(!1),null==n||n()},()=>{e.onDismissUI=n}},[t,x,D]),a.useEffect(()=>{if(!p||!x.detailPanelEventId)return;const e=x.detailPanelEventId.split("::")[0],n=t.getEvents().find(t=>t.id===e);n&&(D.setMobileDraftEvent(n),D.setIsMobileDrawerOpen(!0)),x.setDetailPanelEventId(null)},[x.detailPanelEventId,p]);const k=a.useCallback(e=>{t.setCurrentDate(e),t.selectEvent(null)},[t]),S=a.useCallback(e=>t.selectEvent(e),[t]),M=a.useRef(null),N={app:t,config:t.getCurrentView().config||{},customDetailPanelContent:o,customEventDetailDialog:b,switcherMode:t.state.switcherMode,calendarRef:M,meta:l,selectedEventId:f,onEventSelect:S,onDateChange:k,detailPanelEventId:x.detailPanelEventId,onDetailPanelToggle:x.setDetailPanelEventId},I=a.useMemo(()=>({isCollapsed:w.isCollapsed,toggleCollapsed:w.toggleCollapsed}),[w.isCollapsed,w.toggleCollapsed]),R=void 0!==u,O=R?"0px":w.miniWidth,H=R&&w.isCollapsed?u:w.safeAreaLeft,A=t.getCalendarHeaderConfig(),P=Object.assign({calendar:t,switcherMode:t.state.switcherMode,onAddCalendar:D.handleAddButtonClick,onSearchChange:y.setSearchKeyword,onSearchClick:y.handleSearchClick,searchValue:y.searchKeyword,isSearchOpen:y.isSearchOpen,isEditable:t.canMutateFromUI()},H>0?{safeAreaLeft:H}:{}),L=t.getCurrentView().component,$=t.getCustomMobileEventRenderer()||er;return Ie(Nn,{initialTheme:E,onThemeChange:T,children:Ie(sr,{locale:t.state.locale,messages:s,children:Ie("div",{className:"df-calendar-container relative flex flex-row overflow-hidden select-none",children:[Ie(Hn,{store:h,generatorName:"titleBarSlot",generatorArgs:I,defaultContent:c&&("function"==typeof c?c(I):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?O:w.width:0},children:[!1===A?null:Ie(Hn,{store:h,generatorName:"calendarHeader",generatorArgs:P,defaultContent:n.h(Sn,P)}),Ie("div",{className:"relative flex-1 overflow-hidden",ref:M,children:[Ie("div",{className:"calendar-renderer relative flex h-full flex-row",children:[Ie("div",{className:"h-full flex-1 overflow-hidden",children:Ie(L,Object.assign({},N))}),Ie(ar,{isOpen:y.isSearchOpen,onClose:y.handleSearchClose,loading:y.searchLoading,results:y.searchResults,keyword:y.searchKeyword,onResultClick:e=>y.handleSearchResultClick(e,"desktop"),emptyText:null==d?void 0:d.emptyText})]}),Ie(rr,{isOpen:y.isMobileSearchOpen,onClose:y.handleMobileSearchClose,keyword:y.searchKeyword,onSearchChange:y.setSearchKeyword,results:y.searchResults,loading:y.searchLoading,onResultClick:e=>y.handleSearchResultClick(e,"mobile"),emptyText:null==d?void 0:d.emptyText})]})]}),Ie(qn,{app:t,anchorRef:D.quickCreateAnchorRef,isOpen:D.isQuickCreateOpen,onClose:()=>D.setIsQuickCreateOpen(!1)}),Ie($,{isOpen:D.isMobileDrawerOpen,onClose:()=>{D.setIsMobileDrawerOpen(!1),D.setMobileDraftEvent(null)},onSave:e=>{t.getEvents().some(t=>t.id===e.id)?t.updateEvent(e.id,e):t.addEvent(e),D.setIsMobileDrawerOpen(!1),D.setMobileDraftEvent(null)},onEventDelete:e=>{t.deleteEvent(e),D.setIsMobileDrawerOpen(!1),D.setMobileDraftEvent(null)},draftEvent:D.mobileDraftEvent,app:t}),w.extraContent,D.isCreateCalendarOpen&&Ie(jn,{app:t,onClose:()=>D.setIsCreateCalendarOpen(!1),onCreate:n=>e.__awaiter(void 0,void 0,void 0,function*(){yield t.createCalendar(n),D.setIsCreateCalendarOpen(!1)})}),(()=>{if(!x.dialogProps)return null;const e=b,t="undefined"==typeof document?null:document.body;if(!t)return null;const a=null==h?void 0:h.isOverridden("eventDetailDialog");return Ie(Hn,{store:h,generatorName:"eventDetailDialog",generatorArgs:x.dialogProps,defaultContent:a?null:r.createPortal(n.h(e,x.dialogProps),t)})})()]})})})};class cr{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 ur=r.forwardRef(({x:e,y:t,onClose:n,children:o,className:i},l)=>{const s=a.useRef(null);a.useEffect(()=>{const e=()=>n(),t=e=>{if(s.current&&!s.current.contains(e.target)){if(e.target.closest("[data-submenu-content]"))return;n()}};window.dispatchEvent(new CustomEvent("dayflow-close-all-menus")),window.addEventListener("dayflow-close-all-menus",e),document.body.addEventListener("mousedown",t,{capture:!0}),document.body.addEventListener("contextmenu",t,{capture:!0});const r=e=>{"Escape"===e.key&&n()};window.addEventListener("keydown",r);const a=()=>n();return window.addEventListener("scroll",a,!0),window.addEventListener("resize",a),()=>{window.removeEventListener("dayflow-close-all-menus",e),document.body.removeEventListener("mousedown",t,{capture:!0}),document.body.removeEventListener("contextmenu",t,{capture:!0}),window.removeEventListener("keydown",r),window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",a)}},[n]);const d={top:t,left:e};return r.createPortal(Ie("div",{ref:e=>{s.current=e,"function"==typeof l?l(e):l&&"current"in l&&(l.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 ${i||""}`,style:d,onContextMenu:e=>e.preventDefault(),"data-context-menu-root":"true",children:o}),document.body)});ur.displayName="ContextMenu";const hr=({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?"df-text-destructive df-hover-fill-destructive df-focus-fill-destructive":"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]}),gr=()=>Ie("div",{className:"-mx-1 my-1 h-px bg-slate-200 dark:bg-slate-800"}),mr=({children:e})=>{const[t,r]=a.useState(!1),o=a.useRef(null);return a.useEffect(()=>()=>{o.current&&clearTimeout(o.current)},[]),Ie("div",{className:"relative",onMouseEnter:()=>{o.current&&(clearTimeout(o.current),o.current=null),r(!0)},onMouseLeave:()=>{o.current=setTimeout(()=>{r(!1)},100)},children:(Array.isArray(e)?e:[e]).map(e=>n.isValidElement(e)?n.cloneElement(e,{isOpen:t}):e)})},fr=({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(tn,{className:"ml-auto h-4 w-4 "+(n?"text-white opacity-100":"opacity-60")})]}),pr=({children:e,isOpen:t})=>{const n=a.useRef(null),[r,o]=a.useState("right");return a.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"===r?"100%":"auto",right:"left"===r?"100%":"auto",marginLeft:"right"===r?"0.25rem":0,marginRight:"left"===r?"0.25rem":0},"data-submenu-content":"true",children:e}):null},vr=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],yr=({x:t,y:n,date:r,onClose:a,app:o,onCreateEvent:i,viewType:l})=>{const{t:s}=bt();if(!o.canMutateFromUI())return null;const d=Je.hasEvent();return Ie(ur,{x:t,y:n,onClose:a,className:"df-context-menu",children:[Ie(hr,{onClick:()=>{i(),a()},children:s("newEvent")||"New Event"}),Ie(hr,{onClick:()=>e.__awaiter(void 0,void 0,void 0,function*(){yield((t,n,r)=>e.__awaiter(void 0,void 0,void 0,function*(){if(Je.hasEvent())try{let e=Je.getEvent();if(!e){const t=yield navigator.clipboard.readText();t&&(e=JSON.parse(t))}if(e&&"object"==typeof e&&"title"in e){const a=e,o=_(a.start),i=_(a.end).getTime()-o.getTime(),l=e,s=new Date(n),d=r===exports.ViewType.MONTH||r===exports.ViewType.YEAR,c=0===s.getHours()&&0===s.getMinutes(),u=0!==o.getHours()||0!==o.getMinutes();!a.allDay&&(d||c&&u)&&s.setHours(o.getHours(),o.getMinutes(),o.getSeconds(),o.getMilliseconds());const h=new Date(s.getTime()+(i>0?i:36e5)),g=Object.assign(Object.assign({},l),{title:a.title,id:De(),start:a.allDay?W(s):G(s,t.timeZone),end:a.allDay?W(h):G(h,t.timeZone),calendarId:a.calendarId&&t.getCalendarRegistry().has(a.calendarId)?a.calendarId:t.getCalendarRegistry().getDefaultCalendarId()||"default"});t.addEvent(g)}}catch(e){console.error("Failed to paste event:",e)}}))(o,r,l),a()}),disabled:!d,children:s("pasteHere")||"Paste Here"})]})},br=({event:t,x:r,y:a,onClose:o,app:i})=>{var l;const{t:s}=bt();if(!i.canMutateFromUI(t.id))return null;const d=i.getCalendars(),c=i.callbacks,u=null===(l=null==c?void 0:c.renderEventContextMenu)||void 0===l?void 0:l.call(c,t,o);return Ie(ur,{x:r,y:a,onClose:o,children:[Ie(mr,{children:[Ie(fr,{children:s("calendars")||"Calendars"}),Ie(pr,{children:d.map(e=>{const n=e.id===t.calendarId;return Ie(hr,{onClick:()=>{return n=e.id,i.updateEvent(t.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(sn,{className:"df-text-primary h-3 w-3"})}),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:e.colors.lineColor}}),Ie("span",{className:"truncate "+(n?"font-semibold":""),children:e.name})]})]})},e.id)})})]}),Ie(gr,{}),Ie(hr,{onClick:()=>{i.deleteEvent(t.id),o()},danger:!0,children:s("delete")||"Delete"}),Ie(hr,{onClick:()=>e.__awaiter(void 0,void 0,void 0,function*(){try{const e=JSON.stringify(t,null,2);yield navigator.clipboard.writeText(e),Je.setEvent(t),i.deleteEvent(t.id)}catch(e){console.error("Failed to cut event: ",e)}o()}),children:s("cut")||"Cut"}),Ie(hr,{onClick:()=>e.__awaiter(void 0,void 0,void 0,function*(){try{const e=JSON.stringify(t,null,2);yield navigator.clipboard.writeText(e),Je.setEvent(t)}catch(e){console.error("Failed to copy event: ",e)}o()}),children:s("copy")||"Copy"}),u&&Ie(n.Fragment,{children:[Ie(gr,{}),u]})]})},xr=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(mn,{className:"h-3 w-3"}):t.includes("birthday")||t.includes("anniversary")||t.includes("生日")?Ie(fn,{className:"h-3 w-3"}):t.includes("conference")||t.includes("meeting")||t.includes("会议")||t.includes("研讨")?Ie(vn,{className:"h-3 w-3"}):t.includes("trip")||t.includes("travel")||t.includes("旅行")?Ie(pn,{className:"h-3 w-3"}):Ie(un,{className:"h-3 w-3"})},wr=(e,t,n=7,r)=>{const a=[],o=new Date(t);return o.setDate(t.getDate()+(n-1)),o.setHours(23,59,59,999),e.forEach(e=>{const i=z(e.start,r),l=e.end?z(e.end,r):i,s=new Date(i);s.setHours(0,0,0,0);const d=new Date(l);d.setHours(0,0,0,0);let c=new Date(d);if(!e.allDay){if(!(0!==l.getHours()||0!==l.getMinutes()||0!==l.getSeconds())){const e=l.getTime()-i.getTime();e>0&&e<864e5&&(c=new Date(d),c.setDate(c.getDate()-1))}}const u=D(s,c)>0;if(!u&&e.allDay){if(s<t||s>o)return;const r=Math.floor((s.getTime()-t.getTime())/864e5);return void(r>=0&&r<=n-1&&a.push({id:`${e.id}-week-${t.getTime()}`,originalEventId:e.id,event:e,startDayIndex:r,endDayIndex:r,segmentType:"single",totalDays:1,segmentIndex:0,isFirstSegment:!0,isLastSegment:!0}))}if(!u)return;const h=s;let g;if(e.allDay)g=new Date(d),g.setHours(23,59,59,999);else{0!==l.getHours()||0!==l.getMinutes()||0!==l.getSeconds()?(g=new Date(d),g.setHours(23,59,59,999)):(g=new Date(d),g.setTime(g.getTime()-1))}if(g<t||h>o)return;const m=h<t?t:h,f=g>o?o:g,p=Math.max(0,Math.floor((m.getTime()-t.getTime())/864e5)),v=Math.min(n-1,Math.floor((f.getTime()-t.getTime())/864e5)),y=h>=t,b=g<=o,x=0===p||v===n-1;let w;w=y&&b?"single":y?x&&v===n-1?"start-week-end":"start":b?x&&0===p?"end-week-start":"end":"middle";const E=D(h,g)+1;a.push({id:`${e.id}-week-${t.getTime()}`,originalEventId:e.id,event:e,startDayIndex:p,endDayIndex:v,segmentType:w,totalDays:E,segmentIndex:0,isFirstSegment:y,isLastSegment:b})}),a},Dr=(e,t,n=7,r)=>{if(e.allDay)return[];const a=z(e.start,r),o=e.end?z(e.end,r):a,i=new Date(a);i.setHours(0,0,0,0);const l=new Date(o);l.setHours(0,0,0,0);const s=D(i,l);if(0===s)return[];const d=0!==o.getHours()||0!==o.getMinutes()||0!==o.getSeconds()||0!==o.getMilliseconds(),c=o.getTime()-a.getTime();if(!e.allDay&&1===s&&!d&&c<864e5)return[];const u=d?s:Math.max(0,s-1),h=[];for(let e=0;e<=u;e++){const r=new Date(i);r.setDate(i.getDate()+e);const l=Math.floor((r.getTime()-t.getTime())/864e5);if(l<0||l>n-1)continue;const s=0===e,c=e===u,g=s?a.getHours()+a.getMinutes()/60:0,m=c&&d?o.getHours()+o.getMinutes()/60:24;h.push({dayIndex:l,startHour:g,endHour:m,isFirst:s,isLast:c})}return h},Er=r.memo(({segment:e,segmentIndex:t,isDragging:r,isResizing:o=!1,isSelected:i=!1,onMoveStart:l,onResizeStart:s,onEventLongPress:d,isMobile:c=!1,isDraggable:u=!0,isEditable:h=!0,viewable:g=!0,isPopping:m,renderSlot:f,appTimeZone:p})=>{const[v,y]=a.useState(!1),b=a.useMemo(()=>{if(!p||e.event.allDay)return e.event;const t=U(e.event.start,p),n=e.event.end?U(e.event.end,p):void 0;return Object.assign(Object.assign({},e.event),{start:t,end:n})},[e.event,p]),x=17*t,w=`calc(${e.startDayIndex/7*100}% + 2px)`,D=`calc(${(e.endDayIndex-e.startDayIndex+1)/7*100}% - 4px)`,C=a.useRef(null),T=a.useRef(null),k=t=>{const n="left"===t;return(n?e.isFirstSegment:e.isLastSegment)&&s&&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(),s(t,e.event,n?"left":"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}):null},S=()=>{const t=b.allDay,n=b.calendarId||"blue",r=E(b.start),a=J(b),o=X(r),i=X(a);if(t){const t=()=>e.isFirstSegment?b.title:"middle"===e.segmentType||e.isLastSegment&&e.totalDays>1?"···":b.title;return Ie("div",{className:"pointer-events-auto flex w-full min-w-0 items-center",children:[e.isFirstSegment&&xr(b)&&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:P(n),width:"12px",height:"12px"},children:xr(b)})}),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 l=e.isFirstSegment||e.isLastSegment?b.title:"···",s=e.endDayIndex-e.startDayIndex+1,d=s>1?{position:"absolute",right:`calc(${s>1?(s-1)/s*100:0}% + 2px)`,top:"50%",transform:"translateY(-50%)"}:void 0;return Ie("div",{className:"pointer-events-auto relative flex w-full min-w-0 items-center",children:[Ie("div",{className:Pt,style:{backgroundColor:P(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:l})}),e.isFirstSegment&&!c&&Ie("span",{className:"text-xs font-medium whitespace-nowrap "+(1===s?"ml-2":""),style:d,children:o}),e.isLastSegment&&!b.allDay&&24!==a&&!c&&Ie("span",{className:"ml-auto text-xs font-medium whitespace-nowrap",children:`ends ${i}`})]})},M=e.event.calendarId||"blue",N=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:w,width:D,top:`${x}px`,height:"16px",borderRadius:(I=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"}[I]),pointerEvents:"auto",zIndex:10,transform:m?"scale(1.02)":"scale(1)",transition:"transform 0.5s cubic-bezier(0.22, 1, 0.36, 1)",willChange:"transform"},i||r||v?{backgroundColor:A(M),color:"#fff"}:{backgroundColor:O(M),color:H(M)}),{cursor:u||g?"pointer":"default"}),"data-segment-days":N,onMouseDown:t=>{if(!u&&!g)return;t.preventDefault(),t.stopPropagation(),y(!0);!t.target.closest(".resize-handle")&&u&&(null==l||l(t,e.event))},onMouseUp:()=>{y(!1)},onMouseLeave:()=>{y(!1)},onTouchStart:t=>{if(!l||!c||!u&&!g)return;t.stopPropagation(),y(!0);const n=t.touches[0],r=n.clientX,a=n.clientY,o=t.currentTarget;T.current={x:r,y:a},C.current=setTimeout(()=>{d&&d(e.event.id);u&&l({preventDefault:()=>{},stopPropagation:()=>{},currentTarget:o,touches:[{clientX:r,clientY:a}],cancelable:!1},e.event),C.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},onTouchMove:e=>{if(C.current&&T.current){const t=Math.abs(e.touches[0].clientX-T.current.x),n=Math.abs(e.touches[0].clientY-T.current.y);(t>10||n>10)&&(clearTimeout(C.current),C.current=null,T.current=null,y(!1))}},onTouchEnd:()=>{y(!1),C.current&&(clearTimeout(C.current),C.current=null),T.current=null},title:`${b.title} (${Re(b.start)} - ${Re(b.end)})`,children:[c&&i&&h&&Ie(n.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:P(M)},onTouchStart:t=>{t.stopPropagation(),null==s||s(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:P(M)},onTouchStart:t=>{t.stopPropagation(),null==s||s(t,e.event,"right")}})]}),k("left"),Ie("div",{className:"min-w-0 flex-1",style:{cursor:o?"ew-resize":"pointer"},children:f?f(S()):S()}),k("right")]});var I});Er.displayName="MultiDayEvent";const Cr=({event:e,isEditable:t,onResizeStart:r,isMultiDay:a,segment:o,isSlidingView:i,renderSlot:l})=>{const s=!1!==e.icon,d="boolean"==typeof e.icon?null:e.icon,c=(()=>{if(!i||!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:[s&&(d?Ie("div",{className:"mr-1 shrink-0",children:d}):Ie(un,{className:Lt})),Ie("div",{className:`${At} 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:[l?l(u):u,r&&t&&Ie(n.Fragment,{children:[Ie("div",{className:$t,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),r(t,e,"left")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}),Ie("div",{className:jt,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),r(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]})]})},Tr=({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(un,{className:`${Lt} ${t?"text-white":""}`})),Ie("span",{className:"truncate "+(t?"text-white":""),children:e.title})]})},kr=({event:e,app:t,isEventSelected:n,hideTime:r,isMobile:a})=>{const o=`${Math.floor(E(e.start)).toString().padStart(2,"0")}:${Math.round(E(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:P(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())},className:Pt}),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:`${Kt} ml-1 shrink-0 ${n?"text-white":""}`,style:n?void 0:{opacity:.8},children:o})]})},Sr=({event:e,app:t,multiDaySegmentInfo:r,isEditable:a,isTouchEnabled:o,isEventSelected:i,onResizeStart:l,timeFormat:s="24h",resizeHandleOrientation:d="vertical",renderSlot:c})=>{const u=r?r.startHour:E(e.start),h=r?r.endHour:J(e),g=h-u,m=!r||r.isFirst,f=!r||r.isLast,p=e.calendarId||"blue",v=!r&&g<=.25?"px-1 py-0":"p-1",y=Ie(n.Fragment,{children:[Ie("div",{className:"df-event-color-bar absolute left-1 top-1 bottom-1 w-[3px] rounded-full",style:{backgroundColor:P(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())}}),Ie("div",{className:`flex h-full flex-col overflow-hidden pl-3 ${v}`,children:[Ie("div",{className:`${At} 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?`${X(u,0,s)} - ${X(h,0,s)}`:Q(e,s)})]})]});return Ie(n.Fragment,{children:[c?c(y):y,l&&a&&"vertical"===d&&Ie(n.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=>l(t,e,"top")}),f&&Ie("div",{className:"absolute bottom-0 left-0 w-full h-1.5 cursor-ns-resize z-10 rounded-b-sm",onMouseDown:t=>l(t,e,"bottom")}),!m&&f&&r&&Ie("div",{className:jt,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),l(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]}),o&&i&&l&&a&&"vertical"===d&&Ie(n.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:P(p,null==t?void 0:t.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),l(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:P(p,null==t?void 0:t.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),l(t,e,"bottom")}})]}),l&&a&&"horizontal"===d&&Ie(n.Fragment,{children:[Ie("div",{className:$t,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),l(t,e,"left")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}),Ie("div",{className:jt,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),l(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]})]})},Mr=({event:e,segment:t,isEditable:r,onMoveStart:a,onResizeStart:o,renderSlot:i})=>{const l=!!e.allDay,s=e.calendarId||"blue",d=P(s),c=l?xr(e):null,{isFirstSegment:u,isLastSegment:h}=t,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(l){const n=()=>t.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:[t.isFirstSegment&&xr(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:P(s),width:"12px",height:"12px"},children:xr(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:n()})}),t.isLastSegment&&!t.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 n=t.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:[!l&&Ie("span",{style:{backgroundColor:d},className:"df-year-event-indicator inline-block h-3 w-0.75 shrink-0 rounded-full"}),l&&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:n})]})};return Ie(n.Fragment,{children:[g("left"),i?i(m()):m(),g("right")]})};const Nr=({event:e,viewType:t,isAllDay:n,isMultiDay:r,segment:a,yearSegment:o,segmentIndex:i,isBeingDragged:l,isBeingResized:s,isEventSelected:d,isPopping:c,isEditable:u,isDraggable:h,canOpenDetail:g,isTouchEnabled:m,hideTime:f,isMobile:p,isSlidingView:v,app:y,onMoveStart:b,onResizeStart:x,multiDaySegmentInfo:w,customRenderingStore:D,eventContentSlotArgs:E,timeFormat:C="24h",appTimeZone:T,renderVisualContent:k,resizeHandleOrientation:S})=>{const M=t===exports.ViewType.MONTH,N=t===exports.ViewType.YEAR,I=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),R=e=>k?k(e):e;if(M&&r&&a)return Ie(Er,{segment:a,segmentIndex:null!=i?i:0,isDragging:l||d,isResizing:s,isSelected:d,onMoveStart:b,onResizeStart:x,isMobile:p,isDraggable:h,isEditable:u,viewable:g,isPopping:c,appTimeZone:T,renderSlot:e=>Ie(Hn,{store:D,generatorName:I,generatorArgs:E,defaultContent:R(e)})});if(N&&o)return Ie(Mr,{event:e,segment:o,isEditable:u,onMoveStart:b,onResizeStart:x,renderSlot:e=>Ie(Hn,{store:D,generatorName:I,generatorArgs:E,defaultContent:R(e)})});if(M){const t=e.allDay?Ie(Tr,{event:e,isEventSelected:d}):Ie(kr,{event:e,app:y,isEventSelected:d,hideTime:f,isMobile:p});return Ie(Hn,{store:D,generatorName:I,generatorArgs:E,defaultContent:R(t)})}const O=e=>Ie(Hn,{store:D,generatorName:I,generatorArgs:E,defaultContent:R(e)});return n?Ie(Cr,{event:e,isEditable:u,onResizeStart:x,isMultiDay:r,segment:a,isSlidingView:v,renderSlot:O}):Ie(Sr,{event:e,app:y,multiDaySegmentInfo:w,isEditable:u,isTouchEnabled:m,isEventSelected:d,onResizeStart:x,timeFormat:C,resizeHandleOrientation:S,renderSlot:O})},Ir=({event:n,position:o,panelRef:i,isAllDay:l,eventVisibility:s,calendarRef:d,selectedEventElementRef:c,onEventUpdate:u,onEventDelete:h,onClose:g,app:f})=>{var p,v;const{effectiveTheme:y}=In(),b=_e(y),{t:x}=bt(),[w,D]=a.useState(n),[E,C]=a.useState(!1),T=a.useRef(n),k=a.useRef(n),S=a.useRef(!1),M=a.useCallback(()=>{if(S.current)return;const e=T.current,t=k.current;if(xe(e,t))return;const n=ie(e,t,null==f?void 0:f.timeZone);T.current=n,k.current=n;const r=u(n);r&&Promise.resolve(r).catch(e=>{L.error("Failed to commit deferred event detail panel update",e)})},[null==f?void 0:f.timeZone,u]),N=a.useCallback(e=>{if(!xe(k.current,e)&&(k.current=e,D(e),f)){const t=f.updateEvent(e.id,e,!0);t&&Promise.resolve(t).catch(e=>{L.error("Failed to apply pending event detail panel update",e)})}},[f]);a.useEffect(()=>{if(!(T.current.id===n.id))return M(),S.current=!1,T.current=n,k.current=n,void D(n);xe(T.current,k.current)&&(T.current=n,k.current=n,D(n))},[n,M]),a.useEffect(()=>()=>{M()},[M]);const R=a.useMemo(()=>{var e;return null!==(e=null==f?void 0:f.timeZone)&&void 0!==e?e:t.Temporal.Now.timeZoneId()},[f]),O=a.useMemo(()=>(f?f.getCalendarRegistry():I()).getVisible().map(e=>({label:e.name,value:e.id})),[f,null==f?void 0:f.getCalendars()]),H="dark"===b||"undefined"!=typeof document&&document.documentElement.classList.contains("dark"),A=null!==(p=null==f?void 0:f.canMutateFromUI(n.id))&&void 0!==p&&p,P=null==f?void 0:f.getReadOnlyConfig(n.id),$=!1!==(null==P?void 0:P.viewable),j=!!w.allDay,Y=!a.useMemo(()=>{if(!n.calendarId)return!1;const e=null==f?void 0:f.getCalendarRegistry().get(n.calendarId);return!!(null==e?void 0:e.subscription)},[f,n.calendarId])||""!==(w.description||"").trim();if(!$)return null;const F=H?"#1f2937":"white",V=H?"rgb(55, 65, 81)":"rgb(229, 231, 235)",Z=(()=>{var e;let t={};if("sticky-top"===s){const n=null===(e=d.current)||void 0===e?void 0:e.querySelector(".df-calendar-content");if(n){const e=n.getBoundingClientRect().top+3-o.top;t=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:F,transform:"rotate(45deg)",transformOrigin:"center",top:e-6+"px",borderRight:""+(o.isSunday?`1px solid ${V}`:"none"),borderTop:""+(o.isSunday?`1px solid ${V}`:"none"),borderLeft:""+(o.isSunday?"none":`1px solid ${V}`),borderBottom:""+(o.isSunday?"none":`1px solid ${V}`)},o.isSunday?{right:"-6px"}:{left:"-6px"})}}else if("sticky-bottom"===s){const e=i.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:F,transform:"rotate(45deg)",transformOrigin:"center",top:`${n}px`,left:o.isSunday?void 0:"-6px",right:o.isSunday?"-6px":void 0,borderRight:""+(o.isSunday?`1px solid ${V}`:"none"),borderTop:""+(o.isSunday?`1px solid ${V}`:"none"),borderLeft:""+(o.isSunday?"none":`1px solid ${V}`),borderBottom:""+(o.isSunday?"none":`1px solid ${V}`)}}else if(o&&c.current&&d.current){const e=c.current.getBoundingClientRect(),n=d.current.querySelector(".df-calendar-content");if(n){const r=n.getBoundingClientRect(),a=Math.max(e.top,r.top),l=Math.min(e.bottom,r.bottom),s=Math.max(0,l-a);let d;d=s===e.height?e.top+e.height/2:s>0?a+s/2:e.top+e.height/2;const c=d-o.top,u=i.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:F,transform:"rotate(45deg)",transformOrigin:"center",top:m-6+"px",borderRight:""+(o.isSunday?`1px solid ${V}`:"none"),borderTop:""+(o.isSunday?`1px solid ${V}`:"none"),borderLeft:""+(o.isSunday?"none":`1px solid ${V}`),borderBottom:""+(o.isSunday?"none":`1px solid ${V}`)},o.isSunday?{right:"-6px"}:{left:"-6px"})}}return t})(),_=Ie("div",{ref:i,className:`${Zt} p-4`,"data-event-detail-panel":"true","data-event-id":n.id,style:{top:`${o.top}px`,left:`${o.left}px`,zIndex:9999,pointerEvents:"auto"},children:[Ie("div",{style:Z}),Ie("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:x("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-${w.id}`,name:"title",type:"text",value:w.title,readOnly:!A||E,disabled:!A||E,onChange:e=>N(Object.assign(Object.assign({},w),{title:e.target.value})),onInput:e=>N(Object.assign(Object.assign({},w),{title:e.target.value})),className:"df-focus-ring w-full rounded-lg border border-slate-200 px-3 py-1.5 text-sm text-gray-900 shadow-sm transition focus:ring-2 focus:outline-none disabled:opacity-50 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100"})}),A&&Ie(Bn,{options:O,value:w.calendarId||"blue",disabled:E,onChange:e=>{N(Object.assign(Object.assign({},w),{calendarId:e}))},registry:null==f?void 0:f.getCalendarRegistry()})]}),Ie("div",j?{className:"mb-3",children:[Ie("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:x("dateRange")}),Ie(Wn,{value:[w.start,w.end],format:"YYYY-MM-DD",showTime:!1,timeZone:R,matchTriggerWidth:!0,disabled:!A||E,onChange:e=>{if(E)return;const[t,n]=e;N(Object.assign(Object.assign({},w),{start:t.toPlainDate(),end:n.toPlainDate()}))},locale:null==f?void 0:f.state.locale})]}:{className:"mb-3",children:[Ie("div",{className:"mb-1 text-xs text-gray-600 dark:text-gray-300",children:x("timeRange")}),Ie(Wn,{value:[w.start,w.end],timeZone:R,disabled:!A||E,onChange:e=>{if(E)return;const[t,n]=e;N(Object.assign(Object.assign({},w),{start:t,end:n}))},locale:null==f?void 0:f.state.locale})]}),Y&&Ie("div",{className:"mb-3",children:[Ie("span",{className:"mb-1 block text-xs text-gray-600 dark:text-gray-300",children:x("note")}),Ie("textarea",{id:`event-note-${w.id}`,name:"note",value:null!==(v=w.description)&&void 0!==v?v:"",readOnly:!A||E,disabled:!A||E,onChange:e=>N(Object.assign(Object.assign({},w),{description:e.target.value})),onInput:e=>N(Object.assign(Object.assign({},w),{description:e.target.value})),rows:3,className:"df-focus-ring w-full resize-none rounded-lg border border-slate-200 px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:ring-2 focus:outline-none disabled:opacity-50 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100",placeholder:x("addNotePlaceholder")})]}),A&&Ie("div",{className:"flex space-x-2",children:[Ie(Ln,j?{type:"button",className:"df-fill-primary df-hover-primary-solid rounded px-2 py-1 text-xs font-medium transition",onClick:()=>{var e;if(E)return;const n=m(w.start)?w.start:w.start.toPlainDate(),r=null!==(e=null==f?void 0:f.timeZone)&&void 0!==e?e:t.Temporal.Now.timeZoneId(),a=t.Temporal.ZonedDateTime.from({year:n.year,month:n.month,day:n.day,hour:9,minute:0,timeZone:r}),o=t.Temporal.ZonedDateTime.from({year:n.year,month:n.month,day:n.day,hour:10,minute:0,timeZone:r});N(Object.assign(Object.assign({},w),{allDay:!1,start:a,end:o}))},loading:E,children:x("setAsTimed")}:{type:"button",className:"df-fill-primary df-hover-primary-solid rounded px-2 py-1 text-xs font-medium transition",onClick:()=>{if(E)return;const e=m(w.start)?w.start:w.start.toPlainDate(),t=m(w.end)?w.end:w.end.toPlainDate();N(Object.assign(Object.assign({},w),{allDay:!0,start:e,end:t}))},loading:E,children:x("setAsAllDay")}),Ie(Ln,{type:"button",className:"df-fill-destructive df-hover-destructive rounded px-2 py-1 text-xs font-medium transition",onClick:()=>e.__awaiter(void 0,void 0,void 0,function*(){if(!E){S.current=!0,C(!0);try{yield h(w.id)}finally{C(!1)}}}),loading:E,children:x("delete")})]})]});if("undefined"==typeof window||"undefined"==typeof document)return null;const z=document.body;return z?r.createPortal(_,z):null},Rr=({event:e,position:t,panelRef:n,isAllDay:a,eventVisibility:o,calendarRef:i,selectedEventElementRef:l,onEventUpdate:s,onEventDelete:d,onClose:c,contentRenderer:u})=>{const{effectiveTheme:h}=In(),g=_e(h),m="dark"===g?"#1f2937":"white",f="dark"===g?"rgb(55, 65, 81)":"rgb(229, 231, 235)",p=(()=>{var e;let r={};if("sticky-top"===o){const n=null===(e=i.current)||void 0===e?void 0:e.querySelector(".df-calendar-content");if(n){const e=n.getBoundingClientRect().top+3-t.top;r=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:m,transform:"rotate(45deg)",transformOrigin:"center",top:e-6+"px",borderRight:""+(t.isSunday?`1px solid ${f}`:"none"),borderTop:""+(t.isSunday?`1px solid ${f}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${f}`),borderBottom:""+(t.isSunday?"none":`1px solid ${f}`)},t.isSunday?{right:"-6px"}:{left:"-6px"})}}else if("sticky-bottom"===o){const e=n.current;let a=200;if(e){const t=e.getBoundingClientRect(),n=window.getComputedStyle(e),r=Number.parseInt(n.paddingBottom,10)||0,o=Number.parseInt(n.borderBottomWidth,10)||0;a=t.height-r-o-6+11}r={position:"absolute",width:"12px",height:"12px",backgroundColor:m,transform:"rotate(45deg)",transformOrigin:"center",top:`${a}px`,left:t.isSunday?void 0:"-6px",right:t.isSunday?"-6px":void 0,borderRight:""+(t.isSunday?`1px solid ${f}`:"none"),borderTop:""+(t.isSunday?`1px solid ${f}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${f}`),borderBottom:""+(t.isSunday?"none":`1px solid ${f}`)}}else if(t&&l.current&&i.current){const e=l.current.getBoundingClientRect(),a=i.current.querySelector(".df-calendar-content");if(a){const o=a.getBoundingClientRect(),i=Math.max(e.top,o.top),l=Math.min(e.bottom,o.bottom),s=Math.max(0,l-i);let d;d=s===e.height?e.top+e.height/2:s>0?i+s/2:e.top+e.height/2;const c=d-t.top,u=n.current;let h=228;if(u){const e=u.getBoundingClientRect(),t=window.getComputedStyle(u),n=Number.parseInt(t.paddingBottom,10)||0,r=Number.parseInt(t.borderBottomWidth,10)||0;h=e.height-n-r+11}const g=12,p=Math.max(g,Math.min(h,c));r=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:m,transform:"rotate(45deg)",transformOrigin:"center",top:p-6+"px",borderRight:""+(t.isSunday?`1px solid ${f}`:"none"),borderTop:""+(t.isSunday?`1px solid ${f}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${f}`),borderBottom:""+(t.isSunday?"none":`1px solid ${f}`)},t.isSunday?{right:"-6px"}:{left:"-6px"})}}return r})(),v=Ie("div",{ref:n,className:`${Zt} 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:p}),Ie(u,{event:e,isAllDay:a,onEventUpdate:s,onEventDelete:d,onClose:c})]});return r.createPortal(v,document.body)},Or=({showDetailPanel:e,customEventDetailDialog:t,detailPanelPosition:n,event:r,detailPanelRef:a,isAllDay:o,eventVisibility:i,calendarRef:l,selectedEventElementRef:s,onEventUpdate:d,onEventDelete:c,handlePanelClose:u,customRenderingStore:h,contentSlotRenderer:g,customDetailPanelContent:m,app:f})=>{if(!e)return null;if(t)return null;if(!n)return null;const p={event:r,position:n,panelRef:a,isAllDay:o,eventVisibility:i,calendarRef:l,selectedEventElementRef:s,onEventUpdate:d,onEventDelete:c,onClose:u};return(null==h?void 0:h.isOverridden("eventDetailContent"))?Ie(Rr,Object.assign({},p,{contentRenderer:g})):m?Ie(Rr,Object.assign({},p,{contentRenderer:m})):Ie(Ir,Object.assign({},p,{app:f}))},Hr=(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},Ar=(e,t,n,r,a)=>{let o="df-event calendar-event select-none pointer-events-auto";const i=e===exports.ViewType.DAY,l=e===exports.ViewType.MONTH,s=e===exports.ViewType.YEAR;i?o+=" df-day-event flex flex-col":l||s?s&&(o+=" df-year-event transition-colors group px-1 overflow-hidden whitespace-nowrap cursor-pointer"):o+=" df-week-event flex flex-col";const d=()=>{if(n&&r){const{segmentType:e}=r;if("single"===e||"start"===e)return Ot;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 Ot};if(s)return`${o} ${(()=>{if(a){const{isFirstSegment:e,isLastSegment:t}=a;return e&&t?"rounded":e?"rounded-l rounded-r-none":t?"rounded-r rounded-l-none":"rounded-none"}return"rounded"})()}`;if(l){let e=`\n ${o}\n ${t?d():Ht}\n `;return n||(e+=" mb-[2px] last:mb-0"),e}return`\n ${o}\n shadow-sm\n ${t?d():Ht}\n `},Pr="transform 0.5s cubic-bezier(0.22, 1, 0.36, 1)",Lr=({event:e,layout:t,isAllDay:r=!1,allDayHeight:o=28,calendarRef:i,isBeingDragged:l=!1,isBeingResized:s=!1,viewType:d,isMultiDay:c=!1,segment:u,yearSegment:h,columnsPerRow:g,segmentIndex:m=0,hourHeight:f,firstHour:p,selectedEventId:v,detailPanelEventId:y,onMoveStart:b,onResizeStart:x,onEventUpdate:w,onEventDelete:D,newlyCreatedEventId:C,onDetailPanelOpen:T,onEventSelect:k,onEventLongPress:S,onDetailPanelToggle:M,customDetailPanelContent:N,customEventDetailDialog:I,multiDaySegmentInfo:R,app:P,isMobile:L=!1,isSlidingView:$=!1,enableTouch:j,hideTime:Y,timeFormat:F="24h",styleOverride:V,className:Z,disableDefaultStyle:_=!1,renderVisualContent:z,resizeHandleOrientation:W,appTimeZone:B})=>{var G;const K=a.useContext(Rn),q=null!=j?j:L,X=d===exports.ViewType.YEAR,Q=a.useMemo(()=>{if(!B||e.allDay)return e;const t=U(e.start,B),n=e.end?U(e.end,B):void 0;return Object.assign(Object.assign({},e),{start:t,end:n})},[e,B]),[ee,te]=a.useState(null),[ne,re]=a.useState(!1),ae=a.useRef(null),oe=a.useRef(null),ie=a.useRef(null),le=a.useRef(null),se=c&&u?`${e.id}::${u.id}`:void 0===(null==R?void 0:R.dayIndex)?X&&h?h.id:e.id:`${e.id}::day-${R.dayIndex}`,de=y===se,ce=de&&!I,ue=null==P?void 0:P.getReadOnlyConfig(e.id),he=null!==(G=null==P?void 0:P.canMutateFromUI(e.id))&&void 0!==G&&G,ge=!1!==(null==ue?void 0:ue.viewable),me=!1!==(null==ue?void 0:ue.draggable),{isSelected:fe,setIsSelected:pe,isPressed:ve,setIsPressed:ye,handleTouchStart:be,handleTouchMove:xe,handleTouchEnd:we}=(({event:e,isTouchEnabled:t,onMoveStart:n,onEventLongPress:r,onDetailPanelToggle:o,canOpenDetail:i,app:l,multiDaySegmentInfo:s,isMultiDay:d,segment:c,detailPanelKey:u})=>{const[h,g]=a.useState(!1),[m,f]=a.useState(!1),p=a.useRef(null),v=a.useRef(null);return{isSelected:h,setIsSelected:g,isPressed:m,setIsPressed:f,handleTouchStart:a=>{if(!n||!t)return;f(!0);const o=a.touches[0],i=o.clientX,l=o.clientY,u=a.currentTarget;v.current={x:i,y:l},p.current=setTimeout(()=>{var t;r?r(e.id):g(!0);const a={preventDefault:()=>{},stopPropagation:()=>{},currentTarget:u,touches:[{clientX:i,clientY:l}],cancelable:!1};if(s){const r=Object.assign(Object.assign({},e),{day:null!==(t=s.dayIndex)&&void 0!==t?t:e.day,_segmentInfo:s});n(a,r)}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(a,t)}else n(a,e);p.current=null,v.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},handleTouchMove:e=>{if(p.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(p.current),p.current=null,v.current=null,f(!1))}},handleTouchEnd:n=>{f(!1),p.current&&(clearTimeout(p.current),p.current=null),t&&v.current&&(n.preventDefault(),n.stopPropagation(),l&&l.onEventClick(e),i?null==o||o(u):null==o||o(null)),v.current=null}}})({event:e,isTouchEnabled:q,onMoveStart:b,onEventLongPress:S,onDetailPanelToggle:M,canOpenDetail:ge,app:P,multiDaySegmentInfo:R,isMultiDay:c,segment:u,detailPanelKey:se}),[De,Ee]=a.useState("visible"),Ce=e=>{le.current=e},Te=a.useCallback(()=>((e,t,n,r,a,o)=>{var i;if(null!==r)return r;if(t===n){const e=n.split("::").at(-1);if(e&&e.startsWith("day-")){const t=Number(e.replace("day-",""));if(!Number.isNaN(t))return t}}return void 0!==(null==a?void 0:a.dayIndex)?a.dayIndex:o?o.startDayIndex:null!==(i=e.day)&&void 0!==i?i:0})(e,y||void 0,se,le.current,R,u),[e,y,se,R,u]),ke=a.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=Hr(t,r),i=n===exports.ViewType.DAY?1:7,l=(a.width-o)/i,s=e-a.left-o,d=Math.floor(s/l);return Number.isFinite(d)?Math.max(0,Math.min(i-1,d)):null})(e,i,d,L),[i,d,L]),Se=a.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=Hr(t,r);if(n===exports.ViewType.DAY){const e=a.width-o;return{left:a.left+o,width:e}}const i=(a.width-o)/7;return{left:a.left+o+e*i,width:i}})(e,i,d,L),[i,d,L]),{detailPanelPosition:Me,setDetailPanelPosition:Ne,updatePanelPosition:Re}=(({event:e,viewType:t,isMultiDay:n,segment:r,yearSegment:o,multiDaySegmentInfo:i,calendarRef:l,eventRef:s,detailPanelRef:d,selectedEventElementRef:c,isMobile:u,eventVisibility:h,firstHour:g,hourHeight:m,columnsPerRow:f,showDetailPanel:p,detailPanelEventId:v,detailPanelKey:y,getActiveDayIdx:b,getDayMetricsWrapper:x})=>{const[w,D]=a.useState(null),E=t===exports.ViewType.DAY,C=t===exports.ViewType.MONTH,T=t===exports.ViewType.YEAR,k=a.useCallback(()=>{if(!c.current||!l.current||!d.current)return;const e=l.current.getBoundingClientRect(),t=b(),a=x(t);let o,i;if(a)o=a.left,i=a.width;else if(C)i=e.width/7,o=e.left+t*i;else{const n=Hr(l,u);i=(e.width-n)/7,o=e.left+n+t*i}const g=Math.min(window.innerWidth,e.right),m=Math.min(window.innerHeight,e.bottom);requestAnimationFrame(()=>{var a,i,l;if(!d.current)return;if(!c.current)return;const u=d.current.getBoundingClientRect(),f=u.width,p=u.height;let v,y,b;if("sticky-top"===h||"sticky-bottom"===h){const e=null===(a=s.current)||void 0===a?void 0:a.getBoundingClientRect();if(!e)return;b=e}else b=c.current.getBoundingClientRect();if(C&&n&&r){const n=x(t),r=null!==(i=null==n?void 0:n.width)&&void 0!==i?i:e.width/7,a=null!==(l=null==n?void 0:n.left)&&void 0!==l?l: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>=f+20?b.right+10:E>=f+20?b.left-f-10:w>E?Math.max(e.left+10,g-f-10):e.left+10;const k=b.top-p/2+b.height/2,S=Math.max(10,e.top+10),M=m-10;y=k<S?S:k+p>M?M-p: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})})})},[l,e.day,e.start,e.end,h,C,g,m,n,r,i,v,y,u,E,T,o,f,b,x,c,d,s]);return a.useEffect(()=>{!p||w||u||(D({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>k()))},[p,w,k,u]),{detailPanelPosition:w,setDetailPanelPosition:D,updatePanelPosition:k}})({event:e,viewType:d,isMultiDay:c,segment:u,yearSegment:h,multiDaySegmentInfo:R,calendarRef:i,eventRef:ae,detailPanelRef:oe,selectedEventElementRef:ie,isMobile:L,eventVisibility:De,firstHour:p,hourHeight:f,columnsPerRow:g,showDetailPanel:de,detailPanelEventId:y,detailPanelKey:se,getActiveDayIdx:Te,getDayMetricsWrapper:Se}),{handleClick:Oe,handleDoubleClick:He,handleContextMenu:Ae,hasPendingSelection:Pe}=(({event:e,timingEvent:t,viewType:n,isAllDay:r,isMultiDay:o,segment:i,multiDaySegmentInfo:l,calendarRef:s,firstHour:d,hourHeight:c,isMobile:u,canOpenDetail:h,detailPanelKey:g,app:m,onEventSelect:f,onDetailPanelToggle:p,setIsSelected:v,setDetailPanelPosition:y,setContextMenuPosition:b,setActiveDayIndex:x,getClickedDayIdx:w,updatePanelPosition:D,selectedEventElementRef:C})=>{const T=n===exports.ViewType.MONTH,k=n===exports.ViewType.YEAR,S=null!=t?t:e,M=a.useRef(null),[N,I]=a.useState(!1),R=a.useCallback(()=>{M.current&&(clearTimeout(M.current),M.current=null,I(!1))},[]);a.useEffect(()=>()=>R(),[R]);const O=a.useCallback(()=>new Promise(e=>{if(!s.current||r||T||k)return void e();const t=s.current.querySelector(".df-calendar-content");if(!t)return void e();const n=l?l.startHour:E(S.start),a=l?l.endHour:J(S),o=(n-d)*c,i=o+Math.max((a-n)*c,c/4),u=t.scrollTop,h=t.clientHeight;if(o>=u&&i<=u+h)return void e();const g=((n+a)/2-d)*c-h/2,m=t.scrollHeight-h;t.scrollTo({top:Math.max(0,Math.min(m,g)),behavior:"smooth"}),setTimeout(()=>e(),300)}),[s,r,T,k,l,S.start,S.end,d,c]),H=a.useCallback(t=>{R(),t.preventDefault(),t.stopPropagation(),m&&!m.canMutateFromUI(e.id)||(f&&f(e.id),b({x:t.clientX,y:t.clientY}))},[m,R,e.id,f,b]),A=a.useCallback(t=>{var n,r,a;if(o){const a=w(t);x(null===a?null!==(r=null!==(n=null==l?void 0:l.dayIndex)&&void 0!==n?n:e.day)&&void 0!==r?r:null:i?Math.min(Math.max(a,i.startDayIndex),i.endDayIndex):a)}else x(null!==(a=e.day)&&void 0!==a?a:null);m&&m.onEventClick(e),f?f(e.id):h&&v(!0),null==p||p(null),y(null)},[o,w,x,null==l?void 0:l.dayIndex,e,i,m,f,h,v,p,y]),P=a.useCallback(t=>{var n,r,a,l,s;if(R(),t.preventDefault(),t.stopPropagation(),!h)return;let d=t.currentTarget;if(o){const e=d.querySelector("div");e&&(d=e)}if(C.current=d,o){const o=w(t.clientX);x(null===o?null!==(r=null!==(n=null==i?void 0:i.startDayIndex)&&void 0!==n?n:e.day)&&void 0!==r?r:0:Math.min(Math.max(o,null!==(a=null==i?void 0:i.startDayIndex)&&void 0!==a?a:0),null!==(l=null==i?void 0:i.endDayIndex)&&void 0!==l?l:6))}else x(null!==(s=e.day)&&void 0!==s?s:null);O().then(()=>{v(!0),null==f||f(e.id),u||(null==p||p(g),y({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>D()))})},[R,h,o,C,w,x,null==i?void 0:i.startDayIndex,null==i?void 0:i.endDayIndex,e.day,O,v,k,u,p,g,y,D]);return{handleClick:a.useCallback(e=>{e.preventDefault(),e.stopPropagation();const t=e.clientX;if(k&&!u)return R(),I(!0),void(M.current=setTimeout(()=>{A(t),M.current=null,I(!1)},180));A(t)},[R,k,u,A]),handleDoubleClick:P,handleContextMenu:H,hasPendingSelection:N,scrollEventToCenter:O}})({event:e,timingEvent:Q,viewType:d,isAllDay:r,isMultiDay:c,segment:u,multiDaySegmentInfo:R,calendarRef:i,firstHour:p,hourHeight:f,isMobile:L,canOpenDetail:ge,detailPanelKey:se,app:P,onEventSelect:k,onDetailPanelToggle:M,setIsSelected:pe,setDetailPanelPosition:Ne,setContextMenuPosition:te,setActiveDayIndex:Ce,getClickedDayIdx:ke,updatePanelPosition:Re,selectedEventElementRef:ie}),Le=(void 0===v?fe:v===e.id)||Pe||!q&&ve||l,{calculateEventStyle:$e}=(({event:e,timingEvent:t,layout:n,isAllDay:r,allDayHeight:a,viewType:o,isMultiDay:i,segment:l,yearSegment:s,columnsPerRow:d,segmentIndex:c,hourHeight:u,firstHour:h,isEventSelected:g,showDetailPanel:m,isPopping:f,isDraggable:p,canOpenDetail:v,eventVisibility:y,calendarRef:b,isMobile:x,eventRef:w,getActiveDayIdx:D,getDayMetricsWrapper:C,multiDaySegmentInfo:T})=>{const k=o===exports.ViewType.DAY,S=o===exports.ViewType.MONTH,M=o===exports.ViewType.YEAR,N=null!=t?t:e;return{calculateEventStyle:()=>{var e,t,o,I,R,O,H,A;if(M&&s&&d){const{startCellIndex:e,endCellIndex:t,visualRowIndex:n}=s,r=2;return{position:"absolute",left:`calc(${e/d*100}% + ${r}px)`,top:18*n+"px",width:`calc(${(t-e+1)/d*100}% - ${2*r}px)`,height:"16px",opacity:1,zIndex:g||m?1e3:1,transform:f?"scale(1.05)":"scale(1)",transition:Pr,cursor:p||v?"pointer":"default"}}if(S)return i&&l?{opacity:1,zIndex:g||m?1e3:1,cursor:p||v?"pointer":"default"}:{opacity:1,zIndex:g||m?1e3:1,transform:f?"scale(1.05)":"scale(1)",transition:Pr,cursor:p||v?"pointer":"default"};if(r){const e={height:a-4+"px",opacity:1,zIndex:g||m?1e3:1,transform:f?"scale(1.05)":"scale(1)",transition:Pr,cursor:p||v?"pointer":"default"},t=c*a;if(Object.assign(e,{top:`${t}px`}),k)Object.assign(e,{width:"100%",left:"0px",right:"2px",position:"absolute"});else if(i&&l){const t=d||7,n=(l.endDayIndex-l.startDayIndex+1)/t*100,r=l.startDayIndex/t*100,a=2,o=l.isFirstSegment?a:0,i=o+(l.isLastSegment?a:0);Object.assign(e,{width:i>0?`calc(${n}% - ${i}px)`:`${n}%`,left:o>0?`calc(${r}% + ${o}px)`:`${r}%`,position:"absolute",pointerEvents:"auto"})}else Object.assign(e,{width:"100%",left:"0px",position:"relative"});return e}const P=T?T.startHour:E(N.start),L=T?T.endHour:J(N),$={top:(P-h)*u+3+"px",height:Math.max((L-P)*u,u/4)-4+"px",position:"absolute",opacity:1,zIndex:g||m?1e3:null!==(e=null==n?void 0:n.zIndex)&&void 0!==e?e:1,transform:f?"scale(1.05)":"scale(1)",transition:Pr,cursor:p||v?"pointer":"default"};if(g&&m&&("sticky-top"===y||"sticky-bottom"===y)){const e=null===(t=b.current)||void 0===t?void 0:t.getBoundingClientRect();if(e){const t=D(),r=Hr(b,x),a=k?1:d||7;let i=(e.width-r)/a,l=e.left+r+(k?0:t*i);S&&(i=e.width/7,l=e.left+t*i);const s=C(t);s&&(l=s.left,i=s.width);let c=null===(o=b.current)||void 0===o?void 0:o.querySelector(".df-calendar-content");c||(c=null===(I=b.current)||void 0===I?void 0:I.querySelector(".calendar-renderer"));const u=null==c?void 0:c.getBoundingClientRect(),h=null===(O=null===(R=w.current)||void 0===R?void 0:R.parentElement)||void 0===O?void 0:O.getBoundingClientRect();let g,m;if(h&&h.width>0)n?(g=h.left+n.left/100*h.width,m=k?n.width/100*h.width:(n.width-1)/100*h.width):(g=h.left,m=k?h.width:h.width-3);else{const e=C(t),r=null!==(H=null==e?void 0:e.left)&&void 0!==H?H:l,a=null!==(A=null==e?void 0:e.width)&&void 0!==A?A:i;g=r,m=a-3,n&&(g=r+n.left/100*a,m=k?n.width/100*a:(n.width-1)/100*a)}if("sticky-top"===y){let t=u?u.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:`${g}px`,width:`${m}px`,height:"6px",zIndex:1e3,overflow:"hidden"}}let f=u?u.bottom:e.bottom;return f=Math.min(f,window.innerHeight),f=Math.min(f,e.bottom),f=Math.max(f,e.top+6),f=Math.max(f,6),{position:"fixed",top:f-6+"px",left:`${g}px`,width:`${m}px`,height:"6px",zIndex:1e3,overflow:"hidden"}}}if(n&&!r){const e=k?`${n.width}%`:n.width-1+"%";return Object.assign(Object.assign({},$),{left:`${n.left}%`,width:e,right:"auto"})}return Object.assign(Object.assign({},$),{left:"0px",right:k?"0px":"3px"})}}})({event:e,timingEvent:Q,layout:t,isAllDay:r,allDayHeight:o,viewType:d,isMultiDay:c,segment:u,yearSegment:h,columnsPerRow:g,segmentIndex:m,hourHeight:f,firstHour:p,isEventSelected:Le,showDetailPanel:de,isPopping:ne,isDraggable:me,canOpenDetail:ge,eventVisibility:De,calendarRef:i,isMobile:L,eventRef:ae,getActiveDayIdx:Te,getDayMetricsWrapper:Se,multiDaySegmentInfo:R});(({event:e,timingEvent:t,isEventSelected:n,showDetailPanel:r,eventRef:o,calendarRef:i,isAllDay:l,viewType:s,multiDaySegmentInfo:d,firstHour:c,hourHeight:u,updatePanelPosition:h,eventVisibility:g,setEventVisibility:m})=>{const f=s===exports.ViewType.MONTH,p=s===exports.ViewType.YEAR,v=null!=t?t:e,y=a.useCallback(()=>{if(!n||!r||!o.current||!i.current||l||f||p)return;const e=i.current.querySelector(".df-calendar-content");if(!e)return;const t=d?d.startHour:E(v.start),a=d?d.endHour:J(v),s=(t-c)*u,y=s+Math.max((a-t)*u,u/4),b=e.getBoundingClientRect(),x=e.scrollTop,w=x+b.height,D=b.bottom<0,C=b.top>window.innerHeight;let T=g;D?T="sticky-top":C?T="sticky-bottom":"visible"===g?y<x?T="sticky-top":s>w-20&&(T="sticky-bottom"):"sticky-top"===g?y>=x&&(T="visible"):"sticky-bottom"===g&&s<=w-20&&(T="visible"),T!==g&&m(T),h()},[n,r,i,l,f,v.start,v.end,c,u,h,d,g,m]);a.useEffect(()=>{var e,t;if(!n||!r||l)return;const a=null===(e=i.current)||void 0===e?void 0:e.querySelector(".df-calendar-content");if(!a)return;const o=()=>y(),s=()=>{y(),h()},d=[a];let c=null===(t=i.current)||void 0===t?void 0:t.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",o)}),window.addEventListener("scroll",o,!0),window.addEventListener("resize",s);let u=null;return i.current&&(u=new ResizeObserver(()=>{s()}),u.observe(i.current)),y(),()=>{d.forEach(e=>{e.removeEventListener("scroll",o)}),window.removeEventListener("scroll",o,!0),window.removeEventListener("resize",s),u&&u.disconnect()}},[n,r,l,y,h,i])})({event:e,timingEvent:Q,isEventSelected:Le,showDetailPanel:de,eventRef:ae,calendarRef:i,isAllDay:r,viewType:d,multiDaySegmentInfo:R,firstHour:p,hourHeight:f,updatePanelPosition:Re,eventVisibility:De,setEventVisibility:Ee});const je=de&&!!I;(({eventRef:e,detailPanelRef:t,eventId:n,isEventSelected:r,showDetailPanel:o,onEventSelect:i,onDetailPanelToggle:l,setIsSelected:s,setActiveDayIndex:d})=>{a.useEffect(()=>{if(!r&&!o)return;const a=a=>{var c,u;const h=a.target,g=null===(c=e.current)||void 0===c?void 0:c.contains(h),m=null!==h.closest(`[data-event-id="${n}"]`),f=null===(u=t.current)||void 0===u?void 0:u.contains(h),p=h.closest("[data-event-detail-dialog]"),v=h.closest("[data-range-picker-popup]"),y=h.closest("[data-calendar-picker-dropdown]");o?g||m||f||p||v||y||(null==i||i(null),d(null),s(!1),null==l||l(null)):!r||g||m||p||v||y||(null==i||i(null),d(null),s(!1),null==l||l(null))};return document.addEventListener("mousedown",a),()=>{document.removeEventListener("mousedown",a)}},[r,o,i,l,n])})({eventRef:ae,detailPanelRef:oe,eventId:e.id,isEventSelected:!je&&Le,showDetailPanel:ce,onEventSelect:k,onDetailPanelToggle:M,setIsSelected:pe,setActiveDayIndex:Ce});const Ye=a.useCallback(()=>{k&&k(null),le.current=null,pe(!1),null==M||M(null)},[k,M,pe]),Fe=a.useMemo(()=>({event:e,isAllDay:r,onEventUpdate:w,onEventDelete:D,onClose:Ye}),[e,r,w,D,Ye]),Ve=a.useMemo(()=>({event:e,viewType:d,isAllDay:r,isMobile:L,isSelected:Le,isDragging:l,segment:u,layout:t}),[e,d,r,L,Le,l,u,t]),Ze=a.useCallback(()=>Ie(Hn,{store:K,generatorName:"eventDetailContent",generatorArgs:Fe}),[K,Fe]);a.useEffect(()=>{if((null==P?void 0:P.state.highlightedEventId)===e.id){re(!0);const e=setTimeout(()=>{re(!1)},650);return()=>{clearTimeout(e),re(!1)}}},[null==P?void 0:P.state.highlightedEventId,e.id]),a.useEffect(()=>{he||te(null)},[he]),a.useEffect(()=>{const t=c&&(null==u?void 0:u.isFirstSegment)||X&&(null==h?void 0:h.isFirstSegment)||!c&&!X;C===e.id&&!de&&t&&setTimeout(()=>{null==M||M(se),null==T||T()},50)},[C,e.id,de,c,u,X,h,M,T,se]);const _e=e.calendarId||"blue",ze=null==P?void 0:P.getCalendarRegistry();return Ie(n.Fragment,{children:[Ie("div",{ref:ae,"data-event-id":e.id,className:`${Ar(d,r,c,u,h)} ${r&&C===e.id?"df-all-day-event-animate":""} ${null!=Z?Z:""}`,style:Object.assign(Object.assign(Object.assign({},_?{}:$e()),{backgroundColor:Le?A(_e,ze):O(_e,ze),color:Le?"#fff":H(_e,ze)}),V),onClick:Oe,onContextMenu:Ae,onDblClick:He,onMouseDown:t=>{var n;if(q||ye(!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:()=>!q&&ye(!1),onMouseLeave:()=>!q&&ye(!1),onTouchStart:be,onTouchMove:xe,onTouchEnd:we,children:Ie(Nr,{event:Q,viewType:d,isAllDay:r,isMultiDay:c,segment:u,yearSegment:h,segmentIndex:m,isBeingDragged:l,isBeingResized:s,isEventSelected:Le,isPopping:ne,isEditable:he,isDraggable:me,canOpenDetail:ge,isTouchEnabled:q,hideTime:Y,isMobile:L,isSlidingView:$,app:P,onMoveStart:b,onResizeStart:x,multiDaySegmentInfo:R,customRenderingStore:K,eventContentSlotArgs:Ve,timeFormat:F,appTimeZone:B,renderVisualContent:z,resizeHandleOrientation:W})}),de&&!I&&Ie("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:9998,pointerEvents:"none"}}),Ie(Or,{showDetailPanel:de,customEventDetailDialog:I,detailPanelPosition:Me,event:e,detailPanelRef:oe,isAllDay:r,eventVisibility:De,calendarRef:i,selectedEventElementRef:ie,onEventUpdate:w,onEventDelete:D,handlePanelClose:Ye,customRenderingStore:K,contentSlotRenderer:Ze,customDetailPanelContent:N,app:P}),ee&&P&&he&&Ie(br,{event:e,x:ee.x,y:ee.y,onClose:()=>te(null),app:P,onDetailPanelToggle:M,detailPanelKey:se})]})},$r=({handlePreviousMonth:e,handleToday:t,handleNextMonth:n})=>{const{t:r}=bt();return Ie("div",{className:"df-navigation flex items-center gap-1",children:[Ie("button",{type:"button",className:Ft,onClick:e,"aria-label":"Previous month",children:Ie(en,{className:Vt})}),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:Ft,onClick:n,"aria-label":"Next month",children:Ie(tn,{className:Vt})})]})},jr=({viewType:e,currentDate:t,onPrevious:n,onNext:r,onToday:a,customTitle:o,customSubtitle:i,showTodayBox:l,stickyYear:s,stickyYearOffset:d=0,nextYear:c,nextYearOffset:u=0})=>{const{locale:h}=bt(),g=void 0===l||l,m=o||(()=>{switch(e){case"day":return t.toLocaleDateString(h,{day:"numeric",month:"long",year:"numeric"});case"week":case"month":return t.toLocaleDateString(h,{month:"long",year:"numeric"});case"year":return t.getFullYear().toString();default:return""}})(),f="day"===e?i||("day"===e?t.toLocaleDateString(h,{weekday:"long"}):null):null;return Ie("div",{className:wt,style:{position:"relative"},onContextMenu:e=>e.preventDefault(),children:[Ie("div",{className:"flex-1",children:Ie("div","year"===e&&s?{style:{position:"relative",overflow:"hidden",height:"1.5em"},children:[Ie("h1",{className:Dt,style:{position:"absolute",top:0,left:0,transform:`translateY(-${d}px)`,willChange:"transform"},children:s}),c&&Ie("h1",{className:Dt,style:{position:"absolute",top:0,left:0,transform:`translateY(${u}px)`,willChange:"transform"},children:c})]}:{children:[Ie("div",{className:`${Dt} text-gray-900 dark:text-white`,children:m}),f&&Ie("div",{className:"mt-3 leading-6 text-gray-600 dark:text-gray-400",children:f})]})}),g&&n&&r&&a&&Ie("div",{className:"flex items-center gap-2",children:Ie($r,{handlePreviousMonth:n,handleNextMonth:r,handleToday:a})})]})};function Yr(e,t,n,r,a){if(r||0!==e.button)return;let o=!0;const i={move(r){if(!o)return;Math.hypot(r.clientX-e.clientX,r.clientY-e.clientY)>=5&&(o=!1,document.removeEventListener("mousemove",i.move),document.removeEventListener("mouseup",i.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",i.move),document.removeEventListener("mouseup",i.up)}};document.addEventListener("mousemove",i.move),document.addEventListener("mouseup",i.up)}function Fr(){document.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0,cancelable:!1}))}const Vr=({app:e,currentDate:t,currentWeekStart:n,events:r,currentDayEvents:o,organizedAllDayEvents:i,allDayAreaHeight:l,timeSlots:s,eventLayouts:d,isToday:c,currentTime:u,selectedEventId:h,setSelectedEventId:g,newlyCreatedEventId:m,setNewlyCreatedEventId:f,detailPanelEventId:p,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:O,customEventDetailDialog:H,calendarRef:A,allDayRowRef:P,timeGridRef:L,switcherMode:$,isMobile:j,isTouch:Y,setDraftEvent:F,setIsDrawerOpen:V,ALL_DAY_HEIGHT:Z,HOUR_HEIGHT:_,FIRST_HOUR:z,LAST_HOUR:U,showAllDay:W,showStartOfDayLabel:B,timeFormat:G="24h",secondaryTimeSlots:K,primaryTzLabel:q,secondaryTzLabel:J,appTimeZone:Q})=>{var ee;const te=!!K&&K.length>0&&!j,{t:ne}=bt(),re=a.useRef(e.state.highlightedEventId),[ae,oe]=a.useState(null),ie=a.useMemo(()=>Ze(),[]),le=()=>{var e;const t=null===(e=A.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=A.current)||void 0===t?void 0:t.querySelector(".df-calendar-content");if(!n)return null;const r=n.getBoundingClientRect(),a=n.scrollTop||0;return z+(e-r.top+a-le())/_},de=e.canMutateFromUI();a.useEffect(()=>{de||oe(null)},[de]);const ce=(e,n)=>{var r,a,o,i;if(e.preventDefault(),j||!de)return;const l=new Date(t);if(n)l.setHours(0,0,0,0);else{const t=null===(a=null===(r=A.current)||void 0===r?void 0:r.querySelector(".df-calendar-content"))||void 0===a?void 0:a.getBoundingClientRect();if(t){const n=(null===(i=null===(o=A.current)||void 0===o?void 0:o.querySelector(".df-calendar-content"))||void 0===i?void 0:i.scrollTop)||0,r=le(),a=(e.clientY-t.top+n-r)/_+z,s=Math.floor(a),d=Math.floor(60*(a-s)),c=15*Math.round(d/15),u=60===c?s+1:s,h=60===c?0:c;l.setHours(u,h,0,0)}}oe({x:e.clientX,y:e.clientY,date:l})};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 ${Xt} h-full`,children:[Ie("div",{onContextMenu:e=>e.preventDefault(),style:{paddingRight:j||!ie?"0px":"15px"},children:Ie(jr,{calendar:e,viewType:exports.ViewType.DAY,currentDate:t})}),Ie("div",W?{className:Qt(Rt,"relative items-stretch border-t border-gray-200 dark:border-gray-700"),ref:P,style:{paddingRight:j||!ie?"0px":"0.6875rem"},onContextMenu:e=>ce(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:ne("allDay")}),Ie("div",{className:Qt("relative flex flex-1 self-stretch",!j&&ie?"border-r border-gray-200 dark:border-gray-700":""),children:Ie("div",{className:"relative w-full",style:{minHeight:`${l}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:i.map(t=>Ie(Lr,{event:t,isAllDay:!0,viewType:exports.ViewType.DAY,segmentIndex:t.row,allDayHeight:Z,calendarRef:A,isBeingDragged:b&&(null==y?void 0:y.eventId)===t.id&&"move"===(null==y?void 0:y.mode),hourHeight:_,firstHour:z,onMoveStart:x,onEventUpdate:N,onEventDelete:I,newlyCreatedEventId:m,onDetailPanelOpen:()=>f(null),detailPanelEventId:p,onDetailPanelToggle:e=>v(e),selectedEventId:h,onEventSelect:t=>{const n=e.getReadOnlyConfig().viewable,a=e.canMutateFromUI(),o=r.find(e=>e.id===t);(j||Y)&&o&&n&&a?(F(o),V(!0)):(g(t),e.state.highlightedEventId&&(e.highlightEvent(null),re.current=null))},onEventLongPress:e=>{(j||Y)&&g(e)},customDetailPanelContent:O,customEventDetailDialog:H,app:e,isMobile:j,enableTouch:Y,appTimeZone:Q},t.id))})})]}:{className:!j&&ie?"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<z||t>U)return null;return Ie("div",{className:Nt,style:{top:`${(t-z)*_}px`,width:"100%",height:0,zIndex:20,marginTop:te?"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:It,children:X(t,0,G,!1)})]}),Ie("div",{className:"flex flex-1 items-center",children:Ie("div",{className:"df-current-time-bar h-0.5 w-full df-fill-primary relative"})})]})})(),Ie("div",{className:"df-time-column flex-shrink-0 "+(te?"w-20 md:w-22":"w-12 md:w-20"),onContextMenu:e=>e.preventDefault(),children:[Ie("div",{className:te?"h-8":"h-3",children:te&&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:q})]})}),s.map((e,t)=>{var n;return Ie("div",{className:kt,children:Ie("div",te?{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:B&&0===t?"":null!==(n=null==K?void 0:K[t])&&void 0!==n?n:""}),Ie("span",{className:"text-[10px] text-gray-500 md:text-[12px] dark:text-gray-400",children:B&&0===t?"":e.label})]}:{className:`${St} text-[10px] md:text-[12px]`,children:B&&0===t?"":e.label})},t)})]}),Ie("div",{className:"grow select-none",children:[Ie("div",{className:Qt(zt,!j&&ie?"border-r":"","border-t-0"),style:te?{height:"2rem"}:void 0,children:Ie("div",{className:`${Ut} -left-9.5`,style:{top:"auto",bottom:"-0.625rem"},children:B?X(z,0,G):""})}),Ie("div",{className:"relative",style:{WebkitTouchCallout:"none"},ref:L,children:[s.map((e,r)=>Ie("div",{className:Qt(Mt,!j&&ie?"border-r":""),onClick:()=>null==R?void 0:R(t),onMouseDown:e=>{const r=se(e.clientY);if(null===r)return;Yr(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),Fr()},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 i=null===(r=null===(n=A.current)||void 0===n?void 0:n.querySelector(".df-calendar-content"))||void 0===r?void 0:r.getBoundingClientRect();if(!i)return;const l=(null===(o=null===(a=A.current)||void 0===a?void 0:a.querySelector(".df-calendar-content"))||void 0===o?void 0:o.scrollTop)||0,s=le(),d=e.clientY-i.top+l-s,c=Math.floor(z+d/_);M(e,t,c)},onContextMenu:e=>ce(e,!1)},r)),Ie("div",{className:Qt(zt,!j&&ie?"border-r":""),children:Ie("div",te?{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!==(ee=null==K?void 0:K[0])&&void 0!==ee?ee:""}),Ie("span",{children:X(0,0,G)})]}:{className:`${Ut} -left-9.5`,children:X(0,0,G)})}),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(Lr,{event:t,layout:n,viewType:exports.ViewType.DAY,calendarRef:A,isBeingDragged:b&&(null==y?void 0:y.eventId)===t.id&&"move"===(null==y?void 0:y.mode),hourHeight:_,firstHour:z,onMoveStart:x,onResizeStart:w,onEventUpdate:N,onEventDelete:I,newlyCreatedEventId:m,onDetailPanelOpen:()=>f(null),detailPanelEventId:p,onDetailPanelToggle:e=>v(e),selectedEventId:h,onEventSelect:t=>{const n=e.getReadOnlyConfig().viewable,a=r.find(e=>e.id===t);(j||Y)&&a&&n?(F(a),V(!0)):(g(t),e.state.highlightedEventId&&(e.highlightEvent(null),re.current=null))},onEventLongPress:e=>{(j||Y)&&g(e)},customDetailPanelContent:O,customEventDetailDialog:H,app:e,isMobile:j,enableTouch:Y,appTimeZone:Q},t.id)})})]})]})]})})]}),de&&ae&&Ie(yr,{x:ae.x,y:ae.y,date:ae.date,viewType:exports.ViewType.DAY,onClose:()=>oe(null),app:e,onCreateEvent:()=>{if(D){const e=Math.floor((t.getTime()-n.getTime())/864e5);if(0===ae.date.getHours()&&0===ae.date.getMinutes())null==E||E({clientX:ae.x,clientY:ae.y},e);else{const t=ae.date.getHours()+ae.date.getMinutes()/60,n={preventDefault:()=>{},stopPropagation:()=>{},clientX:ae.x,clientY:ae.y};D(n,e,t)}}}})]})},Zr=({app:e,currentDate:t,visibleMonth:n,currentDayEvents:r,selectedEvent:a,setSelectedEvent:o,handleMonthChange:i,handleDateSelect:l,switcherMode:s,timeFormat:d="24h",showEventDots:c=!0,appTimeZone:u})=>{const{t:h,locale:g}=bt(),m=[...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:`${Xt} 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:wt,style:{position:"relative"},children:Ie("div",{children:Ie("h1",{className:Dt,children:" "})})}),Ie($r,{handlePreviousMonth:()=>e.goToPrevious(),handleNextMonth:()=>e.goToNext(),handleToday:()=>e.goToToday()})]}),Ie(Xn,{visibleMonth:n,currentDate:t,showHeader:!0,onMonthChange:i,onDateSelect:l,events:e.getEvents(),showEventDots:c,calendarRegistry:e.getCalendarRegistry(),timeZone:e.timeZone})]})}),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(g,{weekday:"long",month:"long",day:"numeric"})}),0===m.length?Ie("p",{className:`${Bt} ${qt}`,children:h("noEvents")}):Ie("div",{className:"space-y-2",children:m.map(t=>{var n;return Ie("div",{className:` p-2 cursor-pointer rounded border-l-4 transition-colors ${(null==a?void 0:a.id)===t.id?"df-border-primary df-tint-primary":"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:P(t.calendarId||"blue")},onClick:()=>{o(t),e.onEventClick(t)},children:[Ie("div",{className:`font-medium ${qt}`,children:t.title}),!t.allDay&&Ie("div",{className:`${Kt} ${Gt}`,children:[X(E(u?z(t.start,u):t.start),0,d)," ","-"," ",X(u?E(z(null!==(n=t.end)&&void 0!==n?n:t.start,u)):J(t),0,d)]}),t.allDay&&Ie("div",{className:`${Kt} ${Gt}`,children:h("allDay")})]},t.id)})})]})})]})})},_r={PARALLEL_THRESHOLD:.25,NESTED_THRESHOLD:.5,INDENT_STEP_PERCENT:2.5,MIN_WIDTH:25,MARGIN_BETWEEN:1,EDGE_MARGIN_PERCENT:.9};function zr(e){return Object.assign(Object.assign({},e),{parentId:void 0,children:[],_startHour:e.allDay?0:E(e.start),_endHour:e.allDay?0:J(e)})}function Ur(e){var t;return null!==(t=e._startHour)&&void 0!==t?t:E(e.start)}function Wr(e){var t;return null!==(t=e._endHour)&&void 0!==t?t:J(e)}function Br(e,t){return e.day===t.day&&!e.allDay&&!t.allDay&&(Ur(e)<Wr(t)&&Ur(t)<Wr(e))}function Gr(e,t){const n=Wr(e)-Ur(e);if(n<1.25)return!1;const r=Ur(e)+.4*n,a=Ur(t)>=r,o=Br(e,t);return a&&o}function Kr(e,t,n=_r){if(!Br(e,t))return!1;const r=Math.abs(Ur(e)-Ur(t));return r<=n.PARALLEL_THRESHOLD||(r>n.PARALLEL_THRESHOLD&&r<n.NESTED_THRESHOLD||function(e,t){return!(!Br(e,t)||!Gr(e,t)&&!Gr(t,e))}(e,t))}function qr(e,t){const n=Ur(e)<=Ur(t)&&Wr(e)>=Wr(t),r=Ur(e)<=Ur(t)&&Ur(t)<Wr(e)&&Br(e,t);return n||r}function Xr(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(Ur(r)-Ur(t))<=_r.PARALLEL_THRESHOLD&&(a.push(t),n.add(t.id))}a.sort((e,t)=>Ur(e)-Ur(t));const o={events:a,startHour:Math.min(...a.map(e=>Ur(e))),endHour:Math.max(...a.map(e=>Wr(e)))};t.push(o)}return t.sort((e,t)=>e.startHour-t.startHour),t}function Jr(e){return"day"===e?.5:2.5}function Qr(e){const t=Wr(e)-Ur(e);return Math.max(.1,Math.min(1,t/4))}function ea(e){if(e.length<2)return!1;for(let t=0;t<e.length;t++)for(let n=t+1;n<e.length;n++)if(Kr(e[t],e[n],_r))return!0;return!1}function ta(e,t,n,r,a={}){const o=Jr(a.viewType);let i=e.depth*o;if(e.isProcessed){const t=function(e,t){let n=e;for(;n.parent&&n.parent.depth>0;)n=n.parent;return 1===n.depth?n.depth*Jr(t):null}(e,a.viewType);null!==t&&(i=t)}const l="day"===a.viewType;let s=0;1===e.depth?s=l?.5:1.5:2===e.depth?s=l?-.01:-1:e.depth>=3&&(s=l?.55:-3.5);const d=t+i+s;let c=n-(i+s);if(d+c>t+n&&(c=t+n-d),r.set(e.event.id,{id:e.event.id,left:d,width:c,zIndex:e.depth,level:e.depth,isPrimary:0===e.depth,indentOffset:i*(a.containerWidth||320)/100,importance:Qr(e.event)}),0===e.children.length)return;const u=[...e.children].toSorted((e,t)=>Wr(t.event)-Ur(t.event)-(Wr(e.event)-Ur(e.event)));1===u.length?ta(u[0],d,c,r,a):ea(u.map(e=>e.event))?na(u,d,c,r,a):u.forEach(e=>ta(e,d,c,r,a))}function na(e,t,n,r,a={}){const o=e.length,i=e[0].depth,l=i*Jr(a.viewType),s="day"===a.viewType;let d=1===i?s?.5:1.5:2===i?s?-.01:-1:s?.55:-3.5;const c=t+l+d,u=n-(l+d);if(u<=0)return void e.forEach(e=>ta(e,t,n,r,a));let h=_r.MARGIN_BETWEEN*(1===i?s?.15:.3:s?.1:.2);const g=(u-h*(o-1))/o;e.forEach((e,t)=>{const n=c+t*(g+h);if(r.set(e.event.id,{id:e.event.id,left:n,width:g,zIndex:e.depth,level:e.depth,isPrimary:0===e.depth,indentOffset:l*(a.containerWidth||320)/100,importance:Qr(e.event)}),e.children.length>0){const t=[...e.children].toSorted((e,t)=>Wr(t.event)-Ur(t.event)-(Wr(e.event)-Ur(e.event)));1===t.length?ta(t[0],n,g,r,a):ea(t.map(e=>e.event))?na(t,n,g,r,a):t.forEach(e=>ta(e,n,g,r,a))}})}function ra(e,t,n={}){const r=100-("day"===n.viewType?0:_r.EDGE_MARGIN_PERCENT);if(1===e.length)ta(e[0],0,r,t,n);else if(e.length>1){const a=e.length,o=(r-_r.MARGIN_BETWEEN*(a-1))/a;e.forEach((e,r)=>{ta(e,r*(o+_r.MARGIN_BETWEEN),Math.max(o,_r.MIN_WIDTH),t,n)})}}function aa(e){let t=0;for(const n of e.children)t+=1+aa(n);return t}function oa(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:aa(e)})).toSorted((e,t)=>t.load-e.load)}function ia(e){return!(e.length<2)&&e[0].load-e.at(-1).load>=2}function la(e,t){t.parentId=e.id,e.children.includes(t.id)||e.children.push(t.id)}function sa(e,t){e.parent&&(e.parent.children=e.parent.children.filter(t=>t!==e));const n=t.children.find(t=>qr(t.event,e.event));n?(e.parent=n,e.depth=n.depth+1,n.children.push(e),la(n.event,e.event)):(e.parent=t,e.depth=t.depth+1,t.children.push(e),la(t.event,e.event))}function da(e,t){0===e.children.length?t.push(e):e.children.forEach(e=>da(e,t))}function ca(e,t){const n=[];return da(e,n),n.find(e=>qr(t.event,e.event))||n[0]||null}function ua(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=ca(n.node,r.node);if(!a)break;sa(a,r.node),n.load--,r.load++,t++}}function ha(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(Br(n,e)&&Math.abs(Ur(e)-Ur(n))<_r.NESTED_THRESHOLD)return!0;return!1}(e,t))return!1;if(n<_r.NESTED_THRESHOLD)return!1;for(const n of e.events)for(const e of t.events)if(qr(n,e))return!0;return!1}function ga(e,t,n){const r=t.events.filter(t=>qr(t,e));if(0===r.length)return null;if(1===r.length)return r[0];const a=r.map(t=>({parent:t,load:t.children.length,hasParallelSibling:t.children.some(t=>{const r=n.find(e=>e.id===t);return r&&Kr(e,r,_r)})}));return a.sort((t,n)=>t.load!==n.load?t.load-n.load:t.hasParallelSibling!==n.hasParallelSibling?t.hasParallelSibling?-1:1:Math.abs(Ur(e)-Ur(t.parent))-Math.abs(Ur(e)-Ur(n.parent))),a[0].parent}function ma(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=Wr(e)-Ur(e),i=a.flatMap(e=>e.children);return o>Math.max(...i.map(e=>{const t=n.find(t=>t.id===e);return t?Wr(t)-Ur(t):0}),0)?a[0]:a.at(-1)||null}function fa(e,t){t.parentId=e.id,e.children.includes(t.id)||e.children.push(t.id)}function pa(e){let t=0;for(const n of e.children)t+=1+pa(n);return t}function va(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 ya(e,t){const n=t.get(e.id);if(!n)return null;let r=n;for(;r.parent&&r.depth>1;)r=r.parent;if(1!==r.depth)return null;const a=r.parent;if(!a)return null;const o=a.children.filter(e=>1===e.depth&&e.event.id!==r.event.id);let i=1/0,l=null;for(const e of o){const t=pa(e);t<i&&(i=t,l=e)}return l?l.event:null}function ba(e,t,n){const r=[];if(1===e.length){const a=ga(e[0],t,n);return a&&(r.push({child:e[0],parent:a}),fa(a,e[0])),r}const a=t.events.filter(t=>e.every(e=>qr(t,e)));if(0===a.length){for(const a of e){const o=ga(a,t,n);if(o)r.push({child:a,parent:o}),fa(o,a);else{const t=e.find(e=>e.id!==a.id&&Br(e,a));if(t){const e=ya(t,va(n));e&&(r.push({child:a,parent:e}),fa(e,a))}}}return r}const o=[...e].toSorted((e,t)=>Wr(t)-Ur(t)-(Wr(e)-Ur(e)));if(o.length%a.length===0){const e=o.length/a.length;for(let t=0;t<a.length;t++){const n=a[t],i=o.slice(t*e,(t+1)*e);for(const e of i)r.push({child:e,parent:n}),fa(n,e)}}else for(const e of o){const t=ma(e,a,o);t&&(r.push({child:e,parent:t}),fa(t,e))}return r}function xa(e,t){const n=[],r=new Map,a=new Map;t.forEach(e=>a.set(e.id,e));for(const t of e)for(const e of t.events){const t={event:a.get(e.id),children:[],parent:null,depth:0,isProcessed:!1};n.push(t),r.set(e.id,t)}for(let n=0;n<e.length;n++){const o=e[n],i=o.events.map(e=>a.get(e.id));let l=!1;for(let s=n-1;s>=0&&!l;s--){const n=e[s],d={events:n.events.map(e=>a.get(e.id)),startHour:n.startHour,endHour:n.endHour};if(ha(d,{events:i,startHour:o.startHour,endHour:o.endHour})){const e=ba(i,d,t);for(const t of e){const e=r.get(t.child.id),n=r.get(t.parent.id);e.parent=n,e.depth=n.depth+1,n.children.push(e)}l=!0}}}const o=n.filter(e=>null===e.parent);return o.forEach(e=>{e.depth=0}),function(e,t){for(let n=e.length-1;n>=1;n--){const r=oa(e[n].events.map(e=>t.find(t=>t.event.id===e.id)),t);ia(r)&&ua(r)}}(e,n),o}const wa={calculateDayEventLayouts(e,t={}){const n=e.map(zr);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)||Br(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:_r.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{ra(xa(Xr([...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}},Da=(e,t,n=7,r)=>{const a=new Map;for(let o=0;o<n;o++){const i=[];e.forEach(e=>{var a;if(e.allDay)return;const l=Dr(e,t,n,r);if(l.length>0){const n=l.find(e=>e.dayIndex===o);if(n){const r=n.endHour>=24?23.99:n.endHour,a=Object.assign(Object.assign({},e),{start:G(C(pe(t,o),n.startHour)),end:G(C(pe(t,o),r)),day:o});i.push(a)}}else if(e.day===o){const t=e=>r?z(e,r):_(e);i.push(Object.assign(Object.assign({},e),{start:G(t(e.start),r),end:G(t(null!==(a=e.end)&&void 0!==a?a:e.start),r),day:o}))}});const l=wa.calculateDayEventLayouts(i,{viewType:"week"});a.set(o,l)}return a},Ea=(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},Ca={HOUR_HEIGHT:72,FIRST_HOUR:0,LAST_HOUR:24,ALL_DAY_HEIGHT:28};function Ta(e){const{app:n,onEventCreated:r}=e,{t:o}=bt(),i=a.useCallback(e=>{e.dataTransfer&&e.dataTransfer.types.includes("application/x-dayflow-calendar")&&(e.preventDefault(),e.dataTransfer.dropEffect="copy")},[]);return{handleDrop:a.useCallback((e,a,i,l)=>{if(e.preventDefault(),!e.dataTransfer)return null;const s=e.dataTransfer.getData("application/x-dayflow-calendar");if(!s)return null;try{const e=JSON.parse(s);let d,c,u=!1;if(l){const e=t.Temporal.PlainDate.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate()});d=e,c=e,u=!0}else if(void 0===i){const e=new Date(a);e.setHours(9,0,0,0);const t=new Date(e);t.setHours(10,0,0,0),d=G(e,n.timeZone),c=G(t,n.timeZone)}else{const e=new Date(a);e.setHours(i,0,0,0);const t=new Date(e);t.setHours(i+1,0,0,0),d=G(e,n.timeZone),c=G(t,n.timeZone)}const h={id:`event-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,title:o(u?"newAllDayCalendarEvent":"newCalendarEvent",{calendarName:e.calendarName}),description:"",start:d,end:c,calendarId:e.calendarId,allDay:u};return n.addEvent(h),null==r||r(h),h}catch(e){return console.error("Error creating event from calendar drop:",e),null}},[n,r]),handleDragOver:i}}let ka=null;const Sa={handleMoveStart:()=>{},handleCreateStart:()=>{},handleResizeStart:void 0,handleCreateAllDayEvent:()=>{},dragState:{active:!1,mode:null,eventId:null,targetDate:null,startDate:null,endDate:null},isDragging:!1};function Ma(e,t){return ka?ka(e,t):Sa}const Na=({app:e,config:t,customDetailPanelContent:n,customEventDetailDialog:r,calendarRef:o,switcherMode:i="buttons",selectedEventId:l,onEventSelect:s,onDateChange:d,detailPanelEventId:c,onDetailPanelToggle:u})=>{const h=e.getEvents(),{screenSize:g}=vt(),m="desktop"!==g,[f,p]=a.useState(!1),{hourHeight:v=Ca.HOUR_HEIGHT,firstHour:y=Ca.FIRST_HOUR,lastHour:b=Ca.LAST_HOUR,allDayHeight:x=Ca.ALL_DAY_HEIGHT,showAllDay:w=!0,timeFormat:D="24h",secondaryTimeZone:C,showEventDots:T=!0}=t,k=v,S=y,M=b,N=x,I=!w;a.useEffect(()=>{p("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const R=e.getCustomMobileEventRenderer()||er,[O,H]=a.useState(null),[A,P]=a.useState(null),[L,$]=a.useState(null),j=void 0===l?A:l,Y=void 0===c?L:c,F=a.useMemo(()=>j&&h.find(e=>e.id===j)||null,[j,h]),V=e=>{s?s(e):P(e)},[Z,U]=a.useState(null),[W,B]=a.useState(!1),[K,q]=a.useState(null),J=a.useRef(null),Q=e.getCurrentDate(),[ae,oe]=a.useState(Q),ie=a.useRef(Q.getTime());Q.getTime()!==ie.current&&(ie.current=Q.getTime(),Q.getFullYear()===ae.getFullYear()&&Q.getMonth()===ae.getMonth()||oe(Q));const le=a.useCallback(t=>{oe(n=>{const r=new Date(n.getFullYear(),n.getMonth()+t,1);return e.setVisibleMonth(r),r})},[e]),se=a.useRef(e.state.highlightedEventId);a.useEffect(()=>{var t;if(e.state.highlightedEventId!==se.current)if(e.state.highlightedEventId){V(e.state.highlightedEventId);const n=e.getEvents().find(t=>t.id===e.state.highlightedEventId);if(n&&!n.allDay){const e=E(n.start),r=null===(t=o.current)||void 0===t?void 0:t.querySelector(".df-calendar-content");if(r){const t=(e-S)*k;requestAnimationFrame(()=>{r.scrollTo({top:Math.max(0,t-100),behavior:"smooth"})})}}}else V(null);se.current=e.state.highlightedEventId},[e.state.highlightedEventId,S,k,o,e]);const de=a.useRef(null),ce=a.useRef(null),ue=a.useMemo(()=>Ea(Q),[Q]),he=e.timeZone,ge=a.useMemo(()=>((e,t,n,r)=>{const a=new Date(t);a.setHours(0,0,0,0);const o=new Date(t);o.setHours(23,59,59,999);const i=e=>r?z(e,r):_(e);return e.filter(e=>{var t;const n=i(e.start),r=i(null!==(t=e.end)&&void 0!==t?t:e.start);if(e.allDay){const e=new Date(n);e.setHours(0,0,0,0);const t=new Date(r);return t.setHours(0,0,0,0),e<=o&&t>=a}return n<o&&r>a}).map(e=>{const t=i(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,ue,he),[h,Q,ue,he]),me=a.useMemo(()=>((e,t,n)=>{const r=new Date(t);r.setHours(0,0,0,0);const a=new Date(r);a.setDate(a.getDate()+1);const o=e=>n?z(e,n):_(e);return e.filter(e=>!e.allDay).map(e=>{var t;const i=o(e.start),l=o(null!==(t=e.end)&&void 0!==t?t:e.start);let s=G(i,n),d=G(l,n);return i<r&&(s=G(r,n)),l>a&&(d=G(a,n)),Object.assign(Object.assign({},e),{start:s,end:d,day:0})})})(ge,Q,he),[ge,Q,he]),fe=a.useMemo(()=>wa.calculateDayEventLayouts(me,{viewType:"day"}),[me]),pe=a.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(ft(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=_(e.start),r=_(e.end),a=_(t.start);return n<=_(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})(ge,e.state.allDaySortComparator),[ge,e.state.allDaySortComparator]),ve=a.useMemo(()=>{if(0===pe.length)return N;return(Math.max(...pe.map(e=>e.row))+1)*N},[pe,N]),{handleMoveStart:ye,handleCreateStart:be,handleResizeStart:xe,handleCreateAllDayEvent:De,dragState:Ee,isDragging:Ce}=Ma(e,{calendarRef:o,allDayRowRef:w?de:void 0,timeGridRef:ce,viewType:exports.ViewType.DAY,onEventsUpdate:(t,n,r)=>{const a=t(ge),o=new Set(a.map(e=>e.id)),i=ge.filter(e=>!o.has(e.id)),l=new Set(ge.map(e=>e.id)),s=a.filter(e=>!l.has(e.id)),d=a.filter(e=>{if(!l.has(e.id))return!1;const t=h.find(t=>t.id===e.id);return t&&we(t,e)});e.applyEventsChanges({delete:i.map(e=>e.id),add:s,update:d.map(e=>({id:e.id,updates:e}))},void 0,r)},onEventCreate:t=>{m?(q(t),B(!0)):(e.addEvent(t),U(t.id))},onEventEdit:()=>{},currentWeekStart:ue,events:ge,calculateNewEventLayout:(e,t,n)=>((e,t,n,r,a,o)=>{const i=new Date(r),l=new Date(r);i.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:G(i,o),end:G(l,o),calendarId:"blue",allDay:!1}];return wa.calculateDayEventLayouts(s,{viewType:"day"}).get("-1")||null})(0,t,n,Q,me,he),calculateDragLayout:(e,t,n,r)=>((e,t,n,r,a,o,i)=>{const l=o.filter(t=>t.id!==e.id),s=new Date(a),d=new Date(s);d.setHours(Math.floor(n),n%1*60,0,0);const c=new Date(s);c.setHours(Math.floor(r),r%1*60,0,0);const u=[...l,Object.assign(Object.assign({},e),{start:G(d,i),end:G(c,i),day:0})];return 0===u.length?null:wa.calculateDayEventLayouts(u,{viewType:"day"}).get(e.id)||null})(e,0,n,r,Q,me,he),TIME_COLUMN_WIDTH:C&&!m?88:m?48:80,isMobile:m}),{handleDrop:Te,handleDragOver:ke}=Ta({app:e,onEventCreated:e=>{U(e.id)}}),Se=Array.from({length:24},(e,t)=>({hour:t+S,label:X(t+S,0,D)})),Me=a.useMemo(()=>C?ee(Se,C,D,Q,he):void 0,[C,D,S,Q,he]),Ne=a.useMemo(()=>C?te(he,Q):void 0,[C,he,Q]),Re=a.useMemo(()=>C?te(C,Q):void 0,[C,Q]),Oe=a.useCallback(t=>{const n=new Date(t.getFullYear(),t.getMonth(),t.getDate());e.setCurrentDate(n),oe(new Date(n.getFullYear(),n.getMonth(),1))},[e]),He=a.useMemo(()=>{const e=re(he);return Q.toDateString()===e.toDateString()},[Q,he]);return a.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=ne(he),n=e.getHours()+e.getMinutes()/60,r=t.clientHeight;t.scrollTop=Math.max(0,(n-S)*k-r/2)}}},[he,t.scrollToCurrentTime,S,k]),a.useEffect(()=>{H(ne(he));const e=setInterval(()=>H(ne(he)),6e4);return()=>clearInterval(e)},[he]),Ie("div",{className:"df-day-view flex h-full bg-gray-50 dark:bg-gray-800",children:[Ie(Vr,{app:e,currentDate:Q,currentWeekStart:ue,events:h,currentDayEvents:ge,organizedAllDayEvents:pe,allDayAreaHeight:ve,timeSlots:Se,eventLayouts:fe,isToday:He,currentTime:O,selectedEventId:j,setSelectedEventId:V,newlyCreatedEventId:Z,setNewlyCreatedEventId:U,detailPanelEventId:Y,setDetailPanelEventId:e=>{u?u(e):$(e)},dragState:Ee,isDragging:Ce,handleMoveStart:ye,handleResizeStart:xe,handleCreateStart:be,handleCreateAllDayEvent:De,handleTouchStart:(e,t)=>{if(!m&&!f)return;const n=e.touches[0],r=n.clientX,a=n.clientY,i=e.currentTarget;J.current=setTimeout(()=>{var e,n,l;const s=null===(n=null===(e=o.current)||void 0===e?void 0:e.querySelector(".df-calendar-content"))||void 0===n?void 0:n.getBoundingClientRect();if(!s)return;const d=null===(l=o.current)||void 0===l?void 0:l.querySelector(".df-calendar-content"),c=d?d.scrollTop:0,u=a-s.top+c;null==be||be({preventDefault:()=>{},stopPropagation:()=>{},touches:[{clientX:r,clientY:a}],changedTouches:[{clientX:r,clientY:a}],target:i,currentTarget:i,cancelable:!0},t,S+u/k)},500)},handleTouchEnd:()=>{J.current&&(clearTimeout(J.current),J.current=null)},handleTouchMove:()=>{J.current&&(clearTimeout(J.current),J.current=null)},handleDragOver:ke,handleDrop:Te,handleEventUpdate:t=>e.updateEvent(t.id,t),handleEventDelete:t=>e.deleteEvent(t),onDateChange:d,customDetailPanelContent:n,customEventDetailDialog:r,calendarRef:o,allDayRowRef:de,timeGridRef:ce,switcherMode:i,isMobile:m,isTouch:f,setDraftEvent:q,setIsDrawerOpen:B,ALL_DAY_HEIGHT:N,HOUR_HEIGHT:k,FIRST_HOUR:S,LAST_HOUR:M,showAllDay:w,showStartOfDayLabel:I,timeFormat:D,secondaryTimeSlots:Me,primaryTzLabel:Ne,secondaryTzLabel:Re,appTimeZone:he}),Ie(Zr,{app:e,currentDate:Q,visibleMonth:ae,currentDayEvents:ge,selectedEvent:F,setSelectedEvent:e=>V(e?e.id:null),handleMonthChange:le,handleDateSelect:Oe,switcherMode:i,timeFormat:D,showEventDots:T,appTimeZone:he}),Ie(R,{isOpen:W,onClose:()=>{B(!1),q(null)},onSave:t=>{h.some(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),B(!1),q(null)},draftEvent:K,app:e,timeFormat:D})]})},Ia=({originalComponent:e,app:t,viewType:n,config:r,customDetailPanelContent:o,customEventDetailDialog:i,calendarRef:l,switcherMode:s,meta:d,selectedEventId:c,detailPanelEventId:u,onEventSelect:h,onDateChange:g,onDetailPanelToggle:m})=>{const f=t.getPlugin("events"),p=t.getPlugin("drag"),v=t.getCurrentDate(),y=t.state.currentView,b=t.getEvents(),x=a.useCallback(e=>f?f.update(e.id,e):t.updateEvent(e.id,e),[f,t]),w=a.useCallback(e=>f?f.delete(e):t.deleteEvent(e),[f,t]),D=a.useCallback(e=>{f?f.add(e):t.addEvent(e)},[f,t]),E=a.useCallback(e=>{g?g(e):t.setCurrentDate(e)},[t,g]),C=a.useCallback(e=>{t.changeView(e)},[t]),T=a.useMemo(()=>{const e=t.getViewConfig(n);return Object.assign(Object.assign({},e),r)},[r,t.state.views,n]),k=a.useMemo(()=>({app:t,currentDate:v,currentView:y,events:b,onEventUpdate:x,onEventDelete:w,onEventCreate:D,onDateChange:E,onViewChange:C,config:T,customDetailPanelContent:o,customEventDetailDialog:i,calendarRef:l,switcherMode:s,meta:d,selectedEventId:c,detailPanelEventId:u,onEventSelect:h,onDetailPanelToggle:m}),[t,v,y,b,x,w,D,E,C,T,o,i,l,s,d,c,u,h,m]),S=a.useMemo(()=>{const e={currentDate:v,events:b,setEvents:e=>{b.forEach(e=>w(e.id)),e.forEach(e=>D(e))},updateEvent:x,deleteEvent:w,addEvent:D,goToPrevious:()=>{const e=new Date(v);switch(y){case exports.ViewType.DAY:e.setDate(e.getDate()-1);break;case exports.ViewType.WEEK:e.setDate(e.getDate()-7);break;case exports.ViewType.MONTH:e.setMonth(e.getMonth()-1)}E(e)},goToNext:()=>{const e=new Date(v);switch(y){case exports.ViewType.DAY:e.setDate(e.getDate()+1);break;case exports.ViewType.WEEK:e.setDate(e.getDate()+7);break;case exports.ViewType.MONTH:e.setMonth(e.getMonth()+1)}E(e)},goToToday:()=>{E(new Date)},changeView:C,selectDate:E};return Object.assign(Object.assign({calendar:e},k),{eventsService:f,dragService:p})},[v,b,y,x,w,D,E,C,k,f,p]);return Ie(e,Object.assign({},S))},Ra={},Oa=e=>n.h(Ia,Object.assign(Object.assign({},e),{viewType:exports.ViewType.DAY,originalComponent:Na,className:"day-view-factory"}));Oa.displayName="DayViewAdapter";const Ha=(e={})=>{const t=Object.assign(Object.assign({},Ra),e);return{type:exports.ViewType.DAY,component:Oa,config:t}},Aa=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:t=[],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:t.map((e,t)=>Ie("div",{className:"flex justify-center",children:Ie("span",{className:"text-[10px] font-medium "+(e.isToday?"df-text-primary":"text-gray-500"),children:Aa(e.dayName)})},`label-${t}`))}),Ie("div",{className:"relative grid grid-cols-7 overflow-hidden",children:(()=>{if(!r)return null;const o=t.findIndex(e=>e.fullDate.getTime()===r.getTime()),i=-1===o?"0":`calc(${(o+.5)/7*100}% - 16px)`,l=`calc(${1/7*100}% + 32px)`;return Ie(n.Fragment,{children:[Ie("div",{className:"absolute rounded-full bg-gray-100 transition-all duration-300 dark:bg-gray-800",style:{left:i,top:0,width:l,height:"32px"}}),t.map((t,n)=>{const r=t.isCurrent,i=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?"df-text-primary font-bold":i?"text-gray-900 dark:text-gray-100":"text-gray-500 dark:text-gray-400"} `,children:[t.date,t.isToday&&!r&&Ie("div",{className:"df-fill-primary absolute bottom-1 h-1 w-1 rounded-full"})]})},`date-${n}`)})]})})()})]}),La=({app:e,weekDaysLabels:t,mobileWeekDaysLabels:r,weekDates:o,fullWeekDates:i,isSlidingView:l,mobilePageStart:s,currentWeekStart:d,gridWidth:c,allDayAreaHeight:u,organizedAllDaySegments:h,allDayLabelText:g,isMobile:m,isTouch:f,showAllDay:p=!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:O,newlyCreatedEventId:H,setNewlyCreatedEventId:A,selectedEventId:P,setSelectedEventId:L,detailPanelEventId:$,setDetailPanelEventId:j,handleCreateAllDayEvent:Y,handleDragOver:F,handleDrop:V,customDetailPanelContent:Z,customEventDetailDialog:_})=>{const z={flexShrink:0},[U,W]=a.useState(null),B=a.useMemo(()=>Ze(),[]),G=!!S&&S.length>0&&!m,K=e.canMutateFromUI();a.useEffect(()=>{K||W(null)},[K]);return Ie("div",{className:"flex w-full flex-col",children:[l&&i&&s&&Ie(Pa,{app:e,fullWeekDates:i,mobilePageStart:s,onDateChange:O}),Ie("div",{className:`flex flex-none ${p?"border-b border-gray-200 dark:border-gray-700":""} relative z-10`,onContextMenu:e=>e.preventDefault(),children:[p&&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 "+(l?"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:p?`${u+(l?0:36)}px`:"auto"},children:Ie("div",{ref:b,className:"flex flex-col",style:{width:c,minWidth:"100%",transform:l?"translateX(calc(-100% / 3))":void 0},children:[!l&&Ie("div",{className:"df-week-header flex border-b",style:{marginRight:B?"-50px":"0px",paddingRight:B?"50px":"0px"},children:t.map((e,t)=>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:z,children:Ie(n.Fragment,m?{children:[Ie("div",{className:"text-[12px] leading-tight font-medium text-gray-500",children:r[t]}),Ie("div",{className:`${Et} h-7 w-7 text-base font-medium ${o[t].isToday?Yt:""}`,children:o[t].date})]}:{children:[Ie("div",{className:"mt-1 mr-1 inline-flex items-center justify-center text-sm",children:e}),Ie("div",{className:`${Et} ${o[t].isToday?Yt:""}`,children:o[t].date})]})},t))}),p&&Ie("div",{className:`${Rt} 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:[t.map((e,n)=>{const r=new Date(d);return r.setDate(d.getDate()+n),Ie("div",{className:"df-all-day-cell flex-1 border-r relative transition-[min-height] duration-300 ease-in-out "+(n!==t.length-1||!m&&B?"":"border-r-0"),style:Object.assign({minHeight:`${u}px`},z),onMouseDown:e=>null==Y?void 0:Y(e,n),onDblClick:e=>null==Y?void 0:Y(e,n),onDragOver:F,onDrop:e=>{V(e,r,void 0,!0)},onContextMenu:e=>((e,t)=>{if(e.preventDefault(),m||!K)return;const n=new Date(d);n.setDate(d.getDate()+t),n.setHours(0,0,0,0),W({x:e.clientX,y:e.clientY,date:n})})(e,n)},`allday-${n}`)}),Ie("div",{className:"pointer-events-none absolute inset-0",children:h.map(n=>Ie(Lr,{event:n.event,segment:n,segmentIndex:n.row,isAllDay:!0,isMultiDay:!0,allDayHeight:x,calendarRef:v,viewType:exports.ViewType.WEEK,columnsPerRow:t.length,isBeingDragged:C&&(null==E?void 0:E.eventId)===n.event.id&&"move"===(null==E?void 0:E.mode),hourHeight:w,firstHour:D,onMoveStart:M,onResizeStart:N,onEventUpdate:I,onEventDelete:R,newlyCreatedEventId:H,onDetailPanelOpen:()=>A(null),selectedEventId:P,detailPanelEventId:$,onEventSelect:e=>{L(e)},onEventLongPress:e=>{(m||f)&&L(e)},onDetailPanelToggle:e=>j(e),customDetailPanelContent:Z,customEventDetailDialog:_,app:e,isMobile:m,isSlidingView:l,enableTouch:f},n.event.id))})]})})]})}),K&&U&&Ie(yr,{x:U.x,y:U.y,date:U.date,viewType:exports.ViewType.WEEK,onClose:()=>W(null),app:e,onCreateEvent:()=>{const e=Math.floor((U.date.getTime()-d.getTime())/864e5);null==Y||Y({clientX:U.x,clientY:U.y},e)}})]})]})},$a=({app:e,timeSlots:t,weekDaysLabels:r,currentWeekStart:o,currentWeekEvents:i,eventLayouts:l,gridWidth:s,isMobile:d,isTouch:c,scrollerRef:u,timeGridRef:h,leftFrozenContentRef:g,swipeContentRef:m,calendarRef:f,handleScroll:p,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:O,setSelectedEventId:H,detailPanelEventId:A,setDetailPanelEventId:P,customDetailPanelContent:L,customEventDetailDialog:$,isSlidingView:j,isCurrentWeek:Y,currentTime:F,HOUR_HEIGHT:V,FIRST_HOUR:Z,LAST_HOUR:_,showStartOfDayLabel:z,timeFormat:U="24h",secondaryTimeSlots:W,appTimeZone:B})=>{var G,K;const q=!!W&&W.length>0&&!d,J={flexShrink:0},Q=a.useRef(e.state.highlightedEventId),[ee,te]=a.useState(null),ne=a.useMemo(()=>Ze(),[]),re=e.canMutateFromUI();a.useEffect(()=>{re||te(null)},[re]);const ae=e=>{if(!h.current)return Z;const t=h.current.getBoundingClientRect();return Z+(e-t.top)/V};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%"===s?"overflow-x-hidden":"snap-x snap-mandatory"),style:{display:"grid",gridTemplateColumns:"auto 1fr"},onScroll:p,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:q?Ie(n.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:z&&null!==(G=null==W?void 0:W[0])&&void 0!==G?G:""}),Ie("span",{className:"text-[10px] text-gray-500 md:text-[12px] dark:text-gray-400",children:z?X(Z,0,U):""})]})}):Ie("div",{className:"absolute right-2 -bottom-1 text-[10px] text-gray-500 select-none md:text-[12px] dark:text-gray-400",children:z?X(Z,0,U):""})}),t.map((e,t)=>{var n;return Ie("div",{className:kt,children:Ie("div",q?{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:z&&0===t?"":null!==(n=null==W?void 0:W[t])&&void 0!==n?n:""}),Ie("span",{className:"text-[10px] md:text-[12px]",children:z&&0===t?"":e.label})]}:{className:`${St} text-[10px] md:text-[12px]`,children:z&&0===t?"":e.label})},t)}),Ie("div",{className:"relative",children:Ie("div",q?{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!==(K=null==W?void 0:W[0])&&void 0!==K?K:""}),Ie("span",{className:"text-[10px] md:text-[12px]",children:X(0,0,U)})]}:{className:`${St} text-[10px] md:text-[12px]`,children:X(0,0,U)})}),Y&&F&&(()=>{const e=F,t=e.getHours()+e.getMinutes()/60;if(t<Z||t>_)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)*V}px`,transform:"translateY(-50%)",marginTop:"0.75rem"},children:Ie("div",{className:It,children:X(t,0,U,!1)})})})()]}),Ie("div",{ref:m,className:"flex",style:{width:s,minWidth:"100%",transform:j?"translateX(calc(-100% / 3))":void 0},children:Ie("div",{className:"grow",children:[Ie("div",{className:`${zt} flex border-t-0`,children:r.map((e,t)=>Ie("div",{className:`relative flex-1 ${t!==r.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&&F&&(()=>{const e=F,t=e.getHours()+e.getMinutes()/60;if(t<Z||t>_)return null;const n=new Date(e);n.setHours(0,0,0,0);const a=new Date(o);a.setHours(0,0,0,0);const i=n.getTime()-a.getTime(),l=Math.round(i/864e5);return Ie("div",{className:Nt,style:{top:`${(t-Z)*V}px`,width:"100%",height:0,zIndex:20},children:[Ie("div",{className:"flex w-0 items-center"}),Ie("div",{className:"flex flex-1",children:r.map((e,t)=>Ie("div",{className:"flex flex-1 items-center",children:Ie("div",{className:"relative h-0.5 w-full "+(t===l?"df-fill-primary":"df-tint-primary-lg"),style:{zIndex:9999},children:t===l&&0!==l&&Ie("div",{className:"df-fill-primary absolute h-2 w-2 rounded-full",style:{top:"-3px",left:"-4px"}})})},t))})]})})(),t.map((e,t)=>Ie("div",{className:Mt,children:r.map((n,a)=>{const i=new Date(o);return i.setDate(o.getDate()+a),Ie("div",{className:"df-time-grid-cell flex-1 relative border-r select-none snap-start "+(a!==r.length-1||!d&&ne?"":"border-r-0"),style:J,onClick:()=>{const e=new Date(o);e.setDate(o.getDate()+a),null==N||N(e)},onMouseDown:e=>{Yr(e,a,ae(e.clientY),c,v)},onDblClick:e=>{null==v||v(e,a,ae(e.clientY)),Fr()},onTouchStart:t=>y(t,a,e.hour),onTouchEnd:b,onTouchMove:x,onDragOver:w,onDrop:t=>{D(t,i,e.hour)},onContextMenu:t=>((e,t,n)=>{if(e.preventDefault(),d||!re)return;const r=new Date(o);if(r.setDate(o.getDate()+t),h.current){const t=h.current.getBoundingClientRect(),n=(e.clientY-t.top)/V+Z,a=Math.floor(n),o=Math.floor(60*(n-a)),i=15*Math.round(o/15),l=60===i?a+1:a,s=60===i?0:i;r.setHours(l,s,0,0)}else r.setHours(n,0,0,0);te({x:e.clientX,y:e.clientY,date:r})})(t,a,e.hour)},`${t}-${a}`)})},t)),Ie("div",{className:`${zt} flex`,children:r.map((e,t)=>Ie("div",{className:`relative flex-1 ${t!==r.length-1||!d&&ne?"border-r":""} border-gray-200 dark:border-gray-700`,style:J},`24-${t}`))}),r.map((t,n)=>{const a=r.length,s=fe(n,i),u=[];return s.forEach(e=>{const t=Dr(e,o,r.length,B);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})}),i.forEach(e=>{if(e.allDay||e.day===n)return;const t=Dr(e,o,r.length,B).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/a*n}%)`,width:100/a+"%",height:"100%"},children:u.map(({event:t,segmentInfo:r})=>{const o=l.get(n),i=null==o?void 0:o.get(t.id);return Ie(Lr,{event:t,layout:i,viewType:exports.ViewType.WEEK,calendarRef:f,columnsPerRow:a,isBeingDragged:C&&(null==E?void 0:E.eventId)===t.id&&"move"===(null==E?void 0:E.mode),hourHeight:V,firstHour:Z,onMoveStart:T,onResizeStart:k,onEventUpdate:S,onEventDelete:M,newlyCreatedEventId:I,onDetailPanelOpen:()=>R(null),selectedEventId:O,detailPanelEventId:A,onEventSelect:t=>{H(t),e.state.highlightedEventId&&(e.highlightEvent(null),Q.current=null)},onEventLongPress:e=>{(d||c)&&H(e)},onDetailPanelToggle:e=>P(e),customDetailPanelContent:L,customEventDetailDialog:$,multiDaySegmentInfo:r,app:e,isMobile:d,isSlidingView:j,enableTouch:c,appTimeZone:B},r?`${t.id}-seg-${n}`:t.id)})},`events-day-${n}`)})]})]})})]}),re&&ee&&Ie(yr,{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,i={preventDefault:()=>{},stopPropagation:()=>{},clientX:ee.x,clientY:ee.y};v(i,r,a)}}})]})},ja=({app:e,config:n,customDetailPanelContent:r,customEventDetailDialog:o,calendarRef:i,selectedEventId:l,onEventSelect:s,onDateChange:d,detailPanelEventId:c,onDetailPanelToggle:u})=>{var h;const{t:g,getWeekDaysLabels:m,locale:f}=bt(),p=e.getCurrentDate(),v=a.useMemo(()=>p,[p.getTime()]),y=e.getEvents(),{screenSize:b}=vt(),x="desktop"!==b,w=a.useRef(null),[D,T]=a.useState(!1),{hourHeight:k=Ca.HOUR_HEIGHT,firstHour:S=Ca.FIRST_HOUR,lastHour:M=Ca.LAST_HOUR,allDayHeight:N=Ca.ALL_DAY_HEIGHT,showAllDay:I=!0,timeFormat:R="24h",secondaryTimeZone:O}=n,H=O&&"mobile"!==b?88:"mobile"===b?48:80,A=k,P=S,L=M,$=N,j=!I;a.useEffect(()=>{T("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const Y=e.getCustomMobileEventRenderer()||er,F="desktop"!==b,V=F?2:7,Z=F,U=null!==(h=n.startOfWeek)&&void 0!==h?h:1,W=Z?"300%":"100%",B=a.useMemo(()=>Ea(v,U),[v,U]),[K,q]=a.useState(()=>{const e=new Date(v);return e.setHours(0,0,0,0),e});a.useEffect(()=>{Z&&q(e=>{const t=new Date(v);t.setHours(0,0,0,0);const n=new Date(e),r=new Date(e);return r.setDate(r.getDate()+V-1),t>=n&&t<=r?e:t})},[v,Z,V]);const J=Z?K:B,Q=Z?3*V:7,ae=a.useMemo(()=>{if(!Z)return J;const e=new Date(J);return e.setDate(e.getDate()-V),e},[J,Z,V]),[oe,ie]=a.useState(null),[le,se]=a.useState(null),[de,ce]=a.useState(null),ue=void 0===l?le:l,he=void 0===c?de:c,ge=e=>{s?s(e):se(e)},me=e=>{u?u(e):ce(e)},[fe,ve]=a.useState(null),[ye,be]=a.useState(!1),[xe,De]=a.useState(null),Ee=a.useRef(null),[Ce,Te]=a.useState(0),[ke,Se]=a.useState(!1),Me=a.useRef(null),Ne=a.useRef(null),Re=a.useRef(null),Oe=a.useRef(null),He=a.useRef(null),Ae=a.useRef({x:0,y:0}),Pe=a.useRef(!1),Le=a.useRef(0);a.useEffect(()=>{if(!Z)return;const t=Ne.current;if(!t)return;const n=e=>{Ae.current={x:e.touches[0].clientX,y:e.touches[0].clientY},Pe.current=!1,Le.current=0,Se(!1)},r=e=>{if(ke)return;const n=e.touches[0].clientX-Ae.current.x,r=e.touches[0].clientY-Ae.current.y;if(!Pe.current&&Math.abs(n)>10&&Math.abs(n)>Math.abs(r)&&(Pe.current=!0),Pe.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))`;Re.current&&(Re.current.style.transition="none",Re.current.style.transform=o),He.current&&(He.current.style.transition="none",He.current.style.transform=o),Le.current=a}},a=()=>{var n;if(!Pe.current)return void(Le.current=0);const r=Le.current,a=((null===(n=He.current)||void 0===n?void 0:n.clientWidth)||t.clientWidth)/Q;r>100?(Se(!0),Te(a),setTimeout(()=>{const t=new Date(K);t.setDate(t.getDate()-1),q(t),e.setCurrentDate(t),Te(0),Le.current=0,Se(!1)},300)):r<-100?(Se(!0),Te(-a),setTimeout(()=>{const t=new Date(K);t.setDate(t.getDate()+1),q(t),e.setCurrentDate(t),Te(0),Le.current=0,Se(!1)},300)):(Se(!0),Te(0),Le.current=0,setTimeout(()=>{Se(!1)},300))};return t.addEventListener("touchstart",n,{passive:!0}),t.addEventListener("touchmove",r,{passive:!1}),t.addEventListener("touchend",a,{passive:!0}),()=>{t.removeEventListener("touchstart",n),t.removeEventListener("touchmove",r),t.removeEventListener("touchend",a)}},[Z,e,J,ke,V,Q]);const $e=e.timeZone,je=a.useMemo(()=>((e,t,n=7,r)=>{const a=new Date(t);a.setDate(t.getDate()+(n-1)),a.setHours(23,59,59,999);const o=e=>r?z(e,r):_(e);return e.filter(e=>{var n;const r=o(e.start);r.setHours(0,0,0,0);const i=o(null!==(n=e.end)&&void 0!==n?n:e.start);return i.setHours(23,59,59,999),i>=t&&r<=a}).map(e=>{const r=o(e.start),a=Math.floor((r.getTime()-t.getTime())/864e5),i=Math.max(0,Math.min(n-1,a));return Object.assign(Object.assign({},e),{day:i})})})(y,ae,Q,$e),[y,ae,Q,$e]),Ye=a.useRef(e.state.highlightedEventId);a.useEffect(()=>{if(e.state.highlightedEventId!==Ye.current)if(e.state.highlightedEventId){ge(e.state.highlightedEventId);const t=je.find(t=>t.id===e.state.highlightedEventId);if(t&&!t.allDay){const e=E(t.start),n=Ne.current;if(n){const t=(e-P)*A;requestAnimationFrame(()=>{n.scrollTo({top:Math.max(0,t-100),behavior:"smooth"})})}}}else ge(null);Ye.current=e.state.highlightedEventId},[e.state.highlightedEventId,je,P,A]);const Fe=a.useMemo(()=>((e,t,n=7,r)=>{const a=wr(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=ft(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})(je,ae,Q,e.state.allDaySortComparator),[je,ae,Q,e.state.allDaySortComparator]),Ve=a.useMemo(()=>{const e=Z?Fe.filter(e=>e.endDayIndex>=V&&e.startDayIndex<=2*V-1):Fe;if(0===e.length)return $;const t=Math.max(...e.map(e=>e.row));return $+t*$},[Fe,$,Z,V]),Ze=a.useMemo(()=>Da(je,ae,Q,$e),[je,ae,Q,$e]),_e=a.useCallback((t,n,r)=>{const a=t(je),o=new Set(a.map(e=>e.id)),i=je.filter(e=>!o.has(e.id)),l=new Set(je.map(e=>e.id)),s=a.filter(e=>!l.has(e.id)),d=a.filter(e=>{if(!l.has(e.id))return!1;const t=je.find(t=>t.id===e.id);return t&&we(t,e)});e.applyEventsChanges({delete:i.map(e=>e.id),add:s,update:d.map(e=>({id:e.id,updates:e}))},n,r)},[je,e]),ze=a.useCallback(t=>{x?(De(t),be(!0)):(e.addEvent(t),ve(t.id))},[x,e]),Ue=a.useCallback(()=>{},[]),We=a.useCallback((e,t,n)=>((e,t,n,r,a,o=7,i)=>{var l;const s=pe(a,e),d=pe(a,e);s.setHours(Math.floor(t),t%1*60,0,0),d.setHours(Math.floor(n),n%1*60,0,0);const c={id:"-1",title:"Temp",day:e,start:G(s,i),end:G(d,i),calendarId:"blue",allDay:!1};return(null===(l=Da([...r,c],a,o,i).get(e))||void 0===l?void 0:l.get("-1"))||null})(e,t,n,je,ae,Q,$e),[je,ae,Q,$e]),Be=a.useCallback((e,t,n,r)=>((e,t,n,r,a,o,i=7,l)=>{var s;const d=a.map(a=>{if(a.id!==e.id)return a;const i=pe(o,t),s=C(i,n),d=C(i,r),c=G(s,l),u=G(d,l);return Object.assign(Object.assign({},a),{day:t,start:c,end:u})});return(null===(s=Da(d,o,i,l).get(t))||void 0===s?void 0:s.get(e.id))||null})(e,t,n,r,je,ae,Q,$e),[je,ae,Q,$e]),Ge=a.useMemo(()=>({calendarRef:i,allDayRowRef:I?Me:void 0,timeGridRef:w,viewType:exports.ViewType.WEEK,onEventsUpdate:_e,onEventCreate:ze,onEventEdit:Ue,currentWeekStart:ae,events:je,calculateNewEventLayout:We,calculateDragLayout:Be,TIME_COLUMN_WIDTH:H,isMobile:x,gridWidth:W,displayDays:Q}),[i,I,_e,ze,Ue,ae,je,We,Be,H,x,W,Q]),{handleMoveStart:Ke,handleCreateStart:qe,handleResizeStart:Xe,handleCreateAllDayEvent:Je,dragState:Qe,isDragging:et}=Ma(e,Ge),{handleDrop:tt,handleDragOver:nt}=Ta({app:e,onEventCreated:e=>{ve(e.id)}}),rt=a.useMemo(()=>Z?Array.from({length:Q},(e,t)=>{const n=new Date(ae);return n.setDate(n.getDate()+t),n.toLocaleDateString(f,{weekday:"short"})}):m(f,"short",U),[f,m,Z,ae,Q,U]),at=a.useMemo(()=>{if(!x)return[];const e=f.split("-")[0].toLowerCase();return"zh"===e||"ja"===e?m(f,"narrow"):rt.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,f,m,rt]),ot=a.useMemo(()=>g("allDay"),[g]),it=Array.from({length:24},(e,t)=>({hour:t+P,label:X(t+P,0,R)})),lt=a.useMemo(()=>O?ee(it,O,R,v,$e):void 0,[O,R,P,v,$e]),st=a.useMemo(()=>O?te($e,v):void 0,[O,$e,v]),dt=a.useMemo(()=>O?te(O,v):void 0,[O,v]),ct=a.useMemo(()=>{const e=t.Temporal.Now.plainDateISO($e),n=new Date(e.year,e.month-1,e.day).toDateString();return rt.map((e,t)=>{const r=new Date(ae);return r.setDate(ae.getDate()+t),{date:r.getDate(),month:r.toLocaleString(f,{month:"short"}),fullDate:new Date(r),isToday:r.toDateString()===n}})},[ae,rt,f,$e]),ut=a.useMemo(()=>{const e=t.Temporal.Now.plainDateISO($e),n=new Date(e.year,e.month-1,e.day).toDateString(),r=new Date(v.getFullYear(),v.getMonth(),v.getDate()).getTime(),a=B;return Array.from({length:7},(e,t)=>{const o=new Date(a);o.setDate(a.getDate()+t);const i=new Date(o.getFullYear(),o.getMonth(),o.getDate());return{date:o.getDate(),month:o.toLocaleString(f,{month:"short"}),fullDate:new Date(o),isToday:o.toDateString()===n,isCurrent:i.getTime()===r,dayName:o.toLocaleDateString(f,{weekday:"short"})}})},[B,f,v,$e]);a.useEffect(()=>{if(!Z)return Re.current&&(Re.current.style.transform="",Re.current.style.transition=""),void(He.current&&(He.current.style.transform="",He.current.style.transition=""));const e=ke?"transform 0.3s ease-out":"none",t=`translateX(calc(calc(-100% / 3) + ${Ce}px))`;Re.current&&(Re.current.style.transition=e,Re.current.style.transform=t),He.current&&(He.current.style.transition=e,He.current.style.transform=t)},[Ce,ke,Z]);const ht=t=>e.updateEvent(t.id,t),gt=t=>e.deleteEvent(t),mt=a.useMemo(()=>{const e=re($e);e.setHours(0,0,0,0);const t=new Date(ae);t.setHours(0,0,0,0);const n=new Date(t);return n.setDate(t.getDate()+Q),e>=t&&e<n},[ae,Q,$e]);return a.useLayoutEffect(()=>{if(n.scrollToCurrentTime&&Ne.current){const e=Ne.current,t=ne($e),n=t.getHours()+t.getMinutes()/60,r=e.clientHeight;e.scrollTop=Math.max(0,(n-P)*A-r/2)}},[$e,n.scrollToCurrentTime,P,A]),a.useEffect(()=>{ie(ne($e));const e=setInterval(()=>ie(ne($e)),6e4);return()=>clearInterval(e)},[$e]),Ie("div",{className:"df-calendar relative flex flex-col w-full overflow-hidden h-full select-none df-week-view",children:[Ie(jr,{calendar:e,viewType:exports.ViewType.WEEK,currentDate:v,onPrevious:()=>{if(Z){const t=new Date(v);t.setDate(t.getDate()-1),q(e=>{const t=new Date(e);return t.setDate(t.getDate()-1),t}),e.setCurrentDate(t)}else e.goToPrevious()},onNext:()=>{if(Z){const t=new Date(v);t.setDate(t.getDate()+1),q(e=>{const t=new Date(e);return t.setDate(t.getDate()+1),t}),e.setCurrentDate(t)}else e.goToNext()},onToday:()=>e.goToToday()}),Ie(La,{app:e,weekDaysLabels:rt,mobileWeekDaysLabels:at,weekDates:ct,fullWeekDates:ut,isSlidingView:Z,mobilePageStart:K,currentWeekStart:ae,gridWidth:W,allDayAreaHeight:Ve,organizedAllDaySegments:Fe,allDayLabelText:ot,isMobile:x,isTouch:D,showAllDay:I,calendarRef:i,allDayRowRef:Me,topFrozenContentRef:Re,ALL_DAY_HEIGHT:$,HOUR_HEIGHT:A,FIRST_HOUR:P,dragState:Qe,isDragging:et,secondaryTimeSlots:lt,primaryTzLabel:st,secondaryTzLabel:dt,handleMoveStart:Ke,handleResizeStart:Xe,handleEventUpdate:ht,handleEventDelete:gt,onDateChange:d,newlyCreatedEventId:fe,setNewlyCreatedEventId:ve,selectedEventId:ue,setSelectedEventId:ge,detailPanelEventId:he,setDetailPanelEventId:me,handleCreateAllDayEvent:Je,handleDragOver:nt,handleDrop:tt,customDetailPanelContent:r,customEventDetailDialog:o}),Ie($a,{app:e,timeSlots:it,weekDaysLabels:rt,currentWeekStart:ae,currentWeekEvents:je,eventLayouts:Ze,gridWidth:W,isMobile:x,isSlidingView:Z,isTouch:D,scrollerRef:Ne,timeGridRef:w,leftFrozenContentRef:Oe,swipeContentRef:He,calendarRef:i,handleScroll:e=>{const{scrollLeft:t}=e.currentTarget;if(Re.current){const e=Z?"calc(-100% / 3)":"0px",n=Z?`${Ce}px`:`-${t}px`;Re.current.style.transform=`translateX(calc(${e} + ${n}))`,Re.current.style.transition=Z&&ke?"transform 0.3s ease-out":"none"}},handleCreateStart:qe,handleTouchStart:(e,t,n)=>{if(!x&&!D)return;const r=e.touches[0],a=r.clientX,o=r.clientY,i=e.currentTarget;Ee.current=setTimeout(()=>{null==qe||qe({preventDefault:()=>{},stopPropagation:()=>{},touches:[{clientX:a,clientY:o}],changedTouches:[{clientX:a,clientY:o}],target:i,currentTarget:i,cancelable:!0},t,n)},500)},handleTouchEnd:()=>{Ee.current&&(clearTimeout(Ee.current),Ee.current=null)},handleTouchMove:()=>{Ee.current&&(clearTimeout(Ee.current),Ee.current=null)},handleDragOver:nt,handleDrop:tt,dragState:Qe,isDragging:et,handleMoveStart:Ke,handleResizeStart:Xe,handleEventUpdate:ht,handleEventDelete:gt,onDateChange:d,newlyCreatedEventId:fe,setNewlyCreatedEventId:ve,selectedEventId:ue,setSelectedEventId:ge,detailPanelEventId:he,setDetailPanelEventId:me,customDetailPanelContent:r,customEventDetailDialog:o,isCurrentWeek:mt,currentTime:oe,HOUR_HEIGHT:A,FIRST_HOUR:P,LAST_HOUR:L,showStartOfDayLabel:j,timeFormat:R,secondaryTimeSlots:lt,appTimeZone:$e}),Ie(Y,{isOpen:ye,onClose:()=>{be(!1),De(null)},onSave:t=>{y.some(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),be(!1),De(null)},draftEvent:xe,app:e,timeFormat:R})]})},Ya={startOfWeek:1},Fa=e=>n.h(Ia,Object.assign(Object.assign({},e),{viewType:exports.ViewType.WEEK,originalComponent:ja,className:"week-view-factory"}));Fa.displayName="WeekViewAdapter";const Va=(e={})=>{const t=Object.assign(Object.assign({},Ya),e);return{type:exports.ViewType.WEEK,component:Fa,config:t}},Za=17,_a=r.memo(({currentMonth:e,currentYear:n,newlyCreatedEventId:r,screenSize:o,isScrolling:i,isDragging:l,showWeekNumbers:s,showMonthIndicator:d=!0,item:c,weekHeight:u,events:h,dragState:g,calendarRef:m,onEventUpdate:f,onEventDelete:p,onMoveStart:v,onCreateStart:y,onResizeStart:b,onDetailPanelOpen:x,onMoreEventsClick:w,onChangeView:D,onSelectDate:C,selectedEventId:k,onEventSelect:S,onEventLongPress:M,detailPanelEventId:N,onDetailPanelToggle:I,customDetailPanelContent:R,customEventDetailDialog:O,onCalendarDrop:H,onCalendarDragOver:A,app:P,enableTouch:$,appTimeZone:j})=>{const{t:Y,locale:F}=bt(),[V,Z]=a.useState(!1),_=a.useRef(null),U=a.useRef(null),W=a.useRef(null),[B,G]=a.useState(null),K=P.canMutateFromUI();a.useEffect(()=>{K||G(null)},[K]);const q=a.useMemo(()=>{const e=u-33;if(e<=0)return{maxSlots:0,maxSlotsWithMore:0};const t=Math.floor(e/Za),n=e-20,r=Math.max(0,Math.floor(n/Za));return{maxSlots:t,maxSlotsWithMore:t>0?Math.min(r,t-1):r}},[u]);a.useEffect(()=>i?(Z(!0),_.current&&(clearTimeout(_.current),_.current=null),()=>{_.current&&(clearTimeout(_.current),_.current=null)}):V?(_.current=setTimeout(()=>{Z(!1),_.current=null},100),()=>{_.current&&(clearTimeout(_.current),_.current=null)}):void 0,[i,V]);const{weekData:X}=c,J=X.days.find(e=>1===e.day),Q=`${u}px`,ee=a.useMemo(()=>Ze(),[]),te=a.useMemo(()=>wr(h,X.startDate,7,j),[h,X.startDate,j]),ne=a.useMemo(()=>((e,n,r)=>{const a=[],o=new Date(n);return o.setDate(o.getDate()+6),o.setHours(23,59,59,999),e.forEach(e=>{if(!e.start||!e.end)return void L.warn("Event missing start or end date:",e);const i=z(e.start,r),l=e.end?z(e.end,r):i,s=new Date(i);s.setHours(0,0,0,0);const d=new Date(l);d.setHours(0,0,0,0);let c=new Date(d);if(!e.allDay&&0===l.getHours()&&0===l.getMinutes()&&0===l.getSeconds()){const e=l.getTime()-i.getTime();e>0&&e<864e5&&(c=new Date(d),c.setDate(c.getDate()-1))}const u=s.toDateString()!==c.toDateString();if(!u||e.allDay)if(u&&e.allDay){let r=new Date(i);r<n&&(r=new Date(n),r.setHours(0,0,0,0));const s=l>o?o:l;for(let o=i.getTime();o<=s.getTime();o+=864e5){const i=new Date(o);if(i<n)continue;const l=t.Temporal.PlainDate.from({year:i.getFullYear(),month:i.getMonth()+1,day:i.getDate()});a.push(Object.assign(Object.assign({},e),{start:l,end:l,day:r.getDay()}))}}else a.push(Object.assign(Object.assign({},e),{start:e.start,end:e.end,day:i.getDay()}))}),a})(h,X.startDate,j),[h,X.startDate,j]),re=a.useMemo(()=>{const e=new Map;return X.days.forEach(t=>{const n=t.date.toDateString();e.set(n,ne.filter(e=>{if(!e.start||!e.end)return z(e.start,j).toDateString()===n;const t=z(e.start,j),r=z(e.end,j);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},[ne,X.days,j]),ae=a.useMemo(()=>((e,t)=>{const n=t||ft(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,i=!(e.endDayIndex<r.startDayIndex||e.startDayIndex>r.endDayIndex);if(a&&i){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})(te,P.state.allDaySortComparator),[te,P.state.allDaySortComparator]),oe=a.useMemo(()=>ae.flat(),[ae]),ie=a.useMemo(()=>{const e=Array.from({length:7}).fill(0);return ae.forEach((t,n)=>{t.forEach(t=>{for(let r=t.startDayIndex;r<=t.endDayIndex;r++)e[r]=Math.max(e[r],n+1)})}),e},[ae]),le=a.useMemo(()=>{const e=Array.from({length:7},()=>new Set);return ae.forEach((t,n)=>{t.forEach(t=>{for(let r=t.startDayIndex;r<=t.endDayIndex;r++)r>=0&&r<7&&e[r].add(n)})}),e},[ae]),se=a.useMemo(()=>{const{maxSlots:e,maxSlotsWithMore:t}=q,n=X.days.map((n,r)=>{var a,o;const i=(e=>[...e].toSorted((e,t)=>e.allDay!==t.allDay?e.allDay?-1:1:e.allDay&&t.allDay?0:E(e.start)-E(t.start)))(null!==(a=re.get(n.date.toDateString()))&&void 0!==a?a:[]),l=i.filter(e=>{if(!e.allDay)return!0;return!oe.some(t=>t.originalEventId===e.id)}),s=(null!==(o=ie[r])&&void 0!==o?o:0)-1,d=le[r],c=[];for(let e=0;e<=s;e++)d.has(e)||c.push(e);const u=l.length,h=Math.max(0,u-c.length),g=Math.max(s+1,0)+h,m=g>e;return{totalSlotsNeeded:g,hasMore:m,limit:m?t:e,timedEventsOnly:l,gapLayers:c,occupiedLayers:d,maxOccupiedLayer:s}}),r=new Set;return ae.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;oe.forEach(e=>{e.startDayIndex<=a&&e.endDayIndex>=a&&r.has(e.id)&&(o=!0)});const i=n.hasMore||o,l=i?t:e;return Object.assign(Object.assign({},n),{hasMore:i,limit:l,segmentIsHidden:r})})},[q,X.days,re,oe,ie,le,ae]),de=a.useMemo(()=>Math.min(ae.length,q.maxSlots),[ae.length,q.maxSlots]),ce=a.useMemo(()=>Math.max(0,de*Za),[de]),ue=(t,a)=>{const i=t.date.toLocaleDateString(F,{month:F.startsWith("zh")||F.startsWith("ja")?"short":"long"})===e&&t.year===n,{hasMore:d,limit:c,timedEventsOnly:u,gapLayers:h,occupiedLayers:L,maxOccupiedLayer:V,totalSlotsNeeded:Z}=se[a];let _=0;ae.slice(c).forEach(e=>{e.forEach(e=>{e.startDayIndex<=a&&e.endDayIndex>=a&&_++})}),ae.slice(0,c).forEach(e=>{e.forEach(e=>{e.startDayIndex<=a&&e.endDayIndex>=a&&se[a].segmentIsHidden.has(e.id)&&_++})});const z=h.filter(e=>e<c).length,B=ae.slice(0,c).filter(e=>e.some(e=>e.startDayIndex<=a&&e.endDayIndex>=a&&se[a].segmentIsHidden.has(e.id))).length,q=Math.max(0,c-Math.max(V+1,0)),X=Math.min(u.length,z+q+B),J=u.slice(0,X),te=_+(u.length-X),ne=d&&de>c,re=(de-c)*Za,oe=[];let ie=0;const le=Math.min(c,Z);for(let e=0;e<le;e++)if(L.has(e)&&!ae[e].some(e=>e.startDayIndex<=a&&e.endDayIndex>=a&&se[a].segmentIsHidden.has(e.id)))oe.push(Ie("div",{className:"shrink-0",style:{height:"17px",minHeight:"17px"}},`placeholder-layer-${e}-${t.date.getTime()}`));else if(ie<J.length){const e=J[ie];oe.push(Ie(Lr,{event:e,isAllDay:!!e.allDay,viewType:exports.ViewType.MONTH,isBeingDragged:l&&g.eventId===e.id&&"move"===g.mode,calendarRef:m,hourHeight:72,firstHour:0,onEventUpdate:f,onEventDelete:p,onMoveStart:v,onResizeStart:b,onDetailPanelOpen:x,onEventSelect:S,onEventLongPress:M,newlyCreatedEventId:r,selectedEventId:k,detailPanelEventId:N,onDetailPanelToggle:I,customDetailPanelContent:R,customEventDetailDialog:O,app:P,isMobile:"desktop"!==o,enableTouch:$,appTimeZone:j},`${e.id}-${e.day}-${E(e.start)}-${ie}`)),ie++}return Ie("div",{className:Qt("df-month-day-cell relative flex flex-col border-r",i?"text-gray-800 dark:text-gray-100":"text-gray-400 dark:text-gray-600",6===a?ee?"last:border-r":"border-r-0":""),style:{height:Q},"data-date":(ce=t.date,`${ce.getFullYear()}-${String(ce.getMonth()+1).padStart(2,"0")}-${String(ce.getDate()).padStart(2,"0")}`),onClick:()=>i&&(null==C?void 0:C(t.date)),onDblClick:e=>null==y?void 0:y(e,t.date),onTouchStart:e=>{if("mobile"!==o&&!$)return;const n=e.touches[0],r=n.clientX,a=n.clientY;W.current={x:r,y:a},U.current=setTimeout(()=>{null==y||y(e,t.date),U.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},onTouchMove:e=>{if(U.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(U.current),U.current=null)}},onTouchEnd:()=>{U.current&&(clearTimeout(U.current),U.current=null),W.current=null},onDragOver:A,onDrop:e=>null==H?void 0:H(e,t.date),onContextMenu:e=>((e,t)=>{e.preventDefault(),"mobile"!==o&&K&&G({x:e.clientX,y:e.clientY,date:t})})(e,t.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:[s&&0===a&&"mobile"!==o&&Ie("span",{className:"mr-auto ml-1 text-[10px] font-medium text-gray-400 dark:text-gray-500",children:T(t.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 ${t.isToday?Yt:i?"text-gray-900 dark:text-gray-100":"text-gray-400 dark:text-gray-600"} `,children:1===t.day&&"desktop"===o?t.date.toLocaleDateString(F,{month:"short",day:"numeric"}):t.day})]}),Ie("div",{className:"pointer-events-none relative flex-1 overflow-hidden px-1",children:[ne&&Ie("div",{className:"pointer-events-none absolute right-0 left-0 z-[100] bg-white dark:bg-gray-900",style:{top:c*Za+"px",height:`${re}px`}}),oe,d&&Ie("div",{className:Qt("df-month-more-events text-xs text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 cursor-pointer hover:underline relative z-20","desktop"===o?"text-left font-normal":"text-center font-medium","pointer-events-auto","z-[100]"),onClick:e=>{e.stopPropagation(),w?w(t.date):(null==C||C(t.date),null==D||D(exports.ViewType.DAY))},children:["+",te,"desktop"===o?` ${Y("more")}`:""]})]})]},`day-${t.date.getTime()}`);var ce},he=a.useMemo(()=>J?J.date.toLocaleDateString(F,{month:"long",year:"numeric"}):"",[J,F]);return Ie("div",{className:"relative border-b border-gray-200 select-none dark:border-gray-700",style:{height:Q},children:[d&&J&&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 ${V?"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:he})}),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:X.days.map((e,t)=>ue(e,t))}),ae.length>0&&Ie("div",{className:"pointer-events-none absolute right-0 left-0",style:{top:"33px",height:`${ce}px`},children:ae.slice(0,de).map((e,t)=>Ie("div",{className:"absolute inset-0",children:e.filter(e=>!se[0].segmentIsHidden.has(e.id)).map(e=>Ie(Lr,{event:e.event,isAllDay:!0,segment:e,segmentIndex:t,viewType:exports.ViewType.MONTH,isMultiDay:!0,calendarRef:m,hourHeight:72,firstHour:0,onEventUpdate:f,onEventDelete:p,onMoveStart:v,onResizeStart:b,isBeingDragged:l&&g.eventId===e.event.id&&"move"===g.mode,isBeingResized:l&&g.eventId===e.event.id&&"resize"===g.mode,newlyCreatedEventId:r,onDetailPanelOpen:x,selectedEventId:k,onEventSelect:S,onEventLongPress:M,detailPanelEventId:N,onDetailPanelToggle:I,customDetailPanelContent:R,customEventDetailDialog:O,app:P,isMobile:"desktop"!==o,enableTouch:$,appTimeZone:j},e.id))},`layer-${t}`))})]})}),K&&B&&Ie(yr,{x:B.x,y:B.y,date:B.date,viewType:exports.ViewType.MONTH,onClose:()=>G(null),app:P,onCreateEvent:()=>{if(y){const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:B.x,clientY:B.y};y(e,B.date)}}})]})});_a.displayName="WeekComponent";const za=({app:e,config:t,customDetailPanelContent:n,customEventDetailDialog:r,calendarRef:o,selectedEventId:i,onEventSelect:l,detailPanelEventId:s,onDetailPanelToggle:d})=>{var c,g,m;const{getWeekDaysLabels:f,getMonthLabels:p,locale:v}=bt(),y=e.getCurrentDate(),b=e.getEvents(),x=null!==(c=t.startOfWeek)&&void 0!==c?c:1,w=e.timeZone,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]=a.useState(y),[k,S]=a.useState(!1),[M,N]=a.useState("forward"),I=a.useRef(y),R=a.useRef(null),O=y.getFullYear(),H=y.getMonth();a.useEffect(()=>{if(!E)return;if(O===I.current.getFullYear()&&H===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)}},[O,H,E]);const A=a.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(ge(t))}return o})(C,x):[],[E,C,x]),P=a.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("-"),$=a.useRef(null),j=a.useMemo(()=>{const e=$.current;return e&&e.length===b.length&&e.every((e,t)=>e===b[t])?e:($.current=b,b)},[b]),Y=a.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=z(e.start,w),a=e.end?z(e.end,w):r,o=new Date(r);o.setHours(0,0,0,0);const i=new Date(a);i.setHours(0,0,0,0);let l=new Date(i);if(!e.allDay){0!==a.getHours()||0!==a.getMinutes()||0!==a.getSeconds()||0!==a.getMilliseconds()||l.setDate(l.getDate()-1)}l<o&&(l=new Date(o));const s=t(o),d=t(l);let c=s.getTime();const u=d.getTime();for(;c<=u;){n(c,e);const t=new Date(c);t.setDate(t.getDate()+7),t.setHours(0,0,0,0),c=t.getTime()}}),e},[j,x,w]),{screenSize:F}=vt(),[V,Z]=a.useState(!1);a.useEffect(()=>{Z("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const _=e.getCustomMobileEventRenderer()||er,[U,W]=a.useState(()=>{if("undefined"==typeof window)return 119;const e=window.innerHeight-150;return Math.max(80,Math.ceil(e/6))}),[B,G]=a.useState(()=>"undefined"!=typeof window),K=a.useRef(U),q=a.useRef([]),[X,J]=a.useState(null),[Q,ee]=a.useState(!1),[te,ne]=a.useState(null),[re,ae]=a.useState(null),[oe,ie]=a.useState(null),le=void 0===i?re:i,se=void 0===s?oe:s,de=a.useCallback(e=>{l?l(e):ae(e)},[l]),ce=a.useCallback(e=>{d?d(e):ie(e)},[d]),ue=a.useRef(e.state.highlightedEventId);a.useEffect(()=>{e.state.highlightedEventId?de(e.state.highlightedEventId):ue.current&&de(null),ue.current=e.state.highlightedEventId},[e.state.highlightedEventId]);const he=a.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:pe,handleResizeStart:ve,dragState:ye,isDragging:be}=Ma(e,{calendarRef:o,viewType:exports.ViewType.MONTH,onEventsUpdate:(t,n,r)=>{const a=t(j),o=new Set(a.map(e=>e.id)),i=j.filter(e=>!o.has(e.id)),l=new Set(j.map(e=>e.id)),s=a.filter(e=>!l.has(e.id)),d=a.filter(e=>{if(!l.has(e.id))return!1;const t=j.find(t=>t.id===e.id);return t&&we(t,e)});e.applyEventsChanges({delete:i.map(e=>e.id),add:s,update:d.map(e=>({id:e.id,updates:e}))},n,r)},onEventCreate:t=>{"desktop"===F?e.addEvent(t):(ne(t),ee(!0))},onEventEdit:e=>{J(e.id)},currentWeekStart:he,events:j,isMobile:"desktop"!==F}),{handleDrop:xe,handleDragOver:De}=Ta({app:e,onEventCreated:e=>{J(e.id)}}),Ee=a.useMemo(()=>f(v,"short",x),[v,f,x]),{currentMonth:Ce,currentYear:Te,isScrolling:ke,virtualData:Se,weeksData:Me,scrollElementRef:Ne,isNavigating:Re,handleScroll:Oe,handlePreviousMonth:He,handleNextMonth:Ae,handleToday:Pe,setScrollTop:Le}=(({currentDate:e,weekHeight:t,onCurrentMonthChange:n,initialWeeksToLoad:r=104,locale:o="en-US",startOfWeek:i=1,isEnabled:l=!0,snapToMonth:s=!1})=>{const d=a.useRef(null),c=a.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=a.useMemo(()=>{const t=new Date(e);return t.setDate(1),t.setHours(0,0,0,0),me(t,r,i)},[e,r,i]),m=a.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]),[f,p]=a.useState(m),[v,y]=a.useState(600),[b,x]=a.useState(c(e.getMonth(),e.getFullYear())),[w,D]=a.useState(e.getFullYear()),[E,C]=a.useState(!1),[T,k]=a.useState(g),[S,M]=a.useState(!1),N=a.useRef(!1),[I,R]=a.useState(!1),O=a.useRef(e),H=a.useRef(null),A=a.useRef(null),P=a.useRef(new h),L=a.useRef(0),$=a.useRef(0),j=a.useRef(!1),Y=a.useCallback(e=>{e&&(H.current=e)},[]),F=a.useCallback(e=>{let t=P.current.get(e);return t||(t=ge(e),P.current.set(e,t)),t},[]),V=a.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(()=>{p(e=>e+a),H.current&&(H.current.scrollTop+=a)})}}finally{setTimeout(()=>{j.current=!1},200)}},0))},[T,F,t]),Z=a.useMemo(()=>{const e=T.length*t,n=Math.floor(f/t);let r=Math.max(0,n);r=Math.min(r,Math.max(0,T.length-6));const a=Math.min(T.length-1,r+6-1),o=Math.max(0,r-15),i=Math.min(T.length-1,a+15),l=[];for(let e=o;e<=i;e++)l.push({index:e,weekData:T[e],top:e*t,height:t});return{totalHeight:e,visibleItems:l,displayStartIndex:r}},[f,v,t,T]),_=a.useCallback(e=>{if(S||E||0===e.length||!I)return;const t=f+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="",i=0,l=0;Object.entries(a).forEach(([e,t])=>{if(t>l){l=t;const[n,r]=e.split("-");o=n,i=Number.parseInt(r,10)}}),o&&i&&(d.current?o===d.current.month&&i===d.current.year&&(d.current=null,o===b&&i===w||(x(o),D(i),null==n||n(o,i))):o===b&&i===w||(x(o),D(i),null==n||n(o,i)))},[v,b,w,S,E,n,f,I]),z=a.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,p(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),A.current&&clearTimeout(A.current),A.current=setTimeout(()=>{C(!1)},u.SCROLL_DEBOUNCE)},[t,V,S]),U=a.useCallback((e,n=!0)=>{if(!H.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 H.current.scrollTo({top:e,behavior:n?"smooth":"auto"}),void r()}const o=(e.getDay()-i+7)%7,l=new Date(e);l.setDate(e.getDate()-o),l.setHours(0,0,0,0);const s=T[0],d=T.at(-1);let c=0,u=!1,h=!1;l<s.startDate?(c=Math.ceil((s.startDate.getTime()-l.getTime())/6048e5),u=!0):l>d.startDate&&(c=Math.ceil((l.getTime()-d.startDate.getTime())/6048e5),h=!0);const g=Math.min(c+10,52);if(u){const a=[];for(let e=g;e>=1;e--){const t=new Date(s.startDate);t.setDate(t.getDate()-7*e),a.push(F(t))}const o=a.length*t;k(e=>[...a,...e]),requestAnimationFrame(()=>{const i=[...a,...T].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(H.current&&-1!==i){const e=i*t;H.current.scrollTop+=o,p(e=>e+o),setTimeout(()=>{H.current&&H.current.scrollTo({top:e,behavior:n?"smooth":"auto"})},50)}r()})}else if(h){const a=[];for(let e=1;e<=g;e++){const t=new Date(d.startDate);t.setDate(t.getDate()+7*e),a.push(F(t))}k(e=>[...e,...a]),requestAnimationFrame(()=>{const o=[...T,...a].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(H.current&&-1!==o){const e=o*t;H.current.scrollTo({top:e,behavior:n?"smooth":"auto"})}r()})}else r()},[T,t,F]),W=a.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,i=0;for(const[e,t]of Object.entries(r))t>i&&(i=t,[a,o]=e.split("-").map(Number));const l=new Date(o,a-1,1);U(l)},[Z.displayStartIndex,T,U]),B=a.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,i=0;for(const[e,t]of Object.entries(r))t>i&&(i=t,[a,o]=e.split("-").map(Number));const l=new Date(o,a+1,1);U(l)},[Z.displayStartIndex,T,U]),G=a.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 i=T.findIndex(e=>e.days.some(e=>e.date.toDateString()===o.toDateString()));if(-1===i)M(!0),N.current=!0,requestAnimationFrame(()=>{U(o,!0),setTimeout(()=>{N.current=!1,M(!1)},200)});else{const e=i*t,n=H.current;n&&(M(!0),N.current=!0,requestAnimationFrame(()=>{p(e),requestAnimationFrame(()=>{n&&(n.scrollTop=e,setTimeout(()=>{N.current=!1,M(!1)},200))})}))}},[T,t,n,U]);return a.useEffect(()=>{_(Z.visibleItems)},[Z.visibleItems,_]),a.useEffect(()=>{const t=O.current,r=t.getMonth(),a=t.getFullYear(),o=e.getMonth(),i=e.getFullYear();if(r!==o||a!==i){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 l="",s=0;for(const[e,t]of Object.entries(a))t>s&&(s=t,l=e);if(l!==`${o}-${i}`){const e=new Date(i,o,1),t=c(o,i);d.current={month:t,year:i},x(t),D(i),null==n||n(t,i),U(e,!0)}}O.current=e},[e,n,U,Z,T,c]),a.useEffect(()=>{const e=H.current;if(!e)return;const t=new ResizeObserver(([e])=>{y(e.contentRect.height)});return t.observe(e),()=>t.disconnect()},[]),a.useLayoutEffect(()=>{const e=H.current;e&&!I&&l&&(m>0&&(e.scrollTop=m),R(!0))},[I,m,l]),a.useEffect(()=>{var e;if(!s||E||S||!I)return;const n=Math.floor(f/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,i=0,l=0;for(const[e,t]of Object.entries(a))t>l&&(l=t,[o,i]=e.split("-").map(Number));const d=new Date(i,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-f)>5){const e=setTimeout(()=>{U(d,!0)},200);return()=>clearTimeout(e)}},[E,s,S,I,f,t,T,U]),a.useEffect(()=>()=>{A.current&&clearTimeout(A.current)},[]),{scrollTop:f,containerHeight:v,currentMonth:b,currentYear:w,isScrolling:E,isNavigating:S,virtualData:Z,scrollElementRef:H,handleScroll:z,scrollToDate:U,handlePreviousMonth:W,handleNextMonth:B,handleToday:G,setScrollTop:p,setContainerHeight:y,setCurrentMonth:x,setCurrentYear:D,setIsScrolling:C,cache:P.current,scrollElementRefCallback:Y,weeksData:T}})({currentDate:y,weekHeight:U,onCurrentMonthChange:(t,n)=>{const r=v.startsWith("zh")||v.startsWith("ja"),a=p(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}),$e=a.useRef(0),[je,Ye]=a.useState(0),Fe=a.useMemo(()=>je-6*U,[je,U]),{visibleWeeks:Ve,startIndex:Ze}=a.useMemo(()=>{var e,t;const{visibleItems:n,displayStartIndex:r}=Se,a=n.findIndex(e=>e.index===r);if(-1===a)return q.current.length>0?{visibleWeeks:q.current,startIndex:$e.current}:{visibleWeeks:[],startIndex:r};const o=Math.max(0,a-2),i=n.slice(o,a+8),l=null!==(t=null===(e=n[o])||void 0===e?void 0:e.index)&&void 0!==t?t:r;return i.length>=6&&(q.current=i,$e.current=l),{visibleWeeks:i,startIndex:l}},[Se]),_e=a.useMemo(()=>Ze*U,[Ze,U]),ze=a.useRef(!0),Ue=a.useRef(!1),We=((e,t)=>{const[n,r]=a.useState(e);return a.useEffect(()=>{const n=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(n)}},[e,t]),n})(Se.displayStartIndex,250);a.useEffect(()=>{Re&&(Ue.current=!0)},[Re]),a.useEffect(()=>{if(ze.current)return void(ze.current=!1);const t=Me[We];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,Ue.current?"navigation":"scroll"),Ue.current=!1},[e,Me,We]);const Be=a.useMemo(()=>{const e=Se.totalHeight,t=Ze*U+Ve.length*U+Fe;return Math.max(0,e-t)},[Se.totalHeight,Ze,U,Fe,Ve.length]);a.useEffect(()=>{const e=Ne.current;if(!e)return;const t=new ResizeObserver(t=>{for(const n of t){const t=n.contentRect.height;if(Ye(t),t>0){const n=Math.max(80,Math.ceil(t/6));if(n!==K.current){const t=e.scrollTop;if(t>0){const r=Math.round(t/K.current)*n;e.scrollTop=r,Le(r)}W(n),K.current=n}}}});return t.observe(e),()=>{t.disconnect()}},[Ne,Le]),a.useLayoutEffect(()=>{const e=window.innerHeight-150,t=Math.max(80,Math.ceil(e/6));W(t),K.current=t,G(!0)},[]),a.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 Ge=a.useCallback(t=>e.updateEvent(t.id,t),[e]),Ke=a.useCallback(t=>e.deleteEvent(t),[e]),qe=t=>{e.changeView(t)},Xe=a.useCallback(()=>J(null),[]),Je=a.useCallback(t=>{const n=e.getReadOnlyConfig().viewable;if(("desktop"!==F||V)&&t&&n){const e=j.find(e=>e.id===t);if(e)return ne(e),void ee(!0)}de(t)},[F,V,j,de,e]),Qe=a.useCallback(e=>{("desktop"!==F||V)&&de(e)},[F,V,de]);return Ie("div",{className:xt,children:[Ie(jr,{calendar:e,viewType:exports.ViewType.MONTH,currentDate:y,customTitle:(()=>{const e=v.startsWith("zh")||v.startsWith("ja");if(E){const t=p(v,e?"short":"long")[C.getMonth()],n=C.getFullYear();return e?`${n}年${t}`:`${t} ${n}`}return e?`${Te}年${Ce}`:`${Ce} ${Te}`})(),onPrevious:()=>{e.goToPrevious(),E||He()},onNext:()=>{e.goToNext(),E||Ae()},onToday:()=>{e.goToToday(),E||Pe()}}),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:A.map((a,i)=>{var l;const s=null!==(l=Y.get(a.startDate.getTime()))&&void 0!==l?l:[],d={index:i,weekData:a,top:i*U,height:U},c=5===i?Object.assign(Object.assign({},d),{height:d.height+Fe}):d;return Ie(_a,{item:c,weekHeight:U,showWeekNumbers:t.showWeekNumbers,showMonthIndicator:!1,currentMonth:"",currentYear:0,screenSize:F,isScrolling:!1,calendarRef:o,events:s,onEventUpdate:Ge,onEventDelete:Ke,onMoveStart:fe,onCreateStart:pe,onResizeStart:ve,isDragging:be,dragState:ye,newlyCreatedEventId:X,onDetailPanelOpen:Xe,onMoreEventsClick:e.onMoreEventsClick,onChangeView:qe,onSelectDate:e.selectDate,selectedEventId:le,onEventSelect:Je,onEventLongPress:Qe,detailPanelEventId:se,onDetailPanelToggle:ce,customDetailPanelContent:n,customEventDetailDialog:r,onCalendarDrop:xe,onCalendarDragOver:De,calendarSignature:L,app:e,enableTouch:V,appTimeZone:w},`week-${a.startDate.getTime()}`)})})}:{ref:Ne,className:Ct,style:{overflow:"hidden auto",overscrollBehavior:"contain",visibility:B?"visible":"hidden"},onScroll:Oe,children:[Ie("div",{style:{height:_e}}),Ve.map((a,i)=>{var l;const s=null!==(l=Y.get(a.weekData.startDate.getTime()))&&void 0!==l?l:[],d=5===i?Object.assign(Object.assign({},a),{height:a.height+Fe}):a,c=!(!1===t.showMonthIndicator||!a.weekData.days.some(e=>1===e.day))&&ke;return Ie(_a,{item:d,weekHeight:U,showWeekNumbers:t.showWeekNumbers,showMonthIndicator:t.showMonthIndicator,currentMonth:Ce,currentYear:Te,screenSize:F,isScrolling:c,calendarRef:o,events:s,onEventUpdate:Ge,onEventDelete:Ke,onMoveStart:fe,onCreateStart:pe,onResizeStart:ve,isDragging:be,dragState:ye,newlyCreatedEventId:X,onDetailPanelOpen:Xe,onMoreEventsClick:e.onMoreEventsClick,onChangeView:qe,onSelectDate:e.selectDate,selectedEventId:le,onEventSelect:Je,onEventLongPress:Qe,detailPanelEventId:se,onDetailPanelToggle:ce,customDetailPanelContent:n,customEventDetailDialog:r,onCalendarDrop:xe,onCalendarDragOver:De,calendarSignature:L,app:e,enableTouch:V,appTimeZone:w},`week-${a.weekData.startDate.getTime()}`)}),Ie("div",{style:{height:Be}})]}),Ie(_,{isOpen:Q,onClose:()=>{ee(!1),ne(null)},onSave:t=>{j.some(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),ee(!1),ne(null)},draftEvent:te,app:e})]})},Ua={showWeekNumbers:!1,showMonthIndicator:!0,startOfWeek:1},Wa=e=>n.h(Ia,Object.assign(Object.assign({},e),{viewType:exports.ViewType.MONTH,originalComponent:za,className:"month-view-factory"}));Wa.displayName="MonthViewAdapter";const Ba=(e={})=>{const t=Object.assign(Object.assign({},Ua),e);return{type:exports.ViewType.MONTH,component:Wa,config:t}};const Ga=r.memo(({date:e,isToday:t,locale:n,onSelectDate:r,onCreateStart:a,onMoreEventsClick:o,moreCount:i=0,onContextMenu:l})=>{const{t:s}=bt(),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-(--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==l||l(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:"df-fill-primary rounded-sm px-1 py-0.5 text-[9px] leading-none font-bold",children:u}),Ie("span",{className:"ml-auto text-[10px] font-medium "+(t?"df-fill-primary flex h-5 w-5 items-center justify-center rounded-full":"text-gray-700 dark:text-gray-300"),children:d})]}),i>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:["+",i," ",s("more")]})})]})});Ga.displayName="YearDayCell";const Ka=r.memo(({rowDays:e,events:t,columnsPerRow:n,app:r,calendarRef:o,locale:i,isDragging:l,dragState:s,onMoveStart:d,onResizeStart:c,onCreateStart:u,selectedEventId:h,onEventSelect:g,onMoreEventsClick:m,newlyCreatedEventId:f,onDetailPanelOpen:p,detailPanelEventId:v,onDetailPanelToggle:y,customDetailPanelContent:b,customEventDetailDialog:x,onContextMenu:w,appTimeZone:D})=>{const E=a.useMemo(()=>{const e=re(D);return e.setHours(0,0,0,0),e},[D]),C=a.useCallback((e,t)=>{e.preventDefault(),e.stopPropagation(),w({x:e.clientX,y:e.clientY,date:t})},[w]),T=a.useCallback(e=>{r.selectDate(e)},[r]),k=a.useMemo(()=>function(e,t,n,r,a){if(0===t.length)return[];const o=t[0],i=t.at(-1);if(!o||!i)return[];const l=new Date(o.getFullYear(),o.getMonth(),o.getDate()).getTime(),s=new Date(i.getFullYear(),i.getMonth(),i.getDate(),23,59,59,999).getTime(),d=e.map(e=>{const t=z(e.start,a),n=e.end?z(e.end,a):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===d.length)return[];const c=ft(d.map(e=>e.event),r);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=[];return d.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 c=0;for(;;){h[c]||(h[c]=[]);let e=!1;for(let t=a;t<=o;t++)if(h[c][t]){e=!0;break}if(!e){for(let e=a;e<=o;e++)h[c][e]=!0;break}c++}u.push({id:`${e.id}::year-${l}`,event:e,startCellIndex:a,endCellIndex:o,isFirstSegment:i,isLastSegment:d,visualRowIndex:c})}),u}(t,e,n,r.state.allDaySortComparator,D),[t,e,n,r.state.allDaySortComparator,D]),{visibleSegments:S,moreCounts:M}=a.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 i=Math.max(0,a.startCellIndex),l=Math.min(e.length-1,a.endCellIndex);for(let e=i;e<=l;e++){const n=t[e]>3?1:2;if(a.visualRowIndex>n){o=!1;break}}if(o)n.push(a);else for(let e=i;e<=l;e++)r[e]++}),{visibleSegments:n,moreCounts:r}},[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(Ga,{date:e,isToday:n,locale:i,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(Lr,{event:e.event,isAllDay:!!e.event.allDay,viewType:exports.ViewType.YEAR,yearSegment:e,columnsPerRow:n,isBeingDragged:l&&s.eventId===e.event.id,selectedEventId:h,onMoveStart:d,onResizeStart:c,onEventSelect:g,onDetailPanelToggle:y,newlyCreatedEventId:f,onDetailPanelOpen:p,calendarRef:o,app:r,detailPanelEventId:v,customDetailPanelContent:b,customEventDetailDialog:x,firstHour:0,hourHeight:0,onEventUpdate:e=>r.updateEvent(e.id,e),onEventDelete:e=>r.deleteEvent(e),appTimeZone:D})},e.id))})})]})});Ka.displayName="YearRowComponent";const qa=({app:e,calendarRef:n,customDetailPanelContent:r,customEventDetailDialog:o,config:i,selectedEventId:l,onEventSelect:s,detailPanelEventId:d,onDetailPanelToggle:c})=>{var u;const{t:h,locale:g}=bt(),m=e.getCurrentDate(),f=m.getFullYear(),p=e.getEvents(),v=e.timeZone,y=a.useRef(null),[b,x]=a.useState(()=>"undefined"!=typeof window?Math.max(1,Math.floor(window.innerWidth/80)):7),[w,D]=a.useState(()=>"undefined"!=typeof window),[E,C]=a.useState(()=>"undefined"!=typeof window&&window.innerWidth<768),[T,k]=a.useState(null),[S,M]=a.useState(null),N=void 0===l?T:l,I=void 0===d?S:d,[R,O]=a.useState(null),H=a.useCallback(e=>{s?s(e):k(e)},[s]),A=a.useCallback(e=>{c?c(e):M(e)},[c]),P=a.useCallback(()=>{O(null)},[]),[L,$]=a.useState(null),j=e.canMutateFromUI();a.useEffect(()=>{j||$(null)},[j]),a.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]"),i=t.closest("[data-calendar-picker-dropdown]"),l=t.closest(".df-context-menu");n||r||a||o||i||l||(H(null),A(null),$(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const Y=a.useRef(null);a.useLayoutEffect(()=>{const e=y.current;if(!e)return;const t=new ResizeObserver(e=>{Y.current&&clearTimeout(Y.current),Y.current=setTimeout(()=>{const t=e[0].contentRect.width,n=Math.floor(t/80);x(Math.max(1,n)),C(t<768),D(!0)},60)});return t.observe(e),()=>{t.disconnect(),Y.current&&clearTimeout(Y.current)}},[]);const F=a.useRef(e.state.highlightedEventId);a.useEffect(()=>{e.state.highlightedEventId?(H(e.state.highlightedEventId),requestAnimationFrame(()=>{const t=y.current;if(!t)return;const n=t.querySelector(`[data-event-id="${e.state.highlightedEventId}"]`);null==n||n.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})})):F.current&&H(null),F.current=e.state.highlightedEventId},[e.state.highlightedEventId]);const{handleMoveStart:V,handleResizeStart:Z,handleCreateStart:_,dragState:U,isDragging:W}=Ma(e,{calendarRef:n,viewType:exports.ViewType.YEAR,onEventsUpdate:(t,n,r)=>{const a=t(p).filter(e=>{const t=p.find(t=>t.id===e.id);return t&&we(t,e)});a.length>0&&e.applyEventsChanges({update:a.map(e=>({id:e.id,updates:e}))},n,r)},currentWeekStart:new Date,events:p,onEventCreate:t=>{e.addEvent(t)},onEventEdit:e=>{O(e.id)},isMobile:E}),B=null!==(u=null==i?void 0:i.showTimedEventsInYearView)&&void 0!==u&&u,G=a.useCallback((n,r)=>{if(B)null==_||_(n,r);else{const n=t.Temporal.PlainDate.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate()}),a={id:`event-${Date.now()}`,title:h("newEvent")||"New Event",start:n,end:n,allDay:!0,calendarId:e.getCalendarRegistry().getDefaultCalendarId()||"default"};e.addEvent(a),O(a.id)}},[B,_,e,h]),K=a.useMemo(()=>{const e=[],t=new Date(f,0,1),n=new Date(f,11,31);for(let r=t.getTime();r<=n.getTime();r+=864e5)e.push(new Date(r));return e},[f]),q=a.useMemo(()=>function(e,t){const n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}(K,b),[K,b]),X=a.useMemo(()=>{const e=new Date(f,0,1),t=new Date(f,11,31,23,59,59);return p.filter(n=>{if(!n.start)return!1;if(!B&&!n.allDay)return!1;const r=z(n.start,v),a=n.end?z(n.end,v):r;return r<=t&&a>=e})},[p,f,B,v]),J=a.useMemo(()=>{const e=X.map(e=>{const t=z(e.start,v),n=e.end?z(e.end,v):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 q.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)})},[q,X,v]);return Ie("div",{className:xt,onContextMenu:e=>e.preventDefault(),children:[Ie(jr,{calendar:e,viewType:exports.ViewType.YEAR,currentDate:m,customTitle:g.startsWith("zh")||g.startsWith("ja")?`${f}年`:`${f}`,onPrevious:()=>{const t=new Date(m);t.setFullYear(t.getFullYear()-1),e.setCurrentDate(t)},onNext:()=>{const t=new Date(m);t.setFullYear(t.getFullYear()+1),e.setCurrentDate(t)},onToday:()=>{e.goToToday()}}),Ie("div",{ref:y,className:`${Ct} ${Tt}`,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:w?1:0,transition:"opacity 0.2s ease"},children:q.map((t,a)=>Ie(Ka,{rowDays:t,events:J[a],columnsPerRow:b,app:e,calendarRef:n,locale:g,isDragging:W,dragState:U,onMoveStart:V,onResizeStart:Z,onCreateStart:G,selectedEventId:N,onEventSelect:H,onMoreEventsClick:e.onMoreEventsClick,newlyCreatedEventId:R,onDetailPanelOpen:P,detailPanelEventId:I,onDetailPanelToggle:A,customDetailPanelContent:r,customEventDetailDialog:o,onContextMenu:e=>{j&&$(e)},appTimeZone:v},a))})}),j&&L&&Ie(yr,{x:L.x,y:L.y,date:L.date,viewType:exports.ViewType.YEAR,onClose:()=>$(null),app:e,onCreateEvent:()=>{if(L&&L.date){const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:L.x,clientY:L.y};G(e,L.date)}}})]})};function Xa(e,t,n,r=1,a){const o=new Date(n,t,1),i=new Date(n,t+1,0).getDate(),l=(o.getDay()-r+7)%7,s=o.getTime(),d=new Date(n,t,i,23,59,59,999).getTime(),c=e.filter(e=>!!e.start).map(e=>{const t=z(e.start,a),n=e.end?z(e.end,a):t,r=new Date(t.getFullYear(),t.getMonth(),t.getDate()),o=new Date(n.getFullYear(),n.getMonth(),n.getDate());return{event:e,startMs:r.getTime(),endMs:o.getTime(),eventStartDay:r,eventEndDay:o}}).filter(e=>e.startMs<=d&&e.endMs>=s);if(0===c.length)return{segments:[],maxVisualRow:-1};const u=ft(c.map(e=>e.event));c.sort((e,t)=>{const n=!!e.event.allDay;return n!==!!t.event.allDay?n?-1:1:u(e.event,t.event)});const h=[],g=[];c.forEach(({event:e,startMs:r,endMs:a,eventStartDay:o,eventEndDay:i})=>{const c=Math.max(r,s),u=Math.min(a,d),m=new Date(c).getDate(),f=new Date(u).getDate(),p=l+(m-1),v=l+(f-1),y=o.getMonth()===t&&o.getFullYear()===n,b=i.getMonth()===t&&i.getFullYear()===n;let x=0;for(;;){g[x]||(g[x]=[]);let e=!1;for(let t=p;t<=v;t++)if(g[x][t]){e=!0;break}if(!e){for(let e=p;e<=v;e++)g[x][e]=!0;break}x++}h.push({id:`${e.id}::month-${t}`,event:e,startCellIndex:p,endCellIndex:v,isFirstSegment:y,isLastSegment:b,visualRowIndex:x,monthIndex:t})});const m=h.length>0?Math.max(...h.map(e=>e.visualRowIndex)):-1;return{segments:h,maxVisualRow:m}}const Ja=({app:e,calendarRef:n,customDetailPanelContent:r,customEventDetailDialog:o,config:i,selectedEventId:l,onEventSelect:s,detailPanelEventId:d,onDetailPanelToggle:c})=>{var u,h;const{t:g,locale:m,getWeekDaysLabels:f}=bt(),p=e.getCurrentDate(),v=p.getFullYear(),y=e.getEvents(),b=e.timeZone,x=re(b);x.setHours(0,0,0,0);const w=null!==(u=null==i?void 0:i.startOfWeek)&&void 0!==u?u:1,D=a.useRef(null),E=a.useRef(null),C=a.useRef(null),[T,k]=a.useState(0),[S,M]=a.useState(0),[N,I]=a.useState(null),[R,O]=a.useState(null),H=void 0===l?N:l,A=void 0===d?R:d,P=e=>{s?s(e):I(e)},L=e=>{c?c(e):O(e)},[$,j]=a.useState(null),[Y,F]=a.useState(null),V=e.canMutateFromUI();a.useEffect(()=>{V||F(null)},[V]),a.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]"),i=t.closest("[data-calendar-picker-dropdown]");n||r||a||o||i||(P(null),L(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const Z=a.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()-w+7)%7+r;a>e&&(e=a)}return e},[v,w]),{handleMoveStart:_,handleResizeStart:U,handleCreateStart:W,dragState:B,isDragging:G}=Ma(e,{calendarRef:n,viewType:exports.ViewType.YEAR,onEventsUpdate:(t,n,r)=>{const a=t(y).filter(e=>{const t=y.find(t=>t.id===e.id);return t&&we(t,e)});a.length>0&&e.applyEventsChanges({update:a.map(e=>({id:e.id,updates:e}))},n,r)},currentWeekStart:new Date,events:y,onEventCreate:t=>{e.addEvent(t)},onEventEdit:e=>{j(e.id)}}),K=null!==(h=null==i?void 0:i.showTimedEventsInYearView)&&void 0!==h&&h,q=a.useCallback((n,r)=>{if(K)null==W||W(n,r);else{const n=t.Temporal.PlainDate.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate()}),a={id:`event-${Date.now()}`,title:g("newEvent")||"New Event",start:n,end:n,allDay:!0};e.addEvent(a),j(a.id)}},[K,W,e,g]),X=a.useMemo(()=>{const e=f(m,"short",w).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<Z;n++)t.push(e[n%7]);return t},[m,f,Z,w]),J=a.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(!K&&!n.allDay)return!1;const r=z(n.start,b),a=n.end?z(n.end,b):r;return r<=t&&a>=e})},[y,v,K,b]),Q=a.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()-w+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<Z;)o.push(null);const i=n.toLocaleDateString(m,{month:"short"}),l=i.charAt(0).toUpperCase()+i.slice(1).toLowerCase(),{segments:s,maxVisualRow:d}=Xa(J,t,v,w,b),c=d+1,u=Math.max(60,20+18*c);e.push({monthIndex:t,monthName:l,days:o,eventSegments:s,minHeight:u})}return e},[v,m,Z,J,w,b]),ee=a.useCallback(e=>{const t=e.currentTarget;D.current&&(D.current.scrollLeft=t.scrollLeft),E.current&&(E.current.scrollTop=t.scrollTop)},[]);a.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()}},[Q]);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(jr,{calendar:e,viewType:exports.ViewType.YEAR,currentDate:p,customTitle:m.startsWith("zh")||m.startsWith("ja")?`${v}年`:`${v}`,onPrevious:()=>{const t=new Date(p);t.setFullYear(t.getFullYear()-1),e.setCurrentDate(t)},onNext:()=>{const t=new Date(p);t.setFullYear(t.getFullYear()+1),e.setCurrentDate(t)},onToday:()=>{e.goToToday()}})}),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(${Z}, minmax(0, 1fr))`,minWidth:"1352px"},children:X.map((e,t)=>{const n=(t+w)%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:[Q.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 ${Tt}`,onScroll:ee,children:Ie("div",{className:"flex min-h-full flex-col",style:{minWidth:"1352px"},children:Q.map(t=>Ie("div",{className:"relative shrink-0 grow",style:{minHeight:`${t.minHeight}px`},children:[Ie("div",{className:"absolute inset-0 z-0 grid",style:{gridTemplateColumns:`repeat(${Z}, minmax(0, 1fr))`},children:t.days.map((n,r)=>{const a=(r+w)%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-${t.monthIndex}-${r}`);const i=(e=>e.getTime()===x.getTime())(n);return Ie("div",{"data-date":`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}-${String(n.getDate()).padStart(2,"0")}`,className:`df-hover-primary-dark-md 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 ${o?"df-year-view-weekend-cell bg-blue-50 dark:bg-blue-900/30":""} `,onClick:()=>e.selectDate(n),onDblClick:e=>q(e,n),onContextMenu:e=>((e,t)=>{e.preventDefault(),e.stopPropagation(),V&&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 ${i?"df-fill-primary font-bold shadow-sm":"text-gray-700 dark:text-gray-300"} `,children:n.getDate()})},n.getTime())})}),t.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:t.eventSegments.map(t=>Ie("div",{className:"pointer-events-auto",children:Ie(Lr,{event:t.event,isAllDay:!!t.event.allDay,viewType:exports.ViewType.YEAR,yearSegment:t,columnsPerRow:Z,isBeingDragged:G&&B.eventId===t.event.id,selectedEventId:H,onMoveStart:_,onResizeStart:U,onEventSelect:P,onDetailPanelToggle:L,newlyCreatedEventId:$,onDetailPanelOpen:()=>j(null),calendarRef:n,app:e,detailPanelEventId:A,customDetailPanelContent:r,customEventDetailDialog:o,firstHour:0,hourHeight:0,onEventUpdate:t=>e.updateEvent(t.id,t),onEventDelete:t=>e.deleteEvent(t),appTimeZone:b})},t.id))})})]},t.monthIndex))})}),V&&Y&&Ie(yr,{x:Y.x,y:Y.y,date:Y.date,viewType:exports.ViewType.YEAR,onClose:()=>F(null),app:e,onCreateEvent:()=>{const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:Y.x,clientY:Y.y};q(e,Y.date)}})]})},Qa=({date:e,events:t,anchorEl:o,position:i,onClose:l,locale:s,app:d,customContent:c,appTimeZone:u})=>{const{t:h}=bt(),g=a.useRef(null);a.useEffect(()=>{const e=e=>{const t=e.target;!g.current||g.current.contains(t)||o.contains(t)||l()},t=e=>{"Escape"===e.key&&l()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[o,l]);const m=d.getCalendars(),f=new Map(m.map(e=>[e.id,e])),p=e.toLocaleDateString(s,{weekday:"long",month:"long",day:"numeric"}),v=Ie(n.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===t.length?Ie("div",{className:"px-4 py-3 text-center text-xs text-gray-400",children:"No events"}):t.map(e=>{var t,n;const r=e.calendarId?f.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=z(e.start,u).toLocaleTimeString(s,{hour:"2-digit",minute:"2-digit",hour12:!1}),e.end){o+=` – ${z(e.end,u).toLocaleTimeString(s,{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:h("allDay")}),o&&Ie("div",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:o})]})]},e.id)})})]});return r.createPortal(Ie("div",{ref:g,"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:i.top,left:i.left},children:c?c(e,t):v}),document.body)};function eo(e,t,n,r){const a=new Map,o=new Date(t,0,1);o.setHours(0,0,0,0);const i=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=z(l.start,r),s=l.end?z(l.end,r):new Date(e);if(e.setHours(0,0,0,0),s.setHours(0,0,0,0),e>i||s<o)continue;const d=e<o?new Date(o):new Date(e),c=s>i?new Date(t,11,31):new Date(s);d.setHours(0,0,0,0),c.setHours(0,0,0,0);const u=864e5,h=d.getTime(),g=Math.round((c.getTime()-h)/u);for(let e=0;e<=g;e++){const t=new Date(h+e*u),n=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`,r=a.get(n);r?r.push(l):a.set(n,[l])}}return a}function to(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 no=({app:e,config:t})=>{var n,r,o;const{locale:i,getWeekDaysLabels:l}=bt(),s=e.getCurrentDate(),d=s.getFullYear(),c=e.getEvents(),u=null!==(n=null==t?void 0:t.startOfWeek)&&void 0!==n?n:1,h=null!==(r=null==t?void 0:t.showTimedEventsInYearView)&&void 0!==r&&r,g=null!==(o=null==t?void 0:t.gridHeatmapLevels)&&void 0!==o?o:5,m=e.timeZone,f=a.useMemo(()=>{const e=re(m);return e.setHours(0,0,0,0),e},[m]),[p,v]=a.useState(null);a.useEffect(()=>{if(!p)return;const e=e=>{const t=e.target;t.closest("[data-grid-day-popup]")||t.closest("[data-grid-day-cell]")||v(null)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[p]);const y=a.useMemo(()=>eo(c,d,h,m),[c,d,h,m]),b=a.useMemo(()=>eo(c,d,!0,m),[c,d,m]),x=a.useMemo(()=>l(i,"narrow",u).map(e=>i.startsWith("zh")?e.at(-1):e.charAt(0).toUpperCase()),[i,l,u]),w=a.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 l=n.toLocaleDateString(i,{month:"long"}),s=l.charAt(0).toUpperCase()+l.slice(1);e.push({monthIndex:t,monthName:s,cells:a})}return e},[d,i,u]),D=a.useCallback((n,r,a)=>{var o,i;const l=null!==(o=null==t?void 0:t.gridDateClick)&&void 0!==o?o:"popup";if("function"==typeof l){const e=`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,"0")}-${String(r.getDate()).padStart(2,"0")}`;return void l(r,null!==(i=b.get(e))&&void 0!==i?i:[])}if("popup"===l){const e=n.currentTarget;p&&p.date.getTime()===r.getTime()&&p.monthIndex===a?v(null):v({date:r,monthIndex:a,anchorEl:e,position:to(e)})}else"day-view"===l&&(e.setCurrentDate(r),e.changeView(exports.ViewType.DAY))},[t,e,p,b]),E=a.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=b.get(e))&&void 0!==a?a:[])}"day-view"===o&&(v(null),e.setCurrentDate(n),e.changeView(exports.ViewType.DAY))},[t,e,b]),C=a.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=b.get(t))&&void 0!==e?e:[]].toSorted((e,t)=>{const n=!!e.allDay;return n!==!!t.allDay?n?-1:1:0})},[p,b]);return Ie("div",{className:xt,children:[Ie(jr,{calendar:e,viewType:exports.ViewType.YEAR,currentDate:s,customTitle:i.startsWith("zh")||i.startsWith("ja")?`${d}年`:`${d}`,onPrevious:()=>{const t=new Date(s);t.setFullYear(t.getFullYear()-1),e.setCurrentDate(t)},onNext:()=>{const t=new Date(s);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:w.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:[x.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 i=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`,l=n&&null!==(o=null===(a=y.get(i))||void 0===a?void 0:a.length)&&void 0!==o?o:0;var s,d;return Ie("div",{"data-grid-day-cell":!0,className:"cursor-pointer rounded-sm transition-colors hover:opacity-80",style:n?(d=g,0===(s=l)?{}:{backgroundColor:`var(--heat-${Math.min(s,d)})`}):{},onClick:n=>D(n,t,e.monthIndex),onDblClick:()=>E(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()===f.getTime()?"df-fill-primary font-bold":n?l>0?l>=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(Qa,{date:p.date,events:C,anchorEl:p.anchorEl,position:p.position,onClose:()=>v(null),locale:i,app:e,customContent:null==t?void 0:t.gridPopupContent,appTimeZone:m})]})},ro=e=>{var t;const n=(null===(t=e.config)||void 0===t?void 0:t.mode)||"year-canvas";return"fixed-week"===n?Ie(Ja,Object.assign({},e)):"grid"===n?Ie(no,{app:e.app,config:e.config}):Ie(qa,Object.assign({},e))},ao={},oo=e=>n.h(Ia,Object.assign(Object.assign({},e),{viewType:exports.ViewType.YEAR,originalComponent:ro,className:"year-view-factory"}));oo.displayName="YearViewAdapter";const io={enableAutoRecalculate:!0,enableValidation:!0,defaultEvents:[],maxEventsPerDay:50};function lo(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 r.createPortal}}),exports.AlertCircle=({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:"12",cy:"12",r:"10"}),Ie("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),Ie("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]}),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=An,exports.CalendarApp=Me,exports.CalendarEvent=Lr,exports.CalendarRegistry=M,exports.CalendarRenderer=class{constructor(e,t){this.app=e,this.container=null,this.unsubscribe=null,this.renderRequested=!1,this.extraProps={},this.customRenderingStore=new cr(t),t&&this.app.setOverrides(t),this.unsubscribe=e.subscribe(()=>this.requestRender())}setProps(e){Ee(this.extraProps,e)||(this.extraProps=e,this.requestRender())}requestRender(){this.renderRequested||(this.renderRequested=!0,requestAnimationFrame(()=>{this.render(),this.renderRequested=!1}))}mount(e){this.container=e,this.render()}unmount(){this.container&&(n.render(null,this.container),this.container=null),this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null)}getCustomRenderingStore(){return this.customRenderingStore}render(){this.container&&n.render(n.h(Rn.Provider,{value:this.customRenderingStore},n.h(dr,Object.assign({app:this.app},this.extraProps))),this.container)}},exports.Check=sn,exports.ChevronDown=an,exports.ChevronRight=tn,exports.ChevronsUpDown=dn,exports.ContentSlot=Hn,exports.ContextMenu=ur,exports.ContextMenuColorPicker=({selectedColor:e,onSelect:t,onCustomColor:n})=>{const{t:r}=bt();return Ie("div",{children:[Ie("div",{className:"grid grid-cols-7 gap-2 p-1 px-3",children:vr.map(n=>Ie("button",{type:"button",className:"df-focus-ring-only h-5 w-5 rounded-full border border-gray-200 transition-transform hover:scale-110 focus:ring-2 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()?"df-ring-primary-solid ring-2 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=hr,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=gr,exports.CreateCalendarDialog=jn,exports.CustomRenderingStore=cr,exports.DayflowRangePicker=Wn,exports.DefaultColorPicker=Pn,exports.DefaultEventDetailDialog=Gn,exports.DefaultEventDetailPanel=Ir,exports.EventContextMenu=br,exports.GridContextMenu=yr,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=l,exports.Loader2=gn,exports.LoadingButton=Ln,exports.LocaleContext=yt,exports.LocaleProvider=Cn,exports.MiniCalendar=Xn,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=on,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=Le,exports.calculateDayIndex=ye,exports.calendarPickerDropdown=_t,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=xn,exports.clipboardStore=Je,exports.compareAllDayDisplayPriority=mt,exports.conditionalTheme=(e,t,n)=>e?t:n,exports.convertDateEvent=function(e,t,n,r,a=!1,o){return We(Object.assign({id:e,title:t,start:n,end:r,allDay:a},o))},exports.convertDateEventWithTimeZone=function(e,t,n,r,a,o){return Be(Object.assign({id:e,title:t,start:n,end:r,timeZone:a},o))},exports.convertToDayFlowEvent=ct,exports.createAllDayDisplayComparator=ft,exports.createAllDayEvent=function(e,t,n,r){return We(Object.assign({id:e,title:t,start:n,end:n,allDay:!0},r))},exports.createDateWithHour=C,exports.createDayView=Ha,exports.createEvent=We,exports.createEventWithDate=(e,t)=>{var n,r;const a=pe(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:ve(a,o),end:ve(a,o)})},exports.createEventWithPlainDateTime=(e,n)=>{var r,a;const o=pe(n,null!==(r=e.day)&&void 0!==r?r:0);if(null!==(a=e.allDay)&&void 0!==a&&a){const n=t.Temporal.PlainDate.from({year:o.getFullYear(),month:o.getMonth()+1,day:o.getDate()});return Object.assign(Object.assign({},e),{start:n,end:n})}const i=t.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({},e),{start:i,end:i})},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:ve(a,o),end:ve(a,o)})},exports.createEventWithZonedDateTime=(e,n,r)=>{var a,o;const i=pe(n,null!==(a=e.day)&&void 0!==a?a:0);if(null!==(o=e.allDay)&&void 0!==o&&o){const n=t.Temporal.PlainDate.from({year:i.getFullYear(),month:i.getMonth()+1,day:i.getDate()});return Object.assign(Object.assign({},e),{start:n,end:n})}const l=t.Temporal.ZonedDateTime.from({year:i.getFullYear(),month:i.getMonth()+1,day:i.getDate(),hour:i.getHours(),minute:i.getMinutes(),second:i.getSeconds(),millisecond:i.getMilliseconds(),timeZone:r});return Object.assign(Object.assign({},e),{start:l,end:l})},exports.createEvents=function(e){return e.map(e=>We(e))},exports.createEventsPlugin=function(t={}){const n=Object.assign(Object.assign({},io),t);let r;const a={getAll:()=>r.getAllEvents(),getById:e=>r.getAllEvents().find(t=>t.id===e),add:e=>{if(n.enableValidation){const t=a.validateEvent(e);if(t.length>0)throw new Error(`Event validation failed: ${t.join(", ")}`)}if(n.maxEventsPerDay&&void 0!==e.day){if(a.getByDay(e.day,r.getCurrentDate()).length>=n.maxEventsPerDay)throw new Error(`Maximum events per day (${n.maxEventsPerDay}) exceeded`)}if(r.addEvent(e),n.enableAutoRecalculate){const e=lo(r.getCurrentDate());r.state.events=be(r.getAllEvents(),e)}},update:(t,o)=>e.__awaiter(this,void 0,void 0,function*(){const e=a.getById(t);if(!e)throw new Error(`Event with id ${t} not found`);const i=Object.assign(Object.assign({},e),o);if(n.enableValidation){const e=a.validateEvent(i);if(e.length>0)throw new Error(`Event validation failed: ${e.join(", ")}`)}if(yield r.updateEvent(t,o),n.enableAutoRecalculate){const e=lo(r.getCurrentDate());r.state.events=be(r.getAllEvents(),e)}}),delete:t=>e.__awaiter(this,void 0,void 0,function*(){yield r.deleteEvent(t)}),getByDate:e=>r.getAllEvents().filter(t=>{const n=v(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)=>r.getAllEvents().filter(n=>{const r=v(n.start),a=v(n.end);return r>=e&&r<=t||a>=e&&a<=t||r<=e&&a>=t}),getByDay:(e,t)=>r.getAllEvents().filter(t=>t.day===e),getAllDayEvents:(e,t)=>t.filter(t=>t.day===e&&t.allDay),recalculateEventDays:(e,t)=>be(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"),t},filterEvents:(e,t)=>e.filter(t)};return{name:"events",config:n,install:e=>{r=e},api:a}},exports.createMonthView=Ba,exports.createStandardViews=function(e){return[Ha(null==e?void 0:e.day),Va(null==e?void 0:e.week),Ba(null==e?void 0:e.month)]},exports.createTemporalWithHour=y,exports.createTimedEvent=function(e,t,n,r,a){return We(Object.assign({id:e,title:t,start:n,end:r},a))},exports.createTimezoneEvent=Be,exports.createTimezoneEvents=function(e){return e.map(e=>Be(e))},exports.createWeekView=Va,exports.createYearView=(e={})=>{const t=Object.assign(Object.assign({},ao),e);return{type:exports.ViewType.YEAR,component:oo,config:t}},exports.dateToPlainDate=W,exports.dateToPlainDateTime=B,exports.dateToZonedDateTime=G,exports.daysBetween=function(e,n){const r=e=>{if(m(e))return e;if("function"==typeof e.toPlainDate)return e.toPlainDate();const n=e;return t.Temporal.PlainDate.from({year:n.year,month:n.month,day:n.day})},a=r(e),o=r(n);return a.until(o).days},exports.daysDifference=D,exports.downloadICS=function(e,t={}){const n=ht(e,t),r=`${t.filename||"calendar"}.ics`,a=new Blob([n],{type:"text/calendar;charset=utf-8"}),o=URL.createObjectURL(a),i=document.createElement("a");i.href=o,i.setAttribute("download",r),document.body.append(i),i.click(),i.remove(),URL.revokeObjectURL(o)},exports.en=i,exports.escapeICSValue=rt,exports.extractHourFromDate=E,exports.extractHourFromTemporal=function(e){if(e instanceof Date)return e.getHours()+e.getMinutes()/60;if(F(e))return 0;const t=e;return t.hour+t.minute/60},exports.extractVEvents=st,exports.foldLine=ot,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=Re,exports.formatDateToICSTimestamp=nt,exports.formatEventTimeRange=Q,exports.formatICSDate=tt,exports.formatMonthYear=e=>`${["January","February","March","April","May","June","July","August","September","October","November","December"][e.getMonth()]} ${e.getFullYear()}`,exports.formatProperty=it,exports.formatTemporal=Fe,exports.formatTime=X,exports.generateDayData=ue,exports.generateICS=ht,exports.generateSecondaryTimeSlots=ee,exports.generateUniKey=De,exports.generateVEvent=lt,exports.generateWeekData=ge,exports.generateWeekRange=me,exports.generateWeeksData=(e,t=3)=>{const n=5*t,{monday:r}=ce(e),a=[],o=Math.floor(n/2),i=new Date(r);i.setDate(i.getDate()-7*o);for(let e=0;e<n;e++){const t=new Date(i);t.setDate(t.getDate()+7*e),a.push(ge(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=v(t.start);a.setHours(0,0,0,0);const o=v(t.end);return o.setHours(0,0,0,0),r>=a&&r<=o}),exports.getAllDayRangeMetrics=gt,exports.getCalendarColorsForHex=R,exports.getCurrentWeekDates=(e=1)=>{const t=new Date,n=new Date,r=(t.getDay()-e+7)%7;return le.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=pe,exports.getDateObj=Ge,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 w(e)},exports.getEndOfTemporal=w,exports.getEventBgColor=O,exports.getEventEndHour=J,exports.getEventTextColor=H,exports.getEventsForDay=fe,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=v(e.start);return r>=t&&r<=n}).map(e=>{const n=ye(v(e.start),t);return Object.assign(Object.assign({},e),{day:n})})},exports.getIntlLabel=bn,exports.getLineColor=P,exports.getMonthLabels=Dn,exports.getMonthYearOfWeek=he,exports.getNextHourRangeInTimeZone=ae,exports.getNowInTimeZone=ne,exports.getPlainDate=K,exports.getSearchHeaderInfo=qe,exports.getSelectedBgColor=A,exports.getStartOfDay=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(0,0,0,0),t}return x(e)},exports.getStartOfTemporal=x,exports.getTestEvents=function(){const e=new Date,n=e.getDay(),r=new Date(e),a=0===n?-6:1-n;return r.setDate(e.getDate()+a),r.setHours(0,0,0,0),[{id:"15",title:"C-早开始",day:3,startHour:8.5,endHour:10,calendarId:"teal"},{id:"16",title:"D-晚开始",day:3,startHour:9,endHour:10.5,calendarId:"red"},{id:"21",title:"A",day:0,startHour:14,endHour:16,calendarId:"blue"},{id:"22",title:"B",day:0,startHour:14.5,endHour:16,calendarId:"green"},{id:"23",title:"C",day:0,startHour:14.5,endHour:16,calendarId:"purple"},{id:"24",title:"D",day:0,startHour:15,endHour:16,calendarId:"yellow"},{id:"25",title:"E",day:0,startHour:15,endHour:16,calendarId:"red"},{id:"26",title:"F",day:0,startHour:15.5,endHour:16,calendarId:"orange"},{id:"27",title:"G",day:0,startHour:15,endHour:16,calendarId:"pink"},{id:"28",title:"H",day:0,startHour:15.5,endHour:16,calendarId:"teal"},{id:"29",title:"L",day:0,startHour:15.5,endHour:16,calendarId:"teal"},{id:"30",title:"I",day:0,startHour:15.5,endHour:16,calendarId:"blue"},{id:"99",title:"X",day:0,startHour:15.5,endHour:16,calendarId:"blue"},{id:"6",title:"假日",day:0,startHour:0,endHour:0,calendarId:"blue",allDay:!0},{id:"7",title:"研讨会",day:2,startHour:0,endHour:0,calendarId:"green",allDay:!0},{id:"8",title:"团队建设",day:4,startHour:0,endHour:0,calendarId:"purple",allDay:!0},{id:"41",title:"A",day:3,startHour:16,endHour:18.25,calendarId:"blue"},{id:"42",title:"B",day:3,startHour:16.5,endHour:18,calendarId:"green"},{id:"43",title:"C",day:3,startHour:16.75,endHour:17.75,calendarId:"purple"},{id:"44",title:"D",day:3,startHour:17,endHour:19,calendarId:"yellow"},{id:"45",title:"E",day:3,startHour:17.75,endHour:18.75,calendarId:"red"},{id:"46",title:"X",day:2,startHour:15,endHour:15.75,calendarId:"orange"},{id:"47",title:"Y",day:2,startHour:15.5,endHour:19.5,calendarId:"pink"},{id:"48",title:"Z",day:2,startHour:15,endHour:15.75,calendarId:"teal"},{id:"59",title:"Q",day:2,startHour:17,endHour:18,calendarId:"teal"},{id:"60",title:"W",day:2,startHour:15.5,endHour:18,calendarId:"teal"},{id:"31",title:"A",day:6,startHour:14,endHour:16,calendarId:"blue"},{id:"32",title:"B",day:6,startHour:14.5,endHour:16,calendarId:"green"},{id:"33",title:"C",day:6,startHour:14.5,endHour:16,calendarId:"purple"},{id:"34",title:"D",day:6,startHour:15,endHour:16,calendarId:"yellow"},{id:"35",title:"E",day:6,startHour:15.5,endHour:16.5,calendarId:"red"},{id:"36",title:"F",day:6,startHour:16.25,endHour:16.75,calendarId:"orange"},{id:"37",title:"G",day:6,startHour:16,endHour:17.25,calendarId:"pink"},{id:"51",title:"下周会议1",day:1,startHour:9,endHour:10,calendarId:"blue"},{id:"52",title:"下周会议2",day:3,startHour:14,endHour:15,calendarId:"green"},{id:"81",title:"A",day:5,startHour:14,endHour:16,calendarId:"blue"},{id:"82",title:"B",day:5,startHour:14.5,endHour:16,calendarId:"green"},{id:"83",title:"C",day:5,startHour:14.5,endHour:16,calendarId:"purple"},{id:"84",title:"D",day:5,startHour:15,endHour:16,calendarId:"yellow"},{id:"85",title:"E",day:5,startHour:15,endHour:16,calendarId:"red"},{id:"86",title:"F",day:5,startHour:15.75,endHour:17,calendarId:"orange"},{id:"87",title:"G",day:5,startHour:14.75,endHour:17.5,calendarId:"pink"}].map(e=>{const n=new Date(r);if(n.setDate(r.getDate()+e.day),e.allDay)return{id:e.id,title:e.title,start:t.Temporal.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()}),end:t.Temporal.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()}),allDay:!0,calendarId:e.calendarId,day:e.day};const a=Math.floor(e.startHour),o=Math.round(60*(e.startHour-a)),i=Math.floor(e.endHour),l=Math.round(60*(e.endHour-i));return{id:e.id,title:e.title,start:t.Temporal.ZonedDateTime.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate(),hour:a,minute:o,timeZone:t.Temporal.Now.timeZoneId()}),end:t.Temporal.ZonedDateTime.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate(),hour:i,minute:l,timeZone:t.Temporal.Now.timeZoneId()}),allDay:!1,calendarId:e.calendarId,day:e.day}})},exports.getTimezoneDisplayLabel=te,exports.getTodayInTimeZone=re,exports.getWeekDaysLabels=wn,exports.getWeekNumber=T,exports.getWeekRange=ce,exports.getZoneId=je,exports.groupSearchResults=Xe,exports.hasEventChanged=we,exports.importICSFile=function(t,n){return e.__awaiter(this,void 0,void 0,function*(){try{const e=yield t.text();if(!e)throw new Error("File content is empty");return ut(e,n)}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=Ee,exports.isEventDeepEqual=xe,exports.isEventInWeek=(e,t)=>{const n=ye(e,t);return n>=0&&n<=6},exports.isMultiDayEvent=(e,t)=>!k(e,t),exports.isMultiDayTemporalEvent=function(e,t){return!b(e,t)},exports.isPlainDate=F,exports.isPlainDateTime=V,exports.isSameDay=k,exports.isSamePlainDate=b,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=K(e),r=K(t);return n.equals(r)},exports.isValidLocale=d,exports.isZonedDateTime=Z,exports.mergeClasses=(...e)=>e.filter(Boolean).join(" "),exports.mergeFormatTemplate=Ae,exports.monthNames=se,exports.normalizeCssWidth=function(e,t="240px"){return"number"==typeof e?`${e}px`:"string"==typeof e&&e.trim().length>0?e:t},exports.normalizeDate=Ke,exports.normalizeLocale=s,exports.normalizeTimeZoneValue=Y,exports.normalizeToZoned=Ye,exports.now=function(e=t.Temporal.Now.timeZoneId()){return t.Temporal.Now.zonedDateTimeISO(e)},exports.pad=He,exports.pad2=Qe,exports.parseICS=ut,exports.parseICSDate=et,exports.parseTemporalString=$e,exports.parseVEventLines=dt,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=be,exports.registerDragImplementation=function(e){ka=e},exports.registerLocale=function(e){const t=e.code.split("-")[0].toLowerCase();l[t]=e},exports.registerSidebarImplementation=function(e){or=e},exports.resolveAppliedTheme=_e,exports.restoreTimedDragFromAllDayTransition=({wasOriginallyAllDay:e,mouseHour:t,hourOffset:n,duration:r,originalStartHour:a,originalEndHour:o,firstHour:i,lastHour:l,minDuration:s,roundToTimeStep:d})=>{const c=e?1:Math.max(s,r||o-a||1);let u=d(e?t:t+(null!=n?n:0));return u=Math.max(i,Math.min(l-c,u)),{startHour:u,endHour:u+c,duration:c,hourOffset:e?0:null!=n?n:0}},exports.restoreVisualEventToCanonical=ie,exports.restoreVisualTimedTemporalToCanonical=oe,exports.roundToTimeStep=e=>.25*Math.round(e/.25),exports.scrollbarTakesSpace=Ze,exports.setHourInTemporal=function(e,t){const n=Math.floor(t),r=Math.round(60*(t-n));return Z(e),e.with({hour:n,minute:r,second:0,millisecond:0})},exports.shortMonthNames=de,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.subscribeCalendar=function(t){return e.__awaiter(this,void 0,void 0,function*(){const e=yield fetch(t);if(!e.ok)throw new Error(`HTTP ${e.status}`);const n=yield e.text(),r=ut(n),a=n.match(/X-WR-CALNAME[^:]*:([^\r\n]+)/),o=a?a[1].trim():new URL(t).hostname,i=["#3b82f6","#10b981","#8b5cf6","#f59e0b","#ef4444","#f97316","#ec4899","#14b8a6","#6366f1","#6b7280"],l=i[Math.floor(Math.random()*i.length)],{colors:s,darkColors:d}=R(l);return{calendar:{id:De(),name:o,isVisible:!0,colors:s,darkColors:d,subscription:{url:t,status:"ready"}},events:r.events}})},exports.t=En,exports.temporalToDate=_,exports.temporalToVisualDate=z,exports.temporalToVisualTemporal=U,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:"df-focus-ring-only",input:"bg-white dark:bg-gray-700 border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100",inputFocus:"df-focus-ring",buttonPrimary:"df-fill-primary df-hover-primary-solid",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:"df-fill-destructive df-hover-destructive",buttonSuccess:"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-200 hover:bg-blue-200 dark:hover:bg-blue-800",shadow:"shadow-sm dark:shadow-gray-900/50",shadowMd:"shadow-md dark:shadow-gray-900/50",shadowLg:"shadow-lg dark:shadow-gray-900/50",divider:"border-gray-200 dark:border-gray-700"},exports.themeCn=(e,t,n)=>`${e} ${t} ${n.split(" ").filter(Boolean).map(e=>`dark:${e}`).join(" ")}`.trim(),exports.today=function(e=t.Temporal.Now.timeZoneId()){return t.Temporal.Now.plainDateISO(e)},exports.unescapeICSValue=at,exports.updateEventDateAndDay=(e,n,r)=>{const a=pe(r,n);return Object.assign(Object.assign({},e),{day:n,start:e.allDay?t.Temporal.PlainDate.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate()}):t.Temporal.ZonedDateTime.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate(),hour:a.getHours(),minute:a.getMinutes(),timeZone:t.Temporal.Now.timeZoneId()}),end:e.allDay?t.Temporal.PlainDate.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate()}):t.Temporal.ZonedDateTime.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate(),hour:a.getHours(),minute:a.getMinutes(),timeZone:t.Temporal.Now.timeZoneId()})})},exports.updateEventWithRealDate=(e,t,n)=>{var r;const a=new Date(n);a.setDate(n.getDate()+t);const o=null!==(r=e.allDay)&&void 0!==r&&r;return Object.assign(Object.assign({},e),{day:t,start:ve(a,o),end:ve(a,o)})},exports.useDragForView=Ma,exports.useLocale=bt,exports.useSidebarBridge=lr,exports.weekDays=le,exports.weekDaysFullName=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],exports.zonedDateTimeToDate=p;
|