@dayflow/core 2.0.6 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/dist/index.d.ts +2555 -39
  2. package/dist/index.esm.js +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/styles.css +2128 -3113
  5. package/package.json +14 -24
  6. package/LICENSE +0 -21
  7. package/README.ja.md +0 -47
  8. package/README.md +0 -49
  9. package/README.zh.md +0 -47
  10. package/dist/components/calendarEvent/components/AllDayContent.d.ts +0 -9
  11. package/dist/components/calendarEvent/components/MonthAllDayContent.d.ts +0 -8
  12. package/dist/components/calendarEvent/components/MonthRegularContent.d.ts +0 -11
  13. package/dist/components/calendarEvent/components/RegularEventContent.d.ts +0 -20
  14. package/dist/components/calendarEvent/index.d.ts +0 -4
  15. package/dist/components/calendarEvent/types.d.ts +0 -49
  16. package/dist/components/common/CalendarHeader.d.ts +0 -4
  17. package/dist/components/common/CalendarPicker.d.ts +0 -19
  18. package/dist/components/common/ColorPicker.d.ts +0 -19
  19. package/dist/components/common/ContextMenu.d.ts +0 -25
  20. package/dist/components/common/CreateCalendarDialog.d.ts +0 -3
  21. package/dist/components/common/DefaultEventDetailDialog.d.ts +0 -12
  22. package/dist/components/common/DefaultEventDetailPanel.d.ts +0 -11
  23. package/dist/components/common/EventDetailPanelWithContent.d.ts +0 -11
  24. package/dist/components/common/MiniCalendar.d.ts +0 -11
  25. package/dist/components/common/QuickCreateEventPopup.d.ts +0 -10
  26. package/dist/components/common/TodayBox.d.ts +0 -7
  27. package/dist/components/common/ViewHeader.d.ts +0 -33
  28. package/dist/components/common/ViewSwitcher.d.ts +0 -8
  29. package/dist/components/dayView/DayContent.d.ts +0 -55
  30. package/dist/components/dayView/RightPanel.d.ts +0 -16
  31. package/dist/components/dayView/util.d.ts +0 -8
  32. package/dist/components/eventLayout/constants.d.ts +0 -8
  33. package/dist/components/eventLayout/index.d.ts +0 -129
  34. package/dist/components/eventLayout/types.d.ts +0 -23
  35. package/dist/components/eventLayout/utils.d.ts +0 -5
  36. package/dist/components/mobileEventDrawer/DefaultMobileEventDrawer.d.ts +0 -3
  37. package/dist/components/mobileEventDrawer/components/Switch.d.ts +0 -7
  38. package/dist/components/mobileEventDrawer/components/TimePickerWheel.d.ts +0 -7
  39. package/dist/components/mobileEventDrawer/index.d.ts +0 -3
  40. package/dist/components/monthView/MonthDragIndicator.d.ts +0 -12
  41. package/dist/components/monthView/MultiDayEvent.d.ts +0 -31
  42. package/dist/components/monthView/WeekComponent.d.ts +0 -53
  43. package/dist/components/monthView/util.d.ts +0 -11
  44. package/dist/components/rangePicker/components/CalendarGrid.d.ts +0 -13
  45. package/dist/components/rangePicker/components/CalendarHeader.d.ts +0 -11
  46. package/dist/components/rangePicker/components/RangePickerPanel.d.ts +0 -25
  47. package/dist/components/rangePicker/components/TimeSelector.d.ts +0 -21
  48. package/dist/components/rangePicker/constants.d.ts +0 -5
  49. package/dist/components/rangePicker/index.d.ts +0 -4
  50. package/dist/components/rangePicker/types.d.ts +0 -23
  51. package/dist/components/rangePicker/utils.d.ts +0 -2
  52. package/dist/components/search/MobileSearchDialog.d.ts +0 -14
  53. package/dist/components/search/SearchDrawer.d.ts +0 -13
  54. package/dist/components/search/SearchResultsList.d.ts +0 -11
  55. package/dist/components/sidebar/DefaultCalendarSidebar.d.ts +0 -4
  56. package/dist/components/sidebar/components/CalendarList.d.ts +0 -16
  57. package/dist/components/sidebar/components/DeleteCalendarDialog.d.ts +0 -14
  58. package/dist/components/sidebar/components/ImportCalendarDialog.d.ts +0 -11
  59. package/dist/components/sidebar/components/MergeCalendarDialog.d.ts +0 -9
  60. package/dist/components/sidebar/components/MergeMenuItem.d.ts +0 -9
  61. package/dist/components/sidebar/components/SidebarHeader.d.ts +0 -7
  62. package/dist/components/weekView/AllDayRow.d.ts +0 -49
  63. package/dist/components/weekView/DragIndicator/DefaultDragIndicator.d.ts +0 -2
  64. package/dist/components/weekView/DragIndicator/DragIndicatorComponent.d.ts +0 -7
  65. package/dist/components/weekView/TimeGrid.d.ts +0 -52
  66. package/dist/components/weekView/util.d.ts +0 -9
  67. package/dist/components/yearView/DefaultYearView.d.ts +0 -11
  68. package/dist/components/yearView/FixedWeekYearView.d.ts +0 -14
  69. package/dist/components/yearView/YearDayCell.d.ts +0 -12
  70. package/dist/components/yearView/YearMultiDayEvent.d.ts +0 -23
  71. package/dist/components/yearView/YearRowComponent.d.ts +0 -27
  72. package/dist/components/yearView/utils.d.ts +0 -19
  73. package/dist/contexts/ThemeContext.d.ts +0 -38
  74. package/dist/core/CalendarApp.d.ts +0 -85
  75. package/dist/core/DayFlowCalendar.d.ts +0 -20
  76. package/dist/core/calendarRegistry.d.ts +0 -121
  77. package/dist/core/config.d.ts +0 -60
  78. package/dist/core/index.d.ts +0 -6
  79. package/dist/core/useCalendarApp.d.ts +0 -2
  80. package/dist/factories/ViewAdapter.d.ts +0 -4
  81. package/dist/factories/createDayView.d.ts +0 -3
  82. package/dist/factories/createMonthView.d.ts +0 -3
  83. package/dist/factories/createWeekView.d.ts +0 -3
  84. package/dist/factories/createYearView.d.ts +0 -3
  85. package/dist/factories/index.d.ts +0 -10
  86. package/dist/hooks/drag/index.d.ts +0 -7
  87. package/dist/hooks/drag/useDrag.d.ts +0 -2
  88. package/dist/hooks/drag/useDragCommon.d.ts +0 -2
  89. package/dist/hooks/drag/useDragHandlers.d.ts +0 -2
  90. package/dist/hooks/drag/useDragManager.d.ts +0 -2
  91. package/dist/hooks/drag/useDragState.d.ts +0 -2
  92. package/dist/hooks/drag/useMonthDrag.d.ts +0 -2
  93. package/dist/hooks/drag/useWeekDayDrag.d.ts +0 -2
  94. package/dist/hooks/useCalendarDrop.d.ts +0 -20
  95. package/dist/hooks/virtualScroll/index.d.ts +0 -2
  96. package/dist/hooks/virtualScroll/useVirtualMonthScroll.d.ts +0 -7
  97. package/dist/hooks/virtualScroll/useVirtualScroll.d.ts +0 -48
  98. package/dist/locale/LocaleContext.d.ts +0 -10
  99. package/dist/locale/LocaleProvider.d.ts +0 -8
  100. package/dist/locale/index.d.ts +0 -7
  101. package/dist/locale/intl.d.ts +0 -16
  102. package/dist/locale/locales/de.d.ts +0 -3
  103. package/dist/locale/locales/en.d.ts +0 -3
  104. package/dist/locale/locales/es.d.ts +0 -3
  105. package/dist/locale/locales/fr.d.ts +0 -3
  106. package/dist/locale/locales/index.d.ts +0 -18
  107. package/dist/locale/locales/ja.d.ts +0 -3
  108. package/dist/locale/locales/ko.d.ts +0 -3
  109. package/dist/locale/locales/zh.d.ts +0 -3
  110. package/dist/locale/translator.d.ts +0 -9
  111. package/dist/locale/types.d.ts +0 -8
  112. package/dist/locale/useLocale.d.ts +0 -5
  113. package/dist/locale/utils.d.ts +0 -10
  114. package/dist/plugins/dragPlugin.d.ts +0 -5
  115. package/dist/plugins/eventsPlugin.d.ts +0 -3
  116. package/dist/plugins/index.d.ts +0 -6
  117. package/dist/setupTests.d.ts +0 -1
  118. package/dist/styles/classNames.d.ts +0 -381
  119. package/dist/types/calendar.d.ts +0 -26
  120. package/dist/types/calendarTypes.d.ts +0 -68
  121. package/dist/types/config.d.ts +0 -19
  122. package/dist/types/core.d.ts +0 -265
  123. package/dist/types/dragIndicator.d.ts +0 -160
  124. package/dist/types/event.d.ts +0 -18
  125. package/dist/types/eventDetail.d.ts +0 -74
  126. package/dist/types/factory.d.ts +0 -155
  127. package/dist/types/hook.d.ts +0 -103
  128. package/dist/types/index.d.ts +0 -13
  129. package/dist/types/layout.d.ts +0 -113
  130. package/dist/types/mobileEvent.d.ts +0 -21
  131. package/dist/types/monthView.d.ts +0 -65
  132. package/dist/types/plugin.d.ts +0 -80
  133. package/dist/types/search.d.ts +0 -35
  134. package/dist/utils/calendarDataUtils.d.ts +0 -83
  135. package/dist/utils/colorUtils.d.ts +0 -27
  136. package/dist/utils/compareUtils.d.ts +0 -5
  137. package/dist/utils/dateConstants.d.ts +0 -22
  138. package/dist/utils/dateFormat.d.ts +0 -15
  139. package/dist/utils/dateRangeUtils.d.ts +0 -24
  140. package/dist/utils/dateTimeUtils.d.ts +0 -49
  141. package/dist/utils/eventHelpers.d.ts +0 -143
  142. package/dist/utils/eventUtils.d.ts +0 -115
  143. package/dist/utils/helpers.d.ts +0 -27
  144. package/dist/utils/ics/icsDateUtils.d.ts +0 -37
  145. package/dist/utils/ics/icsGenerator.d.ts +0 -23
  146. package/dist/utils/ics/icsParser.d.ts +0 -15
  147. package/dist/utils/ics/index.d.ts +0 -16
  148. package/dist/utils/ics/types.d.ts +0 -91
  149. package/dist/utils/index.d.ts +0 -10
  150. package/dist/utils/logger.d.ts +0 -15
  151. package/dist/utils/rangePicker.d.ts +0 -8
  152. package/dist/utils/searchUtils.d.ts +0 -35
  153. package/dist/utils/styleUtils.d.ts +0 -24
  154. package/dist/utils/temporal.d.ts +0 -100
  155. package/dist/utils/temporalTypeGuards.d.ts +0 -63
  156. package/dist/utils/testDataUtils.d.ts +0 -14
  157. package/dist/utils/themeUtils.d.ts +0 -93
  158. package/dist/utils/throttle.d.ts +0 -11
  159. package/dist/utils/timeUtils.d.ts +0 -38
  160. package/dist/utils/utilityFunctions.d.ts +0 -11
  161. package/dist/views/DayView.d.ts +0 -13
  162. package/dist/views/MonthView.d.ts +0 -11
  163. package/dist/views/WeekView.d.ts +0 -11
  164. package/dist/views/YearView.d.ts +0 -12
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e,t=require("react"),n=require("temporal-polyfill"),a=require("tslib"),r=require("react/jsx-runtime"),o=require("react-dom"),s=require("@dayflow/blossom-color-picker"),l=require("react-color"),i=require("lucide-react"),d=require("react-dom/client");exports.ViewType=void 0,(e=exports.ViewType||(exports.ViewType={})).DAY="day",e.WEEK="week",e.MONTH="month",e.YEAR="year";const c=100,u=8,g=150,m=80,h=90,f=119;class v{constructor(e=c){this.cache=new Map,this.accessOrder=[],this.maxSize=e}getKey(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}get(e){const t=this.getKey(e),n=this.cache.get(t);if(n)return this.updateAccessOrder(t),n}set(e,t){const n=this.getKey(e);if(this.cache.size>=this.maxSize){const e=this.accessOrder.shift();void 0!==e&&this.cache.delete(e)}this.cache.set(n,t),this.updateAccessOrder(n)}updateAccessOrder(e){const t=this.accessOrder.indexOf(e);t>-1&&this.accessOrder.splice(t,1),this.accessOrder.push(e)}getSize(){return this.cache.size}clear(){this.cache.clear(),this.accessOrder=[]}}const p=[{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 y{constructor(e,t,n="light"){this.calendars=new Map,this.defaultCalendarId=t||"blue",this.currentTheme=n;const a=e&&e.length>0;e?e.forEach(e=>{this.calendars.set(e.id,e)}):p.forEach(e=>{this.calendars.set(e.id,Object.assign(Object.assign({},e),{isVisible:!a&&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[a]=n.splice(e,1);n.splice(t,0,a),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,a=this.isDarkTheme(n);let r;return e&&(r=this.get(e)),r||(r=this.getDefaultCalendar()),a&&r.darkColors?r.darkColors:r.colors}getSelectedBgColor(e,t){return this.resolveColors(e,t).eventSelectedColor}getLineColor(e,t){return this.resolveColors(e,t).lineColor}getTextColor(e,t){return this.resolveColors(e,t).textColor}isDarkTheme(e){return"dark"===e||"light"!==e&&(!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-color-scheme: dark)").matches)}validate(e){const t=[];return e.id||t.push("Calendar type must have an id"),e.name||t.push("Calendar type must have a name"),e.colors?(e.colors.eventColor||t.push("Calendar colors must include eventColor"),e.colors.eventSelectedColor||t.push("Calendar colors must include eventSelectedColor"),e.colors.lineColor||t.push("Calendar colors must include lineColor"),e.colors.textColor||t.push("Calendar colors must include textColor")):t.push("Calendar type must have colors configuration"),t}}let x=new y;function b(){return x}function D(e){const t=p.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 w=new class{constructor(){this.isDevelopment="production"!==process.env.NODE_ENV}formatMessage(e,t,...n){if(!this.isDevelopment)return;const a=(new Date).toISOString(),r=`[DayFlow ${e.toUpperCase()}] ${a}:`;switch(e){case"log":console.log(r,t,...n);break;case"warn":console.warn(r,t,...n);break;case"error":console.error(r,t,...n);break;case"debug":console.debug(r,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)}};function C(e,t="240px"){return"number"==typeof e?`${e}px`:"string"==typeof e&&e.trim().length>0?e:t}const E={code:"en-US",messages:{allDay:"All day",noEvents:"No events for this day",more:"more",eventTitle:"Event Title",dateRange:"Date Range",timeRange:"Time Range",note:"Note",addNotePlaceholder:"Add a note...",setAsAllDay:"Set as All-day",setAsTimed:"Set as Timed Event",delete:"Delete",confirm:"Confirm",cancel:"Cancel",today:"Today",day:"Day",week:"Week",month:"Month",year:"Year",newEvent:"New Event",newAllDayEvent:"New All-day Event",newCalendarEvent:"New {calendarName} Event",newAllDayCalendarEvent:"New {calendarName} All-day Event",save:"Save",deleteCalendar:'Delete "{calendarName}"?',deleteCalendarMessage:'Do you want to delete "{calendarName}" or merge its events into another existing calendar?',merge:"Merge",confirmDeleteTitle:'Are you sure you want to delete the calendar "{calendarName}"?',confirmDeleteMessage:"If you delete this calendar, all events associated with the calendar will also be deleted.",mergeConfirmTitle:'Merge "{sourceName}" with "{targetName}"?',mergeConfirmMessage:'Are you sure you want to merge "{sourceName}" with "{targetName}"? Doing so will move all the events from "{sourceName}" to "{targetName}" and "{sourceName}" will be deleted. This cannot be undone.',expandSidebar:"Expand calendar sidebar",collapseSidebar:"Collapse calendar sidebar",calendars:"Calendars",createCalendar:"Create New Calendar",calendarNamePlaceholder:"e.g. Work",customColor:"Custom Color...",create:"Create",calendarOptions:"Calendar Options",untitled:"Untitled",search:"Search",noResults:"No results found",calendar:"Calendar",starts:"Starts",ends:"Ends",notes:"Notes",titlePlaceholder:"Title",notesPlaceholder:"Notes",editEvent:"Edit Event",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"}},k={code:"zh-CN",messages:{allDay:"全天",noEvents:"今日无日程",more:"个",eventTitle:"事件标题",dateRange:"日期范围",timeRange:"时间范围",note:"备注",addNotePlaceholder:"添加备注...",setAsAllDay:"设为全天",setAsTimed:"设为普通事件",delete:"删除",confirm:"确认",cancel:"取消",today:"今天",day:"日",week:"周",month:"月",year:"年",newEvent:"新建日程",newAllDayEvent:"新建全天日程",newCalendarEvent:"新建 {calendarName} 日程",newAllDayCalendarEvent:"新建 {calendarName} 全天日程",save:"保存",deleteCalendar:'删除日历 "{calendarName}"?',deleteCalendarMessage:'您想删除日历 "{calendarName}" 还是将其事件合并到另一个现有日历中?',merge:"合并",confirmDeleteTitle:'您确定要删除日历 "{calendarName}" 吗?',confirmDeleteMessage:"如果您删除此日历,与其关联的所有事件也将被删除。",mergeConfirmTitle:'将 "{sourceName}" 合并到 "{targetName}"?',mergeConfirmMessage:'您确定要将 "{sourceName}" 合并到 "{targetName}" 吗?这样做会将 "{sourceName}" 中的所有事件移动到 "{targetName}",并且 "{sourceName}" 将被删除。此操作无法撤销。',expandSidebar:"展开日历侧边栏",collapseSidebar:"收起日历侧边栏",calendars:"日历",createCalendar:"创建新日历",calendarNamePlaceholder:"例如:工作",customColor:"自定义颜色...",create:"创建",calendarOptions:"日历选项",untitled:"未命名",search:"搜索",noResults:"无结果",calendar:"日历",starts:"开始",ends:"结束",notes:"备注",titlePlaceholder:"标题",notesPlaceholder:"备注",editEvent:"编辑日程",done:"完成",quickCreateEvent:"快速创建日程",quickCreatePlaceholder:"周五晚7点看电影",noSuggestions:"输入内容以创建",newCalendar:"新增日历",refreshAll:"全部刷新",tomorrow:"明天",importCalendar:"导入日历",exportCalendar:"导出日历",addSchedule:"添加日程",importCalendarMessage:"该日历包含新日程。请选取目标日历",ok:"好"}},T={code:"ja-JP",messages:{allDay:"終日",noEvents:"本日は予定がありません",more:"件",eventTitle:"予定名",dateRange:"日付範囲",timeRange:"時間範囲",note:"メモ",addNotePlaceholder:"メモを追加...",setAsAllDay:"終日予定に設定",setAsTimed:"時間指定の予定に設定",delete:"削除",confirm:"確認",cancel:"キャンセル",today:"今日",day:"日",week:"週",month:"月",year:"年",newEvent:"新規予定",newAllDayEvent:"新規終日予定",newCalendarEvent:"新規 {calendarName} 予定",newAllDayCalendarEvent:"新規 {calendarName} 終日予定",save:"保存",deleteCalendar:'カレンダー "{calendarName}" を削除しますか?',deleteCalendarMessage:'カレンダー "{calendarName}" を削除しますか?それともイベントを別の既存のカレンダーにマージしますか?',merge:"マージ",confirmDeleteTitle:'カレンダー "{calendarName}" を削除してもよろしいですか?',confirmDeleteMessage:"このカレンダーを削除すると、関連するすべてのイベントも削除されます。",mergeConfirmTitle:'"{sourceName}" を "{targetName}" にマージしますか?',mergeConfirmMessage:'"{sourceName}" を "{targetName}" にマージしてもよろしいですか?これにより、"{sourceName}" のすべてのイベントが "{targetName}" に移動し、"{sourceName}" は削除されます。この操作は元に戻せません。',expandSidebar:"カレンダーサイドバーを展開",collapseSidebar:"カレンダーサイドバーを折りたたむ",calendars:"カレンダー",createCalendar:"新しいカレンダーを作成",calendarNamePlaceholder:"例:仕事",customColor:"カスタムカラー...",create:"作成",calendarOptions:"カレンダーオプション",untitled:"無題",search:"検索",noResults:"結果が見つかりません",calendar:"カレンダー",starts:"開始",ends:"終了",notes:"メモ",titlePlaceholder:"予定名",notesPlaceholder:"メモ",editEvent:"予定を編集",done:"完了",quickCreateEvent:"クイック作成",quickCreatePlaceholder:"金曜日7時から映画",noSuggestions:"入力して作成",newCalendar:"新しいカレンダー",refreshAll:"すべて更新",tomorrow:"明日",importCalendar:"カレンダーをインポート",exportCalendar:"カレンダーをエクスポート",addSchedule:"予定を追加",importCalendarMessage:"このカレンダーには新しい予定が含まれています。ターゲットカレンダーを選択してください。",ok:"OK"}},j={code:"ko-KR",messages:{allDay:"종일",noEvents:"오늘 일정이 없습니다",more:"개",eventTitle:"일정 제목",dateRange:"날짜 범위",timeRange:"시간 범위",note:"메모",addNotePlaceholder:"메모 추가...",setAsAllDay:"종일 일정으로 설정",setAsTimed:"시간 지정 일정으로 설정",delete:"삭제",confirm:"확인",cancel:"취소",today:"오늘",day:"일",week:"주",month:"월",year:"년",newEvent:"새 일정",newAllDayEvent:"새 종일 일정",newCalendarEvent:"{calendarName}의 새 일정",newAllDayCalendarEvent:"{calendarName}의 새 종일 일정",save:"저장",deleteCalendar:'"{calendarName}" 삭제?',deleteCalendarMessage:'"{calendarName}"을(를) 삭제하시겠습니까, 아니면 이벤트를 다른 기존 캘린더로 병합하시겠습니까?',merge:"병합",confirmDeleteTitle:'"{calendarName}" 캘린더를 삭제하시겠습니까?',confirmDeleteMessage:"이 캘린더를 삭제하면 연결된 모든 이벤트도 삭제됩니다.",mergeConfirmTitle:'"{sourceName}"을(를) "{targetName}"(으)로 병합?',mergeConfirmMessage:'"{sourceName}"을(를) "{targetName}"(으)로 병합하시겠습니까? 이렇게 하면 "{sourceName}"의 모든 이벤트가 "{targetName}"(으)로 이동하고 "{sourceName}"은(는) 삭제됩니다. 이 작업은 취소할 수 없습니다.',expandSidebar:"캘린더 사이드바 펼치기",collapseSidebar:"캘린더 사이드바 접기",calendars:"캘린더",createCalendar:"새 캘린더 만들기",calendarNamePlaceholder:"예: 업무",customColor:"사용자 지정 색상...",create:"만들기",calendarOptions:"캘린더 옵션",untitled:"무제",search:"검색",noResults:"결과 없음",calendar:"캘린더",starts:"시작",ends:"종료",notes:"메모",titlePlaceholder:"제목",notesPlaceholder:"메모",editEvent:"일정 편집",done:"완료",quickCreateEvent:"빠른 일정 생성",quickCreatePlaceholder:"금요일 오후 7시에 영화",noSuggestions:"입력하여 만들기",newCalendar:"새 캘린더",refreshAll:"모두 새로 고침",tomorrow:"내일",importCalendar:"캘린더 가져오기",exportCalendar:"캘린더 내보내기",addSchedule:"일정 추가",importCalendarMessage:"이 캘린더에는 새로운 일정이 포함되어 있습니다. 대상 캘린더를 선택하세요.",ok:"확인"}},S={code:"fr-FR",messages:{allDay:"Toute la journée",noEvents:"Aucun événement aujourd'hui",more:"de plus",eventTitle:"Titre de l'événement",dateRange:"Plage de dates",timeRange:"Plage horaire",note:"Note",addNotePlaceholder:"Ajouter une note...",setAsAllDay:"Définir comme toute la journée",setAsTimed:"Définir comme événement horaire",delete:"Supprimer",confirm:"Confirmer",cancel:"Annuler",today:"Aujourd'hui",day:"Jour",week:"Semaine",month:"Mois",year:"Année",newEvent:"Nouvel événement",newAllDayEvent:"Nouvel événement toute la journée",newCalendarEvent:"Nouvel événement dans {calendarName}",newAllDayCalendarEvent:"Nouvel événement toute la journée dans {calendarName}",save:"Enregistrer",deleteCalendar:'Supprimer "{calendarName}" ?',deleteCalendarMessage:'Voulez-vous supprimer "{calendarName}" ou fusionner ses événements dans un autre calendrier existant ?',merge:"Fusionner",confirmDeleteTitle:'Êtes-vous sûr de vouloir supprimer le calendrier "{calendarName}" ?',confirmDeleteMessage:"Si vous supprimez ce calendrier, tous les événements associés seront également supprimés.",mergeConfirmTitle:'Fusionner "{sourceName}" avec "{targetName}" ?',mergeConfirmMessage:'Êtes-vous sûr de vouloir fusionner "{sourceName}" avec "{targetName}" ? Cela déplacera tous les événements de "{sourceName}" vers "{targetName}" et "{sourceName}" sera supprimé. Cette action est irréversible.',expandSidebar:"Développer la barre latérale",collapseSidebar:"Réduire la barre latérale",calendars:"Calendriers",createCalendar:"Créer un nouveau calendrier",calendarNamePlaceholder:"ex. Travail",customColor:"Couleur personnalisée...",create:"Créer",calendarOptions:"Options du calendrier",untitled:"Sans titre",search:"Rechercher",noResults:"Aucun résultat trouvé",calendar:"Calendrier",starts:"Début",ends:"Fin",notes:"Notes",titlePlaceholder:"Titre",notesPlaceholder:"Notes",editEvent:"Modifier l'événement",done:"Terminé",quickCreateEvent:"Création rapide",quickCreatePlaceholder:"Film à 19h vendredi",noSuggestions:"Tapez pour créer",newCalendar:"Nouveau calendrier",refreshAll:"Tout actualiser",tomorrow:"Demain",importCalendar:"Importer un calendrier",exportCalendar:"Exporter le calendrier",addSchedule:"Ajouter un événement",importCalendarMessage:"Ce calendrier contient de nouveaux événements. Veuillez sélectionner un calendrier cible.",ok:"OK"}},N={code:"de-DE",messages:{allDay:"Ganztägig",noEvents:"Heute keine Termine",more:"mehr",eventTitle:"Ereignistitel",dateRange:"Datumsbereich",timeRange:"Zeitbereich",note:"Notiz",addNotePlaceholder:"Notiz hinzufügen...",setAsAllDay:"Als ganztägig festlegen",setAsTimed:"Als zeitlich begrenztes Ereignis festlegen",delete:"Löschen",confirm:"Bestätigen",cancel:"Abbrechen",today:"Heute",day:"Tag",week:"Woche",month:"Monat",year:"Jahr",newEvent:"Neues Ereignis",newAllDayEvent:"Neues ganztägiges Ereignis",newCalendarEvent:"Neues Ereignis in {calendarName}",newAllDayCalendarEvent:"Neues ganztägiges Ereignis in {calendarName}",save:"Speichern",deleteCalendar:'"{calendarName}" löschen?',deleteCalendarMessage:'Möchten Sie "{calendarName}" löschen oder dessen Ereignisse in einen anderen bestehenden Kalender zusammenführen?',merge:"Zusammenführen",confirmDeleteTitle:'Sind Sie sicher, dass Sie den Kalender "{calendarName}" löschen möchten?',confirmDeleteMessage:"Wenn Sie diesen Kalender löschen, werden auch alle damit verbundenen Ereignisse gelöscht.",mergeConfirmTitle:'"{sourceName}" mit "{targetName}" zusammenführen?',mergeConfirmMessage:'Sind Sie sicher, dass Sie "{sourceName}" mit "{targetName}" zusammenführen möchten? Dadurch werden alle Ereignisse von "{sourceName}" nach "{targetName}" verschoben und "{sourceName}" wird gelöscht. Dies kann nicht rückgängig gemacht werden.',expandSidebar:"Kalender-Seitenleiste erweitern",collapseSidebar:"Kalender-Seitenleiste einklappen",calendars:"Kalender",createCalendar:"Neuen Kalender erstellen",calendarNamePlaceholder:"z.B. Arbeit",customColor:"Benutzerdefinierte Farbe...",create:"Erstellen",calendarOptions:"Kalenderoptionen",untitled:"Unbenannt",search:"Suchen",noResults:"Keine Ergebnisse gefunden",calendar:"Kalender",starts:"Beginnt",ends:"Endet",notes:"Notizen",titlePlaceholder:"Titel",notesPlaceholder:"Notizen",editEvent:"Ereignis bearbeiten",done:"Fertig",quickCreateEvent:"Ereignis schnell erstellen",quickCreatePlaceholder:"Film am Freitag um 19 Uhr",noSuggestions:"Tippen zum Erstellen",newCalendar:"Neuer Kalender",refreshAll:"Alles aktualisieren",tomorrow:"Morgen",importCalendar:"Kalender importieren",exportCalendar:"Kalender exportieren",addSchedule:"Termin hinzufügen",importCalendarMessage:"Dieser Kalender enthält neue Termine. Bitte wählen Sie einen Zielkalender.",ok:"OK"}},M={code:"es-ES",messages:{allDay:"Todo el día",noEvents:"No hay eventos hoy",more:"más",eventTitle:"Título del evento",dateRange:"Rango de fechas",timeRange:"Rango de tiempo",note:"Nota",addNotePlaceholder:"Añadir una nota...",setAsAllDay:"Establecer como todo el día",setAsTimed:"Establecer como evento con horario",delete:"Eliminar",confirm:"Confirmar",cancel:"Cancelar",today:"Hoy",day:"Día",week:"Semana",month:"Mes",year:"Año",newEvent:"Nuevo evento",newAllDayEvent:"Nuevo evento de todo el día",newCalendarEvent:"Nuevo evento en {calendarName}",newAllDayCalendarEvent:"Nuevo evento de todo el día en {calendarName}",save:"Guardar",deleteCalendar:'¿Eliminar "{calendarName}"?',deleteCalendarMessage:'¿Quieres eliminar "{calendarName}" o fusionar sus eventos en otro calendario existente?',merge:"Fusionar",confirmDeleteTitle:'¿Seguro que quieres eliminar el calendario "{calendarName}"?',confirmDeleteMessage:"Si eliminas este calendario, también se eliminarán todos los eventos asociados.",mergeConfirmTitle:'¿Fusionar "{sourceName}" con "{targetName}"?',mergeConfirmMessage:'¿Seguro que quieres fusionar "{sourceName}" con "{targetName}"? Esto moverá todos los eventos de "{sourceName}" a "{targetName}" y se eliminará "{sourceName}". Esta acción no se puede deshacer.',expandSidebar:"Expandir barra lateral del calendario",collapseSidebar:"Contraer barra lateral del calendario",calendars:"Calendarios",createCalendar:"Crear nuevo calendario",calendarNamePlaceholder:"ej. Trabajo",customColor:"Color personalizado...",create:"Crear",calendarOptions:"Opciones de calendario",untitled:"Sin título",search:"Buscar",noResults:"No se encontraron resultados",calendar:"Calendario",starts:"Empieza",ends:"Termina",notes:"Notas",titlePlaceholder:"Título",notesPlaceholder:"Notas",editEvent:"Editar evento",done:"Hecho",quickCreateEvent:"Creación rápida de eventos",quickCreatePlaceholder:"Película a las 7pm el viernes",noSuggestions:"Escribe para crear",newCalendar:"Nuevo calendario",refreshAll:"Actualizar todo",tomorrow:"Mañana",importCalendar:"Importar calendario",exportCalendar:"Exportar calendario",addSchedule:"Añadir evento",importCalendarMessage:"Este calendario contiene nuevos eventos. Seleccione un calendario de destino.",ok:"Aceptar"}},I={en:E,zh:k,ja:T,ko:j,fr:S,de:N,es:M};function R(e){const t=e.split("-")[0].toLowerCase();return t in I?t:"en"}function H(e){try{return new Intl.DateTimeFormat(e),!0}catch(e){return!1}}function O(e){var t;return e instanceof n.Temporal.PlainDate||("PlainDate"===(null===(t=null==e?void 0:e.constructor)||void 0===t?void 0:t.name)||!("hour"in e)&&!("timeZone"in e))}function P(e,t=n.Temporal.Now.timeZoneId()){return n.Temporal.Instant.fromEpochMilliseconds(e.getTime()).toZonedDateTimeISO(t)}function L(e){return n.Temporal.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()})}function $(e){return new Date(e.epochMilliseconds)}function A(e,t){return O(e)?function(e,t=n.Temporal.Now.timeZoneId()){return $(e.toZonedDateTime({timeZone:t,plainTime:n.Temporal.PlainTime.from({hour:0,minute:0})}))}(e,t):"hour"in e&&!("timeZone"in e)?new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second,e.millisecond):$(e)}function z(e,t){const a=Math.floor(t),r=Math.round(60*(t-a));return O(e)?n.Temporal.PlainDateTime.from({year:e.year,month:e.month,day:e.day,hour:a,minute:r}):e.with({hour:a,minute:r,second:0,millisecond:0})}function Y(e,t){const a=O(e)?e:e.toPlainDate(),r=O(t)?t:t.toPlainDate();return 0===n.Temporal.PlainDate.compare(a,r)}function V(e,t=n.Temporal.Now.timeZoneId()){return(O(e)?e:e.toPlainDate()).toZonedDateTime({timeZone:t,plainTime:n.Temporal.PlainTime.from({hour:0,minute:0})})}function F(e,t=n.Temporal.Now.timeZoneId()){return(O(e)?e:e.toPlainDate()).toZonedDateTime({timeZone:t,plainTime:n.Temporal.PlainTime.from({hour:23,minute:59,second:59,millisecond:999})})}function W(e,t){const n=new Date(e.getFullYear(),e.getMonth(),e.getDate()),a=new Date(t.getFullYear(),t.getMonth(),t.getDate());return Math.round((a.getTime()-n.getTime())/864e5)}function Z(e,t){const n=new Date(e);return n.setDate(n.getDate()+t),n}const U=e=>{if(e instanceof Date){return e.getHours()+e.getMinutes()/60}return O(t=e)?0:"hour"in t&&void 0!==t.hour?t.hour+(null!==(n=t.minute)&&void 0!==n?n:0)/60:(console.warn("Warning: No hour property found in temporal object, returning 0"),0);var t,n},B=(e,t)=>{if(e instanceof Date){const n=new Date(e),a=Math.floor(t),r=Math.round(60*(t-a));return n.setHours(a,r,0,0),n}return z(e,t)},_=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(23,59,59,999),t}return F(e)},q=(e,t)=>{if(e instanceof Date&&t instanceof Date)return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate();return Y(e instanceof Date?n.Temporal.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()}):O(e)?e:e.toPlainDate(),t instanceof Date?n.Temporal.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}):O(t)?t:t.toPlainDate())},G=(e,t)=>(t||b()).resolveColors(e).eventColor,X=(e,t)=>(t||b()).resolveColors(e).textColor,K=(e,t)=>(t||b()).resolveColors(e).eventSelectedColor,J=(e,t)=>(t||b()).resolveColors(e).lineColor,Q=.25,ee=(e,t=0)=>{const n=Math.floor(e),a=t||Math.round(60*(e-n));return`${n.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}`},te=e=>{const t=U(e.start),n=ae(e);return`${ee(t)} - ${ee(n)}`},ne=e=>{const t=Q;return Math.round(e/t)*t},ae=e=>{if(!e.end)return 0;const t=U(e.end);if(e.allDay||!e.start)return t;const n=A(e.start),a=A(e.end);if(!(n.getFullYear()!==a.getFullYear()||n.getMonth()!==a.getMonth()||n.getDate()!==a.getDate()))return t;if(0===t&&0===a.getMinutes()&&0===a.getSeconds()&&0===a.getMilliseconds()){const e=a.getTime()-n.getTime();if(e>0&&e<864e5)return 24}return t},re=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],oe=["January","February","March","April","May","June","July","August","September","October","November","December"],se=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],le=e=>{const t=e.getDay(),n=e.getDate()-t+(0===t?-6:1),a=new Date(e);a.setDate(n),a.setHours(0,0,0,0);const r=new Date(a);return r.setDate(a.getDate()+6),r.setHours(23,59,59,999),{monday:a,sunday:r}},ie=e=>{const t=new Date(e),n=t.getDate(),a=t.getMonth(),r=t.getFullYear(),o=new Date;return{date:t,day:n,month:a,year:r,monthName:oe[a],shortMonthName:se[a],isToday:o.getDate()===n&&o.getMonth()===a&&o.getFullYear()===r}},de=e=>{const t=[],n=new Date(e);for(let e=0;e<7;e++){const e=new Date(n);t.push(ie(e)),n.setDate(n.getDate()+1)}return{days:t,startDate:new Date(e),monthYear:ce(t)}},ce=e=>{const t={};e.forEach(e=>{const n=`${e.month}-${e.year}`;t[n]=(t[n]||0)+1});let n=0,a="";Object.entries(t).forEach(([e,t])=>{t>n&&(n=t,a=e)});const[r,o]=a.split("-").map(Number);return{month:oe[r],monthIndex:r,year:o}};function ue(e,t){const n=[],a=Math.floor(t/2),r=new Date(e),o=e.getDay(),s=0===o?6:o-1;r.setDate(e.getDate()-s),r.setHours(0,0,0,0);const l=new Date(r);l.setDate(l.getDate()-7*a);for(let e=0;e<t;e++){const t=new Date(l);t.setDate(t.getDate()+7*e),n.push(de(t))}return n}const ge=(e,t)=>t.filter(t=>t.day===e&&!t.allDay),me=(e,t)=>{const n=new Date(e);return n.setDate(e.getDate()+t),n},he=(e,t)=>t?n.Temporal.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()}):n.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.Temporal.Now.timeZoneId()}),fe=(e,t)=>{const n=new Date(e);n.setHours(0,0,0,0);const a=new Date(t);a.setHours(0,0,0,0);const r=n.getTime()-a.getTime();return Math.floor(r/864e5)},ve=(e,t)=>e.map(e=>{const n=A(e.start),a=fe(n,t);return Object.assign(Object.assign({},e),{day:a})}),pe=(e,t)=>e===t||!(!e||!t)&&(e.title===t.title&&e.calendarId===t.calendarId&&(e.description||"")===(t.description||"")&&!!e.allDay==!!t.allDay&&e.start.toString()===t.start.toString()&&e.end.toString()===t.end.toString());function ye(){return Date.now().toString(36)+Math.random().toString(36).substring(2,8)}function xe(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),a=Object.keys(t);if(n.length!==a.length)return!1;for(const r of n)if(!a.includes(r)||!xe(e[r],t[r]))return!1;return!0}const be="240px",De=e=>{if(!e)return{enabled:!1,width:be,initialCollapsed:!1};if(!0===e)return{enabled:!0,width:be,initialCollapsed:!1};const{enabled:t=!0,width:n,initialCollapsed:a=!1,render:r,createCalendarMode:o,renderCalendarContextMenu:s,renderCreateCalendarDialog:l,colorPickerMode:i}=e;return{enabled:t,width:C(n,be),initialCollapsed:a,render:r,createCalendarMode:o,renderCalendarContextMenu:s,renderCreateCalendarDialog:l,colorPickerMode:i}};class we{constructor(e){var n,a,r,o,s;this.getReadOnlyConfig=()=>{var e,t;const n=this.state.readOnly;return!0===n?{draggable:!1,viewable:!1}:!1===n?{draggable:!0,viewable:!0}:{draggable:null!==(e=n.draggable)&&void 0!==e&&e,viewable:null!==(t=n.viewable)&&void 0!==t&&t}},this.isInternalEditable=()=>!0!==this.state.readOnly&&"object"!=typeof this.state.readOnly,this.changeView=e=>{var t,n;if(!this.state.views.has(e))throw new Error(`View ${e} is not registered`);this.state.currentView=e,this.state.highlightedEventId=null,null===(n=(t=this.callbacks).onViewChange)||void 0===n||n.call(t,e)},this.getCurrentView=()=>{const e=this.state.views.get(this.state.currentView);if(!e)throw new Error(`Current view ${this.state.currentView} is not registered`);return e},this.setCurrentDate=e=>{var t,n;this.state.currentDate=new Date(e),null===(n=(t=this.callbacks).onDateChange)||void 0===n||n.call(t,this.state.currentDate),this.setVisibleMonth(this.state.currentDate)},this.getCurrentDate=()=>new Date(this.state.currentDate),this.setVisibleMonth=e=>{var t,n;const a=new Date(e.getFullYear(),e.getMonth(),1);this.visibleMonth.getFullYear()===a.getFullYear()&&this.visibleMonth.getMonth()===a.getMonth()||(this.visibleMonth=a,null===(n=(t=this.callbacks).onVisibleMonthChange)||void 0===n||n.call(t,new Date(this.visibleMonth)))},this.getVisibleMonth=()=>new Date(this.visibleMonth),this.goToToday=()=>{this.setCurrentDate(new Date)},this.goToPrevious=()=>{const e=new Date(this.state.currentDate);switch(this.state.currentView){case exports.ViewType.DAY:e.setDate(e.getDate()-1);break;case exports.ViewType.WEEK:e.setDate(e.getDate()-7);break;case exports.ViewType.MONTH:e.setMonth(e.getMonth()-1);break;case exports.ViewType.YEAR:e.setFullYear(e.getFullYear()-1)}this.setCurrentDate(e)},this.goToNext=()=>{const e=new Date(this.state.currentDate);switch(this.state.currentView){case exports.ViewType.DAY:e.setDate(e.getDate()+1);break;case exports.ViewType.WEEK:e.setDate(e.getDate()+7);break;case exports.ViewType.MONTH:e.setMonth(e.getMonth()+1);break;case exports.ViewType.YEAR:e.setFullYear(e.getFullYear()+1)}this.setCurrentDate(e)},this.selectDate=e=>{var t,n;this.setCurrentDate(e),null===(n=(t=this.callbacks).onDateChange)||void 0===n||n.call(t,new Date(e))},this.addEvent=e=>{var t,n;this.isInternalEditable()?(this.state.events=[...this.state.events,e],null===(n=(t=this.callbacks).onEventCreate)||void 0===n||n.call(t,e)):w.warn("Cannot add event in read-only mode")},this.updateEvent=(e,t,n)=>{if(!this.isInternalEditable()&&!n)return void w.warn("Cannot update event in read-only mode");if(!this.isInternalEditable())return;const a=this.state.events.findIndex(t=>t.id===e);if(-1===a)throw new Error(`Event with id ${e} not found`);const r=Object.assign(Object.assign({},this.state.events[a]),t);this.state.events=[...this.state.events.slice(0,a),r,...this.state.events.slice(a+1)]},this.deleteEvent=e=>{var t,n;if(!this.isInternalEditable())return void w.warn("Cannot delete event in read-only mode");const a=this.state.events.findIndex(t=>t.id===e);if(-1===a)throw new Error(`Event with id ${e} not found`);this.state.events=[...this.state.events.slice(0,a),...this.state.events.slice(a+1)],null===(n=(t=this.callbacks).onEventDelete)||void 0===n||n.call(t,e)},this.getAllEvents=()=>[...this.state.events],this.onEventClick=e=>{var t,n;null===(n=(t=this.callbacks).onEventClick)||void 0===n||n.call(t,e)},this.onMoreEventsClick=e=>{var t,n;null===(n=(t=this.callbacks).onMoreEventsClick)||void 0===n||n.call(t,e)},this.highlightEvent=e=>{var t,n;this.state.highlightedEventId=e,null===(n=(t=this.callbacks).onRender)||void 0===n||n.call(t)},this.getEvents=()=>{const e=this.getAllEvents(),t=new Set(this.calendarRegistry.getAll().filter(e=>!1!==e.isVisible).map(e=>e.id));return e.filter(e=>!e.calendarId||(!this.calendarRegistry.has(e.calendarId)||t.has(e.calendarId)))},this.getCalendars=()=>this.calendarRegistry.getAll(),this.reorderCalendars=(e,t)=>{var n,a;this.calendarRegistry.reorder(e,t),null===(a=(n=this.callbacks).onRender)||void 0===a||a.call(n)},this.setCalendarVisibility=(e,t)=>{var n,a;this.calendarRegistry.setVisibility(e,t),null===(a=(n=this.callbacks).onRender)||void 0===a||a.call(n)},this.setAllCalendarsVisibility=e=>{var t,n;this.calendarRegistry.setAllVisibility(e),null===(n=(t=this.callbacks).onRender)||void 0===n||n.call(t)},this.updateCalendar=(e,t)=>{var n,a,r,o;this.calendarRegistry.updateCalendar(e,t);const s=this.calendarRegistry.get(e);s&&(null===(a=(n=this.callbacks).onCalendarUpdate)||void 0===a||a.call(n,s)),null===(o=(r=this.callbacks).onRender)||void 0===o||o.call(r)},this.createCalendar=e=>{var t,n,a,r;this.calendarRegistry.register(e),null===(n=(t=this.callbacks).onCalendarCreate)||void 0===n||n.call(t,e),null===(r=(a=this.callbacks).onRender)||void 0===r||r.call(a)},this.deleteCalendar=e=>{var t,n,a,r;this.calendarRegistry.unregister(e),null===(n=(t=this.callbacks).onCalendarDelete)||void 0===n||n.call(t,e),null===(r=(a=this.callbacks).onRender)||void 0===r||r.call(a)},this.mergeCalendars=(e,t)=>{var n,a,r,o;this.state.events.filter(t=>t.calendarId===e).forEach(e=>{this.updateEvent(e.id,{calendarId:t})}),this.deleteCalendar(e),null===(a=(n=this.callbacks).onCalendarMerge)||void 0===a||a.call(n,e,t),null===(o=(r=this.callbacks).onRender)||void 0===o||o.call(r)},this.getSidebarConfig=()=>this.sidebarConfig,this.getCalendarHeaderConfig=()=>this.useCalendarHeader,this.installPlugin=e=>{this.state.plugins.has(e.name)?w.warn(`Plugin ${e.name} is already installed`):(this.state.plugins.set(e.name,e),e.install(this))},this.getPlugin=e=>{const t=this.state.plugins.get(e);return null==t?void 0:t.api},this.hasPlugin=e=>this.state.plugins.has(e),this.render=()=>t.createElement("div",{className:"calendar-app"},"Calendar App"),this.getPluginConfig=e=>{const t=this.state.plugins.get(e);return(null==t?void 0:t.config)||{}},this.updatePluginConfig=(e,t)=>{const n=this.state.plugins.get(e);n&&(n.config=Object.assign(Object.assign({},n.config),t))},this.getViewConfig=e=>{const t=this.state.views.get(e);return(null==t?void 0:t.config)||{}},this.triggerRender=()=>{var e,t;null===(t=(e=this.callbacks).onRender)||void 0===t||t.call(e)},this.getCalendarRegistry=()=>this.calendarRegistry,this.getUseEventDetailDialog=()=>this.useEventDetailDialog,this.getCustomMobileEventRenderer=()=>this.customMobileEventRenderer,this.updateConfig=e=>{var t;let n=!1;if(void 0!==e.customMobileEventRenderer&&e.customMobileEventRenderer!==this.customMobileEventRenderer&&(this.customMobileEventRenderer=e.customMobileEventRenderer,n=!0),void 0!==e.useEventDetailDialog&&e.useEventDetailDialog!==this.useEventDetailDialog&&(this.useEventDetailDialog=e.useEventDetailDialog,n=!0),void 0!==e.useCalendarHeader&&e.useCalendarHeader!==this.useCalendarHeader&&(this.useCalendarHeader=e.useCalendarHeader,n=!0),void 0===e.readOnly||xe(e.readOnly,this.state.readOnly)||(this.state.readOnly=e.readOnly,n=!0),e.callbacks&&(this.callbacks=Object.assign(Object.assign({},this.callbacks),e.callbacks)),void 0!==(null===(t=e.theme)||void 0===t?void 0:t.mode)&&e.theme.mode!==this.getTheme()&&this.setTheme(e.theme.mode),void 0!==e.useSidebar){const t=De(e.useSidebar);xe(t,this.sidebarConfig)||(this.sidebarConfig=t,this.state.sidebar=this.sidebarConfig,n=!0)}if(void 0!==e.switcherMode&&e.switcherMode!==this.state.switcherMode&&(this.state.switcherMode=e.switcherMode,n=!0),void 0!==e.locale){const t=this.resolveLocale(e.locale);xe(t,this.state.locale)||(this.state.locale=t,n=!0)}n&&this.triggerRender()},this.setTheme=e=>{var t,n;this.calendarRegistry.setTheme(e),this.themeChangeListeners.forEach(t=>{t(e)}),null===(n=(t=this.callbacks).onRender)||void 0===n||n.call(t)},this.getTheme=()=>this.calendarRegistry.getTheme(),this.subscribeThemeChange=e=>(this.themeChangeListeners.add(e),()=>{this.unsubscribeThemeChange(e)}),this.unsubscribeThemeChange=e=>{this.themeChangeListeners.delete(e)},this.state={currentView:e.defaultView||exports.ViewType.WEEK,currentDate:e.initialDate||new Date,events:e.events||[],switcherMode:e.switcherMode||"buttons",plugins:new Map,views:new Map,locale:this.resolveLocale(e.locale),highlightedEventId:null,readOnly:e.readOnly||!1},this.callbacks=e.callbacks||{},this.themeChangeListeners=new Set,this.calendarRegistry=new y(e.calendars,e.defaultCalendar,(null===(n=e.theme)||void 0===n?void 0:n.mode)||"light"),s=this.calendarRegistry,x=s,this.sidebarConfig=De(e.useSidebar),this.state.sidebar=this.sidebarConfig;const l=this.state.currentDate;this.visibleMonth=new Date(l.getFullYear(),l.getMonth(),1),this.useEventDetailDialog=null!==(a=e.useEventDetailDialog)&&void 0!==a&&a,this.useCalendarHeader=null===(r=e.useCalendarHeader)||void 0===r||r,this.customMobileEventRenderer=e.customMobileEventRenderer,e.views.forEach(e=>{this.state.views.set(e.type,e)}),null===(o=e.plugins)||void 0===o||o.forEach(e=>{this.installPlugin(e)})}resolveLocale(e){return e?"string"==typeof e?H(e)?e:"en-US":e&&"object"==typeof e&&!H(e.code)?Object.assign(Object.assign({},e),{code:"en-US"}):e:"en-US"}}function Ce(e,t){var n,a,r,o,s;try{if("today"===e){return null!==(a=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!==a?a:null}if("week"===e){return null!==(o=null===(r=new Intl.RelativeTimeFormat(t,{numeric:"always"}).formatToParts(1,"week").find(e=>"unit"===e.type))||void 0===r?void 0:r.value)&&void 0!==o?o:null}return null!==(s=new Intl.DisplayNames(t,{type:"dateTimeField"}).of(e))&&void 0!==s?s:null}catch(e){return null}}function Ee(e){return e.charAt(0).toUpperCase()+e.slice(1)}const ke=(e,t="short")=>{const n=[],a=new Date(2024,0,1);for(let r=0;r<7;r++){const o=new Date(a);o.setDate(a.getDate()+r);try{n.push(o.toLocaleDateString(e,{weekday:t}))}catch(e){n.push(o.toLocaleDateString("en-US",{weekday:t}))}}return n},Te=(e,t="long")=>{const n=[];for(let a=0;a<12;a++){const r=new Date(2024,a,1);try{n.push(r.toLocaleDateString(e,{month:t}))}catch(e){n.push(r.toLocaleDateString("en-US",{month:t}))}}return n};function je(e,t="en-US"){var n;if(["today","day","week","month","year"].includes(e)){const n=Ce(e,t);if(n)return Ee(n)}const a=R(t),r=I[a],o=null===(n=null==r?void 0:r.messages)||void 0===n?void 0:n[e];if(o)return o;const s=I.en.messages;return(null==s?void 0:s[e])||e}const Se=t.createContext({locale:"en-US",t:e=>e,getWeekDaysLabels:()=>[],getMonthLabels:()=>[],isDefault:!0});function Ne(){return t.useContext(Se)}const Me=t.forwardRef(({x:e,y:n,onClose:a,children:s,className:l},i)=>{const d=t.useRef(null);t.useEffect(()=>{const e=e=>{d.current&&!d.current.contains(e.target)&&a()};document.body.addEventListener("mousedown",e);const t=()=>a();return window.addEventListener("scroll",t,!0),window.addEventListener("resize",t),()=>{document.body.removeEventListener("mousedown",e),window.removeEventListener("scroll",t,!0),window.removeEventListener("resize",t)}},[a]);const c={top:n,left:e};return o.createPortal(r.jsx("div",{ref:e=>{d.current=e,"function"==typeof i?i(e):i&&(i.current=e)},className:`fixed z-50 min-w-32 overflow-hidden rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md dark:border-slate-800 dark:bg-slate-950 dark:text-slate-50 animate-in fade-in-0 zoom-in-95 duration-100 ease-out ${l||""}`,style:c,onContextMenu:e=>e.preventDefault(),children:s}),document.body)});Me.displayName="ContextMenu";const Ie=({onClick:e,children:t,icon:n,danger:a})=>r.jsxs("div",{className:"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-slate-100 focus:text-slate-900 data-disabled:pointer-events-none data-disabled:opacity-50 dark:focus:bg-slate-800 dark:focus:text-slate-50 hover:bg-slate-100 dark:hover:bg-slate-800 "+(a?"text-destructive focus:text-destructive-foreground focus:bg-destructive hover:bg-destructive hover:text-destructive-foreground":"text-slate-900 dark:text-slate-50"),onClick:t=>{t.stopPropagation(),e()},children:[n&&r.jsx("span",{className:"mr-2 h-4 w-4",children:n}),t]}),Re=()=>r.jsx("div",{className:"-mx-1 my-1 h-px bg-slate-200 dark:bg-slate-800"}),He=({children:e})=>r.jsx("div",{className:"px-2 py-1.5 text-sm font-semibold text-slate-950 dark:text-slate-50",children:e}),Oe=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],Pe=({selectedColor:e,onSelect:t,onCustomColor:n})=>{const{t:a}=Ne();return r.jsxs("div",{className:"p-2",children:[r.jsx("div",{className:"grid grid-cols-7 gap-2 p-1",children:Oe.map(n=>r.jsx("button",{type:"button",className:"h-5 w-5 rounded-full border border-gray-200 dark:border-gray-600 hover:scale-110 transition-transform focus:outline-none focus:ring-2 focus:ring-offset-1 focus:ring-primary dark:focus:ring-offset-slate-800 "+((null==e?void 0:e.toLowerCase())===n.toLowerCase()?"ring-2 ring-offset-1 ring-primary dark:ring-offset-slate-800":""),style:{backgroundColor:n},onClick:e=>{e.stopPropagation(),t(n)},title:n},n))}),n&&r.jsx("div",{className:"mt-1 flex cursor-pointer items-center rounded-sm px-2 py-1.5 text-sm text-slate-700 hover:bg-slate-100 dark:text-slate-200 dark:hover:bg-slate-800",onClick:e=>{e.stopPropagation(),n()},children:a("customColor")})]})},Le=({isCollapsed:e,onCollapseToggle:t})=>{const{t:n}=Ne();return r.jsxs("div",{className:"flex items-center px-2 py-2",children:[r.jsx("button",{type:"button","aria-label":n(e?"expandSidebar":"collapseSidebar"),className:"flex h-8 w-8 items-center justify-center rounded hover:bg-gray-100 dark:hover:bg-slate-800",onClick:t,children:e?r.jsx(i.PanelRightClose,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"}):r.jsx(i.PanelRightOpen,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"})}),!e&&r.jsx("div",{className:"flex flex-1 justify-between items-center",children:r.jsx("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:n("calendars")})})]})},$e=e=>{if(e.icon)return e.icon;return(e.name||e.id).charAt(0).toUpperCase()},Ae=({calendars:e,onToggleVisibility:n,onReorder:a,onRename:o,onContextMenu:s,editingId:l,setEditingId:i,activeContextMenuCalendarId:d,isDraggable:c=!0,isEditable:u=!0})=>{const[g,m]=t.useState(""),h=t.useRef(null),[f,v]=t.useState(!1),[p,y]=t.useState(null),[x,b]=t.useState(null),D=t.useCallback((e,t)=>{if(l||!c)return void t.preventDefault();v(!0),y(e.id);const n={calendarId:e.id,calendarName:e.name,calendarColors:e.colors,calendarIcon:e.icon};t.dataTransfer.setData("application/x-dayflow-calendar",JSON.stringify(n)),t.dataTransfer.effectAllowed="copy"},[l]),w=t.useCallback(()=>{v(!1),y(null),b(null)},[]),C=t.useCallback((t,n)=>{if(t.preventDefault(),p===n)return void b(null);const a=e.findIndex(e=>e.id===n)===e.length-1,r=t.currentTarget.getBoundingClientRect(),o=t.clientY<r.top+r.height/2;b(a?{id:n,position:o?"top":"bottom"}:{id:n,position:"top"})},[p,e]),E=t.useCallback(()=>{b(null)},[]),k=t.useCallback(t=>{if(!p||!x)return;if(p===t.id)return;const n=e.findIndex(e=>e.id===p);let r=e.findIndex(e=>e.id===t.id);"bottom"===x.position&&(r+=1),r>n&&(r-=1),-1!==n&&-1!==r&&a(n,r),b(null)},[p,x,e,a]),T=t.useCallback(e=>{u&&(i(e.id),m(e.name))},[i,u]),j=t.useCallback(e=>{m(e.target.value)},[]),S=t.useCallback(()=>{if(l&&g.trim()){const t=e.find(e=>e.id===l);t&&t.name!==g.trim()&&o(l,g.trim())}i(null),m("")},[l,g,e,o,i]),N=t.useCallback(()=>{i(null),m("")},[i]),M=t.useCallback(e=>{"Enter"===e.key?S():"Escape"===e.key&&N()},[S,N]);return t.useEffect(()=>{l&&h.current&&(h.current.focus(),h.current.select())},[l]),t.useEffect(()=>{if(l){const t=e.find(e=>e.id===l);t&&m(t.name)}},[l,e]),r.jsx("div",{className:"df-calendar-list flex-1 overflow-y-auto px-2 pb-3",children:r.jsx("ul",{className:"space-y-1 relative",children:e.map(e=>{var t;const a=!1!==e.isVisible,o=(null===(t=e.colors)||void 0===t?void 0:t.lineColor)||"#3b82f6",i=Boolean(e.icon),u=(null==x?void 0:x.id)===e.id,m=d===e.id||l===e.id;return r.jsxs("li",{className:"df-calendar-list-item relative",onDragOver:t=>C(t,e.id),onDragLeave:E,onDrop:()=>k(e),onContextMenu:t=>s(t,e.id),children:[u&&"top"===x.position&&r.jsx("div",{className:"absolute top-0 left-0 right-0 h-0.5 bg-primary z-10 pointer-events-none"}),r.jsx("div",{draggable:c&&!l,onDragStart:t=>D(e,t),onDragEnd:w,className:`rounded transition ${p===e.id?"opacity-50":""} ${c?"cursor-grab":"cursor-default"}`,children:r.jsxs("div",{className:"group flex items-center rounded px-2 py-2 transition hover:bg-gray-100 dark:hover:bg-slate-800 "+(m?"bg-gray-100 dark:bg-slate-800":""),title:e.name,children:[r.jsx("input",{type:"checkbox",className:"calendar-checkbox cursor-pointer shrink-0",style:{"--checkbox-color":o},checked:a,onChange:t=>n(e.id,t.target.checked)}),i&&r.jsx("span",{className:"ml-2 flex h-5 w-5 shrink-0 items-center justify-center text-xs font-semibold text-white","aria-hidden":"true",children:$e(e)}),l===e.id?r.jsx("input",{ref:h,type:"text",value:g,onChange:j,onBlur:S,onKeyDown:M,className:"ml-2 flex-1 min-w-0 h-5 rounded bg-white px-0 py-0 text-sm text-gray-900 focus:outline-none dark:bg-slate-700 dark:text-gray-100",onClick:e=>e.stopPropagation()}):r.jsx("span",{className:"flex-1 pl-1 truncate text-sm text-gray-700 group-hover:text-gray-900 dark:text-gray-200 dark:group-hover:text-white ml-2",onDoubleClick:()=>T(e),children:e.name||e.id})]})}),u&&"bottom"===x.position&&r.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary z-10 pointer-events-none"})]},e.id)})})})},ze="df-month-view h-full flex flex-col bg-white dark:bg-gray-900 select-none",Ye="df-header p-2 flex justify-between",Ve="text-2xl font-bold text-gray-900 dark:text-gray-100",Fe="rounded-md bg-background border border-border px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-(--hover)",We="df-date-number inline-flex items-center justify-center h-6 w-6 rounded-full text-sm mt-1 select-none",Ze="flex-1 overflow-auto will-change-scroll",Ue="df-time-slot relative h-[4.5rem] flex",Be="df-time-label absolute -top-2.5 right-2 text-[12px] text-gray-500 dark:text-gray-400 select-none",_e="df-time-grid-row h-[4.5rem] border-t first:border-none border-gray-200 dark:border-gray-700 flex",qe="df-current-time-line absolute left-0 top-0 flex pointer-events-none",Ge="df-current-time-label ml-2 text-primary-foreground text-xs font-bold px-1.5 bg-primary rounded-sm",Xe="df-all-day-row flex items-center border-b border-gray-200 dark:border-gray-700 sticky",Ke="rounded-xl my-0.5",Je="df-event-title font-medium text-xs truncate pr-1",Qe="df-event-color-bar absolute left-1 top-1 bottom-1 w-[3px] rounded-full",et="h-3 w-3 mr-1",tt="resize-handle absolute right-0 top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20",nt="bg-primary rounded-full text-primary-foreground",at="df-nav-button calendar-nav-button group relative inline-flex items-center justify-center w-7 h-7 rounded-md border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 hover:border-gray-300 dark:hover:border-gray-500 active:bg-gray-100 dark:active:bg-gray-600 transition-all duration-150 shadow-sm hover:shadow focus:outline-none",rt="h-4 w-4 transition-transform group-hover:scale-110",ot="df-event-detail-panel fixed bg-white dark:bg-gray-800 shadow-lg border border-gray-200 dark:border-gray-700 rounded-lg",st="h-3 border-t border-gray-200 dark:border-gray-700 relative",lt="flex h-7 w-7 items-center justify-center rounded hover:bg-gray-100 dark:hover:bg-slate-800 transition-colors",it="text-gray-500 dark:text-gray-400",dt="text-gray-600 dark:text-gray-300",ct="text-xs",ut="text-sm",gt="flex flex-col",mt="mr-1",ht=({visibleMonth:e,currentDate:n,showHeader:a=!1,onMonthChange:o,onDateSelect:s})=>{const{locale:l}=Ne(),d=t.useMemo(()=>(new Date).toDateString(),[]),c=n.toDateString(),u=t.useMemo(()=>ke(l,"narrow"),[l]),g=t.useMemo(()=>e.toLocaleDateString(l,{month:"long",year:"numeric"}),[e,l]),m=t.useMemo(()=>{const t=e.getFullYear(),n=e.getMonth(),a=(new Date(t,n,1).getDay()+6)%7,r=[];for(let e=0;e<42;e++){const o=new Date(t,n,e-a+1),s=o.toDateString();r.push({date:o.getDate(),fullDate:o,isCurrentMonth:o.getMonth()===n,isToday:s===d,isSelected:s===c})}return r},[e,c,d]);return r.jsxs("div",{className:"px-3 py-3",children:[a?r.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[r.jsx("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:r.jsx(i.ChevronLeft,{className:"h-4 w-4"})}),r.jsx("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:g}),r.jsx("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:r.jsx(i.ChevronRight,{className:"h-4 w-4"})})]}):"",r.jsxs("div",{className:"df-mini-calendar-grid grid grid-cols-7 gap-1 text-xs justify-items-center",children:[u.map((e,t)=>r.jsx("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}`)),m.map(e=>r.jsx("button",{type:"button",className:`\n df-mini-calendar-day text-center py-1 rounded text-xs h-6 w-6\n ${e.isToday?nt:e.isCurrentMonth?"text-gray-900 dark:text-gray-100":"text-gray-400 dark:text-gray-600"}\n ${e.isSelected&&!e.isToday?"bg-secondary text-secondary-foreground rounded-full font-medium":""}\n `,onClick:()=>s(e.fullDate),children:e.date},e.fullDate.getTime()))]})]})},ft=({calendars:e,currentCalendarId:n,onMergeSelect:a})=>{const{t:s}=Ne(),[l,d]=t.useState(!1),c=t.useRef(null),u=t.useRef(null),[g,m]=t.useState({x:0,y:0}),h=t.useRef(),f=()=>{if(h.current&&clearTimeout(h.current),c.current){const e=c.current.getBoundingClientRect();m({x:e.right,y:e.top})}d(!0)},v=()=>{h.current=setTimeout(()=>{d(!1)},100)};t.useEffect(()=>{const e=u.current;if(e){const t=e=>e.stopPropagation();return e.addEventListener("mousedown",t),()=>{e.removeEventListener("mousedown",t)}}},[l]);const p=e.filter(e=>e.id!==n);return 0===p.length?null:r.jsxs(r.Fragment,{children:[r.jsxs("div",{ref:c,className:"relative flex cursor-default select-none items-center justify-between rounded-sm px-2 py-1.5 text-sm outline-none transition-colors hover:bg-slate-100 dark:hover:bg-slate-800 text-slate-900 dark:text-slate-50",onMouseEnter:f,onMouseLeave:v,children:[r.jsx("span",{children:s("merge")}),r.jsx(i.ChevronRight,{className:"h-4 w-4"})]}),l&&o.createPortal(r.jsx("div",{ref:u,className:"fixed z-60 min-w-48 overflow-hidden rounded-md border border-slate-200 bg-white p-1 shadow-md dark:border-slate-800 dark:bg-slate-950 animate-in fade-in-0 zoom-in-95 duration-100",style:{top:g.y,left:g.x},onMouseEnter:f,onMouseLeave:v,onMouseDown:e=>e.stopPropagation(),children:p.map(e=>r.jsxs("div",{className:"flex items-center cursor-pointer rounded-sm px-2 py-1.5 text-sm text-slate-900 hover:bg-slate-100 dark:text-slate-50 dark:hover:bg-slate-800",onClick:t=>{t.stopPropagation(),a(e.id)},children:[r.jsx("div",{className:"mr-2 h-3 w-3 rounded-sm shrink-0",style:{backgroundColor:e.colors.lineColor}}),r.jsx("span",{className:"truncate",children:e.name||e.id})]},e.id))}),document.body)]})},vt=({sourceName:e,targetName:t,onConfirm:n,onCancel:a})=>{const{t:o}=Ne();return r.jsx("div",{className:"fixed inset-0 z-100 flex items-center justify-center bg-black/50",children:r.jsxs("div",{className:"w-full max-w-md rounded-lg p-6 shadow-xl bg-background",children:[r.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:o("mergeConfirmTitle",{sourceName:e,targetName:t})}),r.jsx("p",{className:"mt-3 text-sm text-gray-600 dark:text-gray-300",children:o("mergeConfirmMessage",{sourceName:e,targetName:t})}),r.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[r.jsx("button",{type:"button",onClick:a,className:Fe,children:o("cancel")}),r.jsx("button",{type:"button",onClick:n,className:"rounded-md bg-destructive px-4 py-2 text-sm font-medium text-destructive-foreground hover:bg-destructive/90",children:o("merge")})]})]})})},pt=({calendarId:e,calendarName:n,calendars:a,step:o,onStepChange:s,onConfirmDelete:l,onCancel:i,onMergeSelect:d})=>{const[c,u]=t.useState(!1),{t:g}=Ne();return r.jsx("div",{className:"fixed inset-0 z-100 flex items-center justify-center bg-black/50",children:r.jsx("div",{className:"w-full max-w-md rounded-lg p-6 shadow-xl bg-background",children:"initial"===o?r.jsxs(r.Fragment,{children:[r.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:g("deleteCalendar",{calendarName:n})}),r.jsx("p",{className:"mt-3 text-sm text-gray-600 dark:text-gray-300",children:g("deleteCalendarMessage",{calendarName:n})}),r.jsxs("div",{className:"mt-6 flex justify-between items-center",children:[r.jsxs("div",{className:"relative",children:[r.jsx("button",{type:"button",onClick:()=>u(!c),className:"flex items-center gap-1 rounded-md border border-gray-300 px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50 dark:border-gray-600 dark:text-gray-200 dark:hover:bg-slate-700",children:g("merge")}),c&&r.jsx("div",{className:"absolute left-0 top-full mt-1 min-w-full w-max rounded-md border border-gray-200 bg-background shadow-lg dark:border-slate-700 z-10 max-h-60 overflow-y-auto",children:a.filter(t=>t.id!==e).map(e=>r.jsxs("div",{className:"flex items-center px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-slate-700 cursor-pointer",onClick:()=>{d(e.id),u(!1)},children:[r.jsx("div",{className:"mr-2 h-3 w-3 rounded-sm shrink-0",style:{backgroundColor:e.colors.lineColor}}),r.jsx("span",{className:"whitespace-nowrap",children:e.name||e.id})]},e.id))})]}),r.jsxs("div",{className:"flex gap-3",children:[r.jsx("button",{type:"button",onClick:i,className:Fe,children:g("cancel")}),r.jsx("button",{type:"button",onClick:()=>s("confirm_delete"),className:"rounded-md bg-destructive px-4 py-2 text-sm font-medium text-destructive-foreground hover:bg-destructive/90",children:g("delete")})]})]})]}):r.jsxs(r.Fragment,{children:[r.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:g("confirmDeleteTitle",{calendarName:n})}),r.jsx("p",{className:"mt-3 text-sm text-gray-600 dark:text-gray-300",children:g("confirmDeleteMessage")}),r.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[r.jsx("button",{type:"button",onClick:i,className:"rounded-md px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-slate-700",children:g("cancel")}),r.jsx("button",{type:"button",onClick:l,className:"rounded-md bg-destructive px-4 py-2 text-sm font-medium text-destructive-foreground hover:bg-destructive/90",children:g("delete")})]})]})})})},yt="new-calendar",xt=({calendars:e,filename:n,onConfirm:a,onCancel:s})=>{var l;const{t:d}=Ne(),[c,u]=t.useState((null===(l=e[0])||void 0===l?void 0:l.id)||yt),[g,m]=t.useState(!1),[h,f]=t.useState(!1),v=t.useRef(null),p=t.useRef(null);t.useEffect(()=>{if(!g){const e=setTimeout(()=>f(!1),200);return()=>clearTimeout(e)}f(!0)},[g]),t.useEffect(()=>{const e=e=>{var t;!v.current||v.current.contains(e.target)||(null===(t=p.current)||void 0===t?void 0:t.contains(e.target))||m(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const y=e.find(e=>e.id===c),x=c===yt,b=e=>{u(e),m(!1)};return r.jsx("div",{className:"fixed inset-0 z-100 flex items-center justify-center bg-black/50",children:r.jsxs("div",{className:"w-full max-w-md rounded-lg bg-white p-6 shadow-xl dark:bg-slate-900",children:[r.jsx("h2",{className:"mb-4 text-lg font-semibold text-gray-900 dark:text-white",children:d("addSchedule")||"Add Schedule"}),r.jsx("p",{className:"mb-4 text-sm text-gray-600 dark:text-gray-300",children:d("importCalendarMessage")||"This calendar contains new events. Please select a target calendar."}),r.jsxs("div",{className:"relative",children:[r.jsxs("button",{ref:p,type:"button",className:"flex items-center w-full border border-gray-300 dark:border-gray-600 rounded-md px-3 py-2 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors shadow-sm",onClick:()=>m(!g),children:[!x&&y&&r.jsx("div",{className:"mr-3 h-3 w-3 shrink-0 rounded-sm",style:{backgroundColor:y.colors.lineColor}}),r.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-200 flex-1 text-left truncate "+(x?"pl-0":""),children:x?`${d("newCalendar")}: ${n}`:(null==y?void 0:y.name)||(null==y?void 0:y.id)}),r.jsx(i.ChevronsUpDown,{className:"w-4 h-4 text-gray-400 shrink-0 ml-2"})]}),(()=>{var t;if(!h)return null;const a=null===(t=p.current)||void 0===t?void 0:t.getBoundingClientRect();return a?o.createPortal(r.jsx("div",{ref:v,className:"fixed z-110 mt-1 max-h-60 overflow-y-auto rounded-md bg-white shadow-lg border border-gray-200 dark:border-slate-700 dark:bg-slate-800 transition-all duration-200 origin-top "+(g?"opacity-100 scale-100":"opacity-0 scale-95"),style:{top:a.bottom,left:a.left,width:a.width},children:r.jsxs("div",{className:"py-1",children:[e.map(e=>r.jsxs("div",{className:"flex items-center px-3 py-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-slate-700 "+(c===e.id?"bg-primary/10":""),onClick:()=>b(e.id),children:[r.jsx("div",{className:"mr-3 h-3 w-3 shrink-0 rounded-sm",style:{backgroundColor:e.colors.lineColor}}),r.jsx("span",{className:"flex-1 text-sm truncate "+(c===e.id?"font-medium text-primary":"text-gray-700 dark:text-gray-200"),children:e.name||e.id}),c===e.id&&r.jsx(i.Check,{className:"ml-2 w-4 h-4 text-primary shrink-0"})]},e.id)),r.jsx("div",{className:"border-t border-gray-100 dark:border-slate-700 my-1"}),r.jsxs("div",{className:"flex items-center px-3 py-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-slate-700 "+(x?"bg-primary/10":""),onClick:()=>b(yt),children:[r.jsxs("span",{className:"flex-1 text-sm truncate "+(x?"font-medium text-primary":"text-gray-700 dark:text-gray-200 pl-6"),children:[d("newCalendar")||"New Calendar",": ",n]}),x&&r.jsx(i.Check,{className:"ml-2 w-4 h-4 text-primary shrink-0"})]})]})}),document.body):null})()]}),r.jsxs("div",{className:"mt-8 flex justify-end gap-3",children:[r.jsx("button",{type:"button",onClick:s,className:Fe,children:d("cancel")||"Cancel"}),r.jsx("button",{type:"button",onClick:()=>a(c),className:"rounded-md bg-primary px-6 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 transition-colors shadow-sm",children:d("ok")||"OK"})]})]})})};function bt(e){return!("hour"in e)}function Dt(e){return"hour"in e&&!("timeZone"in e)}function wt(e){return"timeZone"in e}function Ct(e){return n.Temporal.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()})}function Et(e){return n.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 kt(e,t){return n.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})}const Tt=/^(\d{4})(\d{2})(\d{2})$/,jt=/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})$/,St=/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z$/;function Nt(e,t,a){const r=e.trim();if("DATE"===(null==t?void 0:t.value)||Tt.test(r)){const e=r.match(Tt);if(e)return n.Temporal.PlainDate.from({year:parseInt(e[1],10),month:parseInt(e[2],10),day:parseInt(e[3],10)})}if(St.test(r)){const e=r.match(St);if(e){const t=n.Temporal.Instant.from(`${e[1]}-${e[2]}-${e[3]}T${e[4]}:${e[5]}:${e[6]}Z`),r=a||n.Temporal.Now.timeZoneId();return t.toZonedDateTimeISO(r)}}const o=r.match(jt);if(o){const e={year:parseInt(o[1],10),month:parseInt(o[2],10),day:parseInt(o[3],10),hour:parseInt(o[4],10),minute:parseInt(o[5],10),second:parseInt(o[6],10)};return(null==t?void 0:t.tzid)?n.Temporal.ZonedDateTime.from(Object.assign(Object.assign({},e),{timeZone:t.tzid})):n.Temporal.PlainDateTime.from(e)}throw new Error(`Invalid ICS date format: ${e}`)}function Mt(e,t=!1){if(t||bt(e)){const t=bt(e)?e:e.toPlainDate();return{value:`${t.year}${Rt(t.month)}${Rt(t.day)}`,params:{VALUE:"DATE"}}}if(wt(e)){const t=e.toInstant().toZonedDateTimeISO("UTC");return{value:`${t.year}${Rt(t.month)}${Rt(t.day)}T${Rt(t.hour)}${Rt(t.minute)}${Rt(t.second)}Z`}}if(Dt(e))return{value:`${e.year}${Rt(e.month)}${Rt(e.day)}T${Rt(e.hour)}${Rt(e.minute)}${Rt(e.second)}`};throw new Error("Unsupported Temporal type")}function It(e){return`${e.getUTCFullYear()}${Rt(e.getUTCMonth()+1)}${Rt(e.getUTCDate())}T${Rt(e.getUTCHours())}${Rt(e.getUTCMinutes())}${Rt(e.getUTCSeconds())}Z`}function Rt(e){return String(e).padStart(2,"0")}function Ht(e,t={}){const a={success:!1,events:[],errors:[],totalParsed:0,totalImported:0};try{const r=e.replace(/(\r\n|\n|\r)[ \t]/g,""),o=function(e){const t=[];let n=null,a=!1;for(const r of e){const e=r.trim().toUpperCase();e.startsWith("BEGIN:VEVENT")?(a=!0,n=[]):e.startsWith("END:VEVENT")?(a&&n&&t.push(n),a=!1,n=null):a&&n&&n.push(r)}return t}(r.split(/\r\n|\n|\r/));a.totalParsed=o.length,o.forEach((e,r)=>{try{const r=function(e){const t={};for(const n of e){const e=n.indexOf(":");if(-1===e)continue;const a=n.substring(0,e),r=n.substring(e+1),[o,...s]=a.split(";"),l=o.trim().toUpperCase(),i={};switch(s.forEach(e=>{const[t,n]=e.split("=");t&&n&&(i[t.trim().toUpperCase()]=n.trim())}),l){case"UID":t.uid=r.trim();break;case"SUMMARY":t.summary=Ot(r);break;case"DESCRIPTION":t.description=Ot(r);break;case"LOCATION":t.location=Ot(r);break;case"DTSTART":t.dtstart=r.trim(),t.dtstartParams={value:i.VALUE,tzid:i.TZID};break;case"DTEND":t.dtend=r.trim(),t.dtendParams={value:i.VALUE,tzid:i.TZID};break;case"CATEGORIES":t.categories=r.split(",").map(e=>Ot(e.trim()))}}if(!t.dtstart)throw new Error("Missing DTSTART in VEVENT");t.uid||(t.uid=ye());return t}(e),o=function(e,t){var a;const{calendarId:r="default",generateNewIds:o=!0,idPrefix:s="ics-",defaultTimeZone:l}=t,i=o?`${s}${ye()}`:e.uid,d=Nt(e.dtstart,e.dtstartParams,l);let c;c=e.dtend?Nt(e.dtend,e.dtendParams,l):bt(d)?d.add({days:1}):d.add({hours:1});const u="DATE"===(null===(a=e.dtstartParams)||void 0===a?void 0:a.value)||bt(d),g=l||n.Temporal.Now.timeZoneId();let m,h;if(bt(d))m=d.toZonedDateTime({timeZone:g,plainTime:"00:00:00"});else if(Dt(d))try{if("function"!=typeof d.toZonedDateTime)throw new Error("toZonedDateTime missing");m=d.toZonedDateTime(g)}catch(e){m=n.Temporal.ZonedDateTime.from({year:d.year,month:d.month,day:d.day,hour:d.hour,minute:d.minute,second:d.second,millisecond:d.millisecond,timeZone:g})}else m=d;if(bt(c))h=c.toZonedDateTime({timeZone:g,plainTime:"00:00:00"});else if(Dt(c))try{if("function"!=typeof c.toZonedDateTime)throw new Error("toZonedDateTime missing");h=c.toZonedDateTime(g)}catch(e){h=n.Temporal.ZonedDateTime.from({year:c.year,month:c.month,day:c.day,hour:c.hour,minute:c.minute,second:c.second,millisecond:c.millisecond,timeZone:g})}else h=c;return{id:i,calendarId:r,title:e.summary||"(No Title)",description:e.description,start:m,end:h,allDay:u,meta:{location:e.location,originalUid:e.uid,categories:e.categories}}}(r,t);a.events.push(o)}catch(e){a.errors.push({line:0,message:e.message||"Unknown parsing error",eventUid:`index-${r}`})}}),a.success=0===a.errors.length,a.totalImported=a.events.length}catch(e){a.errors.push({message:`Fatal parsing error: ${e.message}`})}return a}function Ot(e){return e.replace(/\\,/g,",").replace(/\\;/g,";").replace(/\\[nN]/g,"\n").replace(/\\\\/g,"\\")}function Pt(e,t={}){const{calendarName:n="DayFlow Calendar",productId:a="-//DayFlow//DayFlow Calendar//EN",includeTimezone:r=!0}=t,o=[];return o.push("BEGIN:VCALENDAR"),o.push("VERSION:2.0"),o.push(`PRODID:${a}`),o.push("CALSCALE:GREGORIAN"),o.push("METHOD:PUBLISH"),o.push(`X-WR-CALNAME:${At(n)}`),e.forEach(e=>{o.push(...function(e){var t,n,a;const r=[];r.push("BEGIN:VEVENT");const o=null===(t=e.meta)||void 0===t?void 0:t.originalUid,s=o||`${e.id}@dayflow`;r.push(`UID:${s}`),r.push(`DTSTAMP:${It(new Date)}`);const l=Mt(e.start,e.allDay),i=Mt(e.end,e.allDay);r.push($t("DTSTART",l.value,l.params)),r.push($t("DTEND",i.value,i.params)),r.push($t("SUMMARY",At(e.title))),e.description&&r.push($t("DESCRIPTION",At(e.description)));const d=null===(n=e.meta)||void 0===n?void 0:n.location;d&&r.push($t("LOCATION",At(d)));const c=null===(a=e.meta)||void 0===a?void 0:a.categories;if(c&&Array.isArray(c)){const e=c.map(At).join(",");r.push($t("CATEGORIES",e))}return r.push("END:VEVENT"),r}(e))}),o.push("END:VCALENDAR"),o.join("\r\n")}function Lt(e,t={}){const n=Pt(e,t),a=`${t.filename||"calendar"}.ics`,r=new Blob([n],{type:"text/calendar;charset=utf-8"}),o=URL.createObjectURL(r),s=document.createElement("a");s.href=o,s.setAttribute("download",a),document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(o)}function $t(e,t,n){let a=e;return n&&Object.entries(n).forEach(([e,t])=>{a+=`;${e}=${t}`}),a+=`:${t}`,function(e){if(e.length<=75)return e;const t=[];let n=e;t.push(n.slice(0,75)),n=n.slice(75);for(;n.length>0;)t.push(" "+n.slice(0,74)),n=n.slice(74);return t.join("\r\n")}(a)}function At(e){return e?e.replace(/\\/g,"\\\\").replace(/;/g,"\\;").replace(/,/g,"\\,").replace(/\n/g,"\\n"):""}function zt(e,t){return a.__awaiter(this,void 0,void 0,function*(){return new Promise((n,a)=>{const r=new FileReader;r.onload=e=>{var a;try{const r=null===(a=e.target)||void 0===a?void 0:a.result;if(!r)throw new Error("File content is empty");const o=Ht(r,t);n(o)}catch(e){n({success:!1,events:[],errors:[{message:e.message||"Failed to read file"}],totalParsed:0,totalImported:0})}},r.onerror=()=>{n({success:!1,events:[],errors:[{message:"File read error"}],totalParsed:0,totalImported:0})},r.readAsText(e)})})}const Yt=({app:e,calendars:n,toggleCalendarVisibility:i,isCollapsed:d,setCollapsed:c,renderCalendarContextMenu:u,editingCalendarId:g,setEditingCalendarId:m,onCreateCalendar:h,colorPickerMode:f="default"})=>{var v,p,y,x;const{t:b}=Ne(),w=e.getVisibleMonth(),C=w.getFullYear(),E=w.getMonth(),[k,T]=t.useState(null),j=void 0!==g?g:k,S=m||T,N=t.useRef(null),M=t.useRef(null),[I,R]=t.useState(()=>new Date(C,E,1));t.useEffect(()=>{R(e=>e.getFullYear()===C&&e.getMonth()===E?e:new Date(C,E,1))},[C,E]);const H=t.useCallback(t=>{R(n=>{const a=new Date(n.getFullYear(),n.getMonth()+t,1);return e.setVisibleMonth(a),a})},[e]),[O,P]=t.useState(null),[L,$]=t.useState(null),[A,z]=t.useState(null),[Y,V]=t.useState(!1);t.useEffect(()=>{if(A&&"blossom"===f){const e=setTimeout(()=>{V(!0)},50);return()=>clearTimeout(e)}V(!1)},[A,f]);const[F,W]=t.useState(null),[Z,U]=t.useState(null),[B,_]=t.useState(null),q=t.useCallback((e,t)=>{e.preventDefault(),e.stopPropagation(),P({x:e.clientX,y:e.clientY,calendarId:t}),$(null)},[]),G=t.useCallback(e=>{e.preventDefault(),$({x:e.clientX,y:e.clientY}),P(null)},[]),X=t.useCallback(()=>{P(null)},[]),K=t.useCallback(()=>{$(null)},[]),J=t.useCallback(()=>{O&&(U({calendarId:O.calendarId,step:"initial"}),X())},[O,X]),Q=t.useCallback(t=>{if(O){const{colors:n,darkColors:a}=D(t);e.updateCalendar(O.calendarId,{colors:n,darkColors:a}),X()}},[e,O,X]),ee=t.useCallback(()=>{if(O){const e=n.find(e=>e.id===O.calendarId);if(e){const{h:t,s:n,l:a}=s.hexToHsl(e.colors.lineColor),r=s.lightnessToSliderValue(a);let o=O.x,l=O.y;if(M.current){const e=M.current.getBoundingClientRect();o=e.left+e.width/2,l=e.top+e.height/2}z({x:o,y:l,calendarId:O.calendarId,initialColor:{hue:t,saturation:r,lightness:a,alpha:100,layer:"outer"},currentColor:e.colors.lineColor})}X()}},[O,n,X]),te=t.useCallback(e=>{O&&(W({sourceId:O.calendarId,targetId:e}),X())},[O,X]),ne=t.useCallback(()=>{if(F){const{sourceId:t,targetId:n}=F;e.mergeCalendars(t,n),W(null)}},[e,F]),ae=t.useCallback(()=>{Z&&(e.deleteCalendar(Z.calendarId),U(null))},[e,Z]),re=t.useCallback(e=>{Z&&(W({sourceId:Z.calendarId,targetId:e}),U(null))},[Z]),oe=t.useCallback(()=>{var e;null===(e=N.current)||void 0===e||e.click(),K()},[K]),se=t.useCallback(e=>a.__awaiter(void 0,void 0,void 0,function*(){var t;const n=null===(t=e.target.files)||void 0===t?void 0:t[0];if(!n)return;const a=yield zt(n);a.events.length>0&&_({events:a.events,filename:n.name.replace(/\.[^/.]+$/,"")}),N.current&&(N.current.value="")}),[]),le=t.useCallback(t=>{if(B){let n=t;if(t===yt){const t=["#3b82f6","#10b981","#8b5cf6","#f59e0b","#ef4444","#f97316","#ec4899","#14b8a6","#6366f1","#6b7280"],a=t[Math.floor(Math.random()*t.length)],{colors:r,darkColors:o}=D(a);n=ye(),e.createCalendar({id:n,name:B.filename,isDefault:!1,colors:r,darkColors:o,isVisible:!0})}B.events.forEach(t=>{e.addEvent(Object.assign(Object.assign({},t),{calendarId:n}))}),_(null)}},[e,B]),ie=t.useCallback(()=>{if(O){const t=n.find(e=>e.id===O.calendarId);if(t){Lt(e.getEvents().filter(e=>e.calendarId===t.id),{calendarName:t.name,filename:t.name||"calendar"})}X()}},[O,n,e,X]),de=F?(null===(v=n.find(e=>e.id===F.sourceId))||void 0===v?void 0:v.name)||"Unknown":"",ce=F?(null===(p=n.find(e=>e.id===F.targetId))||void 0===p?void 0:p.name)||"Unknown":"",ue=Z?(null===(y=n.find(e=>e.id===Z.calendarId))||void 0===y?void 0:y.name)||"Unknown":"",ge=e.getReadOnlyConfig(),me=!e.state.readOnly,he=!1!==ge.draggable;return r.jsxs("div",{className:"df-sidebar flex h-full flex-col border-r border-gray-200 dark:border-gray-700 bg-white dark:bg-slate-900",onContextMenu:me?G:void 0,children:[r.jsx(Le,{isCollapsed:d,onCollapseToggle:()=>c(!d)}),d?r.jsx(Ae,{calendars:n,onToggleVisibility:i,onReorder:he?e.reorderCalendars:()=>{},onRename:me?(t,n)=>e.updateCalendar(t,{name:n}):()=>{},onContextMenu:me?q:()=>{},editingId:j,setEditingId:S,activeContextMenuCalendarId:null==O?void 0:O.calendarId,isDraggable:he,isEditable:me}):r.jsxs(r.Fragment,{children:[r.jsx(Ae,{calendars:n,onToggleVisibility:i,onReorder:he?e.reorderCalendars:()=>{},onRename:me?(t,n)=>e.updateCalendar(t,{name:n}):()=>{},onContextMenu:me?q:()=>{},editingId:j,setEditingId:S,activeContextMenuCalendarId:null==O?void 0:O.calendarId,isDraggable:he,isEditable:me}),r.jsx("div",{className:"border-t border-gray-200 dark:border-slate-800",children:r.jsx(ht,{visibleMonth:e.getVisibleMonth(),currentDate:e.getCurrentDate(),showHeader:!0,onMonthChange:H,onDateSelect:t=>e.setCurrentDate(t)})})]}),O&&r.jsx(Me,{ref:M,x:O.x,y:O.y,onClose:X,className:"w-64 p-2",children:u?u(n.find(e=>e.id===O.calendarId),X):r.jsxs(r.Fragment,{children:[r.jsx(He,{children:b("calendarOptions")}),r.jsx(ft,{calendars:n,currentCalendarId:O.calendarId,onMergeSelect:te}),r.jsx(Ie,{onClick:J,children:b("delete")}),r.jsx(Ie,{onClick:ie,children:b("exportCalendar")||"Export Calendar"}),r.jsx(Re,{}),r.jsx(Pe,{selectedColor:null===(x=n.find(e=>e.id===O.calendarId))||void 0===x?void 0:x.colors.lineColor,onSelect:Q,onCustomColor:ee})]})}),L&&o.createPortal(r.jsxs(Me,{x:L.x,y:L.y,onClose:K,className:"w-max p-2",children:[r.jsx(Ie,{onClick:()=>{null==h||h(),K()},children:b("newCalendar")||"New Calendar"}),r.jsx(Ie,{onClick:oe,children:b("importCalendar")||"Import Calendar"}),r.jsx(Ie,{onClick:()=>{e.triggerRender(),K()},children:b("refreshAll")||"Refresh All"})]}),document.body),r.jsx("input",{ref:N,type:"file",accept:".ics",style:{display:"none"},onChange:se}),B&&o.createPortal(r.jsx(xt,{calendars:n,filename:B.filename,onConfirm:le,onCancel:()=>_(null)}),document.body),F&&o.createPortal(r.jsx(vt,{sourceName:de,targetName:ce,onConfirm:ne,onCancel:()=>W(null)}),document.body),Z&&o.createPortal(r.jsx(pt,{calendarId:Z.calendarId,calendarName:ue,calendars:n,step:Z.step,onStepChange:e=>U(t=>t?Object.assign(Object.assign({},t),{step:e}):null),onConfirmDelete:ae,onCancel:()=>U(null),onMergeSelect:re}),document.body),A&&o.createPortal(r.jsx("div",{className:"fixed inset-0 z-50",onMouseDown:()=>z(null),children:r.jsx("div",{className:"absolute flex items-center justify-center",style:{top:A.y,left:A.x,transform:"translate(-50%, -50%)"},onMouseDown:e=>e.stopPropagation(),children:"blossom"===f?r.jsx(s.BlossomColorPicker,{defaultValue:A.initialColor,coreSize:28,petalSize:28,initialExpanded:Y,openOnHover:!1,onChange:t=>{const{colors:n,darkColors:a}=D(t.hex);e.updateCalendar(A.calendarId,{colors:n,darkColors:a})},onCollapse:()=>z(null)}):r.jsx("div",{className:"rounded-md bg-white shadow-xl border border-gray-200 dark:bg-slate-800 dark:border-gray-700",children:r.jsx(l.SketchPicker,{width:"220px",color:A.currentColor,onChange:e=>{z(t=>t?Object.assign(Object.assign({},t),{currentColor:e.hex}):null)},onChangeComplete:t=>{const{colors:n,darkColors:a}=D(t.hex);e.updateCalendar(A.calendarId,{colors:n,darkColors:a})}})})})}),document.body)]})},Vt=({options:e,value:n,onChange:a,registry:s,variant:l="desktop"})=>{const[d,c]=t.useState(!1),[u,g]=t.useState({}),m=t.useRef(null),h=t.useRef(null),f=()=>{if(h.current){const e=h.current.getBoundingClientRect(),t="mobile"===l,n={position:"fixed",zIndex:10001,minWidth:t?"12rem":`${e.width}px`,top:`${e.bottom+4}px`};t?n.right=window.innerWidth-e.right+"px":n.left=`${e.left}px`,g(n)}};t.useEffect(()=>{const e=e=>{!m.current||m.current.contains(e.target)||e.target.closest("[data-calendar-picker-dropdown]")||c(!1)};return d&&(f(),window.addEventListener("mousedown",e),window.addEventListener("scroll",f,!0),window.addEventListener("resize",f)),()=>{window.removeEventListener("mousedown",e),window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)}},[d]);const v=e=>(s||b()).resolveColors(e).lineColor,p=(e,t)=>{e.stopPropagation(),a(t),c(!1)},y=e.find(e=>e.value===n),x=()=>d&&"undefined"!=typeof window?"mobile"===l?o.createPortal(r.jsx("div",{"data-calendar-picker-dropdown":"true",style:u,className:"bg-white dark:bg-gray-800 rounded-md shadow-lg border border-gray-200 dark:border-gray-700 overflow-hidden transition-all duration-200 origin-top-right animate-in fade-in zoom-in-95",children:e.map(e=>r.jsxs("div",{className:"flex items-center px-4 py-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700 "+(e.value===n?"bg-gray-50 dark:bg-gray-700/50":""),onClick:t=>p(t,e.value),children:[r.jsxs("div",{className:"flex items-center flex-1 min-w-0 mr-3",children:[r.jsx("div",{className:"w-5 flex justify-center mr-2",children:e.value===n&&r.jsx(i.Check,{className:"w-4 h-4 text-primary"})}),r.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-200 truncate",children:e.label})]}),r.jsx("span",{className:"w-3 h-3 rounded-full shrink-0",style:{backgroundColor:v(e.value)}})]},e.value))}),document.body):o.createPortal(r.jsx("ul",{"data-calendar-picker-dropdown":"true",style:u,className:"bg-white dark:bg-gray-700 rounded-md shadow-lg dark:shadow-gray-900/50 overflow-hidden border border-gray-200 dark:border-gray-600 transition-all duration-200 origin-top-left animate-in fade-in zoom-in-95",children:e.map(e=>r.jsxs("li",{className:"flex items-center px-2 py-1 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-600 transition-colors "+(n===e.value?"font-semibold":""),onClick:t=>p(t,e.value),children:[n===e.value?r.jsx("span",{className:"mr-2 text-sm text-primary",children:r.jsx(i.Check,{width:12,height:12})}):r.jsx("div",{className:"mr-2 text-sm w-3 h-3",children:" "}),r.jsx("span",{className:"w-3 h-3 mr-2 rounded-sm shrink-0",style:{backgroundColor:v(e.value)}}),r.jsx("span",{className:"text-sm whitespace-nowrap text-gray-700 dark:text-gray-200",children:e.label})]},e.value))}),document.body):null;return"mobile"===l?r.jsxs("div",{className:"relative inline-block",ref:m,children:[r.jsxs("button",{ref:h,onClick:e=>{e.stopPropagation(),c(!d)},className:"flex items-center space-x-2 bg-gray-100 dark:bg-gray-700 rounded-md px-3 py-1.5 transition-colors",children:[r.jsx("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:v(n)}}),r.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-200",children:(null==y?void 0:y.label)||n}),r.jsx(i.ChevronsUpDown,{className:"w-4 h-4 text-gray-400"})]}),x()]}):r.jsxs("div",{className:"relative inline-block",ref:m,children:[r.jsxs("button",{ref:h,type:"button",onClick:e=>{e.stopPropagation(),c(!d)},className:"flex items-center space-x-2 bg-gray-100 dark:bg-gray-700 rounded-md px-2 py-1 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors h-8",children:[r.jsx("span",{className:"w-4 h-4 rounded-sm shrink-0",style:{backgroundColor:v(n)}}),r.jsx(i.ChevronsUpDown,{className:"w-4 h-4 text-gray-600 dark:text-gray-300"})]}),x()]})},Ft=/(YYYY|YY|MM|DD|HH|mm)/g,Wt=e=>e.toString().padStart(2,"0"),Zt=(e,t)=>{const n=(null!=t?t:"").trim(),a=/[Hhms]/.test(e)||!n?e:`${e} ${n}`.trim();return a.replace(/(H{1,2}):MM/g,(e,t)=>`${t}:mm`)},Ut=e=>e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),Bt=e=>{let t,n=0,a="^";for(;null!==(t=Ft.exec(e));){a+=Ut(e.slice(n,t.index));const r=t[0];a+=`(?<${r}>\\d{${"YYYY"===r?4:2}})`,n=t.index+r.length}return a+=Ut(e.slice(n))+"$",new RegExp(a)},_t=(e,t,a,r)=>{const o=e.trim();if(!o)return null;const s=o.match(t),l=null==s?void 0:s.groups;if(!l)return null;const i=l.YYYY?Number(l.YYYY):l.YY?Number(l.YY)+2e3:a.year,d=l.MM?Number(l.MM):a.month,c=l.DD?Number(l.DD):a.day,u=l.HH?Number(l.HH):a.hour,g=l.mm?Number(l.mm):a.minute;try{return n.Temporal.ZonedDateTime.from({timeZone:r,year:i,month:d,day:c,hour:u,minute:g,second:a.second,millisecond:a.millisecond,microsecond:a.microsecond,nanosecond:a.nanosecond})}catch(e){return null}},qt=e=>{const t=e;if(t.timeZoneId&&"string"==typeof t.timeZoneId)return t.timeZoneId;if("timeZoneId"in e&&"string"==typeof e.timeZoneId)return e.timeZoneId;const a=e.timeZone;return a&&"string"==typeof a.id?a.id:"string"==typeof t.timeZone?t.timeZone:n.Temporal.Now.timeZoneId()},Gt=(e,t,a)=>{var r,o,s,l,i,d,c,u,g,m,h,f,v,p,y,x,b,D,w,C,E,k,T,j;if(!e){const e=null!=t?t:a?qt(a):n.Temporal.Now.timeZoneId();return null!=a?a:n.Temporal.Now.zonedDateTimeISO(e)}if(bt(e)){const a=null!=t?t:n.Temporal.Now.timeZoneId(),r=`${e.year}-${Wt(e.month)}-${Wt(e.day)}T00:00:00[${a}]`;return n.Temporal.ZonedDateTime.from(r)}if("hour"in e&&!("timeZone"in e)){const a=null!=t?t:n.Temporal.Now.timeZoneId();if("function"==typeof e.toZonedDateTime)try{return e.toZonedDateTime(a)}catch(e){}return n.Temporal.ZonedDateTime.from({timeZone:a,year:e.year,month:e.month,day:e.day,hour:e.hour,minute:e.minute,second:null!==(r=e.second)&&void 0!==r?r:0,millisecond:null!==(o=e.millisecond)&&void 0!==o?o:0,microsecond:null!==(s=e.microsecond)&&void 0!==s?s:0,nanosecond:null!==(l=e.nanosecond)&&void 0!==l?l:0})}try{return n.Temporal.ZonedDateTime.from(e)}catch(r){const o=e,s=null!==(g=null!==(u=null!==(c=null!==(d="string"==typeof(null==o?void 0:o.timeZone)?o.timeZone:null===(i=null==o?void 0:o.timeZone)||void 0===i?void 0:i.id)&&void 0!==d?d:null==o?void 0:o.timeZoneId)&&void 0!==c?c:t)&&void 0!==u?u:a?qt(a):void 0)&&void 0!==g?g:n.Temporal.Now.timeZoneId();if("function"==typeof(null==o?void 0:o.toZonedDateTime))try{return o.toZonedDateTime({timeZone:s})}catch(e){}const l=null!=a?a:n.Temporal.Now.zonedDateTimeISO(s);return n.Temporal.ZonedDateTime.from({timeZone:s,year:null!==(m=null==o?void 0:o.year)&&void 0!==m?m:l.year,month:null!==(h=null==o?void 0:o.month)&&void 0!==h?h:l.month,day:null!==(f=null==o?void 0:o.day)&&void 0!==f?f:l.day,hour:null!==(p=null!==(v=null==o?void 0:o.hour)&&void 0!==v?v:null==a?void 0:a.hour)&&void 0!==p?p:0,minute:null!==(x=null!==(y=null==o?void 0:o.minute)&&void 0!==y?y:null==a?void 0:a.minute)&&void 0!==x?x:0,second:null!==(D=null!==(b=null==o?void 0:o.second)&&void 0!==b?b:null==a?void 0:a.second)&&void 0!==D?D:0,millisecond:null!==(C=null!==(w=null==o?void 0:o.millisecond)&&void 0!==w?w:null==a?void 0:a.millisecond)&&void 0!==C?C:0,microsecond:null!==(k=null!==(E=null==o?void 0:o.microsecond)&&void 0!==E?E:null==a?void 0:a.microsecond)&&void 0!==k?k:0,nanosecond:null!==(j=null!==(T=null==o?void 0:o.nanosecond)&&void 0!==T?T:null==a?void 0:a.nanosecond)&&void 0!==j?j:0})}},Xt=(e,t,n)=>{const a=Zt(t,n),r={YYYY:e.year.toString(),YY:Wt(e.year%100),MM:Wt(e.month),DD:Wt(e.day),HH:Wt(e.hour),mm:Wt(e.minute)};return a.replace(Ft,e=>{var t;return null!==(t=r[e])&&void 0!==t?t:e})},Kt=Array.from({length:24},(e,t)=>t),Jt=Array.from({length:60},(e,t)=>t),Qt=({visibleMonth:e,monthLabels:t,disabled:n,onMonthChange:a,onYearChange:o})=>r.jsxs("div",{className:"flex items-center justify-between border-b border-slate-100 dark:border-gray-600 px-3 py-2 text-sm font-medium text-slate-700 dark:text-gray-300",children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("button",{type:"button",disabled:n,onClick:()=>o(-1),className:"rounded-md px-2 py-1 text-slate-400 dark:text-gray-400 transition hover:text-slate-600 dark:hover:text-gray-200 disabled:opacity-40",children:r.jsx(i.ChevronsLeft,{width:14,height:12})}),r.jsx("button",{type:"button",disabled:n,onClick:()=>a(-1),className:"rounded-md px-2 py-1 text-slate-400 dark:text-gray-400 transition hover:text-slate-600 dark:hover:text-gray-200 disabled:opacity-40",children:r.jsx(i.ChevronLeft,{width:14,height:12})})]}),r.jsxs("div",{className:"text-sm font-semibold text-slate-700 dark:text-gray-300",children:[t[e.month-1]," ",e.year]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("button",{type:"button",disabled:n,onClick:()=>a(1),className:"rounded-md px-2 py-1 text-slate-400 dark:text-gray-400 transition hover:text-slate-600 dark:hover:text-gray-200 disabled:opacity-40",children:r.jsx(i.ChevronRight,{width:14,height:12})}),r.jsx("button",{type:"button",disabled:n,onClick:()=>o(1),className:"rounded-md px-2 py-1 text-slate-400 dark:text-gray-400 transition hover:text-slate-600 dark:hover:text-gray-200 disabled:opacity-40",children:r.jsx(i.ChevronsRight,{width:14,height:12})})]})]}),en=(e,t)=>n.Temporal.PlainDate.compare(e,t),tn=({calendarDays:e,visibleMonth:t,startDate:n,endDate:a,weekDayLabels:o,disabled:s,onDaySelect:l})=>r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"grid grid-cols-7 gap-1 px-3 pb-3 pt-2 text-center text-[11px] uppercase tracking-wide text-slate-400 dark:text-gray-500",children:o.map((e,t)=>r.jsx("span",{children:e},t))}),r.jsx("div",{className:"grid grid-cols-7 gap-2 px-1 ",children:e.map(e=>{const o=e.month!==t.month,i=0===en(e,n),d=0===en(e,a),c=en(e,n)>=0&&en(e,a)<=0,u=i||d?"bg-primary text-primary-foreground font-semibold":c?"bg-primary/10 text-primary":o?"text-slate-300 dark:text-gray-600":"text-slate-700 dark:text-gray-300 hover:bg-primary/10 hover:text-primary";return r.jsx("button",{type:"button",disabled:s,onClick:()=>l(e),className:`flex h-9 w-9 items-center justify-center rounded-md text-sm transition ${u}`,children:e.day},e.toString())})})]}),nn=({focusedField:e,draftRange:t,disabled:n,onHourSelect:a,onMinuteSelect:o,timeListRefs:s})=>{const l=e,i=t["start"===l?0:1],d=i.minute,c=Jt.includes(d)?Jt:[...Jt,d].sort((e,t)=>e-t);return r.jsxs("div",{className:"flex flex-col rounded-xl border border-slate-200 dark:border-gray-600 bg-white dark:bg-gray-800 shadow-sm sm:w-28",children:[r.jsx("div",{className:"flex border-b border-slate-100 dark:border-gray-600 justify-center",children:r.jsxs("div",{className:"text-lg py-1 text-slate-700 dark:text-gray-300",children:[i.hour.toString().padStart(2,"0"),":",i.minute.toString().padStart(2,"0")]})}),r.jsxs("div",{className:"flex p-1",children:[r.jsx("div",{className:"w-14",children:r.jsx("div",{className:"h-72 overflow-y-auto rounded-md border border-slate-100 dark:border-gray-600 bg-white dark:bg-gray-700",role:"listbox","aria-label":"Hour",ref:e=>{s.current[l]&&(s.current[l].hour=e)},children:Kt.map(e=>{const t=e===i.hour;return r.jsx("button",{type:"button",role:"option","aria-selected":t,disabled:n,onClick:()=>a(l,e),className:"flex h-8 w-full items-center justify-center text-sm transition "+(t?"bg-primary text-primary-foreground font-semibold":"text-slate-600 dark:text-gray-300 hover:bg-primary/10 hover:text-primary"),"data-active":t?"true":void 0,children:Wt(e)},e)})})}),r.jsx("div",{className:"w-14",children:r.jsx("div",{className:"h-72 overflow-y-auto rounded-md border border-slate-100 dark:border-gray-600 bg-white dark:bg-gray-700",role:"listbox","aria-label":"Minute",ref:e=>{s.current[l]&&(s.current[l].minute=e)},children:c.map(e=>{const t=e===d;return r.jsx("button",{type:"button",role:"option","aria-selected":t,disabled:n,onClick:()=>o(l,e),className:"flex h-8 w-full items-center justify-center text-sm transition "+(t?"bg-primary text-primary-foreground font-semibold":"text-slate-600 dark:text-gray-300 hover:bg-primary/10 hover:text-primary"),"data-active":t?"true":void 0,children:Wt(e)},e)})})})]})]})},an=({visibleMonth:e,monthLabels:t,weekDayLabels:n,calendarDays:a,draftRange:o,focusedField:s,isTimeEnabled:l,disabled:i,matchTriggerWidth:d,popupRef:c,timeListRefs:u,onMonthChange:g,onYearChange:m,onDaySelect:h,onHourSelect:f,onMinuteSelect:v,onOk:p,getPopupStyle:y})=>{const x=o[0].toPlainDate(),b=o[1].toPlainDate();return r.jsx("div",{ref:c,style:y(),"data-range-picker-popup":"true",children:r.jsxs("div",{className:"space-y-3 rounded-xl border border-slate-200 dark:border-gray-600 bg-white dark:bg-gray-800 p-3",style:{boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",width:d?"100%":void 0},children:[r.jsxs("div",{className:"flex gap-1",children:[r.jsxs("div",{className:"flex-3 rounded-xl border border-slate-200 dark:border-gray-600 bg-white dark:bg-gray-800 shadow-sm w-full",children:[r.jsx(Qt,{visibleMonth:e,monthLabels:t,disabled:i,onMonthChange:g,onYearChange:m}),r.jsx(tn,{calendarDays:a,visibleMonth:e,startDate:x,endDate:b,weekDayLabels:n,disabled:i,onDaySelect:h})]}),l&&r.jsx("div",{className:"flex flex-1 justify-end sm:w-32",children:r.jsx(nn,{focusedField:s,draftRange:o,disabled:i,onHourSelect:f,onMinuteSelect:v,timeListRefs:u})})]}),r.jsx("div",{className:"flex justify-end",children:r.jsx("button",{type:"button",onClick:p,disabled:i,className:"inline-flex items-center rounded-full bg-primary px-4 py-1.5 text-sm font-semibold text-primary-foreground shadow-sm transition hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-50",children:"OK"})})]})})},rn=({value:e,format:a="YYYY-MM-DD HH:mm",showTimeFormat:s="HH:mm",showTime:l=!0,onChange:d,onOk:c,timeZone:u,disabled:g=!1,placement:m="bottomLeft",autoAdjustOverflow:h=!0,getPopupContainer:f,matchTriggerWidth:v=!1,locale:p="en-US"})=>{const y=t.useMemo(()=>"string"==typeof p?p:(null==p?void 0:p.code)||"en-US",[p]),x=t.useMemo(()=>void 0===l||("object"==typeof l||Boolean(l)),[l]),b=t.useMemo(()=>Te(y,"short"),[y]),D=t.useMemo(()=>ke(y,"narrow"),[y]),w=t.useMemo(()=>x?"object"==typeof l&&(null==l?void 0:l.format)?l.format:s:"",[x,l,s]),C=t.useMemo(()=>Zt(a,w),[a,w]),E=t.useMemo(()=>Bt(C),[C]),k=t.useMemo(()=>{const t=null!=u?u:O(e[0])?O(e[1])?n.Temporal.Now.timeZoneId():qt(e[1]):qt(e[0]),a=Gt(e[0],t);return[a,Gt(e[1],t,a)]},[e,u]),[T,j]=t.useState(k),S=t.useRef(k),[N,M]=t.useState("start"),[I,R]=t.useState([Xt(k[0],a,w),Xt(k[1],a,w)]),H=t.useRef([Xt(k[0],a,w),Xt(k[1],a,w)]),P=t.useRef(k),[L,$]=t.useState(k[0].toPlainDate().with({day:1})),[A,z]=t.useState(!1),Y=t.useCallback(e=>{z(e)},[]),[V,F]=t.useState(m),W=t.useRef(m),Z=t.useRef(null),U=t.useRef(null),B=t.useRef({start:{hour:null,minute:null},end:{hour:null,minute:null}}),_=t.useRef(!1);t.useEffect(()=>{H.current=I},[I]),t.useEffect(()=>{P.current=T},[T]),t.useEffect(()=>{const e=S.current,t=0!==n.Temporal.ZonedDateTime.compare(e[0],k[0]),a=0!==n.Temporal.ZonedDateTime.compare(e[1],k[1]);(t||a)&&j(k),S.current=k},[k]),t.useEffect(()=>{$(k[0].toPlainDate().with({day:1}))},[k[0]]);const q=t.useCallback((e,t,n=0)=>{var a;if(!e||!t)return;const r=e.getBoundingClientRect(),o=t.getBoundingClientRect().top-r.top+e.scrollTop-n,s=(null===(a=window.matchMedia)||void 0===a?void 0:a.call(window,"(prefers-reduced-motion: reduce)").matches)?"auto":"smooth";Math.abs(e.scrollTop-o)>1&&e.scrollTo({top:o,behavior:s})},[]),G=t.useCallback(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=B.current[e];["hour","minute"].forEach(e=>{const n=t[e];if(!n)return;const a=n.querySelector('[data-active="true"]');a&&q(n,a,0)})})})},[q]);t.useEffect(()=>{A&&x&&G(N)},[N,A,G,x]);const X=T[0].epochMilliseconds,K=T[0].offsetNanoseconds,J=T[1].epochMilliseconds,Q=T[1].offsetNanoseconds;t.useEffect(()=>{const[e,t]=P.current,n=Xt(e,a,w),r=Xt(t,a,w),[o,s]=H.current;o===n&&s===r||(H.current=[n,r],R([n,r]))},[X,K,J,Q,a,w]),t.useEffect(()=>{if(!A)return;const e=e=>{var t,n;const a=e.target;if(null===(t=Z.current)||void 0===t?void 0:t.contains(a))return;if(null===(n=U.current)||void 0===n?void 0:n.contains(a))return;a.closest("[data-range-picker-popup]")||Y(!1)},t=setTimeout(()=>{document.addEventListener("mousedown",e)},100);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[A]),t.useEffect(()=>{A||(M("start"),_.current||j(k),_.current=!1)},[A,k]);const ee=t.useCallback(e=>{d&&d(e,[Xt(e[0],a,w),Xt(e[1],a,w)])},[w,a,d]),te=t.useCallback(e=>{c&&c(e,[Xt(e[0],a,w),Xt(e[1],a,w)])},[w,a,c]),ne=t.useCallback((e,t)=>{j(a=>{const r=[...a];if("start"===e){const e=Gt(r[1],qt(t),t),a=n.Temporal.ZonedDateTime.compare(t,e)>0?t:e;return[t,a]}const o=Gt(r[0],qt(t),t);return[n.Temporal.ZonedDateTime.compare(o,t)>0?t:o,t]})},[]),ae=e=>{if(g)return;const t=(e,t)=>{var a,r,o,s;const l=qt(e);return n.Temporal.ZonedDateTime.from({timeZone:l,year:t.year,month:t.month,day:t.day,hour:e.hour,minute:e.minute,second:null!==(a=e.second)&&void 0!==a?a:0,millisecond:null!==(r=e.millisecond)&&void 0!==r?r:0,microsecond:null!==(o=e.microsecond)&&void 0!==o?o:0,nanosecond:null!==(s=e.nanosecond)&&void 0!==s?s:0})};if("start"===N){const n=t(T[0],e),a=T[1].epochMilliseconds-T[0].epochMilliseconds,r=n.add({milliseconds:a});return void j([n,r])}const a=t(T[1],e),r=T[1].epochMilliseconds-T[0].epochMilliseconds;if(n.Temporal.ZonedDateTime.compare(a,T[0])<0){const n=t(T[0],e),a=n.add({milliseconds:r});return void j([n,a])}const o=[T[0],a];j(o),$(a.toPlainDate().with({day:1}))},re=t.useCallback((e,t)=>{if(g)return;const a="start"===e?0:1;j(r=>{const o=r[a],s=o.with({hour:t,minute:o.minute,second:0,millisecond:0,microsecond:0,nanosecond:0});if("start"===e){const e=Gt(r[1],qt(s),s);return[s,n.Temporal.ZonedDateTime.compare(s,e)>0?s:e]}const l=Gt(r[0],qt(s),s);return[n.Temporal.ZonedDateTime.compare(l,s)>0?s:l,s]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=B.current[e].hour;if(!t)return;const n=t.querySelector('[data-active="true"]');n&&q(t,n,0)})})},[g]),oe=t.useCallback((e,t)=>{if(g)return;const a="start"===e?0:1;j(r=>{const o=r[a].with({minute:t,second:0,millisecond:0,microsecond:0,nanosecond:0});if("start"===e){const e=Gt(r[1],qt(o),o);return[o,n.Temporal.ZonedDateTime.compare(o,e)>0?o:e]}const s=Gt(r[0],qt(o),o);return[n.Temporal.ZonedDateTime.compare(s,o)>0?o:s,o]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=B.current[e].minute;if(!t)return;const n=t.querySelector('[data-active="true"]');n&&q(t,n,0)})})},[g]),se=t.useCallback((e,t)=>{const n="start"===e?0:1;R(e=>{const a=[...e];return a[n]=t,a})},[]),le=t.useCallback((e,t)=>{const n="start"===e?0:1,r=T[n],o=qt(r),s=_t(t,E,r,o);if(s){ne(e,s);const t=s.toPlainDate().with({day:1});return $(t),"start"===e&&M("end"),!0}return R(e=>{const t=[...e];return t[n]=Xt(T[n],a,w),t}),!1},[T,w,a,E,ne]),ie=t.useCallback(e=>t=>{se(e,t.target.value)},[se]),de=t.useCallback(e=>t=>{var n;if(g)return;if(A)return;const a=t.relatedTarget;a&&(null===(n=Z.current)||void 0===n?void 0:n.contains(a))||le(e,t.target.value)},[le,g,A]),ce=t.useCallback(e=>t=>{"Enter"===t.key&&(t.preventDefault(),le(e,t.currentTarget.value)),"Escape"===t.key&&t.currentTarget.blur()},[le]),ue=()=>{_.current=!0,ee(T),te(T),Y(!1)},ge=e=>{$(t=>t.add({months:e}).with({day:1}))},me=e=>{$(t=>t.add({years:e}).with({day:1}))},he=t.useMemo(()=>{const e=L,t=e.dayOfWeek%7,n=e.subtract({days:t});return Array.from({length:42},(e,t)=>n.add({days:t}))},[L]),fe=t.useCallback((e=m)=>{if(!h||!Z.current)return e;const t=Z.current.getBoundingClientRect(),n=v?t.width:480,a=window.innerHeight-t.bottom,r=t.top,o=window.innerWidth-t.left,s=t.right;let l=e;return l.startsWith("bottom")&&a<500&&r>a?l=l.replace("bottom","top"):l.startsWith("top")&&r<500&&a>r&&(l=l.replace("top","bottom")),l.endsWith("Left")&&o<n&&s>o?l=l.replace("Left","Right"):l.endsWith("Right")&&s<n&&o>s&&(l=l.replace("Right","Left")),l},[h,v,m]),ve=t.useCallback(()=>{const e=fe();W.current!==e&&(W.current=e,F(e))},[fe]),pe=e=>{if(g)return;M(e);const t=T["start"===e?0:1].toPlainDate().with({day:1});$(t);const n=fe();W.current!==n&&(W.current=n,F(n)),Y(!0)};t.useEffect(()=>{if(!A)return;ve();const e=()=>ve();return window.addEventListener("resize",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e,!0)}},[A,ve]);const ye=()=>{if(!Z.current)return{};const e=Z.current.getBoundingClientRect(),t=W.current,n={position:"fixed",zIndex:9999};return t.startsWith("bottom")?n.top=e.bottom+8:n.bottom=window.innerHeight-e.top+8,t.endsWith("Left")?n.left=e.left:n.right=window.innerWidth-e.right,v&&(n.width=`${e.width}px`),n};return r.jsxs("div",{className:"relative max-w-100",ref:Z,children:[r.jsxs("div",{className:"flex items-center gap-2 rounded-lg border text-sm shadow-sm transition "+(g?"cursor-not-allowed border-slate-200 dark:border-gray-600 bg-slate-50 dark:bg-gray-800 text-slate-400 dark:text-gray-500":A?"border-primary bg-white dark:bg-gray-700 shadow-md":"border-slate-200 dark:border-gray-600 bg-white dark:bg-gray-700"),children:[r.jsx("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:r.jsx("input",{type:"text",value:I[0],onChange:ie("start"),onFocus:()=>pe("start"),onClick:()=>pe("start"),onBlur:de("start"),onKeyDown:ce("start"),className:"w-full rounded-md border px-2 py-1.5 text-sm font-medium transition focus:outline-none focus:ring-2 "+(g?"cursor-not-allowed border-transparent bg-transparent text-slate-400 dark:text-gray-500":"start"===N&&A?" bg-white dark:bg-gray-700 text-primary":"border-transparent bg-transparent text-slate-700 dark:text-gray-300"),placeholder:C,autoComplete:"off",disabled:g})}),r.jsx(i.MoveRight,{className:"text-slate-400 dark:text-gray-500"}),r.jsx("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:r.jsx("input",{type:"text",value:I[1],onChange:ie("end"),onFocus:()=>pe("end"),onClick:()=>pe("end"),onBlur:de("end"),onKeyDown:ce("end"),className:"w-full rounded-md border px-2 py-1.5 text-sm font-medium transition focus:outline-none focus:ring-2 "+(g?"cursor-not-allowed border-transparent bg-transparent text-slate-400 dark:text-gray-500":"end"===N&&A?"bg-white dark:bg-gray-700 text-primary":"border-transparent bg-transparent text-slate-700 dark:text-gray-300"),placeholder:C,autoComplete:"off",disabled:g})})]}),A&&(f?o.createPortal(r.jsx(an,{visibleMonth:L,monthLabels:b,weekDayLabels:D,calendarDays:he,draftRange:T,focusedField:N,isTimeEnabled:!!x,disabled:g,matchTriggerWidth:v,popupRef:U,timeListRefs:B,onMonthChange:ge,onYearChange:me,onDaySelect:ae,onHourSelect:re,onMinuteSelect:oe,onOk:ue,getPopupStyle:ye}),f()):o.createPortal(r.jsx(an,{visibleMonth:L,monthLabels:b,weekDayLabels:D,calendarDays:he,draftRange:T,focusedField:N,isTimeEnabled:!!x,disabled:g,matchTriggerWidth:v,popupRef:U,timeListRefs:B,onMonthChange:ge,onYearChange:me,onDaySelect:ae,onHourSelect:re,onMinuteSelect:oe,onOk:ue,getPopupStyle:ye}),document.body))]})},on=({event:e,isOpen:a,isAllDay:s,onEventUpdate:l,onEventDelete:i,onClose:d,app:c})=>{var u;const[g,m]=t.useState(e),{t:h}=Ne();t.useEffect(()=>{m(e)},[e]);const f=t.useMemo(()=>(c?c.getCalendarRegistry():b()).getVisible().map(e=>({label:e.name,value:e.id})),[c,null==c?void 0:c.getCalendars()]),v=t.useMemo(()=>!pe(e,g),[e,g]),p=t.useMemo(()=>O(g.start)?g.end&&!O(g.end)&&(g.end.timeZoneId||g.end.timeZoneId)||n.Temporal.Now.timeZoneId():g.start.timeZoneId||g.start.timeZoneId||n.Temporal.Now.timeZoneId(),[g.end,g.start]),y=e=>{const[t,n]=e;m(Object.assign(Object.assign({},g),{start:t.toPlainDate(),end:n.toPlainDate()}))},x=!(null==c?void 0:c.state.readOnly),D=!1!==(null==c?void 0:c.getReadOnlyConfig().viewable);if(!a||!D)return null;if("undefined"==typeof window||"undefined"==typeof document)return null;const w=r.jsxs("div",{className:"fixed inset-0 flex items-center justify-center",style:{pointerEvents:"auto",zIndex:9998},"data-event-detail-dialog":"true",children:[r.jsx("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&&d()}}),r.jsxs("div",{className:"df-dialog-container relative bg-white dark:bg-gray-800 shadow-2xl border border-gray-200 dark:border-gray-700 rounded-lg p-6 max-w-md w-full mx-4",children:[r.jsx("button",{onClick:d,className:"absolute top-4 right-4 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-200 transition","aria-label":"Close",children:r.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),r.jsxs("div",{children:[r.jsx("span",{className:"block text-xs text-gray-600 dark:text-gray-300 mb-1",children:h("eventTitle")}),r.jsxs("div",{className:"flex items-center justify-between gap-3 mb-4",children:[r.jsx("div",{className:"flex-1",children:r.jsx("input",{type:"text",value:g.title,readOnly:!x,disabled:!x,onChange:e=>{m(Object.assign(Object.assign({},g),{title:e.target.value}))},className:"w-full border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-1.5 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary transition"})}),x&&r.jsx(Vt,{options:f,value:g.calendarId||"blue",onChange:e=>{m(Object.assign(Object.assign({},g),{calendarId:e}))},registry:null==c?void 0:c.getCalendarRegistry()})]}),g.allDay?r.jsxs("div",{className:"mb-4",children:[r.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-1",children:h("dateRange")}),r.jsx(rn,{value:[g.start,g.end],format:"YYYY-MM-DD",showTime:!1,timeZone:p,matchTriggerWidth:!0,disabled:!x,onChange:y,onOk:y,locale:null==c?void 0:c.state.locale})]}):r.jsxs("div",{className:"mb-4",children:[r.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-1",children:h("timeRange")}),r.jsx(rn,{value:[g.start,g.end],timeZone:p,disabled:!x,onChange:e=>{const[t,n]=e;m(Object.assign(Object.assign({},g),{start:t,end:n}))},onOk:e=>{const[t,n]=e;m(Object.assign(Object.assign({},g),{start:t,end:n}))},locale:null==c?void 0:c.state.locale})]}),r.jsxs("div",{className:"mb-4",children:[r.jsx("span",{className:"block text-xs text-gray-600 dark:text-gray-300 mb-1",children:h("note")}),r.jsx("textarea",{value:null!==(u=g.description)&&void 0!==u?u:"",readOnly:!x,disabled:!x,onChange:e=>m(Object.assign(Object.assign({},g),{description:e.target.value})),rows:4,className:"w-full border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary transition resize-none",placeholder:h("addNotePlaceholder")})]}),x&&r.jsxs("div",{className:"flex space-x-2",children:[g.allDay?r.jsx("button",{className:"px-3 py-2 bg-secondary/10 text-secondary rounded-lg hover:bg-secondary/20 text-sm font-medium transition",onClick:()=>{const e=O(g.start)?g.start:g.start.toPlainDate(),t=n.Temporal.ZonedDateTime.from({year:e.year,month:e.month,day:e.day,hour:9,minute:0,timeZone:n.Temporal.Now.timeZoneId()}),a=n.Temporal.ZonedDateTime.from({year:e.year,month:e.month,day:e.day,hour:10,minute:0,timeZone:n.Temporal.Now.timeZoneId()});m(Object.assign(Object.assign({},g),{allDay:!1,start:t,end:a}))},children:h("setAsTimed")}):r.jsx("button",{className:"px-3 py-2 bg-secondary/10 text-secondary rounded-lg hover:bg-secondary/20 text-sm font-medium transition",onClick:()=>{const e=O(g.start)?g.start:g.start.toPlainDate();m(Object.assign(Object.assign({},g),{allDay:!0,start:e,end:e}))},children:h("setAsAllDay")}),r.jsx("button",{className:"px-3 py-2 bg-destructive border border-border text-destructive-foreground rounded-lg hover:bg-destructive/90 text-sm font-medium transition",onClick:()=>{i(e.id),d()},children:h("delete")}),r.jsx("button",{className:"px-3 py-2 bg-primary text-primary-foreground rounded-lg text-sm font-medium transition ml-auto "+(v?"hover:bg-primary/90 shadow-lg shadow-primary/20":"opacity-50 cursor-not-allowed grayscale-[0.5]"),onClick:()=>{l(g),d()},disabled:!v,children:h("save")})]})]})]})]}),C=document.body;return C?o.createPortal(w,C):null},sn=({calendar:e,mode:n="buttons"})=>{const[a,o]=t.useState(!1),s=t.useRef(null),{t:l}=Ne(),d=Array.from(e.state.views.keys()),c=e.state.currentView;return d.length<=1?null:(t.useEffect(()=>{const e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)};if(a)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[a]),"select"===n?r.jsxs("div",{className:"relative inline-block",ref:s,children:[r.jsxs("button",{onClick:()=>o(!a),className:"flex items-center gap-2 px-3 mb-1 h-7 text-sm font-medium border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none focus:ring-1 focus:ring-primary focus:ring-offset-1 transition-all duration-200 shadow-sm min-w-30 justify-between","aria-expanded":a,"aria-haspopup":"listbox",children:[r.jsx("span",{className:"text-gray-900 dark:text-gray-100",children:l(c)}),r.jsx("span",{className:`${it} transition-transform duration-200 ${a?"rotate-180":""}`,children:r.jsx(i.ChevronDown,{width:16,height:16})})]}),a&&r.jsx("div",{className:"absolute top-full mt-1 left-0 z-50 w-full min-w-30 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-600 rounded-lg shadow-lg dark:shadow-gray-900/50 overflow-hidden animate-in",children:r.jsx("div",{className:"py-1",role:"listbox",children:d.map(t=>r.jsx("button",{onClick:()=>{e.changeView(t),o(!1)},className:"w-full text-left px-3 py-2 text-sm transition-colors duration-150 "+(c===t?"bg-primary/10 text-primary font-medium":"text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700"),role:"option","aria-selected":c===t,children:l(t)},t))})}),r.jsx("style",{children:"\n @keyframes slideIn {\n from {\n opacity: 0;\n transform: translateY(-4px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n .animate-in {\n animation: slideIn 0.15s ease-out;\n }\n "})]}):r.jsx("div",{className:"inline-flex items-center gap-1 p-0.5 mb-1 bg-gray-100 dark:bg-gray-800 rounded-lg",children:d.map(t=>r.jsx("button",{className:"px-4 h-6 text-sm font-medium rounded-md transition-all duration-200 "+(c===t?"bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-100 hover:bg-gray-50 dark:hover:bg-gray-700"),onClick:()=>e.changeView(t),children:l(t)},t))}))},ln=0,dn=1970,cn=2100,un=8,gn=100,mn=1200,hn=900,fn=700;class vn{static trackScrollEvent(e=0){this.metrics.scrollEvents++,this.metrics.totalScrollDistance+=Math.abs(e),this.metrics.avgScrollDelta=this.metrics.totalScrollDistance/this.metrics.scrollEvents}static trackRenderTime(e){this.metrics.renderTime.push(e),e>16.67&&this.metrics.frameDrops++,this.metrics.renderTime.length>100&&this.metrics.renderTime.shift()}static trackCacheHit(){this.metrics.cacheHits++}static trackCacheMiss(){this.metrics.cacheMisses++}static getMetrics(){const e=this.metrics.renderTime.length>0?this.metrics.renderTime.reduce((e,t)=>e+t,0)/this.metrics.renderTime.length:0,t=this.metrics.cacheHits+this.metrics.cacheMisses>0?this.metrics.cacheHits/(this.metrics.cacheHits+this.metrics.cacheMisses)*100:0,n=Date.now()-this.metrics.startTime,a=e>0?1e3/e:0;return{scrollEvents:this.metrics.scrollEvents,avgRenderTime:Math.round(100*e)/100,cacheHitRate:Math.round(100*t)/100,uptime:Math.round(n/1e3),scrollEventsPerSecond:Math.round(this.metrics.scrollEvents/(n/1e3)*100)/100,estimatedFPS:Math.round(a),frameDrops:this.metrics.frameDrops,avgScrollDelta:Math.round(100*this.metrics.avgScrollDelta)/100}}static reset(){this.metrics={scrollEvents:0,renderTime:[],cacheHits:0,cacheMisses:0,startTime:Date.now(),frameDrops:0,avgScrollDelta:0,totalScrollDistance:0}}}vn.metrics={scrollEvents:0,renderTime:[],cacheHits:0,cacheMisses:0,startTime:Date.now(),frameDrops:0,avgScrollDelta:0,totalScrollDistance:0};const pn=e=>{if(!e)return"";let t,a,r;e instanceof Date?(t=e.getFullYear(),a=e.getMonth()+1,r=e.getDate()):O(e)?(t=e.year,a=e.month,r=e.day):(!function(){n.Temporal.ZonedDateTime}(e),t=e.year,a=e.month,r=e.day);const o=String(a).padStart(2,"0");return`${String(r).padStart(2,"0")}/${o}/${t}`},yn=e=>{if("undefined"==typeof document)return e;const t=document.documentElement,n=[t.getAttribute("data-dayflow-theme-override"),t.getAttribute("data-theme-override"),t.getAttribute("data-theme")];for(const e of n)if("light"===e||"dark"===e)return e;return t.classList.contains("dark")?"dark":t.classList.contains("light")?"light":e};function xn(e,t=!1){if(e instanceof n.Temporal.PlainDate||e instanceof n.Temporal.PlainDateTime)return e;if(e instanceof Date)return t?Ct(e):Et(e);throw new Error("Invalid time type: "+typeof e)}function bn(e,t){if(e instanceof n.Temporal.ZonedDateTime)return e;if(e instanceof Date)return kt(e,t);throw new Error("Invalid time type: "+typeof e)}function Dn(e){var t;const n=xn(e.start,e.allDay),a=xn(e.end,e.allDay);return{id:e.id,title:e.title,description:e.description,start:n,end:a,allDay:null!==(t=e.allDay)&&void 0!==t&&t,calendarId:e.calendarId,meta:e.meta}}function wn(e){const t=bn(e.start,e.timeZone),n=bn(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 Cn=e=>{try{return e instanceof Date?e:"string"==typeof e?new Date(e):A(e)}catch(e){return new Date}},En=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},kn=(e,t,n,a)=>{const r=e.getTime()-t.getTime(),o=Math.round(r/864e5);let s="",l="text-gray-500 dark:text-gray-400";if(0===o)s=a("today")||"Today",l="text-primary";else if(1===o||2===o)try{const e=new Intl.RelativeTimeFormat(n,{numeric:"auto"}).format(o,"day");s=e.charAt(0).toUpperCase()+e.slice(1),l="text-black dark:text-white"}catch(t){s=e.toLocaleDateString(n,{weekday:"long"})}else s=e.toLocaleDateString(n,{year:"numeric",month:"long",day:"numeric",weekday:"long"});return{title:s,colorClass:l}},Tn=(e,t)=>{const n=new Map;e.forEach(e=>{var t;const a=Cn(e.start),r=En(a),o=r.getTime();n.has(o)||n.set(o,{date:r,events:[]}),null===(t=n.get(o))||void 0===t||t.events.push(e)});const a=t.getTime();n.has(a)||n.set(a,{date:t,events:[]});return Array.from(n.values()).sort((e,t)=>e.date.getTime()-t.date.getTime())};let jn=null;const Sn=()=>{const[e,n]=t.useState(()=>jn||{weekHeight:f,screenSize:"desktop",weeksPerView:6});return t.useEffect(()=>{const e=()=>{const e=window.innerWidth,t=window.innerHeight-150,a=Math.max(80,Math.floor(t/6)),r=e<768?{weekHeight:Math.max(m,a),screenSize:"mobile",weeksPerView:6}:e<1024?{weekHeight:Math.max(h,a),screenSize:"tablet",weeksPerView:6}:{weekHeight:Math.max(f,a),screenSize:"desktop",weeksPerView:6};jn&&jn.screenSize===r.screenSize&&jn.weekHeight===r.weekHeight&&jn.weeksPerView===r.weeksPerView||(jn=r,n(r))};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e},Nn=({currentDate:e,weekHeight:n,onCurrentMonthChange:a,initialWeeksToLoad:r=104,locale:o="en-US",isEnabled:s=!0})=>{const l=t.useRef(null),i=t.useCallback((e,t)=>{const n=new Date(t,e,1),a=o.startsWith("zh")||o.startsWith("ja");return n.toLocaleDateString(o,{month:a?"short":"long"})},[o]),d=t.useMemo(()=>{const t=new Date(e);return t.setDate(1),t.setHours(0,0,0,0),ue(t,r)},[e,r]),c=t.useMemo(()=>{const t=new Date(e);t.setDate(1),t.setHours(0,0,0,0);const a=d.findIndex(e=>e.days.some(e=>e.date.toDateString()===t.toDateString()));return a>0?a*n:0},[d,e,n]),[m,h]=t.useState(c),[f,p]=t.useState(600),[y,x]=t.useState(i(e.getMonth(),e.getFullYear())),[b,D]=t.useState(e.getFullYear()),[w,C]=t.useState(!1),[E,k]=t.useState(d),[T,j]=t.useState(!1),S=t.useRef(!1),[N,M]=t.useState(!1),I=t.useRef(e),R=t.useRef(null),H=t.useRef(null),O=t.useRef(new v),P=t.useRef(0),L=t.useRef(0),$=t.useRef(!1),A=t.useCallback(e=>{e&&(R.current=e)},[]),z=t.useCallback(e=>{let t=O.current.get(e);return console.log("weekData",t),t||(t=de(e),O.current.set(e,t)),t},[]),Y=t.useCallback((e,t=26)=>{$.current||($.current=!0,setTimeout(()=>{try{if("future"===e){const e=E[E.length-1],n=[];for(let a=1;a<=t;a++){const t=new Date(e.startDate);t.setDate(t.getDate()+7*a),n.push(z(t))}k(e=>[...e,...n])}else{const e=E[0],a=[];for(let n=t;n>=1;n--){const t=new Date(e.startDate);t.setDate(t.getDate()-7*n),a.push(z(t))}const r=a.length*n;k(e=>[...a,...e]),requestAnimationFrame(()=>{h(e=>e+r),R.current&&(R.current.scrollTop+=r)})}}finally{setTimeout(()=>{$.current=!1},200)}},0))},[E,z,n]),V=t.useMemo(()=>{const e=E.length*n,t=Math.floor(m/n);let a=Math.max(0,t);a=Math.min(a,Math.max(0,E.length-6));const r=Math.min(E.length-1,a+6-1),o=Math.max(0,a-15),s=Math.min(E.length-1,r+15),l=[];for(let e=o;e<=s;e++)l.push({index:e,weekData:E[e],top:e*n,height:n});return{totalHeight:e,visibleItems:l,displayStartIndex:a}},[m,f,n,E]),F=t.useCallback(e=>{if(T||w||0===e.length||!N)return;const t=m+f/2,n=e.find(e=>e.top<=t&&e.top+e.height>t)||e[Math.floor(e.length/2)];if(!n)return;const r={};n.weekData.days.forEach(e=>{const t=`${i(e.month,e.year)}-${e.year}`;r[t]=(r[t]||0)+1});let o="",s=0,d=0;Object.entries(r).forEach(([e,t])=>{if(t>d){d=t;const[n,a]=e.split("-");o=n,s=parseInt(a)}}),o&&s&&(l.current?o===l.current.month&&s===l.current.year&&(l.current=null,o===y&&s===b||(x(o),D(s),null==a||a(o,s))):o===y&&s===b||(x(o),D(s),null==a||a(o,s)))},[f,y,b,T,w,a,m,N]),W=t.useCallback(e=>{const t=performance.now();if(t-P.current<u)return;P.current=t;const a=e.currentTarget,r=a.scrollTop;L.current=r,h(r),T||requestAnimationFrame(()=>{const{scrollHeight:e,clientHeight:t}=a;r+t>e-10*n&&!$.current&&Y("future",26),r<10*n&&!$.current&&Y("past",26)}),C(!0),H.current&&clearTimeout(H.current),H.current=setTimeout(()=>{C(!1)},g)},[n,Y,T]),Z=t.useCallback((e,t=!0)=>{if(!R.current)return;j(!0),S.current=!0;const a=()=>{setTimeout(()=>{j(!1),S.current=!1},t?500:200)},r=E.findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(-1!==r){const e=r*n;return R.current.scrollTo({top:e,behavior:t?"smooth":"auto"}),void a()}const o=e.getDay(),s=0===o?6:o-1,l=new Date(e);l.setDate(e.getDate()-s),l.setHours(0,0,0,0);const i=E[0],d=E[E.length-1];let c=0,u=!1,g=!1;l<i.startDate?(c=Math.ceil((i.startDate.getTime()-l.getTime())/6048e5),u=!0):l>d.startDate&&(c=Math.ceil((l.getTime()-d.startDate.getTime())/6048e5),g=!0);const m=Math.min(c+10,52);if(u){const r=[];for(let e=m;e>=1;e--){const t=new Date(i.startDate);t.setDate(t.getDate()-7*e),r.push(z(t))}const o=r.length*n;k(e=>[...r,...e]),requestAnimationFrame(()=>{const s=[...r,...E].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(R.current&&-1!==s){const e=s*n;R.current.scrollTop+=o,h(e=>e+o),setTimeout(()=>{R.current&&R.current.scrollTo({top:e,behavior:t?"smooth":"auto"})},50)}a()})}else if(g){const r=[];for(let e=1;e<=m;e++){const t=new Date(d.startDate);t.setDate(t.getDate()+7*e),r.push(z(t))}k(e=>[...e,...r]),requestAnimationFrame(()=>{const o=[...E,...r].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(R.current&&-1!==o){const e=o*n;R.current.scrollTo({top:e,behavior:t?"smooth":"auto"})}a()})}else a()},[E,n,z]),U=t.useCallback(()=>{const e=E[V.displayStartIndex].days[0].date,t=new Date(e.getFullYear(),e.getMonth()-1,1);Z(t)},[V.displayStartIndex,E,Z]),B=t.useCallback(()=>{const e=E[V.displayStartIndex].days[0].date,t=new Date(e.getFullYear(),e.getMonth()+1,1);Z(t)},[V.displayStartIndex,E,Z]),_=t.useCallback(()=>{const e=new Date,t=i(e.getMonth(),e.getFullYear()),r=e.getFullYear(),o=new Date(r,e.getMonth(),1);l.current={month:t,year:r},x(t),D(r),null==a||a(t,r);const s=E.findIndex(e=>e.days.some(e=>e.date.toDateString()===o.toDateString()));if(-1!==s){const e=s*n,t=R.current;t&&(j(!0),S.current=!0,requestAnimationFrame(()=>{h(e),requestAnimationFrame(()=>{t&&(t.scrollTop=e,setTimeout(()=>{S.current=!1,j(!1)},200))})}))}else j(!0),S.current=!0,requestAnimationFrame(()=>{Z(o,!0),setTimeout(()=>{S.current=!1,j(!1)},200)})},[E,n,a,Z]);return t.useEffect(()=>{F(V.visibleItems)},[V.visibleItems,F]),t.useEffect(()=>{const t=I.current,n=t.getMonth(),r=t.getFullYear(),o=e.getMonth(),s=e.getFullYear();if(n!==o||r!==s){const e=new Date(s,o,1),t=i(o,s);l.current={month:t,year:s},x(t),D(s),null==a||a(t,s),Z(e,!0)}I.current=e},[e,a,Z]),t.useEffect(()=>{const e=R.current;if(!e)return;const t=new ResizeObserver(([e])=>{p(e.contentRect.height)});return t.observe(e),()=>t.disconnect()},[]),t.useEffect(()=>{const e=R.current;e&&!N&&s&&requestAnimationFrame(()=>{e&&c>0?(e.scrollTop=c,h(c),M(!0)):e&&M(!0)})},[N,c,s]),t.useEffect(()=>()=>{H.current&&clearTimeout(H.current)},[]),{scrollTop:m,containerHeight:f,currentMonth:y,currentYear:b,isScrolling:w,virtualData:V,scrollElementRef:R,handleScroll:W,scrollToDate:Z,handlePreviousMonth:U,handleNextMonth:B,handleToday:_,setScrollTop:h,setContainerHeight:p,setCurrentMonth:x,setCurrentYear:D,setIsScrolling:C,cache:O.current,scrollElementRefCallback:A,weeksData:E}},Mn=({calendar:e,switcherMode:t="buttons",onAddCalendar:n,onSearchChange:a,onSearchClick:o,searchValue:s="",isSearchOpen:l=!1,isEditable:d=!0})=>{const c="buttons"===t,u=e.state.currentView===exports.ViewType.DAY,{screenSize:g}=Sn(),m="mobile"===g,{t:h}=Ne();return r.jsxs("div",{className:"flex items-center justify-between px-2 pt-1 bg-white dark:bg-gray-900 transition-colors duration-200 shrink-0 border-b "+(u||l?"border-gray-200 dark:border-gray-700":"border-transparent"),children:[r.jsx("div",{className:"flex flex-1 items-center mb-1",children:n&&d&&r.jsx("button",{onClick:n,className:lt,title:m?h("newEvent")||"New Event":h("createCalendar")||"Add Calendar",children:r.jsx(i.Plus,{className:`h-4 w-4 ${it}`})})}),r.jsx("div",{className:"flex-1 flex justify-center",children:c&&r.jsx(sn,{mode:t,calendar:e})}),!c&&r.jsx(sn,{mode:t,calendar:e}),r.jsxs("div",{className:`flex ${"select"===t?"ml-2":"flex-1"} items-center justify-end gap-3 mb-1 pb-1 h-6`,children:[r.jsx("button",{onClick:o,className:`md:hidden ${lt}`,children:r.jsx(i.Search,{width:16,height:16})}),r.jsxs("div",{className:"relative hidden md:block group mt-1",children:[r.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:r.jsx("span",{className:"text-gray-400 group-focus-within:text-primary transition-colors",children:r.jsx(i.Search,{width:16,height:16})})}),r.jsx("input",{type:"text",placeholder:"Search",value:s,onChange:e=>{null==a||a(e.target.value)},className:"pl-9 pr-8 py-1 h-7 text-sm border border-slate-200 dark:border-gray-600 rounded-lg text-gray-900 dark:text-gray-100 placeholder-gray-500 dark:placeholder-gray-400 focus:outline-none focus:ring-1 focus:ring-primary focus:border-primary transition resize-none w-48"}),s&&r.jsx("button",{onClick:()=>{null==a||a("")},className:"absolute inset-y-0 right-0 pr-2 flex items-center text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]})]})},In=t.createContext(void 0),Rn=({children:e,initialTheme:n="light",onThemeChange:a})=>{const[o,s]=t.useState(n),[l,i]=t.useState("light"),d="auto"===o?l:o;t.useEffect(()=>{s(n)},[n]);const c=t.useCallback(e=>{s(e)},[]);t.useEffect(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-color-scheme: dark)"),t=e=>{const t=e.matches?"dark":"light";i(t)},n=e.matches?"dark":"light";return i(n),e.addEventListener?e.addEventListener("change",t):e.addListener&&e.addListener(t),()=>{e.removeEventListener?e.removeEventListener("change",t):e.removeListener&&e.removeListener(t)}},[]),t.useEffect(()=>{if("undefined"==typeof document)return;const e=document.documentElement,t=yn(d),n="auto"===o?t:d;e.classList.remove("light","dark"),e.classList.add(n),"auto"===o?e.removeAttribute("data-dayflow-theme-override"):e.setAttribute("data-dayflow-theme-override",n),e.setAttribute("data-theme",n)},[d,o,l]),t.useEffect(()=>{a&&a(o,d)},[o,d,a]);const u={theme:o,effectiveTheme:d,setTheme:c};return r.jsx(In.Provider,{value:u,children:e})},Hn=()=>{const e=t.useContext(In);if(void 0===e)throw new Error("useTheme must be used within a ThemeProvider");return e},On=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],Pn=({onClose:e,onCreate:n,colorPickerMode:a="default"})=>{const{t:i}=Ne(),{effectiveTheme:d}=Hn(),[c,u]=t.useState(""),[g,m]=t.useState(On[Math.floor(Math.random()*On.length)]),[h,f]=t.useState(!1),[v,p]=t.useState(""),y=t.useMemo(()=>{const e=s.DEFAULT_COLORS[Math.floor(Math.random()*s.DEFAULT_COLORS.length)],t=e.layer||"outer",n=s.lightnessToSliderValue(e.l);return{hue:e.h,saturation:n,lightness:e.l,alpha:100,layer:t}},[]),[x,b]=t.useState(null),w="dark"===d,C={default:{picker:{background:w?"#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:w?"1px solid #4b5563":"1px solid #e5e7eb"},head:{background:w?"#1e293b":"#ffffff",borderBottom:w?"1px solid #4b5563":"1px solid #e5e7eb",boxShadow:"none"},body:{background:w?"#1e293b":"#ffffff"},controls:{border:w?"1px solid #4b5563":"1px solid #e5e7eb"},input:{background:w?"#374151":"#ffffff",color:w?"#f3f4f6":"#1f2937",border:w?"1px solid #4b5563":"1px solid #e5e7eb",boxShadow:"none"},previews:{border:w?"1px solid #4b5563":"1px solid #e5e7eb"},actions:{borderTop:w?"1px solid #4b5563":"1px solid #e5e7eb"}}};return"undefined"==typeof window?null:o.createPortal(r.jsx("div",{className:"fixed inset-0 z-10000 flex items-center justify-center bg-black/50",children:r.jsxs("div",{className:"w-full max-w-sm rounded-lg p-6 shadow-xl bg-white dark:bg-slate-900 animate-in fade-in zoom-in-95",onClick:e=>e.stopPropagation(),children:[r.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white "+("blossom"===a?"mb-6":"mb-4"),children:i("createCalendar")}),r.jsxs("form",{onSubmit:t=>{var r;if(t.preventDefault(),!c.trim())return;let o;o="blossom"===a?null!==(r=null==x?void 0:x.hex)&&void 0!==r?r:s.hslToHex(y.hue,y.saturation,y.lightness):g;const{colors:l,darkColors:i}=D(o),d={id:ye(),name:c.trim(),colors:l,darkColors:i,isVisible:!0,isDefault:!1};n(d),e()},children:["blossom"===a?r.jsxs("div",{className:"mb-8 flex items-center gap-4",children:[r.jsx("div",{className:"flex-1",children:r.jsx("input",{type:"text",value:c,onChange:e=>u(e.target.value),className:"w-full rounded-lg border border-slate-200 px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100 dark:focus:border-primary dark:focus:ring-primary",placeholder:i("calendarNamePlaceholder"),autoFocus:!0})}),r.jsx("div",{className:"w-9 h-9 relative shrink-0",children:r.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:r.jsx(s.BlossomColorPicker,{defaultValue:y,coreSize:36,petalSize:32,openOnHover:!1,onChange:e=>b(e),onCollapse:e=>b(e),className:"z-50"})})})]}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"mb-4",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"h-9 w-9 rounded-md border border-gray-200 shadow-sm dark:border-gray-600",style:{backgroundColor:g}}),r.jsx("input",{type:"text",value:c,onChange:e=>u(e.target.value),className:"w-full flex-1 rounded-lg border border-slate-200 px-3 py-2 text-sm text-gray-900 shadow-sm transition focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100 dark:focus:border-primary dark:focus:ring-primary",placeholder:i("calendarNamePlaceholder"),autoFocus:!0})]})}),r.jsxs("div",{className:"mb-6",children:[r.jsx("div",{className:"grid grid-cols-7 gap-6",children:On.map(e=>r.jsx("button",{type:"button",className:"h-6 w-6 rounded-full border border-gray-200 focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 dark:border-gray-600 dark:focus:ring-offset-slate-800 "+(g===e?"ring-2 ring-primary ring-offset-2 dark:ring-offset-slate-800":""),style:{backgroundColor:e},onClick:()=>m(e)},e))}),r.jsxs("div",{className:"mt-2 relative",children:[r.jsx("button",{type:"button",onClick:()=>{p(g),f(!0)},className:"flex w-full cursor-pointer items-center rounded-sm px-2 py-1.5 text-sm text-slate-700 hover:bg-slate-100 dark:text-slate-200 dark:hover:bg-slate-800 transition-colors focus:outline-none focus:bg-slate-100 dark:focus:bg-slate-800",children:i("customColor")}),h&&r.jsx("div",{className:"absolute left-0 top-full z-10001 mt-2",children:r.jsx(l.PhotoshopPicker,{color:g,onChange:e=>{m(e.hex)},onAccept:()=>{f(!1)},onCancel:()=>{m(v),f(!1)},styles:C})})]})]})]}),r.jsxs("div",{className:"flex justify-end space-x-3",children:[r.jsx("button",{type:"button",onClick:e,className:Fe,children:i("cancel")}),r.jsx("button",{type:"submit",disabled:!c.trim(),className:"rounded-md bg-primary px-4 py-2 text-sm font-medium text-white hover:bg-primary/90 disabled:opacity-50",children:i("create")})]})]})]})}),document.body)},Ln=({loading:e,results:n,keyword:a,onResultClick:o,emptyText:s})=>{const{t:l,locale:d}=Ne(),c=t.useMemo(()=>En(new Date),[]),u=t.useMemo(()=>Tn(n,c),[n,c]),g=e=>Cn(e);return e?r.jsxs("div",{className:"flex flex-col items-center justify-center h-40 text-gray-500",children:[r.jsx(i.Loader2,{className:"w-8 h-8 animate-spin mb-2"}),r.jsx("span",{children:"Loading..."})]}):0===n.length?a?r.jsxs("div",{className:"flex flex-col items-center justify-center h-40 text-gray-500",children:[r.jsx($n,{}),r.jsx("span",{className:"mt-2 text-sm",children:"string"==typeof s?s:s&&"object"==typeof s?s[d]||s.en||"No results found":l("noResults")||"No results found"})]}):null:r.jsx("div",{className:"space-y-6",children:u.map(e=>{const{title:n,colorClass:a}=kn(e.date,c,d,l);return r.jsxs("div",{children:[r.jsx("h3",{className:`px-2 text-sm font-medium mb-4 sticky top-0 bg-white dark:bg-gray-900 py-1 z-10 ${a} border-b border-gray-200 dark:border-gray-700`,children:n}),r.jsx("div",{className:"flex flex-col",children:e.events.map(e=>{const n=g(e.start),a=g(e.end),s={hour:"2-digit",minute:"2-digit"},i=e.allDay?l("allDay")||"All Day":n.toLocaleTimeString(d,s),c=e.allDay?"":a.toLocaleTimeString(d,s);return r.jsxs(t.Fragment,{children:[r.jsx("div",{className:"p-2 mx-2 mb-1 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-800 cursor-pointer transition-colors group",onClick:()=>null==o?void 0:o(e),children:r.jsxs("div",{className:"flex items-stretch gap-3",children:[r.jsx("div",{className:"w-1 rounded-full shrink-0",style:{backgroundColor:e.color||"#3b82f6"}}),r.jsxs("div",{className:"flex-1 min-w-0 flex justify-between items-start",children:[r.jsx("div",{className:"font-medium text-black dark:text-white truncate pr-2 text-sm",children:e.title}),r.jsxs("div",{className:"text-xs flex flex-col items-end shrink-0 leading-tight",children:[r.jsx("div",{className:"text-black dark:text-white",children:i}),c&&r.jsx("div",{className:"text-gray-500 dark:text-gray-400",children:c})]})]})]})}),r.jsx("div",{className:"mx-2 border-b border-gray-200 dark:border-gray-700"})]},e.id)})})]},e.date.getTime())})})},$n=()=>r.jsx("svg",{className:"w-12 h-12 text-gray-300 dark:text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),An=({isOpen:e,onClose:t,loading:n,results:a,keyword:o,onResultClick:s,emptyText:l})=>r.jsx("div",{className:"hidden md:flex relative h-full bg-white dark:bg-gray-900 transition-all duration-300 ease-in-out flex-col border-l border-gray-200 dark:border-gray-700 overflow-hidden select-none "+(e?"w-64":"w-0 border-l-0"),children:r.jsx("div",{className:"flex-1 overflow-y-auto min-w-64",children:r.jsx(Ln,{loading:n,results:a,keyword:o,onResultClick:s,emptyText:l})})}),zn=({isOpen:e,onClose:n,keyword:a,onSearchChange:s,results:l,loading:d,onResultClick:c,emptyText:u})=>{const g=t.useRef(null),{t:m}=Ne();return t.useEffect(()=>(e?(setTimeout(()=>{var e;null===(e=g.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?o.createPortal(r.jsxs("div",{className:"fixed inset-0 z-9999 bg-white dark:bg-gray-900 flex flex-col",children:[r.jsxs("div",{className:"flex items-center p-2 border-b border-gray-200 dark:border-gray-700 gap-2",children:[r.jsx("button",{onClick:n,className:"p-2 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:r.jsx(i.ArrowLeft,{className:"w-6 h-6"})}),r.jsxs("div",{className:"flex-1 relative",children:[r.jsx("input",{ref:g,type:"text",placeholder:m("search")||"Search",value:a,onChange:e=>s(e.target.value),className:"w-full pl-3 pr-10 py-2 bg-gray-100 dark:bg-gray-800 border-none rounded-full text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-primary focus:outline-none"}),a&&r.jsx("button",{onClick:()=>s(""),className:"absolute inset-y-0 right-0 pr-3 flex items-center text-gray-400",children:r.jsx(i.X,{className:"w-4 h-4"})})]})]}),r.jsx("div",{className:"flex-1 overflow-y-auto p-2 select-none",children:r.jsx(Ln,{loading:d,results:l,keyword:a,onResultClick:e=>{null==c||c(e)},emptyText:u})})]}),document.body):null},Yn=({app:e,anchorRef:n,onClose:a,isOpen:s})=>{const{t:l}=Ne(),[i,d]=t.useState(""),[c,u]=t.useState(0),[g,m]=t.useState(!1),h=t.useRef(null),f=t.useRef(null);t.useEffect(()=>{s||m(!1)},[s]),t.useEffect(()=>{s&&(setTimeout(()=>{var e;return null===(e=h.current)||void 0===e?void 0:e.focus()},50),d(""),u(0))},[s]),t.useEffect(()=>{const e=e=>{s&&f.current&&!f.current.contains(e.target)&&n.current&&!n.current.contains(e.target)&&a()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[s,a,n]);const[v,p]=t.useState({top:0,left:0}),[y,x]=t.useState("top"),[b,D]=t.useState(0),w=t.useMemo(()=>{const e=new Date,t=new Date(e);t.setHours(t.getHours()+1,0,0,0);const n=new Date(t);return n.setHours(n.getHours()+1),{start:t,end:n}},[s]),C=t.useMemo(()=>{if(!i.trim())return[];const t=[],n=e.getCalendars(),a=e.getAllEvents(),r=i.toLowerCase(),o=a.find(e=>e.title.toLowerCase()===r);let s=null==o?void 0:o.calendarId;if(!s){const e=n.filter(e=>!1!==e.isVisible);if(e.length>0){const t=Math.floor(Math.random()*e.length);s=e[t].id}else n.length>0&&(s=n[0].id)}const l=n.find(e=>e.id===s),d=(null==l?void 0:l.colors.lineColor)||"#3b82f6";t.push({type:"new",title:i,calendarId:s||"",color:d,start:w.start,end:w.end});const c=new Set;c.add(i.toLowerCase());return a.filter(e=>e.title.toLowerCase().includes(r)&&!c.has(e.title.toLowerCase())).slice(0,5).forEach(e=>{c.add(e.title.toLowerCase());const a=n.find(t=>t.id===e.calendarId);t.push({type:"history",title:e.title,calendarId:e.calendarId||"",color:(null==a?void 0:a.colors.lineColor)||"#9ca3af",start:w.start,end:w.end})}),t},[i,e,w]);t.useLayoutEffect(()=>{if(s&&n.current&&f.current){const e=n.current.getBoundingClientRect(),t=f.current.offsetHeight,a=340;let r=e.left+e.width/2-a/2;const o=12,s=window.innerWidth;r<o?r=o:r+a>s-o&&(r=s-a-o);const l=e.left+e.width/2;D(l-r);let i=0,d="top";e.top<t+20?(d="bottom",i=e.bottom+12):(d="top",i=e.top-12-t),x(d),p({top:i,left:r}),m(!0)}},[s,n,C]);const E=t=>{if(!t.calendarId)return;const n=ye(),r={id:n,title:t.title,start:P(t.start),end:P(t.end),calendarId:t.calendarId,allDay:!1};e.addEvent(r),e.setCurrentDate(t.start),e.highlightEvent(n),a()};t.useEffect(()=>{if(!s)return;const e=e=>{"ArrowDown"===e.key?(e.preventDefault(),u(e=>(e+1)%C.length)):"ArrowUp"===e.key?(e.preventDefault(),u(e=>(e-1+C.length)%C.length)):"Enter"===e.key&&(e.preventDefault(),C[c]&&E(C[c]))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[s,C,c]);const k=(e,t)=>{const n=e=>e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1});return`${n(e)} - ${n(t)}`};return s?o.createPortal(r.jsxs("div",{ref:f,className:"fixed z-1000 w-85 flex flex-col bg-white dark:bg-slate-800 rounded-xl shadow-2xl border border-gray-200 dark:border-slate-700 "+(g?"animate-in fade-in zoom-in-95 duration-100":""),style:{top:v.top,left:v.left,visibility:g?"visible":"hidden"},children:[r.jsxs("div",{className:"p-4 pb-2",children:[r.jsx("div",{className:"mb-2 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:l("quickCreateEvent")||"Quick Create Event"}),r.jsx("div",{className:"relative",children:r.jsx("input",{ref:h,type:"text",className:"w-full border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-1.5 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary transition",placeholder:l("quickCreatePlaceholder")||"Enter title (e.g. Code review)",value:i,onChange:e=>d(e.target.value)})})]}),r.jsxs("div",{className:"flex-1 overflow-y-auto max-h-75 py-1 px-2",children:[0===C.length&&i&&r.jsx("div",{className:"px-4 py-3 text-sm text-gray-400 text-center",children:l("noSuggestions")||"Type to create"}),C.map((e,t)=>r.jsxs("div",{className:"flex items-center px-4 py-2 cursor-pointer transition-colors rounded-lg "+(t===c?"bg-primary/10 dark:bg-primary/20 ring-1 ring-inset ring-primary/20":"hover:bg-gray-50 dark:hover:bg-slate-700/50"),onClick:()=>E(e),onMouseEnter:()=>u(t),children:[r.jsx("div",{className:"w-1 h-8 rounded-full mr-3 shrink-0",style:{backgroundColor:e.color}}),r.jsxs("div",{className:"flex-1 min-w-0 flex flex-col gap-0.5",children:[r.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 truncate",children:e.title}),r.jsx("div",{className:"flex",children:r.jsx("span",{className:"font-semibold text-[10px] px-1 bg-gray-100 dark:bg-slate-700 rounded text-gray-500 dark:text-gray-400",children:"new"===e.type?l("today"):l("tomorrow")})}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:k(e.start,e.end)})]})]},`${e.type}-${t}`))]}),r.jsx("div",{className:"absolute w-3 h-3 bg-white dark:bg-slate-800 border-gray-200 dark:border-slate-700 rotate-45 -translate-x-1/2 "+("top"===y?"-bottom-1.5 border-b border-r":"-top-1.5 border-t border-l"),style:{left:b}})]}),document.body):null},Vn=({checked:e,onChange:t})=>r.jsx("div",{className:"w-12 h-7 flex items-center rounded-full p-1 cursor-pointer transition-colors "+(e?"bg-green-500":"bg-gray-300"),onClick:()=>t(!e),children:r.jsx("div",{className:"bg-white w-5 h-5 rounded-full shadow-md transform transition-transform "+(e?"translate-x-5":"")})}),Fn=({date:e,onChange:n})=>{const a=Array.from({length:24},(e,t)=>t),o=Array.from({length:12},(e,t)=>5*t),s=[...a,...a,...a],l=[...o,...o,...o],i=32,d=e.getHours(),c=5*Math.round(e.getMinutes()/5),u=(24+d)*i,g=(12+c/5)*i,[m,h]=t.useState(u),[f,v]=t.useState(g),p=t.useRef(null),y=t.useRef(null),x=t.useRef(null);t.useEffect(()=>{p.current&&(p.current.scrollTop=u,h(u)),y.current&&(y.current.scrollTop=g,v(g))},[u,g]);const b=(t,a)=>{const r=t.currentTarget;let o=r.scrollTop;if("hour"===a){const e=768;o<320?(o+=e,r.scrollTop=o):o>1600&&(o-=e,r.scrollTop=o),h(o)}else{const e=384;o<160?(o+=e,r.scrollTop=o):o>800&&(o-=e,r.scrollTop=o),v(o)}x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{((t,a)=>{const r=Math.round(a/i);if("hour"===t){const t=s[r];if(void 0!==t&&t!==e.getHours()){const a=new Date(e);a.setHours(t),n(a)}}else{const t=l[r];if(void 0!==t&&5*Math.round(e.getMinutes()/5)!==t){const a=new Date(e);a.setMinutes(t),n(a)}}})(a,o)},150)},D=(e,t)=>{const n=96+e*i+16-(t+112),a=Math.min(Math.abs(n)/112,1);return{transform:`perspective(500px) rotateX(${-(n/112*80)}deg) scale(${1-.4*a})`,opacity:1-.7*a,transition:"transform 0.1s ease-out, opacity 0.1s ease-out"}};return r.jsxs("div",{className:"flex h-56 overflow-hidden rounded-lg mt-2 relative ",children:[r.jsx("style",{dangerouslySetInnerHTML:{__html:"\n .no-scrollbar::-webkit-scrollbar { display: none; }\n .no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }\n "}}),r.jsxs("div",{ref:p,className:"flex-1 overflow-y-auto snap-y snap-mandatory no-scrollbar",style:{touchAction:"pan-y"},onScroll:e=>b(e,"hour"),children:[r.jsx("div",{style:{height:96}}),s.map((t,a)=>r.jsx("div",{className:"h-8 flex items-center justify-end pr-5 snap-center cursor-pointer",onClick:()=>{var r;const o=new Date(e);o.setHours(t),n(o),null===(r=p.current)||void 0===r||r.scrollTo({top:a*i,behavior:"smooth"})},children:r.jsx("div",{className:"w-10 text-center text-xl transition-colors duration-200 "+(t===d?"font-bold text-black dark:text-white":"text-gray-400 dark:text-gray-500"),style:D(a,m),children:t.toString().padStart(2,"0")})},a)),r.jsx("div",{style:{height:96}})]}),r.jsxs("div",{ref:y,className:"flex-1 overflow-y-auto snap-y snap-mandatory no-scrollbar",style:{touchAction:"pan-y"},onScroll:e=>b(e,"minute"),children:[r.jsx("div",{style:{height:96}}),l.map((t,a)=>r.jsx("div",{className:"h-8 flex items-center justify-start pl-5 snap-center cursor-pointer",onClick:()=>{var r;const o=new Date(e);o.setMinutes(t),n(o),null===(r=y.current)||void 0===r||r.scrollTo({top:a*i,behavior:"smooth"})},children:r.jsx("div",{className:"w-10 text-center text-xl transition-colors duration-200 "+(t===c?"font-bold text-black dark:text-white":"text-gray-400 dark:text-gray-500"),style:D(a,f),children:t.toString().padStart(2,"0")})},a)),r.jsx("div",{style:{height:96}})]}),r.jsx("div",{className:"absolute top-24 left-2 right-2 h-8 bg-gray-300/20 dark:bg-gray-500/20 pointer-events-none border border-gray-300 dark:border-gray-600 rounded-lg"})]})},Wn=({isOpen:e,onClose:n,onSave:a,draftEvent:s,app:l})=>{const{locale:i,t:d}=Ne(),[c,u]=t.useState(""),[g,m]=t.useState(""),[h,f]=t.useState(!1),[v,p]=t.useState(new Date),[y,x]=t.useState(new Date),[b,D]=t.useState(""),[w,C]=t.useState(new Date),[E,k]=t.useState(new Date),[T,j]=t.useState(null),[S,N]=t.useState(e),[M,I]=t.useState(!1),[R,H]=t.useState(!1);t.useEffect(()=>{if(!e){I(!0);const e=setTimeout(()=>{N(!1),I(!1)},300);return()=>clearTimeout(e)}N(!0),I(!1)},[e]),t.useEffect(()=>{if(e&&s){const e=l.getEvents().some(e=>e.id===s.id);H(e)}},[e,s,l]);const O=l.getCalendars(),L=O.map(e=>({label:e.name,value:e.id}));t.useEffect(()=>{if(e&&O.length>0){O.some(e=>e.id===g)||"blue"!==g&&""!==g||m(O[0].id)}},[O,e,g]),t.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]),t.useEffect(()=>{var t,n;if(e&&s){if(u(s.title||""),m(s.calendarId||(null===(t=O[0])||void 0===t?void 0:t.id)||"blue"),f(s.allDay||!1),s.start)try{const e=A(s.start);p(e),C(e)}catch(e){console.error("Failed to parse start date",e);const t=new Date;p(t),C(t)}if(s.end)try{const e=A(s.end);x(e),k(e)}catch(e){console.error("Failed to parse end date",e);const t=new Date;x(t),k(t)}}else if(e&&!s){m((null===(n=O[0])||void 0===n?void 0:n.id)||"blue");const e=new Date;e.setMinutes(0,0,0),p(e),C(e),x(new Date(e.getTime()+36e5)),k(e)}},[e,s]);const $=t.useMemo(()=>{if(!e||!s)return!1;let t=new Date(v),n=new Date(y);h&&(t.setHours(0,0,0,0),n.setHours(0,0,0,0));const a=Object.assign(Object.assign({},s),{title:c,calendarId:g,allDay:h,description:b,start:P(t),end:P(n)});return!pe(s,a)},[e,s,c,g,h,v,y,b]);if(!S)return null;const z=e=>{j(t=>t===e?null:e)},Y=e=>e.toLocaleDateString(i,{day:"numeric",month:"short",year:"numeric"}),V=(e,t)=>{if("start"===e){const e=new Date(t);e.setHours(v.getHours(),v.getMinutes());const n=e.getTime()-v.getTime();p(e);const a=new Date(y.getTime()+n);x(a)}else{const e=new Date(t);e.setHours(y.getHours(),y.getMinutes()),x(e)}},F=(e,t)=>{"start"===e?C(e=>{const n=new Date(e);return n.setMonth(e.getMonth()+t),n}):k(e=>{const n=new Date(e);return n.setMonth(e.getMonth()+t),n})};return o.createPortal(r.jsxs("div",{className:"fixed inset-0 z-10000 flex items-end pointer-events-none",children:[r.jsx("div",{className:"absolute inset-0 bg-black/30 pointer-events-auto transition-opacity duration-300 "+(M?"opacity-0":"opacity-100"),style:{touchAction:"none"},onClick:n}),r.jsxs("div",{className:"relative w-full bg-gray-100 dark:bg-gray-800 rounded-t-2xl shadow-xl h-[85vh] flex flex-col pointer-events-auto overflow-hidden "+(M?"animate-slide-down":"animate-slide-up"),onClick:e=>e.stopPropagation(),children:[r.jsxs("div",{className:"flex justify-between items-center p-4 bg-white dark:bg-gray-900 border-b border-gray-200 dark:border-gray-700",children:[r.jsx("button",{onClick:n,className:"text-gray-500 hover:text-gray-700 px-2 py-1",children:d("cancel")}),r.jsx("span",{className:"font-semibold text-lg",children:d(R?"editEvent":"newEvent")}),r.jsx("button",{onClick:()=>{if(!s)return;let e=new Date(v),t=new Date(y);h&&(e.setHours(0,0,0,0),t.setHours(0,0,0,0));const n=Object.assign(Object.assign({},s),{title:c,calendarId:g,allDay:h,start:P(e),end:P(t)});a(n)},disabled:!$,className:"font-bold px-2 py-1 transition-colors "+($?"text-primary":"text-gray-400 cursor-not-allowed opacity-50"),children:d(R?"done":"create")})]}),r.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[r.jsx("div",{className:"bg-white dark:bg-gray-900 rounded-lg px-4 py-3",children:r.jsx("input",{type:"text",placeholder:d("titlePlaceholder"),value:c,onChange:e=>u(e.target.value),className:"w-full bg-transparent text-xl font-medium placeholder-gray-400 focus:outline-none",autoFocus:!0})}),O.length>0&&r.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-lg px-4 py-3 flex justify-between items-center relative",children:[r.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:d("calendar")}),r.jsx(Vt,{options:L,value:g,onChange:m,registry:l.getCalendarRegistry(),variant:"mobile"})]}),r.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-lg px-4 py-3 flex justify-between items-center",children:[r.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:d("allDay")}),r.jsx(Vn,{checked:h,onChange:f})]}),r.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-lg overflow-hidden",children:[r.jsxs("div",{className:"flex justify-between items-center px-4 py-3 border-b border-gray-100 dark:border-gray-800 last:border-0",children:[r.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:d("starts")}),r.jsxs("div",{className:"flex space-x-2",children:[r.jsx("button",{className:"px-3 py-1 rounded-md transition-colors "+("start-date"===T?"bg-gray-200 dark:bg-gray-700 text-primary dark:text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300"),onClick:()=>z("start-date"),children:Y(v)}),!h&&r.jsx("button",{className:"px-3 py-1 rounded-md transition-colors "+("start-time"===T?"bg-gray-200 dark:bg-gray-700 text-primary dark:text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300"),onClick:()=>z("start-time"),children:ee(v.getHours()+v.getMinutes()/60)})]})]}),r.jsx("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("start-date"===T?"max-h-100":"max-h-0"),children:r.jsx("div",{className:"",children:r.jsx(ht,{currentDate:v,visibleMonth:w,onDateSelect:e=>V("start",e),onMonthChange:e=>F("start",e),showHeader:!0})})}),r.jsx("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("start-time"===T?"max-h-75":"max-h-0"),children:r.jsx("div",{className:"",children:r.jsx(Fn,{date:v,onChange:e=>{const t=y.getTime()-v.getTime();p(e),x(new Date(e.getTime()+t))}})})})]}),r.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-lg overflow-hidden",children:[r.jsxs("div",{className:"flex justify-between items-center px-4 py-3 border-b border-gray-100 dark:border-gray-800 last:border-0",children:[r.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:d("ends")}),r.jsxs("div",{className:"flex space-x-2",children:[r.jsx("button",{className:"px-3 py-1 rounded-md transition-colors "+("end-date"===T?"bg-gray-200 dark:bg-gray-700 text-primary dark:text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300"),onClick:()=>z("end-date"),children:Y(y)}),!h&&r.jsx("button",{className:"px-3 py-1 rounded-md transition-colors "+("end-time"===T?"bg-gray-200 dark:bg-gray-700 text-primary dark:text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300"),onClick:()=>z("end-time"),children:ee(y.getHours()+y.getMinutes()/60)})]})]}),r.jsx("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("end-date"===T?"max-h-100":"max-h-0"),children:r.jsx("div",{className:"",children:r.jsx(ht,{currentDate:y,visibleMonth:E,onDateSelect:e=>V("end",e),onMonthChange:e=>F("end",e),showHeader:!0})})}),r.jsx("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("end-time"===T?"max-h-75":"max-h-0"),children:r.jsx("div",{className:"",children:r.jsx(Fn,{date:y,onChange:e=>{if(e<v){const t=y.getTime()-v.getTime();x(e),p(new Date(e.getTime()-t))}else x(e)}})})})]}),r.jsx("div",{className:"bg-white dark:bg-gray-900 rounded-lg px-4 py-3",children:r.jsx("textarea",{placeholder:d("notesPlaceholder"),value:b,onChange:e=>D(e.target.value),className:"w-full bg-transparent text-base placeholder-gray-400 focus:outline-none min-h-20"})})]})]})]}),document.body)},Zn=({locale:e="en-US",messages:n,children:a})=>{const o=t.useMemo(()=>{if("string"==typeof e){return{code:H(e)?e:"en-US",messages:void 0}}return e&&!H(e.code)?Object.assign(Object.assign({},e),{code:"en-US"}):e||{code:"en-US"}},[e]),s=t.useMemo(()=>{const e=o.code;return{locale:e,t:(t,a)=>{var r,s,l;let i=null!==(l=null!==(r=null==n?void 0:n[t])&&void 0!==r?r:null===(s=o.messages)||void 0===s?void 0:s[t])&&void 0!==l?l:je(t,e);return a&&Object.entries(a).forEach(([e,t])=>{i=i.replace(new RegExp(`{${e}}`,"g"),t)}),i},getWeekDaysLabels:ke,getMonthLabels:Te,isDefault:!1}},[o,n]);return r.jsx(Se.Provider,{value:s,children:a})},Un=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],Bn=({locale:e,messages:t,children:n})=>Ne().isDefault?r.jsx(Zn,{locale:e,messages:t,children:n}):r.jsx(r.Fragment,{children:n}),_n=({calendar:e,className:n,style:o,customDetailPanelContent:s,customEventDetailDialog:l,meta:i,search:d})=>{var c,u;const g=e.app,m=g.getCurrentView(),h=m.component,f=g.getSidebarConfig(),v=null!==(c=null==f?void 0:f.enabled)&&void 0!==c&&c,[p,y]=t.useState(0),[x,b]=t.useState(null!==(u=null==f?void 0:f.initialCollapsed)&&void 0!==u&&u),{t:w}=Ne(),[E,k]=t.useState(!1),[T,j]=t.useState(null),[S,N]=t.useState(!1),M=t.useRef(null),[I,R]=t.useState(!1),[H,O]=t.useState(!1),[L,$]=t.useState(null),[z,Y]=t.useState(()=>g.getTheme()),[V,F]=t.useState(""),[W,Z]=t.useState(!1),[U,B]=t.useState(!1),[_,q]=t.useState(!1),[G,X]=t.useState([]);t.useEffect(()=>{const e=()=>{R(window.matchMedia("(max-width: 768px)").matches)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),t.useEffect(()=>{var e;if(!V.trim())return Z(!1),X([]),void g.highlightEvent(null);const t=null!==(e=null==d?void 0:d.debounceDelay)&&void 0!==e?e:300,n=setTimeout(()=>a.__awaiter(void 0,void 0,void 0,function*(){var e;q(!0),Z(!0);try{let t=[];if(null==d?void 0:d.customSearch){const e=g.getEvents().map(e=>{var t;return Object.assign(Object.assign({},e),{color:(null===(t=g.getCalendarRegistry().get(e.calendarId||""))||void 0===t?void 0:t.colors.lineColor)||g.getCalendarRegistry().resolveColors().lineColor})});t=d.customSearch({keyword:V,events:e})}else if(null==d?void 0:d.onSearch)t=yield d.onSearch(V);else{const e=V.toLowerCase();t=g.getEvents().filter(t=>t.title.toLowerCase().includes(e)||t.description&&t.description.toLowerCase().includes(e)).map(e=>{var t;return Object.assign(Object.assign({},e),{color:(null===(t=g.getCalendarRegistry().get(e.calendarId||""))||void 0===t?void 0:t.colors.lineColor)||g.getCalendarRegistry().resolveColors().lineColor})})}X(t),null===(e=null==d?void 0:d.onSearchStateChange)||void 0===e||e.call(d,{keyword:V,loading:!1,results:t})}catch(e){console.error("Search failed",e),X([])}finally{q(!1)}}),t);return()=>clearTimeout(n)},[V,d,g]),t.useEffect(()=>{W||g.highlightEvent(null)},[W,g]);const K=e=>{let t;t=e.start instanceof Date?e.start:"string"==typeof e.start?new Date(e.start):A(e.start),g.setCurrentDate(t),g.highlightEvent(e.id),U&&B(!1)};t.useEffect(()=>{var e;b(null!==(e=null==f?void 0:f.initialCollapsed)&&void 0!==e&&e)},[null==f?void 0:f.initialCollapsed]),t.useEffect(()=>{const e=g.subscribeThemeChange(e=>{Y(e)});return()=>{e()}},[g]);const J=t.useCallback(e=>{g.setTheme(e)},[g]),Q=t.useCallback(()=>{y(e=>e+1)},[]),ee=t.useMemo(()=>g.getCalendars(),[g,p,e]),te=t.useCallback((e,t)=>{g.setCalendarVisibility(e,t),Q()},[g,Q]),ne=t.useCallback(e=>{g.setAllCalendarsVisibility(e),Q()},[g,Q]),ae=t.useCallback(()=>{if("modal"===(f.createCalendarMode||"inline"))return void k(!0);const e=Un[Math.floor(Math.random()*Un.length)],{colors:t,darkColors:n}=D(e),a=ye(),r={id:a,name:w("untitled"),colors:t,darkColors:n,isVisible:!0,isDefault:!1};g.createCalendar(r),j(a),Q()},[g,f.createCalendarMode,w,Q]),re=t.useCallback(e=>{var t,n;if(!g.state.readOnly){if(I){const e=new Date;e.setMinutes(0,0,0),e.setHours(e.getHours()+1);const a=new Date(e);a.setHours(a.getHours()+1);const r={id:ye(),title:"",start:P(e),end:P(a),calendarId:(null===(t=g.getCalendars().find(e=>!1!==e.isVisible))||void 0===t?void 0:t.id)||(null===(n=g.getCalendars()[0])||void 0===n?void 0:n.id)};return $(r),void O(!0)}v?S?N(!1):(M.current=e.currentTarget,N(!0)):ae()}},[v,I,S,ae,g]),oe=t.useRef(null),se=l||(g.getUseEventDetailDialog()?on:void 0),le={app:g,config:m.config||{},customDetailPanelContent:s,customEventDetailDialog:se,switcherMode:g.state.switcherMode,calendarRef:oe,meta:i},ie={app:g,calendars:ee,toggleCalendarVisibility:te,toggleAll:ne,isCollapsed:x,setCollapsed:b,renderCalendarContextMenu:f.renderCalendarContextMenu,createCalendarMode:f.createCalendarMode,renderCreateCalendarDialog:f.renderCreateCalendarDialog,editingCalendarId:T,setEditingCalendarId:j,onCreateCalendar:ae,colorPickerMode:f.colorPickerMode},de=C(null==f?void 0:f.width,"240px"),ce=g.getCalendarHeaderConfig(),ue={calendar:g,switcherMode:g.state.switcherMode,onAddCalendar:re,onSearchChange:F,onSearchClick:()=>{F(""),B(!0)},searchValue:V,isSearchOpen:W,isEditable:!g.state.readOnly},ge=g.getCustomMobileEventRenderer()||Wn;return r.jsx(Rn,{initialTheme:z,onThemeChange:J,children:r.jsxs("div",{className:`calendar-container relative flex flex-row h-full overflow-hidden select-none ${null!=n?n:""}`,style:Object.assign({height:800},o),children:[v&&r.jsx("aside",{className:"absolute top-0 bottom-0 left-0 z-0 h-full",style:{width:de},children:v?f.render?f.render(ie):r.jsx(Yt,Object.assign({},ie)):null}),r.jsxs("div",{className:"flex flex-col flex-1 h-full overflow-hidden relative z-10 bg-white dark:bg-gray-900 transition-all duration-250 ease-in-out border-l "+(x?"border-gray-200 dark:border-gray-700 shadow-xl":"border-transparent"),style:{marginLeft:v?x?"50px":de:0},children:[!1===ce?null:"function"==typeof ce?ce(ue):r.jsx(Mn,Object.assign({},ue)),r.jsxs("div",{className:"flex-1 overflow-hidden relative",ref:oe,children:[r.jsxs("div",{className:"calendar-renderer h-full relative flex flex-row",children:[r.jsx("div",{className:"flex-1 h-full overflow-hidden",children:r.jsx(h,Object.assign({},le))}),r.jsx(An,{isOpen:W,onClose:()=>{Z(!1),F(""),g.highlightEvent(null)},loading:_,results:G,keyword:V,onResultClick:K,emptyText:null==d?void 0:d.emptyText})]}),r.jsx(zn,{isOpen:U,onClose:()=>{B(!1),F(""),g.highlightEvent(null)},keyword:V,onSearchChange:F,results:G,loading:_,onResultClick:K,emptyText:null==d?void 0:d.emptyText})]})]}),r.jsx(Yn,{app:g,anchorRef:M,isOpen:S,onClose:()=>N(!1)}),r.jsx(ge,{isOpen:H,onClose:()=>{O(!1),$(null)},onSave:e=>{g.addEvent(e),O(!1),$(null)},draftEvent:L,app:g}),E&&(f.renderCreateCalendarDialog?f.renderCreateCalendarDialog({onClose:()=>k(!1),onCreate:e=>{g.createCalendar(e),k(!1),Q()},colorPickerMode:f.colorPickerMode}):r.jsx(Pn,{onClose:()=>k(!1),onCreate:e=>{g.createCalendar(e),k(!1),Q()},colorPickerMode:f.colorPickerMode}))]})})},qn=({originalComponent:e,app:n,config:a,customDetailPanelContent:o,customEventDetailDialog:s,calendarRef:l,switcherMode:i,meta:d})=>{const c=n.getPlugin("events"),u=a.enableDrag?n.getPlugin("drag"):void 0,g=n.getCurrentDate(),m=n.state.currentView,h=n.getEvents(),f=t.useCallback(e=>{c?c.update(e.id,e):n.updateEvent(e.id,e)},[c,n]),v=t.useCallback(e=>{c?c.delete(e):n.deleteEvent(e)},[c,n]),p=t.useCallback(e=>{c?c.add(e):n.addEvent(e)},[c,n]),y=t.useCallback(e=>{n.setCurrentDate(e)},[n]),x=t.useCallback(e=>{n.changeView(e)},[n]),b=t.useMemo(()=>{const e=a.viewConfig||{};return u&&Object.assign(e,a.dragConfig||{}),c&&Object.assign(e,a.eventsConfig||{}),e},[a,u,c]),D=t.useMemo(()=>({app:n,currentDate:g,currentView:m,events:h,onEventUpdate:f,onEventDelete:v,onEventCreate:p,onDateChange:y,onViewChange:x,config:b}),[n,g,m,h,f,v,p,y,x,b]),w=t.useMemo(()=>{const e={currentDate:g,events:h,setEvents:e=>{h.forEach(e=>v(e.id)),e.forEach(e=>p(e))},updateEvent:f,deleteEvent:v,addEvent:p,goToPrevious:()=>{const e=new Date(g);switch(m){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)}y(e)},goToNext:()=>{const e=new Date(g);switch(m){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)}y(e)},goToToday:()=>{y(new Date)},changeView:x,selectDate:y};return Object.assign(Object.assign({calendar:e},D),{eventsService:c,dragService:u,customDetailPanelContent:o,customEventDetailDialog:s,calendarRef:l,switcherMode:i,meta:d})},[g,h,m,f,v,p,y,x,D,c,u,o,s,l,i,d]);return r.jsx(e,Object.assign({},w))};function Gn(e){return Object.assign(Object.assign({},e),{parentId:void 0,children:[],_startHour:e.allDay?0:U(e.start),_endHour:e.allDay?0:ae(e)})}function Xn(e){var t;return null!==(t=e._startHour)&&void 0!==t?t:U(e.start)}function Kn(e){var t;return null!==(t=e._endHour)&&void 0!==t?t:ae(e)}const Jn=.25,Qn=.5,ea=25,ta=1,na=.9;class aa{static getIndentStepPercent(e){return"day"===e?.5:2.5}static calculateDayEventLayouts(e,t={}){const n=e.map(Gn);this.clearAllParentChildRelations(n);const a=new Map,r=n.filter(e=>!e.allDay);if(0===r.length)return a;const o=this.groupOverlappingEvents(r);for(let e=0;e<o.length;e++){const n=o[e];1===n.length?this.setSingleEventLayout(n[0],a):this.calculateComplexGroupLayout(n,a,t)}return a}static clearAllParentChildRelations(e){for(const t of e)t.parentId=void 0,t.children=[]}static setParentChildRelation(e,t){t.parentId=e.id,e.children.includes(t.id)||e.children.push(t.id)}static eventsOverlap(e,t){return e.day===t.day&&!e.allDay&&!t.allDay&&(Xn(e)<Kn(t)&&Xn(t)<Kn(e))}static groupOverlappingEvents(e){const t=[],n=new Set;for(const a of e){if(n.has(a.id))continue;const r=[a],o=[a];for(n.add(a.id);o.length>0;){const t=o.shift();for(const a of e)n.has(a.id)||this.eventsOverlap(t,a)&&(r.push(a),o.push(a),n.add(a.id))}t.push(r)}return t}static setSingleEventLayout(e,t){t.set(e.id,{id:e.id,left:0,width:100-na,zIndex:0,level:0,isPrimary:!0,indentOffset:0,importance:1})}static calculateComplexGroupLayout(e,t,n={}){const a=[...e].sort((e,t)=>{const n=Xn(e),a=Xn(t);if(n!==a)return n-a;return Kn(t)-Xn(t)-(Kn(e)-Xn(e))}),r=this.analyzeParallelGroups(a),o=this.buildNestedStructure(r,e);this.calculateLayoutFromStructure(o,t,n)}static analyzeParallelGroups(e){const t=[],n=new Set;for(const a of e){if(n.has(a.id))continue;const r=[a];n.add(a.id);for(const t of e){if(n.has(t.id))continue;Math.abs(Xn(a)-Xn(t))<=Jn&&(r.push(t),n.add(t.id))}r.sort((e,t)=>Xn(e)-Xn(t));const o={events:r,startHour:Math.min(...r.map(e=>Xn(e))),endHour:Math.max(...r.map(e=>Kn(e)))};t.push(o)}return t.sort((e,t)=>e.startHour-t.startHour),t}static shouldBeParallel(e,t){if(!this.eventsOverlap(e,t))return!1;const n=Math.abs(Xn(e)-Xn(t));if(n<=Jn)return!0;if(n>Jn&&n<Qn)return!0;return!!this.checkExtendedEventParallel(e,t)}static checkExtendedEventParallel(e,t){return!!this.eventsOverlap(e,t)&&(!!this.isExtendedEventParallel(e,t)||!!this.isExtendedEventParallel(t,e))}static isExtendedEventParallel(e,t){const n=Kn(e)-Xn(e);if(n<1.25)return!1;const a=Xn(e)+.4*n,r=Xn(t)>=a,o=this.eventsOverlap(e,t);return r&&o}static buildNestedStructure(e,t){const n=[],a=new Map,r=new Map;t.forEach(e=>r.set(e.id,e));for(const t of e)for(const e of t.events){const t={event:r.get(e.id),children:[],parent:null,depth:0,isProcessed:!1};n.push(t),a.set(e.id,t)}for(let n=0;n<e.length;n++){const o=e[n],s=o.events.map(e=>r.get(e.id));let l=!1;for(let i=n-1;i>=0&&!l;i--){const n=e[i],d={events:n.events.map(e=>r.get(e.id)),startHour:n.startHour,endHour:n.endHour};if(this.canGroupContain(d,{events:s,startHour:o.startHour,endHour:o.endHour})){const e=this.optimizeChildAssignments(s,d,t);for(const t of e){const e=a.get(t.child.id),n=a.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}),this.rebalanceLoadByGroups(e,n),o}static findAlternateBranchRoot(e,t,n){const a=n.get(e.id);if(!a)return null;let r=a;for(;r.parent&&r.depth>1;)r=r.parent;if(1!==r.depth)return null;const o=r.parent;if(!o)return null;const s=o.children.filter(e=>1===e.depth&&e.event.id!==r.event.id);let l=1/0,i=null;for(const e of s){const t=this.calculateBranchLoad(e);t<l&&(l=t,i=e)}return i?i.event:null}static calculateBranchLoad(e){let t=0;function n(e){t++;for(const t of e.children)n(t)}for(const t of e.children)n(t);return t}static canGroupContain(e,t){const n=t.startHour-e.startHour;if(this.checkLoadBalanceParallel(e,t))return!1;if(n<Qn)return!1;let a=!1;for(const n of e.events){for(const e of t.events)if(this.canEventContain(n,e)){a=!0;break}if(a)break}return a}static checkLoadBalanceParallel(e,t){for(const n of e.events)for(const e of t.events){if(!this.eventsOverlap(n,e))continue;const t=Math.abs(Xn(e)-Xn(n));if(t<=Jn)return!0;if(t>Jn&&t<Qn)return!0}return!1}static canEventContain(e,t){const n=Xn(e)<=Xn(t)&&Kn(e)>=Kn(t),a=Xn(e)<=Xn(t)&&Xn(t)<Kn(e)&&this.eventsOverlap(e,t);return n||a}static optimizeChildAssignments(e,t,n){const a=[];if(1===e.length){const r=this.findBestParentInGroup(e[0],t,n);return r&&(a.push({child:e[0],parent:r}),this.setParentChildRelation(r,e[0])),a}if(1===t.events.length){const n=t.events[0];for(const t of e)this.canEventContain(n,t)&&(a.push({child:t,parent:n}),this.setParentChildRelation(n,t));return a}const r=t.events.filter(t=>e.every(e=>this.canEventContain(t,e)));if(0===r.length){for(const r of e){const o=this.findBestParentInGroup(r,t,n);if(o)a.push({child:r,parent:o}),this.setParentChildRelation(o,r);else{const t=e.find(e=>e.id!==r.id&&this.eventsOverlap(e,r));if(t){const e=this.buildTempNodeMap(n),o=this.findAlternateBranchRoot(t,Array.from(e.values()),e);o&&(a.push({child:r,parent:o}),this.setParentChildRelation(o,r))}}}return a}const o=[...e].sort((e,t)=>{const n=Kn(e)-Xn(e);return Kn(t)-Xn(t)-n});if(o.length%r.length===0){const e=o.length/r.length;for(let t=0;t<r.length;t++){const n=r[t],s=o.slice(t*e,(t+1)*e);for(const e of s)a.push({child:e,parent:n}),this.setParentChildRelation(n,e)}return a}for(let e=0;e<o.length;e++){const t=o[e],n=this.findParentWithMinLoadFromEvents(t,r,o);n&&(a.push({child:t,parent:n}),this.setParentChildRelation(n,t))}return a}static buildTempNodeMap(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),a=t.get(n.parentId);e&&a&&(e.parent=a,e.depth=a.depth+1,a.children.push(e))}return t}static findParentWithMinLoadFromEvents(e,t,n){if(0===t.length)return null;let a=1/0,r=[];for(const e of t){const t=e.children.length;t<a?(a=t,r=[e]):t===a&&r.push(e)}const o=r.map(e=>e.children).flat();return Kn(e)-Xn(e)>Math.max(...o.map(e=>{const t=n.find(t=>t.id===e);return t?Kn(t)-Xn(t):0}))?r[0]:r[r.length-1]}static findBestParentInGroup(e,t,n){const a=t.events.filter(t=>this.canEventContain(t,e));if(0===a.length)return null;if(1===a.length)return a[0];const r=a.map(e=>({parent:e,load:e.children.length,hasParallelSibling:!1}));for(const t of r)for(const a of t.parent.children){const r=n.find(e=>e.id===a);if(r&&this.shouldBeParallel(e,r)){t.hasParallelSibling=!0;break}}r.sort((t,n)=>{if(t.load!==n.load)return t.load-n.load;if(t.hasParallelSibling!==n.hasParallelSibling)return t.hasParallelSibling?-1:1;if(t.load!==n.load)return t.load-n.load;return Math.abs(Xn(e)-Xn(t.parent))-Math.abs(Xn(e)-Xn(n.parent))});return r[0].parent}static calculateLayoutFromStructure(e,t,n={}){const a=100-na;if(1===e.length)this.calculateNodeLayoutWithVirtualParallel(e[0],0,a,t,n);else{const r=e.length,o=(a-ta*(r-1))/r;e.forEach((e,a)=>{const r=a*(o+ta);this.calculateNodeLayoutWithVirtualParallel(e,r,Math.max(o,ea),t,n)})}}static calculateNodeLayoutWithVirtualParallel(e,t,n,a,r={}){let o=e.depth*this.getIndentStepPercent(r.viewType);if(e.isProcessed){const t=this.findBranchRootIndent(e,r.viewType);null!==t&&(o=t)}let s=0;const l="day"===r.viewType;1===e.depth?s=l?.5:1.5:2===e.depth?s=l?-.01:-1:e.depth>=3&&(s=l?.55:-3.5);const i=t+o+s;let d=n-(o+s);if(i+d>t+n&&(d=t+n-i),a.set(e.event.id,{id:e.event.id,left:i,width:d,zIndex:e.depth,level:e.depth,isPrimary:0===e.depth,indentOffset:o*(r.containerWidth||320)/100,importance:this.calculateEventImportance(e.event)}),0===e.children.length)return;const c=[...e.children].sort((e,t)=>{const n=Kn(e.event)-Xn(e.event);return Kn(t.event)-Xn(t.event)-n});if(1===c.length)this.calculateNodeLayoutWithVirtualParallel(c[0],i,d,a,r);else{this.shouldChildrenBeParallel(c.map(e=>e.event))?this.calculateParallelChildrenLayout(c,i,d,a,r):c.forEach(e=>{this.calculateNodeLayoutWithVirtualParallel(e,i,d,a,r)})}}static calculateParallelChildrenLayout(e,t,n,a,r={}){const o=e.length,s=e[0].depth,l=s*this.getIndentStepPercent(r.viewType);let i;const d="day"===r.viewType;i=1===s?d?.5:1.5:2===s?d?-.01:-1:d?.55:-3.5;const c=t+l+i,u=n-(l+i);if(u<=0)return void e.forEach(e=>{this.calculateNodeLayoutWithVirtualParallel(e,t,n,a,r)});let g;g=1===s?ta*(d?.15:.3):ta*(d?.1:.2);const m=(u-g*(o-1))/o;e.forEach((e,t)=>{const n=c+t*(m+g);if(a.set(e.event.id,{id:e.event.id,left:n,width:m,zIndex:e.depth,level:e.depth,isPrimary:0===e.depth,indentOffset:l*(r.containerWidth||320)/100,importance:this.calculateEventImportance(e.event)}),e.children.length>0){const t=[...e.children].sort((e,t)=>{const n=Kn(e.event)-Xn(e.event);return Kn(t.event)-Xn(t.event)-n});if(1===t.length)this.calculateNodeLayoutWithVirtualParallel(t[0],n,m,a,r);else{this.shouldChildrenBeParallel(t.map(e=>e.event))?this.calculateParallelChildrenLayout(t,n,m,a,r):t.forEach(e=>{this.calculateNodeLayoutWithVirtualParallel(e,n,m,a,r)})}}})}static findBranchRootIndent(e,t){let n=e;for(;n.parent&&n.parent.depth>0;)n=n.parent;if(1===n.depth){return n.depth*this.getIndentStepPercent(t)}return null}static shouldChildrenBeParallel(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(this.shouldBeParallel(e[t],e[n]))return!0;return!1}static calculateEventImportance(e){const t=Kn(e)-Xn(e);return Math.max(.1,Math.min(1,t/4))}static countDescendants(e){let t=0;for(const n of e.children)t+=1+this.countDescendants(n);return t}static findTransferableLeaf(e,t){const n=[];return this.collectLeaves(e,n),n.find(e=>this.canEventContain(t.event,e.event))||n[0]}static collectLeaves(e,t){0===e.children.length?t.push(e):e.children.forEach(e=>this.collectLeaves(e,t))}static transferNode(e,t){e.parent&&(e.parent.children=e.parent.children.filter(t=>t!==e));const n=t.children;let a=null;for(const t of n){if(this.shouldBeParallel(e.event,t.event))break;if(this.canEventContain(t.event,e.event)){a=t;break}}a?(e.parent=a,e.depth=a.depth+1,a.children.push(e),this.setParentChildRelation(a.event,e.event)):(e.parent=t,e.depth=t.depth+1,t.children.push(e),this.setParentChildRelation(t.event,e.event))}static calculateParentLoads(e,t){var n,a;const r=[],o=null===(a=null===(n=e[0])||void 0===n?void 0:n.parent)||void 0===a?void 0:a.depth;if(void 0===o)return r;const s=t.filter(e=>e.depth===o);for(const e of s){const t=this.countDescendants(e);r.push({node:e,load:t})}return r.sort((e,t)=>t.load-e.load),r}static needsRebalancing(e){if(e.length<2)return!1;return e[0].load-e[e.length-1].load>=2}static rebalanceGroupLoad(e){let t=0;for(;t<5;){e.sort((e,t)=>t.load-e.load);const n=e[0],a=e[e.length-1];if(n.load-a.load<2)break;const r=this.findTransferableLeaf(n.node,a.node);if(!r)break;this.transferNode(r,a.node),n.load--,a.load++,t++}}static rebalanceLoadByGroups(e,t){for(let n=e.length-1;n>=1;n--){const a=e[n].events.map(e=>t.find(t=>t.event.id===e.id)),r=this.calculateParentLoads(a,t);this.needsRebalancing(r)&&this.rebalanceGroupLoad(r)}}}const ra={HOUR_HEIGHT:72,FIRST_HOUR:0,LAST_HOUR:24,MIN_DURATION:.25,TIME_COLUMN_WIDTH:80,ALL_DAY_HEIGHT:28,getLineColor:e=>J(e),getDynamicPadding:e=>e.endHour-e.startHour<=.25?"px-1 py-0":"p-1"};const oa=e=>{const{viewType:n,onEventsUpdate:a}=e,r=n===exports.ViewType.MONTH,o=t.useRef({active:!1,mode:null,eventId:null,startX:0,startY:0,dayIndex:0,startHour:0,endHour:0,originalDay:0,originalStartHour:0,originalEndHour:0,resizeDirection:null,hourOffset:null,duration:0,lastRawMouseHour:null,lastUpdateTime:0,initialMouseY:0,lastClientY:0,allDay:!1,targetDate:null,originalDate:null,originalEvent:null,dragOffset:0,originalStartDate:null,originalEndDate:null,eventDate:void 0,originalStartTime:null,originalEndTime:null,sourceElement:null,indicatorVisible:!1}),s=t.useRef({x:0,y:0}),l=t.useMemo(()=>r?{active:!1,mode:null,eventId:null,targetDate:null,startDate:null,endDate:null}:{active:!1,mode:null,eventId:null,dayIndex:0,startHour:0,endHour:0,allDay:!1},[r]),[i,d]=t.useState(l),c=t.useMemo(()=>function(e,t){let n=null,a=0;const r=function(...r){const o=Date.now(),s=t-(o-a);s<=0||s>t?(n&&(clearTimeout(n),n=null),a=o,e.apply(this,r)):n||(n=setTimeout(()=>{a=Date.now(),n=null,e.apply(this,r)},s))};return r.cancel=()=>{n&&(clearTimeout(n),n=null),a=0},r}((e,t)=>a(e,"resize"===t),r?16:8),[r,a]),u=t.useCallback(()=>{d(r?{active:!1,mode:null,eventId:null,targetDate:null,startDate:null,endDate:null}:{active:!1,mode:null,eventId:null,dayIndex:0,startHour:0,endHour:0,allDay:!1}),o.current={active:!1,mode:null,eventId:null,startX:0,startY:0,dayIndex:0,startHour:0,endHour:0,originalDay:0,originalStartHour:0,originalEndHour:0,duration:0,resizeDirection:null,hourOffset:null,lastRawMouseHour:null,lastUpdateTime:0,initialMouseY:0,lastClientY:0,allDay:!1,targetDate:null,originalDate:null,originalEvent:null,dragOffset:0,originalStartDate:null,originalEndDate:null,eventDate:void 0,originalStartTime:null,originalEndTime:null,sourceElement:null,indicatorVisible:!1}},[r]);return{dragRef:o,currentDragRef:s,dragState:i,setDragState:d,resetDragState:u,throttledSetEvents:c}},sa={renderAllDayContent:({title:e,color:t})=>r.jsxs("div",{className:"h-full flex items-center overflow-hidden pl-3 pt-1",children:[r.jsx(i.CalendarDays,{className:"h-3 w-3 mr-1 text-white"}),r.jsx("div",{className:"font-medium text-xs truncate pr-1 text-white",children:e})]}),renderRegularContent:({drag:e,title:t,layout:n,formatTime:a,getLineColor:o,getDynamicPadding:s,color:l,isMobile:i})=>r.jsxs(r.Fragment,{children:[r.jsx("div",{className:Qe,style:{backgroundColor:o(l||"blue")}}),r.jsxs("div",{className:`h-full flex flex-col overflow-hidden pl-3 text-white ${s(e)}`,children:[r.jsx("div",{className:"font-medium text-xs truncate pr-1 text-white",style:{lineHeight:e.endHour-e.startHour<=.25?"1.2":"normal"},children:t}),!e.allDay&&e.endHour-e.startHour>.5&&r.jsxs("div",{className:"text-xs truncate time-display text-white opacity-90",children:[a(e.startHour)," - ",a(e.endHour)]})]}),i&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"absolute -top-1.5 right-5 w-2.5 h-2.5 bg-white border-2 rounded-full z-50",style:{borderColor:o(l||"blue")}}),r.jsx("div",{className:"absolute -bottom-1.5 left-5 w-2.5 h-2.5 bg-white border-2 rounded-full z-50",style:{borderColor:o(l||"blue")}})]})]}),renderDefaultContent:({drag:e,title:t,allDay:n})=>n?r.jsxs("div",{className:"h-full flex items-center overflow-hidden pl-3 px-1 py-0",children:[r.jsx("svg",{className:"h-3 w-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 002 2z"})}),r.jsx("div",{className:"font-medium text-xs truncate pr-1",style:{lineHeight:1.2},children:t})]}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"absolute left-0.5 top-1 bottom-1 w-0.5 rounded-full bg-primary"}),r.jsx("div",{className:"h-full flex flex-col overflow-hidden pl-3 p-1",children:r.jsx("div",{className:"font-medium text-xs truncate pr-1 text-primary",children:t})})]})},la=({drag:e,color:t,title:n,layout:a,allDay:o,formatTime:s,getLineColor:l,getDynamicPadding:i,renderer:d=sa,isMobile:c})=>{const{t:u}=Ne(),g=n||u(o?"newAllDayEvent":"newEvent");return r.jsx("div",{className:"drag-indicator-content",children:t?o?d.renderAllDayContent({drag:e,color:t,title:g,layout:a,allDay:o,formatTime:s,getLineColor:l,getDynamicPadding:i,isMobile:c}):d.renderRegularContent({drag:e,color:t,title:g,layout:a,allDay:o,formatTime:s,getLineColor:l,getDynamicPadding:i,isMobile:c}):d.renderDefaultContent({drag:e,color:t,title:g,layout:a,allDay:o,formatTime:s,getLineColor:l,getDynamicPadding:i,isMobile:c})})},ia=({event:e,isCreating:t,isMultiDay:n=!1,startDate:a,endDate:o})=>{const{t:s}=Ne(),l=(()=>{if(t)return{title:s("newEvent"),icon:r.jsx(i.Calendar,{className:"h-3 w-3"}),showDateRange:!1};if(n&&a&&o){const t=W(a,o)+1;return{title:e.title.replace(/ \(\d+天\)$/,""),showDateRange:!0,duration:t}}return{title:e.title,showDateRange:!1}})();return r.jsxs("div",{className:"flex items-center space-x-2 text-white text-xs font-medium rounded-sm",children:[r.jsx("div",{className:"shrink-0",children:l.icon}),r.jsx("div",{className:"flex-1 min-w-0",children:r.jsx("div",{className:"truncate font-medium",children:l.title})})]})},da=e=>{let t,n;return"touches"in e&&e.touches.length>0?(t=e.touches[0].clientX,n=e.touches[0].clientY):"changedTouches"in e&&e.changedTouches.length>0?(t=e.changedTouches[0].clientX,n=e.changedTouches[0].clientY):(t=e.clientX,n=e.clientY),{clientX:t,clientY:n}},ca=e=>{const n=t.useMemo(()=>Object.assign(Object.assign(Object.assign({},ra),e),{getLineColor:t=>{var n;return e.getLineColor?e.getLineColor(t):J(t,null===(n=e.app)||void 0===n?void 0:n.getCalendarRegistry())}}),[e]),{viewType:a}=n,r=a===exports.ViewType.MONTH||a===exports.ViewType.YEAR,o=(e=>{const{calendarRef:n,allDayRowRef:a,viewType:r,HOUR_HEIGHT:o=72,FIRST_HOUR:s=0,LAST_HOUR:l=24,TIME_COLUMN_WIDTH:i=80,isMobile:d}=e,c=r===exports.ViewType.MONTH,u=r===exports.ViewType.WEEK,g=t.useCallback(e=>{if(c||!n.current)return s;const t=n.current.querySelector(".calendar-content");if(!t)return s;const a=t.getBoundingClientRect(),r=t.scrollTop,i=window.getComputedStyle(t),d=parseInt(i.paddingTop,10)||0,u=(e-a.top+r-d)/o+s;return Math.max(s,Math.min(l,u))},[n,s,o,l,c]),m=t.useCallback(e=>{if(c||!n.current)return 0;const t=n.current.querySelector(".calendar-content");if(!t)return 0;const a=t.getBoundingClientRect(),r=t.scrollLeft,o=a.width;if(u){const t=(d?1.75*o:o)/7,n=e-a.left+r,s=Math.floor(n/t);return Math.max(0,Math.min(6,s))}return 0},[n,c,u,d]),h=t.useCallback(e=>{if(c||!n.current)return;const t=n.current.querySelector(".calendar-content");if(!t)return;const a=t.getBoundingClientRect();e<a.top?t.scrollTop+=e-a.top:e+40>a.bottom&&(t.scrollTop+=e+40-a.bottom)},[n,c]),f=t.useCallback(e=>!(c||!(null==a?void 0:a.current))&&e<=a.current.getBoundingClientRect().bottom,[a,c]),v=t.useMemo(()=>864e5,[]);return{pixelYToHour:g,getColumnDayIndex:m,checkIfInAllDayArea:f,handleDirectScroll:h,daysDifference:t.useCallback((e,t)=>W(e,t),[]),addDaysToDate:t.useCallback((e,t)=>Z(e,t),[]),getTargetDateFromPosition:t.useCallback((e,t)=>{if(r!==exports.ViewType.MONTH&&r!==exports.ViewType.YEAR||!n.current)return null;const a=document.elementFromPoint(e,t);if(!a)return null;let o=a,s=0;for(;o&&!o.hasAttribute("data-date")&&s<10;)o=o.parentElement,s++;if(o&&o.hasAttribute("data-date")){const e=o.getAttribute("data-date");if(e)return new Date(e+"T00:00:00")}return null},[n,r]),ONE_DAY_MS:v}})(n),s=oa(n),l=(e=>{const{t:n,locale:a}=Ne(),{calendarRef:r,allDayRowRef:o,viewType:s,getLineColor:l,getDynamicPadding:i,renderer:c,HOUR_HEIGHT:u=72,FIRST_HOUR:g=0,TIME_COLUMN_WIDTH:m=80,ALL_DAY_HEIGHT:h=60,app:f,isMobile:v}=e,p=s===exports.ViewType.MONTH||s===exports.ViewType.YEAR,y=s===exports.ViewType.DAY,x=t.useRef(null),b=t.useRef(null),D=t.useRef(null),w=t.useCallback(()=>{b.current&&(b.current.unmount(),b.current=null),x.current&&(x.current.remove(),x.current=null),D.current=null},[]),C=t.useCallback((e,s,C,E,k)=>{var T,j,S,N,M,I,R,H,O;w();const L=document.createElement("div");if(L.style.position=p?"fixed":"absolute",L.style.pointerEvents="none",L.style.zIndex="1000",p){let r,o;if(L.style.opacity="0.9",k){const t=k.getBoundingClientRect(),n=null!==(j=null!==(T=e.currentSegmentDays)&&void 0!==T?T:e.eventDurationDays)&&void 0!==j?j:1;r=t.width/n,o=t.height,L.className=`rounded-sm shadow-sm ${k.className}`}else r=120,o=22,L.className="rounded text-xs px-2 py-1";L.style.width=`${r}px`,L.style.height=`${o}px`,L.style.left=e.startX-r/2+"px",L.style.top=e.startY-o/2+"px",document.body.appendChild(L),b.current=d.createRoot(L);const l=P(new Date),i=e.originalEvent||{id:String(Date.now()),color:s||"blue",title:C||n("newEvent"),start:l,end:l,allDay:!1,day:0};b.current.render(t.createElement(Zn,{locale:a},t.createElement(ia,{event:i,isCreating:"create"===e.mode,targetDate:e.targetDate||null,startDate:e.originalStartDate||null,endDate:e.originalEndDate||null})))}else{if(k){const t=k.getBoundingClientRect();let n;if(n=e.allDay?null===(S=null==o?void 0:o.current)||void 0===S?void 0:S.getBoundingClientRect():null===(M=null===(N=r.current)||void 0===N?void 0:N.querySelector(".calendar-content"))||void 0===M?void 0:M.getBoundingClientRect(),n){if(e.allDay&&y)L.style.left=`${m}px`,L.style.top=k.offsetTop-2+"px",L.style.width=`calc(100% - ${m}px - 2px)`,L.style.height=`${t.height}px`;else if(e.allDay&&!y){const n=`calc(${v&&!y?"175%":"100%"} / 7)`;L.style.left=`calc(${n} * ${e.dayIndex})`,L.style.top=k.offsetTop-2+"px",L.style.width=`calc(${n} - 2px)`,L.style.height=`${t.height}px`}else{const a=(e.startHour-g)*u,o=null===(I=r.current)||void 0===I?void 0:I.querySelector(".calendar-content"),s=(null==o?void 0:o.scrollLeft)||0;L.style.left=`${t.left-n.left+s}px`,L.style.top=`${a+3}px`,L.style.width=`${t.width}px`,L.style.height=`${t.height}px`}L.className=k.className,L.style.opacity="0.8",L.style.boxShadow="0 4px 12px rgba(0, 0, 0, 0.15)"}}else if(e.allDay)if(L.style.top="2px",L.style.height=h-4+"px",L.style.marginBottom="3px",L.className="rounded-xl shadow-sm",y)L.style.left=`${m}px`,L.style.width=`calc(100% - ${m}px - 2px)`;else{const t=`calc(${v?"175%":"100%"} / 7)`;L.style.left=`calc(${t} * ${e.dayIndex})`,L.style.width=`calc(${t} - 2px)`}else{const t=(e.startHour-g)*u,n=(e.endHour-e.startHour)*u;if(L.style.top=`${t+3}px`,L.style.height=n-4+"px",L.style.color="#fff",L.className="rounded-sm shadow-sm",E){if(y)L.style.left=`${m}px`,L.style.width=`calc(((100% - ${m}px) * ${E.width/100}) - 3px)`;else{const t=`calc(${v&&!y?"175%":"100%"} / 7)`;L.style.left=`calc((${t} * ${e.dayIndex}) + (${t} * ${E.left/100}))`,L.style.width=`calc((${t} * ${(E.width-1)/100}))`}L.style.zIndex=String(1e3)}else{const t=y?`calc(100% - ${m}px)`:`calc(${v&&!y?"175%":"100%"} / 7)`;L.style.left=y?`${m}px`:`calc(${t} * ${e.dayIndex})`,L.style.width=`calc(${t} - 3px)`}}e.allDay?null===(R=null==o?void 0:o.current)||void 0===R||R.appendChild(L):null===(O=null===(H=r.current)||void 0===H?void 0:H.querySelector(".calendar-content"))||void 0===O||O.appendChild(L),D.current={drag:e,color:s,title:C,layout:E},b.current=d.createRoot(L),b.current.render(t.createElement(Zn,{locale:a},t.createElement(la,{drag:e,color:s,title:C,layout:E,allDay:e.allDay,formatTime:ee,getLineColor:l||(()=>""),getDynamicPadding:i||(()=>"0px"),renderer:c,isMobile:v})))}s?(L.style.backgroundColor=K(s,null==f?void 0:f.getCalendarRegistry()),L.style.color=X(s,null==f?void 0:f.getCalendarRegistry())):L.className+=" bg-primary/10 text-primary border border-dashed border-primary/50",x.current=L},[w,p,y,o,r,ee,l,i,c,m,h,g,u]),E=t.useCallback((...e)=>{var n,s;const d=x.current;if(d)if(p){const[t,n]=e,a=parseFloat(d.style.width)||120,r=parseFloat(d.style.height)||22;requestAnimationFrame(()=>{d.style.left=t-a/2+"px",d.style.top=n-r/2+"px",d.style.transition="none"})}else{const[f,p,x,w=!1,C]=e;if(w&&d.parentElement!==(null==o?void 0:o.current))null===(n=null==o?void 0:o.current)||void 0===n||n.appendChild(d);else if(!w){const e=null===(s=r.current)||void 0===s?void 0:s.querySelector(".calendar-content");d.parentElement!==e&&(null==e||e.appendChild(d))}if(w){if(y)d.style.left=`${m}px`,d.style.width=`calc(100% - ${m}px - 2px)`;else{const e=`calc(${v&&!y?"175%":"100%"} / 7)`;d.style.left=`calc(${e} * ${f})`,d.style.width=`calc(${e} - 2px)`,d.style.top="2px"}d.style.height=h-4+"px",d.style.marginBottom="3px",d.className=d.className.replace("rounded-sm","rounded-xl")}else{const e=(p-g)*u,t=(x-p)*u;d.style.top=`${e+3}px`,d.style.height=t-4+"px",d.style.marginBottom="0",d.className=d.className.replace("rounded-xl","rounded-sm");const n=v&&!y?"175%":"100%";if(C){if(y)d.style.left=`${m}px`,d.style.width=`calc(((100% - ${m}px) * ${C.width/100}) - 3px)`;else{const e=`calc(${n} / 7)`;d.style.left=`calc((${e} * ${f}) + (${e} * ${C.left/100}))`,d.style.width=`calc((${e} * ${(C.width-1)/100}))`}d.style.zIndex=String(C.zIndex+10)}else{const e=y?`calc(100% - ${m}px)`:`calc(${n} / 7)`;d.style.left=y?`${m}px`:`calc(${e} * ${f})`,d.style.width=`calc(${e} - 3px)`}}if(d.style.cursor="grabbing",b.current&&D.current){const e=Object.assign(Object.assign({},D.current.drag),{dayIndex:f,startHour:p,endHour:x,allDay:w});D.current.drag=e,b.current.render(t.createElement(Zn,{locale:a},t.createElement(la,{drag:e,color:D.current.color,title:D.current.title,layout:C||D.current.layout,allDay:w,formatTime:ee,getLineColor:l||(()=>""),getDynamicPadding:i||(()=>"0px"),renderer:c,isMobile:v})))}}},[p,o,ee,r,y,h,m,g,u,l,i,c]);return{dragIndicatorRef:x,reactRootRef:b,removeDragIndicator:w,createDragIndicator:C,updateDragIndicator:E}})(n),i=(e=>{const{t:n}=Ne(),{options:a,common:r,state:o,manager:s}=e,{viewType:l,onEventsUpdate:i,onEventCreate:d,onEventEdit:c,calculateNewEventLayout:u,calculateDragLayout:g,currentWeekStart:m,events:h,FIRST_HOUR:f=0,LAST_HOUR:v=24,MIN_DURATION:p=.25,app:y}=a,{dragRef:x,currentDragRef:b,setDragState:D,resetDragState:w,throttledSetEvents:C}=o,{removeDragIndicator:E,createDragIndicator:k,updateDragIndicator:T}=s,{pixelYToHour:j,getColumnDayIndex:S,checkIfInAllDayArea:N,handleDirectScroll:M,daysDifference:I,addDaysToDate:R,getTargetDateFromPosition:H}=r,O=l===exports.ViewType.MONTH||l===exports.ViewType.YEAR,$=l===exports.ViewType.DAY,z=864e5,Y=(e,t,n=!1)=>{const a=new Date(e);a.setHours(0,0,0,0);const r=new Date(t);r.setHours(0,0,0,0);let o=Math.floor((r.getTime()-a.getTime())/z);if(o<=0)return 0;if(!n&&1===o){const n=0===t.getHours()&&0===t.getMinutes()&&0===t.getSeconds()&&0===t.getMilliseconds(),a=t.getTime()-e.getTime();if(n&&a<z)return 0}return o},V=t.useCallback(e=>{var t,n;const a=null==y?void 0:y.getReadOnlyConfig(),r=!1!==(null==a?void 0:a.draggable),o=!(null==y?void 0:y.state.readOnly),s=x.current;if(!s)return;if("move"===s.mode&&!r)return;if(("resize"===s.mode||"create"===s.mode)&&!o)return;e.cancelable&&(e.preventDefault(),e.stopPropagation());const{clientX:l,clientY:i}=da(e);if(!s||!s.active)return;if("move"===s.mode&&!s.indicatorVisible){if(Math.hypot(l-s.startX,i-s.startY)<3)return;k(s,s.calendarId,s.title,null,s.sourceElement||void 0),s.indicatorVisible=!0}"resize"===s.mode?s.allDay?document.body.style.cursor="ew-resize":document.body.style.cursor="ns-resize":document.body.style.cursor="grabbing";const d=N(i),c=$?s.dayIndex:S(l);if(d){if(!s.allDay){s.allDay=!0,s.startHour=0,s.endHour=0,s.eventDate=m?me(m,c):new Date,E(),s.indicatorVisible=!1;const e=null==h?void 0:h.find(e=>e.id===s.eventId);k(s,null==e?void 0:e.calendarId,null==e?void 0:e.title),s.sourceElement=null,s.indicatorVisible=!0}s.dayIndex=c,D(e=>Object.assign(Object.assign({},e),{dayIndex:c,startHour:0,endHour:0,allDay:!0})),T(c,0,0,!0)}else{M(i);const e=j(i);if(null!==(t=s.startDragDayIndex)&&void 0!==t||s.originalDay,s.dayIndex,s.allDay){s.allDay=!1,s.startHour=ne(e),s.endHour=s.startHour+1,s.duration=1,s.hourOffset=0,s.eventDate=m?me(m,c):new Date,E(),s.indicatorVisible=!1;const t=null==h?void 0:h.find(e=>e.id===s.eventId);k(s,null==t?void 0:t.calendarId,null==t?void 0:t.title),s.sourceElement=null,s.indicatorVisible=!0}else{let t=ne(e+(null!==(n=s.hourOffset)&&void 0!==n?n:0));t=Math.max(f,Math.min(v-s.duration,t)),s.startHour=t,s.endHour=t+s.duration}s.dayIndex=c,s.eventDate=m?me(m,c):new Date,D(e=>Object.assign(Object.assign({},e),{dayIndex:c,startHour:ne(s.startHour),endHour:ne(s.endHour),allDay:!1}));let a=null;if("move"===s.mode&&s.eventId&&g){const e=null==h?void 0:h.find(e=>e.id===s.eventId);e&&(a=g(e,c,ne(s.startHour),ne(s.endHour)))}T(c,ne(s.startHour),ne(s.endHour),!1,a)}},[g,N,k,m,h,f,S,M,v,$,j,E,T,x,D]),F=t.useCallback(()=>{const e=x.current;if(!e||!e.active)return;const t=null==y?void 0:y.getReadOnlyConfig(),n=!1!==(null==t?void 0:t.draggable),a=!(null==y?void 0:y.state.readOnly);if("move"===e.mode&&!n)return;if(("resize"===e.mode||"create"===e.mode)&&!a)return;if(document.body.style.cursor="default","move"===e.mode&&!e.indicatorVisible)return document.removeEventListener("mousemove",V),document.removeEventListener("mouseup",F),document.removeEventListener("touchmove",V,{capture:!0}),document.removeEventListener("touchend",F),void w();if("move"!==e.mode||!e.eventId)return;let r=e.startHour,o=e.endHour;e.allDay||(r=ne(e.startHour),o=ne(e.endHour),o-r<p&&(o=r+p)),null==i||i(t=>t.map(t=>{var n,a;if(t.id!==e.eventId)return t;m?me(m,e.dayIndex):A(t.start);const s=null!==(n=e.startDragDayIndex)&&void 0!==n?n:e.originalDay,l=e.dayIndex-s;let i,d;if(e.allDay){const n=e.originalStartDate?new Date(e.originalStartDate):A(t.start);n.setHours(0,0,0,0);const a=new Date(n);a.setDate(a.getDate()+l);const r=new Date(a);e.eventDurationDays&&e.eventDurationDays>0&&r.setDate(r.getDate()+e.eventDurationDays),i=L(a),d=L(_(r))}else{const n=A(t.start),s=A(t.end),c=t.allDay;if(Y(n,s,null!==(a=t.allDay)&&void 0!==a&&a)>0&&!c){const e=new Date(n);e.setDate(e.getDate()+l);const t=new Date(s);t.setDate(t.getDate()+l),i=P(e),d=P(t)}else{const t=m?me(m,e.dayIndex):new Date,n=B(t,r),a=B(t,o);i=P(n),d=P(a)}}const c=e.originalDay+l;return Object.assign(Object.assign({},t),{day:c,start:i,end:d,allDay:e.allDay})})),document.removeEventListener("mousemove",V),document.removeEventListener("mouseup",F),document.removeEventListener("touchmove",V,{capture:!0}),document.removeEventListener("touchend",F),E(),w()},[V,E,w,i,p,m,x]),W=t.useCallback(e=>{var t,r,o,s,l,i,d,c,p,b;const D=x.current;if(!D||!D.active)return;const w=null==y?void 0:y.getReadOnlyConfig(),E=!1!==(null==w?void 0:w.draggable),N=!(null==y?void 0:y.state.readOnly);if("move"===D.mode&&!E)return;if(("resize"===D.mode||"create"===D.mode)&&!N)return;e.cancelable&&(e.preventDefault(),e.stopPropagation());const{clientX:z,clientY:V}=da(e);if(D&&D.active)if("resize"===D.mode?O||D.allDay?document.body.style.cursor="ew-resize":document.body.style.cursor="ns-resize":document.body.style.cursor="grabbing",O){if("resize"!==D.mode){if("move"===D.mode){const e=Math.hypot(z-D.startX,V-D.startY);!D.indicatorVisible&&e>=3&&(k(D,null===(t=D.originalEvent)||void 0===t?void 0:t.calendarId,null===(r=D.originalEvent)||void 0===r?void 0:r.title,null,D.sourceElement||void 0),D.indicatorVisible=!0)}D.indicatorVisible&&T(z,V)}const e=H(z,V);if(!e)return;if("resize"===D.mode&&D.originalEvent&&D.resizeDirection){const t=A(D.originalEvent.start);let n,a;const r=(e,t)=>{var n,a;e&&((null===(n=D.originalEvent)||void 0===n?void 0:n.allDay)?e.setHours(0,0,0,0):t&&e.setHours(t.hour,t.minute,null!==(a=t.second)&&void 0!==a?a:0,0))},o=D.originalStartTime,s=D.originalEndTime;if("left"===D.resizeDirection){n=new Date(e),r(n,o);const l=A(D.originalEvent.end)||t;a=new Date(l),r(a,s),n>a&&(n=a)}else{const l=A(D.originalEvent.start)||t;n=new Date(l),r(n,o),a=new Date(e),r(a,s),a<n&&(a=n)}D.originalStartDate=new Date(n.getTime()),D.originalEndDate=new Date(a.getTime());const l=D.originalEvent.allDay?L(n):P(n),i=D.originalEvent.allDay?L(a):P(a);C(e=>e.map(e=>e.id===D.eventId?Object.assign(Object.assign({},e),{start:l,end:i,title:e.title}):e),D.mode)}else if("move"===D.mode)if(D.originalStartDate&&D.originalEndDate){const t=new Date(D.originalStartDate);t.setHours(0,0,0,0);const n=I(t,e),a=R(D.originalStartDate,n),r=R(D.originalEndDate,n);(null===(o=D.originalStartDate)||void 0===o?void 0:o.getTime())!==a.getTime()&&(D.originalStartDate=new Date(a.getTime()),D.originalEndDate=new Date(r.getTime()),D.targetDate=a)}else(null===(s=D.targetDate)||void 0===s?void 0:s.getTime())!==e.getTime()&&(D.targetDate=e)}else{M(V),D.lastClientY=V;const e=j(V);if("create"===D.mode&&D.allDay){const e=Math.hypot(z-D.startX,V-D.startY);if(!D.indicatorVisible){if(e<3)return;k(D,"blue",n("newAllDayEvent")),D.indicatorVisible=!0}const t=$?D.dayIndex:S(z);return D.dayIndex=t,void T(t,0,0,!0)}if("resize"===D.mode)if(D.allDay){const e=$?D.dayIndex:S(z);let t=D.originalStartDate||new Date,n=D.originalEndDate||new Date;"left"===D.resizeDirection?(t=m?me(m,e):new Date,t>n&&(t=n)):"right"===D.resizeDirection&&(n=m?me(m,e):new Date,n<t&&(n=t)),D.originalStartDate=new Date(t.getTime()),D.originalEndDate=new Date(n.getTime());const a=L(t),r=L(n);C(e=>e.map(e=>e.id!==D.eventId?e:Object.assign(Object.assign({},e),{start:a,end:r,allDay:!0})),D.mode)}else{let t=D.startHour,n=D.endHour;const a=null==h?void 0:h.find(e=>e.id===D.eventId);let r=D.dayIndex;if(a){const e=A(a.start),t=A(a.end),n=Y(e,t,null!==(l=a.allDay)&&void 0!==l&&l);r=(null!==(i=a.day)&&void 0!==i?i:0)+n}let o=r,s=D.originalDay;if("top"===D.resizeDirection){const a=$?D.dayIndex:S(z),o=e+(null!==(d=null==D?void 0:D.hourOffset)&&void 0!==d?d:0);a<r?(s=a,t=Math.max(f,Math.min(v,o))):(s=r,o>D.originalEndHour?(t=D.originalEndHour,n=o,D.hourOffset=n-e):(t=Math.max(f,o),D.originalEndHour-t<Q&&(t=D.originalEndHour-Q)))}else if("bottom"===D.resizeDirection){const a=$?D.dayIndex:S(z),r=e+(null!==(c=null==D?void 0:D.hourOffset)&&void 0!==c?c:0);a!==D.dayIndex?(o=a,n=Math.max(f,Math.min(v,r))):r<D.originalStartHour?(n=D.originalStartHour,t=r,D.hourOffset=t-e):(n=Math.min(v,r),n-D.startHour<Q&&(n=D.startHour+Q))}else if("right"===D.resizeDirection){const e=$?D.dayIndex:S(z);o=Math.max(D.dayIndex,e)}o===s&&([t,n]=[Math.max(f,Math.min(t,n)),Math.min(v,Math.max(t,n))]);const[u,g]=[ne(t),ne(n)];D.startHour=t,D.endHour=n,D.dayIndex=s,C(e=>e.map(e=>{if(e.id!==D.eventId)return e;const t=A(e.start),n=B(m?me(m,s):t,u),a=m?me(m,o):t,r=B(a,g),l=P(n),i=P(r);return Object.assign(Object.assign({},e),{start:l,end:i,day:s})}),D.mode),T(D.dayIndex,u,g,!1)}else if("create"===D.mode){if(a.isMobile){const t=ne(e+(null!==(p=D.hourOffset)&&void 0!==p?p:0)),n=Math.max(f,Math.min(v-(D.duration||1),t));D.startHour=n,D.endHour=n+(D.duration||1)}else{const t=ne(e),[n,a]=V<D.startY?[t,Math.max(t+Q,D.endHour)]:[D.startHour,Math.max(D.startHour+Q,t)];D.startHour=n,D.endHour=a}const t=null==u?void 0:u(D.dayIndex,D.startHour,D.endHour);T(D.dayIndex,D.startHour,D.endHour,!1,t)}else if("move"===D.mode){const t=$?D.dayIndex:S(z);let n=ne(e+(null!==(b=D.hourOffset)&&void 0!==b?b:0));n=Math.max(f,Math.min(v-D.duration,n));const a=n+D.duration;D.dayIndex=t,D.startHour=n,D.endHour=a;let r=null;if(D.eventId&&g){const e=null==h?void 0:h.find(e=>e.id===D.eventId);e&&(r=g(e,t,ne(n),ne(a)))}T(t,ne(n),ne(a),!1,r)}}},[O,$,T,H,C,I,R,f,v,u,S,j,M,g,h,x,k]),Z=t.useCallback(e=>{var t,a,r;const o=x.current;if(!o||!o.active)return;const s=null==y?void 0:y.getReadOnlyConfig(),l=!1!==(null==s?void 0:s.draggable),c=!(null==y?void 0:y.state.readOnly);if("move"===o.mode&&!l)return;if(("resize"===o.mode||"create"===o.mode)&&!c)return;if(document.body.style.cursor="default",("move"===o.mode||"create"===o.mode)&&!o.indicatorVisible)return document.removeEventListener("mousemove",W),document.removeEventListener("mouseup",Z),document.removeEventListener("touchmove",W,{capture:!0}),document.removeEventListener("touchend",Z),void w();const{clientX:u,clientY:g}=da(e);if(o&&o.active){if(O){if("resize"===o.mode&&o.eventId&&o.originalStartDate&&o.originalEndDate){D(e=>"targetDate"in e?Object.assign(Object.assign({},e),{targetDate:o.originalStartDate,startDate:o.originalStartDate,endDate:o.originalEndDate}):e);const e=(null===(t=o.originalEvent)||void 0===t?void 0:t.allDay)||!1,n=e?L(o.originalStartDate):P(o.originalStartDate),a=e?L(o.originalEndDate):P(o.originalEndDate);C(e=>e.map(e=>e.id===o.eventId?Object.assign(Object.assign({},e),{start:n,end:a,title:e.title}):e))}else if("move"===o.mode)if(o.eventId&&o.originalStartDate&&o.originalEndDate){const e=(null===(a=o.originalEvent)||void 0===a?void 0:a.start)?A(o.originalEvent.start):null;if(e&&e.getTime()!==o.originalStartDate.getTime()){D(e=>"targetDate"in e?Object.assign(Object.assign({},e),{targetDate:o.originalStartDate,startDate:o.originalStartDate,endDate:o.originalEndDate}):e);const e=(null===(r=o.originalEvent)||void 0===r?void 0:r.allDay)||!1,t=e?L(o.originalStartDate):P(o.originalStartDate),n=e?L(o.originalEndDate):P(o.originalEndDate);C(e=>e.map(e=>e.id===o.eventId?Object.assign(Object.assign({},e),{start:t,end:n,title:e.title}):e))}}else{const e=H(u,g)||o.targetDate;o.eventId&&e&&(D(t=>"targetDate"in t?Object.assign(Object.assign({},t),{targetDate:e}):t),C(t=>t.map(t=>{if(t.id!==o.eventId)return t;const n=A(t.start),a=A(t.end),r=new Date(e);r.setHours(n.getHours(),n.getMinutes(),0,0);const s=new Date(e);s.setHours(a.getHours(),a.getMinutes(),0,0);const l=t.allDay?L(r):P(r),i=t.allDay?L(s):P(s);return Object.assign(Object.assign({},t),{start:l,end:i})})))}}else{let[e,t]=[ne(o.startHour),ne(o.endHour)];if(t-e<p&&("top"===o.resizeDirection?e=t-p:t=e+p),"create"===o.mode){const a=m?me(m,o.dayIndex):new Date;D(n=>"dayIndex"in n?Object.assign(Object.assign({},n),{dayIndex:o.dayIndex,startHour:e,endHour:t}):n);const r=B(a,e),s=B(a,t),l=o.allDay,i=l?L(r):P(r),c=l?L(s):P(s);null==d||d({id:String(Date.now()),title:n(l?"newAllDayEvent":"newEvent"),day:o.dayIndex,start:i,end:c,calendarId:"blue",allDay:l})}else"move"!==o.mode&&"resize"!==o.mode||(D(n=>"dayIndex"in n?Object.assign(Object.assign({},n),{dayIndex:o.dayIndex,startHour:e,endHour:t}):n),"move"===o.mode&&(null==i||i(e=>e.map(e=>e.id===o.eventId?Object.assign(Object.assign({},e),{day:o.dayIndex}):e))))}document.removeEventListener("mousemove",W),document.removeEventListener("mouseup",Z),document.removeEventListener("touchmove",W,{capture:!0}),document.removeEventListener("touchend",Z),E(),o.indicatorVisible=!1,o.sourceElement=null,w()}},[O,W,E,w,H,C,p,m,d,i,x,D]),q=t.useCallback((e,...t)=>{var r;if(null==y?void 0:y.state.readOnly)return;if(e.cancelable&&e.preventDefault(),e.stopPropagation(),null===(r=x.current)||void 0===r?void 0:r.active)return;const{clientX:o,clientY:s}=da(e);if(O){const[e]=t,a=new Date(e);a.setHours(9,0,0,0);const r=new Date(e);r.setHours(10,0,0,0);const o=P(a),s=P(r),l={id:String(Date.now()),title:n("newEvent"),start:o,end:s,day:e.getDay(),calendarId:"blue",allDay:!1};null==d||d(l),c&&setTimeout(()=>{c(l)},50)}else{const[e,r]=t,l=x.current;if(!l)return;const i=1,d=!!a.isMobile?-i/2:0,c=ne(r+d);Object.assign(l,{active:!0,mode:"create",eventId:null,startX:o,startY:s,dayIndex:e,startHour:c,endHour:c+i,allDay:!1,eventDate:m?me(m,e):new Date,duration:i,hourOffset:d}),D({active:!0,mode:"create",eventId:null,dayIndex:e,startHour:l.startHour,endHour:l.endHour,allDay:!1});const g=null==u?void 0:u(e,l.startHour,l.endHour);k(l,"blue",n("newEvent"),g),l.sourceElement=null,l.indicatorVisible=!0,document.addEventListener("mousemove",W),document.addEventListener("mouseup",Z),document.addEventListener("touchmove",W,{capture:!0,passive:!1}),document.addEventListener("touchend",Z)}},[O,d,c,m,u,k,W,Z,x,D]),G=t.useCallback((e,t)=>{var n,a,r,o;if(e.cancelable&&("touches"in e||"changedTouches"in e)&&e.preventDefault(),e.stopPropagation(),null===(n=x.current)||void 0===n?void 0:n.active)return;const{clientX:s,clientY:l}=da(e),i=x.current;if(!i)return;const d=e.currentTarget;if(O){b.current={x:s-d.getBoundingClientRect().left,y:l-d.getBoundingClientRect().top};const e=A(t.start),n=A(t.end);let a=1;if(t.allDay&&t.start&&t.end){const t=new Date(e);t.setHours(0,0,0,0);const r=new Date(n);r.setHours(0,0,0,0),a=Math.floor((r.getTime()-t.getTime())/864e5+1),a=Math.max(1,a)}const r=d.getAttribute("data-segment-days"),o=r?parseInt(r,10):a;i.active=!0,i.mode="move",i.eventId=t.id,i.startX=s,i.startY=l,i.targetDate=e,i.originalDate=e,i.originalEvent=Object.assign({},t),i.lastUpdateTime=Date.now(),i.originalStartDate=e,i.originalEndDate=n,i.eventDurationDays=a,i.currentSegmentDays=o,D({active:!0,mode:"move",eventId:t.id,targetDate:e,startDate:e,endDate:n}),i.sourceElement=d,i.indicatorVisible=!1,document.addEventListener("mousemove",W),document.addEventListener("mouseup",Z),document.addEventListener("touchmove",W,{capture:!0,passive:!1}),document.addEventListener("touchend",Z)}else{const e=j(l),n=t._segmentInfo,c=!!n,u=c?n.dayIndex:null!==(a=t.day)&&void 0!==a?a:0,g=c?n.startHour:U(t.start);let m=0;if(t.allDay&&t.start&&t.end){const e=A(t.start);e.setHours(0,0,0,0);const n=A(t.end);n.setHours(0,0,0,0),m=Math.floor((n.getTime()-e.getTime())/864e5)}const h=A(t.start);if(Object.assign(i,{active:!0,mode:"move",eventId:t.id,startX:s,startY:l,dayIndex:u,startHour:g,endHour:c?n.endHour:ae(t),originalDay:null!==(r=t.day)&&void 0!==r?r:0,originalStartHour:U(t.start),originalEndHour:ae(t),allDay:t.allDay||!1,eventDate:h,eventDurationDays:m,startDragDayIndex:u,calendarId:t.calendarId,title:t.title}),!t.allDay){i.hourOffset=g-e;const n=A(t.start),a=A(t.end).getTime()-n.getTime();i.duration=a/36e5}D({active:!0,mode:"move",eventId:t.id,dayIndex:null!==(o=t.day)&&void 0!==o?o:0,startHour:U(t.start),endHour:ae(t),allDay:t.allDay||!1}),i.sourceElement=d,i.indicatorVisible=!1,document.addEventListener("mousemove",V),document.addEventListener("mouseup",F),document.addEventListener("touchmove",V,{capture:!0,passive:!1}),document.addEventListener("touchend",F)}},[O,k,Z,W,V,F,j,x,b,D]),X=t.useCallback((e,t,n)=>{var a,r,o,s,l,i;if(null==y?void 0:y.state.readOnly)return;if(e.cancelable&&e.preventDefault(),e.stopPropagation(),null===(a=x.current)||void 0===a?void 0:a.active)return;const{clientX:d,clientY:c}=da(e),u=x.current;if(u){if(O){const e=A(t.start),a=A(t.start),r=A(t.end),o={hour:a.getHours(),minute:a.getMinutes(),second:a.getSeconds()},s={hour:r.getHours(),minute:r.getMinutes(),second:r.getSeconds()};u.active=!0,u.mode="resize",u.eventId=t.id,u.startX=d,u.startY=c,u.targetDate="left"===n?a:r,u.originalDate=e,u.originalEvent=Object.assign({},t),u.lastUpdateTime=Date.now(),u.resizeDirection=n,u.originalStartDate=a,u.originalEndDate=r,u.originalStartTime=o,u.originalEndTime=s,D({active:!0,mode:"resize",eventId:t.id,targetDate:"left"===n?a:r,startDate:a,endDate:r})}else if(t.allDay){const e=A(t.start),a=A(t.end);u.active=!0,u.mode="resize",u.eventId=t.id,u.startX=d,u.startY=c,u.allDay=!0,u.resizeDirection=n,u.originalStartDate=e,u.originalEndDate=a,u.originalEvent=Object.assign({},t),u.dayIndex=null!==(r=t.day)&&void 0!==r?r:0,D({active:!0,mode:"resize",eventId:t.id,dayIndex:null!==(o=t.day)&&void 0!==o?o:0,startHour:0,endHour:0,allDay:!0})}else{const e=j(c);Object.assign(u,{active:!0,mode:"resize",eventId:t.id,startX:d,startY:c,dayIndex:null!==(s=t.day)&&void 0!==s?s:0,startHour:U(t.start),endHour:ae(t),originalDay:null!==(l=t.day)&&void 0!==l?l:0,originalStartHour:U(t.start),originalEndHour:ae(t),resizeDirection:n,lastUpdateTime:Date.now(),initialMouseY:e,hourOffset:"top"===n?U(t.start)-e:ae(t)-e,allDay:!1}),D({active:!0,mode:"resize",eventId:t.id,dayIndex:null!==(i=t.day)&&void 0!==i?i:0,startHour:U(t.start),endHour:ae(t),allDay:!1})}document.addEventListener("mousemove",W),document.addEventListener("mouseup",Z),document.addEventListener("touchmove",W,{capture:!0,passive:!1}),document.addEventListener("touchend",Z)}},[O,W,Z,j,x,D]);return{handleDragMove:W,handleDragEnd:Z,handleCreateStart:q,handleMoveStart:G,handleResizeStart:X,handleUniversalDragMove:V,handleUniversalDragEnd:F}})({options:n,common:o,state:s,manager:l}),c=(e=>{const{t:n}=Ne(),{options:a,common:r,state:o,manager:s,handleDragMove:l,handleDragEnd:i}=e,{viewType:d,currentWeekStart:c,app:u}=a,{dragRef:g,setDragState:m}=o,{createDragIndicator:h}=s,{pixelYToHour:f,getColumnDayIndex:v}=r,p=d===exports.ViewType.MONTH;return{handleCreateAllDayEvent:t.useCallback((e,t)=>{var r;if(null==u?void 0:u.state.readOnly)return;if(p)return;if(e.preventDefault(),e.stopPropagation(),"dblclick"===e.type){const e=c?me(c,t):new Date,r=L(e),o=L(e),s={id:String(Date.now()),title:n("newAllDayEvent"),day:t,start:r,end:o,calendarId:"blue",allDay:!0};return void a.onEventCreate(s)}if(null===(r=g.current)||void 0===r?void 0:r.active)return;const o=g.current;o&&(Object.assign(o,{active:!0,mode:"create",eventId:null,startX:e.clientX,startY:e.clientY,dayIndex:t,allDay:!0,eventDate:c?me(c,t):new Date}),m({active:!0,mode:"create",eventId:null,dayIndex:t,startHour:0,endHour:0,allDay:!0}),o.indicatorVisible=!1,o.sourceElement=null,document.addEventListener("mousemove",l),document.addEventListener("mouseup",i))},[p,c,i,l,g,m,null==u?void 0:u.state.locale,a]),pixelYToHour:f,getColumnDayIndex:v}})({options:n,common:o,state:s,manager:l,handleDragMove:i.handleDragMove,handleDragEnd:i.handleDragEnd}),u=(e=>{const{common:t}=e,{daysDifference:n,addDaysToDate:a,getTargetDateFromPosition:r}=t;return{daysDifference:n,addDaysToDate:a,getTargetDateFromPosition:r}})({common:o});return Object.assign({createDragIndicator:l.createDragIndicator,updateDragIndicator:l.updateDragIndicator,removeDragIndicator:l.removeDragIndicator,handleCreateStart:i.handleCreateStart,handleMoveStart:i.handleMoveStart,handleResizeStart:i.handleResizeStart,dragState:s.dragState,isDragging:s.dragState.active},r?{daysDifference:u.daysDifference,addDaysToDate:u.addDaysToDate,getTargetDateFromPosition:u.getTargetDateFromPosition}:{handleCreateAllDayEvent:c.handleCreateAllDayEvent,pixelYToHour:c.pixelYToHour,getColumnDayIndex:c.getColumnDayIndex})};function ua(e,t){const n=e.getPlugin("drag"),a=ca(Object.assign(Object.assign({},t),{app:e}));if(!n)return w.warn("Drag plugin is not installed. Drag functionality will be disabled. Add createDragPlugin() to your plugins array to enable dragging."),{handleMoveStart:()=>{},handleCreateStart:()=>{},handleResizeStart:()=>{},handleCreateAllDayEvent:void 0,dragState:a.dragState,isDragging:!1};const r=n.getConfig(),o=n.isViewSupported(t.viewType),s=!1!==e.getReadOnlyConfig().draggable,l=!e.state.readOnly;return o||console.info(`Drag functionality is not supported for ${t.viewType} view.`),{handleMoveStart:o&&r.enableDrag&&s?a.handleMoveStart:()=>{},handleCreateStart:o&&r.enableCreate&&l?a.handleCreateStart:()=>{},handleResizeStart:o&&r.enableResize&&l?a.handleResizeStart:void 0,handleCreateAllDayEvent:o&&r.enableAllDayCreate&&l?a.handleCreateAllDayEvent:()=>{},dragState:a.dragState,isDragging:!(!o||!s)&&a.isDragging}}function ga(e){const{app:a,onEventCreated:r}=e,{t:o}=Ne(),s=t.useCallback(e=>{e.dataTransfer.types.includes("application/x-dayflow-calendar")&&(e.preventDefault(),e.dataTransfer.dropEffect="copy")},[]);return{handleDrop:t.useCallback((e,t,s,l)=>{e.preventDefault();const i=e.dataTransfer.getData("application/x-dayflow-calendar");if(!i)return null;try{const e=JSON.parse(i);let d,c,u=!1;l?(d=n.Temporal.PlainDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:0,minute:0}),c=n.Temporal.PlainDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:23,minute:59,second:59}),u=!0):void 0!==s?(d=n.Temporal.PlainDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:s,minute:0}),c=d.add({hours:1})):(d=n.Temporal.PlainDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:9,minute:0}),c=d.add({hours:1}));const g={id:`event-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,title:o(u?"newAllDayCalendarEvent":"newCalendarEvent",{calendarName:e.calendarName}),description:"",start:d,end:c,calendarId:e.calendarId,allDay:u};return a.addEvent(g),null==r||r(g),g}catch(e){return console.error("Error creating event from calendar drop:",e),null}},[a,r]),handleDragOver:s}}const ma=({handlePreviousMonth:e,handleToday:t,handleNextMonth:n})=>{const{t:a}=Ne();return r.jsxs("div",{className:"df-navigation flex items-center gap-1",children:[r.jsx("button",{className:at,onClick:e,"aria-label":"Previous month",children:r.jsx(i.ChevronLeft,{className:rt})}),r.jsx("button",{className:"df-today-button calendar-today-button inline-flex items-center justify-center px-4 h-7 text-sm font-medium rounded-md border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 hover:bg-gray-50 dark:hover:bg-gray-700 hover:border-gray-300 dark:hover:border-gray-500 active:bg-gray-100 dark:active:bg-gray-600 transition-all duration-150 shadow-sm hover:shadow focus:outline-none",onClick:t,children:a("today")}),r.jsx("button",{className:at,onClick:n,"aria-label":"Next month",children:r.jsx(i.ChevronRight,{className:rt})})]})},ha=({app:e,currentDate:t,visibleMonth:n,currentDayEvents:a,selectedEvent:o,setSelectedEvent:s,handleMonthChange:l,handleDateSelect:i,switcherMode:d})=>{const{t:c,locale:u}=Ne();return r.jsx("div",{className:"df-right-panel hidden md:block flex-none w-[30%] bg-white dark:bg-gray-900",children:r.jsxs("div",{className:`${gt} h-full`,children:[r.jsx("div",{className:"df-mini-calendar px-2 border-b border-gray-200 dark:border-gray-700",children:r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-end gap-2",children:[r.jsx("div",{className:Ye,style:{position:"relative"},children:r.jsx("div",{children:r.jsx("h1",{className:Ve,children:" "})})}),r.jsx(ma,{handlePreviousMonth:()=>e.goToPrevious(),handleNextMonth:()=>e.goToNext(),handleToday:()=>e.goToToday()})]}),r.jsx(ht,{visibleMonth:n,currentDate:t,showHeader:!0,onMonthChange:l,onDateSelect:i})]})}),r.jsxs("div",{className:"flex-1 p-4 overflow-y-auto",children:[r.jsx("h3",{className:"text-lg font-semibold mb-3",children:t.toLocaleDateString(u,{weekday:"long",month:"long",day:"numeric"})}),0===a.length?r.jsx("p",{className:`${it} ${ut}`,children:c("noEvents")}):r.jsx("div",{className:"space-y-2",children:a.map(t=>r.jsxs("div",{className:`\n p-2 rounded border-l-4 cursor-pointer transition-colors\n ${(null==o?void 0:o.id)===t.id?"bg-primary/10 border-primary":"bg-gray-50 dark:bg-gray-800 border-gray-300 dark:border-gray-600"}\n hover:bg-gray-100 dark:hover:bg-gray-700\n `,style:{borderLeftColor:J(t.calendarId||"blue")},onClick:()=>{s(t),e.onEventClick(t)},children:[r.jsx("div",{className:`font-medium ${ut}`,children:t.title}),!t.allDay&&r.jsxs("div",{className:`${ct} ${dt}`,children:[ee(U(t.start))," -"," ",ee(ae(t))]}),t.allDay&&r.jsx("div",{className:`${ct} ${dt}`,children:c("allDay")})]},t.id))})]})]})})},fa=({viewType:e,currentDate:t,onPrevious:n,onNext:a,onToday:o,customTitle:s,customSubtitle:l,showTodayBox:i,stickyYear:d,stickyYearOffset:c=0,nextYear:u,nextYearOffset:g=0})=>{const{locale:m}=Ne(),h=void 0===i||i,f=s||(()=>{switch(e){case"day":return t.toLocaleDateString(m,{day:"numeric",month:"long",year:"numeric"});case"week":case"month":return t.toLocaleDateString(m,{month:"long",year:"numeric"});case"year":return t.getFullYear().toString();default:return""}})(),v="day"===e?l||("day"===e?t.toLocaleDateString(m,{weekday:"long"}):null):null;return r.jsxs("div",{className:Ye,style:{position:"relative"},children:[r.jsx("div",{className:"flex-1",children:"year"===e&&d?r.jsxs("div",{style:{position:"relative",overflow:"hidden",height:"1.5em"},children:[r.jsx("h1",{className:Ve,style:{position:"absolute",top:0,left:0,transform:`translateY(-${c}px)`,willChange:"transform"},children:d}),u&&r.jsx("h1",{className:Ve,style:{position:"absolute",top:0,left:0,transform:`translateY(${g}px)`,willChange:"transform"},children:u})]}):r.jsxs("div",{children:[r.jsx("div",{className:`${Ve} text-gray-900 dark:text-white`,children:f}),v&&r.jsx("div",{className:"mt-3 text-gray-600 dark:text-gray-400",children:v})]})}),h&&n&&a&&o&&r.jsx("div",{className:"flex items-center gap-2",children:r.jsx(ma,{handlePreviousMonth:n,handleNextMonth:a,handleToday:o})})]})},va=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("假期")?r.jsx(i.Gift,{className:"h-3 w-3"}):t.includes("birthday")||t.includes("anniversary")||t.includes("生日")?r.jsx(i.Heart,{className:"h-3 w-3"}):t.includes("conference")||t.includes("meeting")||t.includes("会议")||t.includes("研讨")?r.jsx(i.Star,{className:"h-3 w-3"}):t.includes("trip")||t.includes("travel")||t.includes("旅行")?r.jsx(i.MapPin,{className:"h-3 w-3"}):r.jsx(i.CalendarDays,{className:"h-3 w-3"})},pa=(e,t)=>{const n=[],a=new Date(t);return a.setDate(t.getDate()+6),a.setHours(23,59,59,999),e.forEach(e=>{const r=A(e.start),o=A(e.end),s=new Date(r);s.setHours(0,0,0,0);const l=new Date(o);l.setHours(0,0,0,0);let i=new Date(l);if(!e.allDay){if(!(0!==o.getHours()||0!==o.getMinutes()||0!==o.getSeconds())){const e=o.getTime()-r.getTime();e>0&&e<864e5&&(i=new Date(l),i.setDate(i.getDate()-1))}}const d=W(s,i)>0;if(!d&&e.allDay){if(s<t||s>a)return;const r=Math.floor((s.getTime()-t.getTime())/864e5);return void(r>=0&&r<=6&&n.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(!d)return;const c=s;let u;if(e.allDay)u=new Date(l),u.setHours(23,59,59,999);else{0!==o.getHours()||0!==o.getMinutes()||0!==o.getSeconds()?(u=new Date(l),u.setHours(23,59,59,999)):(u=new Date(l),u.setTime(u.getTime()-1))}if(u<t||c>a)return;const g=c<t?t:c,m=u>a?a:u,h=Math.max(0,Math.floor((g.getTime()-t.getTime())/864e5)),f=Math.min(6,Math.floor((m.getTime()-t.getTime())/864e5)),v=c>=t,p=u<=a,y=0===h||6===f;let x;x=v&&p?"single":v?y&&6===f?"start-week-end":"start":p?y&&0===h?"end-week-start":"end":"middle";const b=W(c,u)+1;n.push({id:`${e.id}-week-${t.getTime()}`,originalEventId:e.id,event:e,startDayIndex:h,endDayIndex:f,segmentType:x,totalDays:b,segmentIndex:0,isFirstSegment:v,isLastSegment:p})}),n},ya=(e,t)=>{if(e.allDay)return[];const n=A(e.start),a=A(e.end),r=new Date(n);r.setHours(0,0,0,0);const o=new Date(a);o.setHours(0,0,0,0);const s=W(r,o);if(0===s)return[];const l=0!==a.getHours()||0!==a.getMinutes()||0!==a.getSeconds()||0!==a.getMilliseconds(),i=a.getTime()-n.getTime();if(!e.allDay&&1===s&&!l&&i<864e5)return[];const d=l?s:Math.max(0,s-1),c=[];for(let e=0;e<=d;e++){const o=new Date(r);o.setDate(r.getDate()+e);const s=Math.floor((o.getTime()-t.getTime())/864e5);if(s<0||s>6)continue;const i=0===e,u=e===d,g=i?n.getHours()+n.getMinutes()/60:0,m=u&&l?a.getHours()+a.getMinutes()/60:24;c.push({dayIndex:s,startHour:g,endHour:m,isFirst:i,isLast:u})}return c},xa=t.memo(({segment:e,segmentIndex:n,isDragging:a,isResizing:o=!1,isSelected:s=!1,onMoveStart:l,onResizeStart:i,onEventLongPress:d,isMobile:c=!1,isDraggable:u=!0,isEditable:g=!0,viewable:m=!0})=>{const h=17*n,f=`calc(${e.startDayIndex/7*100}% + 2px)`,v=`calc(${(e.endDayIndex-e.startDayIndex+1)/7*100}% - 4px)`,p=t.useRef(null),y=t.useRef(null),x=t=>{const n="left"===t;return(n?e.isFirstSegment:e.isLastSegment)&&i&&g?r.jsx("div",{className:`resize-handle absolute ${n?"left-0":"right-0"} top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20`,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),i(t,e.event,n?"left":"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}):null},b=e.event.calendarId||"blue",D=e.endDayIndex-e.startDayIndex+1;return r.jsxs("div",{className:"absolute px-1 text-xs select-none flex items-center transition-all duration-200 hover:shadow-sm dark:hover:shadow-lg dark:hover:shadow-black/20 group",style:Object.assign(Object.assign({left:f,width:v,top:`${h}px`,height:"16px",borderRadius:(w=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"}[w]),pointerEvents:"auto",zIndex:10},s||a?{backgroundColor:K(b),color:"#fff"}:{backgroundColor:G(b),color:X(b)}),{cursor:u||m?"pointer":"default"}),"data-segment-days":D,onMouseDown:t=>{if(!u&&!m)return;t.preventDefault(),t.stopPropagation();!t.target.closest(".resize-handle")&&u&&l(t,e.event)},onTouchStart:t=>{if(!l||!c||!u&&!m)return;t.stopPropagation();const n=t.touches[0],a=n.clientX,r=n.clientY,o=t.currentTarget;y.current={x:a,y:r},p.current=setTimeout(()=>{d&&d(e.event.id);u&&l({preventDefault:()=>{},stopPropagation:()=>{},currentTarget:o,touches:[{clientX:a,clientY:r}],cancelable:!1},e.event),p.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},onTouchMove:e=>{if(p.current&&y.current){const t=Math.abs(e.touches[0].clientX-y.current.x),n=Math.abs(e.touches[0].clientY-y.current.y);(t>10||n>10)&&(clearTimeout(p.current),p.current=null,y.current=null)}},onTouchEnd:()=>{p.current&&(clearTimeout(p.current),p.current=null),y.current=null},title:`${e.event.title} (${pn(e.event.start)} - ${pn(e.event.end)})`,children:[c&&s&&g&&r.jsxs(r.Fragment,{children:[e.isFirstSegment&&r.jsx("div",{className:"absolute left-5 top-1/2 -translate-y-1/2 w-2.5 h-2.5 bg-white border-2 rounded-full z-50 pointer-events-none",style:{borderColor:J(b)}}),e.isLastSegment&&r.jsx("div",{className:"absolute right-5 top-1/2 -translate-y-1/2 w-2.5 h-2.5 bg-white border-2 rounded-full z-50 pointer-events-none",style:{borderColor:J(b)}})]}),x("left"),r.jsx("div",{className:"flex-1 min-w-0",style:{cursor:o?"ew-resize":"pointer"},children:(()=>{const t=e.event.allDay,n=e.event.calendarId||"blue",a=U(e.event.start),o=ae(e.event),s=ee(a),l=ee(o);if(t){const t=()=>e.isFirstSegment?e.event.title:"middle"===e.segmentType||e.isLastSegment&&e.totalDays>1?"···":e.event.title;return r.jsxs("div",{className:"flex items-center min-w-0 w-full pointer-events-auto",children:[e.isFirstSegment&&va(e.event)&&r.jsx("div",{className:"shrink-0 mr-1",children:r.jsx("div",{className:"rounded-full p-0.5 text-white flex items-center justify-center",style:{backgroundColor:J(n),width:"12px",height:"12px"},children:va(e.event)})}),r.jsx("div",{className:"flex-1 min-w-0",children:r.jsx("div",{className:"truncate font-medium text-xs",children:t()})}),e.isLastSegment&&"single"!==e.segmentType&&r.jsx("div",{className:"shrink-0 ml-1 text-white/80 dark:text-white/90",children:r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-white/60 dark:bg-white/80"})})]})}const i=e.isFirstSegment||e.isLastSegment?e.event.title:"···",d=e.endDayIndex-e.startDayIndex+1,c=d>1?{position:"absolute",right:`calc(${d>1?(d-1)/d*100:0}% + 2px)`,top:"50%",transform:"translateY(-50%)"}:void 0;return r.jsxs("div",{className:"relative flex items-center min-w-0 w-full pointer-events-auto",children:[r.jsx("span",{className:"inline-block w-0.75 h-3 rounded-full shrink-0 mr-1",style:{backgroundColor:J(n)}}),r.jsx("div",{className:"flex items-center min-w-0 flex-1",children:r.jsx("span",{className:"whitespace-nowrap overflow-hidden block md:truncate mobile-mask-fade font-medium text-xs",children:i})}),e.isFirstSegment&&r.jsx("span",{className:`text-xs font-medium whitespace-nowrap ${1===d?"ml-2":""} hidden md:block`,style:c,children:s}),e.isLastSegment&&!e.event.allDay&&24!==o&&r.jsx("span",{className:"text-xs font-medium whitespace-nowrap ml-auto hidden md:inline",children:`ends ${l}`})]})})()}),x("right")]});var w});xa.displayName="MultiDayEvent";const ba=({event:e,position:a,panelRef:s,isAllDay:l,eventVisibility:i,calendarRef:d,selectedEventElementRef:c,onEventUpdate:u,onEventDelete:g,app:m})=>{var h;const{effectiveTheme:f}=Hn(),v=yn(f),{t:p}=Ne(),y="dark"===v||"undefined"!=typeof document&&document.documentElement.classList.contains("dark"),x=!(null==m?void 0:m.state.readOnly);if(!(!1!==(null==m?void 0:m.getReadOnlyConfig().viewable)))return null;const D=y?"#1f2937":"white",w=y?"rgb(55, 65, 81)":"rgb(229, 231, 235)",C=t.useMemo(()=>(m?m.getCalendarRegistry():b()).getVisible().map(e=>({label:e.name,value:e.id})),[m,null==m?void 0:m.getCalendars()]),E=t.useMemo(()=>O(e.start)?e.end&&!O(e.end)&&(e.end.timeZoneId||e.end.timeZoneId)||n.Temporal.Now.timeZoneId():e.start.timeZoneId||e.start.timeZoneId||n.Temporal.Now.timeZoneId(),[e.end,e.start]),k=t=>{const[n,a]=t;u(Object.assign(Object.assign({},e),{start:n.toPlainDate(),end:a.toPlainDate()}))},T=(()=>{var e;let t={};if("sticky-top"===i){const n=null===(e=d.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(n){const e=n.getBoundingClientRect().top+3-a.top;t=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:D,transform:"rotate(45deg)",transformOrigin:"center",top:e-6+"px",borderRight:""+(a.isSunday?`1px solid ${w}`:"none"),borderTop:""+(a.isSunday?`1px solid ${w}`:"none"),borderLeft:""+(a.isSunday?"none":`1px solid ${w}`),borderBottom:""+(a.isSunday?"none":`1px solid ${w}`)},a.isSunday?{right:"-6px"}:{left:"-6px"})}}else if("sticky-bottom"===i){const e=s.current;let n=200;if(e){const t=e.getBoundingClientRect(),a=window.getComputedStyle(e),r=parseInt(a.paddingBottom,10)||0,o=parseInt(a.borderBottomWidth,10)||0;n=t.height-r-o-6+11}t={position:"absolute",width:"12px",height:"12px",backgroundColor:D,transform:"rotate(45deg)",transformOrigin:"center",top:`${n}px`,left:a.isSunday?void 0:"-6px",right:a.isSunday?"-6px":void 0,borderRight:""+(a.isSunday?`1px solid ${w}`:"none"),borderTop:""+(a.isSunday?`1px solid ${w}`:"none"),borderLeft:""+(a.isSunday?"none":`1px solid ${w}`),borderBottom:""+(a.isSunday?"none":`1px solid ${w}`)}}else if(a&&c.current&&d.current){const e=c.current.getBoundingClientRect(),n=d.current.querySelector(".calendar-content");if(n){const r=n.getBoundingClientRect(),o=Math.max(e.top,r.top),l=Math.min(e.bottom,r.bottom),i=Math.max(0,l-o);let d;d=i===e.height?e.top+e.height/2:i>0?o+i/2:e.top+e.height/2;const c=d-a.top,u=s.current;let g=228;if(u){const e=u.getBoundingClientRect(),t=window.getComputedStyle(u),n=parseInt(t.paddingBottom,10)||0,a=parseInt(t.borderBottomWidth,10)||0;g=e.height-n-a+11}const m=12,h=Math.max(m,Math.min(g,c));t=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:D,transform:"rotate(45deg)",transformOrigin:"center",top:h-6+"px",borderRight:""+(a.isSunday?`1px solid ${w}`:"none"),borderTop:""+(a.isSunday?`1px solid ${w}`:"none"),borderLeft:""+(a.isSunday?"none":`1px solid ${w}`),borderBottom:""+(a.isSunday?"none":`1px solid ${w}`)},a.isSunday?{right:"-6px"}:{left:"-6px"})}}return t})(),j=r.jsxs("div",{ref:s,className:`${ot} p-4`,"data-event-detail-panel":"true",style:{top:`${a.top}px`,left:`${a.left}px`,zIndex:9999,pointerEvents:"auto"},children:[r.jsx("div",{style:T}),r.jsx("span",{className:"block text-xs text-gray-600 dark:text-gray-300 mb-1",children:p("eventTitle")}),r.jsxs("div",{className:"flex items-center justify-between gap-3 mb-3",children:[r.jsx("div",{className:"flex-1",children:r.jsx("input",{type:"text",value:e.title,readOnly:!x,disabled:!x,onChange:t=>{u(Object.assign(Object.assign({},e),{title:t.target.value}))},className:"w-full border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-1.5 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary transition"})}),x&&r.jsx(Vt,{options:C,value:e.calendarId||"blue",onChange:t=>{u(Object.assign(Object.assign({},e),{calendarId:t}))},registry:null==m?void 0:m.getCalendarRegistry()})]}),l?r.jsxs("div",{className:"mb-3",children:[r.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-1",children:p("dateRange")}),r.jsx(rn,{value:[e.start,e.end],format:"YYYY-MM-DD",showTime:!1,timeZone:E,matchTriggerWidth:!0,disabled:!x,onChange:k,onOk:k,locale:null==m?void 0:m.state.locale})]}):r.jsxs("div",{className:"mb-3",children:[r.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-1",children:p("timeRange")}),r.jsx(rn,{value:[e.start,e.end],timeZone:E,disabled:!x,onChange:t=>{const[n,a]=t;u(Object.assign(Object.assign({},e),{start:n,end:a}))},onOk:t=>{const[n,a]=t;u(Object.assign(Object.assign({},e),{start:n,end:a}))},locale:null==m?void 0:m.state.locale})]}),r.jsxs("div",{className:"mb-3",children:[r.jsx("span",{className:"block text-xs text-gray-600 dark:text-gray-300 mb-1",children:p("note")}),r.jsx("textarea",{value:null!==(h=e.description)&&void 0!==h?h:"",readOnly:!x,disabled:!x,onChange:t=>u(Object.assign(Object.assign({},e),{description:t.target.value})),rows:3,className:"w-full border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary transition resize-none",placeholder:p("addNotePlaceholder")})]}),x&&r.jsxs("div",{className:"flex space-x-2",children:[l?r.jsx("button",{className:"px-2 py-1 bg-primary text-primary-foreground rounded hover:bg-primary text-xs font-medium transition",onClick:()=>{const t=O(e.start)?e.start:e.start.toPlainDate(),a=n.Temporal.ZonedDateTime.from({year:t.year,month:t.month,day:t.day,hour:9,minute:0,timeZone:n.Temporal.Now.timeZoneId()}),r=n.Temporal.ZonedDateTime.from({year:t.year,month:t.month,day:t.day,hour:10,minute:0,timeZone:n.Temporal.Now.timeZoneId()});u(Object.assign(Object.assign({},e),{allDay:!1,start:a,end:r}))},children:p("setAsTimed")}):r.jsx("button",{className:"px-2 py-1 bg-primary text-primary-foreground rounded hover:bg-primary text-xs font-medium transition",onClick:()=>{const t=O(e.start)?e.start:e.start.toPlainDate();u(Object.assign(Object.assign({},e),{allDay:!0,start:t,end:t}))},children:p("setAsAllDay")}),r.jsx("button",{className:"px-2 py-1 bg-destructive text-destructive-foreground rounded hover:bg-destructive/90 text-xs font-medium transition",onClick:()=>g(e.id),children:p("delete")})]})]});if("undefined"==typeof window||"undefined"==typeof document)return null;const S=document.body;return S?o.createPortal(j,S):null},Da=({event:e,position:t,panelRef:n,isAllDay:a,eventVisibility:s,calendarRef:l,selectedEventElementRef:i,onEventUpdate:d,onEventDelete:c,onClose:u,contentRenderer:g})=>{const{effectiveTheme:m}=Hn(),h=yn(m),f="dark"===h?"#1f2937":"white",v="dark"===h?"rgb(55, 65, 81)":"rgb(229, 231, 235)",p=(()=>{var e;let a={};if("sticky-top"===s){const n=null===(e=l.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(n){const e=n.getBoundingClientRect().top+3-t.top;a=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:f,transform:"rotate(45deg)",transformOrigin:"center",top:e-6+"px",borderRight:""+(t.isSunday?`1px solid ${v}`:"none"),borderTop:""+(t.isSunday?`1px solid ${v}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${v}`),borderBottom:""+(t.isSunday?"none":`1px solid ${v}`)},t.isSunday?{right:"-6px"}:{left:"-6px"})}}else if("sticky-bottom"===s){const e=n.current;let r=200;if(e){const t=e.getBoundingClientRect(),n=window.getComputedStyle(e),a=parseInt(n.paddingBottom,10)||0,o=parseInt(n.borderBottomWidth,10)||0;r=t.height-a-o-6+11}a={position:"absolute",width:"12px",height:"12px",backgroundColor:f,transform:"rotate(45deg)",transformOrigin:"center",top:`${r}px`,left:t.isSunday?void 0:"-6px",right:t.isSunday?"-6px":void 0,borderRight:""+(t.isSunday?`1px solid ${v}`:"none"),borderTop:""+(t.isSunday?`1px solid ${v}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${v}`),borderBottom:""+(t.isSunday?"none":`1px solid ${v}`)}}else if(t&&i.current&&l.current){const e=i.current.getBoundingClientRect(),r=l.current.querySelector(".calendar-content");if(r){const o=r.getBoundingClientRect(),s=Math.max(e.top,o.top),l=Math.min(e.bottom,o.bottom),i=Math.max(0,l-s);let d;d=i===e.height?e.top+e.height/2:i>0?s+i/2:e.top+e.height/2;const c=d-t.top,u=n.current;let g=228;if(u){const e=u.getBoundingClientRect(),t=window.getComputedStyle(u),n=parseInt(t.paddingBottom,10)||0,a=parseInt(t.borderBottomWidth,10)||0;g=e.height-n-a+11}const m=12,h=Math.max(m,Math.min(g,c));a=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:f,transform:"rotate(45deg)",transformOrigin:"center",top:h-6+"px",borderRight:""+(t.isSunday?`1px solid ${v}`:"none"),borderTop:""+(t.isSunday?`1px solid ${v}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${v}`),borderBottom:""+(t.isSunday?"none":`1px solid ${v}`)},t.isSunday?{right:"-6px"}:{left:"-6px"})}}return a})(),y=r.jsxs("div",{ref:n,className:`${ot} p-3`,"data-event-detail-panel":"true",style:{top:`${t.top}px`,left:`${t.left}px`,zIndex:9999,pointerEvents:"auto",backgroundColor:"dark"===h?"#1f2937":"#ffffff"},children:[r.jsx("div",{style:p}),r.jsx(g,{event:e,isAllDay:a,onEventUpdate:d,onEventDelete:c,onClose:u})]});return o.createPortal(y,document.body)},wa=({event:e,app:t,isEventSelected:n,hideTime:a})=>{const o=`${Math.floor(U(e.start)).toString().padStart(2,"0")}:${Math.round(U(e.start)%1*60).toString().padStart(2,"0")}`;return r.jsxs("div",{className:"text-xs mb-[2px] cursor-pointer flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center flex-1 min-w-0",children:[r.jsx("span",{style:{backgroundColor:J(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())},className:`inline-block w-0.75 h-3 ${mt} shrink-0 rounded-full`}),r.jsx("span",{className:"whitespace-nowrap overflow-hidden block md:truncate mobile-mask-fade "+(n?"text-white":""),children:e.title})]}),!a&&r.jsx("span",{className:`${ct} ml-1 shrink-0 ${n?"text-white":""} hidden md:block`,style:n?void 0:{opacity:.8},children:o})]})},Ca=({event:e,isEventSelected:t})=>{const n=!1!==e.icon,a="boolean"!=typeof e.icon?e.icon:null;return r.jsxs("div",{className:"text-xs px-1 mb-[2px] rounded truncate cursor-pointer flex items-center",children:[n&&(a?r.jsx("div",{className:`${mt} shrink-0`,children:a}):e.title.toLowerCase().includes("easter")||e.title.toLowerCase().includes("holiday")?r.jsx("span",{className:`inline-block ${mt} shrink-0 ${t?"text-yellow-200":"text-yellow-600"}`,children:"⭐"}):r.jsx(i.CalendarDays,{className:`${et} ${t?"text-white":""}`})),r.jsx("span",{className:"truncate "+(t?"text-white":""),children:e.title})]})},Ea=({event:e,isEditable:t,onResizeStart:n})=>{const a=!1!==e.icon,o="boolean"!=typeof e.icon?e.icon:null;return r.jsxs("div",{className:"h-full flex items-center overflow-hidden pl-3 px-1 py-0 relative group",children:[n&&t&&r.jsx("div",{className:"resize-handle absolute left-0 top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20",onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),n(t,e,"left")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}),a&&(o?r.jsx("div",{className:"mr-1 shrink-0",children:o}):r.jsx(i.CalendarDays,{className:et})),r.jsx("div",{className:`${Je} pr-1`,style:{lineHeight:"1.2"},children:e.title}),n&&t&&r.jsx("div",{className:tt,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),n(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]})},ka=({event:e,app:t,multiDaySegmentInfo:n,isEditable:a,isTouchEnabled:o,isEventSelected:s,onResizeStart:l})=>{const i=n?n.startHour:U(e.start),d=n?n.endHour:ae(e),c=d-i,u=!n||n.isFirst,g=!n||n.isLast,m=e.calendarId||"blue";return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:Qe,style:{backgroundColor:J(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())}}),r.jsxs("div",{className:"h-full flex flex-col overflow-hidden pl-3 "+(ae(e)-U(e.start)<=.25?"px-1 py-0":"p-1"),children:[r.jsx("div",{className:`${Je} pr-1`,style:{lineHeight:c<=.25?"1.2":"normal"},children:e.title}),c>.5&&r.jsx("div",{className:"df-event-time text-xs opacity-80 truncate",children:n?`${ee(i)} - ${ee(d)}`:te(e)})]}),l&&a&&r.jsxs(r.Fragment,{children:[u&&r.jsx("div",{className:"absolute top-0 left-0 w-full h-1.5 cursor-ns-resize z-10 rounded-t-sm",onMouseDown:t=>l(t,e,"top")}),g&&r.jsx("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")}),!u&&g&&n&&r.jsx("div",{className:tt,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),l(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]}),o&&s&&l&&a&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"absolute -top-1.5 right-5 w-2.5 h-2.5 bg-white border-2 rounded-full z-50",style:{borderColor:J(m,null==t?void 0:t.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),l(t,e,"top")}}),r.jsx("div",{className:"absolute -bottom-1.5 left-5 w-2.5 h-2.5 bg-white border-2 rounded-full z-50",style:{borderColor:J(m,null==t?void 0:t.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),l(t,e,"bottom")}})]})]})},Ta=({event:e,layout:n,isAllDay:a=!1,allDayHeight:s=28,calendarRef:l,isBeingDragged:i=!1,isBeingResized:d=!1,isDayView:c=!1,isMonthView:u=!1,isMultiDay:g=!1,segment:m,segmentIndex:h=0,hourHeight:f,firstHour:v,selectedEventId:p,detailPanelEventId:y,onMoveStart:x,onResizeStart:b,onEventUpdate:D,onEventDelete:w,newlyCreatedEventId:C,onDetailPanelOpen:E,onEventSelect:k,onEventLongPress:T,onDetailPanelToggle:j,customDetailPanelContent:S,customEventDetailDialog:N,multiDaySegmentInfo:M,app:I,isMobile:R=!1,enableTouch:H,hideTime:O})=>{const P=null!=H?H:R,[L,$]=t.useState(!1),[A,z]=t.useState(!1),Y=g&&m?`${e.id}::${m.id}`:void 0!==(null==M?void 0:M.dayIndex)?`${e.id}::day-${M.dayIndex}`:e.id,V=y===Y,[F,W]=t.useState(null),[Z,B]=t.useState("visible"),_=t.useRef(null),q=t.useRef(null),J=t.useRef(null),Q=t.useRef(null),ee=t.useRef(null),te=t.useRef(null),ne=void 0!==p?p===e.id:L,re=null==I?void 0:I.getReadOnlyConfig(),oe=!(null==I?void 0:I.state.readOnly),se=!1!==(null==re?void 0:re.viewable),le=!1!==(null==re?void 0:re.draggable),ie=e=>{if(!l.current)return null;const t=l.current.getBoundingClientRect();if(u){const n=t.width/7;return{left:t.left+e*n,width:n}}const n=R?48:80;if(c){const e=t.width-n;return{left:t.left+n,width:e}}const a=(t.width-n)/7;return{left:t.left+n+e*a,width:a}},de=e=>{Q.current=e},ce=()=>{var t;if(null!==Q.current)return Q.current;if(y===Y){const e=Y.split("::"),t=e[e.length-1];if(t.startsWith("day-")){const e=Number(t.replace("day-",""));if(!Number.isNaN(e))return e}}return void 0!==(null==M?void 0:M.dayIndex)?M.dayIndex:m?m.startDayIndex:null!==(t=e.day)&&void 0!==t?t:0},ue=e=>{if(!l.current)return null;const t=l.current.getBoundingClientRect();if(u){const n=t.width/7,a=e-t.left,r=Math.floor(a/n);return Number.isFinite(r)?Math.max(0,Math.min(6,r)):null}const n=R?48:80,a=c?1:7,r=(t.width-n)/a,o=e-t.left-n,s=Math.floor(o/r);return Number.isFinite(s)?Math.max(0,Math.min(a-1,s)):null},ge=()=>new Promise(t=>{if(!l.current||a||u)return void t();const n=l.current.querySelector(".calendar-content");if(!n)return void t();const r=M?M.startHour:U(e.start),o=M?M.endHour:ae(e),s=(r-v)*f,i=s+Math.max((o-r)*f,f/4),d=n.scrollTop,c=n.clientHeight;if(s>=d&&i<=d+c)return void t();const g=((r+o)/2-v)*f-c/2,m=n.scrollHeight-c,h=Math.max(0,Math.min(m,g));n.scrollTo({top:h,behavior:"smooth"}),setTimeout(()=>{t()},300)}),me=t.useCallback(()=>{if(!J.current||!l.current||!q.current)return;const t=l.current.getBoundingClientRect(),n=ce(),a=ie(n);let r,o;if(a)r=a.left,o=a.width;else if(u)o=t.width/7,r=t.left+n*o;else{const e=R?48:80;o=(t.width-e)/7,r=t.left+e+n*o}const s=Math.min(window.innerWidth,t.right),i=Math.min(window.innerHeight,t.bottom);requestAnimationFrame(()=>{var a,o,d,h,p;if(!q.current)return;if(!J.current)return;const y=q.current.getBoundingClientRect(),x=y.width,b=y.height;let D,w,C;if("sticky-top"===Z||"sticky-bottom"===Z){const t=null===(a=l.current)||void 0===a?void 0:a.querySelector(".calendar-content");if(!t)return;const n=M?M.startHour:U(e.start),r=M?M.endHour:ae(e),s=(n-v)*f,i=Math.max((r-n)*f,f/4),d=t.getBoundingClientRect(),c=t.scrollTop,u=d.top+s-c,g=null===(o=_.current)||void 0===o?void 0:o.getBoundingClientRect();if(!g)return;C={top:u,bottom:u+i,left:g.left,right:g.right,width:g.width,height:i,x:g.x,y:u,toJSON:()=>({})}}else C=J.current.getBoundingClientRect();if(u&&g&&m){const e=ie(n),a=null!==(d=null==e?void 0:e.width)&&void 0!==d?d:t.width/7,r=null!==(h=null==e?void 0:e.left)&&void 0!==h?h:t.left+n*a,o=r+a;C={top:C.top,bottom:C.bottom,left:r,right:o,width:o-r,height:C.height,x:r,y:C.top,toJSON:()=>({})}}if(("sticky-top"===Z||"sticky-bottom"===Z)&&!u){const e=null!==(p=null==M?void 0:M.dayIndex)&&void 0!==p?p:ce(),n=R?48:80,a=c?1:7,r=(t.width-n)/a,o=ie(e),s=o?o.left:t.left+n+e*r,l=o?o.width:r,i=Math.max(0,c?C.width:l-3),d=c?C.left:s;C=Object.assign(Object.assign({},C),{left:d,right:d+i,width:i})}const E=s-C.right,k=C.left-t.left;D=E>=x+20?C.right+10:k>=x+20?C.left-x-10:E>k?Math.max(t.left+10,s-x-10):t.left+10;const T=C.top-b/2+C.height/2,j=Math.max(10,t.top+10),S=i-10;w=T<j?j:T+b>S?S-b:T,W(e=>e?Object.assign(Object.assign({},e),{top:w,left:D,isSunday:D<r}):null)})},[l,e.day,e.start,e.end,Z,u,v,f,g,null==m?void 0:m.startDayIndex,null==m?void 0:m.endDayIndex,null==M?void 0:M.dayIndex,y,Y]),he=t.useCallback(()=>{if(!ne||!V||!_.current||!l.current||a||u)return;const t=l.current.querySelector(".calendar-content");if(!t)return;const n=M?M.startHour:U(e.start),r=M?M.endHour:ae(e),o=(n-v)*f,s=o+Math.max((r-n)*f,f/4),i=t.getBoundingClientRect(),d=t.scrollTop;let c=s<d+6,g=o>d+i.height-6;const m=i.bottom<0,h=i.top>window.innerHeight;m?c=!0:h&&(g=!0),B(c?"sticky-top":g?"sticky-bottom":"visible"),me()},[L,V,l,a,u,U(e.start),ae(e),v,f,me,null==M?void 0:M.startHour,null==M?void 0:M.endHour,null==M?void 0:M.dayIndex,y,Y]);t.useEffect(()=>{var e,t;if(!ne||!V||a)return;const n=null===(e=l.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(!n)return;const r=()=>he(),o=()=>{he(),me()},s=[n];let i=null===(t=l.current)||void 0===t?void 0:t.parentElement;for(;i;){const e=window.getComputedStyle(i),t=e.overflowY,n=e.overflowX;"auto"!==t&&"scroll"!==t&&"auto"!==n&&"scroll"!==n||s.push(i),i=i.parentElement}s.forEach(e=>{e.addEventListener("scroll",r)}),window.addEventListener("scroll",r,!0),window.addEventListener("resize",o);let d=null;return l.current&&(d=new ResizeObserver(()=>{o()}),d.observe(l.current)),he(),()=>{s.forEach(e=>{e.removeEventListener("scroll",r)}),window.removeEventListener("scroll",r,!0),window.removeEventListener("resize",o),d&&d.disconnect()}},[ne,V,a,he,me,l,Z]),t.useEffect(()=>{if(!ne&&!V)return;const t=t=>{var n,a;const r=t.target,o=null===(n=_.current)||void 0===n?void 0:n.contains(r),s=null!==r.closest(`[data-event-id="${e.id}"]`),l=null===(a=q.current)||void 0===a?void 0:a.contains(r),i=r.closest("[data-event-detail-dialog]"),d=r.closest("[data-range-picker-popup]"),c=r.closest("[data-calendar-picker-dropdown]");V?o||s||l||i||d||c||(k&&k(null),de(null),$(!1),null==j||j(null)):!ne||o||s||c||(k&&k(null),de(null),$(!1),null==j||j(null))};return document.addEventListener("mousedown",t),()=>{document.removeEventListener("mousedown",t)}},[ne,V,k,j,e.id]),t.useEffect(()=>{g&&m&&!m.isFirstSegment||C!==e.id||V||setTimeout(()=>{var t,n;if(_.current){let a=_.current;if(g){const e=_.current.querySelector("div");e&&(a=e)}g?m?de(m.startDayIndex):void 0!==(null==M?void 0:M.dayIndex)?de(M.dayIndex):de(null!==(t=e.day)&&void 0!==t?t:null):de(null!==(n=e.day)&&void 0!==n?n:null),J.current=a,$(!0),null==j||j(Y),W({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>{me()})}null==E||E()},150)},[C,e.id,V,E,me,g,m,j,Y]);const fe=t.useRef(null);t.useEffect(()=>{let t,n=!0;const a=null==I?void 0:I.state.highlightedEventId;return ne&&a===e.id?fe.current!==a&&(fe.current=a,ge().then(()=>{n&&(z(!0),t=setTimeout(()=>{n&&z(!1)},150))})):z(!1),a!==e.id&&(fe.current=null),()=>{n=!1,t&&clearTimeout(t)}},[ne,null==I?void 0:I.state.highlightedEventId,e.id]);const ve=()=>m?r.jsx(xa,{segment:m,segmentIndex:null!=h?h:0,isDragging:i||ne,isResizing:d,isSelected:ne,onMoveStart:x||(()=>{}),onResizeStart:b,isMobile:R,isDraggable:le,isEditable:oe,viewable:se}):null,pe=()=>{if(g&&m){const{segmentType:e}=m;if("single"===e||"start"===e)return Ke;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 Ke},ye=e.calendarId||"blue";return r.jsxs(r.Fragment,{children:[r.jsx("div",{ref:_,"data-event-id":e.id,className:(()=>{let e="df-event calendar-event select-none pointer-events-auto px-0.5";return c?e+=" df-day-event":u||(e+=" df-week-event"),u?`\n ${e}\n ${a?pe():"rounded-sm"}\n `:`\n ${e}\n shadow-sm\n ${a?pe():"rounded-sm"}\n `})(),style:Object.assign(Object.assign({},(()=>{var t,r,o,d,p,y;if(u)return{opacity:i?.3:1,zIndex:ne||V?1e3:1,transform:A?"scale(1.15)":void 0,transition:"transform 0.1s ease-in-out",cursor:le||se?"pointer":"default"};if(a){const e={height:s-4+"px",opacity:i?.3:1,zIndex:ne||V?1e3:1,transform:A?"scale(1.12)":void 0,transition:"transform 0.1s ease-in-out",cursor:le||se?"pointer":"default"},t=h*s;if(Object.assign(e,{top:`${t}px`}),c)Object.assign(e,{width:"100%",left:"0px",right:"2px",position:"absolute"});else if(g&&m){const t=(m.endDayIndex-m.startDayIndex+1)/7*100,n=m.startDayIndex/7*100,a=2,r=m.isFirstSegment?a:0,o=r+(m.isLastSegment?a:0);Object.assign(e,{width:o>0?`calc(${t}% - ${o}px)`:`${t}%`,left:r>0?`calc(${n}% + ${r}px)`:`${n}%`,position:"absolute",pointerEvents:"auto"})}else Object.assign(e,{width:"calc(100% - 3px)",left:"0px",position:"relative"});return e}const x=M?M.startHour:U(e.start),b=M?M.endHour:ae(e),D={top:`${(x-v)*f+3}px`,height:Math.max((b-x)*f,f/4)-4+"px",position:"absolute",opacity:i?.3:1,zIndex:ne||V?1e3:null!==(t=null==n?void 0:n.zIndex)&&void 0!==t?t:1,transform:A?"scale(1.12)":void 0,transition:"transform 0.1s ease-in-out",cursor:le||se?"pointer":"default"};if(ne&&V&&("sticky-top"===Z||"sticky-bottom"===Z)){const e=null===(r=l.current)||void 0===r?void 0:r.getBoundingClientRect();if(e){const t=null!==(o=null==M?void 0:M.dayIndex)&&void 0!==o?o:ce(),n=R?48:80,a=c?1:7;let r=(e.width-n)/a,s=e.left+n+t*r;u&&(r=e.width/7,s=e.left+t*r);const i=ie(t);i&&(s=i.left,r=i.width);let g=null===(d=l.current)||void 0===d?void 0:d.querySelector(".calendar-content");g||(g=null===(p=l.current)||void 0===p?void 0:p.querySelector(".calendar-renderer"));const m=null==g?void 0:g.getBoundingClientRect(),h=null===(y=_.current)||void 0===y?void 0:y.getBoundingClientRect(),f=null==h?void 0:h.left,v=null==h?void 0:h.width;if("sticky-top"===Z){let t=m?m.top:e.top;return t=Math.max(t,0),t=Math.max(t,e.top),t=Math.min(t,e.bottom-6),t=Math.min(t,window.innerHeight-6),{position:"fixed",top:`${t}px`,left:`${c?f:s}px`,width:`${c?v:r-3}px`,height:"6px",zIndex:1e3,overflow:"hidden"}}let x=m?m.bottom:e.bottom;return x=Math.min(x,window.innerHeight),x=Math.min(x,e.bottom),x=Math.max(x,e.top+6),x=Math.max(x,6),{position:"fixed",top:x-6+"px",left:`${c?f:s}px`,width:`${c?v:r-3}px`,height:"6px",zIndex:1e3,overflow:"hidden"}}}if(n&&!a){const e=c?`calc(${n.width}% - 3px)`:n.width-1+"%";return Object.assign(Object.assign({},D),{left:`${n.left}%`,width:e,right:"auto"})}return Object.assign(Object.assign({},D),{left:"0px",right:"3px"})})()),ne?{backgroundColor:K(ye,null==I?void 0:I.getCalendarRegistry()),color:"#fff"}:{backgroundColor:G(ye,null==I?void 0:I.getCalendarRegistry()),color:X(ye,null==I?void 0:I.getCalendarRegistry())}),onClick:P?void 0:t=>{var n,a;if(t.preventDefault(),t.stopPropagation(),g)if(m){const e=ue(t.clientX);if(null!==e){const t=Math.min(Math.max(e,m.startDayIndex),m.endDayIndex);de(t)}else de(m.startDayIndex)}else void 0!==(null==M?void 0:M.dayIndex)?de(M.dayIndex):de(null!==(n=e.day)&&void 0!==n?n:null);else de(null!==(a=e.day)&&void 0!==a?a:null);I&&I.onEventClick(e);k?k(e.id):se&&$(!0),null==j||j(null),W(null)},onDoubleClick:P?void 0:t=>{var n,a;if(!se)return;t.preventDefault(),t.stopPropagation();let r=t.currentTarget;if(g){const e=r.querySelector("div");e&&(r=e)}if(J.current=r,g)if(m){const e=ue(t.clientX);if(null!==e){const t=Math.min(Math.max(e,m.startDayIndex),m.endDayIndex);de(t)}else de(m.startDayIndex)}else void 0!==(null==M?void 0:M.dayIndex)?de(M.dayIndex):de(null!==(n=e.day)&&void 0!==n?n:null);else de(null!==(a=e.day)&&void 0!==a?a:null);ge().then(()=>{$(!0),R||(null==j||j(Y),W({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>{me()}))})},onMouseDown:x?t=>{var n;if(M){const a=Object.assign(Object.assign({},e),{day:null!==(n=M.dayIndex)&&void 0!==n?n:e.day,_segmentInfo:M});x(t,a)}else if(g&&m){const n=Object.assign(Object.assign({},e),{day:m.startDayIndex,_segmentInfo:{dayIndex:m.startDayIndex,isFirst:m.isFirstSegment,isLast:m.isLastSegment}});x(t,n)}else x(t,e)}:void 0,onTouchStart:t=>{if(!x||!P)return;t.stopPropagation();const n=t.touches[0],a=n.clientX,r=n.clientY,o=t.currentTarget;te.current={x:a,y:r},ee.current=setTimeout(()=>{var t;T?T(e.id):$(!0);const n={preventDefault:()=>{},stopPropagation:()=>{},currentTarget:o,touches:[{clientX:a,clientY:r}],cancelable:!1};if(M){const a=Object.assign(Object.assign({},e),{day:null!==(t=M.dayIndex)&&void 0!==t?t:e.day,_segmentInfo:M});x(n,a)}else if(g&&m){const t=Object.assign(Object.assign({},e),{day:m.startDayIndex,_segmentInfo:{dayIndex:m.startDayIndex,isFirst:m.isFirstSegment,isLast:m.isLastSegment}});x(n,t)}else x(n,e);ee.current=null,te.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},onTouchMove:e=>{if(ee.current&&te.current){const t=Math.abs(e.touches[0].clientX-te.current.x),n=Math.abs(e.touches[0].clientY-te.current.y);(t>10||n>10)&&(clearTimeout(ee.current),ee.current=null,te.current=null)}},onTouchEnd:t=>{ee.current&&(clearTimeout(ee.current),ee.current=null),P&&te.current&&(t.preventDefault(),t.stopPropagation(),k?k(e.id):se&&$(!0),I&&I.onEventClick(e),null==j||j(null),W(null)),te.current=null},children:u?g&&m?ve():e.allDay?g?ve():r.jsx(Ca,{event:e,isEventSelected:ne}):r.jsx(wa,{event:e,app:I,isEventSelected:ne,hideTime:O}):e.allDay?r.jsx(Ea,{event:e,isEditable:!!oe,onResizeStart:b}):r.jsx(ka,{event:e,app:I,multiDaySegmentInfo:M,isEditable:!!oe,isTouchEnabled:!!P,isEventSelected:ne,onResizeStart:b})}),V&&r.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:9998,pointerEvents:"none"}}),(()=>{if(!V)return null;const t=()=>{k&&k(null),de(null),$(!1),null==j||j(null)};if(N){const n=N,s={event:e,isOpen:V,isAllDay:a,onEventUpdate:D,onEventDelete:w,onClose:t,app:I};if("undefined"==typeof window||"undefined"==typeof document)return null;const l=document.body;return l?o.createPortal(r.jsx(n,Object.assign({},s)),l):null}return F?S?r.jsx(Da,{event:e,position:F,panelRef:q,isAllDay:a,eventVisibility:Z,calendarRef:l,selectedEventElementRef:J,onEventUpdate:D,onEventDelete:w,onClose:t,contentRenderer:S}):r.jsx(ba,{event:e,position:F,panelRef:q,isAllDay:a,eventVisibility:Z,calendarRef:l,selectedEventElementRef:J,onEventUpdate:D,onEventDelete:w,onClose:t,app:I}):null})()]})},ja=({app:e,currentDate:n,currentWeekStart:a,events:o,currentDayEvents:s,organizedAllDayEvents:l,allDayAreaHeight:i,timeSlots:d,eventLayouts:c,isToday:u,currentTime:g,selectedEventId:m,setSelectedEventId:h,newlyCreatedEventId:f,setNewlyCreatedEventId:v,detailPanelEventId:p,setDetailPanelEventId:y,dragState:x,isDragging:b,handleMoveStart:D,handleResizeStart:w,handleCreateStart:C,handleCreateAllDayEvent:E,handleTouchStart:k,handleTouchEnd:T,handleTouchMove:j,handleDragOver:S,handleDrop:N,handleEventUpdate:M,handleEventDelete:I,customDetailPanelContent:R,customEventDetailDialog:H,calendarRef:O,allDayRowRef:P,switcherMode:L,isMobile:$,isTouch:A,setDraftEvent:z,setIsDrawerOpen:Y,ALL_DAY_HEIGHT:V,HOUR_HEIGHT:F,FIRST_HOUR:W,LAST_HOUR:Z})=>{const{t:U,locale:B}=Ne(),_=t.useRef(e.state.highlightedEventId);return r.jsx("div",{className:`flex-none ${"buttons"===L?"":"md:w-[60%]"} w-full md:w-[70%] bg-white dark:bg-gray-900 border-r border-gray-200 dark:border-gray-700`,children:r.jsxs("div",{className:`relative ${gt} h-full`,children:[r.jsx(fa,{calendar:e,viewType:exports.ViewType.DAY,currentDate:n,customSubtitle:n.toLocaleDateString(B,{weekday:"long"})}),r.jsxs("div",{className:`${Xe} pt-px`,ref:P,children:[r.jsx("div",{className:"df-all-day-label flex-shrink-0 p-1 text-xs font-medium text-gray-500 dark:text-gray-400 flex justify-end select-none w-12 text-[10px] md:w-20 md:text-xs",children:U("allDay")}),r.jsx("div",{className:"flex flex-1 relative",children:r.jsx("div",{className:"w-full relative",style:{minHeight:`${i}px`},onMouseDown:e=>{const t=Math.floor((n.getTime()-a.getTime())/864e5);null==E||E(e,t)},onDoubleClick:e=>{const t=Math.floor((n.getTime()-a.getTime())/864e5);null==E||E(e,t)},onDragOver:S,onDrop:e=>{N(e,n,void 0,!0)},children:l.map(t=>r.jsx(Ta,{event:t,isAllDay:!0,isDayView:!0,segmentIndex:t.row,allDayHeight:V,calendarRef:O,isBeingDragged:b&&(null==x?void 0:x.eventId)===t.id&&"move"===(null==x?void 0:x.mode),hourHeight:F,firstHour:W,onMoveStart:D,onEventUpdate:M,onEventDelete:I,newlyCreatedEventId:f,onDetailPanelOpen:()=>v(null),detailPanelEventId:p,onDetailPanelToggle:e=>y(e),selectedEventId:m,onEventSelect:t=>{const n=!1!==e.getReadOnlyConfig().viewable,a=e.state.readOnly,r=o.find(e=>e.id===t);($||A)&&r&&n&&!a?(z(r),Y(!0)):(h(t),e.state.highlightedEventId&&(e.highlightEvent(null),_.current=null))},onEventLongPress:e=>{($||A)&&h(e)},customDetailPanelContent:R,customEventDetailDialog:H,app:e,isMobile:$,enableTouch:A},t.id))})})]}),r.jsx("div",{className:"relative overflow-y-auto calendar-content df-day-time-grid",style:{position:"relative"},children:r.jsxs("div",{className:"relative flex",children:[u&&g&&(()=>{const e=g,t=e.getHours()+e.getMinutes()/60;if(t<W||t>Z)return null;const n=(t-W)*F;return r.jsxs("div",{className:qe,style:{top:`${n}px`,width:"100%",height:0,zIndex:20},children:[r.jsxs("div",{className:"flex items-center w-12 md:w-20",children:[r.jsx("div",{className:"relative w-full flex items-center"}),r.jsx("div",{className:Ge,children:ee(t)})]}),r.jsx("div",{className:"flex-1 flex items-center",children:r.jsx("div",{className:"df-current-time-bar h-0.5 w-full bg-primary relative"})})]})})(),r.jsx("div",{className:"df-time-column flex-shrink-0 border-gray-200 dark:border-gray-700 w-12 md:w-20",children:d.map((e,t)=>r.jsx("div",{className:Ue,children:r.jsx("div",{className:`${Be} text-[10px] md:text-[12px]`,children:0===t?"":e.label})},t))}),r.jsxs("div",{className:"grow relative select-none",style:{WebkitTouchCallout:"none"},children:[d.map((e,t)=>r.jsx("div",{className:_e,onDoubleClick:e=>{var t,r,o,s;const l=Math.floor((n.getTime()-a.getTime())/864e5),i=null===(r=null===(t=O.current)||void 0===t?void 0:t.querySelector(".calendar-content"))||void 0===r?void 0:r.getBoundingClientRect();if(!i)return;const d=e.clientY-i.top+(null===(s=null===(o=O.current)||void 0===o?void 0:o.querySelector(".calendar-content"))||void 0===s?void 0:s.scrollTop)||0;null==C||C(e,l,W+d/F)},onTouchStart:e=>{const t=Math.floor((n.getTime()-a.getTime())/864e5);k(e,t)},onTouchEnd:T,onTouchMove:j,onDragOver:S,onDrop:e=>{var t,a,r,o;const s=null===(a=null===(t=O.current)||void 0===t?void 0:t.querySelector(".calendar-content"))||void 0===a?void 0:a.getBoundingClientRect();if(!s)return;const l=e.clientY-s.top+(null===(o=null===(r=O.current)||void 0===r?void 0:r.querySelector(".calendar-content"))||void 0===o?void 0:o.scrollTop)||0,i=Math.floor(W+l/F);N(e,n,i)},onContextMenu:e=>$&&e.preventDefault()},t)),r.jsx("div",{className:st,children:r.jsx("div",{className:"absolute -top-2.5 text-[12px] text-gray-500 dark:text-gray-400 -left-9",children:"00:00"})}),r.jsx("div",{className:"absolute top-0 left-0 right-0 bottom-0 pointer-events-none",children:s.filter(e=>!e.allDay).map(t=>{const n=c.get(t.id);return r.jsx(Ta,{event:t,layout:n,isDayView:!0,calendarRef:O,isBeingDragged:b&&(null==x?void 0:x.eventId)===t.id&&"move"===(null==x?void 0:x.mode),hourHeight:F,firstHour:W,onMoveStart:D,onResizeStart:w,onEventUpdate:M,onEventDelete:I,newlyCreatedEventId:f,onDetailPanelOpen:()=>v(null),detailPanelEventId:p,onDetailPanelToggle:e=>y(e),selectedEventId:m,onEventSelect:t=>{const n=!1!==e.getReadOnlyConfig().viewable,a=o.find(e=>e.id===t);($||A)&&a&&n?(z(a),Y(!0)):(h(t),e.state.highlightedEventId&&(e.highlightEvent(null),_.current=null))},onEventLongPress:e=>{($||A)&&h(e)},customDetailPanelContent:R,customEventDetailDialog:H,app:e,isMobile:$,enableTouch:A},t.id)})})]})]})})]})})},Sa=e=>{const t=e.getDay(),n=e.getDate()-t+(0===t?-6:1),a=new Date(e);return a.setDate(n),a.setHours(0,0,0,0),a},Na=({app:e,customDetailPanelContent:n,customEventDetailDialog:a,calendarRef:o,switcherMode:s="buttons"})=>{const l=e.getEvents(),{t:i,locale:d}=Ne(),{screenSize:c}=Sn(),u="desktop"!==c,[g,m]=t.useState(!1);t.useEffect(()=>{m("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const h=e.getCustomMobileEventRenderer()||Wn,[f,v]=t.useState(null),[p,y]=t.useState(null),[x,b]=t.useState(null),[D,w]=t.useState(null),[C,E]=t.useState(!1),[k,T]=t.useState(null),j=t.useRef(null),S=e.getCurrentDate(),N=e.getVisibleMonth();N.getFullYear(),N.getMonth();const[M,I]=t.useState(S),R=t.useRef(S.getTime());S.getTime()!==R.current&&(R.current=S.getTime(),S.getFullYear()===M.getFullYear()&&S.getMonth()===M.getMonth()||I(S));const H=t.useCallback(t=>{I(n=>{const a=new Date(n.getFullYear(),n.getMonth()+t,1);return e.setVisibleMonth(a),a})},[e]),{HOUR_HEIGHT:O,FIRST_HOUR:L,LAST_HOUR:$,TIME_COLUMN_WIDTH:z,ALL_DAY_HEIGHT:Y}=ra,V=t.useRef(e.state.highlightedEventId);t.useEffect(()=>{var t;if(e.state.highlightedEventId!==V.current)if(e.state.highlightedEventId){const n=e.getEvents().find(t=>t.id===e.state.highlightedEventId);if(n&&(y(n),!n.allDay)){const e=U(n.start),a=null===(t=o.current)||void 0===t?void 0:t.querySelector(".calendar-content");if(a){const t=(e-L)*O;requestAnimationFrame(()=>{a.scrollTo({top:Math.max(0,t-100),behavior:"smooth"})})}}}else y(null);V.current=e.state.highlightedEventId},[e.state.highlightedEventId,L,O,o,e]);const F=t.useRef(null),W=t.useMemo(()=>Sa(S),[S]),Z=t.useMemo(()=>((e,t,n)=>{const a=new Date(t);a.setHours(0,0,0,0);const r=new Date(t);return r.setHours(23,59,59,999),e.filter(e=>{const t=A(e.start),n=A(e.end);if(e.allDay){const e=new Date(t);e.setHours(0,0,0,0);const o=new Date(n);return o.setHours(0,0,0,0),e<=r&&o>=a}return t<r&&n>a}).map(e=>{const t=A(e.start),a=Math.floor((t.getTime()-n.getTime())/864e5),r=Math.max(0,Math.min(6,a));return Object.assign(Object.assign({},e),{day:r})})})(l,S,W),[l,S,W]),B=t.useMemo(()=>((e,t)=>{const n=new Date(t);n.setHours(0,0,0,0);const a=new Date(n);return a.setDate(a.getDate()+1),e.filter(e=>!e.allDay).map(e=>{const t=A(e.start),r=A(e.end);let o=e.start,s=e.end,l=!1;return t<n&&(o=P(n),l=!0),r>a&&(s=P(a),l=!0),Object.assign(Object.assign({},e),{start:l?o:e.start,end:l?s:e.end,day:0})})})(Z,S),[Z,S]),_=t.useMemo(()=>aa.calculateDayEventLayouts(B,{viewType:"day"}),[B]),q=t.useMemo(()=>(e=>{const t=e.filter(e=>e.allDay);t.sort((e,t)=>{const n=A(e.start),a=A(t.start);if(n.getTime()!==a.getTime())return n.getTime()-a.getTime();const r=A(e.end);return A(t.end).getTime()-r.getTime()});const n=[],a=[];return t.forEach(e=>{let t=0,r=!1;for(;!r;)n[t]?n[t].some(t=>{const n=A(e.start),a=A(e.end),r=A(t.start);return n<=A(t.end)&&r<=a})?t++:(n[t].push(e),a.push(Object.assign(Object.assign({},e),{row:t})),r=!0):(n[t]=[e],a.push(Object.assign(Object.assign({},e),{row:t})),r=!0)}),a})(Z),[Z]),G=t.useMemo(()=>{if(0===q.length)return Y;return(Math.max(...q.map(e=>e.row))+1)*Y},[q,Y]),{handleMoveStart:X,handleCreateStart:K,handleResizeStart:J,handleCreateAllDayEvent:Q,dragState:te,isDragging:ne}=ua(e,{calendarRef:o,allDayRowRef:F,viewType:exports.ViewType.DAY,onEventsUpdate:t=>{const n=t(Z),a=new Set(n.map(e=>e.id)),r=Z.filter(e=>!a.has(e.id)),o=new Set(Z.map(e=>e.id)),s=n.filter(e=>!o.has(e.id)),l=n.filter(e=>{if(!o.has(e.id))return!1;const t=Z.find(t=>t.id===e.id);return t&&(A(t.start).getTime()!==A(e.start).getTime()||A(t.end).getTime()!==A(e.end).getTime()||t.day!==e.day||U(t.start)!==U(e.start)||U(t.end)!==U(e.end)||t.title!==e.title)});r.forEach(t=>e.deleteEvent(t.id)),s.forEach(t=>e.addEvent(t)),l.forEach(t=>e.updateEvent(t.id,t))},onEventCreate:t=>{u?(T(t),E(!0)):(e.addEvent(t),w(t.id))},onEventEdit:()=>{},currentWeekStart:W,events:Z,calculateNewEventLayout:(e,t,n)=>((e,t,n,a,r)=>{const o=new Date(a),s=new Date(a);o.setHours(Math.floor(t),t%1*60,0,0),s.setHours(Math.floor(n),n%1*60,0,0);const l=[...r,{id:"-1",title:"Temp",day:0,start:P(o),end:P(s),calendarId:"blue",allDay:!1}];return aa.calculateDayEventLayouts(l,{viewType:"day"}).get("-1")||null})(0,t,n,S,B),calculateDragLayout:(e,t,n,a)=>((e,t,n,a,r,o)=>{const s=o.filter(t=>t.id!==e.id),l=new Date(r),i=new Date(l);i.setHours(Math.floor(n),n%1*60,0,0);const d=new Date(l);d.setHours(Math.floor(a),a%1*60,0,0);const c=[...s,Object.assign(Object.assign({},e),{start:P(i),end:P(d),day:0})];return 0===c.length?null:aa.calculateDayEventLayouts(c,{viewType:"day"}).get(e.id)||null})(e,0,n,a,S,B),TIME_COLUMN_WIDTH:u?48:80,isMobile:u}),{handleDrop:ae,handleDragOver:re}=ga({app:e,onEventCreated:e=>{w(e.id)}}),oe=Array.from({length:24},(e,t)=>({hour:t+L,label:ee(t+L)})),se=t.useCallback(t=>{const n=new Date(t.getFullYear(),t.getMonth(),t.getDate());e.setCurrentDate(n),I(new Date(n.getFullYear(),n.getMonth(),1))},[e]),le=t.useMemo(()=>{const e=new Date;e.setHours(0,0,0,0);const t=new Date(S);return t.setHours(0,0,0,0),t.getTime()===e.getTime()},[S]);return t.useEffect(()=>{v(new Date);const e=setInterval(()=>v(new Date),6e4);return()=>clearInterval(e)},[]),r.jsxs("div",{className:"df-day-view flex h-full bg-gray-50 dark:bg-gray-800",children:[r.jsx(ja,{app:e,currentDate:S,currentWeekStart:W,events:l,currentDayEvents:Z,organizedAllDayEvents:q,allDayAreaHeight:G,timeSlots:oe,eventLayouts:_,isToday:le,currentTime:f,selectedEventId:p?p.id:null,setSelectedEventId:e=>{if(e){const t=l.find(t=>t.id===e);y(t||null)}else y(null)},newlyCreatedEventId:D,setNewlyCreatedEventId:w,detailPanelEventId:x,setDetailPanelEventId:b,dragState:te,isDragging:ne,handleMoveStart:X,handleResizeStart:J,handleCreateStart:K,handleCreateAllDayEvent:Q,handleTouchStart:(e,t)=>{if(!u&&!g)return;const n=e.touches[0],a=n.clientX,r=n.clientY,s=e.currentTarget;j.current=setTimeout(()=>{var e,n,l;const i=null===(n=null===(e=o.current)||void 0===e?void 0:e.querySelector(".calendar-content"))||void 0===n?void 0:n.getBoundingClientRect();if(!i)return;const d=null===(l=o.current)||void 0===l?void 0:l.querySelector(".calendar-content"),c=d?d.scrollTop:0,u=r-i.top+c;null==K||K({preventDefault:()=>{},stopPropagation:()=>{},touches:[{clientX:a,clientY:r}],changedTouches:[{clientX:a,clientY:r}],target:s,currentTarget:s,cancelable:!0},t,L+u/O)},500)},handleTouchEnd:()=>{j.current&&(clearTimeout(j.current),j.current=null)},handleTouchMove:()=>{j.current&&(clearTimeout(j.current),j.current=null)},handleDragOver:re,handleDrop:ae,handleEventUpdate:t=>{e.updateEvent(t.id,t)},handleEventDelete:t=>{e.deleteEvent(t)},customDetailPanelContent:n,customEventDetailDialog:a,calendarRef:o,allDayRowRef:F,switcherMode:s,isMobile:u,isTouch:g,setDraftEvent:T,setIsDrawerOpen:E,ALL_DAY_HEIGHT:Y,HOUR_HEIGHT:O,FIRST_HOUR:L,LAST_HOUR:$}),r.jsx(ha,{app:e,currentDate:S,visibleMonth:M,currentDayEvents:Z,selectedEvent:p,setSelectedEvent:y,handleMonthChange:H,handleDateSelect:se,switcherMode:s}),r.jsx(h,{isOpen:C,onClose:()=>{E(!1),T(null)},onSave:t=>{l.find(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),E(!1),T(null)},draftEvent:k,app:e})]})},Ma={enableDrag:!0,enableResize:!0,enableCreate:!0,showMiniCalendar:!0,showAllDay:!0,scrollToCurrentTime:!0,hourHeight:72,firstHour:0,lastHour:24,dragConfig:{supportedViews:[exports.ViewType.DAY],enableAllDayCreate:!0},eventsConfig:{enableAutoRecalculate:!0,enableValidation:!0},viewConfig:{showMiniCalendar:!0,showAllDay:!0,scrollToCurrentTime:!0}},Ia=({app:e,weekDaysLabels:t,mobileWeekDaysLabels:n,weekDates:a,currentWeekStart:o,gridWidth:s,allDayAreaHeight:l,organizedAllDaySegments:i,allDayLabelText:d,isMobile:c,isTouch:u,calendarRef:g,allDayRowRef:m,topFrozenContentRef:h,ALL_DAY_HEIGHT:f,HOUR_HEIGHT:v,FIRST_HOUR:p,dragState:y,isDragging:x,handleMoveStart:b,handleResizeStart:D,handleEventUpdate:w,handleEventDelete:C,newlyCreatedEventId:E,setNewlyCreatedEventId:k,selectedEventId:T,setSelectedEventId:j,detailPanelEventId:S,setDetailPanelEventId:N,handleCreateAllDayEvent:M,handleDragOver:I,handleDrop:R,customDetailPanelContent:H,customEventDetailDialog:O,events:P,setDraftEvent:L,setIsDrawerOpen:$})=>{const A={flexShrink:0};return r.jsxs("div",{className:"flex flex-none border-b border-gray-200 dark:border-gray-700 relative z-10",children:[r.jsxs("div",{className:"w-12 md:w-20 shrink-0 bg-white dark:bg-gray-900 z-20 flex flex-col",children:[r.jsx("div",{className:"flex-1 border-b border-gray-200 dark:border-gray-700"}),r.jsx("div",{className:"flex items-center justify-end p-1 text-[10px] md:text-xs font-medium text-gray-500 dark:text-gray-400 select-none",style:{minHeight:`${l}px`},children:d})]}),r.jsx("div",{className:"flex-1 overflow-x-hidden overflow-y-auto relative",style:{scrollbarGutter:"stable"},children:r.jsxs("div",{ref:h,className:"flex flex-col",style:{width:s,minWidth:"100%"},children:[r.jsx("div",{className:"df-week-header flex border-b border-gray-200 dark:border-gray-700",style:{marginRight:"-50px",paddingRight:"50px"},children:t.map((e,t)=>r.jsx("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 "+(c?"flex-col gap-0":""),style:A,children:c?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"text-[11px] leading-tight text-gray-500 font-medium",children:n[t]}),r.jsx("div",{className:`${We} w-7 h-7 text-base font-medium ${a[t].isToday?nt:""}`,children:a[t].date})]}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"inline-flex items-center justify-center text-sm mt-1 mr-1",children:e}),r.jsx("div",{className:`${We} ${a[t].isToday?nt:""}`,children:a[t].date})]})},t))}),r.jsx("div",{className:`${Xe} border-none`,ref:m,style:{minHeight:`${l}px`},children:r.jsxs("div",{className:"df-all-day-content flex flex-1 relative",style:{minHeight:`${l}px`},children:[t.map((e,n)=>{const a=new Date(o);return a.setDate(o.getDate()+n),r.jsx("div",{className:"df-all-day-cell flex-1 border-r border-gray-200 dark:border-gray-700 relative "+(c&&n===t.length-1?"border-r-0":""),style:Object.assign({minHeight:`${l}px`},A),onMouseDown:e=>null==M?void 0:M(e,n),onDoubleClick:e=>null==M?void 0:M(e,n),onDragOver:I,onDrop:e=>{R(e,a,void 0,!0)}},`allday-${n}`)}),r.jsx("div",{className:"absolute inset-0 pointer-events-none",children:i.map(t=>r.jsx(Ta,{event:t.event,segment:t,segmentIndex:t.row,isAllDay:!0,isMultiDay:!0,allDayHeight:f,calendarRef:g,isBeingDragged:x&&(null==y?void 0:y.eventId)===t.event.id&&"move"===(null==y?void 0:y.mode),hourHeight:v,firstHour:p,onMoveStart:b,onResizeStart:D,onEventUpdate:w,onEventDelete:C,newlyCreatedEventId:E,onDetailPanelOpen:()=>k(null),selectedEventId:T,detailPanelEventId:S,onEventSelect:t=>{const n=!1!==e.getReadOnlyConfig().viewable,a=e.state.readOnly;if((c||u)&&t&&n&&!a){const e=P.find(e=>e.id===t);if(e)return L(e),void $(!0)}j(t)},onEventLongPress:e=>{(c||u)&&j(e)},onDetailPanelToggle:e=>N(e),customDetailPanelContent:H,customEventDetailDialog:O,app:e,isMobile:c,enableTouch:u},t.id))})]})})]})})]})},Ra=({app:e,timeSlots:n,weekDaysLabels:a,currentWeekStart:o,currentWeekEvents:s,eventLayouts:l,gridWidth:i,isMobile:d,isTouch:c,scrollerRef:u,timeGridRef:g,leftFrozenContentRef:m,calendarRef:h,handleScroll:f,handleCreateStart:v,handleTouchStart:p,handleTouchEnd:y,handleTouchMove:x,handleDragOver:b,handleDrop:D,dragState:w,isDragging:C,handleMoveStart:E,handleResizeStart:k,handleEventUpdate:T,handleEventDelete:j,newlyCreatedEventId:S,setNewlyCreatedEventId:N,selectedEventId:M,setSelectedEventId:I,detailPanelEventId:R,setDetailPanelEventId:H,customDetailPanelContent:O,customEventDetailDialog:P,events:L,setDraftEvent:$,setIsDrawerOpen:A,isCurrentWeek:z,currentTime:Y,HOUR_HEIGHT:V,FIRST_HOUR:F,LAST_HOUR:W})=>{const Z={flexShrink:0},U=t.useRef(e.state.highlightedEventId);return r.jsxs("div",{className:"flex flex-1 overflow-hidden relative",children:[r.jsx("div",{className:"w-12 md:w-20 shrink-0 overflow-hidden relative bg-white dark:bg-gray-900 z-10",children:r.jsxs("div",{ref:m,children:[n.map((e,t)=>r.jsx("div",{className:Ue,children:r.jsx("div",{className:`${Be} text-[10px] md:text-[12px]`,children:0===t?"":e.label})},t)),r.jsx("div",{className:"relative",children:r.jsx("div",{className:`${Be} text-[10px] md:text-[12px]`,children:"00:00"})}),z&&Y&&(()=>{const e=Y,t=e.getHours()+e.getMinutes()/60;if(t<F||t>W)return null;const n=(t-F)*V;return r.jsx("div",{className:"absolute left-0 w-full z-20 pointer-events-none flex items-center justify-end",style:{top:`${n}px`,transform:"translateY(-50%)"},children:r.jsx("div",{className:Ge,children:ee(t)})})})()]})}),r.jsx("div",{ref:u,className:"flex-1 overflow-auto relative calendar-content snap-x snap-mandatory",onScroll:f,children:r.jsxs("div",{ref:g,className:"relative flex",style:{width:i,minWidth:"100%"},children:[z&&Y&&(()=>{const e=Y,t=e.getHours()+e.getMinutes()/60;if(t<F||t>W)return null;const n=e.getDay(),o=0===n?6:n-1,s=(t-F)*V;return r.jsxs("div",{className:qe,style:{top:`${s}px`,width:"100%",height:0,zIndex:20},children:[r.jsx("div",{className:"flex items-center w-0"}),r.jsx("div",{className:"flex flex-1",children:a.map((e,t)=>r.jsx("div",{className:"flex-1 flex items-center",children:r.jsx("div",{className:"h-0.5 w-full relative "+(t===o?"bg-primary":"bg-primary/30"),style:{zIndex:9999},children:t===o&&0!==o&&r.jsx("div",{className:"absolute w-2 h-2 bg-primary rounded-full",style:{top:"-3px",left:"-4px"}})})},t))})]})})(),r.jsxs("div",{className:"grow relative",children:[n.map((e,t)=>r.jsx("div",{className:_e,children:a.map((n,s)=>{const l=new Date(o);return l.setDate(o.getDate()+s),r.jsx("div",{className:"df-time-grid-cell flex-1 relative border-r border-gray-200 dark:border-gray-700 select-none snap-start "+(d&&s===a.length-1?"border-r-0":""),style:Z,onDoubleClick:t=>{null==v||v(t,s,e.hour)},onTouchStart:t=>p(t,s,e.hour),onTouchEnd:y,onTouchMove:x,onDragOver:b,onDrop:t=>{D(t,l,e.hour)},onContextMenu:e=>d&&e.preventDefault()},`${t}-${s}`)})},t)),r.jsx("div",{className:`${st} flex`,children:a.map((e,t)=>r.jsx("div",{className:`flex-1 relative ${d&&t===a.length-1?"":"border-r"} border-gray-200 dark:border-gray-700`,style:Z},`24-${t}`))}),a.map((t,n)=>{const a=ge(n,s),i=[];return a.forEach(e=>{const t=ya(e,o);if(t.length>0){const a=t.find(e=>e.dayIndex===n);a&&i.push({event:e,segmentInfo:Object.assign(Object.assign({},a),{dayIndex:n})})}else i.push({event:e})}),s.forEach(e=>{if(e.allDay||e.day===n)return;const t=ya(e,o).find(e=>e.dayIndex===n);t&&i.push({event:e,segmentInfo:Object.assign(Object.assign({},t),{dayIndex:n})})}),r.jsx("div",{className:"absolute top-0 pointer-events-none",style:{left:`calc(${100/7*n}%)`,width:100/7+"%",height:"100%"},children:i.map(({event:t,segmentInfo:a})=>{const o=l.get(n),s=null==o?void 0:o.get(t.id);return r.jsx(Ta,{event:t,layout:s,calendarRef:h,isBeingDragged:C&&(null==w?void 0:w.eventId)===t.id&&"move"===(null==w?void 0:w.mode),hourHeight:V,firstHour:F,onMoveStart:E,onResizeStart:k,onEventUpdate:T,onEventDelete:j,newlyCreatedEventId:S,onDetailPanelOpen:()=>N(null),selectedEventId:M,detailPanelEventId:R,onEventSelect:t=>{const n=!1!==e.getReadOnlyConfig().viewable,a=e.state.readOnly;if((d||c)&&t&&n&&!a){const e=L.find(e=>e.id===t);if(e)return $(e),void A(!0)}I(t),e.state.highlightedEventId&&(e.highlightEvent(null),U.current=null)},onEventLongPress:e=>{(d||c)&&I(e)},onDetailPanelToggle:e=>H(e),customDetailPanelContent:O,customEventDetailDialog:P,multiDaySegmentInfo:a,app:e,isMobile:d,enableTouch:c},a?`${t.id}-seg-${n}`:t.id)})},`events-day-${n}`)})]})]})})]})},Ha=({app:e,customDetailPanelContent:n,customEventDetailDialog:a,calendarRef:o})=>{const{t:s,getWeekDaysLabels:l,locale:i}=Ne(),d=e.getCurrentDate(),c=e.getEvents(),{screenSize:u}=Sn(),g="desktop"!==u,m="mobile"===u?48:80,h=t.useRef(null),[f,v]=t.useState(!1);t.useEffect(()=>{v("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const p=e.getCustomMobileEventRenderer()||Wn,y=t.useMemo(()=>Sa(d),[d]),[x,b]=t.useState(null),[D,w]=t.useState(null),[C,E]=t.useState(null),[k,T]=t.useState(null),[j,S]=t.useState(!1),[N,M]=t.useState(null),I=t.useRef(null),{HOUR_HEIGHT:R,FIRST_HOUR:H,LAST_HOUR:O,TIME_COLUMN_WIDTH:L,ALL_DAY_HEIGHT:$}=ra,z=t.useRef(null),Y=t.useRef(null),V=t.useRef(null),F=t.useRef(null),W=t.useMemo(()=>((e,t)=>{const n=new Date(t);return n.setDate(t.getDate()+6),n.setHours(23,59,59,999),e.filter(e=>{const a=A(e.start);a.setHours(0,0,0,0);const r=A(e.end);return r.setHours(23,59,59,999),r>=t&&a<=n}).map(e=>{const n=A(e.start),a=Math.floor((n.getTime()-t.getTime())/864e5),r=Math.max(0,Math.min(6,a));return Object.assign(Object.assign({},e),{day:r})})})(c,y),[c,y]),Z=t.useRef(e.state.highlightedEventId);t.useEffect(()=>{if(e.state.highlightedEventId!==Z.current)if(e.state.highlightedEventId){E(e.state.highlightedEventId);const t=W.find(t=>t.id===e.state.highlightedEventId);if(t&&!t.allDay){const e=U(t.start),n=Y.current;if(n){const t=(e-H)*R;requestAnimationFrame(()=>{n.scrollTo({top:Math.max(0,t-100),behavior:"smooth"})})}}}else E(null);Z.current=e.state.highlightedEventId},[e.state.highlightedEventId,W,H,R]);const _=t.useMemo(()=>((e,t)=>{const n=pa(e,t).filter(e=>e.event.allDay);n.sort((e,t)=>{if(e.startDayIndex!==t.startDayIndex)return e.startDayIndex-t.startDayIndex;const n=e.endDayIndex-e.startDayIndex;return t.endDayIndex-t.startDayIndex-n});const a=[];return n.forEach(e=>{let t=0,n=!1;for(;!n;)a.some(n=>n.row===t&&!(e.endDayIndex<n.startDayIndex||e.startDayIndex>n.endDayIndex))?t++:n=!0;a.push(Object.assign(Object.assign({},e),{row:t}))}),a})(W,y),[W,y]),q=t.useMemo(()=>{if(0===_.length)return $;const e=Math.max(..._.map(e=>e.row));return $+e*$},[_,$]),G=t.useMemo(()=>((e,t)=>{const n=new Map;for(let a=0;a<7;a++){const r=[];e.forEach(e=>{if(e.allDay)return;const n=ya(e,t);if(n.length>0){const o=n.find(e=>e.dayIndex===a);if(o){const n=o.endHour>=24?23.99:o.endHour,s=Object.assign(Object.assign({},e),{start:P(B(me(t,a),o.startHour)),end:P(B(me(t,a),n)),day:a});r.push(s)}}else e.day===a&&r.push(e)});const o=aa.calculateDayEventLayouts(r,{viewType:"week"});n.set(a,o)}return n})(W,y),[W,y]),{handleMoveStart:X,handleCreateStart:K,handleResizeStart:J,handleCreateAllDayEvent:Q,dragState:te,isDragging:ne}=ua(e,{calendarRef:o,allDayRowRef:z,viewType:exports.ViewType.WEEK,onEventsUpdate:(t,n)=>{const a=t(W),r=new Set(a.map(e=>e.id)),o=W.filter(e=>!r.has(e.id)),s=new Set(W.map(e=>e.id)),l=a.filter(e=>!s.has(e.id)),i=a.filter(e=>{if(!s.has(e.id))return!1;const t=W.find(t=>t.id===e.id);return t&&(A(t.start).getTime()!==A(e.start).getTime()||A(t.end).getTime()!==A(e.end).getTime()||t.day!==e.day||U(t.start)!==U(e.start)||U(t.end)!==U(e.end)||t.title!==e.title)});o.forEach(t=>e.deleteEvent(t.id)),l.forEach(t=>e.addEvent(t)),i.forEach(t=>e.updateEvent(t.id,t,n))},onEventCreate:t=>{g?(M(t),S(!0)):(e.addEvent(t),T(t.id))},onEventEdit:()=>{},currentWeekStart:y,events:W,calculateNewEventLayout:(e,t,n)=>((e,t,n,a)=>{const r=new Date,o=new Date;r.setHours(Math.floor(t),t%1*60,0,0),o.setHours(Math.floor(n),n%1*60,0,0);const s={id:"-1",title:"Temp",day:e,start:P(r),end:P(o),calendarId:"blue",allDay:!1},l=[...a.filter(t=>t.day===e&&!t.allDay),s];return aa.calculateDayEventLayouts(l,{viewType:"week"}).get("-1")||null})(e,t,n,W),calculateDragLayout:(e,t,n,a)=>((e,t,n,a,r)=>{const o=r.map(r=>{if(r.id!==e.id)return r;const o=A(r.start),s=B(o,n),l=B(o,a),i=P(s),d=P(l);return Object.assign(Object.assign({},r),{day:t,start:i,end:d})}).filter(e=>e.day===t&&!e.allDay);return 0===o.length?null:aa.calculateDayEventLayouts(o,{viewType:"week"}).get(e.id)||null})(e,t,n,a,W),TIME_COLUMN_WIDTH:m,isMobile:g}),{handleDrop:ae,handleDragOver:re}=ga({app:e,onEventCreated:e=>{T(e.id)}}),oe=t.useMemo(()=>l(i,"short"),[i,l]),se=t.useMemo(()=>{if(!g)return[];const e=i.split("-")[0].toLowerCase();return"zh"===e||"ja"===e?l(i,"narrow"):oe.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)})},[g,i,l,oe]),le=t.useMemo(()=>s("allDay"),[s]),ie=Array.from({length:24},(e,t)=>({hour:t+H,label:ee(t+H)})),de=t.useMemo(()=>{const e=new Date;return e.setHours(0,0,0,0),oe.map((t,n)=>{const a=new Date(y);a.setDate(y.getDate()+n);const r=new Date(a);return r.setHours(0,0,0,0),{date:a.getDate(),month:a.toLocaleString(i,{month:"short"}),fullDate:new Date(a),isToday:r.getTime()===e.getTime()}})},[y,oe,i]),ce=t=>{e.updateEvent(t.id,t)},ue=t=>{e.deleteEvent(t)},ge=t.useMemo(()=>{const e=new Date,t=Sa(e);return y.getTime()===t.getTime()},[y]);t.useEffect(()=>{b(new Date);const e=setInterval(()=>b(new Date),6e4);return()=>clearInterval(e)},[]);const he=g?"175%":"100%";return r.jsxs("div",{className:"df-calendar relative flex flex-col bg-white dark:bg-gray-900 w-full overflow-hidden h-full select-none df-week-view",children:[r.jsx(fa,{calendar:e,viewType:exports.ViewType.WEEK,currentDate:d,onPrevious:()=>e.goToPrevious(),onNext:()=>e.goToNext(),onToday:()=>e.goToToday()}),r.jsx(Ia,{app:e,weekDaysLabels:oe,mobileWeekDaysLabels:se,weekDates:de,currentWeekStart:y,gridWidth:he,allDayAreaHeight:q,organizedAllDaySegments:_,allDayLabelText:le,isMobile:g,isTouch:f,calendarRef:o,allDayRowRef:z,topFrozenContentRef:V,ALL_DAY_HEIGHT:$,HOUR_HEIGHT:R,FIRST_HOUR:H,dragState:te,isDragging:ne,handleMoveStart:X,handleResizeStart:J,handleEventUpdate:ce,handleEventDelete:ue,newlyCreatedEventId:k,setNewlyCreatedEventId:T,selectedEventId:C,setSelectedEventId:E,detailPanelEventId:D,setDetailPanelEventId:w,handleCreateAllDayEvent:Q,handleDragOver:re,handleDrop:ae,customDetailPanelContent:n,customEventDetailDialog:a,events:c,setDraftEvent:M,setIsDrawerOpen:S}),r.jsx(Ra,{app:e,timeSlots:ie,weekDaysLabels:oe,currentWeekStart:y,currentWeekEvents:W,eventLayouts:G,gridWidth:he,isMobile:g,isTouch:f,scrollerRef:Y,timeGridRef:h,leftFrozenContentRef:F,calendarRef:o,handleScroll:e=>{const{scrollTop:t,scrollLeft:n}=e.currentTarget;V.current&&(V.current.style.transform=`translateX(${-n}px)`),F.current&&(F.current.style.transform=`translateY(${-t}px)`)},handleCreateStart:K,handleTouchStart:(e,t,n)=>{if(!g&&!f)return;const a=e.touches[0],r=a.clientX,o=a.clientY,s=e.currentTarget;I.current=setTimeout(()=>{null==K||K({preventDefault:()=>{},stopPropagation:()=>{},touches:[{clientX:r,clientY:o}],changedTouches:[{clientX:r,clientY:o}],target:s,currentTarget:s,cancelable:!0},t,n)},500)},handleTouchEnd:()=>{I.current&&(clearTimeout(I.current),I.current=null)},handleTouchMove:()=>{I.current&&(clearTimeout(I.current),I.current=null)},handleDragOver:re,handleDrop:ae,dragState:te,isDragging:ne,handleMoveStart:X,handleResizeStart:J,handleEventUpdate:ce,handleEventDelete:ue,newlyCreatedEventId:k,setNewlyCreatedEventId:T,selectedEventId:C,setSelectedEventId:E,detailPanelEventId:D,setDetailPanelEventId:w,customDetailPanelContent:n,customEventDetailDialog:a,events:c,setDraftEvent:M,setIsDrawerOpen:S,isCurrentWeek:ge,currentTime:x,HOUR_HEIGHT:R,FIRST_HOUR:H,LAST_HOUR:O}),r.jsx(p,{isOpen:j,onClose:()=>{S(!1),M(null)},onSave:t=>{c.find(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),S(!1),M(null)},draftEvent:N,app:e})]})},Oa={enableDrag:!0,enableResize:!0,enableCreate:!0,showWeekends:!0,showAllDay:!0,startOfWeek:1,scrollToCurrentTime:!0,hourHeight:72,firstHour:0,lastHour:24,dragConfig:{supportedViews:[exports.ViewType.WEEK],enableAllDayCreate:!0},eventsConfig:{enableAutoRecalculate:!0,enableValidation:!0},viewConfig:{showWeekends:!0,showAllDay:!0,startOfWeek:1,scrollToCurrentTime:!0}},Pa=t.memo(({currentMonth:e,currentYear:a,newlyCreatedEventId:o,screenSize:s,isScrolling:l,isDragging:i,item:d,weekHeight:c,events:u,dragState:g,calendarRef:m,onEventUpdate:h,onEventDelete:f,onMoveStart:v,onCreateStart:p,onResizeStart:y,onDetailPanelOpen:x,onMoreEventsClick:b,onChangeView:D,onSelectDate:C,selectedEventId:E,onEventSelect:k,onEventLongPress:T,detailPanelEventId:j,onDetailPanelToggle:S,customDetailPanelContent:N,customEventDetailDialog:M,onCalendarDrop:I,onCalendarDragOver:R,app:H,enableTouch:O})=>{const{t:P,locale:L}=Ne(),[$,z]=t.useState(!1),Y=t.useRef(null),V=t.useRef(null),F=t.useRef(null),W=t.useMemo(()=>{const e=c-33;if(e<=0)return{maxSlots:0,maxSlotsWithMore:0};const t=e-20;return{maxSlots:Math.min(4,Math.floor(e/17)),maxSlotsWithMore:Math.min(4,Math.max(0,Math.floor(t/17)))}},[c]);t.useEffect(()=>l?(z(!0),Y.current&&(clearTimeout(Y.current),Y.current=null),()=>{Y.current&&(clearTimeout(Y.current),Y.current=null)}):$?(Y.current=setTimeout(()=>{z(!1),Y.current=null},100),()=>{Y.current&&(clearTimeout(Y.current),Y.current=null)}):void 0,[l,$]);const{weekData:Z}=d,B=Z.days.find(e=>1===e.day),_=`${c}px`,q=t.useMemo(()=>pa(u,Z.startDate),[u,Z.startDate]),G=t.useMemo(()=>((e,t)=>{const a=[],r=new Date(t);return r.setDate(r.getDate()+6),r.setHours(23,59,59,999),e.forEach(e=>{if(!e.start||!e.end)return void w.warn("Event missing start or end date:",e);const o=A(e.start),s=A(e.end),l=new Date(o);l.setHours(0,0,0,0);const i=new Date(s);i.setHours(0,0,0,0);let d=new Date(i);if(!e.allDay&&0===s.getHours()&&0===s.getMinutes()&&0===s.getSeconds()){const e=s.getTime()-o.getTime();e>0&&e<864e5&&(d=new Date(i),d.setDate(d.getDate()-1))}const c=l.toDateString()!==d.toDateString();if(!c||e.allDay)if(c&&e.allDay){let l=new Date(o);l<t&&(l=new Date(t),l.setHours(0,0,0,0));const i=s>r?r:s;for(;l<=i;){const t=n.Temporal.PlainDate.from({year:l.getFullYear(),month:l.getMonth()+1,day:l.getDate()});a.push(Object.assign(Object.assign({},e),{start:t,end:t,day:l.getDay()})),l.setDate(l.getDate()+1)}}else a.push(Object.assign(Object.assign({},e),{start:e.start,end:e.end,day:o.getDay()}))}),a})(u,Z.startDate),[u,Z.startDate]),X=t.useMemo(()=>(e=>{const t=[...e].sort((e,t)=>{const n=e.endDayIndex-e.startDayIndex+1,a=t.endDayIndex-t.startDayIndex+1;return e.startDayIndex>t.startDayIndex?1:n!==a?a-n:e.startDayIndex-t.startDayIndex}),n=[];t.forEach(e=>{let t=0,a=!1;for(;!a;)n.some(n=>{var a;const r=Math.abs((null!==(a=n.yPosition)&&void 0!==a?a:0)-t)<16,o=!(e.endDayIndex<n.startDayIndex||e.startDayIndex>n.endDayIndex);return r&&o})?t+=16:a=!0;n.push(Object.assign(Object.assign({},e),{yPosition:t}))});const a=[];return n.forEach(e=>{var t;const n=Math.floor((null!==(t=e.yPosition)&&void 0!==t?t:0)/16);a[n]||(a[n]=[]),a[n].push(e)}),a.forEach(e=>{e.sort((e,t)=>e.startDayIndex-t.startDayIndex)}),a})(q),[q]),K=t.useMemo(()=>{const e=Array(7).fill(0);return X.forEach((t,n)=>{t.forEach(t=>{for(let a=t.startDayIndex;a<=t.endDayIndex;a++)e[a]=Math.max(e[a],n+1)})}),e},[X]),J=t.useMemo(()=>{const e=Array.from({length:7},()=>new Set);return X.forEach((t,n)=>{t.forEach(t=>{for(let a=t.startDayIndex;a<=t.endDayIndex;a++)a>=0&&a<7&&e[a].add(n)})}),e},[X]),Q=t.useMemo(()=>{const e=X.flat();for(let t=0;t<Z.days.length;t++){const n=Z.days[t],a=G.filter(e=>{if(!e.start||!e.end)return A(e.start).toDateString()===n.date.toDateString();const t=A(e.start),a=A(e.end);if(!e.allDay){if(!(0!==a.getHours()||0!==a.getMinutes()||0!==a.getSeconds())){const e=a.getTime()-t.getTime();if(e>0&&e<864e5)return t.toDateString()===n.date.toDateString()}}return t.toDateString()===n.date.toDateString()||a.toDateString()===n.date.toDateString()}).filter(t=>{if(!t.allDay)return!0;return!e.some(e=>e.originalEventId===t.id)}),r=J[t],o=K[t]-1;let s=0;for(let e=0;e<=o;e++)r.has(e)||s++;if(o+1+Math.max(0,a.length-s)>W.maxSlots)return W.maxSlotsWithMore}return W.maxSlots},[Z.days,G,X,K,J,W.maxSlots,W.maxSlotsWithMore]),ee=t.useMemo(()=>Math.max(0,17*X.length),[X]),te=(t,n)=>{var l;const d=t.date.toLocaleDateString(L,{month:L.startsWith("zh")||L.startsWith("ja")?"short":"long"})===e&&t.year===a;var c;const u=(e=>[...e].sort((e,t)=>e.allDay!==t.allDay?e.allDay?-1:1:e.allDay&&t.allDay?0:U(e.start)-U(t.start)))((c=t.date,G.filter(e=>{if(!e.start||!e.end)return A(e.start).toDateString()===c.toDateString();const t=A(e.start),n=A(e.end);if(!e.allDay&&0===n.getHours()&&0===n.getMinutes()&&0===n.getSeconds()){const e=n.getTime()-t.getTime();if(e>0&&e<864e5)return t.toDateString()===c.toDateString()}return t.toDateString()===c.toDateString()||n.toDateString()===c.toDateString()}))),w=X.flat(),$=u.filter(e=>{if(!e.allDay)return!0;return!w.some(t=>t.originalEventId===e.id)}),z=J[n],Y=(null!==(l=K[n])&&void 0!==l?l:0)-1,Z=[];for(let e=0;e<=Y;e++)z.has(e)||Z.push(e);const B=$.length,q=Math.max(0,B-Z.length),Q=Math.max(Y+1,0)+q,ee=Q>W.maxSlots,te=ee?W.maxSlotsWithMore:W.maxSlots,ne=Z.filter(e=>e<te).length,ae=Math.max(0,te-Math.max(Y+1,0)),re=Math.min(B,ne+ae),oe=$.slice(0,re),se=B-re,le=[];let ie=0;const de=Math.min(te,Q);for(let e=0;e<de;e++)if(z.has(e))le.push(r.jsx("div",{className:"shrink-0",style:{height:"17px",minHeight:"17px"}},`placeholder-layer-${e}-${t.date.getTime()}`));else if(ie<oe.length){const e=oe[ie];le.push(r.jsx(Ta,{event:e,isAllDay:!!e.allDay,isMonthView:!0,isBeingDragged:i&&g.eventId===e.id&&"move"===g.mode,calendarRef:m,hourHeight:72,firstHour:0,onEventUpdate:h,onEventDelete:f,onMoveStart:v,onResizeStart:y,onDetailPanelOpen:x,onEventSelect:k,onEventLongPress:T,newlyCreatedEventId:o,selectedEventId:E,detailPanelEventId:j,onDetailPanelToggle:S,customDetailPanelContent:N,customEventDetailDialog:M,app:H,isMobile:"desktop"!==s,enableTouch:O},`${e.id}-${e.day}-${U(e.start)}-${ie}`)),ie++}return r.jsxs("div",{className:`\n df-month-day-cell relative flex flex-col border-r border-gray-200 dark:border-gray-700 last:border-r-0\n ${d?"text-gray-800 dark:text-gray-100":"text-gray-400 dark:text-gray-600"}\n `,style:{height:_},"data-date":(ce=t.date,`${ce.getFullYear()}-${String(ce.getMonth()+1).padStart(2,"0")}-${String(ce.getDate()).padStart(2,"0")}`),onDoubleClick:e=>null==p?void 0:p(e,t.date),onTouchStart:e=>{if("mobile"!==s&&!O)return;const n=e.touches[0],a=n.clientX,r=n.clientY;F.current={x:a,y:r},V.current=setTimeout(()=>{null==p||p(e,t.date),V.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},onTouchMove:e=>{if(V.current&&F.current){const t=Math.abs(e.touches[0].clientX-F.current.x),n=Math.abs(e.touches[0].clientY-F.current.y);(t>10||n>10)&&(clearTimeout(V.current),V.current=null)}},onTouchEnd:()=>{V.current&&(clearTimeout(V.current),V.current=null),F.current=null},onDragOver:R,onDrop:e=>null==I?void 0:I(e,t.date),children:[r.jsxs("div",{className:"df-month-date-number-container flex items-center justify-between px-2 h-[33px] relative z-20",children:[r.jsx("div",{className:"flex-1"}),r.jsx("div",{className:"flex items-center",children:r.jsx("span",{className:`\n df-month-date-number inline-flex items-center justify-center h-6 min-w-6 rounded-full text-sm font-medium whitespace-nowrap px-1\n ${t.isToday?"bg-primary text-primary-foreground":d?"text-gray-900 dark:text-gray-100":"text-gray-400 dark:text-gray-600"}\n `,children:1===t.day&&"desktop"===s?t.date.toLocaleDateString(L,{month:"short",day:"numeric"}):t.day})})]}),r.jsxs("div",{className:"flex-1 overflow-hidden px-1",children:[le,ee&&r.jsxs("div",{className:"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 text-center md:text-left font-medium md:font-normal relative z-20 bg-white dark:bg-gray-900",onClick:e=>{e.stopPropagation(),b?b(t.date):(null==C||C(t.date),null==D||D(exports.ViewType.DAY))},children:["+",se," ",r.jsx("span",{className:"hidden md:inline",children:P("more")})]})]})]},`day-${t.date.getTime()}`);var ce},ne=t.useMemo(()=>B?B.date.toLocaleDateString(L,{month:"long",year:"numeric"}):"",[B,L]);return r.jsxs("div",{className:"relative select-none border-b border-gray-200 dark:border-gray-700",style:{height:_},children:[B&&r.jsx("div",{className:`\n df-month-title absolute top-10 left-0 z-30 bg-white/50 dark:bg-gray-900/50 py-2 px-2 duration-300\n ${$?"opacity-100 pointer-events-auto":"opacity-0 pointer-events-none"}\n `,style:{transition:"opacity 0.5s ease",maxWidth:"fit-content"},children:r.jsx("span",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:ne})}),r.jsx("div",{className:"h-full flex flex-col",children:r.jsxs("div",{className:"calendar-week relative h-full",children:[r.jsx("div",{className:"grid grid-cols-7 h-full",children:Z.days.map((e,t)=>te(e,t))}),X.length>0&&r.jsx("div",{className:"absolute left-0 right-0 pointer-events-none",style:{top:"33px",height:`${ee}px`,zIndex:10},children:X.slice(0,Q).map((e,t)=>r.jsx("div",{className:"absolute inset-0",children:e.map(e=>r.jsx(Ta,{event:e.event,isAllDay:!!e.event.allDay,segment:e,segmentIndex:t,isMonthView:!0,isMultiDay:!0,calendarRef:m,hourHeight:72,firstHour:0,onEventUpdate:h,onEventDelete:f,onMoveStart:v,onResizeStart:y,isBeingDragged:i&&g.eventId===e.event.id&&"move"===g.mode,isBeingResized:i&&g.eventId===e.event.id&&"resize"===g.mode,newlyCreatedEventId:o,onDetailPanelOpen:x,selectedEventId:E,onEventSelect:k,onEventLongPress:T,detailPanelEventId:j,onDetailPanelToggle:S,customDetailPanelContent:N,customEventDetailDialog:M,app:H,isMobile:"desktop"!==s,enableTouch:O},e.id))},`layer-${t}`))})]})})]})});Pa.displayName="WeekComponent";const La=({app:e,customDetailPanelContent:n,customEventDetailDialog:a,calendarRef:o})=>{const{getWeekDaysLabels:s,getMonthLabels:l,locale:i}=Ne(),d=e.getCurrentDate(),c=e.getEvents(),u=e.getCalendars().map(e=>e.id+e.colors.lineColor).join("-"),g=t.useRef(null),m=t.useMemo(()=>{const e=g.current;return e&&e.length===c.length&&e.every((e,t)=>e===c[t])?e:(g.current=c,c)},[c]),h=t.useMemo(()=>{const e=new Map,t=e=>{const t=new Date(e);t.setHours(0,0,0,0);const n=t.getDay(),a=0===n?-6:1-n;return t.setDate(t.getDate()+a),t.setHours(0,0,0,0),t},n=(t,n)=>{const a=e.get(t);a?a.push(n):e.set(t,[n])};return m.forEach(e=>{if(!e.start)return;const a=A(e.start),r=e.end?A(e.end):a,o=new Date(a);o.setHours(0,0,0,0);const s=new Date(r);s.setHours(0,0,0,0);let l=new Date(s);if(!e.allDay){0!==r.getHours()||0!==r.getMinutes()||0!==r.getSeconds()||0!==r.getMilliseconds()||l.setDate(l.getDate()-1)}l<o&&(l=new Date(o));const i=t(o),d=t(l);let c=i.getTime();const u=d.getTime();for(;c<=u;){n(c,e);const t=new Date(c);t.setDate(t.getDate()+7),t.setHours(0,0,0,0),c=t.getTime()}}),e},[m]),{screenSize:f}=Sn(),[v,p]=t.useState(!1);t.useEffect(()=>{p("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const y=e.getCustomMobileEventRenderer()||Wn,[x,b]=t.useState(119),[D,w]=t.useState(!1),C=t.useRef(x),E=t.useRef([]),[k,T]=t.useState(null),[j,S]=t.useState(!1),[N,M]=t.useState(null),[I,R]=t.useState(null),H=t.useRef(e.state.highlightedEventId);t.useEffect(()=>{e.state.highlightedEventId?R(e.state.highlightedEventId):H.current&&R(null),H.current=e.state.highlightedEventId},[e.state.highlightedEventId]);const[O,P]=t.useState(null),L=t.useMemo(()=>{const e=d.getDay(),t=d.getDate()-e+(0===e?-6:1),n=new Date(d);return n.setDate(t),n.setHours(0,0,0,0),n},[d]),{handleMoveStart:$,handleCreateStart:z,handleResizeStart:Y,dragState:V,isDragging:F}=ua(e,{calendarRef:o,viewType:exports.ViewType.MONTH,onEventsUpdate:(t,n)=>{const a=t(m),r=new Set(a.map(e=>e.id)),o=m.filter(e=>!r.has(e.id)),s=new Set(m.map(e=>e.id)),l=a.filter(e=>!s.has(e.id)),i=a.filter(e=>{if(!s.has(e.id))return!1;const t=m.find(t=>t.id===e.id);return t&&(A(t.start).getTime()!==A(e.start).getTime()||A(t.end).getTime()!==A(e.end).getTime()||t.day!==e.day||U(t.start)!==U(e.start)||U(t.end)!==U(e.end)||t.title!==e.title||(null==t?void 0:t.start)!==(null==e?void 0:e.start)||(null==t?void 0:t.end)!==(null==e?void 0:e.end))});o.forEach(t=>e.deleteEvent(t.id)),l.forEach(t=>e.addEvent(t)),i.forEach(t=>e.updateEvent(t.id,t,n))},onEventCreate:t=>{"desktop"!==f?(M(t),S(!0)):e.addEvent(t)},onEventEdit:e=>{T(e.id)},currentWeekStart:L,events:m}),{handleDrop:W,handleDragOver:Z}=ga({app:e,onEventCreated:e=>{T(e.id)}}),B=t.useMemo(()=>s(i,"short"),[i,s]),{currentMonth:_,currentYear:q,isScrolling:G,virtualData:X,scrollElementRef:K,handleScroll:J,handlePreviousMonth:Q,handleNextMonth:ee,handleToday:te,setScrollTop:ne}=Nn({currentDate:d,weekHeight:x,onCurrentMonthChange:(t,n)=>{const a=i.startsWith("zh")||i.startsWith("ja"),r=l(i,a?"short":"long").indexOf(t);r>=0&&e.setVisibleMonth(new Date(n,r,1))},initialWeeksToLoad:156,locale:i,isEnabled:D}),ae=t.useRef(0),[re,oe]=t.useState(0),se=t.useMemo(()=>re-6*x,[re,x]),{visibleWeeks:le,startIndex:ie}=t.useMemo(()=>{const{visibleItems:e,displayStartIndex:t}=X,n=e.findIndex(e=>e.index===t);if(-1===n)return E.current.length>0?{visibleWeeks:E.current,startIndex:ae.current}:{visibleWeeks:[],startIndex:t};const a=e.slice(n,n+8);return a.length>=6&&(E.current=a,ae.current=t),{visibleWeeks:a,startIndex:t}},[X]),de=t.useMemo(()=>ie*x,[ie,x]),ce=t.useMemo(()=>{const e=X.totalHeight,t=ie*x+16*x+se;return Math.max(0,e-t)},[X.totalHeight,ie,x,se]);t.useEffect(()=>{const e=K.current;if(!e)return;const t=new ResizeObserver(t=>{for(const n of t){const t=n.contentRect.height;if(oe(t),!D&&t>0){const n=Math.max(80,Math.floor(t/6));if(n!==C.current){const t=e.scrollTop;if(t>0){const a=Math.round(t/C.current)*n;e.scrollTop=a,ne(a)}}b(n),C.current=n,requestAnimationFrame(()=>{w(!0)})}}});return t.observe(e),()=>{t.disconnect()}},[K,D,ne]),t.useEffect(()=>{const e=window.innerHeight-150,t=Math.max(80,Math.floor(e/6));b(t)},[]);const ue=t=>{e.updateEvent(t.id,t)},ge=t=>{e.deleteEvent(t)},me=t=>{e.changeView(t)};return r.jsxs("div",{className:ze,children:[r.jsx(fa,{calendar:e,viewType:exports.ViewType.MONTH,currentDate:d,customTitle:i.startsWith("zh")||i.startsWith("ja")?`${q}年${_}`:`${_} ${q}`,onPrevious:()=>{e.goToPrevious(),Q()},onNext:()=>{e.goToNext(),ee()},onToday:()=>{e.goToToday(),te()}}),r.jsx("div",{className:"df-week-header-row sticky top-0 z-10 bg-white dark:bg-gray-900 border-b border-gray-200 dark:border-gray-700",children:r.jsx("div",{className:"grid grid-cols-7 px-2",children:B.map((e,t)=>r.jsx("div",{className:"text-right text-gray-500 dark:text-gray-400 text-sm py-2 pr-2 select-none",children:e},t))})}),r.jsxs("div",{ref:K,className:Ze,style:{scrollSnapType:"y mandatory",overflow:"hidden auto",visibility:D?"visible":"hidden"},onScroll:J,children:[r.jsx("div",{style:{height:de}}),le.map((t,s)=>{var l;const i=null!==(l=h.get(t.weekData.startDate.getTime()))&&void 0!==l?l:[],d=5===s?Object.assign(Object.assign({},t),{height:t.height+se}):t;return r.jsx(Pa,{item:d,weekHeight:x,currentMonth:_,currentYear:q,screenSize:f,isScrolling:G,calendarRef:o,events:i,onEventUpdate:ue,onEventDelete:ge,onMoveStart:$,onCreateStart:z,onResizeStart:Y,isDragging:F,dragState:V,newlyCreatedEventId:k,onDetailPanelOpen:()=>T(null),onMoreEventsClick:e.onMoreEventsClick,onChangeView:me,onSelectDate:e.selectDate,selectedEventId:I,onEventSelect:t=>{const n=!1!==e.getReadOnlyConfig().viewable;if(("desktop"!==f||v)&&t&&n){const e=m.find(e=>e.id===t);if(e)return M(e),void S(!0)}R(t)},onEventLongPress:e=>{("desktop"!==f||v)&&R(e)},detailPanelEventId:O,onDetailPanelToggle:P,customDetailPanelContent:n,customEventDetailDialog:a,onCalendarDrop:W,onCalendarDragOver:Z,calendarSignature:u,app:e,enableTouch:v},`week-${t.weekData.startDate.getTime()}`)}),r.jsx("div",{style:{height:ce}})]}),r.jsx(y,{isOpen:j,onClose:()=>{S(!1),M(null)},onSave:t=>{m.find(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),S(!1),M(null)},draftEvent:N,app:e})]})},$a={enableDrag:!0,enableResize:!1,enableCreate:!0,showOtherMonth:!0,weekHeight:120,showWeekNumbers:!1,enableVirtualScroll:!0,initialWeeksToLoad:156,dragConfig:{supportedViews:[exports.ViewType.MONTH],enableAllDayCreate:!1},eventsConfig:{enableAutoRecalculate:!0,enableValidation:!0},virtualScrollConfig:{weekHeight:120,initialWeeksToLoad:156,enableVirtualScroll:!0,enableKeyboardNavigation:!0,supportedViews:[exports.ViewType.MONTH]},viewConfig:{showOtherMonth:!0,weekHeight:120,showWeekNumbers:!1,enableVirtualScroll:!0}};const Aa=t.memo(({date:e,isToday:t,locale:n,onSelectDate:a,onCreateStart:o,onMoreEventsClick:s,moreCount:l=0})=>{const{t:i}=Ne(),d=e.getDate(),c=1===d,u=e.toLocaleDateString(n,{month:"short"}).toUpperCase(),g=`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`;return r.jsxs("div",{className:`\n relative flex flex-col border-r border-b border-gray-100 dark:border-gray-800\n ${c?"border-l-2 border-l-primary dark:border-l-primary":""}\n overflow-hidden bg-white dark:bg-gray-900 select-none\n `,style:{aspectRatio:"1/1"},onClick:()=>a(e),onDoubleClick:t=>null==o?void 0:o(t,e),"data-date":g,children:[r.jsxs("div",{className:"flex items-center px-1 py-1 shrink-0 h-6",children:[c&&r.jsx("span",{className:"text-[9px] font-bold text-primary-foreground bg-primary px-1 py-0.5 rounded-sm leading-none",children:u}),r.jsx("span",{className:"text-[10px] font-medium ml-auto "+(t?"bg-primary text-primary-foreground rounded-full w-5 h-5 flex items-center justify-center":"text-gray-700 dark:text-gray-300"),children:d})]}),l>0&&r.jsx("div",{className:"absolute bottom-0.5 left-1 z-20",children:r.jsxs("span",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 cursor-pointer hover:underline",onClick:t=>{t.stopPropagation(),null==s||s(e)},children:["+",l," ",i("more")]})})]})});Aa.displayName="YearDayCell";const za=({segment:e,columnsPerRow:n,isDragging:a,isSelected:s,onMoveStart:l,onResizeStart:i,onEventSelect:d,detailPanelEventId:c,onDetailPanelToggle:u,newlyCreatedEventId:g,onDetailPanelOpen:m,customDetailPanelContent:h,customEventDetailDialog:f,app:v,calendarRef:p})=>{const{event:y,startCellIndex:x,endCellIndex:b,visualRowIndex:D,isFirstSegment:w,isLastSegment:C}=e,E=t.useRef(null),k=t.useRef(null),[T,j]=t.useState(null),S=c===e.id,N=!(null==v?void 0:v.state.readOnly),M=x/n*100,I=(b-x+1)/n*100,R=y.calendarId||"blue",H=s?K(R):G(R),O=s?"#fff":X(R),P=J(R),L=!!y.allDay,$=L?va(y):null,A=18*D,z=()=>{var t;const n=null===(t=E.current)||void 0===t?void 0:t.getBoundingClientRect();if(n){const e=200,t=300;let a=n.bottom+10,r=n.left;a+e>window.innerHeight&&(a=n.top-e-10),r+t>window.innerWidth&&(r=window.innerWidth-t-10),j({top:a,left:r,eventHeight:n.height,eventMiddleY:n.top+n.height/2})}null==u||u(e.id)};t.useEffect(()=>{g===y.id&&!S&&w&&setTimeout(()=>{z(),null==m||m()},50)},[g,y.id,S,m,w]);const Y=e=>{const t="left"===e,n=t?w:C;return y.allDay&&n&&i&&N?r.jsx("div",{className:`resize-handle absolute ${t?"left-0":"right-0"} top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20`,onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),i(e,y,t?"left":"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}):null},V=b-x+1;return r.jsxs(r.Fragment,{children:[r.jsxs("div",{ref:E,className:"df-year-event absolute z-30 text-[11px] px-1 overflow-hidden whitespace-nowrap cursor-pointer transition-colors group",style:{left:`calc(${M}% + 2px)`,top:`${A}px`,height:"16px",backgroundColor:H,color:O,opacity:a?.6:1,width:`calc(${I}% - 4px)`,pointerEvents:a?"none":"auto",borderRadius:w&&C?"0.25rem":w?"0.25rem 0 0 0.25rem":C?"0 0.25rem 0.25rem 0":"0"},"data-segment-days":V,"data-event-id":y.id,onMouseDown:e=>{e.stopPropagation(),l&&l(e,y)},onClick:e=>{e.preventDefault(),e.stopPropagation(),d&&d(y.id)},onDoubleClick:e=>{e.preventDefault(),e.stopPropagation(),z()},onTouchStart:e=>{e.stopPropagation(),d&&d(y.id),l&&l(e,y)},title:y.title,children:[Y("left"),(()=>{if(y.allDay){const t=()=>e.isFirstSegment?y.title:"···";return r.jsxs("div",{className:"df-year-event-content flex items-center min-w-0 w-full pointer-events-auto h-full",children:[e.isFirstSegment&&va(y)&&r.jsx("div",{className:"df-year-event-icon shrink-0 mr-1",children:r.jsx("div",{className:"rounded-full p-0.5 text-white flex items-center justify-center",style:{backgroundColor:J(R),width:"12px",height:"12px"},children:va(y)})}),r.jsx("div",{className:"flex-1 min-w-0",children:r.jsx("div",{className:"df-year-event-title font-medium text-[11px] leading-none whitespace-nowrap overflow-hidden",style:{maskImage:"linear-gradient(to right, black 70%, transparent 100%)",WebkitMaskImage:"linear-gradient(to right, black 70%, transparent 100%)"},children:t()})}),e.isLastSegment&&!e.isFirstSegment&&r.jsx("div",{className:"shrink-0 ml-1 text-white/80 dark:text-white/90",children:r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-white/60 dark:bg-white/80"})})]})}const t=e.isFirstSegment?y.title:"";return r.jsxs("div",{className:"df-year-event-content w-full h-full flex items-center overflow-hidden gap-1 pointer-events-auto",children:[!L&&r.jsx("span",{style:{backgroundColor:P},className:"df-year-event-indicator inline-block w-0.75 h-3 shrink-0 rounded-full"}),L&&$&&r.jsx("div",{className:"df-year-event-icon shrink-0 flex items-center justify-center opacity-80 scale-75",children:$}),r.jsx("span",{className:"df-year-event-title w-full block font-medium whitespace-nowrap overflow-hidden leading-none",style:{maskImage:"linear-gradient(to right, black 70%, transparent 100%)",WebkitMaskImage:"linear-gradient(to right, black 70%, transparent 100%)"},children:t})]})})(),Y("right")]}),(()=>{if(!S||!p)return null;const e=()=>{null==u||u(null),d&&d(null)};if(f){const t=f,n={event:y,isOpen:S,isAllDay:L,onClose:e,app:v,onEventUpdate:e=>null==v?void 0:v.updateEvent(e.id,e),onEventDelete:e=>null==v?void 0:v.deleteEvent(e)};if("undefined"==typeof window||"undefined"==typeof document)return null;const a=document.body;return a?o.createPortal(r.jsx(t,Object.assign({},n)),a):null}return T?h?r.jsx(Da,{event:y,position:T,panelRef:k,isAllDay:L,onClose:e,contentRenderer:h,onEventUpdate:e=>null==v?void 0:v.updateEvent(e.id,e),onEventDelete:e=>null==v?void 0:v.deleteEvent(e),eventVisibility:"visible",calendarRef:p,selectedEventElementRef:E}):r.jsx(ba,{event:y,position:T,panelRef:k,isAllDay:L,onClose:e,app:v,onEventUpdate:e=>null==v?void 0:v.updateEvent(e.id,e),onEventDelete:e=>null==v?void 0:v.deleteEvent(e),eventVisibility:"visible",calendarRef:p,selectedEventElementRef:E}):null})()]})},Ya=t.memo(({rowDays:e,events:n,columnsPerRow:a,app:o,calendarRef:s,locale:l,isDragging:i,dragState:d,onMoveStart:c,onResizeStart:u,onCreateStart:g,selectedEventId:m,onEventSelect:h,onMoreEventsClick:f,newlyCreatedEventId:v,onDetailPanelOpen:p,detailPanelEventId:y,onDetailPanelToggle:x,customDetailPanelContent:b,customEventDetailDialog:D})=>{const w=new Date;w.setHours(0,0,0,0);const C=t.useMemo(()=>function(e,t,n){if(0===t.length)return[];const a=t[0],r=t[t.length-1],o=new Date(a.getFullYear(),a.getMonth(),a.getDate()).getTime(),s=new Date(r.getFullYear(),r.getMonth(),r.getDate(),23,59,59,999).getTime(),l=e.filter(e=>{if(!e.start)return!1;const t=A(e.start),n=e.end?A(e.end):t,a=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),r=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime();return a<=s&&r>=o});l.sort((e,t)=>{const n=A(e.start).getTime(),a=e.end?A(e.end).getTime():n,r=A(t.start).getTime(),o=a-n,s=(t.end?A(t.end).getTime():r)-r;return o!==s?s-o:n-r});const i=[],d=[];return l.forEach(e=>{const r=A(e.start),l=e.end?A(e.end):r,c=new Date(r.getFullYear(),r.getMonth(),r.getDate()).getTime(),u=new Date(l.getFullYear(),l.getMonth(),l.getDate()).getTime();let g=-1,m=-1;const h=Math.round((c-o)/864e5);g=h>=0?h:0;const f=Math.round((u-o)/864e5);m=f<t.length?f:t.length-1,g=Math.max(0,Math.min(g,n-1)),m=Math.max(0,Math.min(m,n-1));const v=c>=o,p=u<=s;let y=0;for(;;){let e=!1;d[y]||(d[y]=[]);for(let t=g;t<=m;t++)if(d[y][t]){e=!0;break}if(!e){for(let e=g;e<=m;e++)d[y][e]=!0;break}y++}i.push({id:`${e.id}_${a.getTime()}`,event:e,startCellIndex:g,endCellIndex:m,isFirstSegment:v,isLastSegment:p,visualRowIndex:y})}),i}(n,e,a),[n,e,a]),{visibleSegments:E,moreCounts:k}=t.useMemo(()=>{const t=new Array(e.length).fill(0);C.forEach(n=>{const a=Math.max(0,n.startCellIndex),r=Math.min(e.length-1,n.endCellIndex);for(let e=a;e<=r;e++)t[e]++});const n=[],a=new Array(e.length).fill(0);return C.forEach(r=>{let o=!0;const s=Math.max(0,r.startCellIndex),l=Math.min(e.length-1,r.endCellIndex);for(let e=s;e<=l;e++){const n=t[e]>3?1:2;if(r.visualRowIndex>n){o=!1;break}}if(o)n.push(r);else for(let e=s;e<=l;e++)a[e]++}),{visibleSegments:n,moreCounts:a}},[C,e.length]);return r.jsxs("div",{className:"relative w-full",style:{display:"grid",gridTemplateColumns:`repeat(${a}, 1fr)`},children:[e.map((e,t)=>{const n=e.getTime()===w.getTime();return r.jsx(Aa,{date:e,isToday:n,locale:l,onSelectDate:e=>{o.selectDate(e)},onCreateStart:g,onMoreEventsClick:f,moreCount:k[t]},e.getTime())}),r.jsx("div",{className:"absolute inset-0 pointer-events-none",style:{top:26,bottom:0,left:0,right:0},children:r.jsx("div",{className:"relative w-full h-full",children:E.map(e=>r.jsx("div",{className:"pointer-events-auto",children:r.jsx(za,{segment:e,columnsPerRow:a,isDragging:i&&d.eventId===e.event.id,isSelected:m===e.event.id,onMoveStart:c,onResizeStart:u,onEventSelect:h,onDetailPanelToggle:x,newlyCreatedEventId:v,onDetailPanelOpen:p,calendarRef:s,app:o,detailPanelEventId:y,customDetailPanelContent:b,customEventDetailDialog:D})},e.id))})})]})});Ya.displayName="YearRowComponent";const Va=({app:e,calendarRef:a,customDetailPanelContent:o,customEventDetailDialog:s,config:l})=>{var i;const{locale:d}=Ne(),c=e.getCurrentDate(),u=c.getFullYear(),g=e.getEvents(),m=t.useRef(null),[h,f]=t.useState(()=>"undefined"!=typeof window?Math.max(1,Math.floor(window.innerWidth/80)):7),[v,p]=t.useState(!1),[y,x]=t.useState(null),[b,D]=t.useState(null),[w,C]=t.useState(null);t.useEffect(()=>{const e=e=>{const t=e.target,n=t.closest("[data-event-id]"),a=t.closest("[data-event-detail-panel]");n||a||(x(null),D(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),t.useEffect(()=>{const e=m.current;if(!e)return;const t=new ResizeObserver(e=>{const t=e[0].contentRect.width,n=Math.floor(t/80);f(Math.max(1,n)),p(!0)});return t.observe(e),()=>t.disconnect()},[]);const{handleMoveStart:E,handleResizeStart:k,handleCreateStart:T,dragState:j,isDragging:S}=ua(e,{calendarRef:a,viewType:exports.ViewType.YEAR,onEventsUpdate:(t,n)=>{t(g).forEach(t=>{const a=g.find(e=>e.id===t.id);!a||a.start===t.start&&a.end===t.end||e.updateEvent(t.id,t,n)})},currentWeekStart:new Date,events:g,onEventCreate:t=>{e.addEvent(t)},onEventEdit:e=>{C(e.id)}}),N=null!==(i=null==l?void 0:l.showTimedEventsInYearView)&&void 0!==i&&i,M=t.useCallback((t,a)=>{if(N)null==T||T(t,a);else{const t=n.Temporal.PlainDate.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate()}),r={id:`event-${Date.now()}`,title:"",start:t,end:t,allDay:!0};e.addEvent(r),C(r.id)}},[N,T,e]),I=t.useMemo(()=>{const e=[],t=new Date(u,0,1),n=new Date(u,11,31),a=new Date(t);for(;a<=n;)e.push(new Date(a)),a.setDate(a.getDate()+1);return e},[u]),R=t.useMemo(()=>function(e,t){const n=[];for(let a=0;a<e.length;a+=t)n.push(e.slice(a,a+t));return n}(I,h),[I,h]),H=t.useMemo(()=>{const e=new Date(u,0,1),t=new Date(u,11,31,23,59,59);return g.filter(n=>{if(!n.start)return!1;if(!N&&!n.allDay)return!1;const a=A(n.start),r=n.end?A(n.end):a;return a<=t&&r>=e})},[g,u,N]);return r.jsxs("div",{className:ze,children:[r.jsx(fa,{calendar:e,viewType:exports.ViewType.YEAR,currentDate:c,customTitle:d.startsWith("zh")||d.startsWith("ja")?`${u}年`:`${u}`,onPrevious:()=>{const t=new Date(c);t.setFullYear(t.getFullYear()-1),e.setCurrentDate(t)},onNext:()=>{const t=new Date(c);t.setFullYear(t.getFullYear()+1),e.setCurrentDate(t)},onToday:()=>{e.goToToday()}}),r.jsx("div",{ref:m,className:`${Ze}`,style:{overflow:"hidden auto"},children:r.jsx("div",{className:"w-full flex flex-col border-t border-l border-gray-100 dark:border-gray-800",style:{opacity:v?1:0,transition:"opacity 0.2s ease"},children:R.map((t,n)=>r.jsx(Ya,{rowDays:t,events:H,columnsPerRow:h,app:e,calendarRef:a,locale:d,isDragging:S,dragState:j,onMoveStart:E,onResizeStart:k,onCreateStart:M,selectedEventId:y,onEventSelect:x,onMoreEventsClick:e.onMoreEventsClick,newlyCreatedEventId:w,onDetailPanelOpen:()=>C(null),detailPanelEventId:b,onDetailPanelToggle:D,customDetailPanelContent:o,customEventDetailDialog:s},n))})})]})};function Fa(e,t,n){const a=new Date(n,t,1),r=new Date(n,t+1,0).getDate(),o=a.getDay(),s=a.getTime(),l=new Date(n,t,r,23,59,59,999).getTime(),i=e.filter(e=>{if(!e.start)return!1;const t=A(e.start),n=e.end?A(e.end):t,a=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),r=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime();return a<=l&&r>=s});i.sort((e,t)=>{const n=A(e.start).getTime(),a=e.end?A(e.end).getTime():n,r=A(t.start).getTime(),o=a-n,s=(t.end?A(t.end).getTime():r)-r;return o!==s?s-o:n-r});const d=[],c=[];i.forEach(e=>{const a=A(e.start),r=e.end?A(e.end):a,i=new Date(Math.max(a.getTime(),s)),u=new Date(Math.min(r.getTime(),l)),g=i.getDate(),m=u.getDate(),h=o+(g-1),f=o+(m-1),v=a.getMonth()===t&&a.getFullYear()===n,p=r.getMonth()===t&&r.getFullYear()===n;let y=0;for(;;){let e=!1;c[y]||(c[y]=[]);for(let t=h;t<=f;t++)if(c[y][t]){e=!0;break}if(!e){for(let e=h;e<=f;e++)c[y][e]=!0;break}y++}d.push({id:`${e.id}_month_${t}`,event:e,startCellIndex:h,endCellIndex:f,isFirstSegment:v,isLastSegment:p,visualRowIndex:y,monthIndex:t})});const u=d.length>0?Math.max(...d.map(e=>e.visualRowIndex)):-1;return{segments:d,maxVisualRow:u}}const Wa=({app:e,calendarRef:a,customDetailPanelContent:o,customEventDetailDialog:s,config:l})=>{var i;const{locale:d,getWeekDaysLabels:c}=Ne(),u=e.getCurrentDate(),g=u.getFullYear(),m=e.getEvents(),h=new Date;h.setHours(0,0,0,0);const f=t.useRef(null),v=t.useRef(null),p=t.useRef(null),[y,x]=t.useState(0),[b,D]=t.useState(0),[w,C]=t.useState(null),[E,k]=t.useState(null),[T,j]=t.useState(null);t.useEffect(()=>{const e=e=>{const t=e.target,n=t.closest("[data-event-id]"),a=t.closest("[data-event-detail-panel]");n||a||(C(null),k(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const S=t.useMemo(()=>{let e=0;for(let t=0;t<12;t++){const n=new Date(g,t,1),a=new Date(g,t+1,0).getDate(),r=n.getDay()+a;r>e&&(e=r)}return e},[g]),{handleMoveStart:N,handleResizeStart:M,handleCreateStart:I,dragState:R,isDragging:H}=ua(e,{calendarRef:a,viewType:exports.ViewType.YEAR,onEventsUpdate:(t,n)=>{t(m).forEach(t=>{const a=m.find(e=>e.id===t.id);!a||a.start===t.start&&a.end===t.end||e.updateEvent(t.id,t,n)})},currentWeekStart:new Date,events:m,onEventCreate:t=>{e.addEvent(t)},onEventEdit:e=>{j(e.id)}}),O=null!==(i=null==l?void 0:l.showTimedEventsInYearView)&&void 0!==i&&i,P=t.useCallback((t,a)=>{if(O)null==I||I(t,a);else{const t=n.Temporal.PlainDate.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate()}),r={id:`event-${Date.now()}`,title:"",start:t,end:t,allDay:!0};e.addEvent(r),j(r.id)}},[O,I,e]),L=t.useMemo(()=>{const e=c(d,"short"),t=[e[6],...e.slice(0,6)].map(e=>{if(d.startsWith("zh"))return e.charAt(e.length-1);const t=e.substring(0,2);return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}),n=[];for(let e=0;e<S;e++)n.push(t[e%7]);return n},[d,c,S]),$=t.useMemo(()=>{const e=new Date(g,0,1),t=new Date(g,11,31,23,59,59);return m.filter(n=>{if(!n.start)return!1;if(!O&&!n.allDay)return!1;const a=A(n.start),r=n.end?A(n.end):a;return a<=t&&r>=e})},[m,g,O]),z=t.useMemo(()=>{const e=[];for(let t=0;t<12;t++){const n=new Date(g,t,1),a=new Date(g,t+1,0).getDate(),r=n.getDay(),o=[];for(let e=0;e<r;e++)o.push(null);for(let e=1;e<=a;e++)o.push(new Date(g,t,e));for(;o.length<S;)o.push(null);const s=n.toLocaleDateString(d,{month:"short"}),l=s.charAt(0).toUpperCase()+s.slice(1).toLowerCase(),{segments:i,maxVisualRow:c}=Fa($,t,g),u=c+1,m=Math.max(60,20+18*u);e.push({monthIndex:t,monthName:l,days:o,eventSegments:i,minHeight:m})}return e},[g,d,S,$]),Y=t.useCallback(e=>{const t=e.currentTarget;f.current&&(f.current.scrollLeft=t.scrollLeft),v.current&&(v.current.scrollTop=t.scrollTop)},[]);t.useEffect(()=>{const e=()=>{if(p.current){const e=p.current,t=e.offsetHeight-e.clientHeight,n=e.offsetWidth-e.clientWidth;D(e=>e!==t?t:e),x(e=>e!==n?n:e)}},t=p.current;if(!t)return;e();const n=new ResizeObserver(()=>{e()});return n.observe(t),()=>{n.disconnect()}},[z]);return r.jsxs("div",{className:"h-full bg-white dark:bg-gray-900 overflow-hidden select-none",style:{display:"grid",gridTemplateColumns:"3rem 1fr",gridTemplateRows:"auto auto 1fr"},children:[r.jsx("div",{className:"col-span-2",children:r.jsx(fa,{calendar:e,viewType:exports.ViewType.YEAR,currentDate:u,customTitle:d.startsWith("zh")||d.startsWith("ja")?`${g}年`:`${g}`,onPrevious:()=>{const t=new Date(u);t.setFullYear(t.getFullYear()-1),e.setCurrentDate(t)},onNext:()=>{const t=new Date(u);t.setFullYear(t.getFullYear()+1),e.setCurrentDate(t)},onToday:()=>{e.goToToday()}})}),r.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 border-r border-b border-gray-200 dark:border-gray-800 z-30"}),r.jsx("div",{ref:f,className:"overflow-hidden bg-gray-50 dark:bg-gray-900 border-b border-gray-200 dark:border-gray-800",children:r.jsxs("div",{className:"flex",style:{minWidth:`calc(1352px + ${y}px)`},children:[r.jsx("div",{className:"grid flex-1",style:{gridTemplateColumns:`repeat(${S}, minmax(0, 1fr))`,minWidth:"1352px"},children:L.map((e,t)=>{const n=t%7,a=0===n||6===n;return r.jsx("div",{className:"text-center py-2 text-[10px] font-bold tracking-wider border-r border-gray-200 dark:border-gray-700 text-gray-500 dark:text-gray-400 "+(a?"df-year-view-weekend-header":""),children:e},t)})}),y>0&&r.jsx("div",{className:"shrink-0 bg-gray-50 dark:bg-gray-900",style:{width:`${y}px`}})]})}),r.jsx("div",{ref:v,className:"overflow-hidden bg-white dark:bg-gray-900 border-r border-gray-200 dark:border-gray-700",children:r.jsxs("div",{className:"flex flex-col",children:[z.map(e=>r.jsx("div",{className:"flex items-center justify-center border-b border-gray-200 dark:border-gray-700 font-bold text-[10px] text-gray-500 dark:text-gray-400",style:{height:`${e.minHeight}px`},children:e.monthName},e.monthIndex)),b>0&&r.jsx("div",{className:"shrink-0 bg-white dark:bg-gray-900",style:{height:`${b}px`}})]})}),r.jsx("div",{ref:p,className:"overflow-auto",onScroll:Y,children:r.jsx("div",{className:"flex flex-col",style:{minWidth:"1352px"},children:z.map(t=>r.jsxs("div",{className:"relative",style:{height:`${t.minHeight}px`},children:[r.jsx("div",{className:"grid absolute inset-0 z-0",style:{gridTemplateColumns:`repeat(${S}, minmax(0, 1fr))`},children:t.days.map((t,n)=>{const a=n%7,o=0===a||6===a;if(!t)return r.jsx("div",{className:"bg-gray-50/80 dark:bg-gray-800/40 border-r border-b border-gray-200 dark:border-gray-700 "+(o?"df-year-view-weekend-cell":"")},`empty-${n}`);const s=(e=>e.getTime()===h.getTime())(t),l=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`;return r.jsx("div",{"data-date":l,className:`\n relative flex items-start justify-end p-0.5 border-r border-b border-gray-200 dark:border-gray-700\n cursor-pointer hover:bg-blue-100 dark:hover:bg-primary/20 transition-colors\n ${o?"bg-blue-50 dark:bg-blue-900/30 df-year-view-weekend-cell":""}\n `,onClick:()=>e.selectDate(t),onDoubleClick:e=>P(e,t),children:r.jsx("span",{className:`\n text-[10px] font-medium w-5 h-5 flex items-center justify-center rounded-full\n ${s?"bg-primary text-primary-foreground font-bold shadow-sm":"text-gray-700 dark:text-gray-300"}\n `,children:t.getDate()})},t.getTime())})}),t.eventSegments.length>0&&r.jsx("div",{className:"absolute inset-0 pointer-events-none z-20",style:{top:20},children:r.jsx("div",{className:"relative w-full h-full",children:t.eventSegments.map(t=>r.jsx("div",{className:"pointer-events-auto",children:r.jsx(za,{segment:t,columnsPerRow:S,isDragging:H&&R.eventId===t.event.id,isSelected:w===t.event.id,onMoveStart:N,onResizeStart:M,onEventSelect:C,onDetailPanelToggle:k,newlyCreatedEventId:T,onDetailPanelOpen:()=>j(null),calendarRef:a,app:e,detailPanelEventId:E,customDetailPanelContent:o,customEventDetailDialog:s})},t.id))})})]},t.monthIndex))})})]})},Za=e=>{var t;return"fixed-week"===((null===(t=e.config)||void 0===t?void 0:t.mode)||"year-canvas")?r.jsx(Wa,Object.assign({},e,{config:e.config})):r.jsx(Va,Object.assign({},e,{config:e.config}))},Ua={enableDrag:!1,enableResize:!1,enableCreate:!1,enableVirtualScroll:!0,showDebugInfo:!1,eventsConfig:{enableAutoRecalculate:!1,enableValidation:!0},viewConfig:{enableVirtualScroll:!0,showDebugInfo:!1}},Ba={enableAutoRecalculate:!0,enableValidation:!0,defaultEvents:[],maxEventsPerDay:50};exports.CalendarApp=we,exports.CalendarEvent=Ta,exports.CalendarPicker=Vt,exports.CalendarRegistry=y,exports.DayFlowCalendar=e=>{const{calendar:t,customMessages:n}=e,a=t.app;return r.jsx(Bn,{locale:a.state.locale,messages:n,children:r.jsx(_n,Object.assign({},e))})},exports.DefaultEventDetailDialog=on,exports.DefaultEventDetailPanel=ba,exports.EventDetailPanelWithContent=Da,exports.EventLayoutCalculator=aa,exports.LOCALES=I,exports.LocaleContext=Se,exports.TIME_STEP=Q,exports.ThemeProvider=Rn,exports.ViewHeader=fa,exports.addDays=Z,exports.buildParseRegExp=Bt,exports.calculateDayIndex=fe,exports.capitalize=Ee,exports.conditionalTheme=(e,t,n)=>e?t:n,exports.convertDateEvent=function(e,t,n,a,r=!1,o){return Dn(Object.assign({id:e,title:t,start:n,end:a,allDay:r},o))},exports.convertDateEventWithTimeZone=function(e,t,n,a,r,o){return wn(Object.assign({id:e,title:t,start:n,end:a,timeZone:r},o))},exports.createAllDayEvent=function(e,t,n,a){return Dn(Object.assign({id:e,title:t,start:n,end:n,allDay:!0},a))},exports.createDateWithHour=B,exports.createDayView=(e={})=>{const n=Object.assign(Object.assign({},Ma),e),a=e=>t.createElement(qn,{viewType:exports.ViewType.DAY,originalComponent:Na,app:e.app,config:n,className:"day-view-factory",customDetailPanelContent:e.customDetailPanelContent,customEventDetailDialog:e.customEventDetailDialog,calendarRef:e.calendarRef,switcherMode:e.switcherMode,meta:e.meta});return a.displayName="DayViewAdapter",{type:exports.ViewType.DAY,component:a,config:n}},exports.createDragPlugin=function(e={}){const t=Object.assign({enableDrag:!0,enableResize:!0,enableCreate:!0,enableAllDayCreate:!0,supportedViews:[exports.ViewType.DAY,exports.ViewType.WEEK,exports.ViewType.MONTH,exports.ViewType.YEAR]},e),n={getConfig:()=>t,updateConfig:e=>{Object.assign(t,e)},isViewSupported:e=>t.supportedViews.includes(e)};return{name:"drag",config:t,install:()=>{w.log("Drag plugin installed - providing drag capabilities")},api:n}},exports.createEvent=Dn,exports.createEventWithDate=(e,t)=>{var n,a;const r=me(t,null!==(n=e.day)&&void 0!==n?n:0),o=null!==(a=e.allDay)&&void 0!==a&&a;return Object.assign(Object.assign({},e),{start:he(r,o),end:he(r,o)})},exports.createEventWithRealDate=(e,t)=>{var n,a;const r=new Date(t);r.setDate(t.getDate()+(null!==(n=e.day)&&void 0!==n?n:0));const o=null!==(a=e.allDay)&&void 0!==a&&a;return Object.assign(Object.assign({},e),{start:he(r,o),end:he(r,o)})},exports.createEvents=function(e){return e.map(e=>Dn(e))},exports.createEventsPlugin=function(e={}){const t=Object.assign(Object.assign({},Ba),e);let n;const a={getAll:()=>n.getAllEvents(),getById:e=>n.getAllEvents().find(t=>t.id===e),add:e=>{if(t.enableValidation){const t=a.validateEvent(e);if(t.length>0)throw new Error(`Event validation failed: ${t.join(", ")}`)}if(t.maxEventsPerDay&&void 0!==e.day){if(a.getByDay(e.day,n.getCurrentDate()).length>=t.maxEventsPerDay)throw new Error(`Maximum events per day (${t.maxEventsPerDay}) exceeded`)}if(n.addEvent(e),t.enableAutoRecalculate){const e=r(n.getCurrentDate()),t=ve(n.getAllEvents(),e);n.state.events=t}},update:(e,o)=>{const s=a.getById(e);if(!s)throw new Error(`Event with id ${e} not found`);const l=Object.assign(Object.assign({},s),o);if(t.enableValidation){const e=a.validateEvent(l);if(e.length>0)throw new Error(`Event validation failed: ${e.join(", ")}`)}if(n.updateEvent(e,o),t.enableAutoRecalculate){const e=r(n.getCurrentDate()),t=ve(n.getAllEvents(),e);n.state.events=t}return n.getAllEvents().find(t=>t.id===e)},delete:e=>{n.deleteEvent(e)},getByDate:e=>n.getAllEvents().filter(t=>{const n=A(t.start);n.setHours(0,0,0,0);const a=new Date(e);return a.setHours(0,0,0,0),n.getTime()===a.getTime()}),getByDateRange:(e,t)=>n.getAllEvents().filter(n=>{const a=A(n.start),r=A(n.end);return a>=e&&a<=t||r>=e&&r<=t||a<=e&&r>=t}),getByDay:(e,t)=>n.getAllEvents().filter(t=>t.day===e),getAllDayEvents:(e,t)=>t.filter(t=>t.day===e&&t.allDay),recalculateEventDays:(e,t)=>ve(e,t),validateEvent:e=>{const t=[];return e.title&&""!==e.title.trim()||t.push("Event title is required"),e.start||t.push("Event start time is required"),e.end||t.push("Event end time is required"),e.start&&e.end&&!e.allDay&&e.start>=e.end&&t.push("Start time must be before end time"),e.id&&"string"!=typeof e.id&&t.push("Event ID must be a string"),t},filterEvents:(e,t)=>e.filter(t)};function r(e){const t=e.getDay(),n=e.getDate()-t+(0===t?-6:1),a=new Date(e);return a.setDate(n),a.setHours(0,0,0,0),a}return{name:"events",config:t,install:e=>{n=e,w.log("Events plugin installed - providing event management services")},api:a}},exports.createMonthView=(e={})=>{const n=Object.assign(Object.assign({},$a),e),a=e=>t.createElement(qn,{viewType:exports.ViewType.MONTH,originalComponent:La,app:e.app,config:n,className:"month-view-factory",customDetailPanelContent:e.customDetailPanelContent,customEventDetailDialog:e.customEventDetailDialog,calendarRef:e.calendarRef,switcherMode:e.switcherMode,meta:e.meta});return a.displayName="MonthViewAdapter",{type:exports.ViewType.MONTH,component:a,config:n}},exports.createTemporalWithHour=z,exports.createTimedEvent=function(e,t,n,a,r){return Dn(Object.assign({id:e,title:t,start:n,end:a},r))},exports.createTimezoneEvent=wn,exports.createTimezoneEvents=function(e){return e.map(e=>wn(e))},exports.createWeekView=(e={})=>{const n=Object.assign(Object.assign({},Oa),e),a=e=>t.createElement(qn,{viewType:exports.ViewType.WEEK,originalComponent:Ha,app:e.app,config:n,className:"week-view-factory",customDetailPanelContent:e.customDetailPanelContent,customEventDetailDialog:e.customEventDetailDialog,calendarRef:e.calendarRef,switcherMode:e.switcherMode,meta:e.meta});return a.displayName="WeekViewAdapter",{type:exports.ViewType.WEEK,component:a,config:n}},exports.createYearView=(e={})=>{const n=Object.assign(Object.assign({},Ua),e);e.mode&&(n.viewConfig=Object.assign(Object.assign({},n.viewConfig),{mode:e.mode}));const a=e=>t.createElement(qn,{viewType:exports.ViewType.YEAR,originalComponent:Za,app:e.app,config:n,className:"year-view-factory",customDetailPanelContent:e.customDetailPanelContent,customEventDetailDialog:e.customEventDetailDialog,calendarRef:e.calendarRef,meta:e.meta});return a.displayName="YearViewAdapter",{type:exports.ViewType.YEAR,component:a,config:n}},exports.dateToPlainDate=Ct,exports.dateToPlainDateTime=Et,exports.dateToZonedDateTime=kt,exports.daysBetween=function(e,t){const n=O(e)?e:e.toPlainDate(),a=O(t)?t:t.toPlainDate();return n.until(a).days},exports.daysDifference=W,exports.de=N,exports.downloadICS=Lt,exports.en=E,exports.es=M,exports.extractHourFromDate=U,exports.extractHourFromTemporal=function(e){return bt(e)?0:e.hour+e.minute/60},exports.formatDate=e=>{const t=e.year,n=e.month;return`${e.day} ${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][n-1]} ${t}`},exports.formatDateConsistent=pn,exports.formatDateToICSTimestamp=It,exports.formatEventTimeRange=te,exports.formatICSDate=Mt,exports.formatMonthYear=e=>`${["January","February","March","April","May","June","July","August","September","October","November","December"][e.getMonth()]} ${e.getFullYear()}`,exports.formatTemporal=Xt,exports.formatTime=ee,exports.fr=S,exports.generateDayData=ie,exports.generateICS=Pt,exports.generateUniKey=ye,exports.generateWeekData=de,exports.generateWeekRange=ue,exports.generateWeeksData=(e,t=3)=>{const n=5*t,{monday:a}=le(e),r=[],o=Math.floor(n/2),s=new Date(a);s.setDate(s.getDate()-7*o);for(let e=0;e<n;e++){const t=new Date(s);t.setDate(t.getDate()+7*e),r.push(de(t))}return r},exports.getAllDayEventsForDay=(e,t,n)=>t.filter(t=>{if(!t.allDay)return!1;if(!n)return t.day===e;const a=new Date(n);a.setDate(n.getDate()+e),a.setHours(0,0,0,0);const r=A(t.start);r.setHours(0,0,0,0);const o=A(t.end);return o.setHours(0,0,0,0),a>=r&&a<=o}),exports.getCurrentWeekDates=()=>{const e=new Date,t=new Date,n=e.getDay(),a=e.getDate()-n+(0===n?-6:1);return re.map((n,r)=>{const o=new Date(e);return o.setDate(a+r),{date:o.getDate(),month:o.toLocaleString("default",{month:"short"}),isToday:o.getDate()===t.getDate()&&o.getMonth()===t.getMonth()&&o.getFullYear()===t.getFullYear()}})},exports.getDateByDayIndex=me,exports.getDateObj=Cn,exports.getDayIndexByDate=(e,t)=>{const n=new Date(e);n.setHours(0,0,0,0);const a=new Date(t);a.setHours(0,0,0,0);const r=a.getTime()-n.getTime();return Math.floor(r/864e5)},exports.getEndOfDay=_,exports.getEndOfTemporal=F,exports.getEventBgColor=G,exports.getEventEndHour=ae,exports.getEventTextColor=X,exports.getEventsForDay=ge,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 a=A(e.start);return a>=t&&a<=n}).map(e=>{const n=fe(A(e.start),t);return Object.assign(Object.assign({},e),{day:n})})},exports.getIntlLabel=Ce,exports.getLineColor=J,exports.getMonthLabels=Te,exports.getMonthYearOfWeek=ce,exports.getPlainDate=function(e){return bt(e)?e:(Dt(e),e.toPlainDate())},exports.getSearchHeaderInfo=kn,exports.getSelectedBgColor=K,exports.getStartOfDay=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(0,0,0,0),t}return V(e)},exports.getStartOfTemporal=V,exports.getTestEvents=function(){const e=new Date,t=e.getDay(),a=new Date(e),r=0===t?-6:1-t;return a.setDate(e.getDate()+r),a.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 t=new Date(a);if(t.setDate(a.getDate()+e.day),e.allDay)return{id:e.id,title:e.title,start:n.Temporal.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}),end:n.Temporal.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}),allDay:!0,calendarId:e.calendarId,day:e.day};const r=Math.floor(e.startHour),o=Math.round(60*(e.startHour-r)),s=Math.floor(e.endHour),l=Math.round(60*(e.endHour-s));return{id:e.id,title:e.title,start:n.Temporal.ZonedDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:r,minute:o,timeZone:n.Temporal.Now.timeZoneId()}),end:n.Temporal.ZonedDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:s,minute:l,timeZone:n.Temporal.Now.timeZoneId()}),allDay:!1,calendarId:e.calendarId,day:e.day}})},exports.getWeekDaysLabels=ke,exports.getWeekRange=le,exports.getZoneId=qt,exports.groupSearchResults=Tn,exports.importICSFile=zt,exports.isDate=function(e){return e instanceof Date},exports.isDeepEqual=xe,exports.isEventEqual=pe,exports.isEventInWeek=(e,t)=>{const n=fe(e,t);return n>=0&&n<=6},exports.isMultiDayEvent=(e,t)=>!q(e,t),exports.isMultiDayTemporalEvent=function(e,t){return!Y(e,t)},exports.isPlainDate=bt,exports.isPlainDateTime=Dt,exports.isSameDay=q,exports.isSamePlainDate=Y,exports.isSameTemporal=function(e,t){const n=bt(e)?e:(Dt(e),e.toPlainDate()),a=bt(t)?t:(Dt(t),t.toPlainDate());return n.equals(a)},exports.isValidLocale=H,exports.isZonedDateTime=wt,exports.ja=T,exports.ko=j,exports.mergeClasses=(...e)=>e.filter(Boolean).join(" "),exports.mergeFormatTemplate=Zt,exports.monthNames=oe,exports.normalizeCssWidth=C,exports.normalizeDate=En,exports.normalizeLocale=R,exports.normalizeToZoned=Gt,exports.now=function(e=n.Temporal.Now.timeZoneId()){return n.Temporal.Now.zonedDateTimeISO(e)},exports.pad=Wt,exports.parseICS=Ht,exports.parseICSDate=Nt,exports.parseTemporalString=_t,exports.plainDateTimeToDate=function(e){return new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second,e.millisecond)},exports.plainDateToDate=function(e){return new Date(e.year,e.month-1,e.day)},exports.recalculateEventDays=ve,exports.resolveAppliedTheme=yn,exports.roundToTimeStep=ne,exports.setHourInTemporal=function(e,t){const n=Math.floor(t),a=Math.round(60*(t-n));return wt(e),e.with({hour:n,minute:a,second:0,millisecond:0})},exports.shortMonthNames=se,exports.t=je,exports.temporalToDate=function(e){if(bt(e))return new Date(e.year,e.month-1,e.day);if(Dt(e))return new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second,e.millisecond);const t=e.toInstant();return new Date(t.epochMilliseconds)},exports.themeClasses={container:"bg-white dark:bg-gray-900",card:"bg-white dark:bg-gray-800",sidebar:"bg-gray-50 dark:bg-gray-900",text:"text-gray-900 dark:text-gray-100",textMuted:"text-gray-500 dark:text-gray-400",textSubtle:"text-gray-600 dark:text-gray-300",textEmphasis:"text-gray-900 dark:text-white",border:"border-gray-200 dark:border-gray-700",borderLight:"border-gray-100 dark:border-gray-800",borderStrong:"border-gray-300 dark:border-gray-600",bgPrimary:"bg-white dark:bg-gray-900",bgSecondary:"bg-gray-50 dark:bg-gray-800",bgTertiary:"bg-gray-100 dark:bg-gray-700",bgMuted:"bg-gray-100 dark:bg-gray-800",hover:"hover:bg-gray-100 dark:hover:bg-gray-800",hoverSubtle:"hover:bg-gray-50 dark:hover:bg-gray-900",active:"bg-gray-200 dark:bg-gray-700",focus:"focus:ring-primary",input:"bg-white dark:bg-gray-700 border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100",inputFocus:"focus:border-primary focus:ring-primary",buttonPrimary:"bg-primary text-primary-foreground hover:bg-primary/90",buttonSecondary:"bg-gray-200 dark:bg-gray-700 text-gray-900 dark:text-gray-100 hover:bg-gray-300 dark:hover:bg-gray-600",buttonDanger:"bg-destructive text-destructive-foreground hover:bg-destructive/90",buttonSuccess:"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-200 hover:bg-blue-200 dark:hover:bg-blue-800",shadow:"shadow-sm dark:shadow-gray-900/50",shadowMd:"shadow-md dark:shadow-gray-900/50",shadowLg:"shadow-lg dark:shadow-gray-900/50",divider:"border-gray-200 dark:border-gray-700"},exports.themeCn=(e,t,n)=>`${e} ${t} ${n.split(" ").filter(Boolean).map(e=>`dark:${e}`).join(" ")}`.trim(),exports.today=function(e=n.Temporal.Now.timeZoneId()){return n.Temporal.Now.plainDateISO(e)},exports.updateEventDateAndDay=(e,t,a)=>{const r=me(a,t);return Object.assign(Object.assign({},e),{day:t,start:e.allDay?n.Temporal.PlainDate.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate()}):n.Temporal.ZonedDateTime.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate(),hour:r.getHours(),minute:r.getMinutes(),timeZone:n.Temporal.Now.timeZoneId()}),end:e.allDay?n.Temporal.PlainDate.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate()}):n.Temporal.ZonedDateTime.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate(),hour:r.getHours(),minute:r.getMinutes(),timeZone:n.Temporal.Now.timeZoneId()})})},exports.updateEventWithRealDate=(e,t,n)=>{var a;const r=new Date(n);r.setDate(n.getDate()+t);const o=null!==(a=e.allDay)&&void 0!==a&&a;return Object.assign(Object.assign({},e),{day:t,start:he(r,o),end:he(r,o)})},exports.useCalendarApp=function(e){const n=t.useMemo(()=>new we(e),[]),[a,r]=t.useState(n.state.currentView),[o,s]=t.useState(n.state.currentDate),[l,i]=t.useState(n.getEvents()),[d,c]=t.useState(n.getSidebarConfig()),[,u]=t.useState({}),g=t.useCallback(()=>{u({})},[]);t.useEffect(()=>{const e=n.changeView;n.changeView=t=>{e(t),r(t),g()};const t=n.setCurrentDate;n.setCurrentDate=e=>{t(e),s(new Date(e)),g()};const a=n.addEvent;n.addEvent=e=>{a(e),i([...n.getEvents()]),g()};const o=n.updateEvent;n.updateEvent=(e,t,a)=>{o(e,t,a),i([...n.getEvents()]),g()};const l=n.deleteEvent;n.deleteEvent=e=>{l(e),i([...n.getEvents()]),g()};const d=n.setCalendarVisibility;n.setCalendarVisibility=(e,t)=>{d(e,t),i([...n.getEvents()]),g()};const u=n.setAllCalendarsVisibility;n.setAllCalendarsVisibility=e=>{u(e),i([...n.getEvents()]),g()};const m=n.setVisibleMonth;n.setVisibleMonth=e=>{m(e),g()};const h=n.reorderCalendars;n.reorderCalendars=(e,t)=>{h(e,t),g()};const f=n.updateCalendar;n.updateCalendar=(e,t)=>{f(e,t),g()};const v=n.createCalendar;n.createCalendar=e=>{v(e),g()};const p=n.deleteCalendar;n.deleteCalendar=e=>{p(e),g()};const y=n.mergeCalendars;n.mergeCalendars=(e,t)=>{y(e,t),i([...n.getEvents()]),g()};const x=n.highlightEvent;n.highlightEvent=e=>{x(e),g()};const b=n.triggerRender;return n.triggerRender=()=>{b(),c(n.getSidebarConfig()),g()},()=>{}},[n,g]),t.useEffect(()=>{r(n.state.currentView),s(n.state.currentDate),i(n.getEvents())},[n]);const m=t.useRef(e);t.useEffect(()=>{xe(m.current,e)||(n.updateConfig(e),m.current=e)},[n,e]);const h=t.useCallback(e=>{n.changeView(e)},[n]),f=t.useCallback(e=>{n.setCurrentDate(e)},[n]),v=t.useCallback(e=>{n.addEvent(e)},[n]),p=t.useCallback((e,t,a)=>{n.updateEvent(e,t,a)},[n]),y=t.useCallback(e=>{n.deleteEvent(e)},[n]),x=t.useCallback(()=>{n.goToToday()},[n]),b=t.useCallback(()=>{n.goToPrevious()},[n]),D=t.useCallback(()=>{n.goToNext()},[n]),w=t.useCallback(e=>{n.selectDate(e)},[n]),C=t.useCallback((e,t)=>{n.setCalendarVisibility(e,t)},[n]),E=t.useCallback(e=>{n.setAllCalendarsVisibility(e)},[n]);return{app:n,currentView:a,currentDate:o,events:l,changeView:h,setCurrentDate:f,addEvent:v,updateEvent:p,deleteEvent:y,goToToday:x,goToPrevious:b,goToNext:D,selectDate:w,getCalendars:()=>n.getCalendars(),createCalendar:e=>n.createCalendar(e),mergeCalendars:(e,t)=>n.mergeCalendars(e,t),setCalendarVisibility:C,setAllCalendarsVisibility:E,getAllEvents:()=>n.getAllEvents(),highlightEvent:e=>n.highlightEvent(e),setVisibleMonth:e=>n.setVisibleMonth(e),getVisibleMonth:()=>n.getVisibleMonth(),sidebarConfig:d,readOnlyConfig:n.getReadOnlyConfig()}},exports.useDrag=ca,exports.useDragForView=ua,exports.useLocale=Ne,exports.useResponsiveConfig=()=>{const[e,n]=t.useState({yearHeight:fn,screenSize:"desktop"});return t.useEffect(()=>{const e=()=>{const e=window.innerWidth;n(e<640?{yearHeight:mn,screenSize:"mobile"}:e<900?{yearHeight:hn,screenSize:"tablet"}:{yearHeight:fn,screenSize:"desktop"})};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e},exports.useResponsiveMonthConfig=Sn,exports.useTheme=Hn,exports.useVirtualMonthScroll=Nn,exports.useVirtualScroll=({currentDate:e,yearHeight:n,onCurrentYearChange:a})=>{const r=e.getFullYear(),o=(r-dn)*n,[s,l]=t.useState(o),[i,d]=t.useState(600),[c,u]=t.useState(r),[g,m]=t.useState(!1),h=t.useRef(null),f=t.useRef(null),v=t.useRef(0),p=t.useRef(0),y=t.useRef(n);t.useEffect(()=>{if(y.current===n)return;y.current=n;const e=(c-dn)*n;l(e),p.current=e,h.current&&(h.current.scrollTop=e)},[n,c]);const x=t.useMemo(()=>{const e=performance.now(),t=cn-dn+1,a=t*n,r=Math.floor(s/n),o=Math.min(t-1,Math.ceil((s+i)/n)),l=Math.max(0,r-ln),d=Math.min(t-1,o+ln),c=[];for(let e=l;e<=d;e++)c.push({index:e,year:dn+e,top:e*n,height:n});const u=performance.now()-e;return vn.trackRenderTime(u),{totalHeight:a,visibleItems:c}},[s,i,n]),b=t.useCallback(e=>{const t=performance.now();if(t-v.current<un)return;v.current=t;const r=e.currentTarget.scrollTop,o=Math.abs(r-p.current);p.current=r,vn.trackScrollEvent(o),requestAnimationFrame(()=>{l(r);const e=r,t=Math.floor(dn+e/n);t!==c&&t>=dn&&t<=cn&&(u(t),null==a||a(t))}),m(!0),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{m(!1)},gn)},[i,c,n,a]);t.useEffect(()=>{const e=h.current;if(!e)return;e.scrollTop=o,p.current=o;const t=new ResizeObserver(([e])=>{d(e.contentRect.height)});return t.observe(e),()=>t.disconnect()},[o]);const D=t.useCallback((e,t=!0)=>{if(!h.current)return;const a=(e-dn)*n;h.current.scrollTo({top:Math.max(0,a),behavior:t?"smooth":"auto"})},[n]),w=t.useCallback(()=>{const e=Math.max(dn,c-1);u(e),D(e)},[c,D]),C=t.useCallback(()=>{const e=Math.min(cn,c+1);u(e),D(e)},[c,D]),E=t.useCallback(()=>{const e=(new Date).getFullYear();u(e),D(e)},[D]);return t.useEffect(()=>()=>{f.current&&clearTimeout(f.current)},[]),{scrollTop:s,containerHeight:i,currentYear:c,isScrolling:g,virtualData:x,scrollElementRef:h,handleScroll:b,scrollToYear:D,handlePreviousYear:w,handleNextYear:C,handleToday:E,setScrollTop:l,setContainerHeight:d,setCurrentYear:u,setIsScrolling:m}},exports.weekDays=re,exports.weekDaysFullName=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],exports.zh=k,exports.zonedDateTimeToDate=$;
1
+ "use strict";var e,t=require("temporal-polyfill"),n=require("preact"),a=require("tslib"),r=require("preact/hooks"),o=require("preact/compat"),l=require("@dayflow/blossom-color-picker");exports.ViewType=void 0,(e=exports.ViewType||(exports.ViewType={})).DAY="day",e.WEEK="week",e.MONTH="month",e.YEAR="year";const i={OVERSCAN:6,BUFFER_SIZE:100,MIN_YEAR:1900,MAX_YEAR:2200,SCROLL_THROTTLE:8,SCROLL_DEBOUNCE:150,CACHE_CLEANUP_THRESHOLD:200,MOBILE_WEEK_HEIGHT:80,TABLET_WEEK_HEIGHT:90,WEEK_HEIGHT:119};class s{constructor(e=i.BUFFER_SIZE){this.cache=new Map,this.accessOrder=[],this.maxSize=e}getKey(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}get(e){const t=this.getKey(e),n=this.cache.get(t);if(n)return this.updateAccessOrder(t),n}set(e,t){const n=this.getKey(e);if(this.cache.size>=this.maxSize){const e=this.accessOrder.shift();void 0!==e&&this.cache.delete(e)}this.cache.set(n,t),this.updateAccessOrder(n)}updateAccessOrder(e){const t=this.accessOrder.indexOf(e);t>-1&&this.accessOrder.splice(t,1),this.accessOrder.push(e)}getSize(){return this.cache.size}clear(){this.cache.clear(),this.accessOrder=[]}}const d=[{id:"blue",name:"Blue",isDefault:!0,colors:{eventColor:"#eff6ff",eventSelectedColor:"rgba(59, 130, 246)",lineColor:"#3b82f6",textColor:"#1e3a8a"},darkColors:{eventColor:"rgba(30, 64, 175, 0.8)",eventSelectedColor:"rgba(30, 58, 138, 1)",lineColor:"#3b82f6",textColor:"#dbeafe"}},{id:"green",name:"Green",isDefault:!0,colors:{eventColor:"#f0fdf4",eventSelectedColor:"rgba(16, 185, 129, 1)",lineColor:"#10b981",textColor:"#064e3b"},darkColors:{eventColor:"rgba(4, 120, 87, 0.8)",eventSelectedColor:"rgba(6, 78, 59, 1)",lineColor:"#10b981",textColor:"#d1fae5"}},{id:"purple",name:"Purple",isDefault:!0,colors:{eventColor:"#faf5ff",eventSelectedColor:"rgba(139, 92, 246, 1)",lineColor:"#8b5cf6",textColor:"#5b21b6"},darkColors:{eventColor:"rgba(109, 40, 217, 0.8)",eventSelectedColor:"rgba(91, 33, 182, 1)",lineColor:"#8b5cf6",textColor:"#ede9fe"}},{id:"yellow",name:"Yellow",isDefault:!0,colors:{eventColor:"#fefce8",eventSelectedColor:"rgba(245, 158, 11, 1)",lineColor:"#f59e0b",textColor:"#78350f"},darkColors:{eventColor:"rgba(180, 83, 9, 0.8)",eventSelectedColor:"rgba(120, 53, 15, 1)",lineColor:"#f59e0b",textColor:"#fef3c7"}},{id:"red",name:"Red",isDefault:!0,colors:{eventColor:"#fef2f2",eventSelectedColor:"rgba(239, 68, 68, 1)",lineColor:"#ef4444",textColor:"#7f1d1d"},darkColors:{eventColor:"rgba(185, 28, 28, 0.8)",eventSelectedColor:"rgba(127, 29, 29, 1)",lineColor:"#ef4444",textColor:"#fee2e2"}},{id:"orange",name:"Orange",isDefault:!0,colors:{eventColor:"#fff7edb3",eventSelectedColor:"rgba(249, 115, 22, 1)",lineColor:"#f97316",textColor:"#7c2d12"},darkColors:{eventColor:"rgba(194, 65, 12, 0.8)",eventSelectedColor:"rgba(124, 45, 18, 1)",lineColor:"#f97316",textColor:"#fed7aa"}},{id:"pink",name:"Pink",isDefault:!0,colors:{eventColor:"#fdf2f8",eventSelectedColor:"rgba(236, 72, 153, 1)",lineColor:"#ec4899",textColor:"#831843"},darkColors:{eventColor:"rgba(190, 24, 93, 0.8)",eventSelectedColor:"rgba(131, 24, 67, 1)",lineColor:"#ec4899",textColor:"#fce7f3"}},{id:"teal",name:"Teal",isDefault:!0,colors:{eventColor:"#f0fdfa",eventSelectedColor:"rgba(20, 184, 166, 1)",lineColor:"#14b8a6",textColor:"#134e4a"},darkColors:{eventColor:"rgba(15, 118, 110, 0.8)",eventSelectedColor:"rgba(19, 78, 74, 1)",lineColor:"#14b8a6",textColor:"#ccfbf1"}},{id:"indigo",name:"Indigo",isDefault:!0,colors:{eventColor:"#eef2ffb3",eventSelectedColor:"rgba(99, 102, 241, 1)",lineColor:"#6366f1",textColor:"#312e81"},darkColors:{eventColor:"rgba(67, 56, 202, 0.8)",eventSelectedColor:"rgba(49, 46, 129, 1)",lineColor:"#6366f1",textColor:"#e0e7ff"}},{id:"gray",name:"Gray",isDefault:!0,colors:{eventColor:"#f9fafbb3",eventSelectedColor:"rgba(107, 114, 128, 1)",lineColor:"#6b7280",textColor:"#1f2937"},darkColors:{eventColor:"rgba(75, 85, 99, 0.8)",eventSelectedColor:"rgba(31, 41, 55, 1)",lineColor:"#6b7280",textColor:"#f3f4f6"}}];class c{constructor(e,t,n="light"){this.calendars=new Map,this.defaultCalendarId=t||"blue",this.currentTheme=n;const a=e&&e.length>0;e?e.forEach(e=>{this.calendars.set(e.id,e)}):d.forEach(e=>{this.calendars.set(e.id,Object.assign(Object.assign({},e),{isVisible:!a&&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[a]=n.splice(e,1);n.splice(t,0,a),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,a=this.isDarkTheme(n);let r;return e&&(r=this.get(e)),r||(r=this.getDefaultCalendar()),a&&r.darkColors?r.darkColors:r.colors}getSelectedBgColor(e,t){return this.resolveColors(e,t).eventSelectedColor}getLineColor(e,t){return this.resolveColors(e,t).lineColor}getTextColor(e,t){return this.resolveColors(e,t).textColor}isDarkTheme(e){return"dark"===e||"light"!==e&&(!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-color-scheme: dark)").matches)}validate(e){const t=[];return e.id||t.push("Calendar type must have an id"),e.name||t.push("Calendar type must have a name"),e.colors?(e.colors.eventColor||t.push("Calendar colors must include eventColor"),e.colors.eventSelectedColor||t.push("Calendar colors must include eventSelectedColor"),e.colors.lineColor||t.push("Calendar colors must include lineColor"),e.colors.textColor||t.push("Calendar colors must include textColor")):t.push("Calendar type must have colors configuration"),t}}let u=new c;function g(){return u}function h(e){const t=d.find(t=>t.colors.lineColor.toLowerCase()===e.toLowerCase());return t?{colors:t.colors,darkColors:t.darkColors}:{colors:{eventColor:e+"1A",eventSelectedColor:e,lineColor:e,textColor:e},darkColors:{eventColor:e+"CC",eventSelectedColor:e,lineColor:e,textColor:"#ffffff"}}}const m=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 a=(new Date).toISOString(),r=`[DayFlow ${e.toUpperCase()}] ${a}:`;switch(e){case"log":console.log(r,t,...n);break;case"warn":console.warn(r,t,...n);break;case"error":console.error(r,t,...n);break;case"debug":console.debug(r,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)}};function v(e,t="240px"){return"number"==typeof e?`${e}px`:"string"==typeof e&&e.trim().length>0?e:t}function f(){if("undefined"==typeof document)return!1;const e=document.createElement("div");e.style.width="100px",e.style.height="100px",e.style.overflow="scroll",e.style.position="absolute",e.style.top="-9999px",document.body.appendChild(e);const t=e.offsetWidth-e.clientWidth>0;return document.body.removeChild(e),t}const p={code:"en-US",messages:{allDay:"All day",noEvents:"No events for this day",more:"more",eventTitle:"Event Title",dateRange:"Date Range",timeRange:"Time Range",note:"Note",addNotePlaceholder:"Add a note...",setAsAllDay:"Set as All-day",setAsTimed:"Set as Timed Event",delete:"Delete",confirm:"Confirm",cancel:"Cancel",today:"Today",day:"Day",week:"Week",month:"Month",year:"Year",newEvent:"New Event",newAllDayEvent:"New All-day Event",newCalendarEvent:"New {calendarName} Event",newAllDayCalendarEvent:"New {calendarName} All-day Event",save:"Save",deleteCalendar:'Delete "{calendarName}"?',deleteCalendarMessage:'Do you want to delete "{calendarName}" or merge its events into another existing calendar?',merge:"Merge",confirmDeleteTitle:'Are you sure you want to delete the calendar "{calendarName}"?',confirmDeleteMessage:"If you delete this calendar, all events associated with the calendar will also be deleted.",mergeConfirmTitle:'Merge "{sourceName}" with "{targetName}"?',mergeConfirmMessage:'Are you sure you want to merge "{sourceName}" with "{targetName}"? Doing so will move all the events from "{sourceName}" to "{targetName}" and "{sourceName}" will be deleted. This cannot be undone.',expandSidebar:"Expand calendar sidebar",collapseSidebar:"Collapse calendar sidebar",calendars:"Calendars",createCalendar:"Create New Calendar",calendarNamePlaceholder:"e.g. Work",customColor:"Custom Color...",create:"Create",calendarOptions:"Calendar Options",untitled:"Untitled",search:"Search",noResults:"No results found",calendar:"Calendar",starts:"Starts",ends:"Ends",notes:"Notes",titlePlaceholder:"Title",notesPlaceholder:"Notes",editEvent:"Edit Event",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"}},y={code:"zh-CN",messages:{allDay:"全天",noEvents:"今日无日程",more:"个",eventTitle:"事件标题",dateRange:"日期范围",timeRange:"时间范围",note:"备注",addNotePlaceholder:"添加备注...",setAsAllDay:"设为全天",setAsTimed:"设为普通事件",delete:"删除",confirm:"确认",cancel:"取消",today:"今天",day:"日",week:"周",month:"月",year:"年",newEvent:"新建日程",newAllDayEvent:"新建全天日程",newCalendarEvent:"新建 {calendarName} 日程",newAllDayCalendarEvent:"新建 {calendarName} 全天日程",save:"保存",deleteCalendar:'删除日历 "{calendarName}"?',deleteCalendarMessage:'您想删除日历 "{calendarName}" 还是将其事件合并到另一个现有日历中?',merge:"合并",confirmDeleteTitle:'您确定要删除日历 "{calendarName}" 吗?',confirmDeleteMessage:"如果您删除此日历,与其关联的所有事件也将被删除。",mergeConfirmTitle:'将 "{sourceName}" 合并到 "{targetName}"?',mergeConfirmMessage:'您确定要将 "{sourceName}" 合并到 "{targetName}" 吗?这样做会将 "{sourceName}" 中的所有事件移动到 "{targetName}",并且 "{sourceName}" 将被删除。此操作无法撤销。',expandSidebar:"展开日历侧边栏",collapseSidebar:"收起日历侧边栏",calendars:"日历",createCalendar:"创建新日历",calendarNamePlaceholder:"例如:工作",customColor:"自定义颜色...",create:"创建",calendarOptions:"日历选项",untitled:"未命名",search:"搜索",noResults:"无结果",calendar:"日历",starts:"开始",ends:"结束",notes:"备注",titlePlaceholder:"标题",notesPlaceholder:"备注",editEvent:"编辑日程",done:"完成",quickCreateEvent:"快速创建日程",quickCreatePlaceholder:"周五晚7点看电影",noSuggestions:"输入内容以创建",newCalendar:"新增日历",refreshAll:"全部刷新",tomorrow:"明天",importCalendar:"导入日历",exportCalendar:"导出日历",addSchedule:"添加日程",importCalendarMessage:"该日历包含新日程。请选取目标日历",ok:"好",cut:"剪切",copy:"复制",pasteHere:"粘贴在此处",eventSummary:"简介"}},b={code:"ja-JP",messages:{allDay:"終日",noEvents:"本日は予定がありません",more:"件",eventTitle:"予定名",dateRange:"日付範囲",timeRange:"時間範囲",note:"メモ",addNotePlaceholder:"メモを追加...",setAsAllDay:"終日予定に設定",setAsTimed:"時間指定の予定に設定",delete:"削除",confirm:"確認",cancel:"キャンセル",today:"今日",day:"日",week:"週",month:"月",year:"年",newEvent:"新規予定",newAllDayEvent:"新規終日予定",newCalendarEvent:"新規 {calendarName} 予定",newAllDayCalendarEvent:"新規 {calendarName} 終日予定",save:"保存",deleteCalendar:'カレンダー "{calendarName}" を削除しますか?',deleteCalendarMessage:'カレンダー "{calendarName}" を削除しますか?それともイベントを別の既存のカレンダーにマージしますか?',merge:"マージ",confirmDeleteTitle:'カレンダー "{calendarName}" を削除してもよろしいですか?',confirmDeleteMessage:"このカレンダーを削除すると、関連するすべてのイベントも削除されます。",mergeConfirmTitle:'"{sourceName}" を "{targetName}" にマージしますか?',mergeConfirmMessage:'"{sourceName}" を "{targetName}" にマージしてもよろしいですか?これにより、"{sourceName}" のすべてのイベントが "{targetName}" に移動し、"{sourceName}" は削除されます。この操作は元に戻せません。',expandSidebar:"カレンダーサイドバーを展開",collapseSidebar:"カレンダーサイドバーを折りたたむ",calendars:"カレンダー",createCalendar:"新しいカレンダーを作成",calendarNamePlaceholder:"例:仕事",customColor:"カスタムカラー...",create:"作成",calendarOptions:"カレンダーオプション",untitled:"無題",search:"検索",noResults:"結果が見つかりません",calendar:"カレンダー",starts:"開始",ends:"終了",notes:"メモ",titlePlaceholder:"予定名",notesPlaceholder:"メモ",editEvent:"予定を編集",done:"完了",quickCreateEvent:"クイック作成",quickCreatePlaceholder:"金曜日7時から映画",noSuggestions:"入力して作成",newCalendar:"新しいカレンダー",refreshAll:"すべて更新",tomorrow:"明日",importCalendar:"カレンダーをインポート",exportCalendar:"カレンダーをエクスポート",addSchedule:"予定を追加",importCalendarMessage:"このカレンダーには新しい予定が含まれています。ターゲットカレンダーを選択してください。",ok:"OK",cut:"切り取り",copy:"コピー",pasteHere:"ここに貼り付け",eventSummary:"概要"}},x={code:"ko-KR",messages:{allDay:"종일",noEvents:"오늘 일정이 없습니다",more:"개",eventTitle:"일정 제목",dateRange:"날짜 범위",timeRange:"시간 범위",note:"메모",addNotePlaceholder:"메모 추가...",setAsAllDay:"종일 일정으로 설정",setAsTimed:"시간 지정 일정으로 설정",delete:"삭제",confirm:"확인",cancel:"취소",today:"오늘",day:"일",week:"주",month:"월",year:"년",newEvent:"새 일정",newAllDayEvent:"새 종일 일정",newCalendarEvent:"{calendarName}의 새 일정",newAllDayCalendarEvent:"{calendarName}의 새 종일 일정",save:"저장",deleteCalendar:'"{calendarName}" 삭제?',deleteCalendarMessage:'"{calendarName}"을(를) 삭제하시겠습니까, 아니면 이벤트를 다른 기존 캘린더로 병합하시겠습니까?',merge:"병합",confirmDeleteTitle:'"{calendarName}" 캘린더를 삭제하시겠습니까?',confirmDeleteMessage:"이 캘린더를 삭제하면 연결된 모든 이벤트도 삭제됩니다.",mergeConfirmTitle:'"{sourceName}"을(를) "{targetName}"(으)로 병합?',mergeConfirmMessage:'"{sourceName}"을(를) "{targetName}"(으)로 병합하시겠습니까? 이렇게 하면 "{sourceName}"의 모든 이벤트가 "{targetName}"(으)로 이동하고 "{sourceName}"은(는) 삭제됩니다. 이 작업은 취소할 수 없습니다.',expandSidebar:"캘린더 사이드바 펼치기",collapseSidebar:"캘린더 사이드바 접기",calendars:"캘린더",createCalendar:"새 캘린더 만들기",calendarNamePlaceholder:"예: 업무",customColor:"사용자 지정 색상...",create:"만들기",calendarOptions:"캘린더 옵션",untitled:"무제",search:"검색",noResults:"결과 없음",calendar:"캘린더",starts:"시작",ends:"종료",notes:"메모",titlePlaceholder:"제목",notesPlaceholder:"메모",editEvent:"일정 편집",done:"완료",quickCreateEvent:"빠른 일정 생성",quickCreatePlaceholder:"금요일 오후 7시에 영화",noSuggestions:"입력하여 만들기",newCalendar:"새 캘린더",refreshAll:"모두 새로 고침",tomorrow:"내일",importCalendar:"캘린더 가져오기",exportCalendar:"캘린더 내보내기",addSchedule:"일정 추가",importCalendarMessage:"이 캘린더에는 새로운 일정이 포함되어 있습니다. 대상 캘린더를 선택하세요.",ok:"확인",cut:"잘라내기",copy:"복사",pasteHere:"여기에 붙여넣기",eventSummary:"요약"}},D={code:"fr-FR",messages:{allDay:"Toute la journée",noEvents:"Aucun événement aujourd'hui",more:"de plus",eventTitle:"Titre de l'événement",dateRange:"Plage de dates",timeRange:"Plage horaire",note:"Note",addNotePlaceholder:"Ajouter une note...",setAsAllDay:"Définir comme toute la journée",setAsTimed:"Définir comme événement horaire",delete:"Supprimer",confirm:"Confirmer",cancel:"Annuler",today:"Aujourd'hui",day:"Jour",week:"Semaine",month:"Mois",year:"Année",newEvent:"Nouvel événement",newAllDayEvent:"Nouvel événement toute la journée",newCalendarEvent:"Nouvel événement dans {calendarName}",newAllDayCalendarEvent:"Nouvel événement toute la journée dans {calendarName}",save:"Enregistrer",deleteCalendar:'Supprimer "{calendarName}" ?',deleteCalendarMessage:'Voulez-vous supprimer "{calendarName}" ou fusionner ses événements dans un autre calendrier existant ?',merge:"Fusionner",confirmDeleteTitle:'Êtes-vous sûr de vouloir supprimer le calendrier "{calendarName}" ?',confirmDeleteMessage:"Si vous supprimez ce calendrier, tous les événements associés seront également supprimés.",mergeConfirmTitle:'Fusionner "{sourceName}" avec "{targetName}" ?',mergeConfirmMessage:'Êtes-vous sûr de vouloir fusionner "{sourceName}" avec "{targetName}" ? Cela déplacera tous les événements de "{sourceName}" vers "{targetName}" et "{sourceName}" sera supprimé. Cette action est irréversible.',expandSidebar:"Développer la barre latérale",collapseSidebar:"Réduire la barre latérale",calendars:"Calendriers",createCalendar:"Créer un nouveau calendrier",calendarNamePlaceholder:"ex. Travail",customColor:"Couleur personnalisée...",create:"Créer",calendarOptions:"Options du calendrier",untitled:"Sans titre",search:"Rechercher",noResults:"Aucun résultat trouvé",calendar:"Calendrier",starts:"Début",ends:"Fin",notes:"Notes",titlePlaceholder:"Titre",notesPlaceholder:"Notes",editEvent:"Modifier l'événement",done:"Terminé",quickCreateEvent:"Création rapide",quickCreatePlaceholder:"Film à 19h vendredi",noSuggestions:"Tapez pour créer",newCalendar:"Nouveau calendrier",refreshAll:"Tout actualiser",tomorrow:"Demain",importCalendar:"Importer un calendrier",exportCalendar:"Exporter le calendrier",addSchedule:"Ajouter un événement",importCalendarMessage:"Ce calendrier contient de nouveaux événements. Veuillez sélectionner un calendrier cible.",ok:"OK",cut:"Couper",copy:"Copier",pasteHere:"Coller ici",eventSummary:"Résumé"}},w={code:"de-DE",messages:{allDay:"Ganztägig",noEvents:"Heute keine Termine",more:"mehr",eventTitle:"Ereignistitel",dateRange:"Datumsbereich",timeRange:"Zeitbereich",note:"Notiz",addNotePlaceholder:"Notiz hinzufügen...",setAsAllDay:"Als ganztägig festlegen",setAsTimed:"Als zeitlich begrenztes Ereignis festlegen",delete:"Löschen",confirm:"Bestätigen",cancel:"Abbrechen",today:"Heute",day:"Tag",week:"Woche",month:"Monat",year:"Jahr",newEvent:"Neues Ereignis",newAllDayEvent:"Neues ganztägiges Ereignis",newCalendarEvent:"Neues Ereignis in {calendarName}",newAllDayCalendarEvent:"Neues ganztägiges Ereignis in {calendarName}",save:"Speichern",deleteCalendar:'"{calendarName}" löschen?',deleteCalendarMessage:'Möchten Sie "{calendarName}" löschen oder dessen Ereignisse in einen anderen bestehenden Kalender zusammenführen?',merge:"Zusammenführen",confirmDeleteTitle:'Sind Sie sicher, dass Sie den Kalender "{calendarName}" löschen möchten?',confirmDeleteMessage:"Wenn Sie diesen Kalender löschen, werden auch alle damit verbundenen Ereignisse gelöscht.",mergeConfirmTitle:'"{sourceName}" mit "{targetName}" zusammenführen?',mergeConfirmMessage:'Sind Sie sicher, dass Sie "{sourceName}" mit "{targetName}" zusammenführen möchten? Dadurch werden alle Ereignisse von "{sourceName}" nach "{targetName}" verschoben und "{sourceName}" wird gelöscht. Dies kann nicht rückgängig gemacht werden.',expandSidebar:"Kalender-Seitenleiste erweitern",collapseSidebar:"Kalender-Seitenleiste einklappen",calendars:"Kalender",createCalendar:"Neuen Kalender erstellen",calendarNamePlaceholder:"z.B. Arbeit",customColor:"Benutzerdefinierte Farbe...",create:"Erstellen",calendarOptions:"Kalenderoptionen",untitled:"Unbenannt",search:"Suchen",noResults:"Keine Ergebnisse gefunden",calendar:"Kalender",starts:"Beginnt",ends:"Endet",notes:"Notizen",titlePlaceholder:"Titel",notesPlaceholder:"Notizen",editEvent:"Ereignis bearbeiten",done:"Fertig",quickCreateEvent:"Ereignis schnell erstellen",quickCreatePlaceholder:"Film am Freitag um 19 Uhr",noSuggestions:"Tippen zum Erstellen",newCalendar:"Neuer Kalender",refreshAll:"Alles aktualisieren",tomorrow:"Morgen",importCalendar:"Kalender importieren",exportCalendar:"Kalender exportieren",addSchedule:"Termin hinzufügen",importCalendarMessage:"Dieser Kalender enthält neue Termine. Bitte wählen Sie einen Zielkalender.",ok:"OK",cut:"Ausschneiden",copy:"Kopieren",pasteHere:"Hier einfügen",eventSummary:"Zusammenfassung"}},C={code:"es-ES",messages:{allDay:"Todo el día",noEvents:"No hay eventos hoy",more:"más",eventTitle:"Título del evento",dateRange:"Rango de fechas",timeRange:"Rango de tiempo",note:"Nota",addNotePlaceholder:"Añadir una nota...",setAsAllDay:"Establecer como todo el día",setAsTimed:"Establecer como evento con horario",delete:"Eliminar",confirm:"Confirmar",cancel:"Cancelar",today:"Hoy",day:"Día",week:"Semana",month:"Mes",year:"Año",newEvent:"Nuevo evento",newAllDayEvent:"Nuevo evento de todo el día",newCalendarEvent:"Nuevo evento en {calendarName}",newAllDayCalendarEvent:"Nuevo evento de todo el día en {calendarName}",save:"Guardar",deleteCalendar:'¿Eliminar "{calendarName}"?',deleteCalendarMessage:'¿Quieres eliminar "{calendarName}" o fusionar sus eventos en otro calendario existente?',merge:"Fusionar",confirmDeleteTitle:'¿Seguro que quieres eliminar el calendario "{calendarName}"?',confirmDeleteMessage:"Si eliminas este calendario, también se eliminarán todos los eventos asociados.",mergeConfirmTitle:'¿Fusionar "{sourceName}" con "{targetName}"?',mergeConfirmMessage:'¿Seguro que quieres fusionar "{sourceName}" con "{targetName}"? Esto moverá todos los eventos de "{sourceName}" a "{targetName}" y se eliminará "{sourceName}". Esta acción no se puede deshacer.',expandSidebar:"Expandir barra lateral del calendario",collapseSidebar:"Contraer barra lateral del calendario",calendars:"Calendarios",createCalendar:"Crear nuevo calendario",calendarNamePlaceholder:"ej. Trabajo",customColor:"Color personalizado...",create:"Crear",calendarOptions:"Opciones de calendario",untitled:"Sin título",search:"Buscar",noResults:"No se encontraron resultados",calendar:"Calendario",starts:"Empieza",ends:"Termina",notes:"Notas",titlePlaceholder:"Título",notesPlaceholder:"Notas",editEvent:"Editar evento",done:"Hecho",quickCreateEvent:"Creación rápida de eventos",quickCreatePlaceholder:"Película a las 7pm el viernes",noSuggestions:"Escribe para crear",newCalendar:"Nuevo calendario",refreshAll:"Actualizar todo",tomorrow:"Mañana",importCalendar:"Importar calendario",exportCalendar:"Exportar calendario",addSchedule:"Añadir evento",importCalendarMessage:"Este calendario contiene nuevos eventos. Seleccione un calendario de destino.",ok:"Aceptar",cut:"Cortar",copy:"Copiar",pasteHere:"Pegar aquí",eventSummary:"Resumen"}},E={en:p,zh:y,ja:b,ko:x,fr:D,de:w,es:C};function k(e){const t=e.split("-")[0].toLowerCase();return t in E?t:"en"}function T(e){try{return new Intl.DateTimeFormat(e),!0}catch(e){return!1}}function S(e){var n;return!(!e||"object"!=typeof e)&&(!(e instanceof Date)&&(e instanceof t.Temporal.PlainDate||("PlainDate"===(null===(n=null==e?void 0:e.constructor)||void 0===n?void 0:n.name)||!("hour"in e)&&!("timeZone"in e)&&"year"in e&&"month"in e&&"day"in e)))}function N(e,n=t.Temporal.Now.timeZoneId()){return t.Temporal.Instant.fromEpochMilliseconds(e.getTime()).toZonedDateTimeISO(n)}function M(e){return t.Temporal.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()})}function I(e){return"number"==typeof e.epochMilliseconds?new Date(e.epochMilliseconds):new Date(e.year,e.month-1,e.day,e.hour,e.minute)}function H(e,n){if(e instanceof Date)return e;if(S(e))return function(e,n=t.Temporal.Now.timeZoneId()){if("function"==typeof e.toZonedDateTime)try{return I(e.toZonedDateTime({timeZone:n,plainTime:t.Temporal.PlainTime.from({hour:0,minute:0})}))}catch(e){}return new Date(e.year,e.month-1,e.day)}(e,n);if(e&&"object"==typeof e&&"hour"in e&&!("timeZone"in e)){const t=e;return new Date(t.year,t.month-1,t.day,t.hour,t.minute,t.second||0,t.millisecond||0)}return e&&"object"==typeof e&&"year"in e?I(e):new Date(e)}function R(e,n){const a=Math.floor(n),r=Math.round(60*(n-a));return S(e)?t.Temporal.PlainDateTime.from({year:e.year,month:e.month,day:e.day,hour:a,minute:r}):"function"==typeof e.with?e.with({hour:a,minute:r,second:0,millisecond:0}):t.Temporal.PlainDateTime.from({year:e.year,month:e.month,day:e.day,hour:a,minute:r})}function O(e,n){if(e instanceof Date&&n instanceof Date)return e.toDateString()===n.toDateString();const a=e=>e instanceof Date?M(e):S(e)?e:"function"==typeof e.toPlainDate?e.toPlainDate():t.Temporal.PlainDate.from({year:e.year,month:e.month,day:e.day}),r=a(e),o=a(n);return 0===t.Temporal.PlainDate.compare(r,o)}function P(e,n=t.Temporal.Now.timeZoneId()){if("function"==typeof e.toZonedDateTime){return(S(e)?e:e.toPlainDate()).toZonedDateTime({timeZone:n,plainTime:t.Temporal.PlainTime.from({hour:0,minute:0})})}return(S(e)?e:t.Temporal.PlainDate.from({year:e.year,month:e.month,day:e.day})).toZonedDateTime({timeZone:n,plainTime:t.Temporal.PlainTime.from({hour:0,minute:0})})}function A(e,n=t.Temporal.Now.timeZoneId()){if("function"==typeof e.toZonedDateTime){return(S(e)?e:e.toPlainDate()).toZonedDateTime({timeZone:n,plainTime:t.Temporal.PlainTime.from({hour:23,minute:59,second:59,millisecond:999})})}return(S(e)?e:t.Temporal.PlainDate.from({year:e.year,month:e.month,day:e.day})).toZonedDateTime({timeZone:n,plainTime:t.Temporal.PlainTime.from({hour:23,minute:59,second:59,millisecond:999})})}function L(e,t){const n=new Date(e.getFullYear(),e.getMonth(),e.getDate()),a=new Date(t.getFullYear(),t.getMonth(),t.getDate());return Math.round((a.getTime()-n.getTime())/864e5)}function $(e,t){const n=new Date(e);return n.setDate(n.getDate()+t),n}const j=e=>{if(e instanceof Date){return e.getHours()+e.getMinutes()/60}return(t=e)instanceof Date?t.getHours()+t.getMinutes()/60:S(t)?0:null!==t&&"object"==typeof t&&"hour"in t&&void 0!==t.hour?t.hour+(null!==(n=t.minute)&&void 0!==n?n:0)/60:0;var t,n},Y=(e,t)=>{if(e instanceof Date){const n=new Date(e),a=Math.floor(t),r=Math.round(60*(t-a));return n.setHours(a,r,0,0),n}return R(e,t)},z=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(23,59,59,999),t}return A(e)},F=(e,n)=>{if(e instanceof Date&&n instanceof Date)return e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate();return O(e instanceof Date?t.Temporal.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()}):S(e)?e:e.toPlainDate(),n instanceof Date?t.Temporal.PlainDate.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate()}):S(n)?n:n.toPlainDate())},V=(e,t)=>(t||g()).resolveColors(e).eventColor,_=(e,t)=>(t||g()).resolveColors(e).textColor,W=(e,t)=>(t||g()).resolveColors(e).eventSelectedColor,B=(e,t)=>(t||g()).resolveColors(e).lineColor,U=.25,Z=(e,t=0)=>{const n=Math.floor(e),a=t||Math.round(60*(e-n));return`${n.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}`},q=e=>{const t=j(e.start),n=X(e);return`${Z(t)} - ${Z(n)}`},K=e=>{const t=U;return Math.round(e/t)*t},X=e=>{if(!e.end)return 0;const t=j(e.end);if(e.allDay||!e.start)return t;const n=H(e.start),a=H(e.end);if(!(n.getFullYear()!==a.getFullYear()||n.getMonth()!==a.getMonth()||n.getDate()!==a.getDate()))return t;if(0===t&&0===a.getMinutes()&&0===a.getSeconds()&&0===a.getMilliseconds()){const e=a.getTime()-n.getTime();if(e>0&&e<864e5)return 24}return t},G=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],J=["January","February","March","April","May","June","July","August","September","October","November","December"],Q=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],ee=e=>{const t=e.getDay(),n=e.getDate()-t+(0===t?-6:1),a=new Date(e);a.setDate(n),a.setHours(0,0,0,0);const r=new Date(a);return r.setDate(a.getDate()+6),r.setHours(23,59,59,999),{monday:a,sunday:r}},te=e=>{const t=new Date(e),n=t.getDate(),a=t.getMonth(),r=t.getFullYear(),o=new Date;return{date:t,day:n,month:a,year:r,monthName:J[a],shortMonthName:Q[a],isToday:o.getDate()===n&&o.getMonth()===a&&o.getFullYear()===r}},ne=e=>{const t=[],n=new Date(e);for(let e=0;e<7;e++){const e=new Date(n);t.push(te(e)),n.setDate(n.getDate()+1)}return{days:t,startDate:new Date(e),monthYear:ae(t)}},ae=e=>{const t={};e.forEach(e=>{const n=`${e.month}-${e.year}`;t[n]=(t[n]||0)+1});let n=0,a="";Object.entries(t).forEach(([e,t])=>{t>n&&(n=t,a=e)});const[r,o]=a.split("-").map(Number);return{month:J[r],monthIndex:r,year:o}};function re(e,t){const n=[],a=Math.floor(t/2),r=new Date(e),o=e.getDay(),l=0===o?6:o-1;r.setDate(e.getDate()-l),r.setHours(0,0,0,0);const i=new Date(r);i.setDate(i.getDate()-7*a);for(let e=0;e<t;e++){const t=new Date(i);t.setDate(t.getDate()+7*e),n.push(ne(t))}return n}const oe=(e,t)=>t.filter(t=>t.day===e&&!t.allDay),le=(e,t)=>{const n=new Date(e);return n.setDate(e.getDate()+t),n},ie=(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()}),se=(e,t)=>{const n=new Date(e);n.setHours(0,0,0,0);const a=new Date(t);a.setHours(0,0,0,0);const r=n.getTime()-a.getTime();return Math.floor(r/864e5)},de=(e,t)=>e.map(e=>{const n=H(e.start),a=se(n,t);return Object.assign(Object.assign({},e),{day:a})}),ce=(e,t)=>e===t||!(!e||!t)&&(e.title===t.title&&e.calendarId===t.calendarId&&(e.description||"")===(t.description||"")&&!!e.allDay==!!t.allDay&&e.start.toString()===t.start.toString()&&e.end.toString()===t.end.toString());function ue(){return Date.now().toString(36)+Math.random().toString(36).substring(2,8)}function ge(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),a=Object.keys(t);if(n.length!==a.length)return!1;for(const r of n)if(!a.includes(r)||!ge(e[r],t[r]))return!1;return!0}const he="240px",me=e=>{if(!e)return{enabled:!1,width:he,initialCollapsed:!1};if(!0===e)return{enabled:!0,width:he,initialCollapsed:!1};const{enabled:t=!0,width:n,initialCollapsed:a=!1,render:r,createCalendarMode:o,renderCalendarContextMenu:l,renderCreateCalendarDialog:i,colorPickerMode:s}=e;return{enabled:t,width:v(n,he),initialCollapsed:a,render:r,createCalendarMode:o,renderCalendarContextMenu:l,renderCreateCalendarDialog:i,colorPickerMode:s}};class ve{constructor(){this.renderings=new Map,this.overrides=new Set,this.listeners=new Set}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 fe=n.createContext(null);var pe=0;function ye(e,t,a,r,o,l){t||(t={});var i,s,d=t;if("ref"in d)for(s in d={},t)"ref"==s?i=t[s]:d[s]=t[s];var c={type:e,props:d,key:a,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--pe,__i:-1,__u:0,__source:o,__self:l};if("function"==typeof e&&(i=e.defaultProps))for(s in i)void 0===d[s]&&(d[s]=i[s]);return n.options.vnode&&n.options.vnode(c),c}const be=({className:e,width:t=24,height:n=24})=>ye("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:ye("path",{d:"m15 18-6-6 6-6"})}),xe=({className:e,width:t=24,height:n=24})=>ye("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:ye("path",{d:"m9 18 6-6-6-6"})}),De=({className:e,width:t=24,height:n=24})=>ye("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:[ye("path",{d:"m11 17-5-5 5-5"}),ye("path",{d:"m18 17-5-5 5-5"})]}),we=({className:e,width:t=24,height:n=24})=>ye("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:[ye("path",{d:"m6 17 5-5-5-5"}),ye("path",{d:"m13 17 5-5-5-5"})]}),Ce=({className:e,width:t=24,height:n=24})=>ye("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:ye("path",{d:"m6 9 6 6 6-6"})}),Ee=({className:e,width:t=24,height:n=24})=>ye("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:[ye("path",{d:"M5 12h14"}),ye("path",{d:"M12 5v14"})]}),ke=({className:e,width:t=24,height:n=24})=>ye("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:[ye("circle",{cx:"11",cy:"11",r:"8"}),ye("path",{d:"m21 21-4.3-4.3"})]}),Te=({className:e,width:t=24,height:n=24})=>ye("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:ye("path",{d:"M20 6 9 17l-5-5"})}),Se=({className:e,width:t=24,height:n=24})=>ye("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:[ye("path",{d:"m7 15 5 5 5-5"}),ye("path",{d:"m7 9 5-5 5 5"})]}),Ne=({className:e,width:t=24,height:n=24})=>ye("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:[ye("path",{d:"M18 6 6 18"}),ye("path",{d:"m6 6 12 12"})]}),Me=({className:e,width:t=24,height:n=24})=>ye("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:[ye("path",{d:"M8 2v4"}),ye("path",{d:"M16 2v4"}),ye("rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}),ye("path",{d:"M3 10h18"}),ye("path",{d:"M8 14h.01"}),ye("path",{d:"M12 14h.01"}),ye("path",{d:"M16 14h.01"}),ye("path",{d:"M8 18h.01"}),ye("path",{d:"M12 18h.01"}),ye("path",{d:"M16 18h.01"})]}),Ie=({className:e,width:t=24,height:n=24})=>ye("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:[ye("path",{d:"M18 8L22 12L18 16"}),ye("path",{d:"M2 12H22"})]}),He=({className:e,width:t=24,height:n=24})=>ye("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:ye("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),Re=({className:e,width:t=24,height:n=24})=>ye("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:[ye("rect",{width:"18",height:"14",x:"3",y:"8",rx:"2"}),ye("path",{d:"M12 5a3 3 0 1 0-3 3"}),ye("path",{d:"M12 5a3 3 0 1 1 3 3"}),ye("path",{d:"M3 12h18"}),ye("path",{d:"M12 22V8"})]}),Oe=({className:e,width:t=24,height:n=24})=>ye("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:ye("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"})}),Pe=({className:e,width:t=24,height:n=24})=>ye("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:[ye("path",{d:"M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z"}),ye("circle",{cx:"12",cy:"10",r:"3"})]}),Ae=({className:e,width:t=24,height:n=24})=>ye("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:ye("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"})}),Le=({className:e,width:t=24,height:n=24})=>ye("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:[ye("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),ye("path",{d:"M15 3v18"}),ye("path",{d:"m8 9 3 3-3 3"})]}),$e=({className:e,width:t=24,height:n=24})=>ye("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:[ye("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),ye("path",{d:"M15 3v18"}),ye("path",{d:"m10 15-3-3 3-3"})]}),je=({className:e,width:t=24,height:n=24})=>ye("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:[ye("rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}),ye("path",{d:"M3 10h18"}),ye("path",{d:"M8 2v4"}),ye("path",{d:"M16 2v4"})]}),Ye=({className:e,width:t=24,height:n=24})=>ye("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:[ye("path",{d:"m12 19-7-7 7-7"}),ye("path",{d:"M19 12H5"})]});function ze(e,t){var n,a,r,o,l;try{if("today"===e){return null!==(a=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!==a?a:null}if("week"===e){return null!==(o=null===(r=new Intl.RelativeTimeFormat(t,{numeric:"always"}).formatToParts(1,"week").find(e=>"unit"===e.type))||void 0===r?void 0:r.value)&&void 0!==o?o:null}return null!==(l=new Intl.DisplayNames(t,{type:"dateTimeField"}).of(e))&&void 0!==l?l:null}catch(e){return null}}function Fe(e){return e.charAt(0).toUpperCase()+e.slice(1)}const Ve=(e,t="short")=>{const n=[],a=new Date(2024,0,1);for(let r=0;r<7;r++){const o=new Date(a);o.setDate(a.getDate()+r);try{n.push(o.toLocaleDateString(e,{weekday:t}))}catch(e){n.push(o.toLocaleDateString("en-US",{weekday:t}))}}return n},_e=(e,t="long")=>{const n=[];for(let a=0;a<12;a++){const r=new Date(2024,a,1);try{n.push(r.toLocaleDateString(e,{month:t}))}catch(e){n.push(r.toLocaleDateString("en-US",{month:t}))}}return n};function We(e,t="en-US"){var n;if(["today","day","week","month","year"].includes(e)){const n=ze(e,t);if(n)return Fe(n)}const a=k(t),r=E[a],o=null===(n=null==r?void 0:r.messages)||void 0===n?void 0:n[e];if(o)return o;const l=E.en.messages;return(null==l?void 0:l[e])||e}const Be=n.createContext({locale:"en-US",t:e=>e,getWeekDaysLabels:()=>[],getMonthLabels:()=>[],isDefault:!0});function Ue(){return r.useContext(Be)}const Ze=o.forwardRef(({x:e,y:t,onClose:n,children:a,className:l},i)=>{const s=r.useRef(null);r.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 a=e=>{"Escape"===e.key&&n()};window.addEventListener("keydown",a);const r=()=>n();return window.addEventListener("scroll",r,!0),window.addEventListener("resize",r),()=>{window.removeEventListener("dayflow-close-all-menus",e),document.body.removeEventListener("mousedown",t,{capture:!0}),document.body.removeEventListener("contextmenu",t,{capture:!0}),window.removeEventListener("keydown",a),window.removeEventListener("scroll",r,!0),window.removeEventListener("resize",r)}},[n]);const d={top:t,left:e};return o.createPortal(ye("div",{ref:e=>{s.current=e,"function"==typeof i?i(e):i&&(i.current=e)},className:`fixed z-50 min-w-32 overflow-visible rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md dark:border-slate-800 dark:bg-slate-950 dark:text-slate-50 animate-in fade-in-0 zoom-in-95 duration-100 ease-out ${l||""}`,style:d,onContextMenu:e=>e.preventDefault(),"data-context-menu-root":"true",children:a}),document.body)});Ze.displayName="ContextMenu";const qe=({onClick:e,children:t,icon:n,danger:a,disabled:r})=>ye("div",{className:`relative flex cursor-default select-none items-center rounded-sm px-3 py-0.5 text-[12px] outline-none transition-colors group\n ${r?"pointer-events-none opacity-50":"focus:bg-primary focus:text-white hover:bg-primary hover:text-white dark:focus:bg-primary dark:focus:text-white dark:hover:bg-primary dark:hover:text-white"}\n ${a?"text-destructive focus:text-destructive-foreground focus:bg-destructive hover:bg-destructive hover:text-destructive-foreground":"text-slate-900 dark:text-slate-50"}`,onClick:t=>{t.stopPropagation(),r||e()},"data-disabled":r,children:[n&&ye("span",{className:"mr-2 h-4 w-4",children:n}),t]}),Ke=()=>ye("div",{className:"-mx-1 my-1 h-px bg-slate-200 dark:bg-slate-800"}),Xe=({children:e})=>ye("div",{className:"px-3 py-0.5 text-[12px] font-semibold text-slate-950 dark:text-slate-50",children:e}),Ge=({children:e})=>{const[t,a]=r.useState(!1),o=r.useRef(null);return r.useEffect(()=>()=>{o.current&&clearTimeout(o.current)},[]),ye("div",{className:"relative",onMouseEnter:()=>{o.current&&(clearTimeout(o.current),o.current=null),a(!0)},onMouseLeave:()=>{o.current=setTimeout(()=>{a(!1)},100)},children:(Array.isArray(e)?e:[e]).map(e=>n.isValidElement(e)?n.cloneElement(e,{isOpen:t}):e)})},Je=({children:e,icon:t,isOpen:n})=>ye("div",{className:"relative flex cursor-default select-none items-center rounded-sm px-3 py-0.5 text-[12px] outline-none transition-colors focus:bg-primary focus:text-white hover:bg-primary hover:text-white dark:focus:bg-primary dark:focus:text-white dark:hover:bg-primary dark:hover:text-white "+(n?"bg-primary text-white":""),children:[t&&ye("span",{className:"mr-2 h-4 w-4",children:t}),ye("span",{className:"grow text-left",children:e}),ye(xe,{className:"ml-auto h-4 w-4 "+(n?"text-white opacity-100":"opacity-60")})]}),Qe=({children:e,isOpen:t})=>{const n=r.useRef(null),[a,o]=r.useState("right");return r.useEffect(()=>{var e;if(t&&n.current){const t=n.current.getBoundingClientRect(),a=null===(e=n.current.parentElement)||void 0===e?void 0:e.getBoundingClientRect();a&&(a.right+t.width>window.innerWidth?o("left"):o("right"))}},[t]),t?ye("div",{ref:n,className:"absolute top-0 z-50 min-w-32 whitespace-nowrap overflow-hidden rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md dark:border-slate-800 dark:bg-slate-950 dark:text-slate-50 animate-in fade-in-0 zoom-in-95 duration-100 ease-out",style:{left:"right"===a?"100%":"auto",right:"left"===a?"100%":"auto",marginLeft:"right"===a?"0.25rem":0,marginRight:"left"===a?"0.25rem":0},"data-submenu-content":"true",children:e}):null},et=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],tt=({selectedColor:e,onSelect:t,onCustomColor:n})=>{const{t:a}=Ue();return ye("div",{children:[ye("div",{className:"grid grid-cols-7 gap-2 p-1 px-3",children:et.map(n=>ye("button",{type:"button",className:"h-5 w-5 rounded-full border border-gray-200 dark:border-gray-600 hover:scale-110 transition-transform focus:outline-none focus:ring-2 focus:ring-offset-1 focus:ring-primary dark:focus:ring-offset-slate-800 "+((null==e?void 0:e.toLowerCase())===n.toLowerCase()?"ring-2 ring-offset-1 ring-primary dark:ring-offset-slate-800":""),style:{backgroundColor:n},onClick:e=>{e.stopPropagation(),t(n)},title:n},n))}),n&&ye("div",{className:"mt-1 flex cursor-pointer items-center rounded-sm px-3 py-0.5 text-[12px] text-slate-700 hover:bg-primary hover:text-white dark:text-slate-200 dark:hover:bg-primary dark:hover:text-white transition-colors",onClick:e=>{e.stopPropagation(),n()},children:a("customColor")})]})};const nt=new class{constructor(){this.lastCopiedEvent=null}setEvent(e){this.lastCopiedEvent=e}getEvent(){return this.lastCopiedEvent}hasEvent(){return null!==this.lastCopiedEvent}clear(){this.lastCopiedEvent=null}},at=e=>{if(!e)return"";let n,a,r;e instanceof Date?(n=e.getFullYear(),a=e.getMonth()+1,r=e.getDate()):S(e)?(n=e.year,a=e.month,r=e.day):(!function(e){!e||"object"!=typeof e||e instanceof Date||t.Temporal.ZonedDateTime}(e),n=e.year,a=e.month,r=e.day);const o=String(a).padStart(2,"0");return`${String(r).padStart(2,"0")}/${o}/${n}`};function rt(e){return null!==e&&"object"==typeof e&&!("hour"in e)&&"year"in e&&"month"in e&&"day"in e&&!(e instanceof Date)}function ot(e){return null!==e&&"object"==typeof e&&"hour"in e&&!("timeZone"in e)&&"year"in e&&!(e instanceof Date)}function lt(e){return null!==e&&"object"==typeof e&&"timeZone"in e&&"year"in e&&!(e instanceof Date)}function it(e){if(e instanceof Date)return e;if(rt(e))return new Date(e.year,e.month-1,e.day);if(ot(e))return new Date(e.year,e.month-1,e.day,e.hour,e.minute,e.second||0,e.millisecond||0);if(lt(e))try{if("function"==typeof e.toInstant){const t=e.toInstant();return new Date(t.epochMilliseconds)}return new Date(e.year,e.month-1,e.day,e.hour,e.minute)}catch(t){return new Date(e.year,e.month-1,e.day,e.hour,e.minute)}return new Date(e)}function st(e){return t.Temporal.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()})}function dt(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 ct(e,n){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 ut(e){return e instanceof Date?st(e):rt(e)?e:(ot(e),e.toPlainDate())}const gt=/(YYYY|YY|MM|DD|HH|mm)/g,ht=e=>e.toString().padStart(2,"0"),mt=(e,t)=>{const n=(null!=t?t:"").trim(),a=/[Hhms]/.test(e)||!n?e:`${e} ${n}`.trim();return a.replace(/(H{1,2}):MM/g,(e,t)=>`${t}:mm`)},vt=e=>e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),ft=e=>{let t,n=0,a="^";for(;null!==(t=gt.exec(e));){a+=vt(e.slice(n,t.index));const r=t[0];a+=`(?<${r}>\\d{${"YYYY"===r?4:2}})`,n=t.index+r.length}return a+=vt(e.slice(n))+"$",new RegExp(a)},pt=(e,n,a,r)=>{const o=e.trim();if(!o)return null;const l=o.match(n),i=null==l?void 0:l.groups;if(!i)return null;const s=i.YYYY?Number(i.YYYY):i.YY?Number(i.YY)+2e3:a.year,d=i.MM?Number(i.MM):a.month,c=i.DD?Number(i.DD):a.day,u=i.HH?Number(i.HH):a.hour,g=i.mm?Number(i.mm):a.minute;try{return t.Temporal.ZonedDateTime.from({timeZone:r,year:s,month:d,day:c,hour:u,minute:g,second:a.second,millisecond:a.millisecond,microsecond:a.microsecond,nanosecond:a.nanosecond})}catch(e){return null}},yt=e=>{const n=e;if(n.timeZoneId&&"string"==typeof n.timeZoneId)return n.timeZoneId;if("timeZoneId"in e&&"string"==typeof e.timeZoneId)return e.timeZoneId;const a=e.timeZone;return a&&"string"==typeof a.id?a.id:"string"==typeof n.timeZone?n.timeZone:t.Temporal.Now.timeZoneId()},bt=(e,n,a)=>{var r,o,l,i,s,d,c,u,g,h,m,v,f,p,y,b,x,D,w,C,E,k,T,S;if(!e){const e=null!=n?n:a?yt(a):t.Temporal.Now.timeZoneId();return null!=a?a:t.Temporal.Now.zonedDateTimeISO(e)}if(rt(e)){const a=null!=n?n:t.Temporal.Now.timeZoneId(),r=`${e.year}-${ht(e.month)}-${ht(e.day)}T00:00:00[${a}]`;return t.Temporal.ZonedDateTime.from(r)}if("hour"in e&&!("timeZone"in e)){const a=null!=n?n:t.Temporal.Now.timeZoneId();if("function"==typeof e.toZonedDateTime)try{return e.toZonedDateTime(a)}catch(e){}return t.Temporal.ZonedDateTime.from({timeZone:a,year:e.year,month:e.month,day:e.day,hour:e.hour,minute:e.minute,second:null!==(r=e.second)&&void 0!==r?r:0,millisecond:null!==(o=e.millisecond)&&void 0!==o?o:0,microsecond:null!==(l=e.microsecond)&&void 0!==l?l:0,nanosecond:null!==(i=e.nanosecond)&&void 0!==i?i:0})}try{return t.Temporal.ZonedDateTime.from(e)}catch(r){const o=e,l=null!==(g=null!==(u=null!==(c=null!==(d="string"==typeof(null==o?void 0:o.timeZone)?o.timeZone:null===(s=null==o?void 0:o.timeZone)||void 0===s?void 0:s.id)&&void 0!==d?d:null==o?void 0:o.timeZoneId)&&void 0!==c?c:n)&&void 0!==u?u:a?yt(a):void 0)&&void 0!==g?g:t.Temporal.Now.timeZoneId();if("function"==typeof(null==o?void 0:o.toZonedDateTime))try{return o.toZonedDateTime({timeZone:l})}catch(e){}const i=null!=a?a:t.Temporal.Now.zonedDateTimeISO(l);return t.Temporal.ZonedDateTime.from({timeZone:l,year:null!==(h=null==o?void 0:o.year)&&void 0!==h?h:i.year,month:null!==(m=null==o?void 0:o.month)&&void 0!==m?m:i.month,day:null!==(v=null==o?void 0:o.day)&&void 0!==v?v:i.day,hour:null!==(p=null!==(f=null==o?void 0:o.hour)&&void 0!==f?f:null==a?void 0:a.hour)&&void 0!==p?p:0,minute:null!==(b=null!==(y=null==o?void 0:o.minute)&&void 0!==y?y:null==a?void 0:a.minute)&&void 0!==b?b:0,second:null!==(D=null!==(x=null==o?void 0:o.second)&&void 0!==x?x:null==a?void 0:a.second)&&void 0!==D?D:0,millisecond:null!==(C=null!==(w=null==o?void 0:o.millisecond)&&void 0!==w?w:null==a?void 0:a.millisecond)&&void 0!==C?C:0,microsecond:null!==(k=null!==(E=null==o?void 0:o.microsecond)&&void 0!==E?E:null==a?void 0:a.microsecond)&&void 0!==k?k:0,nanosecond:null!==(S=null!==(T=null==o?void 0:o.nanosecond)&&void 0!==T?T:null==a?void 0:a.nanosecond)&&void 0!==S?S:0})}},xt=(e,t,n)=>{const a=mt(t,n),r={YYYY:e.year.toString(),YY:ht(e.year%100),MM:ht(e.month),DD:ht(e.day),HH:ht(e.hour),mm:ht(e.minute)};return a.replace(gt,e=>{var t;return null!==(t=r[e])&&void 0!==t?t:e})},Dt=e=>{if("undefined"==typeof document)return e;const t=document.documentElement,n=[t.getAttribute("data-dayflow-theme-override"),t.getAttribute("data-theme-override"),t.getAttribute("data-theme")];for(const e of n)if("light"===e||"dark"===e)return e;return t.classList.contains("dark")?"dark":t.classList.contains("light")?"light":e};function wt(e,n=!1){if(e instanceof t.Temporal.PlainDate||e instanceof t.Temporal.PlainDateTime)return e;if(e instanceof Date)return n?st(e):dt(e);throw new Error("Invalid time type: "+typeof e)}function Ct(e,n){if(e instanceof t.Temporal.ZonedDateTime)return e;if(e instanceof Date)return ct(e,n);throw new Error("Invalid time type: "+typeof e)}function Et(e){var t;const n=wt(e.start,e.allDay),a=wt(e.end,e.allDay);return{id:e.id,title:e.title,description:e.description,start:n,end:a,allDay:null!==(t=e.allDay)&&void 0!==t&&t,calendarId:e.calendarId,meta:e.meta}}function kt(e){const t=Ct(e.start,e.timeZone),n=Ct(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 Tt=e=>{try{return e instanceof Date?e:"string"==typeof e?new Date(e):H(e)}catch(e){return new Date}},St=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},Nt=(e,t,n,a)=>{const r=e.getTime()-t.getTime(),o=Math.round(r/864e5);let l="",i="text-gray-500 dark:text-gray-400";if(0===o)l=a("today")||"Today",i="text-primary";else if(1===o||2===o)try{const e=new Intl.RelativeTimeFormat(n,{numeric:"auto"}).format(o,"day");l=e.charAt(0).toUpperCase()+e.slice(1),i="text-black dark:text-white"}catch(t){l=e.toLocaleDateString(n,{weekday:"long"})}else l=e.toLocaleDateString(n,{year:"numeric",month:"long",day:"numeric",weekday:"long"});return{title:l,colorClass:i}},Mt=(e,t)=>{const n=new Map;e.forEach(e=>{var t;const a=Tt(e.start),r=St(a),o=r.getTime();n.has(o)||n.set(o,{date:r,events:[]}),null===(t=n.get(o))||void 0===t||t.events.push(e)});const a=t.getTime();n.has(a)||n.set(a,{date:t,events:[]});return Array.from(n.values()).sort((e,t)=>e.date.getTime()-t.date.getTime())},It=/^(\d{4})(\d{2})(\d{2})$/,Ht=/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})$/,Rt=/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z$/;function Ot(e,n,a){const r=e.trim();if("DATE"===(null==n?void 0:n.value)||It.test(r)){const e=r.match(It);if(e)return t.Temporal.PlainDate.from({year:parseInt(e[1],10),month:parseInt(e[2],10),day:parseInt(e[3],10)})}if(Rt.test(r)){const e=r.match(Rt);if(e){const n=t.Temporal.Instant.from(`${e[1]}-${e[2]}-${e[3]}T${e[4]}:${e[5]}:${e[6]}Z`),r=a||t.Temporal.Now.timeZoneId();return n.toZonedDateTimeISO(r)}}const o=r.match(Ht);if(o){const e={year:parseInt(o[1],10),month:parseInt(o[2],10),day:parseInt(o[3],10),hour:parseInt(o[4],10),minute:parseInt(o[5],10),second:parseInt(o[6],10)};return(null==n?void 0:n.tzid)?t.Temporal.ZonedDateTime.from(Object.assign(Object.assign({},e),{timeZone:n.tzid})):t.Temporal.PlainDateTime.from(e)}throw new Error(`Invalid ICS date format: ${e}`)}function Pt(e,t=!1){if(t||rt(e)){const t=rt(e)?e:e.toPlainDate();return{value:`${t.year}${Lt(t.month)}${Lt(t.day)}`,params:{VALUE:"DATE"}}}if(lt(e)){const t=e.toInstant().toZonedDateTimeISO("UTC");return{value:`${t.year}${Lt(t.month)}${Lt(t.day)}T${Lt(t.hour)}${Lt(t.minute)}${Lt(t.second)}Z`}}if(ot(e))return{value:`${e.year}${Lt(e.month)}${Lt(e.day)}T${Lt(e.hour)}${Lt(e.minute)}${Lt(e.second)}`};throw new Error("Unsupported Temporal type")}function At(e){return`${e.getUTCFullYear()}${Lt(e.getUTCMonth()+1)}${Lt(e.getUTCDate())}T${Lt(e.getUTCHours())}${Lt(e.getUTCMinutes())}${Lt(e.getUTCSeconds())}Z`}function Lt(e){return String(e).padStart(2,"0")}function $t(e,n={}){const a={success:!1,events:[],errors:[],totalParsed:0,totalImported:0};try{const r=e.replace(/(\r\n|\n|\r)[ \t]/g,""),o=function(e){const t=[];let n=null,a=!1;for(const r of e){const e=r.trim().toUpperCase();e.startsWith("BEGIN:VEVENT")?(a=!0,n=[]):e.startsWith("END:VEVENT")?(a&&n&&t.push(n),a=!1,n=null):a&&n&&n.push(r)}return t}(r.split(/\r\n|\n|\r/));a.totalParsed=o.length,o.forEach((e,r)=>{try{const r=function(e){const t={};for(const n of e){const e=n.indexOf(":");if(-1===e)continue;const a=n.substring(0,e),r=n.substring(e+1),[o,...l]=a.split(";"),i=o.trim().toUpperCase(),s={};switch(l.forEach(e=>{const[t,n]=e.split("=");t&&n&&(s[t.trim().toUpperCase()]=n.trim())}),i){case"UID":t.uid=r.trim();break;case"SUMMARY":t.summary=jt(r);break;case"DESCRIPTION":t.description=jt(r);break;case"LOCATION":t.location=jt(r);break;case"DTSTART":t.dtstart=r.trim(),t.dtstartParams={value:s.VALUE,tzid:s.TZID};break;case"DTEND":t.dtend=r.trim(),t.dtendParams={value:s.VALUE,tzid:s.TZID};break;case"CATEGORIES":t.categories=r.split(",").map(e=>jt(e.trim()))}}if(!t.dtstart)throw new Error("Missing DTSTART in VEVENT");t.uid||(t.uid=ue());return t}(e),o=function(e,n){var a;const{calendarId:r="default",generateNewIds:o=!0,idPrefix:l="ics-",defaultTimeZone:i}=n,s=o?`${l}${ue()}`:e.uid,d=Ot(e.dtstart,e.dtstartParams,i);let c;c=e.dtend?Ot(e.dtend,e.dtendParams,i):rt(d)?d.add({days:1}):d.add({hours:1});const u="DATE"===(null===(a=e.dtstartParams)||void 0===a?void 0:a.value)||rt(d),g=i||t.Temporal.Now.timeZoneId();let h,m;if(rt(d))h=d.toZonedDateTime({timeZone:g,plainTime:"00:00:00"});else if(ot(d))try{if("function"!=typeof d.toZonedDateTime)throw new Error("toZonedDateTime missing");h=d.toZonedDateTime(g)}catch(e){h=t.Temporal.ZonedDateTime.from({year:d.year,month:d.month,day:d.day,hour:d.hour,minute:d.minute,second:d.second,millisecond:d.millisecond,timeZone:g})}else h=d;if(rt(c))m=c.toZonedDateTime({timeZone:g,plainTime:"00:00:00"});else if(ot(c))try{if("function"!=typeof c.toZonedDateTime)throw new Error("toZonedDateTime missing");m=c.toZonedDateTime(g)}catch(e){m=t.Temporal.ZonedDateTime.from({year:c.year,month:c.month,day:c.day,hour:c.hour,minute:c.minute,second:c.second,millisecond:c.millisecond,timeZone:g})}else m=c;return{id:s,calendarId:r,title:e.summary||"(No Title)",description:e.description,start:h,end:m,allDay:u,meta:{location:e.location,originalUid:e.uid,categories:e.categories}}}(r,n);a.events.push(o)}catch(e){a.errors.push({line:0,message:e.message||"Unknown parsing error",eventUid:`index-${r}`})}}),a.success=0===a.errors.length,a.totalImported=a.events.length}catch(e){a.errors.push({message:`Fatal parsing error: ${e.message}`})}return a}function jt(e){return e.replace(/\\,/g,",").replace(/\\;/g,";").replace(/\\[nN]/g,"\n").replace(/\\\\/g,"\\")}function Yt(e,t={}){const{calendarName:n="DayFlow Calendar",productId:a="-//DayFlow//DayFlow Calendar//EN",includeTimezone:r=!0}=t,o=[];return o.push("BEGIN:VCALENDAR"),o.push("VERSION:2.0"),o.push(`PRODID:${a}`),o.push("CALSCALE:GREGORIAN"),o.push("METHOD:PUBLISH"),o.push(`X-WR-CALNAME:${Vt(n)}`),e.forEach(e=>{o.push(...function(e){var t,n,a;const r=[];r.push("BEGIN:VEVENT");const o=null===(t=e.meta)||void 0===t?void 0:t.originalUid,l=o||`${e.id}@dayflow`;r.push(`UID:${l}`),r.push(`DTSTAMP:${At(new Date)}`);const i=Pt(e.start,e.allDay),s=Pt(e.end,e.allDay);r.push(Ft("DTSTART",i.value,i.params)),r.push(Ft("DTEND",s.value,s.params)),r.push(Ft("SUMMARY",Vt(e.title))),e.description&&r.push(Ft("DESCRIPTION",Vt(e.description)));const d=null===(n=e.meta)||void 0===n?void 0:n.location;d&&r.push(Ft("LOCATION",Vt(d)));const c=null===(a=e.meta)||void 0===a?void 0:a.categories;if(c&&Array.isArray(c)){const e=c.map(Vt).join(",");r.push(Ft("CATEGORIES",e))}return r.push("END:VEVENT"),r}(e))}),o.push("END:VCALENDAR"),o.join("\r\n")}function zt(e,t={}){const n=Yt(e,t),a=`${t.filename||"calendar"}.ics`,r=new Blob([n],{type:"text/calendar;charset=utf-8"}),o=URL.createObjectURL(r),l=document.createElement("a");l.href=o,l.setAttribute("download",a),document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(o)}function Ft(e,t,n){let a=e;return n&&Object.entries(n).forEach(([e,t])=>{a+=`;${e}=${t}`}),a+=`:${t}`,function(e){if(e.length<=75)return e;const t=[];let n=e;t.push(n.slice(0,75)),n=n.slice(75);for(;n.length>0;)t.push(" "+n.slice(0,74)),n=n.slice(74);return t.join("\r\n")}(a)}function Vt(e){return e?e.replace(/\\/g,"\\\\").replace(/;/g,"\\;").replace(/,/g,"\\,").replace(/\n/g,"\\n"):""}function _t(e,t){return a.__awaiter(this,void 0,void 0,function*(){return new Promise((n,a)=>{const r=new FileReader;r.onload=e=>{var a;try{const r=null===(a=e.target)||void 0===a?void 0:a.result;if(!r)throw new Error("File content is empty");const o=$t(r,t);n(o)}catch(e){n({success:!1,events:[],errors:[{message:e.message||"Failed to read file"}],totalParsed:0,totalImported:0})}},r.onerror=()=>{n({success:!1,events:[],errors:[{message:"File read error"}],totalParsed:0,totalImported:0})},r.readAsText(e)})})}const Wt=({x:e,y:n,date:r,onClose:o,app:l,onCreateEvent:i,viewType:s})=>{const{t:d}=Ue(),c=nt.hasEvent();return ye(Ze,{x:e,y:n,onClose:o,children:[ye(qe,{onClick:()=>{i(),o()},children:d("newEvent")||"New Event"}),ye(qe,{onClick:()=>a.__awaiter(void 0,void 0,void 0,function*(){yield((e,n,r)=>a.__awaiter(void 0,void 0,void 0,function*(){if(nt.hasEvent())try{let o=nt.getEvent();if(!o){const e=yield navigator.clipboard.readText();e&&(o=JSON.parse(e))}if(o&&"object"==typeof o&&o.title){const l=it(o.start),i=it(o.end).getTime()-l.getTime(),s=o,{_segmentInfo:d}=s,c=a.__rest(s,["_segmentInfo"]),u=new Date(n),g=r===exports.ViewType.MONTH||r===exports.ViewType.YEAR,h=0===u.getHours()&&0===u.getMinutes(),m=0!==l.getHours()||0!==l.getMinutes();!o.allDay&&(g||h&&m)&&u.setHours(l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds());const v=new Date(u.getTime()+(i>0?i:36e5)),f=Object.assign(Object.assign({},c),{id:ue(),start:o.allDay?st(u):ct(u,t.Temporal.Now.timeZoneId()),end:o.allDay?st(v):ct(v,t.Temporal.Now.timeZoneId()),calendarId:o.calendarId&&e.getCalendarRegistry().has(o.calendarId)?o.calendarId:e.getCalendarRegistry().getDefaultCalendarId()||"default"});e.addEvent(f)}}catch(e){console.error("Failed to paste event:",e)}}))(l,r,s),o()}),disabled:!c,children:d("pasteHere")||"Paste Here"})]})},Bt=({event:e,x:t,y:r,onClose:o,app:l})=>{var i,s;const{t:d}=Ue(),c=l.getCalendars(),u=null===(s=null===(i=l.callbacks)||void 0===i?void 0:i.renderEventContextMenu)||void 0===s?void 0:s.call(i,e,o);return ye(Ze,{x:t,y:r,onClose:o,children:[ye(Ge,{children:[ye(Je,{children:d("calendars")||"Calendars"}),ye(Qe,{children:c.map(t=>{const n=t.id===e.calendarId;return ye(qe,{onClick:()=>{return n=t.id,l.updateEvent(e.id,{calendarId:n}),void o();var n},children:ye("div",{className:"flex items-center w-full",children:[ye("div",{className:"w-4 shrink-0",children:n&&ye(Te,{className:"w-3 h-3 text-primary"})}),ye("div",{className:"flex items-center gap-1.5 min-w-0",children:[ye("div",{className:"w-3 h-3 rounded-sm shrink-0",style:{backgroundColor:t.colors.lineColor}}),ye("span",{className:"truncate "+(n?"font-semibold":""),children:t.name})]})]})},t.id)})})]}),ye(Ke,{}),ye(qe,{onClick:()=>{l.deleteEvent(e.id),o()},danger:!0,children:d("delete")||"Delete"}),ye(qe,{onClick:()=>a.__awaiter(void 0,void 0,void 0,function*(){try{const t=JSON.stringify(e,null,2);yield navigator.clipboard.writeText(t),nt.setEvent(e),l.deleteEvent(e.id)}catch(e){console.error("Failed to cut event: ",e)}o()}),children:d("cut")||"Cut"}),ye(qe,{onClick:()=>a.__awaiter(void 0,void 0,void 0,function*(){try{const t=JSON.stringify(e,null,2);yield navigator.clipboard.writeText(t),nt.setEvent(e)}catch(e){console.error("Failed to copy event: ",e)}o()}),children:d("copy")||"Copy"}),u&&ye(n.Fragment,{children:[ye(Ke,{}),u]})]})},Ut=e=>{const t=r.useRef(null),n=r.useRef(null);return r.useEffect(()=>{if(t.current){const{className:r}=e,o=a.__rest(e,["className"]);n.current=new l.BlossomColorPicker(t.current,o)}return()=>{n.current&&(n.current.destroy(),n.current=null)}},[]),r.useEffect(()=>{if(n.current){const{className:t}=e,r=a.__rest(e,["className"]);n.current.setOptions(r)}},[e]),ye("div",{ref:t,className:e.className})};let Zt=0;function qt({generatorName:e,generatorArgs:t,defaultContent:n,store:a}){const o=r.useRef(null),l=r.useContext(fe),i=a||l,s=r.useRef(null);s.current||(s.current="df-slot-"+Zt++),r.useEffect(()=>{if(!o.current||!i)return;const n=s.current;return i.register({id:n,containerEl:o.current,generatorName:e,generatorArgs:t}),()=>i.unregister(n)},[i,e,JSON.stringify(t)]);const d="eventContent"===e,c=null==i?void 0:i.isOverridden(e);return ye("div",{ref:o,className:"df-content-slot "+(d?"flex-1 flex flex-col h-full":""),children:!c&&n})}const Kt=({color:e,onChange:t,onClose:n})=>{const a=r.useMemo(()=>{const{h:t,s:n,l:a}=l.hexToHsl(e);return{hue:t,saturation:l.lightnessToSliderValue(a),lightness:a,alpha:100,layer:"outer"}},[e]);return ye("div",{className:"flex justify-center",children:ye(Ut,{defaultValue:a,coreSize:36,petalSize:32,openOnHover:!1,onChange:e=>t({hex:e.hex},!0),onCollapse:n})})},Xt="df-month-view h-full flex flex-col bg-white dark:bg-gray-900 select-none",Gt="p-2 flex justify-between",Jt="text-2xl font-bold text-gray-900 dark:text-gray-100",Qt="rounded-md bg-background border border-border px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-(--hover)",en="df-date-number inline-flex items-center justify-center h-6 w-6 rounded-full text-sm mt-1 select-none",tn="flex-1 overflow-auto will-change-scroll",nn="scrollbar-hide",an="df-time-slot relative h-[4.5rem] flex",rn="df-time-label absolute top-0 -translate-y-1/2 right-2 text-[12px] text-gray-500 dark:text-gray-400 select-none",on="df-time-grid-row h-[4.5rem] border-t border-gray-200 dark:border-gray-700 flex",ln="df-current-time-line absolute left-0 top-0 w-full flex pointer-events-none",sn="df-current-time-label ml-2 text-primary-foreground text-xs font-bold px-1.5 bg-primary rounded-sm",dn="df-all-day-row flex items-center border-b border-gray-200 dark:border-gray-700 sticky",cn="rounded-xl my-0.5",un="rounded-sm",gn="df-event-title font-medium text-xs truncate pr-1",hn="df-event-color-bar absolute left-1 top-1 bottom-1 w-[3px] rounded-full",mn="df-month-event-color-bar inline-block w-0.75 h-3 mr-1 shrink-0 rounded-full",vn="h-3 w-3 mr-1",fn="resize-handle absolute right-0 top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20",pn="bg-primary rounded-full text-primary-foreground",yn="df-nav-button calendar-nav-button group relative inline-flex items-center justify-center w-7 h-7 rounded-md border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 hover:border-gray-300 dark:hover:border-gray-500 active:bg-gray-100 dark:active:bg-gray-600 transition-all duration-150 shadow-sm hover:shadow focus:outline-none",bn="h-4 w-4 transition-transform group-hover:scale-110",xn="df-event-detail-panel fixed bg-white dark:bg-gray-800 shadow-lg border border-gray-200 dark:border-gray-700 rounded-lg",Dn="h-3 border-t border-gray-200 dark:border-gray-700 relative",wn="absolute top-0 -translate-y-1/2 text-[12px] text-gray-500 dark:text-gray-400",Cn="flex h-7 w-7 items-center justify-center rounded hover:bg-gray-100 dark:hover:bg-slate-800 transition-colors",En="text-gray-500 dark:text-gray-400",kn="text-gray-600 dark:text-gray-300",Tn="text-xs",Sn="text-sm",Nn="flex flex-col",Mn="mr-1",In=(...e)=>e.filter(Boolean).join(" "),Hn=({isCollapsed:e,onCollapseToggle:t})=>{const{t:n}=Ue();return ye("div",{className:"df-sidebar-header flex items-center px-2 py-2",children:[ye("button",{type:"button","aria-label":n(e?"expandSidebar":"collapseSidebar"),className:"df-sidebar-header-toggle flex h-8 w-8 items-center justify-center rounded hover:bg-gray-100 dark:hover:bg-slate-800",onClick:t,children:ye(e?Le:$e,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"})}),!e&&ye("div",{className:"flex flex-1 justify-between items-center ml-3",children:ye("span",{className:"df-sidebar-header-title text-sm font-semibold text-gray-700 dark:text-gray-200",children:n("calendars")})})]})},Rn=e=>{if(e.icon)return e.icon;return(e.name||e.id).charAt(0).toUpperCase()},On=({calendars:e,onToggleVisibility:t,onReorder:n,onRename:a,onContextMenu:o,onColorClick:l,editingId:i,setEditingId:s,activeContextMenuCalendarId:d,isDraggable:c=!0,isEditable:u=!0})=>{const[g,h]=r.useState(""),m=r.useRef(null),v=r.useRef(!1),[f,p]=r.useState(!1),[y,b]=r.useState(null),[x,D]=r.useState(null),w=r.useCallback((e,t)=>{if(i||!c)return void t.preventDefault();p(!0),b(e.id);const n={calendarId:e.id,calendarName:e.name,calendarColors:e.colors,calendarIcon:e.icon};t.dataTransfer.setData("application/x-dayflow-calendar",JSON.stringify(n)),t.dataTransfer.effectAllowed="copy"},[i]),C=r.useCallback(()=>{p(!1),b(null),D(null)},[]),E=r.useCallback((t,n)=>{if(t.preventDefault(),y===n)return void D(null);const a=e.findIndex(e=>e.id===n)===e.length-1,r=t.currentTarget.getBoundingClientRect(),o=t.clientY<r.top+r.height/2;D(a?{id:n,position:o?"top":"bottom"}:{id:n,position:"top"})},[y,e]),k=r.useCallback(()=>{D(null)},[]),T=r.useCallback(t=>{if(!y||!x)return;if(y===t.id)return;const a=e.findIndex(e=>e.id===y);let r=e.findIndex(e=>e.id===t.id);"bottom"===x.position&&(r+=1),r>a&&(r-=1),-1!==a&&-1!==r&&n(a,r),D(null)},[y,x,e,n]),S=r.useCallback(e=>{u&&(v.current=!1,s(e.id),h(e.name))},[s,u]);r.useCallback(e=>{h(e.target.value)},[]);const N=r.useCallback(()=>{if(!v.current){if(v.current=!0,i&&g.trim()){const t=e.find(e=>e.id===i);t&&t.name!==g.trim()&&a(i,g.trim())}s(null),h("")}},[i,g,e,a,s]),M=r.useCallback(()=>{v.current||(v.current=!0,s(null),h(""))},[s]),I=r.useCallback(e=>{"Enter"===e.key?N():"Escape"===e.key&&M()},[N,M]);return r.useEffect(()=>{i&&m.current&&(m.current.focus(),m.current.select())},[i]),r.useEffect(()=>{if(i){const t=e.find(e=>e.id===i);t&&h(t.name)}},[i,e]),ye("div",{className:"df-calendar-list flex-1 overflow-y-auto px-2 pb-3",children:ye("ul",{className:"space-y-1 relative",children:e.map(e=>{var n;const a=!1!==e.isVisible,r=(null===(n=e.colors)||void 0===n?void 0:n.lineColor)||"#3b82f6",s=Boolean(e.icon),u=(null==x?void 0:x.id)===e.id,v=d===e.id||i===e.id;return ye("li",{className:"df-calendar-list-item relative",onDragOver:t=>E(t,e.id),onDragLeave:k,onDrop:()=>T(e),onContextMenu:t=>o(t,e.id),children:[u&&"top"===x.position&&ye("div",{className:"absolute top-0 left-0 right-0 h-0.5 bg-primary z-10 pointer-events-none"}),ye("div",{draggable:c&&!i,onDragStart:t=>w(e,t),onDragEnd:C,className:`rounded transition ${y===e.id?"opacity-50":""} ${c?"cursor-grab":"cursor-default"}`,children:ye("div",{className:"group flex items-center rounded px-2 py-2 transition hover:bg-gray-100 dark:hover:bg-slate-800 "+(v?"bg-gray-100 dark:bg-slate-800":""),title:e.name,children:[ye("input",{type:"checkbox",className:"calendar-checkbox cursor-pointer shrink-0",style:{"--checkbox-color":r},checked:a,onChange:n=>t(e.id,n.target.checked),onClick:t=>{l&&a&&(t.preventDefault(),l(t,e.id))}}),s&&ye("span",{className:"ml-2 flex h-5 w-5 shrink-0 items-center justify-center text-xs font-semibold text-white","aria-hidden":"true",children:Rn(e)}),i===e.id?ye("input",{ref:m,type:"text",value:g,onChange:e=>h(e.target.value),onBlur:N,onKeyDown:I,className:"ml-2 flex-1 min-w-0 h-5 rounded bg-white px-0 py-0 text-sm text-gray-900 focus:outline-none dark:bg-slate-700 dark:text-gray-100",onClick:e=>e.stopPropagation()}):ye("span",{className:"flex-1 pl-1 truncate text-sm text-gray-700 group-hover:text-gray-900 dark:text-gray-200 dark:group-hover:text-white ml-2",onDblClick:()=>S(e),children:e.name||e.id})]})}),u&&"bottom"===x.position&&ye("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary z-10 pointer-events-none"})]},e.id)})})})},Pn=({visibleMonth:e,currentDate:t,showHeader:n=!1,onMonthChange:a,onDateSelect:o})=>{const{locale:l}=Ue(),i=r.useMemo(()=>(new Date).toDateString(),[]),s=t.toDateString(),d=r.useMemo(()=>Ve(l,"narrow"),[l]),c=r.useMemo(()=>e.toLocaleDateString(l,{month:"long",year:"numeric"}),[e,l]),u=r.useMemo(()=>{const t=e.getFullYear(),n=e.getMonth(),a=(new Date(t,n,1).getDay()+6)%7,r=[];for(let e=0;e<42;e++){const o=new Date(t,n,e-a+1),l=o.toDateString();r.push({date:o.getDate(),fullDate:o,isCurrentMonth:o.getMonth()===n,isToday:l===i,isSelected:l===s})}return r},[e,s,i]);return ye("div",{className:"px-3 py-3",children:[n?ye("div",{className:"mb-3 flex items-center justify-between",children:[ye("button",{type:"button",className:"flex h-7 w-7 items-center justify-center rounded-full text-gray-500 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-slate-800",onClick:()=>a(-1),"aria-label":"Previous month",children:ye(be,{className:"h-4 w-4"})}),ye("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:c}),ye("button",{type:"button",className:"flex h-7 w-7 items-center justify-center rounded-full text-gray-500 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-slate-800",onClick:()=>a(1),"aria-label":"Next month",children:ye(xe,{className:"h-4 w-4"})})]}):"",ye("div",{className:"df-mini-calendar-grid grid grid-cols-7 gap-1 text-xs justify-items-center",children:[d.map((e,t)=>ye("div",{className:"df-mini-calendar-header text-center text-gray-500 dark:text-gray-400 font-medium py-1 h-6 w-6 text-gray-500 dark:text-gray-400",children:e},`weekday-${t}`)),u.map(e=>ye("button",{type:"button",className:`\n df-mini-calendar-day text-center py-1 rounded text-xs h-6 w-6\n ${e.isToday?pn:e.isCurrentMonth?"text-gray-900 dark:text-gray-100":"text-gray-400 dark:text-gray-600"}\n ${e.isSelected&&!e.isToday?"bg-secondary text-secondary-foreground rounded-full font-medium":""}\n `,onClick:()=>o(e.fullDate),children:e.date},e.fullDate.getTime()))]})]})},An=({calendars:e,currentCalendarId:t,onMergeSelect:a})=>{const{t:l}=Ue(),[i,s]=r.useState(!1),d=r.useRef(null),c=r.useRef(null),[u,g]=r.useState({x:0,y:0}),h=r.useRef(),m=()=>{if(h.current&&clearTimeout(h.current),d.current){const e=d.current.getBoundingClientRect();g({x:e.right,y:e.top})}s(!0)},v=()=>{h.current=setTimeout(()=>{s(!1)},100)};r.useEffect(()=>{const e=c.current;if(e){const t=e=>e.stopPropagation();return e.addEventListener("mousedown",t),()=>{e.removeEventListener("mousedown",t)}}},[i]);const f=e.filter(e=>e.id!==t);return 0===f.length?null:ye(n.Fragment,{children:[ye("div",{ref:d,className:"relative flex cursor-default select-none items-center justify-between rounded-sm px-3 py-0.5 text-[12px] outline-none hover:bg-primary hover:text-white dark:text-slate-200 dark:hover:bg-primary dark:hover:text-white transition-colors",onMouseEnter:m,onMouseLeave:v,children:[ye("span",{children:l("merge")}),ye(xe,{className:"h-4 w-4"})]}),i&&o.createPortal(ye("div",{ref:c,className:"fixed z-60 min-w-48 overflow-hidden rounded-md border border-slate-200 bg-white p-1 shadow-md dark:border-slate-800 dark:bg-slate-950 animate-in fade-in-0 zoom-in-95 duration-100",style:{top:u.y,left:u.x},onMouseEnter:m,onMouseLeave:v,onMouseDown:e=>e.stopPropagation(),children:f.map(e=>ye("div",{className:"flex items-center cursor-pointer rounded-sm px-3 py-1 text-[12px] text-slate-900 hover:bg-primary hover:text-white dark:text-slate-50 dark:hover:bg-primary dark:hover:text-white transition-colors",onClick:t=>{t.stopPropagation(),a(e.id)},children:[ye("div",{className:"mr-2 h-3 w-3 rounded-sm shrink-0",style:{backgroundColor:e.colors.lineColor}}),ye("span",{className:"truncate",children:e.name||e.id})]},e.id))}),document.body)]})},Ln=({sourceName:e,targetName:t,onConfirm:n,onCancel:a})=>{const{t:r}=Ue();return ye("div",{className:"fixed inset-0 z-100 flex items-center justify-center bg-black/50",children:ye("div",{className:"w-full max-w-md rounded-lg p-6 shadow-xl bg-background",children:[ye("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:r("mergeConfirmTitle",{sourceName:e,targetName:t})}),ye("p",{className:"mt-3 text-sm text-gray-600 dark:text-gray-300",children:r("mergeConfirmMessage",{sourceName:e,targetName:t})}),ye("div",{className:"mt-6 flex justify-end gap-3",children:[ye("button",{type:"button",onClick:a,className:Qt,children:r("cancel")}),ye("button",{type:"button",onClick:n,className:"rounded-md bg-destructive px-4 py-2 text-sm font-medium text-destructive-foreground hover:bg-destructive/90",children:r("merge")})]})]})})},$n=({calendarId:e,calendarName:t,calendars:a,step:o,onStepChange:l,onConfirmDelete:i,onCancel:s,onMergeSelect:d})=>{const[c,u]=r.useState(!1),{t:g}=Ue();return ye("div",{className:"fixed inset-0 z-100 flex items-center justify-center bg-black/50",children:ye("div",{className:"w-full max-w-md rounded-lg p-6 shadow-xl bg-background",children:ye(n.Fragment,"initial"===o?{children:[ye("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:g("deleteCalendar",{calendarName:t})}),ye("p",{className:"mt-3 text-sm text-gray-600 dark:text-gray-300",children:g("deleteCalendarMessage",{calendarName:t})}),ye("div",{className:"mt-6 flex justify-between items-center",children:[ye("div",{className:"relative",children:[ye("button",{type:"button",onClick:()=>u(!c),className:"flex items-center gap-1 rounded-md border border-gray-300 px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50 dark:border-gray-600 dark:text-gray-200 dark:hover:bg-slate-700",children:g("merge")}),c&&ye("div",{className:"absolute left-0 top-full mt-1 min-w-full w-max rounded-md border border-gray-200 bg-background shadow-lg dark:border-slate-700 z-10 max-h-60 overflow-y-auto",children:a.filter(t=>t.id!==e).map(e=>ye("div",{className:"flex items-center px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-slate-700 cursor-pointer",onClick:()=>{d(e.id),u(!1)},children:[ye("div",{className:"mr-2 h-3 w-3 rounded-sm shrink-0",style:{backgroundColor:e.colors.lineColor}}),ye("span",{className:"whitespace-nowrap",children:e.name||e.id})]},e.id))})]}),ye("div",{className:"flex gap-3",children:[ye("button",{type:"button",onClick:s,className:Qt,children:g("cancel")}),ye("button",{type:"button",onClick:()=>l("confirm_delete"),className:"rounded-md bg-destructive px-4 py-2 text-sm font-medium text-destructive-foreground hover:bg-destructive/90",children:g("delete")})]})]})]}:{children:[ye("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:g("confirmDeleteTitle",{calendarName:t})}),ye("p",{className:"mt-3 text-sm text-gray-600 dark:text-gray-300",children:g("confirmDeleteMessage")}),ye("div",{className:"mt-6 flex justify-end gap-3",children:[ye("button",{type:"button",onClick:s,className:"rounded-md px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-slate-700",children:g("cancel")}),ye("button",{type:"button",onClick:i,className:"rounded-md bg-destructive px-4 py-2 text-sm font-medium text-destructive-foreground hover:bg-destructive/90",children:g("delete")})]})]})})})},jn="new-calendar",Yn=({calendars:e,filename:t,onConfirm:n,onCancel:a})=>{var l;const{t:i}=Ue(),[s,d]=r.useState((null===(l=e[0])||void 0===l?void 0:l.id)||jn),[c,u]=r.useState(!1),[g,h]=r.useState(!1),m=r.useRef(null),v=r.useRef(null);r.useEffect(()=>{if(!c){const e=setTimeout(()=>h(!1),200);return()=>clearTimeout(e)}h(!0)},[c]),r.useEffect(()=>{const e=e=>{var t;!m.current||m.current.contains(e.target)||(null===(t=v.current)||void 0===t?void 0:t.contains(e.target))||u(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const f=e.find(e=>e.id===s),p=s===jn,y=e=>{d(e),u(!1)};return ye("div",{className:"fixed inset-0 z-100 flex items-center justify-center bg-black/50",children:ye("div",{className:"w-full max-w-md rounded-lg bg-white p-6 shadow-xl dark:bg-slate-900",children:[ye("h2",{className:"mb-4 text-lg font-semibold text-gray-900 dark:text-white",children:i("addSchedule")||"Add Schedule"}),ye("p",{className:"mb-4 text-sm text-gray-600 dark:text-gray-300",children:i("importCalendarMessage")||"This calendar contains new events. Please select a target calendar."}),ye("div",{className:"relative",children:[ye("button",{ref:v,type:"button",className:"flex items-center w-full border border-gray-300 dark:border-gray-600 rounded-md px-3 py-2 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors shadow-sm",onClick:()=>u(!c),children:[!p&&f&&ye("div",{className:"mr-3 h-3 w-3 shrink-0 rounded-sm",style:{backgroundColor:f.colors.lineColor}}),ye("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-200 flex-1 text-left truncate "+(p?"pl-0":""),children:p?`${i("newCalendar")}: ${t}`:(null==f?void 0:f.name)||(null==f?void 0:f.id)}),ye(Se,{className:"w-4 h-4 text-gray-400 shrink-0 ml-2"})]}),(()=>{var n;if(!g)return null;const a=null===(n=v.current)||void 0===n?void 0:n.getBoundingClientRect();return a?o.createPortal(ye("div",{ref:m,className:"fixed z-110 mt-1 max-h-60 overflow-y-auto rounded-md bg-white shadow-lg border border-gray-200 dark:border-slate-700 dark:bg-slate-800 transition-all duration-200 origin-top "+(c?"opacity-100 scale-100":"opacity-0 scale-95"),style:{top:a.bottom,left:a.left,width:a.width},children:ye("div",{className:"py-1",children:[e.map(e=>ye("div",{className:"flex items-center px-3 py-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-slate-700 "+(s===e.id?"bg-primary/10":""),onClick:()=>y(e.id),children:[ye("div",{className:"mr-3 h-3 w-3 shrink-0 rounded-sm",style:{backgroundColor:e.colors.lineColor}}),ye("span",{className:"flex-1 text-sm truncate "+(s===e.id?"font-medium text-primary":"text-gray-700 dark:text-gray-200"),children:e.name||e.id}),s===e.id&&ye(Te,{className:"ml-2 w-4 h-4 text-primary shrink-0"})]},e.id)),ye("div",{className:"border-t border-gray-100 dark:border-slate-700 my-1"}),ye("div",{className:"flex items-center px-3 py-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-slate-700 "+(p?"bg-primary/10":""),onClick:()=>y(jn),children:[ye("span",{className:"flex-1 text-sm truncate "+(p?"font-medium text-primary":"text-gray-700 dark:text-gray-200 pl-6"),children:[i("newCalendar")||"New Calendar",": ",t]}),p&&ye(Te,{className:"ml-2 w-4 h-4 text-primary shrink-0"})]})]})}),document.body):null})()]}),ye("div",{className:"mt-8 flex justify-end gap-3",children:[ye("button",{type:"button",onClick:a,className:Qt,children:i("cancel")||"Cancel"}),ye("button",{type:"button",onClick:()=>n(s),className:"rounded-md bg-primary px-6 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 transition-colors shadow-sm",children:i("ok")||"OK"})]})]})})},zn=({app:e,calendars:t,toggleCalendarVisibility:i,isCollapsed:s,setCollapsed:d,renderCalendarContextMenu:c,editingCalendarId:u,setEditingCalendarId:g,onCreateCalendar:m,colorPickerMode:v="default"})=>{var f,p,y,b;const{t:x}=Ue(),D=e.getVisibleMonth(),w=D.getFullYear(),C=D.getMonth(),[E,k]=r.useState(null),T=void 0!==u?u:E,S=g||k,N=r.useRef(null),M=r.useRef(null),[I,H]=r.useState(()=>new Date(w,C,1));r.useEffect(()=>{H(e=>e.getFullYear()===w&&e.getMonth()===C?e:new Date(w,C,1))},[w,C]);const R=r.useCallback(t=>{H(n=>{const a=new Date(n.getFullYear(),n.getMonth()+t,1);return e.setVisibleMonth(a),a})},[e]),[O,P]=r.useState(null),[A,L]=r.useState(null),[$,j]=r.useState(null),[Y,z]=r.useState(null),[F,V]=r.useState(null),[_,W]=r.useState(null),B=r.useCallback((e,t)=>{e.preventDefault(),e.stopPropagation(),P({x:e.clientX,y:e.clientY,calendarId:t,rowRect:e.currentTarget.getBoundingClientRect()}),L(null)},[]),U=r.useCallback(e=>{e.preventDefault(),L({x:e.clientX,y:e.clientY}),P(null)},[]),Z=r.useCallback(()=>{P(null)},[]),q=r.useCallback(()=>{L(null)},[]),K=r.useCallback((e,n)=>{e.preventDefault(),e.stopPropagation();const a=t.find(e=>e.id===n);if(a){const{l:t,h:r}=l.hexToHsl(a.colors.lineColor),o=l.lightnessToSliderValue(t),i=e.currentTarget.getBoundingClientRect();j({x:i.left+i.width/2,y:i.top+i.height/2,calendarId:n,initialColor:{hue:r,saturation:o,lightness:t,alpha:100,layer:"outer"},currentColor:a.colors.lineColor})}},[t]),X=r.useCallback(()=>{O&&(V({calendarId:O.calendarId,step:"initial"}),Z())},[O,Z]),G=r.useCallback(t=>{if(O){const{colors:n,darkColors:a}=h(t);e.updateCalendar(O.calendarId,{colors:n,darkColors:a}),Z()}},[e,O,Z]),J=r.useCallback(()=>{if(O){const e=t.find(e=>e.id===O.calendarId);if(e){const{l:t,h:n}=l.hexToHsl(e.colors.lineColor),a=l.lightnessToSliderValue(t);let r=O.x,o=O.y;if(O.rowRect)r=O.rowRect.left+24,o=O.rowRect.top+O.rowRect.height/2;else if(M.current){const e=M.current.getBoundingClientRect();r=e.left+e.width/2,o=e.top+e.height/2}j({x:r,y:o,calendarId:O.calendarId,initialColor:{hue:n,saturation:a,lightness:t,alpha:100,layer:"outer"},currentColor:e.colors.lineColor})}Z()}},[O,t,Z]),Q=r.useCallback(e=>{O&&(z({sourceId:O.calendarId,targetId:e}),Z())},[O,Z]),ee=r.useCallback(()=>{if(Y){const{sourceId:t,targetId:n}=Y;e.mergeCalendars(t,n),z(null)}},[e,Y]),te=r.useCallback(()=>{F&&(e.deleteCalendar(F.calendarId),V(null))},[e,F]),ne=r.useCallback(e=>{F&&(z({sourceId:F.calendarId,targetId:e}),V(null))},[F]),ae=r.useCallback(()=>{var e;null===(e=N.current)||void 0===e||e.click(),q()},[q]),re=r.useCallback(e=>a.__awaiter(void 0,void 0,void 0,function*(){var t;const n=null===(t=e.target.files)||void 0===t?void 0:t[0];if(!n)return;const a=yield _t(n);a.events.length>0&&W({events:a.events,filename:n.name.replace(/\.[^/.]+$/,"")}),N.current&&(N.current.value="")}),[]),oe=r.useCallback(t=>{if(_){let n=t;if(t===jn){const t=["#3b82f6","#10b981","#8b5cf6","#f59e0b","#ef4444","#f97316","#ec4899","#14b8a6","#6366f1","#6b7280"],a=t[Math.floor(Math.random()*t.length)],{colors:r,darkColors:o}=h(a);n=ue(),e.createCalendar({id:n,name:_.filename,isDefault:!1,colors:r,darkColors:o,isVisible:!0})}_.events.forEach(t=>{e.addEvent(Object.assign(Object.assign({},t),{calendarId:n}))}),W(null)}},[e,_]),le=r.useCallback(()=>{if(O){const n=t.find(e=>e.id===O.calendarId);if(n){zt(e.getEvents().filter(e=>e.calendarId===n.id),{calendarName:n.name,filename:n.name||"calendar"})}Z()}},[O,t,e,Z]),ie=Y?(null===(f=t.find(e=>e.id===Y.sourceId))||void 0===f?void 0:f.name)||"Unknown":"",se=Y?(null===(p=t.find(e=>e.id===Y.targetId))||void 0===p?void 0:p.name)||"Unknown":"",de=F?(null===(y=t.find(e=>e.id===F.calendarId))||void 0===y?void 0:y.name)||"Unknown":"",ce=e.getReadOnlyConfig(),ge=!e.state.readOnly,he=!1!==ce.draggable;return ye("div",{className:"df-sidebar flex h-full flex-col border-r border-gray-200 dark:border-gray-700 bg-white dark:bg-slate-900",onContextMenu:ge?U:void 0,children:[ye(Hn,{isCollapsed:s,onCollapseToggle:()=>d(!s)}),s?ye(On,{calendars:t,onToggleVisibility:i,onReorder:he?e.reorderCalendars:()=>{},onRename:ge?(t,n)=>e.updateCalendar(t,{name:n}):()=>{},onContextMenu:ge?B:()=>{},onColorClick:ge?K:void 0,editingId:T,setEditingId:S,activeContextMenuCalendarId:null==O?void 0:O.calendarId,isDraggable:he,isEditable:ge}):ye(n.Fragment,{children:[ye(On,{calendars:t,onToggleVisibility:i,onReorder:he?e.reorderCalendars:()=>{},onRename:ge?(t,n)=>e.updateCalendar(t,{name:n}):()=>{},onContextMenu:ge?B:()=>{},onColorClick:ge?K:void 0,editingId:T,setEditingId:S,activeContextMenuCalendarId:null==O?void 0:O.calendarId,isDraggable:he,isEditable:ge}),ye("div",{className:"border-t border-gray-200 dark:border-slate-800",children:ye(Pn,{visibleMonth:e.getVisibleMonth(),currentDate:e.getCurrentDate(),showHeader:!0,onMonthChange:R,onDateSelect:t=>e.setCurrentDate(t)})})]}),O&&ye(Ze,{ref:M,x:O.x,y:O.y,onClose:Z,className:"w-64 p-2",children:c?c(t.find(e=>e.id===O.calendarId),Z):ye(n.Fragment,{children:[ye(Xe,{children:x("calendarOptions")}),ye(An,{calendars:t,currentCalendarId:O.calendarId,onMergeSelect:Q}),ye(qe,{onClick:X,children:x("delete")}),ye(qe,{onClick:le,children:x("exportCalendar")||"Export Calendar"}),ye(Ke,{}),ye(tt,{selectedColor:null===(b=t.find(e=>e.id===O.calendarId))||void 0===b?void 0:b.colors.lineColor,onSelect:G,onCustomColor:J})]})}),A&&o.createPortal(ye(Ze,{x:A.x,y:A.y,onClose:q,className:"w-max p-2",children:[ye(qe,{onClick:()=>{null==m||m(),q()},children:x("newCalendar")||"New Calendar"}),ye(qe,{onClick:ae,children:x("importCalendar")||"Import Calendar"}),ye(qe,{onClick:()=>{e.triggerRender(),q()},children:x("refreshAll")||"Refresh All"})]}),document.body),ye("input",{ref:N,type:"file",accept:".ics",style:{display:"none"},onChange:re}),_&&o.createPortal(ye(Yn,{calendars:t,filename:_.filename,onConfirm:oe,onCancel:()=>W(null)}),document.body),Y&&o.createPortal(ye(Ln,{sourceName:ie,targetName:se,onConfirm:ee,onCancel:()=>z(null)}),document.body),F&&o.createPortal(ye($n,{calendarId:F.calendarId,calendarName:de,calendars:t,step:F.step,onStepChange:e=>V(t=>t?Object.assign(Object.assign({},t),{step:e}):null),onConfirmDelete:te,onCancel:()=>V(null),onMergeSelect:ne}),document.body),$&&o.createPortal(ye("div",{className:"fixed inset-0 z-50",onMouseDown:()=>{e.updateCalendar($.calendarId,{}),j(null)},children:ye("div",{className:"absolute flex items-center justify-center",style:{top:$.y,left:$.x,transform:"translate(280%, -50%)"},onMouseDown:e=>e.stopPropagation(),children:"blossom"===v?ye(Ut,{defaultValue:$.initialColor,coreSize:28,petalSize:28,initialExpanded:!0,adaptivePositioning:!0,openOnHover:!1,onChange:t=>{const{colors:n,darkColors:a}=h(t.hex);e.updateCalendar($.calendarId,{colors:n,darkColors:a},!0)},onCollapse:()=>{e.updateCalendar($.calendarId,{}),j(null)}}):ye(qt,{generatorName:"colorPicker",generatorArgs:{variant:"sketch",color:$.currentColor,onChange:t=>{j(e=>e?Object.assign(Object.assign({},e),{currentColor:t.hex}):null);const{colors:n,darkColors:a}=h(t.hex);e.updateCalendar($.calendarId,{colors:n,darkColors:a},!0)},onChangeComplete:t=>{const{colors:n,darkColors:a}=h(t.hex);e.updateCalendar($.calendarId,{colors:n,darkColors:a})}},defaultContent:ye(Kt,{color:$.currentColor,onChange:(t,n)=>{j(e=>e?Object.assign(Object.assign({},e),{currentColor:t.hex}):null);const{colors:a,darkColors:r}=h(t.hex);e.updateCalendar($.calendarId,{colors:a,darkColors:r},n)},onClose:()=>{e.updateCalendar($.calendarId,{}),j(null)}})})})}),document.body)]})},Fn=({options:e,value:t,onChange:n,registry:a,variant:l="desktop"})=>{const[i,s]=r.useState(!1),[d,c]=r.useState({}),u=r.useRef(null),h=r.useRef(null),m=()=>{if(h.current){const e=h.current.getBoundingClientRect(),t="mobile"===l,n={position:"fixed",zIndex:10001,minWidth:t?"12rem":`${e.width}px`,top:`${e.bottom+4}px`};t?n.right=window.innerWidth-e.right+"px":n.left=`${e.left}px`,c(n)}};r.useEffect(()=>{const e=e=>{!u.current||u.current.contains(e.target)||e.target.closest("[data-calendar-picker-dropdown]")||s(!1)};return i&&(m(),window.addEventListener("mousedown",e),window.addEventListener("scroll",m,!0),window.addEventListener("resize",m)),()=>{window.removeEventListener("mousedown",e),window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",m)}},[i]);const v=e=>(a||g()).resolveColors(e).lineColor,f=(e,t)=>{e.stopPropagation(),n(t),s(!1)},p=e.find(e=>e.value===t),y=()=>i&&"undefined"!=typeof window?"mobile"===l?o.createPortal(ye("div",{"data-calendar-picker-dropdown":"true",style:d,className:"bg-white dark:bg-gray-800 rounded-md shadow-lg border border-gray-200 dark:border-gray-700 overflow-hidden transition-all duration-200 origin-top-right animate-in fade-in zoom-in-95",children:e.map(e=>ye("div",{className:"flex items-center px-4 py-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700 "+(e.value===t?"bg-gray-50 dark:bg-gray-700/50":""),onClick:t=>f(t,e.value),children:[ye("div",{className:"flex items-center flex-1 min-w-0 mr-3",children:[ye("div",{className:"w-5 flex justify-center mr-2",children:e.value===t&&ye(Te,{className:"w-4 h-4 text-primary"})}),ye("span",{className:"text-sm text-gray-700 dark:text-gray-200 truncate",children:e.label})]}),ye("span",{className:"w-3 h-3 rounded-full shrink-0",style:{backgroundColor:v(e.value)}})]},e.value))}),document.body):o.createPortal(ye("ul",{"data-calendar-picker-dropdown":"true",style:d,className:"bg-white dark:bg-gray-700 rounded-md shadow-lg dark:shadow-gray-900/50 overflow-hidden border border-gray-200 dark:border-gray-600 transition-all duration-200 origin-top-left animate-in fade-in zoom-in-95",children:e.map(e=>ye("li",{className:"flex items-center px-2 py-1 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-600 transition-colors "+(t===e.value?"font-semibold":""),onClick:t=>f(t,e.value),children:[t===e.value?ye("span",{className:"mr-2 text-sm text-primary",children:ye(Te,{width:12,height:12})}):ye("div",{className:"mr-2 text-sm w-3 h-3",children:" "}),ye("span",{className:"w-3 h-3 mr-2 rounded-sm shrink-0",style:{backgroundColor:v(e.value)}}),ye("span",{className:"text-sm whitespace-nowrap text-gray-700 dark:text-gray-200",children:e.label})]},e.value))}),document.body):null;return ye("div","mobile"===l?{className:"relative inline-block",ref:u,children:[ye("button",{ref:h,onClick:e=>{e.stopPropagation(),s(!i)},className:"flex items-center space-x-2 bg-gray-100 dark:bg-gray-700 rounded-md px-3 py-1.5 transition-colors",children:[ye("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:v(t)}}),ye("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-200",children:(null==p?void 0:p.label)||t}),ye(Se,{className:"w-4 h-4 text-gray-400"})]}),y()]}:{className:"relative inline-block",ref:u,children:[ye("button",{ref:h,type:"button",onClick:e=>{e.stopPropagation(),s(!i)},className:"flex items-center space-x-2 bg-gray-100 dark:bg-gray-700 rounded-md px-2 py-1 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors h-8",children:[ye("span",{className:"w-4 h-4 rounded-sm shrink-0",style:{backgroundColor:v(t)}}),ye(Se,{className:"w-4 h-4 text-gray-600 dark:text-gray-300"})]}),y()]})},Vn=Array.from({length:24},(e,t)=>t),_n=Array.from({length:60},(e,t)=>t),Wn=({visibleMonth:e,monthLabels:t,disabled:n,onMonthChange:a,onYearChange:r})=>ye("div",{className:"flex items-center justify-between border-b border-slate-100 dark:border-gray-600 px-3 py-2 text-sm font-medium text-slate-700 dark:text-gray-300",children:[ye("div",{className:"flex items-center gap-1",children:[ye("button",{type:"button",disabled:n,onClick:()=>r(-1),className:"rounded-md px-2 py-1 text-slate-400 dark:text-gray-400 transition hover:text-slate-600 dark:hover:text-gray-200 disabled:opacity-40",children:ye(De,{width:14,height:12})}),ye("button",{type:"button",disabled:n,onClick:()=>a(-1),className:"rounded-md px-2 py-1 text-slate-400 dark:text-gray-400 transition hover:text-slate-600 dark:hover:text-gray-200 disabled:opacity-40",children:ye(be,{width:14,height:12})})]}),ye("div",{className:"text-sm font-semibold text-slate-700 dark:text-gray-300",children:[t[e.month-1]," ",e.year]}),ye("div",{className:"flex items-center gap-1",children:[ye("button",{type:"button",disabled:n,onClick:()=>a(1),className:"rounded-md px-2 py-1 text-slate-400 dark:text-gray-400 transition hover:text-slate-600 dark:hover:text-gray-200 disabled:opacity-40",children:ye(xe,{width:14,height:12})}),ye("button",{type:"button",disabled:n,onClick:()=>r(1),className:"rounded-md px-2 py-1 text-slate-400 dark:text-gray-400 transition hover:text-slate-600 dark:hover:text-gray-200 disabled:opacity-40",children:ye(we,{width:14,height:12})})]})]}),Bn=(e,n)=>t.Temporal.PlainDate.compare(e,n),Un=({calendarDays:e,visibleMonth:t,startDate:a,endDate:r,weekDayLabels:o,disabled:l,onDaySelect:i})=>ye(n.Fragment,{children:[ye("div",{className:"grid grid-cols-7 gap-1 px-1 pb-3 pt-2 text-center text-[12px] uppercase tracking-wide text-slate-400 dark:text-gray-500",children:o.map((e,t)=>ye("span",{children:e},t))}),ye("div",{className:"grid grid-cols-7 gap-1 px-1 ",children:e.map(e=>{const n=e.month!==t.month,o=0===Bn(e,a),s=0===Bn(e,r),d=Bn(e,a)>=0&&Bn(e,r)<=0;return ye("button",{type:"button",disabled:l,onClick:()=>i(e),className:`flex h-9 w-9 items-center justify-center rounded-md text-sm transition ${o||s?"bg-primary text-primary-foreground font-semibold":d?"bg-primary/10 text-primary":n?"text-slate-300 dark:text-gray-600":"text-slate-700 dark:text-gray-300 hover:bg-primary/10 hover:text-primary"}`,children:e.day},e.toString())})})]}),Zn=({focusedField:e,draftRange:t,disabled:n,onHourSelect:a,onMinuteSelect:r,timeListRefs:o})=>{const l=e,i=t["start"===l?0:1],s=i.minute,d=_n.includes(s)?_n:[..._n,s].sort((e,t)=>e-t);return ye("div",{className:"flex flex-col rounded-xl border border-slate-200 dark:border-gray-600 bg-white dark:bg-gray-800 shadow-sm sm:w-28",children:[ye("div",{className:"flex border-b border-slate-100 dark:border-gray-600 justify-center",children:ye("div",{className:"text-base py-1.5 text-slate-700 dark:text-gray-300",children:[i.hour.toString().padStart(2,"0"),":",i.minute.toString().padStart(2,"0")]})}),ye("div",{className:"flex p-1",children:[ye("div",{className:"w-14",children:ye("div",{className:`h-72 overflow-y-auto ${nn} rounded-md border border-slate-100 dark:border-gray-600 bg-white dark:bg-gray-700`,role:"listbox","aria-label":"Hour",ref:e=>{o.current&&o.current[l]&&(o.current[l].hour=e)},children:Vn.map(e=>{const t=e===i.hour;return ye("button",{type:"button",role:"option","aria-selected":t,disabled:n,onClick:()=>a(l,e),className:"flex h-8 w-full items-center justify-center text-sm transition "+(t?"bg-primary text-primary-foreground font-semibold":"text-slate-600 dark:text-gray-300 hover:bg-primary/10 hover:text-primary"),"data-active":t?"true":void 0,children:ht(e)},e)})})}),ye("div",{className:"w-14",children:ye("div",{className:`h-72 overflow-y-auto ${nn} rounded-md border border-slate-100 dark:border-gray-600 bg-white dark:bg-gray-700`,role:"listbox","aria-label":"Minute",ref:e=>{o.current&&o.current[l]&&(o.current[l].minute=e)},children:d.map(e=>{const t=e===s;return ye("button",{type:"button",role:"option","aria-selected":t,disabled:n,onClick:()=>r(l,e),className:"flex h-8 w-full items-center justify-center text-sm transition "+(t?"bg-primary text-primary-foreground font-semibold":"text-slate-600 dark:text-gray-300 hover:bg-primary/10 hover:text-primary"),"data-active":t?"true":void 0,children:ht(e)},e)})})})]})]})},qn=({visibleMonth:e,monthLabels:t,weekDayLabels:n,calendarDays:a,draftRange:r,focusedField:o,isTimeEnabled:l,disabled:i,matchTriggerWidth:s,popupRef:d,timeListRefs:c,onMonthChange:u,onYearChange:g,onDaySelect:h,onHourSelect:m,onMinuteSelect:v,onOk:f,getPopupStyle:p})=>{const y=r[0].toPlainDate(),b=r[1].toPlainDate();return ye("div",{ref:d,style:p(),"data-range-picker-popup":"true",children:ye("div",{className:"space-y-3 rounded-xl border border-slate-200 dark:border-gray-600 bg-white dark:bg-gray-800 p-3",style:{boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",width:s?"100%":void 0},children:[ye("div",{className:"flex gap-1",children:[ye("div",{className:"flex-3 rounded-xl border border-slate-200 dark:border-gray-600 bg-white dark:bg-gray-800 shadow-sm w-full",children:[ye(Wn,{visibleMonth:e,monthLabels:t,disabled:i,onMonthChange:u,onYearChange:g}),ye(Un,{calendarDays:a,visibleMonth:e,startDate:y,endDate:b,weekDayLabels:n,disabled:i,onDaySelect:h})]}),l&&ye("div",{className:"flex flex-1 justify-end sm:w-32",children:ye(Zn,{focusedField:o,draftRange:r,disabled:i,onHourSelect:m,onMinuteSelect:v,timeListRefs:c})})]}),ye("div",{className:"flex justify-end",children:ye("button",{type:"button",onClick:f,disabled:i,className:"inline-flex items-center rounded-full bg-primary px-4 py-1.5 text-sm font-semibold text-primary-foreground shadow-sm transition hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-50",children:"OK"})})]})})},Kn=({value:e,format:n="YYYY-MM-DD HH:mm",showTimeFormat:a="HH:mm",showTime:l=!0,onChange:i,onOk:s,timeZone:d,disabled:c=!1,placement:u="bottomLeft",autoAdjustOverflow:g=!0,getPopupContainer:h,matchTriggerWidth:m=!1,locale:v="en-US"})=>{const f=r.useMemo(()=>"string"==typeof v?v:(null==v?void 0:v.code)||"en-US",[v]),p=r.useMemo(()=>void 0===l||("object"==typeof l||Boolean(l)),[l]),y=r.useMemo(()=>_e(f,"short"),[f]),b=r.useMemo(()=>Ve(f,"narrow"),[f]),x=r.useMemo(()=>p?"object"==typeof l&&(null==l?void 0:l.format)?l.format:a:"",[p,l,a]),D=r.useMemo(()=>mt(n,x),[n,x]),w=r.useMemo(()=>ft(D),[D]),C=r.useMemo(()=>{const n=null!=d?d:S(e[0])?S(e[1])?t.Temporal.Now.timeZoneId():yt(e[1]):yt(e[0]),a=bt(e[0],n);return[a,bt(e[1],n,a)]},[e,d]),[E,k]=r.useState(C),T=r.useRef(C),[N,M]=r.useState("start"),[I,H]=r.useState([xt(C[0],n,x),xt(C[1],n,x)]),R=r.useRef([xt(C[0],n,x),xt(C[1],n,x)]),O=r.useRef(C),[P,A]=r.useState(C[0].toPlainDate().with({day:1})),[L,$]=r.useState(!1),j=r.useCallback(e=>{$(e)},[]),[Y,z]=r.useState(u),F=r.useRef(u),V=r.useRef(null),_=r.useRef(null),W=r.useRef({start:{hour:null,minute:null},end:{hour:null,minute:null}}),B=r.useRef(!1);r.useEffect(()=>{R.current=I},[I]),r.useEffect(()=>{O.current=E},[E]),r.useEffect(()=>{const e=T.current,n=0!==t.Temporal.ZonedDateTime.compare(e[0],C[0]),a=0!==t.Temporal.ZonedDateTime.compare(e[1],C[1]);(n||a)&&k(C),T.current=C},[C]),r.useEffect(()=>{A(C[0].toPlainDate().with({day:1}))},[C[0]]);const U=r.useCallback((e,t,n=0)=>{var a;if(!e||!t)return;const r=e.getBoundingClientRect(),o=t.getBoundingClientRect().top-r.top+e.scrollTop-n,l=(null===(a=window.matchMedia)||void 0===a?void 0:a.call(window,"(prefers-reduced-motion: reduce)").matches)?"auto":"smooth";Math.abs(e.scrollTop-o)>1&&e.scrollTo({top:o,behavior:l})},[]),Z=r.useCallback(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=W.current[e];["hour","minute"].forEach(e=>{const n=t[e];if(!n)return;const a=n.querySelector('[data-active="true"]');a&&U(n,a,0)})})})},[U]);r.useEffect(()=>{L&&p&&Z(N)},[N,L,Z,p]);const q=E[0].epochMilliseconds,K=E[0].offsetNanoseconds,X=E[1].epochMilliseconds,G=E[1].offsetNanoseconds;r.useEffect(()=>{const[e,t]=O.current,a=xt(e,n,x),r=xt(t,n,x),[o,l]=R.current;o===a&&l===r||(R.current=[a,r],H([a,r]))},[q,K,X,G,n,x]),r.useEffect(()=>{if(!L)return;const e=e=>{var t,n;const a=e.target;if(null===(t=V.current)||void 0===t?void 0:t.contains(a))return;if(null===(n=_.current)||void 0===n?void 0:n.contains(a))return;a.closest("[data-range-picker-popup]")||j(!1)},t=setTimeout(()=>{document.addEventListener("mousedown",e)},100);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[L]),r.useEffect(()=>{L||(M("start"),B.current||k(C),B.current=!1)},[L,C]);const J=r.useCallback(e=>{i&&i(e,[xt(e[0],n,x),xt(e[1],n,x)])},[x,n,i]),Q=r.useCallback(e=>{s&&s(e,[xt(e[0],n,x),xt(e[1],n,x)])},[x,n,s]),ee=r.useCallback((e,n)=>{k(a=>{const r=[...a];if("start"===e){const e=bt(r[1],yt(n),n),a=t.Temporal.ZonedDateTime.compare(n,e)>0?n:e;return[n,a]}const o=bt(r[0],yt(n),n);return[t.Temporal.ZonedDateTime.compare(o,n)>0?n:o,n]})},[]),te=e=>{if(c)return;const n=(e,n)=>{var a,r,o,l;const i=yt(e);return t.Temporal.ZonedDateTime.from({timeZone:i,year:n.year,month:n.month,day:n.day,hour:e.hour,minute:e.minute,second:null!==(a=e.second)&&void 0!==a?a:0,millisecond:null!==(r=e.millisecond)&&void 0!==r?r:0,microsecond:null!==(o=e.microsecond)&&void 0!==o?o:0,nanosecond:null!==(l=e.nanosecond)&&void 0!==l?l:0})};if("start"===N){const t=n(E[0],e),a=E[1].epochMilliseconds-E[0].epochMilliseconds,r=t.add({milliseconds:a});return void k([t,r])}const a=n(E[1],e),r=E[1].epochMilliseconds-E[0].epochMilliseconds;if(t.Temporal.ZonedDateTime.compare(a,E[0])<0){const t=n(E[0],e),a=t.add({milliseconds:r});return void k([t,a])}const o=[E[0],a];k(o),A(a.toPlainDate().with({day:1}))},ne=r.useCallback((e,n)=>{if(c)return;const a="start"===e?0:1;k(r=>{const o=r[a],l=o.with({hour:n,minute:o.minute,second:0,millisecond:0,microsecond:0,nanosecond:0});if("start"===e){const e=bt(r[1],yt(l),l);return[l,t.Temporal.ZonedDateTime.compare(l,e)>0?l:e]}const i=bt(r[0],yt(l),l);return[t.Temporal.ZonedDateTime.compare(i,l)>0?l:i,l]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=W.current[e].hour;if(!t)return;const n=t.querySelector('[data-active="true"]');n&&U(t,n,0)})})},[c]),ae=r.useCallback((e,n)=>{if(c)return;const a="start"===e?0:1;k(r=>{const o=r[a].with({minute:n,second:0,millisecond:0,microsecond:0,nanosecond:0});if("start"===e){const e=bt(r[1],yt(o),o);return[o,t.Temporal.ZonedDateTime.compare(o,e)>0?o:e]}const l=bt(r[0],yt(o),o);return[t.Temporal.ZonedDateTime.compare(l,o)>0?o:l,o]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=W.current[e].minute;if(!t)return;const n=t.querySelector('[data-active="true"]');n&&U(t,n,0)})})},[c]),re=r.useCallback((e,t)=>{const n="start"===e?0:1;H(e=>{const a=[...e];return a[n]=t,a})},[]),oe=r.useCallback((e,t)=>{const a="start"===e?0:1,r=E[a],o=yt(r),l=pt(t,w,r,o);if(l){ee(e,l);const t=l.toPlainDate().with({day:1});return A(t),"start"===e&&M("end"),!0}return H(e=>{const t=[...e];return t[a]=xt(E[a],n,x),t}),!1},[E,x,n,w,ee]),le=r.useCallback(e=>t=>{re(e,t.target.value)},[re]),ie=r.useCallback(e=>t=>{var n;if(c)return;if(L)return;const a=t.relatedTarget;a&&(null===(n=V.current)||void 0===n?void 0:n.contains(a))||oe(e,t.target.value)},[oe,c,L]),se=r.useCallback(e=>t=>{"Enter"===t.key&&(t.preventDefault(),oe(e,t.currentTarget.value)),"Escape"===t.key&&t.currentTarget.blur()},[oe]),de=()=>{B.current=!0,J(E),Q(E),j(!1)},ce=e=>{A(t=>t.add({months:e}).with({day:1}))},ue=e=>{A(t=>t.add({years:e}).with({day:1}))},ge=r.useMemo(()=>{const e=P,t=e.dayOfWeek%7,n=e.subtract({days:t});return Array.from({length:42},(e,t)=>n.add({days:t}))},[P]),he=r.useCallback((e=u)=>{if(!g||!V.current)return e;const t=V.current.getBoundingClientRect(),n=m?t.width:480,a=window.innerHeight-t.bottom,r=t.top,o=window.innerWidth-t.left,l=t.right;let i=e;return i.startsWith("bottom")&&a<500&&r>a?i=i.replace("bottom","top"):i.startsWith("top")&&r<500&&a>r&&(i=i.replace("top","bottom")),i.endsWith("Left")&&o<n&&l>o?i=i.replace("Left","Right"):i.endsWith("Right")&&l<n&&o>l&&(i=i.replace("Right","Left")),i},[g,m,u]),me=r.useCallback(()=>{const e=he();F.current!==e&&(F.current=e,z(e))},[he]),ve=e=>{if(c)return;M(e);const t=E["start"===e?0:1].toPlainDate().with({day:1});A(t);const n=he();F.current!==n&&(F.current=n,z(n)),j(!0)};r.useEffect(()=>{if(!L)return;me();const e=()=>me();return window.addEventListener("resize",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e,!0)}},[L,me]);const fe=()=>{if(!V.current)return{};const e=V.current.getBoundingClientRect(),t=F.current,n={position:"fixed",zIndex:9999};return t.startsWith("bottom")?n.top=e.bottom+8:n.bottom=window.innerHeight-e.top+8,t.endsWith("Left")?n.left=e.left:n.right=window.innerWidth-e.right,m&&(n.width=`${e.width}px`),n};return ye("div",{className:"relative max-w-100",ref:V,children:[ye("div",{className:"flex items-center gap-2 rounded-lg border text-sm shadow-sm transition "+(c?"cursor-not-allowed border-slate-200 dark:border-gray-600 bg-slate-50 dark:bg-gray-800 text-slate-400 dark:text-gray-500":L?"border-primary bg-white dark:bg-gray-700 shadow-md":"border-slate-200 dark:border-gray-600 bg-white dark:bg-gray-700"),children:[ye("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:ye("input",{type:"text",name:"range-start",value:I[0],onChange:le("start"),onFocus:()=>ve("start"),onClick:()=>ve("start"),onBlur:ie("start"),onKeyDown:se("start"),className:"w-full rounded-md border px-2 py-1.5 text-sm font-medium transition focus:outline-none focus:ring-2 "+(c?"cursor-not-allowed border-transparent bg-transparent text-slate-400 dark:text-gray-500":"start"===N&&L?" bg-white dark:bg-gray-700 text-primary":"border-transparent bg-transparent text-slate-700 dark:text-gray-300"),placeholder:D,autoComplete:"off",disabled:c})}),ye(Ie,{className:"text-slate-400 dark:text-gray-500"}),ye("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:ye("input",{type:"text",name:"range-end",value:I[1],onChange:le("end"),onFocus:()=>ve("end"),onClick:()=>ve("end"),onBlur:ie("end"),onKeyDown:se("end"),className:"w-full rounded-md border px-2 py-1.5 text-sm font-medium transition focus:outline-none focus:ring-2 "+(c?"cursor-not-allowed border-transparent bg-transparent text-slate-400 dark:text-gray-500":"end"===N&&L?"bg-white dark:bg-gray-700 text-primary":"border-transparent bg-transparent text-slate-700 dark:text-gray-300"),placeholder:D,autoComplete:"off",disabled:c})})]}),L&&(h?o.createPortal(ye(qn,{visibleMonth:P,monthLabels:y,weekDayLabels:b,calendarDays:ge,draftRange:E,focusedField:N,isTimeEnabled:!!p,disabled:c,matchTriggerWidth:m,popupRef:_,timeListRefs:W,onMonthChange:ce,onYearChange:ue,onDaySelect:te,onHourSelect:ne,onMinuteSelect:ae,onOk:de,getPopupStyle:fe}),h()):o.createPortal(ye(qn,{visibleMonth:P,monthLabels:y,weekDayLabels:b,calendarDays:ge,draftRange:E,focusedField:N,isTimeEnabled:!!p,disabled:c,matchTriggerWidth:m,popupRef:_,timeListRefs:W,onMonthChange:ce,onYearChange:ue,onDaySelect:te,onHourSelect:ne,onMinuteSelect:ae,onOk:de,getPopupStyle:fe}),document.body))]})},Xn=({event:e,isOpen:n,isAllDay:a,onEventUpdate:l,onEventDelete:i,onClose:s,app:d})=>{var c;const[u,h]=r.useState(e),{t:m}=Ue();r.useEffect(()=>{h(e)},[e]);const v=r.useMemo(()=>(d?d.getCalendarRegistry():g()).getVisible().map(e=>({label:e.name,value:e.id})),[d,null==d?void 0:d.getCalendars()]),f=r.useMemo(()=>!ce(e,u),[e,u]),p=r.useMemo(()=>S(u.start)?u.end&&!S(u.end)&&(u.end.timeZoneId||u.end.timeZoneId)||t.Temporal.Now.timeZoneId():u.start.timeZoneId||u.start.timeZoneId||t.Temporal.Now.timeZoneId(),[u.end,u.start]),y=e=>{const[t,n]=e;h(Object.assign(Object.assign({},u),{start:t.toPlainDate(),end:n.toPlainDate()}))},b=!(null==d?void 0:d.state.readOnly),x=!1!==(null==d?void 0:d.getReadOnlyConfig().viewable);if(!n||!x)return null;if("undefined"==typeof window||"undefined"==typeof document)return null;const D=ye("div",{className:"fixed inset-0 flex items-center justify-center",style:{pointerEvents:"auto",zIndex:9998},"data-event-detail-dialog":"true",children:[ye("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()}}),ye("div",{className:"df-dialog-container relative bg-white dark:bg-gray-800 shadow-2xl border border-gray-200 dark:border-gray-700 rounded-lg p-6 max-w-md w-full mx-4",children:[ye("button",{onClick:s,className:"absolute top-4 right-4 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-200 transition","aria-label":"Close",children:ye("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:ye("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),ye("div",{children:[ye("span",{className:"block text-xs text-gray-600 dark:text-gray-300 mb-1",children:m("eventTitle")}),ye("div",{className:"flex items-center justify-between gap-3 mb-4",children:[ye("div",{className:"flex-1",children:ye("input",{id:`event-dialog-title-${u.id}`,name:"title",type:"text",value:u.title,readOnly:!b,disabled:!b,onChange:e=>{h(Object.assign(Object.assign({},u),{title:e.target.value}))},className:"w-full border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-1.5 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary transition"})}),b&&ye(Fn,{options:v,value:u.calendarId||"blue",onChange:e=>{h(Object.assign(Object.assign({},u),{calendarId:e}))},registry:null==d?void 0:d.getCalendarRegistry()})]}),u.allDay?ye("div",{className:"mb-4",children:[ye("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-1",children:m("dateRange")}),ye(Kn,{value:[u.start,u.end],format:"YYYY-MM-DD",showTime:!1,timeZone:p,matchTriggerWidth:!0,disabled:!b,onChange:y,onOk:y,locale:null==d?void 0:d.state.locale})]}):ye("div",{className:"mb-4",children:[ye("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-1",children:m("timeRange")}),ye(Kn,{value:[u.start,u.end],timeZone:p,disabled:!b,onChange:e=>{const[t,n]=e;h(Object.assign(Object.assign({},u),{start:t,end:n}))},onOk:e=>{const[t,n]=e;h(Object.assign(Object.assign({},u),{start:t,end:n}))},locale:null==d?void 0:d.state.locale})]}),ye("div",{className:"mb-4",children:[ye("span",{className:"block text-xs text-gray-600 dark:text-gray-300 mb-1",children:m("note")}),ye("textarea",{id:`event-dialog-note-${u.id}`,name:"note",value:null!==(c=u.description)&&void 0!==c?c:"",readOnly:!b,disabled:!b,onChange:e=>h(Object.assign(Object.assign({},u),{description:e.target.value})),rows:4,className:"w-full border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary transition resize-none",placeholder:m("addNotePlaceholder")})]}),b&&ye("div",{className:"flex space-x-2",children:[u.allDay?ye("button",{className:"px-3 py-2 bg-secondary/10 text-secondary rounded-lg hover:bg-secondary/20 text-sm font-medium transition",onClick:()=>{const e=S(u.start)?u.start:u.start.toPlainDate(),n=t.Temporal.ZonedDateTime.from({year:e.year,month:e.month,day:e.day,hour:9,minute:0,timeZone:t.Temporal.Now.timeZoneId()}),a=t.Temporal.ZonedDateTime.from({year:e.year,month:e.month,day:e.day,hour:10,minute:0,timeZone:t.Temporal.Now.timeZoneId()});h(Object.assign(Object.assign({},u),{allDay:!1,start:n,end:a}))},children:m("setAsTimed")}):ye("button",{className:"px-3 py-2 bg-secondary/10 text-secondary rounded-lg hover:bg-secondary/20 text-sm font-medium transition",onClick:()=>{const e=S(u.start)?u.start:u.start.toPlainDate();h(Object.assign(Object.assign({},u),{allDay:!0,start:e,end:e}))},children:m("setAsAllDay")}),ye("button",{className:"px-3 py-2 bg-destructive border border-border text-destructive-foreground rounded-lg hover:bg-destructive/90 text-sm font-medium transition",onClick:()=>{i(e.id),s()},children:m("delete")}),ye("button",{className:"px-3 py-2 bg-primary text-primary-foreground rounded-lg text-sm font-medium transition ml-auto "+(f?"hover:bg-primary/90 shadow-lg shadow-primary/20":"opacity-50 cursor-not-allowed grayscale-[0.5]"),onClick:()=>{l(u),s()},disabled:!f,children:m("save")})]})]})]})]}),w=document.body;return w?o.createPortal(D,w):null},Gn=({calendar:e,mode:t="buttons"})=>{const[n,a]=r.useState(!1),o=r.useRef(null),{t:l}=Ue(),i=Array.from(e.state.views.keys()),s=e.state.currentView;return i.length<=1?null:(r.useEffect(()=>{const e=e=>{o.current&&!o.current.contains(e.target)&&a(!1)};if(n)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[n]),ye("div","select"===t?{className:"relative inline-block",ref:o,children:[ye("button",{onClick:()=>a(!n),className:"flex items-center gap-2 px-3 mb-1 h-7 text-sm font-medium border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none transition-all duration-200 shadow-sm min-w-30 justify-between","aria-expanded":n,"aria-haspopup":"listbox",children:[ye("span",{className:"text-gray-900 dark:text-gray-100",children:l(s)}),ye("span",{className:`${En} transition-transform duration-200 ${n?"rotate-180":""}`,children:ye(Ce,{width:16,height:16})})]}),n&&ye("div",{className:"absolute top-full mt-1 left-0 z-50 w-full min-w-30 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-600 rounded-lg shadow-lg dark:shadow-gray-900/50 overflow-hidden animate-in",children:ye("div",{className:"py-1",role:"listbox",children:i.map(t=>ye("button",{onClick:()=>{e.changeView(t),a(!1),e.triggerRender&&e.triggerRender()},className:"w-full text-left px-3 py-2 text-sm transition-colors duration-150 focus:outline-none "+(s===t?"bg-primary/10 text-primary font-medium":"text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700"),role:"option","aria-selected":s===t,children:l(t)},t))})}),ye("style",{children:"\n @keyframes slideIn {\n from {\n opacity: 0;\n transform: translateY(-4px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n .animate-in {\n animation: slideIn 0.15s ease-out;\n }\n "})]}:{className:"inline-flex items-center gap-1 p-0.5 mb-1 bg-gray-100 dark:bg-gray-800 rounded-lg",children:i.map(t=>ye("button",{className:"px-4 h-6 text-sm font-medium rounded-md transition-all duration-200 focus:outline-none "+(s===t?"bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-100 hover:bg-gray-50 dark:hover:bg-gray-700"),onClick:()=>{e.changeView(t),e.triggerRender&&e.triggerRender()},children:l(t)},t))}))};let Jn=null;const Qn=()=>{const[e,t]=r.useState(()=>Jn||{weekHeight:i.WEEK_HEIGHT,screenSize:"desktop",weeksPerView:6});return r.useEffect(()=>{const e=()=>{const e=window.innerWidth,n=window.innerHeight-150,a=Math.max(80,Math.floor(n/6)),r=e<768?{weekHeight:Math.max(i.MOBILE_WEEK_HEIGHT,a),screenSize:"mobile",weeksPerView:6}:e<1024?{weekHeight:Math.max(i.TABLET_WEEK_HEIGHT,a),screenSize:"tablet",weeksPerView:6}:{weekHeight:Math.max(i.WEEK_HEIGHT,a),screenSize:"desktop",weeksPerView:6};Jn=r,t(e=>e.screenSize===r.screenSize&&e.weekHeight===r.weekHeight&&e.weeksPerView===r.weeksPerView?e:r)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e},ea=({calendar:e,switcherMode:t="buttons",onAddCalendar:n,onSearchChange:a,onSearchClick:o,searchValue:l="",isSearchOpen:i=!1,isEditable:s=!0,safeAreaLeft:d})=>{const c=r.useContext(fe),u="buttons"===t,g=e.state.currentView===exports.ViewType.DAY,{screenSize:h}=Qn(),m="mobile"===h,{t:v}=Ue(),f=r.useCallback(e=>{const t=e.target.value;t!==l&&(null==a||a(t))},[a,l]);return ye(qt,{store:c,generatorName:"headerContent",generatorArgs:{calendar:e,switcherMode:t,onAddCalendar:n,onSearchChange:a,onSearchClick:o,searchValue:l,isSearchOpen:i,isEditable:s,safeAreaLeft:d},defaultContent:ye("div",{className:"df-header flex items-center justify-between pr-2 pt-1 bg-white dark:bg-gray-900 transition-colors duration-200 shrink-0 border-b "+(g||i?"border-gray-200 dark:border-gray-700":"border-transparent"),style:{paddingLeft:d||8,transition:"padding-left 160ms ease-in-out"},onContextMenu:e=>e.preventDefault(),children:[ye("div",{className:"df-header-left flex items-center mb-1",children:n&&s&&ye("button",{id:"dayflow-add-event-btn",onClick:n,className:Cn,title:m?v("newEvent")||"New Event":v("createCalendar")||"Add Calendar",children:ye(Ee,{className:`h-4 w-4 ${En}`})})}),ye("div",{className:"df-header-mid flex-1 flex justify-center",children:u&&ye(Gn,{mode:t,calendar:e})}),!u&&ye(Gn,{mode:t,calendar:e}),ye("div",{className:`df-header-right flex ${"select"===t?"ml-2":""} items-center justify-end gap-3 mb-1 pb-1 h-6`,children:[ye("button",{onClick:o,className:`md:hidden ${Cn}`,children:ye(ke,{width:16,height:16})}),ye("div",{className:"relative hidden md:block group mt-1",children:[ye("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:ye("span",{className:"text-gray-400 group-focus-within:text-primary transition-colors",children:ye(ke,{width:16,height:16})})}),ye("input",{id:"dayflow-search-input",type:"text",placeholder:"Search",value:l,onChange:f,className:"pl-9 pr-8 py-1 h-7 text-sm border border-slate-200 dark:border-gray-600 rounded-lg text-gray-900 dark:text-gray-100 placeholder-gray-500 dark:placeholder-gray-400 focus:outline-none focus:ring-1 focus:ring-primary focus:border-primary transition resize-none w-48"}),l&&ye("button",{onClick:()=>{null==a||a("")},className:"absolute inset-y-0 right-0 pr-2 flex items-center text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",children:ye("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[ye("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ye("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]})]})})},ta=n.createContext(void 0),na=({children:e,initialTheme:t="light",onThemeChange:n})=>{const[a,o]=r.useState(t),[l,i]=r.useState("light"),s="auto"===a?l:a;r.useEffect(()=>{o(t)},[t]);const d=r.useCallback(e=>{o(e)},[]);r.useEffect(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-color-scheme: dark)"),t=e=>{const t=e.matches?"dark":"light";i(t)},n=e.matches?"dark":"light";return i(n),e.addEventListener?e.addEventListener("change",t):e.addListener&&e.addListener(t),()=>{e.removeEventListener?e.removeEventListener("change",t):e.removeListener&&e.removeListener(t)}},[]),r.useEffect(()=>{if("undefined"==typeof document)return;const e=document.documentElement,t=Dt(s),n="auto"===a?t:s;e.classList.remove("light","dark"),e.classList.add(n),"auto"===a?e.removeAttribute("data-dayflow-theme-override"):e.setAttribute("data-dayflow-theme-override",n),e.setAttribute("data-theme",n)},[s,a,l]),r.useEffect(()=>{n&&n(a,s)},[a,s,n]);const c={theme:a,effectiveTheme:s,setTheme:d};return ye(ta.Provider,{value:c,children:e})},aa=()=>{const e=r.useContext(ta);if(void 0===e)throw new Error("useTheme must be used within a ThemeProvider");return e},ra=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],oa=({onClose:e,onCreate:t,colorPickerMode:a="default"})=>{const{t:i}=Ue(),{effectiveTheme:s}=aa(),[d,c]=r.useState(""),[u,g]=r.useState(ra[Math.floor(Math.random()*ra.length)]),[m,v]=r.useState(!1),[f,p]=r.useState(""),y=r.useMemo(()=>{const e=l.DEFAULT_COLORS[Math.floor(Math.random()*l.DEFAULT_COLORS.length)],t=e.layer||"outer",n=l.lightnessToSliderValue(e.l);return{hue:e.h,saturation:n,lightness:e.l,alpha:100,layer:t}},[]),[b,x]=r.useState(null),D=e=>{g(e.hex)},w=()=>{v(!1)},C=()=>{g(f),v(!1)},E="dark"===s,k={default:{picker:{background:E?"#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:E?"1px solid #4b5563":"1px solid #e5e7eb"},head:{background:E?"#1e293b":"#ffffff",borderBottom:E?"1px solid #4b5563":"1px solid #e5e7eb",boxShadow:"none"},body:{background:E?"#1e293b":"#ffffff"},controls:{border:E?"1px solid #4b5563":"1px solid #e5e7eb"},input:{background:E?"#374151":"#ffffff",color:E?"#f3f4f6":"#1f2937",border:E?"1px solid #4b5563":"1px solid #e5e7eb",boxShadow:"none"},previews:{border:E?"1px solid #4b5563":"1px solid #e5e7eb"},actions:{borderTop:E?"1px solid #4b5563":"1px solid #e5e7eb"}}};return"undefined"==typeof window?null:o.createPortal(ye("div",{className:"fixed inset-0 z-10000 flex items-center justify-center bg-black/50",children:ye("div",{className:"w-full max-w-sm rounded-lg p-6 shadow-xl bg-white dark:bg-slate-900 animate-in fade-in zoom-in-95",onClick:e=>e.stopPropagation(),children:[ye("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white "+("blossom"===a?"mb-6":"mb-4"),children:i("createCalendar")}),ye("form",{onSubmit:n=>{var r;if(n.preventDefault(),!d.trim())return;let o;o="blossom"===a?null!==(r=null==b?void 0:b.hex)&&void 0!==r?r:l.hslToHex(y.hue,y.saturation,y.lightness):u;const{colors:i,darkColors:s}=h(o),c={id:ue(),name:d.trim(),colors:i,darkColors:s,isVisible:!0,isDefault:!1};t(c),e()},children:["blossom"===a?ye("div",{className:"mb-8 flex items-center gap-4",children:[ye("div",{className:"flex-1",children:ye("input",{id:"blossom-calendar-name",name:"calendar-name",type:"text",value:d,onChange:e=>c(e.target.value),className:"w-full border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-1.5 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary transition",placeholder:i("calendarNamePlaceholder"),autoFocus:!0})}),ye("div",{className:"w-9 h-9 relative shrink-0",children:ye("div",{className:"absolute inset-0 flex items-center justify-center",children:ye(Ut,{defaultValue:y,coreSize:36,petalSize:32,openOnHover:!1,onChange:e=>x(e),onCollapse:e=>x(e),className:"z-50"})})})]}):ye(n.Fragment,{children:[ye("div",{className:"mb-4",children:ye("div",{className:"flex items-center gap-3",children:[ye("div",{className:"h-9 w-9 rounded-md border border-gray-200 shadow-sm dark:border-gray-600",style:{backgroundColor:u}}),ye("input",{id:"default-calendar-name",name:"calendar-name",type:"text",value:d,onChange:e=>c(e.target.value),className:"w-full flex-1 border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-1.5 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary transition",placeholder:i("calendarNamePlaceholder"),autoFocus:!0})]})}),ye("div",{className:"mb-6",children:[ye("div",{className:"grid grid-cols-7 gap-6",children:ra.map(e=>ye("button",{type:"button",className:"h-6 w-6 rounded-full border border-gray-200 focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 dark:border-gray-600 dark:focus:ring-offset-slate-800 "+(u===e?"ring-2 ring-primary ring-offset-2 dark:ring-offset-slate-800":""),style:{backgroundColor:e},onClick:()=>g(e)},e))}),ye("div",{className:"mt-2 relative",children:[ye("button",{type:"button",onClick:()=>{p(u),v(!0)},className:"flex w-full cursor-pointer items-center rounded-sm px-2 py-1.5 text-sm text-slate-700 hover:bg-slate-100 dark:text-slate-200 dark:hover:bg-slate-800 transition-colors focus:outline-none focus:bg-slate-100 dark:focus:bg-slate-800",children:i("customColor")}),m&&ye("div",{className:"absolute left-0 top-full z-10001 mt-2",children:ye(qt,{generatorName:"colorPickerWrapper",generatorArgs:{variant:"photoshop",color:u,onChange:D,onAccept:w,onCancel:C,styles:k},defaultContent:ye("div",{children:[ye(Kt,{color:u,onChange:D}),ye("div",{className:"mt-2 flex justify-end gap-2",children:[ye("button",{type:"button",onClick:C,className:"px-2 py-1 text-xs border border-gray-200 dark:border-gray-600 rounded hover:bg-gray-100 dark:hover:bg-gray-800",children:i("cancel")}),ye("button",{type:"button",onClick:w,className:"px-2 py-1 text-xs bg-primary text-primary-foreground rounded hover:opacity-90",children:"OK"})]})]})})})]})]})]}),ye("div",{className:"flex justify-end space-x-2",children:[ye("button",{type:"button",onClick:e,className:"px-2 py-1 border border-slate-200 dark:border-gray-600 text-gray-700 dark:text-gray-300 rounded hover:bg-gray-50 dark:hover:bg-gray-800 text-xs font-medium transition",children:i("cancel")}),ye("button",{type:"submit",disabled:!d.trim(),className:"px-2 py-1 bg-primary text-primary-foreground rounded hover:bg-primary/90 text-xs font-medium transition disabled:opacity-50",children:i("create")})]})]})]})}),document.body)},la=({loading:e,results:t,keyword:n,onResultClick:a,emptyText:o})=>{const{t:l,locale:i}=Ue(),s=r.useMemo(()=>St(new Date),[]),d=r.useMemo(()=>Mt(t,s),[t,s]),c=e=>Tt(e);return e?ye("div",{className:"flex flex-col items-center justify-center h-40 text-gray-500",children:[ye(He,{className:"w-8 h-8 animate-spin mb-2"}),ye("span",{children:"Loading..."})]}):0===t.length?n?ye("div",{className:"flex flex-col items-center justify-center h-40 text-gray-500",children:[ye(ia,{}),ye("span",{className:"mt-2 text-sm",children:"string"==typeof o?o:o&&"object"==typeof o?o[i]||o.en||"No results found":l("noResults")||"No results found"})]}):null:ye("div",{className:"space-y-6",children:d.map(e=>{const{title:t,colorClass:n}=Nt(e.date,s,i,l);return ye("div",{children:[ye("h3",{className:`px-2 text-sm font-medium mb-4 sticky top-0 bg-white dark:bg-gray-900 py-1 z-10 ${n} border-b border-gray-200 dark:border-gray-700`,children:t}),ye("div",{className:"flex flex-col",children:e.events.map(e=>{const t=c(e.start),n=c(e.end),r={hour:"2-digit",minute:"2-digit"},o=e.allDay?l("allDay")||"All Day":t.toLocaleTimeString(i,r),s=e.allDay?"":n.toLocaleTimeString(i,r);return ye("div",{children:[ye("div",{className:"p-2 mx-2 mb-1 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-800 cursor-pointer transition-colors group",onClick:()=>null==a?void 0:a(e),children:ye("div",{className:"flex items-stretch gap-3",children:[ye("div",{className:"w-1 rounded-full shrink-0",style:{backgroundColor:e.color||"#3b82f6"}}),ye("div",{className:"flex-1 min-w-0 flex justify-between items-start",children:[ye("div",{className:"font-medium text-black dark:text-white truncate pr-2 text-sm",children:e.title}),ye("div",{className:"text-xs flex flex-col items-end shrink-0 leading-tight",children:[ye("div",{className:"text-black dark:text-white",children:o}),s&&ye("div",{className:"text-gray-500 dark:text-gray-400",children:s})]})]})]})}),ye("div",{className:"mx-2 border-b border-gray-200 dark:border-gray-700"})]},e.id)})})]},e.date.getTime())})})},ia=()=>ye("svg",{className:"w-12 h-12 text-gray-300 dark:text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:ye("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),sa=({isOpen:e,onClose:t,loading:n,results:a,keyword:r,onResultClick:o,emptyText:l})=>ye("div",{className:"hidden md:flex relative h-full bg-white dark:bg-gray-900 transition-all duration-300 ease-in-out flex-col border-l border-gray-200 dark:border-gray-700 overflow-hidden select-none "+(e?"w-64":"w-0 border-l-0"),children:ye("div",{className:"flex-1 overflow-y-auto min-w-64",children:ye(la,{loading:n,results:a,keyword:r,onResultClick:o,emptyText:l})})}),da=({isOpen:e,onClose:t,keyword:n,onSearchChange:a,results:l,loading:i,onResultClick:s,emptyText:d})=>{const c=r.useRef(null),{t:u}=Ue();return r.useEffect(()=>(e?(setTimeout(()=>{var e;null===(e=c.current)||void 0===e||e.focus()},100),document.body.style.overflow="hidden"):document.body.style.overflow="",()=>{document.body.style.overflow=""}),[e]),e&&"undefined"!=typeof window?o.createPortal(ye("div",{className:"fixed inset-0 z-9999 bg-white dark:bg-gray-900 flex flex-col",children:[ye("div",{className:"flex items-center p-2 border-b border-gray-200 dark:border-gray-700 gap-2",children:[ye("button",{onClick:t,className:"p-2 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:ye(Ye,{className:"w-6 h-6"})}),ye("div",{className:"flex-1 relative",children:[ye("input",{ref:c,type:"text",placeholder:u("search")||"Search",value:n,onChange:e=>{const t=e.target.value;t!==n&&a(t)},className:"w-full pl-3 pr-10 py-2 bg-gray-100 dark:bg-gray-800 border-none rounded-full text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-primary focus:outline-none"}),n&&ye("button",{onClick:()=>{""!==n&&a("")},className:"absolute inset-y-0 right-0 pr-3 flex items-center text-gray-400",children:ye(Ne,{className:"w-4 h-4"})})]})]}),ye("div",{className:"flex-1 overflow-y-auto p-2 select-none",children:ye(la,{loading:i,results:l,keyword:n,onResultClick:e=>{null==s||s(e)},emptyText:d})})]}),document.body):null},ca=({app:e,anchorRef:t,onClose:n,isOpen:a})=>{const{t:l}=Ue(),[i,s]=r.useState(""),[d,c]=r.useState(0),[u,g]=r.useState(!1),h=r.useRef(null),m=r.useRef(null);r.useEffect(()=>{a||g(!1)},[a]),r.useEffect(()=>{a&&(setTimeout(()=>{var e;return null===(e=h.current)||void 0===e?void 0:e.focus()},50),s(""),c(0))},[a]),r.useEffect(()=>{const e=e=>{a&&m.current&&!m.current.contains(e.target)&&t.current&&!t.current.contains(e.target)&&n()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[a,n,t]);const[v,f]=r.useState({top:0,left:0}),[p,y]=r.useState("top"),[b,x]=r.useState(0),D=r.useMemo(()=>{const e=new Date,t=new Date(e);t.setHours(t.getHours()+1,0,0,0);const n=new Date(t);return n.setHours(n.getHours()+1),{start:t,end:n}},[a]),w=r.useMemo(()=>{if(!i.trim())return[];const t=[],n=e.getCalendars(),a=e.getAllEvents(),r=i.toLowerCase(),o=a.find(e=>e.title.toLowerCase()===r);let l=null==o?void 0:o.calendarId;if(!l){const e=n.filter(e=>!1!==e.isVisible);if(e.length>0){const t=Math.floor(Math.random()*e.length);l=e[t].id}else n.length>0&&(l=n[0].id)}const s=n.find(e=>e.id===l),d=(null==s?void 0:s.colors.lineColor)||"#3b82f6";t.push({type:"new",title:i,calendarId:l||"",color:d,start:D.start,end:D.end});const c=new Set;c.add(i.toLowerCase());return a.filter(e=>e.title.toLowerCase().includes(r)&&!c.has(e.title.toLowerCase())).slice(0,5).forEach(e=>{c.add(e.title.toLowerCase());const a=n.find(t=>t.id===e.calendarId);t.push({type:"history",title:e.title,calendarId:e.calendarId||"",color:(null==a?void 0:a.colors.lineColor)||"#9ca3af",start:D.start,end:D.end})}),t},[i,e,D]);r.useLayoutEffect(()=>{if(a&&t.current&&m.current){const e=t.current.getBoundingClientRect(),n=m.current.offsetHeight,a=340;let r=e.left+e.width/2-a/2;const o=12,l=window.innerWidth;r<o?r=o:r+a>l-o&&(r=l-a-o);const i=e.left+e.width/2;x(i-r);let s=0,d="top";e.top<n+20?(d="bottom",s=e.bottom+12):(d="top",s=e.top-12-n),y(d),f({top:s,left:r}),g(!0)}},[a,t,w]);const C=t=>{if(!t.calendarId)return;const a=ue(),r={id:a,title:t.title,start:N(t.start),end:N(t.end),calendarId:t.calendarId,allDay:!1};e.addEvent(r),e.setCurrentDate(t.start),e.highlightEvent(a),n()};r.useEffect(()=>{if(!a)return;const e=e=>{"ArrowDown"===e.key?(e.preventDefault(),c(e=>(e+1)%w.length)):"ArrowUp"===e.key?(e.preventDefault(),c(e=>(e-1+w.length)%w.length)):"Enter"===e.key&&(e.preventDefault(),w[d]&&C(w[d]))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[a,w,d]);const E=(e,t)=>{const n=e=>e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1});return`${n(e)} - ${n(t)}`};return a?o.createPortal(ye("div",{ref:m,className:"fixed z-1000 w-85 flex flex-col bg-white dark:bg-slate-800 rounded-xl shadow-2xl border border-gray-200 dark:border-slate-700 "+(u?"animate-in fade-in zoom-in-95 duration-100":""),style:{top:v.top,left:v.left,visibility:u?"visible":"hidden"},children:[ye("div",{className:"p-4 pb-2",children:[ye("div",{className:"mb-2 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:l("quickCreateEvent")||"Quick Create Event"}),ye("div",{className:"relative",children:ye("input",{ref:h,type:"text",className:"w-full border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-1.5 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary transition",placeholder:l("quickCreatePlaceholder")||"Enter title (e.g. Code review)",value:i,onChange:e=>s(e.target.value)})})]}),ye("div",{className:"flex-1 overflow-y-auto max-h-75 py-1 px-2",children:[0===w.length&&i&&ye("div",{className:"px-4 py-3 text-sm text-gray-400 text-center",children:l("noSuggestions")||"Type to create"}),w.map((e,t)=>ye("div",{className:"flex items-center px-4 py-2 cursor-pointer transition-colors rounded-lg "+(t===d?"bg-primary/10 dark:bg-primary/20 ring-1 ring-inset ring-primary/20":"hover:bg-gray-50 dark:hover:bg-slate-700/50"),onClick:()=>C(e),onMouseEnter:()=>c(t),children:[ye("div",{className:"w-1 h-8 rounded-full mr-3 shrink-0",style:{backgroundColor:e.color}}),ye("div",{className:"flex-1 min-w-0 flex flex-col gap-0.5",children:[ye("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 truncate",children:e.title}),ye("div",{className:"flex",children:ye("span",{className:"font-semibold text-[10px] px-1 bg-gray-100 dark:bg-slate-700 rounded text-gray-500 dark:text-gray-400",children:"new"===e.type?l("today"):l("tomorrow")})}),ye("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:E(e.start,e.end)})]})]},`${e.type}-${t}`))]}),ye("div",{className:"absolute w-3 h-3 bg-white dark:bg-slate-800 border-gray-200 dark:border-slate-700 rotate-45 -translate-x-1/2 "+("top"===p?"-bottom-1.5 border-b border-r":"-top-1.5 border-t border-l"),style:{left:b}})]}),document.body):null},ua=({checked:e,onChange:t})=>ye("div",{className:"w-12 h-7 flex items-center rounded-full p-1 cursor-pointer transition-colors "+(e?"bg-green-500":"bg-gray-300"),onClick:()=>t(!e),children:ye("div",{className:"bg-white w-5 h-5 rounded-full shadow-md transform transition-transform "+(e?"translate-x-5":"")})}),ga=({date:e,onChange:t})=>{const n=Array.from({length:24},(e,t)=>t),a=Array.from({length:12},(e,t)=>5*t),o=[...n,...n,...n],l=[...a,...a,...a],i=32,s=e.getHours(),d=5*Math.round(e.getMinutes()/5),c=(24+s)*i,u=(12+d/5)*i,[g,h]=r.useState(c),[m,v]=r.useState(u),f=r.useRef(null),p=r.useRef(null),y=r.useRef(null);r.useEffect(()=>{f.current&&(f.current.scrollTop=c,h(c)),p.current&&(p.current.scrollTop=u,v(u))},[c,u]);const b=(n,a)=>{const r=n.currentTarget;let s=r.scrollTop;if("hour"===a){const e=768;s<320?(s+=e,r.scrollTop=s):s>1600&&(s-=e,r.scrollTop=s),h(s)}else{const e=384;s<160?(s+=e,r.scrollTop=s):s>800&&(s-=e,r.scrollTop=s),v(s)}y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{((n,a)=>{const r=Math.round(a/i);if("hour"===n){const n=o[r];if(void 0!==n&&n!==e.getHours()){const a=new Date(e);a.setHours(n),t(a)}}else{const n=l[r];if(void 0!==n&&5*Math.round(e.getMinutes()/5)!==n){const a=new Date(e);a.setMinutes(n),t(a)}}})(a,s)},150)},x=(e,t)=>{const n=96+e*i+16-(t+112),a=Math.min(Math.abs(n)/112,1);return{transform:`perspective(500px) rotateX(${-(n/112*80)}deg) scale(${1-.4*a})`,opacity:1-.7*a,transition:"transform 0.1s ease-out, opacity 0.1s ease-out"}};return ye("div",{className:"flex h-56 overflow-hidden rounded-lg mt-2 relative ",children:[ye("style",{dangerouslySetInnerHTML:{__html:"\n .no-scrollbar::-webkit-scrollbar { display: none; }\n .no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }\n "}}),ye("div",{ref:f,className:"flex-1 overflow-y-auto snap-y snap-mandatory no-scrollbar",style:{touchAction:"pan-y"},onScroll:e=>b(e,"hour"),children:[ye("div",{style:{height:96}}),o.map((n,a)=>ye("div",{className:"h-8 flex items-center justify-end pr-5 snap-center cursor-pointer",onClick:()=>{var r;const o=new Date(e);o.setHours(n),t(o),null===(r=f.current)||void 0===r||r.scrollTo({top:a*i,behavior:"smooth"})},children:ye("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(a,g),children:n.toString().padStart(2,"0")})},a)),ye("div",{style:{height:96}})]}),ye("div",{ref:p,className:"flex-1 overflow-y-auto snap-y snap-mandatory no-scrollbar",style:{touchAction:"pan-y"},onScroll:e=>b(e,"minute"),children:[ye("div",{style:{height:96}}),l.map((n,a)=>ye("div",{className:"h-8 flex items-center justify-start pl-5 snap-center cursor-pointer",onClick:()=>{var r;const o=new Date(e);o.setMinutes(n),t(o),null===(r=p.current)||void 0===r||r.scrollTo({top:a*i,behavior:"smooth"})},children:ye("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(a,m),children:n.toString().padStart(2,"0")})},a)),ye("div",{style:{height:96}})]}),ye("div",{className:"absolute top-24 left-2 right-2 h-8 bg-gray-300/20 dark:bg-gray-500/20 pointer-events-none border border-gray-300 dark:border-gray-600 rounded-lg"})]})},ha=({isOpen:e,onClose:t,onSave:n,draftEvent:a,app:l})=>{const{locale:i,t:s}=Ue(),[d,c]=r.useState(""),[u,g]=r.useState(""),[h,m]=r.useState(!1),[v,f]=r.useState(new Date),[p,y]=r.useState(new Date),[b,x]=r.useState(""),[D,w]=r.useState(new Date),[C,E]=r.useState(new Date),[k,T]=r.useState(null),[S,M]=r.useState(e),[I,R]=r.useState(!1),[O,P]=r.useState(!1);r.useEffect(()=>{if(!e){R(!0);const e=setTimeout(()=>{M(!1),R(!1)},300);return()=>clearTimeout(e)}M(!0),R(!1)},[e]),r.useEffect(()=>{if(e&&a){const e=l.getEvents().some(e=>e.id===a.id);P(e)}},[e,a,l]);const A=l.getCalendars(),L=A.map(e=>({label:e.name,value:e.id}));r.useEffect(()=>{if(e&&A.length>0){A.some(e=>e.id===u)||"blue"!==u&&""!==u||g(A[0].id)}},[A,e,u]),r.useEffect(()=>(e?(document.body.style.overflow="hidden",document.documentElement.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%"):(document.body.style.overflow="",document.documentElement.style.overflow="",document.body.style.position="",document.body.style.width=""),()=>{document.body.style.overflow="",document.documentElement.style.overflow="",document.body.style.position="",document.body.style.width=""}),[e]),r.useEffect(()=>{var t,n;if(e&&a){if(c(a.title||""),g(a.calendarId||(null===(t=A[0])||void 0===t?void 0:t.id)||"blue"),m(a.allDay||!1),a.start)try{const e=H(a.start);f(e),w(e)}catch(e){console.error("Failed to parse start date",e);const t=new Date;f(t),w(t)}if(a.end)try{const e=H(a.end);y(e),E(e)}catch(e){console.error("Failed to parse end date",e);const t=new Date;y(t),E(t)}}else if(e&&!a){g((null===(n=A[0])||void 0===n?void 0:n.id)||"blue");const e=new Date;e.setMinutes(0,0,0),f(e),w(e),y(new Date(e.getTime()+36e5)),E(e)}},[e,a]);const $=r.useMemo(()=>{if(!e||!a)return!1;let t=new Date(v),n=new Date(p);h&&(t.setHours(0,0,0,0),n.setHours(0,0,0,0));const r=Object.assign(Object.assign({},a),{title:d,calendarId:u,allDay:h,description:b,start:N(t),end:N(n)});return!ce(a,r)},[e,a,d,u,h,v,p,b]);if(!S)return null;const j=e=>{T(t=>t===e?null:e)},Y=e=>e.toLocaleDateString(i,{day:"numeric",month:"short",year:"numeric"}),z=(e,t)=>{if("start"===e){const e=new Date(t);e.setHours(v.getHours(),v.getMinutes());const n=e.getTime()-v.getTime();f(e);const a=new Date(p.getTime()+n);y(a)}else{const e=new Date(t);e.setHours(p.getHours(),p.getMinutes()),y(e)}},F=(e,t)=>{"start"===e?w(e=>{const n=new Date(e);return n.setMonth(e.getMonth()+t),n}):E(e=>{const n=new Date(e);return n.setMonth(e.getMonth()+t),n})};return o.createPortal(ye("div",{className:"fixed inset-0 z-10000 flex items-end pointer-events-none",children:[ye("div",{className:"absolute inset-0 bg-black/30 pointer-events-auto transition-opacity duration-300 "+(I?"opacity-0":"opacity-100"),style:{touchAction:"none"},onClick:t}),ye("div",{className:"relative w-full bg-gray-100 dark:bg-gray-800 rounded-t-2xl shadow-xl h-[85vh] flex flex-col pointer-events-auto overflow-hidden "+(I?"animate-slide-down":"animate-slide-up"),onClick:e=>e.stopPropagation(),children:[ye("div",{className:"flex justify-between items-center p-4 bg-white dark:bg-gray-900 border-b border-gray-200 dark:border-gray-700",children:[ye("button",{onClick:t,className:"text-gray-500 hover:text-gray-700 px-2 py-1",children:s("cancel")}),ye("span",{className:"font-semibold text-lg",children:s(O?"editEvent":"newEvent")}),ye("button",{onClick:()=>{if(!a)return;let e=new Date(v),t=new Date(p);h&&(e.setHours(0,0,0,0),t.setHours(0,0,0,0));const r=Object.assign(Object.assign({},a),{title:d,calendarId:u,allDay:h,start:N(e),end:N(t)});n(r)},disabled:!$,className:"font-bold px-2 py-1 transition-colors "+($?"text-primary":"text-gray-400 cursor-not-allowed opacity-50"),children:s(O?"done":"create")})]}),ye("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[ye("div",{className:"bg-white dark:bg-gray-900 rounded-lg px-4 py-3",children:ye("input",{type:"text",placeholder:s("titlePlaceholder"),value:d,onChange:e=>c(e.target.value),className:"w-full bg-transparent text-xl font-medium placeholder-gray-400 focus:outline-none",autoFocus:!0})}),A.length>0&&ye("div",{className:"bg-white dark:bg-gray-900 rounded-lg px-4 py-3 flex justify-between items-center relative",children:[ye("span",{className:"text-gray-700 dark:text-gray-300",children:s("calendar")}),ye(Fn,{options:L,value:u,onChange:g,registry:l.getCalendarRegistry(),variant:"mobile"})]}),ye("div",{className:"bg-white dark:bg-gray-900 rounded-lg px-4 py-3 flex justify-between items-center",children:[ye("span",{className:"text-gray-700 dark:text-gray-300",children:s("allDay")}),ye(ua,{checked:h,onChange:m})]}),ye("div",{className:"bg-white dark:bg-gray-900 rounded-lg overflow-hidden",children:[ye("div",{className:"flex justify-between items-center px-4 py-3 border-b border-gray-100 dark:border-gray-800 last:border-0",children:[ye("span",{className:"text-gray-700 dark:text-gray-300",children:s("starts")}),ye("div",{className:"flex space-x-2",children:[ye("button",{className:"px-3 py-1 rounded-md transition-colors "+("start-date"===k?"bg-gray-200 dark:bg-gray-700 text-primary dark:text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300"),onClick:()=>j("start-date"),children:Y(v)}),!h&&ye("button",{className:"px-3 py-1 rounded-md transition-colors "+("start-time"===k?"bg-gray-200 dark:bg-gray-700 text-primary dark:text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300"),onClick:()=>j("start-time"),children:Z(v.getHours()+v.getMinutes()/60)})]})]}),ye("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("start-date"===k?"max-h-100":"max-h-0"),children:ye("div",{className:"",children:ye(Pn,{currentDate:v,visibleMonth:D,onDateSelect:e=>z("start",e),onMonthChange:e=>F("start",e),showHeader:!0})})}),ye("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("start-time"===k?"max-h-75":"max-h-0"),children:ye("div",{className:"",children:ye(ga,{date:v,onChange:e=>{const t=p.getTime()-v.getTime();f(e),y(new Date(e.getTime()+t))}})})})]}),ye("div",{className:"bg-white dark:bg-gray-900 rounded-lg overflow-hidden",children:[ye("div",{className:"flex justify-between items-center px-4 py-3 border-b border-gray-100 dark:border-gray-800 last:border-0",children:[ye("span",{className:"text-gray-700 dark:text-gray-300",children:s("ends")}),ye("div",{className:"flex space-x-2",children:[ye("button",{className:"px-3 py-1 rounded-md transition-colors "+("end-date"===k?"bg-gray-200 dark:bg-gray-700 text-primary dark:text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300"),onClick:()=>j("end-date"),children:Y(p)}),!h&&ye("button",{className:"px-3 py-1 rounded-md transition-colors "+("end-time"===k?"bg-gray-200 dark:bg-gray-700 text-primary dark:text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300"),onClick:()=>j("end-time"),children:Z(p.getHours()+p.getMinutes()/60)})]})]}),ye("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("end-date"===k?"max-h-100":"max-h-0"),children:ye("div",{className:"",children:ye(Pn,{currentDate:p,visibleMonth:C,onDateSelect:e=>z("end",e),onMonthChange:e=>F("end",e),showHeader:!0})})}),ye("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("end-time"===k?"max-h-75":"max-h-0"),children:ye("div",{className:"",children:ye(ga,{date:p,onChange:e=>{if(e<v){const t=p.getTime()-v.getTime();y(e),f(new Date(e.getTime()-t))}else y(e)}})})})]}),ye("div",{className:"bg-white dark:bg-gray-900 rounded-lg px-4 py-3",children:ye("textarea",{placeholder:s("notesPlaceholder"),value:b,onChange:e=>x(e.target.value),className:"w-full bg-transparent text-base placeholder-gray-400 focus:outline-none min-h-20"})})]})]})]}),document.body)},ma=({locale:e="en-US",messages:t,children:n})=>{const a=r.useMemo(()=>{if("string"==typeof e){return{code:T(e)?e:"en-US",messages:void 0}}return e&&"string"!=typeof e&&!T(e.code)?Object.assign(Object.assign({},e),{code:"en-US"}):e||{code:"en-US"}},[e]),o=r.useMemo(()=>{const e=a.code;return{locale:e,t:(n,r)=>{var o,l,i;let s=null!==(i=null!==(o=null==t?void 0:t[n])&&void 0!==o?o:null===(l=a.messages)||void 0===l?void 0:l[n])&&void 0!==i?i:We(n,e);return r&&Object.entries(r).forEach(([e,t])=>{s=s.replace(new RegExp(`{${e}}`,"g"),t)}),s},getWeekDaysLabels:Ve,getMonthLabels:_e,isDefault:!1}},[a,t]);return ye(Be.Provider,{value:o,children:n})},va=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],fa=({locale:e,messages:t,children:a})=>Ue().isDefault?ye(ma,{locale:e,messages:t,children:a}):ye(n.Fragment,{children:a}),pa=({app:e,customDetailPanelContent:o,customEventDetailDialog:l,meta:i,customMessages:s,search:d,titleBarSlot:c,collapsedSafeAreaLeft:u})=>{var g,m;const f=r.useContext(fe),[p,y]=r.useState(0);r.useEffect(()=>e.subscribe(()=>{y(e=>e+1)}),[e]);const b=e.getCurrentView(),x=b.component,D=e.getSidebarConfig(),w=null!==(g=null==D?void 0:D.enabled)&&void 0!==g&&g,[C,E]=r.useState(0),[k,T]=r.useState(null!==(m=null==D?void 0:D.initialCollapsed)&&void 0!==m&&m),{t:S}=Ue(),[M,I]=r.useState(!1),[R,O]=r.useState(null),[P,A]=r.useState(!1),L=r.useRef(null),[$,j]=r.useState(!1),[Y,z]=r.useState(!1),[F,V]=r.useState(null),[_,W]=r.useState(null),[B,U]=r.useState(null),Z=r.useCallback(t=>{e.setCurrentDate(t),W(null)},[e]);(({app:e,selectedEventId:n,setSelectedEventId:o,detailPanelEventId:l,setDetailPanelEventId:i,isDrawerOpen:s,setIsDrawerOpen:d})=>{r.useEffect(()=>{const r=t=>a.__awaiter(void 0,void 0,void 0,function*(){const a=document.activeElement,r=a&&("INPUT"===a.tagName||"TEXTAREA"===a.tagName||a.isContentEditable);if((t.metaKey||t.ctrlKey)&&"f"===t.key.toLowerCase()){t.preventDefault();const e=document.getElementById("dayflow-search-input");return void(e&&e.focus())}if((t.metaKey||t.ctrlKey)&&"t"===t.key.toLowerCase())return t.preventDefault(),void e.goToToday();if((t.metaKey||t.ctrlKey)&&"n"===t.key.toLowerCase()){t.preventDefault();const e=document.getElementById("dayflow-add-event-btn");return void(e&&e.click())}if("Escape"===t.key)return l&&i(null),void(s&&d(!1));if(!r){if("ArrowLeft"===t.key)return t.preventDefault(),void e.goToPrevious();if("ArrowRight"===t.key)return t.preventDefault(),void e.goToNext()}if("Tab"===t.key)return t.preventDefault(),void u(t.shiftKey);if(t.metaKey||t.ctrlKey)switch(t.key.toLowerCase()){case"z":t.preventDefault(),e.undo();break;case"c":if(n){const t=e.getEvents().find(e=>e.id===n);if(t)try{yield navigator.clipboard.writeText(JSON.stringify(t,null,2)),nt.setEvent(t)}catch(e){console.error("Failed to copy event",e)}}break;case"x":if(n){const t=e.getEvents().find(e=>e.id===n);if(t)try{yield navigator.clipboard.writeText(JSON.stringify(t,null,2)),nt.setEvent(t),e.deleteEvent(t.id),o(null),i(null)}catch(e){console.error("Failed to cut event",e)}}break;case"v":c()}if("Backspace"===t.key||"Delete"===t.key){if(r)return;n&&(e.deleteEvent(n),o(null),i(null))}}),c=()=>a.__awaiter(void 0,void 0,void 0,function*(){try{let r=nt.getEvent();if(!r){const e=yield navigator.clipboard.readText();if(e)try{r=JSON.parse(e)}catch(e){}}if(r&&"object"==typeof r&&r.title){const l=it(r.start),i=it(r.end).getTime()-l.getTime();let s=new Date;if(n){const t=e.getEvents().find(e=>e.id===n);s=t?it(t.start):new Date(e.getCurrentDate())}else s=new Date(e.getCurrentDate());s.setHours(l.getHours(),l.getMinutes(),l.getSeconds(),0);const d=new Date(s.getTime()+(i>0?i:36e5)),c=r,{_segmentInfo:u}=c,g=a.__rest(c,["_segmentInfo"]),h=Object.assign(Object.assign({},g),{id:ue(),start:r.allDay?st(s):ct(s,t.Temporal.Now.timeZoneId()),end:r.allDay?st(d):ct(d,t.Temporal.Now.timeZoneId()),calendarId:r.calendarId&&e.getCalendarRegistry().has(r.calendarId)?r.calendarId:e.getCalendarRegistry().getDefaultCalendarId()||"default"});e.addEvent(h),o(h.id),e.highlightEvent(h.id)}}catch(e){console.error("Failed to paste",e)}}),u=t=>{const a=e.getEvents(),r=e.state.currentView,l=e.getCurrentDate();let i=[];if(r===exports.ViewType.DAY)i=a.filter(e=>it(e.start).toDateString()===l.toDateString());else if(r===exports.ViewType.WEEK){const{monday:e,sunday:t}=ee(l);i=a.filter(n=>{const a=it(n.start);return a>=e&&a<=t})}else if(r===exports.ViewType.MONTH){const t=e.getVisibleMonth(),n=new Date(t.getFullYear(),t.getMonth(),1),r=new Date(t.getFullYear(),t.getMonth()+1,0);i=a.filter(e=>{const t=it(e.start);return t>=n&&t<=r})}else if(r===exports.ViewType.YEAR){const e=l.getFullYear();i=a.filter(t=>it(t.start).getFullYear()===e)}if(i.sort((e,t)=>{const n=it(e.start),a=it(t.start),r=n.getTime()-a.getTime();return 0!==r?r:e.allDay&&!t.allDay?-1:!e.allDay&&t.allDay?1:0}),0===i.length)return;let s=0;if(n){const e=i.findIndex(e=>e.id===n);-1!==e&&(t?(s=e-1,s<0&&(s=i.length-1)):(s=e+1,s>=i.length&&(s=0)))}const d=i[s];d&&(o(d.id),e.highlightEvent(d.id))};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e,n,l,s])})({app:e,selectedEventId:_,setSelectedEventId:W,detailPanelEventId:B,setDetailPanelEventId:U,isDrawerOpen:Y,setIsDrawerOpen:z}),r.useEffect(()=>{e.state.highlightedEventId&&W(e.state.highlightedEventId)},[e.state.highlightedEventId]);const[q,K]=r.useState(()=>e.getTheme()),[X,G]=r.useState(""),[J,Q]=r.useState(!1),[te,ne]=r.useState(!1),[ae,re]=r.useState(!1),[oe,le]=r.useState([]);r.useEffect(()=>{const e=()=>{j(window.matchMedia("(max-width: 768px)").matches)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),r.useEffect(()=>{var t;if(!X.trim())return Q(!1),le([]),void(null!==e.state.highlightedEventId&&e.highlightEvent(null));const n=null!==(t=null==d?void 0:d.debounceDelay)&&void 0!==t?t:300,r=setTimeout(()=>a.__awaiter(void 0,void 0,void 0,function*(){var t;re(!0),Q(!0);try{let n=[];if(null==d?void 0:d.customSearch){const t=e.getEvents().map(t=>{var n;return Object.assign(Object.assign({},t),{color:(null===(n=e.getCalendarRegistry().get(t.calendarId||""))||void 0===n?void 0:n.colors.lineColor)||e.getCalendarRegistry().resolveColors().lineColor})});n=d.customSearch({keyword:X,events:t})}else if(null==d?void 0:d.onSearch)n=yield d.onSearch(X);else{const t=X.toLowerCase();n=e.getEvents().filter(e=>e.title.toLowerCase().includes(t)||e.description&&e.description.toLowerCase().includes(t)).map(t=>{var n;return Object.assign(Object.assign({},t),{color:(null===(n=e.getCalendarRegistry().get(t.calendarId||""))||void 0===n?void 0:n.colors.lineColor)||e.getCalendarRegistry().resolveColors().lineColor})})}le(n),null===(t=null==d?void 0:d.onSearchStateChange)||void 0===t||t.call(d,{keyword:X,loading:!1,results:n})}catch(e){console.error("Search failed",e),le([])}finally{re(!1)}}),n);return()=>clearTimeout(r)},[X,d,e]),r.useEffect(()=>{J||null!==e.state.highlightedEventId&&e.highlightEvent(null)},[J,e]);const ie=t=>{let n;n=t.start instanceof Date?t.start:"string"==typeof t.start?new Date(t.start):H(t.start),e.setCurrentDate(n),e.highlightEvent(t.id),te&&ne(!1)};r.useEffect(()=>{var e;T(null!==(e=null==D?void 0:D.initialCollapsed)&&void 0!==e&&e)},[null==D?void 0:D.initialCollapsed]),r.useEffect(()=>{const t=e.subscribeThemeChange(e=>{K(e)});return()=>{t()}},[e]);const se=r.useCallback(t=>{e.setTheme(t)},[e]),de=r.useCallback(()=>{E(e=>e+1)},[]),ce=r.useMemo(()=>e.getCalendars(),[e,C,p]),ge=r.useCallback((t,n)=>{e.setCalendarVisibility(t,n),de()},[e,de]),he=r.useCallback(t=>{e.setAllCalendarsVisibility(t),de()},[e,de]),me=r.useCallback(()=>{if("modal"===(D.createCalendarMode||"inline"))return void I(!0);const t=va[Math.floor(Math.random()*va.length)],{colors:n,darkColors:a}=h(t),r=ue(),o={id:r,name:S("untitled"),colors:n,darkColors:a,isVisible:!0,isDefault:!1};e.createCalendar(o),O(r),de()},[e,D.createCalendarMode,S,de]),ve=r.useCallback(t=>{var n,a;if(!e.state.readOnly){if($){const t=new Date;t.setMinutes(0,0,0),t.setHours(t.getHours()+1);const r=new Date(t);r.setHours(r.getHours()+1);const o={id:ue(),title:"",start:N(t),end:N(r),calendarId:(null===(n=e.getCalendars().find(e=>!1!==e.isVisible))||void 0===n?void 0:n.id)||(null===(a=e.getCalendars()[0])||void 0===a?void 0:a.id)};return V(o),void z(!0)}w?P?A(!1):(L.current=t.currentTarget,A(!0)):me()}},[w,$,P,me,e]),pe=r.useRef(null),be=l||(e.getUseEventDetailDialog()?Xn:void 0),xe={app:e,config:b.config||{},customDetailPanelContent:o,customEventDetailDialog:be,switcherMode:e.state.switcherMode,calendarRef:pe,meta:i,selectedEventId:_,onEventSelect:W,onDateChange:Z,detailPanelEventId:B,onDetailPanelToggle:U},De={app:e,calendars:ce,toggleCalendarVisibility:ge,toggleAll:he,isCollapsed:k,setCollapsed:T,renderCalendarContextMenu:D.renderCalendarContextMenu,createCalendarMode:D.createCalendarMode,renderCreateCalendarDialog:D.renderCreateCalendarDialog,editingCalendarId:R,setEditingCalendarId:O,onCreateCalendar:me,colorPickerMode:D.colorPickerMode},we=v(null==D?void 0:D.width,"240px"),Ce=null!=u?"0px":"50px",Ee=e.getCalendarHeaderConfig(),ke=null!=u&&k?u:0,Te=Object.assign({calendar:e,switcherMode:e.state.switcherMode,onAddCalendar:ve,onSearchChange:G,onSearchClick:()=>{G(""),ne(!0)},searchValue:X,isSearchOpen:J,isEditable:!e.state.readOnly},ke>0?{safeAreaLeft:ke}:{}),Se=e.getCustomMobileEventRenderer()||ha;return ye(na,{initialTheme:q,onThemeChange:se,children:ye(fa,{locale:e.state.locale,messages:s,children:ye("div",{className:"df-calendar-container relative flex flex-row overflow-hidden select-none",children:[ye(qt,{store:f,generatorName:"titleBarSlot",generatorArgs:{isCollapsed:k,toggleCollapsed:()=>T(e=>!e)},defaultContent:c&&("function"==typeof c?c({isCollapsed:k,toggleCollapsed:()=>T(e=>!e)}):c)}),w&&ye("aside",{className:"absolute top-0 bottom-0 left-0 z-0 h-full",style:{width:we},children:w?D.render?D.render(De):n.h(zn,De):null}),ye("div",{className:"flex flex-col flex-1 h-full overflow-hidden relative z-10 bg-white dark:bg-gray-900 transition-all duration-250 ease-in-out border-l "+(k?"border-gray-200 dark:border-gray-700 shadow-xl":"border-transparent"),style:{marginLeft:w?k?Ce:we:0},children:[!1===Ee?null:"function"==typeof Ee?Ee(Te):n.h(ea,Te),ye("div",{className:"flex-1 overflow-hidden relative",ref:pe,children:[ye("div",{className:"calendar-renderer h-full relative flex flex-row",children:[ye("div",{className:"flex-1 h-full overflow-hidden",children:ye(x,Object.assign({},xe))}),ye(sa,{isOpen:J,onClose:()=>{Q(!1),G(""),e.highlightEvent(null)},loading:ae,results:oe,keyword:X,onResultClick:ie,emptyText:null==d?void 0:d.emptyText})]}),ye(da,{isOpen:te,onClose:()=>{ne(!1),G(""),e.highlightEvent(null)},keyword:X,onSearchChange:G,results:oe,loading:ae,onResultClick:ie,emptyText:null==d?void 0:d.emptyText})]})]}),ye(ca,{app:e,anchorRef:L,isOpen:P,onClose:()=>A(!1)}),ye(Se,{isOpen:Y,onClose:()=>{z(!1),V(null)},onSave:t=>{e.addEvent(t),z(!1),V(null)},draftEvent:F,app:e}),M&&ye(qt,{store:f,generatorName:"createCalendarDialog",generatorArgs:{onClose:()=>I(!1),onCreate:t=>{e.createCalendar(t),I(!1),de()},colorPickerMode:D.colorPickerMode},defaultContent:D.renderCreateCalendarDialog?D.renderCreateCalendarDialog({onClose:()=>I(!1),onCreate:t=>{e.createCalendar(t),I(!1),de()},colorPickerMode:D.colorPickerMode}):ye(oa,{onClose:()=>I(!1),onCreate:t=>{e.createCalendar(t),I(!1),de()},colorPickerMode:D.colorPickerMode})})]})})})};const ya=({originalComponent:e,app:t,config:n,customDetailPanelContent:o,customEventDetailDialog:l,calendarRef:i,switcherMode:s,meta:d,selectedEventId:c,detailPanelEventId:u,onEventSelect:g,onDateChange:h,onDetailPanelToggle:m})=>{const v=t.getPlugin("events"),f=n.enableDrag?t.getPlugin("drag"):void 0,p=t.getCurrentDate(),y=t.state.currentView,b=t.getEvents(),x=r.useCallback(e=>{v?v.update(e.id,e):t.updateEvent(e.id,e)},[v,t]),D=r.useCallback(e=>{v?v.delete(e):t.deleteEvent(e)},[v,t]),w=r.useCallback(e=>{v?v.add(e):t.addEvent(e)},[v,t]),C=r.useCallback(e=>{h?h(e):t.setCurrentDate(e)},[t,h]),E=r.useCallback(e=>{t.changeView(e)},[t]),k=r.useMemo(()=>{const{dragConfig:e,eventsConfig:t,virtualScrollConfig:r}=n,o=a.__rest(n,["dragConfig","eventsConfig","virtualScrollConfig"]),l=Object.assign({},o);return f&&Object.assign(l,e||{}),v&&Object.assign(l,t||{}),l},[n,f,v]),T=r.useMemo(()=>({app:t,currentDate:p,currentView:y,events:b,onEventUpdate:x,onEventDelete:D,onEventCreate:w,onDateChange:C,onViewChange:E,config:k,customDetailPanelContent:o,customEventDetailDialog:l,calendarRef:i,switcherMode:s,meta:d,selectedEventId:c,detailPanelEventId:u,onEventSelect:g,onDetailPanelToggle:m}),[t,p,y,b,x,D,w,C,E,k,o,l,i,s,d,c,u,g,m]),S=r.useMemo(()=>{const e={currentDate:p,events:b,setEvents:e=>{b.forEach(e=>D(e.id)),e.forEach(e=>w(e))},updateEvent:x,deleteEvent:D,addEvent:w,goToPrevious:()=>{const e=new Date(p);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)}C(e)},goToNext:()=>{const e=new Date(p);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)}C(e)},goToToday:()=>{C(new Date)},changeView:E,selectDate:C};return Object.assign(Object.assign({calendar:e},T),{eventsService:v,dragService:f})},[p,b,y,x,D,w,C,E,T,v,f]);return ye(e,Object.assign({},S))},ba={PARALLEL_THRESHOLD:.25,NESTED_THRESHOLD:.5,INDENT_STEP_PERCENT:2.5,MIN_WIDTH:25,MARGIN_BETWEEN:1,EDGE_MARGIN_PERCENT:.9};function xa(e){return Object.assign(Object.assign({},e),{parentId:void 0,children:[],_startHour:e.allDay?0:j(e.start),_endHour:e.allDay?0:X(e)})}function Da(e){var t;return null!==(t=e._startHour)&&void 0!==t?t:j(e.start)}function wa(e){var t;return null!==(t=e._endHour)&&void 0!==t?t:X(e)}function Ca(e,t){return e.day===t.day&&!e.allDay&&!t.allDay&&(Da(e)<wa(t)&&Da(t)<wa(e))}function Ea(e,t){const n=wa(e)-Da(e);if(n<1.25)return!1;const a=Da(e)+.4*n,r=Da(t)>=a,o=Ca(e,t);return r&&o}function ka(e,t,n=ba){if(!Ca(e,t))return!1;const a=Math.abs(Da(e)-Da(t));return a<=n.PARALLEL_THRESHOLD||(a>n.PARALLEL_THRESHOLD&&a<n.NESTED_THRESHOLD||function(e,t){return!(!Ca(e,t)||!Ea(e,t)&&!Ea(t,e))}(e,t))}function Ta(e,t){const n=Da(e)<=Da(t)&&wa(e)>=wa(t),a=Da(e)<=Da(t)&&Da(t)<wa(e)&&Ca(e,t);return n||a}function Sa(e){const t=[],n=new Set;for(const a of e){if(n.has(a.id))continue;const r=[a];n.add(a.id);for(const t of e){if(n.has(t.id))continue;Math.abs(Da(a)-Da(t))<=ba.PARALLEL_THRESHOLD&&(r.push(t),n.add(t.id))}r.sort((e,t)=>Da(e)-Da(t));const o={events:r,startHour:Math.min(...r.map(e=>Da(e))),endHour:Math.max(...r.map(e=>wa(e)))};t.push(o)}return t.sort((e,t)=>e.startHour-t.startHour),t}function Na(e,t){var n,a;const r=null===(a=null===(n=e[0])||void 0===n?void 0:n.parent)||void 0===a?void 0:a.depth;return void 0===r?[]:t.filter(e=>e.depth===r).map(e=>({node:e,load:Ma(e)})).sort((e,t)=>t.load-e.load)}function Ma(e){let t=0;for(const n of e.children)t+=1+Ma(n);return t}function Ia(e){return!(e.length<2)&&e[0].load-e[e.length-1].load>=2}function Ha(e){let t=0;for(;t<5;){e.sort((e,t)=>t.load-e.load);const n=e[0],a=e[e.length-1];if(n.load-a.load<2)break;const r=Ra(n.node,a.node);if(!r)break;Pa(r,a.node),n.load--,a.load++,t++}}function Ra(e,t){const n=[];return Oa(e,n),n.find(e=>Ta(t.event,e.event))||n[0]||null}function Oa(e,t){0===e.children.length?t.push(e):e.children.forEach(e=>Oa(e,t))}function Pa(e,t){e.parent&&(e.parent.children=e.parent.children.filter(t=>t!==e));const n=t.children.find(t=>Ta(t.event,e.event));n?(e.parent=n,e.depth=n.depth+1,n.children.push(e),Aa(n.event,e.event)):(e.parent=t,e.depth=t.depth+1,t.children.push(e),Aa(t.event,e.event))}function Aa(e,t){t.parentId=e.id,e.children.includes(t.id)||e.children.push(t.id)}function La(e,t){const n=[],a=new Map,r=new Map;t.forEach(e=>r.set(e.id,e));for(const t of e)for(const e of t.events){const t={event:r.get(e.id),children:[],parent:null,depth:0,isProcessed:!1};n.push(t),a.set(e.id,t)}for(let n=0;n<e.length;n++){const o=e[n],l=o.events.map(e=>r.get(e.id));let i=!1;for(let s=n-1;s>=0&&!i;s--){const n=e[s],d={events:n.events.map(e=>r.get(e.id)),startHour:n.startHour,endHour:n.endHour};if($a(d,{events:l,startHour:o.startHour,endHour:o.endHour})){const e=ja(l,d,t);for(const t of e){const e=a.get(t.child.id),n=a.get(t.parent.id);e.parent=n,e.depth=n.depth+1,n.children.push(e)}i=!0}}}const o=n.filter(e=>null===e.parent);return o.forEach(e=>{e.depth=0}),function(e,t){for(let n=e.length-1;n>=1;n--){const a=Na(e[n].events.map(e=>t.find(t=>t.event.id===e.id)),t);Ia(a)&&Ha(a)}}(e,n),o}function $a(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(!Ca(n,e))continue;if(Math.abs(Da(e)-Da(n))<ba.NESTED_THRESHOLD)return!0}return!1}(e,t))return!1;if(n<ba.NESTED_THRESHOLD)return!1;for(const n of e.events)for(const e of t.events)if(Ta(n,e))return!0;return!1}function ja(e,t,n){const a=[],r=(e,t)=>{t.parentId=e.id,e.children.includes(t.id)||e.children.push(t.id)};if(1===e.length){const o=za(e[0],t,n);return o&&(a.push({child:e[0],parent:o}),r(o,e[0])),a}const o=t.events.filter(t=>e.every(e=>Ta(t,e)));if(0===o.length){for(const o of e){const e=za(o,t,n);e&&(a.push({child:o,parent:e}),r(e,o))}return a}const l=[...e].sort((e,t)=>wa(t)-Da(t)-(wa(e)-Da(e)));if(l.length%o.length===0){const e=l.length/o.length;for(let t=0;t<o.length;t++){const n=o[t],i=l.slice(t*e,(t+1)*e);for(const e of i)a.push({child:e,parent:n}),r(n,e)}}else for(const e of l){const t=Ya(e,o,l);t&&(a.push({child:e,parent:t}),r(t,e))}return a}function Ya(e,t,n){if(0===t.length)return null;let a=1/0,r=[];for(const e of t){const t=e.children.length;t<a?(a=t,r=[e]):t===a&&r.push(e)}const o=wa(e)-Da(e),l=r.map(e=>e.children).flat();return o>Math.max(...l.map(e=>{const t=n.find(t=>t.id===e);return t?wa(t)-Da(t):0}),0)?r[0]:r[r.length-1]}function za(e,t,n){const a=t.events.filter(t=>Ta(t,e));if(0===a.length)return null;if(1===a.length)return a[0];const r=a.map(t=>({parent:t,load:t.children.length,hasParallelSibling:t.children.some(t=>{const a=n.find(e=>e.id===t);return a&&ka(e,a,ba)})}));return r.sort((t,n)=>t.load!==n.load?t.load-n.load:t.hasParallelSibling!==n.hasParallelSibling?t.hasParallelSibling?-1:1:Math.abs(Da(e)-Da(t.parent))-Math.abs(Da(e)-Da(n.parent))),r[0].parent}function Fa(e,t,n={}){const a=100-("day"===n.viewType?0:ba.EDGE_MARGIN_PERCENT);if(1===e.length)_a(e[0],0,a,t,n);else if(e.length>1){const r=e.length,o=(a-ba.MARGIN_BETWEEN*(r-1))/r;e.forEach((e,a)=>{_a(e,a*(o+ba.MARGIN_BETWEEN),Math.max(o,ba.MIN_WIDTH),t,n)})}}function Va(e){return"day"===e?.5:2.5}function _a(e,t,n,a,r={}){const o=Va(r.viewType);let l=e.depth*o;if(e.isProcessed){const t=function(e,t){let n=e;for(;n.parent&&n.parent.depth>0;)n=n.parent;return 1===n.depth?n.depth*Va(t):null}(e,r.viewType);null!==t&&(l=t)}const i="day"===r.viewType;let s=0;1===e.depth?s=i?.5:1.5:2===e.depth?s=i?-.01:-1:e.depth>=3&&(s=i?.55:-3.5);const d=t+l+s;let c=n-(l+s);if(d+c>t+n&&(c=t+n-d),a.set(e.event.id,{id:e.event.id,left:d,width:c,zIndex:e.depth,level:e.depth,isPrimary:0===e.depth,indentOffset:l*(r.containerWidth||320)/100,importance:Ua(e.event)}),0===e.children.length)return;const u=[...e.children].sort((e,t)=>wa(t.event)-Da(t.event)-(wa(e.event)-Da(e.event)));1===u.length?_a(u[0],d,c,a,r):Ba(u.map(e=>e.event))?Wa(u,d,c,a,r):u.forEach(e=>_a(e,d,c,a,r))}function Wa(e,t,n,a,r={}){const o=e.length,l=e[0].depth,i=l*Va(r.viewType),s="day"===r.viewType;let d=1===l?s?.5:1.5:2===l?s?-.01:-1:s?.55:-3.5;const c=t+i+d,u=n-(i+d);if(u<=0)return void e.forEach(e=>_a(e,t,n,a,r));let g=ba.MARGIN_BETWEEN*(1===l?s?.15:.3:s?.1:.2);const h=(u-g*(o-1))/o;e.forEach((e,t)=>{const n=c+t*(h+g);if(a.set(e.event.id,{id:e.event.id,left:n,width:h,zIndex:e.depth,level:e.depth,isPrimary:0===e.depth,indentOffset:i*(r.containerWidth||320)/100,importance:Ua(e.event)}),e.children.length>0){const t=[...e.children].sort((e,t)=>wa(t.event)-Da(t.event)-(wa(e.event)-Da(e.event)));1===t.length?_a(t[0],n,h,a,r):Ba(t.map(e=>e.event))?Wa(t,n,h,a,r):t.forEach(e=>_a(e,n,h,a,r))}})}function Ba(e){if(e.length<2)return!1;for(let t=0;t<e.length;t++)for(let n=t+1;n<e.length;n++)if(ka(e[t],e[n],ba))return!0;return!1}function Ua(e){const t=wa(e)-Da(e);return Math.max(.1,Math.min(1,t/4))}class Za{static calculateDayEventLayouts(e,t={}){const n=e.map(xa);for(const e of n)e.parentId=void 0,e.children=[];const a=new Map,r=n.filter(e=>!e.allDay);if(0===r.length)return a;const o=function(e){const t=[],n=new Set;for(const a of e){if(n.has(a.id))continue;const r=[a],o=[a];for(n.add(a.id);o.length>0;){const t=o.shift();for(const a of e)n.has(a.id)||Ca(t,a)&&(r.push(a),o.push(a),n.add(a.id))}t.push(r)}return t}(r);for(const e of o)if(1===e.length){const n="day"===t.viewType?0:ba.EDGE_MARGIN_PERCENT;a.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{Fa(La(Sa([...e].sort((e,t)=>e._startHour!==t._startHour?e._startHour-t._startHour:t._endHour-t._startHour-(e._endHour-e._startHour))),e),a,t)}return a}}const qa={HOUR_HEIGHT:72,FIRST_HOUR:0,LAST_HOUR:24,MIN_DURATION:.25,TIME_COLUMN_WIDTH:80,ALL_DAY_HEIGHT:28,getLineColor:e=>B(e),getDynamicPadding:e=>e.endHour-e.startHour<=.25?"px-1 py-0":"p-1"};const Ka=e=>{const{viewType:t,onEventsUpdate:n}=e,a=t===exports.ViewType.MONTH,o=r.useRef({active:!1,mode:null,eventId:null,startX:0,startY:0,dayIndex:0,startHour:0,endHour:0,originalDay:0,originalStartHour:0,originalEndHour:0,resizeDirection:null,hourOffset:null,duration:0,lastRawMouseHour:null,lastUpdateTime:0,initialMouseY:0,lastClientY:0,allDay:!1,targetDate:null,originalDate:null,originalEvent:null,dragOffset:0,originalStartDate:null,originalEndDate:null,eventDate:void 0,originalStartTime:null,originalEndTime:null,sourceElement:null,indicatorVisible:!1}),l=r.useRef({x:0,y:0}),i=r.useMemo(()=>a?{active:!1,mode:null,eventId:null,targetDate:null,startDate:null,endDate:null}:{active:!1,mode:null,eventId:null,dayIndex:0,startHour:0,endHour:0,allDay:!1},[a]),[s,d]=r.useState(i),c=r.useMemo(()=>function(e,t){let n=null,a=0;const r=function(...r){const o=Date.now(),l=t-(o-a);l<=0||l>t?(n&&(clearTimeout(n),n=null),a=o,e.apply(this,r)):n||(n=setTimeout(()=>{a=Date.now(),n=null,e.apply(this,r)},l))};return r.cancel=()=>{n&&(clearTimeout(n),n=null),a=0},r}((e,t)=>n(e,"resize"===t),a?16:8),[a,n]),u=r.useCallback(()=>{d(a?{active:!1,mode:null,eventId:null,targetDate:null,startDate:null,endDate:null}:{active:!1,mode:null,eventId:null,dayIndex:0,startHour:0,endHour:0,allDay:!1}),o.current={active:!1,mode:null,eventId:null,startX:0,startY:0,dayIndex:0,startHour:0,endHour:0,originalDay:0,originalStartHour:0,originalEndHour:0,duration:0,resizeDirection:null,hourOffset:null,lastRawMouseHour:null,lastUpdateTime:0,initialMouseY:0,lastClientY:0,allDay:!1,targetDate:null,originalDate:null,originalEvent:null,dragOffset:0,originalStartDate:null,originalEndDate:null,eventDate:void 0,originalStartTime:null,originalEndTime:null,sourceElement:null,indicatorVisible:!1}},[a]);return{dragRef:o,currentDragRef:l,dragState:s,setDragState:d,resetDragState:u,throttledSetEvents:c}},Xa={renderAllDayContent:({title:e,color:t})=>ye("div",{className:"h-full flex items-center overflow-hidden pl-3 pt-1",children:[ye(Me,{className:"h-3 w-3 mr-1 text-white"}),ye("div",{className:"font-medium text-xs truncate pr-1 text-white",children:e})]}),renderRegularContent:({drag:e,title:t,layout:a,formatTime:r,getLineColor:o,getDynamicPadding:l,color:i,isMobile:s})=>ye(n.Fragment,{children:[ye("div",{className:hn,style:{backgroundColor:o(i||"blue")}}),ye("div",{className:`h-full flex flex-col overflow-hidden pl-3 text-white ${l(e)}`,children:[ye("div",{className:"font-medium text-xs truncate pr-1 text-white",style:{lineHeight:e.endHour-e.startHour<=.25?"1.2":"normal"},children:t}),!e.allDay&&e.endHour-e.startHour>.5&&ye("div",{className:"text-xs truncate time-display text-white opacity-90",children:[r(e.startHour)," - ",r(e.endHour)]})]}),s&&ye(n.Fragment,{children:[ye("div",{className:"absolute -top-1.5 right-5 w-2.5 h-2.5 bg-white border-2 rounded-full z-50",style:{borderColor:o(i||"blue")}}),ye("div",{className:"absolute -bottom-1.5 left-5 w-2.5 h-2.5 bg-white border-2 rounded-full z-50",style:{borderColor:o(i||"blue")}})]})]}),renderDefaultContent:({drag:e,title:t,allDay:a})=>a?ye("div",{className:"h-full flex items-center overflow-hidden pl-3 px-1 py-0",children:[ye("svg",{className:"h-3 w-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:ye("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 002 2z"})}),ye("div",{className:"font-medium text-xs truncate pr-1",style:{lineHeight:1.2},children:t})]}):ye(n.Fragment,{children:[ye("div",{className:"absolute left-0.5 top-1 bottom-1 w-0.5 rounded-full bg-primary"}),ye("div",{className:"h-full flex flex-col overflow-hidden pl-3 p-1",children:ye("div",{className:"font-medium text-xs truncate pr-1 text-primary",children:t})})]})},Ga=({drag:e,color:t,title:n,layout:a,allDay:r,formatTime:o,getLineColor:l,getDynamicPadding:i,renderer:s=Xa,isMobile:d})=>{const{t:c}=Ue(),u=n||c(r?"newAllDayEvent":"newEvent");return ye("div",{className:"drag-indicator-content",children:t?r?s.renderAllDayContent({drag:e,color:t,title:u,layout:a,allDay:r,formatTime:o,getLineColor:l,getDynamicPadding:i,isMobile:d}):s.renderRegularContent({drag:e,color:t,title:u,layout:a,allDay:r,formatTime:o,getLineColor:l,getDynamicPadding:i,isMobile:d}):s.renderDefaultContent({drag:e,color:t,title:u,layout:a,allDay:r,formatTime:o,getLineColor:l,getDynamicPadding:i,isMobile:d})})},Ja=({event:e,isCreating:t,isMultiDay:n=!1,startDate:a,endDate:r})=>{const{t:o}=Ue(),l=(()=>{if(t)return{title:o("newEvent"),icon:ye(je,{className:"h-3 w-3"}),showDateRange:!1};if(n&&a&&r){const t=L(a,r)+1;return{title:e.title.replace(/ \(\d+天\)$/,""),showDateRange:!0,duration:t}}return{title:e.title,showDateRange:!1}})();return ye("div",{className:"flex items-center space-x-2 text-white text-xs font-medium rounded-sm",children:[ye("div",{className:"shrink-0",children:l.icon}),ye("div",{className:"flex-1 min-w-0",children:ye("div",{className:"truncate font-medium",children:l.title})})]})},Qa=e=>{let t,n;return"touches"in e&&e.touches.length>0?(t=e.touches[0].clientX,n=e.touches[0].clientY):"changedTouches"in e&&e.changedTouches.length>0?(t=e.changedTouches[0].clientX,n=e.changedTouches[0].clientY):(t=e.clientX,n=e.clientY),{clientX:t,clientY:n}},er=e=>{const t=r.useMemo(()=>Object.assign(Object.assign(Object.assign({},qa),e),{getLineColor:t=>{var n;return e.getLineColor?e.getLineColor(t):B(t,null===(n=e.app)||void 0===n?void 0:n.getCalendarRegistry())}}),[e]),{viewType:a}=t,o=a===exports.ViewType.MONTH||a===exports.ViewType.YEAR,l=(e=>{const{calendarRef:t,allDayRowRef:n,viewType:a,HOUR_HEIGHT:o=72,FIRST_HOUR:l=0,LAST_HOUR:i=24,TIME_COLUMN_WIDTH:s=80,isMobile:d}=e,c=a===exports.ViewType.MONTH,u=a===exports.ViewType.WEEK,g=r.useCallback(e=>{if(c||!t.current)return l;const n=t.current.querySelector(".calendar-content");if(!n)return l;const a=n.getBoundingClientRect(),r=n.scrollTop,s=n.querySelector(".df-time-grid-row"),d=s?s.getBoundingClientRect().top-a.top+r:0,u=(e-a.top+r-d)/o+l;return Math.max(l,Math.min(i,u))},[t,l,o,i,c]),h=r.useCallback(e=>{if(c||!t.current)return 0;const n=t.current.querySelector(".calendar-content");if(!n)return 0;const a=n.getBoundingClientRect(),r=n.scrollLeft,o=a.width;if(u){const t=(d?1.75*o:o)/7,n=e-a.left+r,l=Math.floor(n/t);return Math.max(0,Math.min(6,l))}return 0},[t,c,u,d]),m=r.useCallback(e=>{if(c||!t.current)return;const n=t.current.querySelector(".calendar-content");if(!n)return;const a=n.getBoundingClientRect();e<a.top?n.scrollTop+=e-a.top:e+40>a.bottom&&(n.scrollTop+=e+40-a.bottom)},[t,c]),v=r.useCallback(e=>!(c||!(null==n?void 0:n.current))&&e<=n.current.getBoundingClientRect().bottom,[n,c]),f=r.useMemo(()=>864e5,[]);return{pixelYToHour:g,getColumnDayIndex:h,checkIfInAllDayArea:v,handleDirectScroll:m,daysDifference:r.useCallback((e,t)=>L(e,t),[]),addDaysToDate:r.useCallback((e,t)=>$(e,t),[]),getTargetDateFromPosition:r.useCallback((e,n)=>{if(a!==exports.ViewType.MONTH&&a!==exports.ViewType.YEAR||!t.current)return null;const r=document.elementFromPoint(e,n);if(!r)return null;let o=r,l=0;for(;o&&!o.hasAttribute("data-date")&&l<10;)o=o.parentElement,l++;if(o&&o.hasAttribute("data-date")){const e=o.getAttribute("data-date");if(e)return new Date(e+"T00:00:00")}return null},[t,a]),ONE_DAY_MS:f}})(t),i=Ka(t),s=(e=>{const{t:t,locale:a}=Ue(),{calendarRef:o,allDayRowRef:l,viewType:i,getLineColor:s,getDynamicPadding:d,renderer:c,HOUR_HEIGHT:u=72,FIRST_HOUR:g=0,TIME_COLUMN_WIDTH:h=80,ALL_DAY_HEIGHT:m=60,app:v,isMobile:f}=e,p=i===exports.ViewType.MONTH||i===exports.ViewType.YEAR,y=i===exports.ViewType.DAY,b=r.useCallback(()=>{var e;const t=null===(e=o.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(!t)return 0;const n=t.querySelector(".df-time-grid-row");return n?n.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop:0},[o]),x=r.useRef(null),D=r.useRef(null),w=r.useCallback(()=>{x.current&&(n.render(null,x.current),x.current.remove(),x.current=null),D.current=null},[]),C=r.useCallback((e,r,i,C,E)=>{var k,T,S,M,I,H,R,O,P;w();const A=document.createElement("div");if(A.style.position=p?"fixed":"absolute",A.style.pointerEvents="none",A.style.zIndex="1000",p){let o,l;if(A.style.opacity="0.9",E){const t=E.getBoundingClientRect(),n=null!==(T=null!==(k=e.currentSegmentDays)&&void 0!==k?k:e.eventDurationDays)&&void 0!==T?T:1;o=t.width/n,l=t.height,A.className=`rounded-sm shadow-sm ${E.className}`}else o=120,l=22,A.className="rounded text-xs px-2 py-1";A.style.width=`${o}px`,A.style.height=`${l}px`,A.style.left=e.startX-o/2+"px",A.style.top=e.startY-l/2+"px",document.body.appendChild(A);const s=N(new Date),d=e.originalEvent||{id:String(Date.now()),color:r||"blue",title:i||t("newEvent"),start:s,end:s,allDay:!1,day:0};n.render(n.h(ma,{locale:a},n.h(Ja,{event:d,isCreating:"create"===e.mode,targetDate:e.targetDate||null,startDate:e.originalStartDate||null,endDate:e.originalEndDate||null})),A)}else{if(E){const t=E.getBoundingClientRect();let n;if(n=e.allDay?null===(S=null==l?void 0:l.current)||void 0===S?void 0:S.getBoundingClientRect():null===(I=null===(M=o.current)||void 0===M?void 0:M.querySelector(".calendar-content"))||void 0===I?void 0:I.getBoundingClientRect(),n){if(e.allDay&&y){A.style.left=`${h}px`,A.style.top=E.offsetTop-2+"px";const e=f?0:11;A.style.width=`calc(100% - ${h}px - ${2+e}px)`,A.style.height=`${t.height}px`}else if(e.allDay&&!y){const n=`calc(${f&&!y?"175%":"100%"} / 7)`;A.style.left=`calc(${n} * ${e.dayIndex})`,A.style.top=E.offsetTop-2+"px",A.style.width=`calc(${n} - 2px)`,A.style.height=`${t.height}px`}else{const a=(e.startHour-g)*u,r=null===(H=o.current)||void 0===H?void 0:H.querySelector(".calendar-content"),l=(null==r?void 0:r.scrollLeft)||0,i=b();A.style.left=`${t.left-n.left+l}px`,A.style.top=`${a+3+i}px`,A.style.width=`${t.width}px`,A.style.height=`${t.height}px`}A.className=E.className,A.style.opacity="0.8",A.style.boxShadow="0 4px 12px rgba(0, 0, 0, 0.15)"}}else if(e.allDay)if(A.style.top="2px",A.style.height=m-4+"px",A.style.marginBottom="3px",A.className="rounded-xl shadow-sm",y){A.style.left=`${h}px`;const e=f?0:11;A.style.width=`calc(100% - ${h}px - ${2+e}px)`}else{const t=`calc(${f?"175%":"100%"} / 7)`;A.style.left=`calc(${t} * ${e.dayIndex})`,A.style.width=`calc(${t} - 2px)`}else{const t=b(),n=(e.startHour-g)*u,a=(e.endHour-e.startHour)*u;if(A.style.top=`${n+3+t}px`,A.style.height=a-4+"px",A.style.color="#fff",A.className="rounded-sm shadow-sm",C){if(y)A.style.left=`${h}px`,A.style.width=`calc(((100% - ${h}px) * ${C.width/100}) - 3px)`;else{const t=`calc(${f&&!y?"175%":"100%"} / 7)`;A.style.left=`calc((${t} * ${e.dayIndex}) + (${t} * ${C.left/100}))`,A.style.width=`calc((${t} * ${(C.width-1)/100}))`}A.style.zIndex=String(1e3)}else{const t=y?`calc(100% - ${h}px)`:`calc(${f&&!y?"175%":"100%"} / 7)`;A.style.left=y?`${h}px`:`calc(${t} * ${e.dayIndex})`,A.style.width=`calc(${t} - 3px)`}}e.allDay?null===(R=null==l?void 0:l.current)||void 0===R||R.appendChild(A):null===(P=null===(O=o.current)||void 0===O?void 0:O.querySelector(".calendar-content"))||void 0===P||P.appendChild(A),D.current={drag:e,color:r,title:i,layout:C},n.render(n.h(ma,{locale:a},n.h(Ga,{drag:e,color:r,title:i,layout:C,allDay:e.allDay,formatTime:Z,getLineColor:s||(()=>""),getDynamicPadding:d||(()=>"0px"),renderer:c,isMobile:f})),A)}r?(A.style.backgroundColor=W(r,null==v?void 0:v.getCalendarRegistry()),A.style.color=_(r,null==v?void 0:v.getCalendarRegistry())):A.className+=" bg-primary/10 text-primary border border-dashed border-primary/50",x.current=A},[w,p,y,l,o,Z,s,d,c,h,m,g,u,b]),E=r.useCallback((...e)=>{var t,r;const i=x.current;if(i)if(p){const[t,n]=e,a=parseFloat(i.style.width)||120,r=parseFloat(i.style.height)||22;requestAnimationFrame(()=>{i.style.left=t-a/2+"px",i.style.top=n-r/2+"px",i.style.transition="none"})}else{const[v,p,x,w=!1,C]=e;if(w&&i.parentElement!==(null==l?void 0:l.current))null===(t=null==l?void 0:l.current)||void 0===t||t.appendChild(i);else if(!w){const e=null===(r=o.current)||void 0===r?void 0:r.querySelector(".calendar-content");i.parentElement!==e&&(null==e||e.appendChild(i))}if(w){if(y){i.style.left=`${h}px`;const e=f?0:11;i.style.width=`calc(100% - ${h}px - ${2+e}px)`}else{const e=`calc(${f&&!y?"175%":"100%"} / 7)`;i.style.left=`calc(${e} * ${v})`,i.style.width=`calc(${e} - 2px)`,i.style.top="2px"}i.style.height=m-4+"px",i.style.marginBottom="3px",i.className=i.className.replace("rounded-sm","rounded-xl")}else{const e=b(),t=(p-g)*u,n=(x-p)*u;i.style.top=`${t+3+e}px`,i.style.height=n-4+"px",i.style.marginBottom="0",i.className=i.className.replace("rounded-xl","rounded-sm");const a=f&&!y?"175%":"100%";if(C){if(y)i.style.left=`${h}px`,i.style.width=`calc(((100% - ${h}px) * ${C.width/100}) - 3px)`;else{const e=`calc(${a} / 7)`;i.style.left=`calc((${e} * ${v}) + (${e} * ${C.left/100}))`,i.style.width=`calc((${e} * ${(C.width-1)/100}))`}i.style.zIndex=String(C.zIndex+10)}else{const e=y?`calc(100% - ${h}px)`:`calc(${a} / 7)`;i.style.left=y?`${h}px`:`calc(${e} * ${v})`,i.style.width=`calc(${e} - 3px)`}}if(i.style.cursor="grabbing",D.current){const e=Object.assign(Object.assign({},D.current.drag),{dayIndex:v,startHour:p,endHour:x,allDay:w});D.current.drag=e,n.render(n.h(ma,{locale:a},n.h(Ga,{drag:e,color:D.current.color,title:D.current.title,layout:C||D.current.layout,allDay:w,formatTime:Z,getLineColor:s||(()=>""),getDynamicPadding:d||(()=>"0px"),renderer:c,isMobile:f})),i)}}},[p,l,Z,o,y,m,h,g,u,s,d,c,b]);return{dragIndicatorRef:x,removeDragIndicator:w,createDragIndicator:C,updateDragIndicator:E}})(t),d=(e=>{const{t:t}=Ue(),{options:n,common:a,state:o,manager:l}=e,{viewType:i,onEventsUpdate:s,onEventCreate:d,onEventEdit:c,calculateNewEventLayout:u,calculateDragLayout:g,currentWeekStart:h,events:m,FIRST_HOUR:v=0,LAST_HOUR:f=24,MIN_DURATION:p=.25,app:y}=n,{dragRef:b,currentDragRef:x,setDragState:D,resetDragState:w,throttledSetEvents:C}=o,{removeDragIndicator:E,createDragIndicator:k,updateDragIndicator:T}=l,{pixelYToHour:S,getColumnDayIndex:I,checkIfInAllDayArea:R,handleDirectScroll:O,daysDifference:P,addDaysToDate:A,getTargetDateFromPosition:L}=a,$=i===exports.ViewType.MONTH||i===exports.ViewType.YEAR,F=i===exports.ViewType.DAY,V=864e5,_=(e,t,n=!1)=>{const a=new Date(e);a.setHours(0,0,0,0);const r=new Date(t);r.setHours(0,0,0,0);let o=Math.floor((r.getTime()-a.getTime())/V);if(o<=0)return 0;if(!n&&1===o){const n=0===t.getHours()&&0===t.getMinutes()&&0===t.getSeconds()&&0===t.getMilliseconds(),a=t.getTime()-e.getTime();if(n&&a<V)return 0}return o},W=r.useCallback(e=>{var t,n;const a=null==y?void 0:y.getReadOnlyConfig(),r=!1!==(null==a?void 0:a.draggable),o=!(null==y?void 0:y.state.readOnly),l=b.current;if(!l)return;if("move"===l.mode&&!r)return;if(("resize"===l.mode||"create"===l.mode)&&!o)return;e.cancelable&&(e.preventDefault(),e.stopPropagation());const{clientX:i,clientY:s}=Qa(e);if(!l||!l.active)return;if("move"===l.mode&&!l.indicatorVisible){if(Math.hypot(i-l.startX,s-l.startY)<3)return;k(l,l.calendarId,l.title,null,l.sourceElement||void 0),l.indicatorVisible=!0}"resize"===l.mode?l.allDay?document.body.style.cursor="ew-resize":document.body.style.cursor="ns-resize":document.body.style.cursor="grabbing";const d=R(s),c=F?l.dayIndex:I(i);if(d){if(!l.allDay){l.allDay=!0,l.startHour=0,l.endHour=0,l.eventDate=h?le(h,c):new Date,E(),l.indicatorVisible=!1;const e=null==m?void 0:m.find(e=>e.id===l.eventId);k(l,null==e?void 0:e.calendarId,null==e?void 0:e.title),l.sourceElement=null,l.indicatorVisible=!0}l.dayIndex=c,D(e=>Object.assign(Object.assign({},e),{dayIndex:c,startHour:0,endHour:0,allDay:!0})),T(c,0,0,!0)}else{O(s);const e=S(s);if(null!==(t=l.startDragDayIndex)&&void 0!==t||l.originalDay,l.dayIndex,l.allDay){l.allDay=!1,l.startHour=K(e),l.endHour=l.startHour+1,l.duration=1,l.hourOffset=0,l.eventDate=h?le(h,c):new Date,E(),l.indicatorVisible=!1;const t=null==m?void 0:m.find(e=>e.id===l.eventId);k(l,null==t?void 0:t.calendarId,null==t?void 0:t.title),l.sourceElement=null,l.indicatorVisible=!0}else{let t=K(e+(null!==(n=l.hourOffset)&&void 0!==n?n:0));t=Math.max(v,Math.min(f-l.duration,t)),l.startHour=t,l.endHour=t+l.duration}l.dayIndex=c,l.eventDate=h?le(h,c):new Date,D(e=>Object.assign(Object.assign({},e),{dayIndex:c,startHour:K(l.startHour),endHour:K(l.endHour),allDay:!1}));let a=null;if("move"===l.mode&&l.eventId&&g){const e=null==m?void 0:m.find(e=>e.id===l.eventId);e&&(a=g(e,c,K(l.startHour),K(l.endHour)))}T(c,K(l.startHour),K(l.endHour),!1,a)}},[g,R,k,h,m,v,I,O,f,F,S,E,T,b,D]),B=r.useCallback(()=>{const e=b.current;if(!e||!e.active)return;const t=null==y?void 0:y.getReadOnlyConfig(),n=!1!==(null==t?void 0:t.draggable),a=!(null==y?void 0:y.state.readOnly);if("move"===e.mode&&!n)return;if(("resize"===e.mode||"create"===e.mode)&&!a)return;if(document.body.style.cursor="default","move"===e.mode&&!e.indicatorVisible)return document.removeEventListener("mousemove",W),document.removeEventListener("mouseup",B),document.removeEventListener("touchmove",W,{capture:!0}),document.removeEventListener("touchend",B),void w();if("move"!==e.mode||!e.eventId)return;let r=e.startHour,o=e.endHour;e.allDay||(r=K(e.startHour),o=K(e.endHour),o-r<p&&(o=r+p)),null==s||s(t=>t.map(t=>{var n,a;if(t.id!==e.eventId)return t;h?le(h,e.dayIndex):H(t.start);const l=null!==(n=e.startDragDayIndex)&&void 0!==n?n:e.originalDay,i=e.dayIndex-l;let s,d;if(e.allDay){const n=e.originalStartDate?new Date(e.originalStartDate):H(t.start);n.setHours(0,0,0,0);const a=new Date(n);a.setDate(a.getDate()+i);const r=new Date(a);e.eventDurationDays&&e.eventDurationDays>0&&r.setDate(r.getDate()+e.eventDurationDays),s=M(a),d=M(z(r))}else{const n=H(t.start),l=H(t.end),c=t.allDay;if(_(n,l,null!==(a=t.allDay)&&void 0!==a&&a)>0&&!c){const e=new Date(n);e.setDate(e.getDate()+i);const t=new Date(l);t.setDate(t.getDate()+i),s=N(e),d=N(t)}else{const t=h?le(h,e.dayIndex):new Date,n=Y(t,r),a=Y(t,o);s=N(n),d=N(a)}}const c=e.originalDay+i;return Object.assign(Object.assign({},t),{day:c,start:s,end:d,allDay:e.allDay})})),document.removeEventListener("mousemove",W),document.removeEventListener("mouseup",B),document.removeEventListener("touchmove",W,{capture:!0}),document.removeEventListener("touchend",B),E(),w()},[W,E,w,s,p,h,b]),Z=r.useCallback(e=>{var a,r,o,l,i,s,d,c,p,x;const D=b.current;if(!D||!D.active)return;const w=null==y?void 0:y.getReadOnlyConfig(),E=!1!==(null==w?void 0:w.draggable),R=!(null==y?void 0:y.state.readOnly);if("move"===D.mode&&!E)return;if(("resize"===D.mode||"create"===D.mode)&&!R)return;e.cancelable&&(e.preventDefault(),e.stopPropagation());const{clientX:j,clientY:z}=Qa(e);if(D&&D.active)if("resize"===D.mode?$||D.allDay?document.body.style.cursor="ew-resize":document.body.style.cursor="ns-resize":document.body.style.cursor="grabbing",$){if("resize"!==D.mode){if("move"===D.mode){const e=Math.hypot(j-D.startX,z-D.startY);!D.indicatorVisible&&e>=3&&(k(D,null===(a=D.originalEvent)||void 0===a?void 0:a.calendarId,null===(r=D.originalEvent)||void 0===r?void 0:r.title,null,D.sourceElement||void 0),D.indicatorVisible=!0)}D.indicatorVisible&&T(j,z)}const e=L(j,z);if(!e)return;if("resize"===D.mode&&D.originalEvent&&D.resizeDirection){const t=H(D.originalEvent.start);let n,a;const r=(e,t)=>{var n,a;e&&((null===(n=D.originalEvent)||void 0===n?void 0:n.allDay)?e.setHours(0,0,0,0):t&&e.setHours(t.hour,t.minute,null!==(a=t.second)&&void 0!==a?a:0,0))},o=D.originalStartTime,l=D.originalEndTime;if("left"===D.resizeDirection){n=new Date(e),r(n,o);const i=H(D.originalEvent.end)||t;a=new Date(i),r(a,l),n>a&&(n=a)}else{const i=H(D.originalEvent.start)||t;n=new Date(i),r(n,o),a=new Date(e),r(a,l),a<n&&(a=n)}D.originalStartDate=new Date(n.getTime()),D.originalEndDate=new Date(a.getTime());const i=D.originalEvent.allDay?M(n):N(n),s=D.originalEvent.allDay?M(a):N(a);C(e=>e.map(e=>e.id===D.eventId?Object.assign(Object.assign({},e),{start:i,end:s,title:e.title}):e),D.mode)}else if("move"===D.mode)if(D.originalStartDate&&D.originalEndDate){const t=new Date(D.originalStartDate);t.setHours(0,0,0,0);const n=P(t,e),a=A(D.originalStartDate,n),r=A(D.originalEndDate,n);(null===(o=D.originalStartDate)||void 0===o?void 0:o.getTime())!==a.getTime()&&(D.originalStartDate=new Date(a.getTime()),D.originalEndDate=new Date(r.getTime()),D.targetDate=a)}else(null===(l=D.targetDate)||void 0===l?void 0:l.getTime())!==e.getTime()&&(D.targetDate=e)}else{O(z),D.lastClientY=z;const e=S(z);if("create"===D.mode&&D.allDay){const e=Math.hypot(j-D.startX,z-D.startY);if(!D.indicatorVisible){if(e<3)return;k(D,"blue",t("newAllDayEvent")),D.indicatorVisible=!0}const n=F?D.dayIndex:I(j);return D.dayIndex=n,void T(n,0,0,!0)}if("resize"===D.mode)if(D.allDay){const e=F?D.dayIndex:I(j);let t=D.originalStartDate||new Date,n=D.originalEndDate||new Date;"left"===D.resizeDirection?(t=h?le(h,e):new Date,t>n&&(t=n)):"right"===D.resizeDirection&&(n=h?le(h,e):new Date,n<t&&(n=t)),D.originalStartDate=new Date(t.getTime()),D.originalEndDate=new Date(n.getTime());const a=M(t),r=M(n);C(e=>e.map(e=>e.id!==D.eventId?e:Object.assign(Object.assign({},e),{start:a,end:r,allDay:!0})),D.mode)}else{let t=D.startHour,n=D.endHour;const a=null==m?void 0:m.find(e=>e.id===D.eventId);let r=D.dayIndex;if(a){const e=H(a.start),t=H(a.end),n=_(e,t,null!==(i=a.allDay)&&void 0!==i&&i);r=(null!==(s=a.day)&&void 0!==s?s:0)+n}let o=r,l=D.originalDay;if("top"===D.resizeDirection){const a=F?D.dayIndex:I(j),o=e+(null!==(d=null==D?void 0:D.hourOffset)&&void 0!==d?d:0);a<r?(l=a,t=Math.max(v,Math.min(f,o))):(l=r,o>D.originalEndHour?(t=D.originalEndHour,n=o,D.hourOffset=n-e):(t=Math.max(v,o),D.originalEndHour-t<U&&(t=D.originalEndHour-U)))}else if("bottom"===D.resizeDirection){const a=F?D.dayIndex:I(j),r=e+(null!==(c=null==D?void 0:D.hourOffset)&&void 0!==c?c:0);a!==D.dayIndex?(o=a,n=Math.max(v,Math.min(f,r))):r<D.originalStartHour?(n=D.originalStartHour,t=r,D.hourOffset=t-e):(n=Math.min(f,r),n-D.startHour<U&&(n=D.startHour+U))}else if("right"===D.resizeDirection){const e=F?D.dayIndex:I(j);o=Math.max(D.dayIndex,e)}o===l&&([t,n]=[Math.max(v,Math.min(t,n)),Math.min(f,Math.max(t,n))]);const[u,g]=[K(t),K(n)];D.startHour=t,D.endHour=n,D.dayIndex=l,C(e=>e.map(e=>{if(e.id!==D.eventId)return e;const t=H(e.start),n=Y(h?le(h,l):t,u),a=h?le(h,o):t,r=Y(a,g),i=N(n),s=N(r);return Object.assign(Object.assign({},e),{start:i,end:s,day:l})}),D.mode),T(D.dayIndex,u,g,!1)}else if("create"===D.mode){if(n.isMobile){const t=K(e+(null!==(p=D.hourOffset)&&void 0!==p?p:0)),n=Math.max(v,Math.min(f-(D.duration||1),t));D.startHour=n,D.endHour=n+(D.duration||1)}else{const t=K(e),[n,a]=z<D.startY?[t,Math.max(t+U,D.endHour)]:[D.startHour,Math.max(D.startHour+U,t)];D.startHour=n,D.endHour=a}const t=null==u?void 0:u(D.dayIndex,D.startHour,D.endHour);T(D.dayIndex,D.startHour,D.endHour,!1,t)}else if("move"===D.mode){const t=F?D.dayIndex:I(j);let n=K(e+(null!==(x=D.hourOffset)&&void 0!==x?x:0));n=Math.max(v,Math.min(f-D.duration,n));const a=n+D.duration;D.dayIndex=t,D.startHour=n,D.endHour=a;let r=null;if(D.eventId&&g){const e=null==m?void 0:m.find(e=>e.id===D.eventId);e&&(r=g(e,t,K(n),K(a)))}T(t,K(n),K(a),!1,r)}}},[$,F,T,L,C,P,A,v,f,u,I,S,O,g,m,b,k]),q=r.useCallback(e=>{var n,a,r;const o=b.current;if(!o||!o.active)return;const l=null==y?void 0:y.getReadOnlyConfig(),i=!1!==(null==l?void 0:l.draggable),c=!(null==y?void 0:y.state.readOnly);if("move"===o.mode&&!i)return;if(("resize"===o.mode||"create"===o.mode)&&!c)return;if(document.body.style.cursor="default",("move"===o.mode||"create"===o.mode)&&!o.indicatorVisible)return document.removeEventListener("mousemove",Z),document.removeEventListener("mouseup",q),document.removeEventListener("touchmove",Z,{capture:!0}),document.removeEventListener("touchend",q),void w();const{clientX:u,clientY:g}=Qa(e);if(o&&o.active){if($){if("resize"===o.mode&&o.eventId&&o.originalStartDate&&o.originalEndDate){D(e=>"targetDate"in e?Object.assign(Object.assign({},e),{targetDate:o.originalStartDate,startDate:o.originalStartDate,endDate:o.originalEndDate}):e);const e=(null===(n=o.originalEvent)||void 0===n?void 0:n.allDay)||!1,t=e?M(o.originalStartDate):N(o.originalStartDate),a=e?M(o.originalEndDate):N(o.originalEndDate);C(e=>e.map(e=>e.id===o.eventId?Object.assign(Object.assign({},e),{start:t,end:a,title:e.title}):e))}else if("move"===o.mode)if(o.eventId&&o.originalStartDate&&o.originalEndDate){const e=(null===(a=o.originalEvent)||void 0===a?void 0:a.start)?H(o.originalEvent.start):null;if(e&&e.getTime()!==o.originalStartDate.getTime()){D(e=>"targetDate"in e?Object.assign(Object.assign({},e),{targetDate:o.originalStartDate,startDate:o.originalStartDate,endDate:o.originalEndDate}):e);const e=(null===(r=o.originalEvent)||void 0===r?void 0:r.allDay)||!1,t=e?M(o.originalStartDate):N(o.originalStartDate),n=e?M(o.originalEndDate):N(o.originalEndDate);C(e=>e.map(e=>e.id===o.eventId?Object.assign(Object.assign({},e),{start:t,end:n,title:e.title}):e))}}else{const e=L(u,g)||o.targetDate;o.eventId&&e&&(D(t=>"targetDate"in t?Object.assign(Object.assign({},t),{targetDate:e}):t),C(t=>t.map(t=>{if(t.id!==o.eventId)return t;const n=H(t.start),a=H(t.end),r=new Date(e);r.setHours(n.getHours(),n.getMinutes(),0,0);const l=new Date(e);l.setHours(a.getHours(),a.getMinutes(),0,0);const i=t.allDay?M(r):N(r),s=t.allDay?M(l):N(l);return Object.assign(Object.assign({},t),{start:i,end:s})})))}}else{let[e,n]=[K(o.startHour),K(o.endHour)];if(n-e<p&&("top"===o.resizeDirection?e=n-p:n=e+p),"create"===o.mode){const a=h?le(h,o.dayIndex):new Date;D(t=>"dayIndex"in t?Object.assign(Object.assign({},t),{dayIndex:o.dayIndex,startHour:e,endHour:n}):t);const r=Y(a,e),l=Y(a,n),i=o.allDay,s=i?M(r):N(r),c=i?M(l):N(l);null==d||d({id:String(Date.now()),title:t(i?"newAllDayEvent":"newEvent"),day:o.dayIndex,start:s,end:c,calendarId:"blue",allDay:i})}else"move"!==o.mode&&"resize"!==o.mode||(D(t=>"dayIndex"in t?Object.assign(Object.assign({},t),{dayIndex:o.dayIndex,startHour:e,endHour:n}):t),"move"===o.mode?null==s||s(e=>e.map(e=>e.id===o.eventId?Object.assign(Object.assign({},e),{day:o.dayIndex}):e)):"resize"===o.mode&&(null==s||s(e=>[...e])))}document.removeEventListener("mousemove",Z),document.removeEventListener("mouseup",q),document.removeEventListener("touchmove",Z,{capture:!0}),document.removeEventListener("touchend",q),E(),o.indicatorVisible=!1,o.sourceElement=null,w()}},[$,Z,E,w,L,C,p,h,d,s,b,D]),G=r.useCallback((e,...a)=>{var r;if(null==y?void 0:y.state.readOnly)return;if(e.cancelable&&e.preventDefault(),e.stopPropagation(),null===(r=b.current)||void 0===r?void 0:r.active)return;const{clientX:o,clientY:l}=Qa(e);if($){const[e]=a,n=new Date(e);n.setHours(9,0,0,0);const r=new Date(e);r.setHours(10,0,0,0);const o=N(n),l=N(r),i={id:String(Date.now()),title:t("newEvent"),start:o,end:l,day:e.getDay(),calendarId:"blue",allDay:!1};null==d||d(i),c&&setTimeout(()=>{c(i)},50)}else{const[e,r]=a,i=b.current;if(!i)return;const s=1,d=!!n.isMobile?-s/2:0,c=K(r+d);Object.assign(i,{active:!0,mode:"create",eventId:null,startX:o,startY:l,dayIndex:e,startHour:c,endHour:c+s,allDay:!1,eventDate:h?le(h,e):new Date,duration:s,hourOffset:d}),D({active:!0,mode:"create",eventId:null,dayIndex:e,startHour:i.startHour,endHour:i.endHour,allDay:!1});const g=null==u?void 0:u(e,i.startHour,i.endHour);k(i,"blue",t("newEvent"),g),i.sourceElement=null,i.indicatorVisible=!0,document.addEventListener("mousemove",Z),document.addEventListener("mouseup",q),document.addEventListener("touchmove",Z,{capture:!0,passive:!1}),document.addEventListener("touchend",q)}},[$,d,c,h,u,k,Z,q,b,D]),J=r.useCallback((e,t)=>{var n,a,r,o;if(e.cancelable&&("touches"in e||"changedTouches"in e)&&e.preventDefault(),e.stopPropagation(),null===(n=b.current)||void 0===n?void 0:n.active)return;const{clientX:l,clientY:i}=Qa(e),s=b.current;if(!s)return;const d=e.currentTarget;if($){x.current={x:l-d.getBoundingClientRect().left,y:i-d.getBoundingClientRect().top};const e=H(t.start),n=H(t.end);let a=1;if(t.allDay&&t.start&&t.end){const t=new Date(e);t.setHours(0,0,0,0);const r=new Date(n);r.setHours(0,0,0,0),a=Math.floor((r.getTime()-t.getTime())/864e5+1),a=Math.max(1,a)}const r=d.getAttribute("data-segment-days"),o=r?parseInt(r,10):a;s.active=!0,s.mode="move",s.eventId=t.id,s.startX=l,s.startY=i,s.targetDate=e,s.originalDate=e,s.originalEvent=Object.assign({},t),s.lastUpdateTime=Date.now(),s.originalStartDate=e,s.originalEndDate=n,s.eventDurationDays=a,s.currentSegmentDays=o,D({active:!0,mode:"move",eventId:t.id,targetDate:e,startDate:e,endDate:n}),s.sourceElement=d,s.indicatorVisible=!1,document.addEventListener("mousemove",Z),document.addEventListener("mouseup",q),document.addEventListener("touchmove",Z,{capture:!0,passive:!1}),document.addEventListener("touchend",q)}else{const e=S(i),n=t._segmentInfo,c=!!n,u=c?n.dayIndex:null!==(a=t.day)&&void 0!==a?a:0,g=c?n.startHour:j(t.start);let h=0;if(t.allDay&&t.start&&t.end){const e=H(t.start);e.setHours(0,0,0,0);const n=H(t.end);n.setHours(0,0,0,0),h=Math.floor((n.getTime()-e.getTime())/864e5)}const m=H(t.start);if(Object.assign(s,{active:!0,mode:"move",eventId:t.id,startX:l,startY:i,dayIndex:u,startHour:g,endHour:c?n.endHour:X(t),originalDay:null!==(r=t.day)&&void 0!==r?r:0,originalStartHour:j(t.start),originalEndHour:X(t),allDay:t.allDay||!1,eventDate:m,eventDurationDays:h,startDragDayIndex:u,calendarId:t.calendarId,title:t.title}),!t.allDay){s.hourOffset=g-e;const n=H(t.start),a=H(t.end).getTime()-n.getTime();s.duration=a/36e5}D({active:!0,mode:"move",eventId:t.id,dayIndex:null!==(o=t.day)&&void 0!==o?o:0,startHour:j(t.start),endHour:X(t),allDay:t.allDay||!1}),s.sourceElement=d,s.indicatorVisible=!1,document.addEventListener("mousemove",W),document.addEventListener("mouseup",B),document.addEventListener("touchmove",W,{capture:!0,passive:!1}),document.addEventListener("touchend",B)}},[$,k,q,Z,W,B,S,b,x,D]),Q=r.useCallback((e,t,n)=>{var a,r,o,l,i,s;if(null==y?void 0:y.state.readOnly)return;if(e.cancelable&&e.preventDefault(),e.stopPropagation(),null===(a=b.current)||void 0===a?void 0:a.active)return;const{clientX:d,clientY:c}=Qa(e),u=b.current;if(u){if($){const e=H(t.start),a=H(t.start),r=H(t.end),o={hour:a.getHours(),minute:a.getMinutes(),second:a.getSeconds()},l={hour:r.getHours(),minute:r.getMinutes(),second:r.getSeconds()};u.active=!0,u.mode="resize",u.eventId=t.id,u.startX=d,u.startY=c,u.targetDate="left"===n?a:r,u.originalDate=e,u.originalEvent=Object.assign({},t),u.lastUpdateTime=Date.now(),u.resizeDirection=n,u.originalStartDate=a,u.originalEndDate=r,u.originalStartTime=o,u.originalEndTime=l,D({active:!0,mode:"resize",eventId:t.id,targetDate:"left"===n?a:r,startDate:a,endDate:r})}else if(t.allDay){const e=H(t.start),a=H(t.end);u.active=!0,u.mode="resize",u.eventId=t.id,u.startX=d,u.startY=c,u.allDay=!0,u.resizeDirection=n,u.originalStartDate=e,u.originalEndDate=a,u.originalEvent=Object.assign({},t),u.dayIndex=null!==(r=t.day)&&void 0!==r?r:0,D({active:!0,mode:"resize",eventId:t.id,dayIndex:null!==(o=t.day)&&void 0!==o?o:0,startHour:0,endHour:0,allDay:!0})}else{const e=S(c);Object.assign(u,{active:!0,mode:"resize",eventId:t.id,startX:d,startY:c,dayIndex:null!==(l=t.day)&&void 0!==l?l:0,startHour:j(t.start),endHour:X(t),originalDay:null!==(i=t.day)&&void 0!==i?i:0,originalStartHour:j(t.start),originalEndHour:X(t),resizeDirection:n,lastUpdateTime:Date.now(),initialMouseY:e,hourOffset:"top"===n?j(t.start)-e:X(t)-e,allDay:!1}),D({active:!0,mode:"resize",eventId:t.id,dayIndex:null!==(s=t.day)&&void 0!==s?s:0,startHour:j(t.start),endHour:X(t),allDay:!1})}document.addEventListener("mousemove",Z),document.addEventListener("mouseup",q),document.addEventListener("touchmove",Z,{capture:!0,passive:!1}),document.addEventListener("touchend",q)}},[$,Z,q,S,b,D]);return{handleDragMove:Z,handleDragEnd:q,handleCreateStart:G,handleMoveStart:J,handleResizeStart:Q,handleUniversalDragMove:W,handleUniversalDragEnd:B}})({options:t,common:l,state:i,manager:s}),c=(e=>{const{t:t}=Ue(),{options:n,common:a,state:o,manager:l,handleDragMove:i,handleDragEnd:s}=e,{viewType:d,currentWeekStart:c,app:u}=n,{dragRef:g,setDragState:h}=o,{createDragIndicator:m}=l,{pixelYToHour:v,getColumnDayIndex:f}=a,p=d===exports.ViewType.MONTH;return{handleCreateAllDayEvent:r.useCallback((e,a)=>{var r;if(null==u?void 0:u.state.readOnly)return;if(p)return;if(e.preventDefault(),e.stopPropagation(),"dblclick"===e.type){const e=c?le(c,a):new Date,r=M(e),o=M(e),l={id:String(Date.now()),title:t("newAllDayEvent"),day:a,start:r,end:o,calendarId:"blue",allDay:!0};return void n.onEventCreate(l)}if(null===(r=g.current)||void 0===r?void 0:r.active)return;const o=g.current;o&&(Object.assign(o,{active:!0,mode:"create",eventId:null,startX:e.clientX,startY:e.clientY,dayIndex:a,allDay:!0,eventDate:c?le(c,a):new Date}),h({active:!0,mode:"create",eventId:null,dayIndex:a,startHour:0,endHour:0,allDay:!0}),o.indicatorVisible=!1,o.sourceElement=null,document.addEventListener("mousemove",i),document.addEventListener("mouseup",s))},[p,c,s,i,g,h,null==u?void 0:u.state.locale,n]),pixelYToHour:v,getColumnDayIndex:f}})({options:t,common:l,state:i,manager:s,handleDragMove:d.handleDragMove,handleDragEnd:d.handleDragEnd}),u=(e=>{const{common:t}=e,{daysDifference:n,addDaysToDate:a,getTargetDateFromPosition:r}=t;return{daysDifference:n,addDaysToDate:a,getTargetDateFromPosition:r}})({common:l});return Object.assign({createDragIndicator:s.createDragIndicator,updateDragIndicator:s.updateDragIndicator,removeDragIndicator:s.removeDragIndicator,handleCreateStart:d.handleCreateStart,handleMoveStart:d.handleMoveStart,handleResizeStart:d.handleResizeStart,dragState:i.dragState,isDragging:i.dragState.active},o?{daysDifference:u.daysDifference,addDaysToDate:u.addDaysToDate,getTargetDateFromPosition:u.getTargetDateFromPosition}:{handleCreateAllDayEvent:c.handleCreateAllDayEvent,pixelYToHour:c.pixelYToHour,getColumnDayIndex:c.getColumnDayIndex})};function tr(e,t){const n=e.getPlugin("drag"),a=er(Object.assign(Object.assign({},t),{app:e}));if(!n)return m.warn("Drag plugin is not installed. Drag functionality will be disabled. Add createDragPlugin() to your plugins array to enable dragging."),{handleMoveStart:()=>{},handleCreateStart:()=>{},handleResizeStart:()=>{},handleCreateAllDayEvent:void 0,dragState:a.dragState,isDragging:!1};const r=n.getConfig(),o=n.isViewSupported(t.viewType),l=!1!==e.getReadOnlyConfig().draggable,i=!e.state.readOnly;return o||console.info(`Drag functionality is not supported for ${t.viewType} view.`),{handleMoveStart:o&&r.enableDrag&&l?a.handleMoveStart:()=>{},handleCreateStart:o&&r.enableCreate&&i?a.handleCreateStart:()=>{},handleResizeStart:o&&r.enableResize&&i?a.handleResizeStart:void 0,handleCreateAllDayEvent:o&&r.enableAllDayCreate&&i?a.handleCreateAllDayEvent:()=>{},dragState:a.dragState,isDragging:!(!o||!l)&&a.isDragging}}function nr(e){const{app:n,onEventCreated:a}=e,{t:o}=Ue(),l=r.useCallback(e=>{e.dataTransfer.types.includes("application/x-dayflow-calendar")&&(e.preventDefault(),e.dataTransfer.dropEffect="copy")},[]);return{handleDrop:r.useCallback((e,r,l,i)=>{e.preventDefault();const s=e.dataTransfer.getData("application/x-dayflow-calendar");if(!s)return null;try{const e=JSON.parse(s);let d,c,u=!1;i?(d=t.Temporal.PlainDateTime.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate(),hour:0,minute:0}),c=t.Temporal.PlainDateTime.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate(),hour:23,minute:59,second:59}),u=!0):void 0!==l?(d=t.Temporal.PlainDateTime.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate(),hour:l,minute:0}),c=d.add({hours:1})):(d=t.Temporal.PlainDateTime.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate(),hour:9,minute:0}),c=d.add({hours:1}));const g={id:`event-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,title:o(u?"newAllDayCalendarEvent":"newCalendarEvent",{calendarName:e.calendarName}),description:"",start:d,end:c,calendarId:e.calendarId,allDay:u};return n.addEvent(g),null==a||a(g),g}catch(e){return console.error("Error creating event from calendar drop:",e),null}},[n,a]),handleDragOver:l}}const ar=({handlePreviousMonth:e,handleToday:t,handleNextMonth:n})=>{const{t:a}=Ue();return ye("div",{className:"df-navigation flex items-center gap-1",children:[ye("button",{className:yn,onClick:e,"aria-label":"Previous month",children:ye(be,{className:bn})}),ye("button",{className:"df-today-button calendar-today-button inline-flex items-center justify-center px-4 h-7 text-sm font-medium rounded-md border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 hover:bg-gray-50 dark:hover:bg-gray-700 hover:border-gray-300 dark:hover:border-gray-500 active:bg-gray-100 dark:active:bg-gray-600 transition-all duration-150 shadow-sm hover:shadow focus:outline-none",onClick:t,children:a("today")}),ye("button",{className:yn,onClick:n,"aria-label":"Next month",children:ye(xe,{className:bn})})]})},rr=({app:e,currentDate:t,visibleMonth:n,currentDayEvents:a,selectedEvent:r,setSelectedEvent:o,handleMonthChange:l,handleDateSelect:i,switcherMode:s})=>{const{t:d,locale:c}=Ue(),u=[...a].sort((e,t)=>e.allDay&&!t.allDay?-1:!e.allDay&&t.allDay?1:0);return ye("div",{className:"df-right-panel hidden md:block flex-none w-[30%] bg-white dark:bg-gray-900",onContextMenu:e=>e.preventDefault(),children:ye("div",{className:`${Nn} h-full`,children:[ye("div",{className:"df-mini-calendar px-2 border-b border-gray-200 dark:border-gray-700",children:ye("div",{children:[ye("div",{className:"flex items-center justify-end gap-2",children:[ye("div",{className:Gt,style:{position:"relative"},children:ye("div",{children:ye("h1",{className:Jt,children:" "})})}),ye(ar,{handlePreviousMonth:()=>e.goToPrevious(),handleNextMonth:()=>e.goToNext(),handleToday:()=>e.goToToday()})]}),ye(Pn,{visibleMonth:n,currentDate:t,showHeader:!0,onMonthChange:l,onDateSelect:i})]})}),ye("div",{className:"flex-1 overflow-y-auto",children:ye("div",{className:"p-4",children:[ye("h3",{className:"text-lg font-semibold mb-3 sticky top-0 bg-white dark:bg-gray-900 z-10 py-2",children:t.toLocaleDateString(c,{weekday:"long",month:"long",day:"numeric"})}),0===u.length?ye("p",{className:`${En} ${Sn}`,children:d("noEvents")}):ye("div",{className:"space-y-2",children:u.map(t=>ye("div",{className:`\n p-2 rounded border-l-4 cursor-pointer transition-colors\n ${(null==r?void 0:r.id)===t.id?"bg-primary/10 border-primary":"bg-gray-50 dark:bg-gray-800 border-gray-300 dark:border-gray-600"}\n hover:bg-gray-100 dark:hover:bg-gray-700\n `,style:{borderLeftColor:B(t.calendarId||"blue")},onClick:()=>{o(t),e.onEventClick(t)},children:[ye("div",{className:`font-medium ${Sn}`,children:t.title}),!t.allDay&&ye("div",{className:`${Tn} ${kn}`,children:[Z(j(t.start))," -"," ",Z(X(t))]}),t.allDay&&ye("div",{className:`${Tn} ${kn}`,children:d("allDay")})]},t.id))})]})})]})})},or=({viewType:e,currentDate:t,onPrevious:n,onNext:a,onToday:r,customTitle:o,customSubtitle:l,showTodayBox:i,stickyYear:s,stickyYearOffset:d=0,nextYear:c,nextYearOffset:u=0})=>{const{locale:g}=Ue(),h=void 0===i||i,m=o||(()=>{switch(e){case"day":return t.toLocaleDateString(g,{day:"numeric",month:"long",year:"numeric"});case"week":case"month":return t.toLocaleDateString(g,{month:"long",year:"numeric"});case"year":return t.getFullYear().toString();default:return""}})(),v="day"===e?l||("day"===e?t.toLocaleDateString(g,{weekday:"long"}):null):null;return ye("div",{className:Gt,style:{position:"relative"},onContextMenu:e=>e.preventDefault(),children:[ye("div",{className:"flex-1",children:ye("div","year"===e&&s?{style:{position:"relative",overflow:"hidden",height:"1.5em"},children:[ye("h1",{className:Jt,style:{position:"absolute",top:0,left:0,transform:`translateY(-${d}px)`,willChange:"transform"},children:s}),c&&ye("h1",{className:Jt,style:{position:"absolute",top:0,left:0,transform:`translateY(${u}px)`,willChange:"transform"},children:c})]}:{children:[ye("div",{className:`${Jt} text-gray-900 dark:text-white`,children:m}),v&&ye("div",{className:"mt-3 text-gray-600 dark:text-gray-400",children:v})]})}),h&&n&&a&&r&&ye("div",{className:"flex items-center gap-2",children:ye(ar,{handlePreviousMonth:n,handleNextMonth:a,handleToday:r})})]})},lr=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("假期")?ye(Re,{className:"h-3 w-3"}):t.includes("birthday")||t.includes("anniversary")||t.includes("生日")?ye(Oe,{className:"h-3 w-3"}):t.includes("conference")||t.includes("meeting")||t.includes("会议")||t.includes("研讨")?ye(Ae,{className:"h-3 w-3"}):t.includes("trip")||t.includes("travel")||t.includes("旅行")?ye(Pe,{className:"h-3 w-3"}):ye(Me,{className:"h-3 w-3"})},ir=(e,t)=>{const n=[],a=new Date(t);return a.setDate(t.getDate()+6),a.setHours(23,59,59,999),e.forEach(e=>{const r=H(e.start),o=H(e.end),l=new Date(r);l.setHours(0,0,0,0);const i=new Date(o);i.setHours(0,0,0,0);let s=new Date(i);if(!e.allDay){if(!(0!==o.getHours()||0!==o.getMinutes()||0!==o.getSeconds())){const e=o.getTime()-r.getTime();e>0&&e<864e5&&(s=new Date(i),s.setDate(s.getDate()-1))}}const d=L(l,s)>0;if(!d&&e.allDay){if(l<t||l>a)return;const r=Math.floor((l.getTime()-t.getTime())/864e5);return void(r>=0&&r<=6&&n.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(!d)return;const c=l;let u;if(e.allDay)u=new Date(i),u.setHours(23,59,59,999);else{0!==o.getHours()||0!==o.getMinutes()||0!==o.getSeconds()?(u=new Date(i),u.setHours(23,59,59,999)):(u=new Date(i),u.setTime(u.getTime()-1))}if(u<t||c>a)return;const g=c<t?t:c,h=u>a?a:u,m=Math.max(0,Math.floor((g.getTime()-t.getTime())/864e5)),v=Math.min(6,Math.floor((h.getTime()-t.getTime())/864e5)),f=c>=t,p=u<=a,y=0===m||6===v;let b;b=f&&p?"single":f?y&&6===v?"start-week-end":"start":p?y&&0===m?"end-week-start":"end":"middle";const x=L(c,u)+1;n.push({id:`${e.id}-week-${t.getTime()}`,originalEventId:e.id,event:e,startDayIndex:m,endDayIndex:v,segmentType:b,totalDays:x,segmentIndex:0,isFirstSegment:f,isLastSegment:p})}),n},sr=(e,t)=>{if(e.allDay)return[];const n=H(e.start),a=H(e.end),r=new Date(n);r.setHours(0,0,0,0);const o=new Date(a);o.setHours(0,0,0,0);const l=L(r,o);if(0===l)return[];const i=0!==a.getHours()||0!==a.getMinutes()||0!==a.getSeconds()||0!==a.getMilliseconds(),s=a.getTime()-n.getTime();if(!e.allDay&&1===l&&!i&&s<864e5)return[];const d=i?l:Math.max(0,l-1),c=[];for(let e=0;e<=d;e++){const o=new Date(r);o.setDate(r.getDate()+e);const l=Math.floor((o.getTime()-t.getTime())/864e5);if(l<0||l>6)continue;const s=0===e,u=e===d,g=s?n.getHours()+n.getMinutes()/60:0,h=u&&i?a.getHours()+a.getMinutes()/60:24;c.push({dayIndex:l,startHour:g,endHour:h,isFirst:s,isLast:u})}return c},dr=o.memo(({segment:e,segmentIndex:t,isDragging:a,isResizing:o=!1,isSelected:l=!1,onMoveStart:i,onResizeStart:s,onEventLongPress:d,isMobile:c=!1,isDraggable:u=!0,isEditable:g=!0,viewable:h=!0})=>{const[m,v]=r.useState(!1),f=17*t,p=`calc(${e.startDayIndex/7*100}% + 2px)`,y=`calc(${(e.endDayIndex-e.startDayIndex+1)/7*100}% - 4px)`,b=r.useRef(null),x=r.useRef(null),D=t=>{const n="left"===t;return(n?e.isFirstSegment:e.isLastSegment)&&s&&g?ye("div",{className:`resize-handle absolute ${n?"left-0":"right-0"} top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20`,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),s(t,e.event,n?"left":"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}):null},w=e.event.calendarId||"blue",C=e.endDayIndex-e.startDayIndex+1;return ye("div",{className:"absolute px-1 text-xs select-none flex items-center transition-all duration-200 hover:shadow-sm dark:hover:shadow-lg dark:hover:shadow-black/20 group",style:Object.assign(Object.assign({left:p,width:y,top:`${f}px`,height:"16px",borderRadius:(E=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"}[E]),pointerEvents:"auto",zIndex:10},l||a||m?{backgroundColor:W(w),color:"#fff"}:{backgroundColor:V(w),color:_(w)}),{cursor:u||h?"pointer":"default"}),"data-segment-days":C,onMouseDown:t=>{if(!u&&!h)return;t.preventDefault(),t.stopPropagation(),v(!0);!t.target.closest(".resize-handle")&&u&&i(t,e.event)},onMouseUp:()=>{v(!1)},onMouseLeave:()=>{v(!1)},onTouchStart:t=>{if(!i||!c||!u&&!h)return;t.stopPropagation(),v(!0);const n=t.touches[0],a=n.clientX,r=n.clientY,o=t.currentTarget;x.current={x:a,y:r},b.current=setTimeout(()=>{d&&d(e.event.id);u&&i({preventDefault:()=>{},stopPropagation:()=>{},currentTarget:o,touches:[{clientX:a,clientY:r}],cancelable:!1},e.event),b.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},onTouchMove:e=>{if(b.current&&x.current){const t=Math.abs(e.touches[0].clientX-x.current.x),n=Math.abs(e.touches[0].clientY-x.current.y);(t>10||n>10)&&(clearTimeout(b.current),b.current=null,x.current=null,v(!1))}},onTouchEnd:()=>{v(!1),b.current&&(clearTimeout(b.current),b.current=null),x.current=null},title:`${e.event.title} (${at(e.event.start)} - ${at(e.event.end)})`,children:[c&&l&&g&&ye(n.Fragment,{children:[e.isFirstSegment&&ye("div",{className:"absolute left-5 top-1/2 -translate-y-1/2 w-2.5 h-2.5 bg-white border-2 rounded-full z-50 pointer-events-none",style:{borderColor:B(w)}}),e.isLastSegment&&ye("div",{className:"absolute right-5 top-1/2 -translate-y-1/2 w-2.5 h-2.5 bg-white border-2 rounded-full z-50 pointer-events-none",style:{borderColor:B(w)}})]}),D("left"),ye("div",{className:"flex-1 min-w-0",style:{cursor:o?"ew-resize":"pointer"},children:(()=>{const t=e.event.allDay,n=e.event.calendarId||"blue",a=j(e.event.start),r=X(e.event),o=Z(a),l=Z(r);if(t){const t=()=>e.isFirstSegment?e.event.title:"middle"===e.segmentType||e.isLastSegment&&e.totalDays>1?"···":e.event.title;return ye("div",{className:"flex items-center min-w-0 w-full pointer-events-auto",children:[e.isFirstSegment&&lr(e.event)&&ye("div",{className:"shrink-0 mr-1",children:ye("div",{className:"rounded-full p-0.5 text-white flex items-center justify-center",style:{backgroundColor:B(n),width:"12px",height:"12px"},children:lr(e.event)})}),ye("div",{className:"flex-1 min-w-0",children:ye("div",{className:"truncate text-xs",children:t()})}),e.isLastSegment&&"single"!==e.segmentType&&ye("div",{className:"shrink-0 ml-1 text-white/80 dark:text-white/90",children:ye("div",{className:"w-1.5 h-1.5 rounded-full bg-white/60 dark:bg-white/80"})})]})}const i=e.isFirstSegment||e.isLastSegment?e.event.title:"···",s=e.endDayIndex-e.startDayIndex+1,d=s>1?{position:"absolute",right:`calc(${s>1?(s-1)/s*100:0}% + 2px)`,top:"50%",transform:"translateY(-50%)"}:void 0;return ye("div",{className:"relative flex items-center min-w-0 w-full pointer-events-auto",children:[ye("div",{className:mn,style:{backgroundColor:B(n)}}),ye("div",{className:"flex items-center min-w-0 flex-1",children:ye("span",{className:`whitespace-nowrap overflow-hidden block ${c?"mobile-mask-fade":"truncate"} font-medium text-xs`,children:i})}),e.isFirstSegment&&!c&&ye("span",{className:"text-xs font-medium whitespace-nowrap "+(1===s?"ml-2":""),style:d,children:o}),e.isLastSegment&&!e.event.allDay&&24!==r&&!c&&ye("span",{className:"text-xs font-medium whitespace-nowrap ml-auto",children:`ends ${l}`})]})})()}),D("right")]});var E});dr.displayName="MultiDayEvent";const cr=({event:e,position:n,panelRef:a,isAllDay:l,eventVisibility:i,calendarRef:s,selectedEventElementRef:d,onEventUpdate:c,onEventDelete:u,app:h})=>{var m;const{effectiveTheme:v}=aa(),f=Dt(v),{t:p}=Ue(),y="dark"===f||"undefined"!=typeof document&&document.documentElement.classList.contains("dark"),b=!(null==h?void 0:h.state.readOnly);if(!(!1!==(null==h?void 0:h.getReadOnlyConfig().viewable)))return null;const x=y?"#1f2937":"white",D=y?"rgb(55, 65, 81)":"rgb(229, 231, 235)",w=r.useMemo(()=>(h?h.getCalendarRegistry():g()).getVisible().map(e=>({label:e.name,value:e.id})),[h,null==h?void 0:h.getCalendars()]),C=r.useMemo(()=>S(e.start)?e.end&&!S(e.end)&&(e.end.timeZoneId||e.end.timeZoneId)||t.Temporal.Now.timeZoneId():e.start.timeZoneId||e.start.timeZoneId||t.Temporal.Now.timeZoneId(),[e.end,e.start]),E=t=>{const[n,a]=t;c(Object.assign(Object.assign({},e),{start:n.toPlainDate(),end:a.toPlainDate()}))},k=(()=>{var e;let t={};if("sticky-top"===i){const a=null===(e=s.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(a){const e=a.getBoundingClientRect().top+3-n.top;t=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:x,transform:"rotate(45deg)",transformOrigin:"center",top:e-6+"px",borderRight:""+(n.isSunday?`1px solid ${D}`:"none"),borderTop:""+(n.isSunday?`1px solid ${D}`:"none"),borderLeft:""+(n.isSunday?"none":`1px solid ${D}`),borderBottom:""+(n.isSunday?"none":`1px solid ${D}`)},n.isSunday?{right:"-6px"}:{left:"-6px"})}}else if("sticky-bottom"===i){const e=a.current;let r=200;if(e){const t=e.getBoundingClientRect(),n=window.getComputedStyle(e),a=parseInt(n.paddingBottom,10)||0,o=parseInt(n.borderBottomWidth,10)||0;r=t.height-a-o-6+11}t={position:"absolute",width:"12px",height:"12px",backgroundColor:x,transform:"rotate(45deg)",transformOrigin:"center",top:`${r}px`,left:n.isSunday?void 0:"-6px",right:n.isSunday?"-6px":void 0,borderRight:""+(n.isSunday?`1px solid ${D}`:"none"),borderTop:""+(n.isSunday?`1px solid ${D}`:"none"),borderLeft:""+(n.isSunday?"none":`1px solid ${D}`),borderBottom:""+(n.isSunday?"none":`1px solid ${D}`)}}else if(n&&d.current&&s.current){const e=d.current.getBoundingClientRect(),r=s.current.querySelector(".calendar-content");if(r){const o=r.getBoundingClientRect(),l=Math.max(e.top,o.top),i=Math.min(e.bottom,o.bottom),s=Math.max(0,i-l);let d;d=s===e.height?e.top+e.height/2:s>0?l+s/2:e.top+e.height/2;const c=d-n.top,u=a.current;let g=228;if(u){const e=u.getBoundingClientRect(),t=window.getComputedStyle(u),n=parseInt(t.paddingBottom,10)||0,a=parseInt(t.borderBottomWidth,10)||0;g=e.height-n-a+11}const h=12,m=Math.max(h,Math.min(g,c));t=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:x,transform:"rotate(45deg)",transformOrigin:"center",top:m-6+"px",borderRight:""+(n.isSunday?`1px solid ${D}`:"none"),borderTop:""+(n.isSunday?`1px solid ${D}`:"none"),borderLeft:""+(n.isSunday?"none":`1px solid ${D}`),borderBottom:""+(n.isSunday?"none":`1px solid ${D}`)},n.isSunday?{right:"-6px"}:{left:"-6px"})}}return t})(),T=ye("div",{ref:a,className:`${xn} p-4`,"data-event-detail-panel":"true","data-event-id":e.id,style:{top:`${n.top}px`,left:`${n.left}px`,zIndex:9999,pointerEvents:"auto"},children:[ye("div",{style:k}),ye("span",{className:"block text-xs text-gray-600 dark:text-gray-300 mb-1",children:p("eventTitle")}),ye("div",{className:"flex items-center justify-between gap-3 mb-3",children:[ye("div",{className:"flex-1",children:ye("input",{id:`event-title-${e.id}`,name:"title",type:"text",value:e.title,readOnly:!b,disabled:!b,onChange:t=>{c(Object.assign(Object.assign({},e),{title:t.target.value}))},className:"w-full border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-1.5 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary transition"})}),b&&ye(Fn,{options:w,value:e.calendarId||"blue",onChange:t=>{c(Object.assign(Object.assign({},e),{calendarId:t}))},registry:null==h?void 0:h.getCalendarRegistry()})]}),ye("div",l?{className:"mb-3",children:[ye("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-1",children:p("dateRange")}),ye(Kn,{value:[e.start,e.end],format:"YYYY-MM-DD",showTime:!1,timeZone:C,matchTriggerWidth:!0,disabled:!b,onChange:E,onOk:E,locale:null==h?void 0:h.state.locale})]}:{className:"mb-3",children:[ye("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-1",children:p("timeRange")}),ye(Kn,{value:[e.start,e.end],timeZone:C,disabled:!b,onChange:t=>{const[n,a]=t;c(Object.assign(Object.assign({},e),{start:n,end:a}))},onOk:t=>{const[n,a]=t;c(Object.assign(Object.assign({},e),{start:n,end:a}))},locale:null==h?void 0:h.state.locale})]}),ye("div",{className:"mb-3",children:[ye("span",{className:"block text-xs text-gray-600 dark:text-gray-300 mb-1",children:p("note")}),ye("textarea",{id:`event-note-${e.id}`,name:"note",value:null!==(m=e.description)&&void 0!==m?m:"",readOnly:!b,disabled:!b,onChange:t=>c(Object.assign(Object.assign({},e),{description:t.target.value})),rows:3,className:"w-full border border-slate-200 dark:border-gray-600 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100 dark:bg-gray-700 shadow-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary transition resize-none",placeholder:p("addNotePlaceholder")})]}),b&&ye("div",{className:"flex space-x-2",children:[ye("button",l?{className:"px-2 py-1 bg-primary text-primary-foreground rounded hover:bg-primary text-xs font-medium transition",onClick:()=>{const n=S(e.start)?e.start:e.start.toPlainDate(),a=t.Temporal.ZonedDateTime.from({year:n.year,month:n.month,day:n.day,hour:9,minute:0,timeZone:t.Temporal.Now.timeZoneId()}),r=t.Temporal.ZonedDateTime.from({year:n.year,month:n.month,day:n.day,hour:10,minute:0,timeZone:t.Temporal.Now.timeZoneId()});c(Object.assign(Object.assign({},e),{allDay:!1,start:a,end:r}))},children:p("setAsTimed")}:{className:"px-2 py-1 bg-primary text-primary-foreground rounded hover:bg-primary text-xs font-medium transition",onClick:()=>{const t=S(e.start)?e.start:e.start.toPlainDate();c(Object.assign(Object.assign({},e),{allDay:!0,start:t,end:t}))},children:p("setAsAllDay")}),ye("button",{className:"px-2 py-1 bg-destructive text-destructive-foreground rounded hover:bg-destructive/90 text-xs font-medium transition",onClick:()=>u(e.id),children:p("delete")})]})]});if("undefined"==typeof window||"undefined"==typeof document)return null;const N=document.body;return N?o.createPortal(T,N):null},ur=({event:e,position:t,panelRef:n,isAllDay:a,eventVisibility:r,calendarRef:l,selectedEventElementRef:i,onEventUpdate:s,onEventDelete:d,onClose:c,contentRenderer:u})=>{const{effectiveTheme:g}=aa(),h=Dt(g),m="dark"===h?"#1f2937":"white",v="dark"===h?"rgb(55, 65, 81)":"rgb(229, 231, 235)",f=(()=>{var e;let a={};if("sticky-top"===r){const n=null===(e=l.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(n){const e=n.getBoundingClientRect().top+3-t.top;a=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:m,transform:"rotate(45deg)",transformOrigin:"center",top:e-6+"px",borderRight:""+(t.isSunday?`1px solid ${v}`:"none"),borderTop:""+(t.isSunday?`1px solid ${v}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${v}`),borderBottom:""+(t.isSunday?"none":`1px solid ${v}`)},t.isSunday?{right:"-6px"}:{left:"-6px"})}}else if("sticky-bottom"===r){const e=n.current;let r=200;if(e){const t=e.getBoundingClientRect(),n=window.getComputedStyle(e),a=parseInt(n.paddingBottom,10)||0,o=parseInt(n.borderBottomWidth,10)||0;r=t.height-a-o-6+11}a={position:"absolute",width:"12px",height:"12px",backgroundColor:m,transform:"rotate(45deg)",transformOrigin:"center",top:`${r}px`,left:t.isSunday?void 0:"-6px",right:t.isSunday?"-6px":void 0,borderRight:""+(t.isSunday?`1px solid ${v}`:"none"),borderTop:""+(t.isSunday?`1px solid ${v}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${v}`),borderBottom:""+(t.isSunday?"none":`1px solid ${v}`)}}else if(t&&i.current&&l.current){const e=i.current.getBoundingClientRect(),r=l.current.querySelector(".calendar-content");if(r){const o=r.getBoundingClientRect(),l=Math.max(e.top,o.top),i=Math.min(e.bottom,o.bottom),s=Math.max(0,i-l);let d;d=s===e.height?e.top+e.height/2:s>0?l+s/2:e.top+e.height/2;const c=d-t.top,u=n.current;let g=228;if(u){const e=u.getBoundingClientRect(),t=window.getComputedStyle(u),n=parseInt(t.paddingBottom,10)||0,a=parseInt(t.borderBottomWidth,10)||0;g=e.height-n-a+11}const h=12,f=Math.max(h,Math.min(g,c));a=Object.assign({position:"absolute",width:"12px",height:"12px",backgroundColor:m,transform:"rotate(45deg)",transformOrigin:"center",top:f-6+"px",borderRight:""+(t.isSunday?`1px solid ${v}`:"none"),borderTop:""+(t.isSunday?`1px solid ${v}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${v}`),borderBottom:""+(t.isSunday?"none":`1px solid ${v}`)},t.isSunday?{right:"-6px"}:{left:"-6px"})}}return a})(),p=ye("div",{ref:n,className:`${xn} p-3`,"data-event-detail-panel":"true","data-event-id":e.id,style:{top:`${t.top}px`,left:`${t.left}px`,zIndex:9999,pointerEvents:"auto",backgroundColor:"dark"===h?"#1f2937":"#ffffff"},children:[ye("div",{style:f}),ye(u,{event:e,isAllDay:a,onEventUpdate:s,onEventDelete:d,onClose:c})]});return o.createPortal(p,document.body)},gr=({event:e,app:t,isEventSelected:n,hideTime:a,isMobile:r})=>{const o=`${Math.floor(j(e.start)).toString().padStart(2,"0")}:${Math.round(j(e.start)%1*60).toString().padStart(2,"0")}`;return ye("div",{className:"text-xs cursor-pointer flex items-center justify-between",children:[ye("div",{className:"flex items-center flex-1 min-w-0",children:[ye("div",{style:{backgroundColor:B(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())},className:mn}),ye("span",{className:`whitespace-nowrap overflow-hidden block ${r?"mobile-mask-fade":"truncate"} ${n?"text-white":""}`,children:e.title})]}),!a&&!r&&ye("span",{className:`${Tn} ml-1 shrink-0 ${n?"text-white":""}`,style:n?void 0:{opacity:.8},children:o})]})},hr=({event:e,isEventSelected:t})=>{const n=!1!==e.icon,a="boolean"!=typeof e.icon?e.icon:null;return ye("div",{className:"text-xs px-1 rounded truncate cursor-pointer flex items-center",children:[n&&(a?ye("div",{className:`${Mn} shrink-0`,children:a}):e.title.toLowerCase().includes("easter")||e.title.toLowerCase().includes("holiday")?ye("span",{className:`inline-block ${Mn} shrink-0 ${t?"text-yellow-200":"text-yellow-600"}`,children:"⭐"}):ye(Me,{className:`${vn} ${t?"text-white":""}`})),ye("span",{className:"truncate "+(t?"text-white":""),children:e.title})]})},mr=({event:e,isEditable:t,onResizeStart:n})=>{const a=!1!==e.icon,r="boolean"!=typeof e.icon?e.icon:null;return ye("div",{className:"h-full flex items-center overflow-hidden pl-3 px-1 py-0 relative group",children:[n&&t&&ye("div",{className:"resize-handle absolute left-0 top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20",onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),n(t,e,"left")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}),a&&(r?ye("div",{className:"mr-1 shrink-0",children:r}):ye(Me,{className:vn})),ye("div",{className:`${gn} pr-1`,style:{lineHeight:"1.2"},children:e.title}),n&&t&&ye("div",{className:fn,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),n(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]})},vr=({event:e,app:t,multiDaySegmentInfo:a,isEditable:r,isTouchEnabled:o,isEventSelected:l,onResizeStart:i})=>{const s=a?a.startHour:j(e.start),d=a?a.endHour:X(e),c=d-s,u=!a||a.isFirst,g=!a||a.isLast,h=e.calendarId||"blue";return ye(n.Fragment,{children:[ye("div",{className:hn,style:{backgroundColor:B(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())}}),ye("div",{className:"h-full flex flex-col overflow-hidden pl-3 "+(X(e)-j(e.start)<=.25?"px-1 py-0":"p-1"),children:[ye("div",{className:`${gn} pr-1`,style:{lineHeight:c<=.25?"1.2":"normal"},children:e.title}),c>.5&&ye("div",{className:"df-event-time text-xs opacity-80 truncate",children:a?`${Z(s)} - ${Z(d)}`:q(e)})]}),i&&r&&ye(n.Fragment,{children:[u&&ye("div",{className:"absolute top-0 left-0 w-full h-1.5 cursor-ns-resize z-10 rounded-t-sm",onMouseDown:t=>i(t,e,"top")}),g&&ye("div",{className:"absolute bottom-0 left-0 w-full h-1.5 cursor-ns-resize z-10 rounded-b-sm",onMouseDown:t=>i(t,e,"bottom")}),!u&&g&&a&&ye("div",{className:fn,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),i(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]}),o&&l&&i&&r&&ye(n.Fragment,{children:[ye("div",{className:"absolute -top-1.5 right-5 w-2.5 h-2.5 bg-white border-2 rounded-full z-50",style:{borderColor:B(h,null==t?void 0:t.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),i(t,e,"top")}}),ye("div",{className:"absolute -bottom-1.5 left-5 w-2.5 h-2.5 bg-white border-2 rounded-full z-50",style:{borderColor:B(h,null==t?void 0:t.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),i(t,e,"bottom")}})]})]})},fr=(e,t,n,a,r)=>{let o="df-event calendar-event select-none pointer-events-auto px-0.5";t?o+=" df-day-event flex flex-col":e||(o+=" df-week-event flex flex-col");const l=()=>{if(a&&r){const{segmentType:e}=r;if("single"===e||"start"===e)return cn;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 cn};if(e){let e=`\n ${o}\n ${n?l():un}\n `;return a||(e+=" mb-[2px]"),e}return`\n ${o}\n shadow-sm\n ${n?l():un}\n `},pr=({event:e,layout:t,isAllDay:a=!1,allDayHeight:l=28,calendarRef:i,isBeingDragged:s=!1,isBeingResized:d=!1,isDayView:c=!1,isMonthView:u=!1,isMultiDay:g=!1,segment:h,segmentIndex:m=0,hourHeight:v,firstHour:f,selectedEventId:p,detailPanelEventId:y,onMoveStart:b,onResizeStart:x,onEventUpdate:D,onEventDelete:w,newlyCreatedEventId:C,onDetailPanelOpen:E,onEventSelect:k,onEventLongPress:T,onDetailPanelToggle:S,customDetailPanelContent:N,customEventDetailDialog:M,multiDaySegmentInfo:I,app:H,isMobile:R=!1,enableTouch:O,hideTime:P})=>{const A=r.useContext(fe),L=null!=O?O:R,[$,Y]=r.useState(null),[z,F]=r.useState(!1),[B,U]=r.useState(null),Z=r.useRef(null),q=r.useRef(null),K=r.useRef(null),G=r.useRef(null),J=g&&h?`${e.id}::${h.id}`:void 0!==(null==I?void 0:I.dayIndex)?`${e.id}::day-${I.dayIndex}`:e.id,Q=y===J,ee=null==H?void 0:H.getReadOnlyConfig(),te=!(null==H?void 0:H.state.readOnly),ne=!1!==(null==ee?void 0:ee.viewable),ae=!1!==(null==ee?void 0:ee.draggable),{isSelected:re,setIsSelected:oe,isPressed:le,setIsPressed:ie,handleTouchStart:se,handleTouchMove:de,handleTouchEnd:ce}=(({event:e,isTouchEnabled:t,onMoveStart:n,onEventLongPress:a,onEventSelect:o,onDetailPanelToggle:l,canOpenDetail:i,app:s,multiDaySegmentInfo:d,isMultiDay:c,segment:u,detailPanelKey:g})=>{const[h,m]=r.useState(!1),[v,f]=r.useState(!1),p=r.useRef(null),y=r.useRef(null);return{isSelected:h,setIsSelected:m,isPressed:v,setIsPressed:f,handleTouchStart:r=>{if(!n||!t)return;r.stopPropagation(),f(!0);const o=r.touches[0],l=o.clientX,i=o.clientY,s=r.currentTarget;y.current={x:l,y:i},p.current=setTimeout(()=>{var t;a?a(e.id):m(!0);const r={preventDefault:()=>{},stopPropagation:()=>{},currentTarget:s,touches:[{clientX:l,clientY:i}],cancelable:!1};if(d){const a=Object.assign(Object.assign({},e),{day:null!==(t=d.dayIndex)&&void 0!==t?t:e.day,_segmentInfo:d});n(r,a)}else if(c&&u){const t=Object.assign(Object.assign({},e),{day:u.startDayIndex,_segmentInfo:{dayIndex:u.startDayIndex,isFirst:u.isFirstSegment,isLast:u.isLastSegment}});n(r,t)}else n(r,e);p.current=null,y.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},handleTouchMove:e=>{if(p.current&&y.current){const t=Math.abs(e.touches[0].clientX-y.current.x),n=Math.abs(e.touches[0].clientY-y.current.y);(t>10||n>10)&&(clearTimeout(p.current),p.current=null,y.current=null,f(!1))}},handleTouchEnd:n=>{f(!1),p.current&&(clearTimeout(p.current),p.current=null),t&&y.current&&(n.preventDefault(),n.stopPropagation(),o?o(e.id):i&&m(!0),s&&s.onEventClick(e),null==l||l(null)),y.current=null}}})({event:e,isTouchEnabled:L,onMoveStart:b,onEventLongPress:T,onEventSelect:k,onDetailPanelToggle:S,canOpenDetail:ne,app:H,multiDaySegmentInfo:I,isMultiDay:g,segment:h,detailPanelKey:J}),ue=(void 0!==p?p===e.id:re)||le||s,[ge,he]=r.useState("visible"),me=e=>{G.current=e},ve=()=>((e,t,n,a,r,o)=>{var l;if(null!==a)return a;if(t===n){const e=n.split("::"),t=e[e.length-1];if(t.startsWith("day-")){const e=Number(t.replace("day-",""));if(!Number.isNaN(e))return e}}return void 0!==(null==r?void 0:r.dayIndex)?r.dayIndex:o?o.startDayIndex:null!==(l=e.day)&&void 0!==l?l:0})(e,y||void 0,J,G.current,I,h),pe=e=>((e,t,n,a,r)=>{if(!t.current)return null;const o=t.current.getBoundingClientRect();if(n){const t=o.width/7,n=e-o.left,a=Math.floor(n/t);return Number.isFinite(a)?Math.max(0,Math.min(6,a)):null}const l=r?48:80,i=a?1:7,s=(o.width-l)/i,d=e-o.left-l,c=Math.floor(d/s);return Number.isFinite(c)?Math.max(0,Math.min(i-1,c)):null})(e,i,u,c,R),be=e=>((e,t,n,a,r)=>{if(!t.current)return null;const o=t.current.getBoundingClientRect();if(n){const t=o.width/7;return{left:o.left+e*t,width:t}}const l=r?48:80;if(a){const e=o.width-l;return{left:o.left+l,width:e}}const i=(o.width-l)/7;return{left:o.left+l+e*i,width:i}})(e,i,u,c,R),xe=r.useCallback(()=>{if(!K.current||!i.current||!q.current)return;const t=i.current.getBoundingClientRect(),n=ve(),a=be(n);let r,o;if(a)r=a.left,o=a.width;else if(u)o=t.width/7,r=t.left+n*o;else{const e=R?48:80;o=(t.width-e)/7,r=t.left+e+n*o}const l=Math.min(window.innerWidth,t.right),s=Math.min(window.innerHeight,t.bottom);requestAnimationFrame(()=>{var a,o,d,m;if(!q.current)return;if(!K.current)return;const p=q.current.getBoundingClientRect(),y=p.width,b=p.height;let x,D,w;if("sticky-top"===ge||"sticky-bottom"===ge){const t=null===(a=i.current)||void 0===a?void 0:a.querySelector(".calendar-content");if(!t)return;const n=I?I.startHour:j(e.start),r=I?I.endHour:X(e),l=(n-f)*v,s=Math.max((r-n)*v,v/4),d=t.getBoundingClientRect(),c=t.scrollTop,u=d.top+l-c,g=null===(o=Z.current)||void 0===o?void 0:o.getBoundingClientRect();if(!g)return;w={top:u,bottom:u+s,left:g.left,right:g.right,width:g.width,height:s,x:g.x,y:u,toJSON:()=>({})}}else w=K.current.getBoundingClientRect();if(u&&g&&h){const e=be(n),a=null!==(d=null==e?void 0:e.width)&&void 0!==d?d:t.width/7,r=null!==(m=null==e?void 0:e.left)&&void 0!==m?m:t.left+n*a,o=r+a;w={top:w.top,bottom:w.bottom,left:r,right:o,width:o-r,height:w.height,x:r,y:w.top,toJSON:()=>({})}}if(("sticky-top"===ge||"sticky-bottom"===ge)&&!u){const e=ve(),n=be(e),a=R?48:80,r=n?n.left:t.left+a+e*(t.width-a)/(c?1:7),o=n?n.width:(t.width-a)/(c?1:7),l=Math.max(0,c?w.width:o-3),i=c?w.left:r;w=Object.assign(Object.assign({},w),{left:i,right:i+l,width:l})}const C=l-w.right,E=w.left-t.left;x=C>=y+20?w.right+10:E>=y+20?w.left-y-10:C>E?Math.max(t.left+10,l-y-10):t.left+10;const k=w.top-b/2+w.height/2,T=Math.max(10,t.top+10),S=s-10;D=k<T?T:k+b>S?S-b:k,U(e=>e?Object.assign(Object.assign({},e),{top:D,left:x,isSunday:x<r}):null)})},[i,e.day,e.start,e.end,ge,u,f,v,g,h,I,y,J,R,c]);(({event:e,isEventSelected:t,showDetailPanel:n,eventRef:a,calendarRef:o,isAllDay:l,isMonthView:i,multiDaySegmentInfo:s,firstHour:d,hourHeight:c,updatePanelPosition:u,setEventVisibility:g})=>{const h=r.useCallback(()=>{if(!t||!n||!a.current||!o.current||l||i)return;const r=o.current.querySelector(".calendar-content");if(!r)return;const h=s?s.startHour:j(e.start),m=s?s.endHour:X(e),v=(h-d)*c,f=v+Math.max((m-h)*c,c/4),p=r.getBoundingClientRect(),y=r.scrollTop;let b=f<y+6,x=v>y+p.height-6;const D=p.bottom<0,w=p.top>window.innerHeight;D?b=!0:w&&(x=!0),g(b?"sticky-top":x?"sticky-bottom":"visible"),u()},[t,n,o,l,i,e.start,e.end,d,c,u,s]);r.useEffect(()=>{var e,a;if(!t||!n||l)return;const r=null===(e=o.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(!r)return;const i=()=>h(),s=()=>{h(),u()},d=[r];let c=null===(a=o.current)||void 0===a?void 0:a.parentElement;for(;c;){const e=window.getComputedStyle(c);"auto"!==e.overflowY&&"scroll"!==e.overflowY&&"auto"!==e.overflowX&&"scroll"!==e.overflowX||d.push(c),c=c.parentElement}d.forEach(e=>{e.addEventListener("scroll",i)}),window.addEventListener("scroll",i,!0),window.addEventListener("resize",s);let g=null;return o.current&&(g=new ResizeObserver(()=>{s()}),g.observe(o.current)),h(),()=>{d.forEach(e=>{e.removeEventListener("scroll",i)}),window.removeEventListener("scroll",i,!0),window.removeEventListener("resize",s),g&&g.disconnect()}},[t,n,l,h,u,o])})({event:e,isEventSelected:ue,showDetailPanel:Q,eventRef:Z,calendarRef:i,isAllDay:a,isMonthView:u,multiDaySegmentInfo:I,firstHour:f,hourHeight:v,updatePanelPosition:xe,setEventVisibility:he}),(({eventRef:e,detailPanelRef:t,eventId:n,isEventSelected:a,showDetailPanel:o,onEventSelect:l,onDetailPanelToggle:i,setIsSelected:s,setActiveDayIndex:d})=>{r.useEffect(()=>{if(!a&&!o)return;const r=r=>{var c,u;const g=r.target,h=null===(c=e.current)||void 0===c?void 0:c.contains(g),m=null!==g.closest(`[data-event-id="${n}"]`),v=null===(u=t.current)||void 0===u?void 0:u.contains(g),f=g.closest("[data-event-detail-dialog]"),p=g.closest("[data-range-picker-popup]"),y=g.closest("[data-calendar-picker-dropdown]");o?h||m||v||f||p||y||(null==l||l(null),d(null),s(!1),null==i||i(null)):!a||h||m||f||p||y||(null==l||l(null),d(null),s(!1),null==i||i(null))};return document.addEventListener("mousedown",r),()=>{document.removeEventListener("mousedown",r)}},[a,o,l,i,n])})({eventRef:Z,detailPanelRef:q,eventId:e.id,isEventSelected:ue,showDetailPanel:Q,onEventSelect:k,onDetailPanelToggle:S,setIsSelected:oe,setActiveDayIndex:me}),r.useEffect(()=>{!Q||B||R||(U({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>xe()))},[Q,B,xe,R]);const De=e.calendarId||"blue",we=null==H?void 0:H.getCalendarRegistry();return ye(n.Fragment,{children:[ye("div",{ref:Z,"data-event-id":e.id,className:fr(u,c,a,g,h),style:Object.assign(Object.assign({},(()=>{var n,r,o,s,d,p,y,b;if(u)return{opacity:1,zIndex:ue||Q?1e3:1,transform:z?"scale(1.15)":void 0,transition:"transform 0.1s ease-in-out",cursor:ae||ne?"pointer":"default"};if(a){const e={height:l-4+"px",opacity:1,zIndex:ue||Q?1e3:1,transform:z?"scale(1.12)":void 0,transition:"transform 0.1s ease-in-out",cursor:ae||ne?"pointer":"default"},t=m*l;if(Object.assign(e,{top:`${t}px`}),c)Object.assign(e,{width:"100%",left:"0px",right:"2px",position:"absolute"});else if(g&&h){const t=(h.endDayIndex-h.startDayIndex+1)/7*100,n=h.startDayIndex/7*100,a=2,r=h.isFirstSegment?a:0,o=r+(h.isLastSegment?a:0);Object.assign(e,{width:o>0?`calc(${t}% - ${o}px)`:`${t}%`,left:r>0?`calc(${n}% + ${r}px)`:`${n}%`,position:"absolute",pointerEvents:"auto"})}else Object.assign(e,{width:"100%",left:"0px",position:"relative"});return e}const x=I?I.startHour:j(e.start),D=I?I.endHour:X(e),w={top:`${(x-f)*v+3}px`,height:Math.max((D-x)*v,v/4)-4+"px",position:"absolute",opacity:1,zIndex:ue||Q?1e3:null!==(n=null==t?void 0:t.zIndex)&&void 0!==n?n:1,transform:z?"scale(1.12)":void 0,transition:"transform 0.1s ease-in-out",cursor:ae||ne?"pointer":"default"};if(ue&&Q&&("sticky-top"===ge||"sticky-bottom"===ge)){const e=null===(r=i.current)||void 0===r?void 0:r.getBoundingClientRect();if(e){const n=ve(),a=R?48:80,r=c?1:7;let l=(e.width-a)/r,g=e.left+a+(c?0:n*l);u&&(l=e.width/7,g=e.left+n*l);const h=be(n);h&&(g=h.left,l=h.width);let m=null===(o=i.current)||void 0===o?void 0:o.querySelector(".calendar-content");m||(m=null===(s=i.current)||void 0===s?void 0:s.querySelector(".calendar-renderer"));const v=null==m?void 0:m.getBoundingClientRect(),f=null===(p=null===(d=Z.current)||void 0===d?void 0:d.parentElement)||void 0===p?void 0:p.getBoundingClientRect();let x,D;if(f&&f.width>0)t?(x=f.left+t.left/100*f.width,D=c?t.width/100*f.width:(t.width-1)/100*f.width):(x=f.left,D=c?f.width:f.width-3);else{const e=be(n),a=null!==(y=null==e?void 0:e.left)&&void 0!==y?y:g,r=null!==(b=null==e?void 0:e.width)&&void 0!==b?b:l;x=a,D=r-3,t&&(x=a+t.left/100*r,D=c?t.width/100*r:(t.width-1)/100*r)}if("sticky-top"===ge){let t=v?v.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:`${x}px`,width:`${D}px`,height:"6px",zIndex:1e3,overflow:"hidden"}}let w=v?v.bottom:e.bottom;return w=Math.min(w,window.innerHeight),w=Math.min(w,e.bottom),w=Math.max(w,e.top+6),w=Math.max(w,6),{position:"fixed",top:w-6+"px",left:`${x}px`,width:`${D}px`,height:"6px",zIndex:1e3,overflow:"hidden"}}}if(t&&!a){const e=c?`${t.width}%`:t.width-1+"%";return Object.assign(Object.assign({},w),{left:`${t.left}%`,width:e,right:"auto"})}return Object.assign(Object.assign({},w),{left:"0px",right:c?"0px":"3px"})})()),{backgroundColor:ue?W(De,we):V(De,we),color:ue?"#fff":_(De,we)}),onClick:L?void 0:t=>{var n,a,r;if(t.preventDefault(),t.stopPropagation(),g){const r=pe(t.clientX);me(null!==r?h?Math.min(Math.max(r,h.startDayIndex),h.endDayIndex):r:null!==(a=null!==(n=null==I?void 0:I.dayIndex)&&void 0!==n?n:e.day)&&void 0!==a?a:null)}else me(null!==(r=e.day)&&void 0!==r?r:null);H&&H.onEventClick(e),k?k(e.id):ne&&oe(!0),null==S||S(null),U(null)},onContextMenu:L?void 0:t=>{t.preventDefault(),t.stopPropagation(),k&&k(e.id),Y({x:t.clientX,y:t.clientY})},onDblClick:L?void 0:t=>{var n,r,o,l,s;if(!ne)return;t.preventDefault(),t.stopPropagation();let d=t.currentTarget;if(g){const e=d.querySelector("div");e&&(d=e)}if(K.current=d,g){const a=pe(t.clientX);me(null!==a?Math.min(Math.max(a,null!==(n=null==h?void 0:h.startDayIndex)&&void 0!==n?n:0),null!==(r=null==h?void 0:h.endDayIndex)&&void 0!==r?r:6):null!==(l=null!==(o=null==h?void 0:h.startDayIndex)&&void 0!==o?o:e.day)&&void 0!==l?l:0)}else me(null!==(s=e.day)&&void 0!==s?s:null);new Promise(t=>{if(!i.current||a||u)return void t();const n=i.current.querySelector(".calendar-content");if(!n)return void t();const r=I?I.startHour:j(e.start),o=I?I.endHour:X(e),l=(r-f)*v,s=l+Math.max((o-r)*v,v/4),d=n.scrollTop,c=n.clientHeight;if(l>=d&&s<=d+c)return void t();const g=((r+o)/2-f)*v-c/2,h=n.scrollHeight-c;n.scrollTo({top:Math.max(0,Math.min(h,g)),behavior:"smooth"}),setTimeout(()=>t(),300)}).then(()=>{oe(!0),R||(null==S||S(J),U({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>xe()))})},onMouseDown:t=>{var n;L||ie(!0),b&&b(t,I?Object.assign(Object.assign({},e),{day:null!==(n=I.dayIndex)&&void 0!==n?n:e.day,_segmentInfo:I}):g&&h?Object.assign(Object.assign({},e),{day:h.startDayIndex,_segmentInfo:{dayIndex:h.startDayIndex,isFirst:h.isFirstSegment,isLast:h.isLastSegment}}):e)},onMouseUp:()=>!L&&ie(!1),onMouseLeave:()=>!L&&ie(!1),onTouchStart:se,onTouchMove:de,onTouchEnd:ce,children:(()=>{let n;return n=u?g&&h?ye(dr,{segment:h,segmentIndex:null!=m?m:0,isDragging:s||ue,isResizing:d,isSelected:ue,onMoveStart:b||(()=>{}),onResizeStart:x,isMobile:R,isDraggable:ae,isEditable:te,viewable:ne}):e.allDay?ye(hr,{event:e,isEventSelected:ue}):ye(gr,{event:e,app:H,isEventSelected:ue,hideTime:P,isMobile:R}):e.allDay?ye(mr,{event:e,isEditable:te,onResizeStart:x}):ye(vr,{event:e,app:H,multiDaySegmentInfo:I,isEditable:te,isTouchEnabled:L,isEventSelected:ue,onResizeStart:x}),ye(qt,{store:A,generatorName:"eventContent",generatorArgs:{event:e,isAllDay:a,isMobile:R,isMonthView:u,segment:h,layout:t},defaultContent:n})})()}),Q&&ye("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:9998,pointerEvents:"none"}}),(()=>{if(!Q)return null;const t=()=>{k&&k(null),me(null),oe(!1),null==S||S(null)};if(M){const n=M,r={event:e,isOpen:Q,isAllDay:a,onEventUpdate:D,onEventDelete:w,onClose:t,app:H},l="undefined"!=typeof document?document.body:null;return l?ye(qt,{store:A,generatorName:"eventDetailDialog",generatorArgs:r,defaultContent:o.createPortal(ye(n,Object.assign({},r)),l)}):null}if(!B)return null;const n={event:e,position:B,panelRef:q,isAllDay:a,eventVisibility:ge,calendarRef:i,selectedEventElementRef:K,onEventUpdate:D,onEventDelete:w,onClose:t};return ye(qt,{store:A,generatorName:"eventDetailContent",generatorArgs:{event:e,position:B,onClose:t},defaultContent:N?ye(ur,Object.assign({},n,{contentRenderer:N})):ye(cr,Object.assign({},n,{app:H}))})})(),$&&H&&ye(Bt,{event:e,x:$.x,y:$.y,onClose:()=>Y(null),app:H,onDetailPanelToggle:S,detailPanelKey:J})]})},yr=({app:e,currentDate:t,currentWeekStart:n,events:a,currentDayEvents:o,organizedAllDayEvents:l,allDayAreaHeight:i,timeSlots:s,eventLayouts:d,isToday:c,currentTime:u,selectedEventId:g,setSelectedEventId:h,newlyCreatedEventId:m,setNewlyCreatedEventId:v,detailPanelEventId:p,setDetailPanelEventId:y,dragState:b,isDragging:x,handleMoveStart:D,handleResizeStart:w,handleCreateStart:C,handleCreateAllDayEvent:E,handleTouchStart:k,handleTouchEnd:T,handleTouchMove:S,handleDragOver:N,handleDrop:M,handleEventUpdate:I,handleEventDelete:H,onDateChange:R,customDetailPanelContent:O,customEventDetailDialog:P,calendarRef:A,allDayRowRef:L,switcherMode:$,isMobile:j,isTouch:Y,setDraftEvent:z,setIsDrawerOpen:F,ALL_DAY_HEIGHT:V,HOUR_HEIGHT:_,FIRST_HOUR:W,LAST_HOUR:B,showAllDay:U,showStartOfDayLabel:q})=>{const{t:K,locale:X}=Ue(),G=r.useRef(e.state.highlightedEventId),[J,Q]=r.useState(null),ee=f(),te=()=>{var e;const t=null===(e=A.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(!t)return 0;const n=t.querySelector(".df-time-grid-row");return n?n.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop:0},ne=(e,n)=>{var a,r,o,l;if(e.preventDefault(),j)return;const i=new Date(t);if(n)i.setHours(0,0,0,0);else{const t=null===(r=null===(a=A.current)||void 0===a?void 0:a.querySelector(".calendar-content"))||void 0===r?void 0:r.getBoundingClientRect();if(t){const n=(null===(l=null===(o=A.current)||void 0===o?void 0:o.querySelector(".calendar-content"))||void 0===l?void 0:l.scrollTop)||0,a=te(),r=(e.clientY-t.top+n-a)/_+W,s=Math.floor(r),d=Math.floor(60*(r-s)),c=15*Math.round(d/15),u=60===c?s+1:s,g=60===c?0:c;i.setHours(u,g,0,0)}}Q({x:e.clientX,y:e.clientY,date:i})};return ye("div",{className:`flex-none ${"buttons"===$?"":"md:w-[60%]"} w-full md:w-[70%] bg-white dark:bg-gray-900 border-r border-gray-200 dark:border-gray-700`,onContextMenu:e=>e.preventDefault(),children:[ye("div",{className:`relative ${Nn} h-full`,children:[ye("div",{onContextMenu:e=>e.preventDefault(),style:{paddingRight:j||!ee?"0px":"15px"},children:ye(or,{calendar:e,viewType:exports.ViewType.DAY,currentDate:t,customSubtitle:t.toLocaleDateString(X,{weekday:"long"})})}),ye("div",U?{className:In(dn,"border-t border-gray-200 dark:border-gray-700 items-stretch"),ref:L,style:{paddingRight:j||!ee?"0px":"0.6875rem"},onContextMenu:e=>ne(e,!0),children:[ye("div",{className:"df-all-day-label flex-shrink-0 p-1 text-xs font-medium text-gray-500 dark:text-gray-400 flex justify-end select-none w-12 text-[10px] md:w-20 md:text-xs flex items-center",onContextMenu:e=>e.preventDefault(),children:K("allDay")}),ye("div",{className:In("flex flex-1 relative self-stretch",!j&&ee?"border-r border-gray-200 dark:border-gray-700":""),children:ye("div",{className:"w-full relative",style:{minHeight:`${i}px`},onClick:()=>null==R?void 0:R(t),onMouseDown:e=>{const a=Math.floor((t.getTime()-n.getTime())/864e5);null==E||E(e,a)},onDblClick:e=>{const a=Math.floor((t.getTime()-n.getTime())/864e5);null==E||E(e,a)},onDragOver:N,onDrop:e=>{M(e,t,void 0,!0)},children:l.map(t=>ye(pr,{event:t,isAllDay:!0,isDayView:!0,segmentIndex:t.row,allDayHeight:V,calendarRef:A,isBeingDragged:x&&(null==b?void 0:b.eventId)===t.id&&"move"===(null==b?void 0:b.mode),hourHeight:_,firstHour:W,onMoveStart:D,onEventUpdate:I,onEventDelete:H,newlyCreatedEventId:m,onDetailPanelOpen:()=>v(null),detailPanelEventId:p,onDetailPanelToggle:e=>y(e),selectedEventId:g,onEventSelect:t=>{const n=!1!==e.getReadOnlyConfig().viewable,r=e.state.readOnly,o=a.find(e=>e.id===t);(j||Y)&&o&&n&&!r?(z(o),F(!0)):(h(t),e.state.highlightedEventId&&(e.highlightEvent(null),G.current=null))},onEventLongPress:e=>{(j||Y)&&h(e)},customDetailPanelContent:O,customEventDetailDialog:P,app:e,isMobile:j,enableTouch:Y},t.id))})})]}:{className:In("border-b border-gray-200 dark:border-gray-700",!j&&ee?"pr-2.75":"")}),ye("div",{className:"relative overflow-y-auto calendar-content df-day-time-grid",style:{position:"relative",scrollbarGutter:"stable"},children:ye("div",{className:"relative flex",children:[c&&u&&(()=>{const e=u,t=e.getHours()+e.getMinutes()/60;if(t<W||t>B)return null;return ye("div",{className:ln,style:{top:`${(t-W)*_}px`,width:"100%",height:0,zIndex:20,marginTop:"0.75rem"},children:[ye("div",{className:"flex items-center w-12 md:w-20",children:[ye("div",{className:"relative w-full flex items-center"}),ye("div",{className:sn,children:Z(t)})]}),ye("div",{className:"flex-1 flex items-center",children:ye("div",{className:"df-current-time-bar h-0.5 w-full bg-primary relative"})})]})})(),ye("div",{className:"df-time-column flex-shrink-0 border-gray-200 dark:border-gray-700 w-12 md:w-20",onContextMenu:e=>e.preventDefault(),children:[ye("div",{className:"h-3"}),s.map((e,t)=>ye("div",{className:an,children:ye("div",{className:`${rn} text-[10px] md:text-[12px]`,children:q&&0===t?"":e.label})},t))]}),ye("div",{className:"grow select-none",children:[ye("div",{className:In(Dn,!j&&ee?"border-r":"","border-t-0"),children:ye("div",{className:`${wn} -left-9.5`,style:{top:"auto",bottom:"-0.625rem"},children:q?Z(W):""})}),ye("div",{className:"relative",style:{WebkitTouchCallout:"none"},children:[s.map((e,a)=>ye("div",{className:In(on,!j&&ee?"border-r":""),onClick:()=>null==R?void 0:R(t),onDblClick:e=>{var a,r,o,l;const i=Math.floor((t.getTime()-n.getTime())/864e5),s=null===(r=null===(a=A.current)||void 0===a?void 0:a.querySelector(".calendar-content"))||void 0===r?void 0:r.getBoundingClientRect();if(!s)return;const d=(null===(l=null===(o=A.current)||void 0===o?void 0:o.querySelector(".calendar-content"))||void 0===l?void 0:l.scrollTop)||0,c=te(),u=e.clientY-s.top+d-c;null==C||C(e,i,W+u/_)},onTouchStart:e=>{const a=Math.floor((t.getTime()-n.getTime())/864e5);k(e,a)},onTouchEnd:T,onTouchMove:S,onDragOver:N,onDrop:e=>{var n,a,r,o;const l=null===(a=null===(n=A.current)||void 0===n?void 0:n.querySelector(".calendar-content"))||void 0===a?void 0:a.getBoundingClientRect();if(!l)return;const i=(null===(o=null===(r=A.current)||void 0===r?void 0:r.querySelector(".calendar-content"))||void 0===o?void 0:o.scrollTop)||0,s=te(),d=e.clientY-l.top+i-s,c=Math.floor(W+d/_);M(e,t,c)},onContextMenu:e=>ne(e,!1)},a)),ye("div",{className:In(Dn,!j&&ee?"border-r":""),children:ye("div",{className:`${wn} -left-9.5`,children:"00:00"})}),ye("div",{className:"absolute top-0 left-0 right-0 bottom-0 pointer-events-none",children:o.filter(e=>!e.allDay).map(t=>{const n=d.get(t.id);return ye(pr,{event:t,layout:n,isDayView:!0,calendarRef:A,isBeingDragged:x&&(null==b?void 0:b.eventId)===t.id&&"move"===(null==b?void 0:b.mode),hourHeight:_,firstHour:W,onMoveStart:D,onResizeStart:w,onEventUpdate:I,onEventDelete:H,newlyCreatedEventId:m,onDetailPanelOpen:()=>v(null),detailPanelEventId:p,onDetailPanelToggle:e=>y(e),selectedEventId:g,onEventSelect:t=>{const n=!1!==e.getReadOnlyConfig().viewable,r=a.find(e=>e.id===t);(j||Y)&&r&&n?(z(r),F(!0)):(h(t),e.state.highlightedEventId&&(e.highlightEvent(null),G.current=null))},onEventLongPress:e=>{(j||Y)&&h(e)},customDetailPanelContent:O,customEventDetailDialog:P,app:e,isMobile:j,enableTouch:Y},t.id)})})]})]})]})})]}),J&&ye(Wt,{x:J.x,y:J.y,date:J.date,viewType:exports.ViewType.DAY,onClose:()=>Q(null),app:e,onCreateEvent:()=>{if(C){const e=Math.floor((t.getTime()-n.getTime())/864e5);if(0===J.date.getHours()&&0===J.date.getMinutes())null==E||E({clientX:J.x,clientY:J.y},e);else{const t=J.date.getHours()+J.date.getMinutes()/60,n={preventDefault:()=>{},stopPropagation:()=>{},clientX:J.x,clientY:J.y};C(n,e,t)}}}})]})},br=e=>{const t=e.getDay(),n=e.getDate()-t+(0===t?-6:1),a=new Date(e);return a.setDate(n),a.setHours(0,0,0,0),a},xr=({app:e,config:t,customDetailPanelContent:n,customEventDetailDialog:a,calendarRef:o,switcherMode:l="buttons",selectedEventId:i,onEventSelect:s,onDateChange:d,detailPanelEventId:c,onDetailPanelToggle:u})=>{const g=e.getEvents(),{screenSize:h}=Qn(),m="desktop"!==h,[v,f]=r.useState(!1),{HOUR_HEIGHT:p=qa.HOUR_HEIGHT,FIRST_HOUR:y=qa.FIRST_HOUR,LAST_HOUR:b=qa.LAST_HOUR,ALL_DAY_HEIGHT:x=qa.ALL_DAY_HEIGHT,showAllDay:D=!0}=t,w=!D;r.useEffect(()=>{f("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const C=e.getCustomMobileEventRenderer()||ha,[E,k]=r.useState(null),[T,S]=r.useState(null),[M,I]=r.useState(null),R=void 0!==i?i:T,O=void 0!==c?c:M,P=r.useMemo(()=>R&&g.find(e=>e.id===R)||null,[R,g]),A=e=>{s?s(e):S(e)},[L,$]=r.useState(null),[Y,z]=r.useState(!1),[F,V]=r.useState(null),_=r.useRef(null),W=e.getCurrentDate();e.getVisibleMonth();const[B,U]=r.useState(W),q=r.useRef(W.getTime());W.getTime()!==q.current&&(q.current=W.getTime(),W.getFullYear()===B.getFullYear()&&W.getMonth()===B.getMonth()||U(W));const K=r.useCallback(t=>{U(n=>{const a=new Date(n.getFullYear(),n.getMonth()+t,1);return e.setVisibleMonth(a),a})},[e]),X=r.useRef(e.state.highlightedEventId);r.useEffect(()=>{var t;if(e.state.highlightedEventId!==X.current)if(e.state.highlightedEventId){A(e.state.highlightedEventId);const n=e.getEvents().find(t=>t.id===e.state.highlightedEventId);if(n&&!n.allDay){const e=j(n.start),a=null===(t=o.current)||void 0===t?void 0:t.querySelector(".calendar-content");if(a){const t=(e-y)*p;requestAnimationFrame(()=>{a.scrollTo({top:Math.max(0,t-100),behavior:"smooth"})})}}}else A(null);X.current=e.state.highlightedEventId},[e.state.highlightedEventId,y,p,o,e]);const G=r.useRef(null),J=r.useMemo(()=>br(W),[W]),Q=r.useMemo(()=>((e,t,n)=>{const a=new Date(t);a.setHours(0,0,0,0);const r=new Date(t);return r.setHours(23,59,59,999),e.filter(e=>{const t=H(e.start),n=H(e.end);if(e.allDay){const e=new Date(t);e.setHours(0,0,0,0);const o=new Date(n);return o.setHours(0,0,0,0),e<=r&&o>=a}return t<r&&n>a}).map(e=>{const t=H(e.start),a=Math.floor((t.getTime()-n.getTime())/864e5),r=Math.max(0,Math.min(6,a));return Object.assign(Object.assign({},e),{day:r})})})(g,W,J),[g,W,J]),ee=r.useMemo(()=>((e,t)=>{const n=new Date(t);n.setHours(0,0,0,0);const a=new Date(n);return a.setDate(a.getDate()+1),e.filter(e=>!e.allDay).map(e=>{const t=H(e.start),r=H(e.end);let o=e.start,l=e.end,i=!1;return t<n&&(o=N(n),i=!0),r>a&&(l=N(a),i=!0),Object.assign(Object.assign({},e),{start:i?o:e.start,end:i?l:e.end,day:0})})})(Q,W),[Q,W]),te=r.useMemo(()=>Za.calculateDayEventLayouts(ee,{viewType:"day"}),[ee]),ne=r.useMemo(()=>(e=>{const t=e.filter(e=>e.allDay);t.sort((e,t)=>{const n=H(e.start),a=H(t.start);if(n.getTime()!==a.getTime())return n.getTime()-a.getTime();const r=H(e.end);return H(t.end).getTime()-r.getTime()});const n=[],a=[];return t.forEach(e=>{let t=0,r=!1;for(;!r;)n[t]?n[t].some(t=>{const n=H(e.start),a=H(e.end),r=H(t.start);return n<=H(t.end)&&r<=a})?t++:(n[t].push(e),a.push(Object.assign(Object.assign({},e),{row:t})),r=!0):(n[t]=[e],a.push(Object.assign(Object.assign({},e),{row:t})),r=!0)}),a})(Q),[Q]),ae=r.useMemo(()=>{if(0===ne.length)return x;return(Math.max(...ne.map(e=>e.row))+1)*x},[ne,x]),{handleMoveStart:re,handleCreateStart:oe,handleResizeStart:le,handleCreateAllDayEvent:ie,dragState:se,isDragging:de}=tr(e,{calendarRef:o,allDayRowRef:D?G:void 0,viewType:exports.ViewType.DAY,onEventsUpdate:t=>{const n=t(Q),a=new Set(n.map(e=>e.id)),r=Q.filter(e=>!a.has(e.id)),o=new Set(Q.map(e=>e.id)),l=n.filter(e=>!o.has(e.id)),i=n.filter(e=>{if(!o.has(e.id))return!1;const t=Q.find(t=>t.id===e.id);return t&&(H(t.start).getTime()!==H(e.start).getTime()||H(t.end).getTime()!==H(e.end).getTime()||t.day!==e.day||j(t.start)!==j(e.start)||j(t.end)!==j(e.end)||t.title!==e.title)});e.applyEventsChanges({delete:r.map(e=>e.id),add:l,update:i.map(e=>({id:e.id,updates:e}))})},onEventCreate:t=>{m?(V(t),z(!0)):(e.addEvent(t),$(t.id))},onEventEdit:()=>{},currentWeekStart:J,events:Q,calculateNewEventLayout:(e,t,n)=>((e,t,n,a,r)=>{const o=new Date(a),l=new Date(a);o.setHours(Math.floor(t),t%1*60,0,0),l.setHours(Math.floor(n),n%1*60,0,0);const i=[...r,{id:"-1",title:"Temp",day:0,start:N(o),end:N(l),calendarId:"blue",allDay:!1}];return Za.calculateDayEventLayouts(i,{viewType:"day"}).get("-1")||null})(0,t,n,W,ee),calculateDragLayout:(e,t,n,a)=>((e,t,n,a,r,o)=>{const l=o.filter(t=>t.id!==e.id),i=new Date(r),s=new Date(i);s.setHours(Math.floor(n),n%1*60,0,0);const d=new Date(i);d.setHours(Math.floor(a),a%1*60,0,0);const c=[...l,Object.assign(Object.assign({},e),{start:N(s),end:N(d),day:0})];return 0===c.length?null:Za.calculateDayEventLayouts(c,{viewType:"day"}).get(e.id)||null})(e,0,n,a,W,ee),TIME_COLUMN_WIDTH:m?48:80,isMobile:m}),{handleDrop:ce,handleDragOver:ue}=nr({app:e,onEventCreated:e=>{$(e.id)}}),ge=Array.from({length:24},(e,t)=>({hour:t+y,label:Z(t+y)})),he=r.useCallback(t=>{const n=new Date(t.getFullYear(),t.getMonth(),t.getDate());e.setCurrentDate(n),U(new Date(n.getFullYear(),n.getMonth(),1))},[e]),me=r.useMemo(()=>{const e=new Date;e.setHours(0,0,0,0);const t=new Date(W);return t.setHours(0,0,0,0),t.getTime()===e.getTime()},[W]);return r.useEffect(()=>{k(new Date);const e=setInterval(()=>k(new Date),6e4);return()=>clearInterval(e)},[]),ye("div",{className:"df-day-view flex h-full bg-gray-50 dark:bg-gray-800",children:[ye(yr,{app:e,currentDate:W,currentWeekStart:J,events:g,currentDayEvents:Q,organizedAllDayEvents:ne,allDayAreaHeight:ae,timeSlots:ge,eventLayouts:te,isToday:me,currentTime:E,selectedEventId:R,setSelectedEventId:A,newlyCreatedEventId:L,setNewlyCreatedEventId:$,detailPanelEventId:O,setDetailPanelEventId:e=>{u?u(e):I(e)},dragState:se,isDragging:de,handleMoveStart:re,handleResizeStart:le,handleCreateStart:oe,handleCreateAllDayEvent:ie,handleTouchStart:(e,t)=>{if(!m&&!v)return;const n=e.touches[0],a=n.clientX,r=n.clientY,l=e.currentTarget;_.current=setTimeout(()=>{var e,n,i;const s=null===(n=null===(e=o.current)||void 0===e?void 0:e.querySelector(".calendar-content"))||void 0===n?void 0:n.getBoundingClientRect();if(!s)return;const d=null===(i=o.current)||void 0===i?void 0:i.querySelector(".calendar-content"),c=d?d.scrollTop:0,u=r-s.top+c;null==oe||oe({preventDefault:()=>{},stopPropagation:()=>{},touches:[{clientX:a,clientY:r}],changedTouches:[{clientX:a,clientY:r}],target:l,currentTarget:l,cancelable:!0},t,y+u/p)},500)},handleTouchEnd:()=>{_.current&&(clearTimeout(_.current),_.current=null)},handleTouchMove:()=>{_.current&&(clearTimeout(_.current),_.current=null)},handleDragOver:ue,handleDrop:ce,handleEventUpdate:t=>{e.updateEvent(t.id,t)},handleEventDelete:t=>{e.deleteEvent(t)},onDateChange:d,customDetailPanelContent:n,customEventDetailDialog:a,calendarRef:o,allDayRowRef:G,switcherMode:l,isMobile:m,isTouch:v,setDraftEvent:V,setIsDrawerOpen:z,ALL_DAY_HEIGHT:x,HOUR_HEIGHT:p,FIRST_HOUR:y,LAST_HOUR:b,showAllDay:D,showStartOfDayLabel:w}),ye(rr,{app:e,currentDate:W,visibleMonth:B,currentDayEvents:Q,selectedEvent:P,setSelectedEvent:e=>A(e?e.id:null),handleMonthChange:K,handleDateSelect:he,switcherMode:l}),ye(C,{isOpen:Y,onClose:()=>{z(!1),V(null)},onSave:t=>{g.find(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),z(!1),V(null)},draftEvent:F,app:e})]})},Dr={enableDrag:!0,enableResize:!0,enableCreate:!0,showMiniCalendar:!0,showAllDay:!0,scrollToCurrentTime:!0,hourHeight:72,firstHour:0,lastHour:24,dragConfig:{supportedViews:[exports.ViewType.DAY],enableAllDayCreate:!0},eventsConfig:{enableAutoRecalculate:!0,enableValidation:!0}},wr=(e={})=>{const t=Object.assign(Object.assign({},Dr),e),a=e=>n.h(ya,{viewType:exports.ViewType.DAY,originalComponent:xr,app:e.app,config:t,className:"day-view-factory",customDetailPanelContent:e.customDetailPanelContent,customEventDetailDialog:e.customEventDetailDialog,calendarRef:e.calendarRef,switcherMode:e.switcherMode,meta:e.meta,selectedEventId:e.selectedEventId,onEventSelect:e.onEventSelect,detailPanelEventId:e.detailPanelEventId,onDetailPanelToggle:e.onDetailPanelToggle});return a.displayName="DayViewAdapter",{type:exports.ViewType.DAY,component:a,config:t}},Cr=({app:e,weekDaysLabels:t,mobileWeekDaysLabels:a,weekDates:o,currentWeekStart:l,gridWidth:i,allDayAreaHeight:s,organizedAllDaySegments:d,allDayLabelText:c,isMobile:u,isTouch:g,showAllDay:h=!0,calendarRef:m,allDayRowRef:v,topFrozenContentRef:p,ALL_DAY_HEIGHT:y,HOUR_HEIGHT:b,FIRST_HOUR:x,dragState:D,isDragging:w,handleMoveStart:C,handleResizeStart:E,handleEventUpdate:k,handleEventDelete:T,onDateChange:S,newlyCreatedEventId:N,setNewlyCreatedEventId:M,selectedEventId:I,setSelectedEventId:H,detailPanelEventId:R,setDetailPanelEventId:O,handleCreateAllDayEvent:P,handleDragOver:A,handleDrop:L,customDetailPanelContent:$,customEventDetailDialog:j,events:Y,setDraftEvent:z,setIsDrawerOpen:F})=>{const V={flexShrink:0},[_,W]=r.useState(null),B=f();return ye("div",{className:`flex flex-none ${h?"border-b border-gray-200 dark:border-gray-700":""} relative z-10`,onContextMenu:e=>e.preventDefault(),children:[h&&ye("div",{className:"w-12 md:w-20 shrink-0 bg-white dark:bg-gray-900 z-20 flex flex-col",onContextMenu:e=>e.preventDefault(),children:[ye("div",{className:"flex-1 border-b border-gray-200 dark:border-gray-700"}),ye("div",{className:"flex items-center justify-end p-1 text-[10px] md:text-xs font-medium text-gray-500 dark:text-gray-400 select-none",style:{minHeight:`${s}px`},children:c})]}),ye("div",{className:"flex-1 overflow-x-hidden overflow-y-auto relative",style:{scrollbarGutter:"stable"},children:ye("div",{ref:p,className:"flex flex-col",style:{width:i,minWidth:"100%"},children:[ye("div",{className:"df-week-header flex border-b border-gray-200 dark:border-gray-700",style:{marginRight:B?"-50px":"0px",paddingRight:B?"50px":"0px"},children:t.map((e,t)=>ye("div",{className:"df-week-day-cell flex flex-1 justify-center items-center text-center text-gray-500 dark:text-gray-400 text-sm p-1 select-none "+(u?"flex-col gap-0":""),style:V,children:ye(n.Fragment,u?{children:[ye("div",{className:"text-[12px] leading-tight text-gray-500 font-medium",children:a[t]}),ye("div",{className:`${en} w-7 h-7 text-base font-medium ${o[t].isToday?pn:""}`,children:o[t].date})]}:{children:[ye("div",{className:"inline-flex items-center justify-center text-sm mt-1 mr-1",children:e}),ye("div",{className:`${en} ${o[t].isToday?pn:""}`,children:o[t].date})]})},t))}),h&&ye("div",{className:`${dn} border-none`,ref:v,style:{minHeight:`${s}px`},children:ye("div",{className:"df-all-day-content flex flex-1 relative",style:{minHeight:`${s}px`},children:[t.map((e,n)=>{const a=new Date(l);return a.setDate(l.getDate()+n),ye("div",{className:"df-all-day-cell flex-1 border-r border-gray-200 dark:border-gray-700 relative "+(n!==t.length-1||!u&&B?"":"border-r-0"),style:Object.assign({minHeight:`${s}px`},V),onClick:()=>{const e=new Date(l);e.setDate(l.getDate()+n),null==S||S(e)},onMouseDown:e=>null==P?void 0:P(e,n),onDblClick:e=>null==P?void 0:P(e,n),onDragOver:A,onDrop:e=>{L(e,a,void 0,!0)},onContextMenu:e=>((e,t)=>{if(e.preventDefault(),u)return;const n=new Date(l);n.setDate(l.getDate()+t),n.setHours(0,0,0,0),W({x:e.clientX,y:e.clientY,date:n})})(e,n)},`allday-${n}`)}),ye("div",{className:"absolute inset-0 pointer-events-none",children:d.map(t=>ye(pr,{event:t.event,segment:t,segmentIndex:t.row,isAllDay:!0,isMultiDay:!0,allDayHeight:y,calendarRef:m,isBeingDragged:w&&(null==D?void 0:D.eventId)===t.event.id&&"move"===(null==D?void 0:D.mode),hourHeight:b,firstHour:x,onMoveStart:C,onResizeStart:E,onEventUpdate:k,onEventDelete:T,newlyCreatedEventId:N,onDetailPanelOpen:()=>M(null),selectedEventId:I,detailPanelEventId:R,onEventSelect:t=>{const n=!1!==e.getReadOnlyConfig().viewable,a=e.state.readOnly;if((u||g)&&t&&n&&!a){const e=Y.find(e=>e.id===t);if(e)return z(e),void F(!0)}H(t)},onEventLongPress:e=>{(u||g)&&H(e)},onDetailPanelToggle:e=>O(e),customDetailPanelContent:$,customEventDetailDialog:j,app:e,isMobile:u,enableTouch:g},t.id))})]})})]})}),_&&ye(Wt,{x:_.x,y:_.y,date:_.date,viewType:exports.ViewType.WEEK,onClose:()=>W(null),app:e,onCreateEvent:()=>{const e=Math.floor((_.date.getTime()-l.getTime())/864e5);null==P||P({clientX:_.x,clientY:_.y},e)}})]})},Er=({app:e,timeSlots:t,weekDaysLabels:n,currentWeekStart:a,currentWeekEvents:o,eventLayouts:l,gridWidth:i,isMobile:s,isTouch:d,scrollerRef:c,timeGridRef:u,leftFrozenContentRef:g,calendarRef:h,handleScroll:m,handleCreateStart:v,handleTouchStart:p,handleTouchEnd:y,handleTouchMove:b,handleDragOver:x,handleDrop:D,dragState:w,isDragging:C,handleMoveStart:E,handleResizeStart:k,handleEventUpdate:T,handleEventDelete:S,onDateChange:N,newlyCreatedEventId:M,setNewlyCreatedEventId:I,selectedEventId:H,setSelectedEventId:R,detailPanelEventId:O,setDetailPanelEventId:P,customDetailPanelContent:A,customEventDetailDialog:L,events:$,setDraftEvent:j,setIsDrawerOpen:Y,isCurrentWeek:z,currentTime:F,HOUR_HEIGHT:V,FIRST_HOUR:_,LAST_HOUR:W,showStartOfDayLabel:B})=>{const U={flexShrink:0},q=r.useRef(e.state.highlightedEventId),[K,X]=r.useState(null),G=f();return ye("div",{className:"flex flex-1 overflow-hidden relative",children:[ye("div",{className:"w-12 md:w-20 shrink-0 overflow-hidden relative bg-white dark:bg-gray-900 z-10",onContextMenu:e=>e.preventDefault(),children:ye("div",{ref:g,children:[ye("div",{className:"h-3 relative",children:ye("div",{className:"absolute -bottom-1 right-2 text-[10px] md:text-[12px] text-gray-500 dark:text-gray-400 select-none",children:B?Z(_):""})}),t.map((e,t)=>ye("div",{className:an,children:ye("div",{className:`${rn} text-[10px] md:text-[12px]`,children:B&&0===t?"":e.label})},t)),ye("div",{className:"relative",children:ye("div",{className:`${rn} text-[10px] md:text-[12px]`,children:"00:00"})}),z&&F&&(()=>{const e=F,t=e.getHours()+e.getMinutes()/60;if(t<_||t>W)return null;return ye("div",{className:"absolute left-0 w-full z-20 pointer-events-none flex items-center justify-end",style:{top:`${(t-_)*V}px`,transform:"translateY(-50%)",marginTop:"0.75rem"},children:ye("div",{className:sn,children:Z(t)})})})()]})}),ye("div",{ref:c,className:"flex-1 overflow-auto relative calendar-content snap-x snap-mandatory",onScroll:m,children:ye("div",{className:"flex",style:{width:i,minWidth:"100%"},children:ye("div",{className:"grow",children:[ye("div",{className:`${Dn} border-t-0 flex`,children:n.map((e,t)=>ye("div",{className:`flex-1 relative ${t!==n.length-1||!s&&G?"border-r":""} border-gray-200 dark:border-gray-700`,style:U},`top-${t}`))}),ye("div",{ref:u,className:"relative",children:[z&&F&&(()=>{const e=F,t=e.getHours()+e.getMinutes()/60;if(t<_||t>W)return null;const a=e.getDay(),r=0===a?6:a-1;return ye("div",{className:ln,style:{top:`${(t-_)*V}px`,width:"100%",height:0,zIndex:20},children:[ye("div",{className:"flex items-center w-0"}),ye("div",{className:"flex flex-1",children:n.map((e,t)=>ye("div",{className:"flex-1 flex items-center",children:ye("div",{className:"h-0.5 w-full relative "+(t===r?"bg-primary":"bg-primary/30"),style:{zIndex:9999},children:t===r&&0!==r&&ye("div",{className:"absolute w-2 h-2 bg-primary rounded-full",style:{top:"-3px",left:"-4px"}})})},t))})]})})(),t.map((e,t)=>ye("div",{className:on,children:n.map((r,o)=>{const l=new Date(a);return l.setDate(a.getDate()+o),ye("div",{className:"df-time-grid-cell flex-1 relative border-r border-gray-200 dark:border-gray-700 select-none snap-start "+(o!==n.length-1||!s&&G?"":"border-r-0"),style:U,onClick:()=>{const e=new Date(a);e.setDate(a.getDate()+o),null==N||N(e)},onDblClick:t=>{null==v||v(t,o,e.hour)},onTouchStart:t=>p(t,o,e.hour),onTouchEnd:y,onTouchMove:b,onDragOver:x,onDrop:t=>{D(t,l,e.hour)},onContextMenu:t=>((e,t,n)=>{if(e.preventDefault(),s)return;const r=new Date(a);if(r.setDate(a.getDate()+t),u.current){const t=u.current.getBoundingClientRect(),n=(e.clientY-t.top)/V+_,a=Math.floor(n),o=Math.floor(60*(n-a)),l=15*Math.round(o/15),i=60===l?a+1:a,s=60===l?0:l;r.setHours(i,s,0,0)}else r.setHours(n,0,0,0);X({x:e.clientX,y:e.clientY,date:r})})(t,o,e.hour)},`${t}-${o}`)})},t)),ye("div",{className:`${Dn} flex`,children:n.map((e,t)=>ye("div",{className:`flex-1 relative ${t!==n.length-1||!s&&G?"border-r":""} border-gray-200 dark:border-gray-700`,style:U},`24-${t}`))}),n.map((t,n)=>{const r=oe(n,o),i=[];return r.forEach(e=>{const t=sr(e,a);if(t.length>0){const a=t.find(e=>e.dayIndex===n);a&&i.push({event:e,segmentInfo:Object.assign(Object.assign({},a),{dayIndex:n})})}else i.push({event:e})}),o.forEach(e=>{if(e.allDay||e.day===n)return;const t=sr(e,a).find(e=>e.dayIndex===n);t&&i.push({event:e,segmentInfo:Object.assign(Object.assign({},t),{dayIndex:n})})}),ye("div",{className:"absolute top-0 pointer-events-none",style:{left:`calc(${100/7*n}%)`,width:100/7+"%",height:"100%"},children:i.map(({event:t,segmentInfo:a})=>{const r=l.get(n),o=null==r?void 0:r.get(t.id);return ye(pr,{event:t,layout:o,calendarRef:h,isBeingDragged:C&&(null==w?void 0:w.eventId)===t.id&&"move"===(null==w?void 0:w.mode),hourHeight:V,firstHour:_,onMoveStart:E,onResizeStart:k,onEventUpdate:T,onEventDelete:S,newlyCreatedEventId:M,onDetailPanelOpen:()=>I(null),selectedEventId:H,detailPanelEventId:O,onEventSelect:t=>{const n=!1!==e.getReadOnlyConfig().viewable,a=e.state.readOnly;if((s||d)&&t&&n&&!a){const e=$.find(e=>e.id===t);if(e)return j(e),void Y(!0)}R(t),e.state.highlightedEventId&&(e.highlightEvent(null),q.current=null)},onEventLongPress:e=>{(s||d)&&R(e)},onDetailPanelToggle:e=>P(e),customDetailPanelContent:A,customEventDetailDialog:L,multiDaySegmentInfo:a,app:e,isMobile:s,enableTouch:d},a?`${t.id}-seg-${n}`:t.id)})},`events-day-${n}`)})]})]})})}),K&&ye(Wt,{x:K.x,y:K.y,date:K.date,viewType:exports.ViewType.WEEK,onClose:()=>X(null),app:e,onCreateEvent:()=>{if(v){const e=new Date(a);e.setHours(0,0,0,0);const t=new Date(K.date);t.setHours(0,0,0,0);const n=t.getTime()-e.getTime(),r=Math.round(n/864e5),o=K.date.getHours()+K.date.getMinutes()/60,l={preventDefault:()=>{},stopPropagation:()=>{},clientX:K.x,clientY:K.y};v(l,r,o)}}})]})},kr=({app:e,config:t,customDetailPanelContent:n,customEventDetailDialog:a,calendarRef:o,selectedEventId:l,onEventSelect:i,onDateChange:s,detailPanelEventId:d,onDetailPanelToggle:c})=>{const{t:u,getWeekDaysLabels:g,locale:h}=Ue(),m=e.getCurrentDate(),v=e.getEvents(),{screenSize:f}=Qn(),p="desktop"!==f,y="mobile"===f?48:80,b=r.useRef(null),[x,D]=r.useState(!1),{HOUR_HEIGHT:w=qa.HOUR_HEIGHT,FIRST_HOUR:C=qa.FIRST_HOUR,LAST_HOUR:E=qa.LAST_HOUR,ALL_DAY_HEIGHT:k=qa.ALL_DAY_HEIGHT,showAllDay:T=!0}=t,S=!T;r.useEffect(()=>{D("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const M=e.getCustomMobileEventRenderer()||ha,I=r.useMemo(()=>br(m),[m]),[R,O]=r.useState(null),[P,A]=r.useState(null),[L,$]=r.useState(null),z=void 0!==l?l:P,F=void 0!==d?d:L,V=e=>{i?i(e):A(e)},_=e=>{c?c(e):$(e)},[W,B]=r.useState(null),[U,q]=r.useState(!1),[K,X]=r.useState(null),G=r.useRef(null),J=r.useRef(null),Q=r.useRef(null),ee=r.useRef(null),te=r.useRef(null),ne=r.useMemo(()=>((e,t)=>{const n=new Date(t);return n.setDate(t.getDate()+6),n.setHours(23,59,59,999),e.filter(e=>{const a=H(e.start);a.setHours(0,0,0,0);const r=H(e.end);return r.setHours(23,59,59,999),r>=t&&a<=n}).map(e=>{const n=H(e.start),a=Math.floor((n.getTime()-t.getTime())/864e5),r=Math.max(0,Math.min(6,a));return Object.assign(Object.assign({},e),{day:r})})})(v,I),[v,I]),ae=r.useRef(e.state.highlightedEventId);r.useEffect(()=>{if(e.state.highlightedEventId!==ae.current)if(e.state.highlightedEventId){V(e.state.highlightedEventId);const t=ne.find(t=>t.id===e.state.highlightedEventId);if(t&&!t.allDay){const e=j(t.start),n=Q.current;if(n){const t=(e-C)*w;requestAnimationFrame(()=>{n.scrollTo({top:Math.max(0,t-100),behavior:"smooth"})})}}}else V(null);ae.current=e.state.highlightedEventId},[e.state.highlightedEventId,ne,C,w]);const re=r.useMemo(()=>((e,t)=>{const n=ir(e,t).filter(e=>e.event.allDay);n.sort((e,t)=>{if(e.startDayIndex!==t.startDayIndex)return e.startDayIndex-t.startDayIndex;const n=e.endDayIndex-e.startDayIndex;return t.endDayIndex-t.startDayIndex-n});const a=[];return n.forEach(e=>{let t=0,n=!1;for(;!n;)a.some(n=>n.row===t&&!(e.endDayIndex<n.startDayIndex||e.startDayIndex>n.endDayIndex))?t++:n=!0;a.push(Object.assign(Object.assign({},e),{row:t}))}),a})(ne,I),[ne,I]),oe=r.useMemo(()=>{if(0===re.length)return k;const e=Math.max(...re.map(e=>e.row));return k+e*k},[re,k]),ie=r.useMemo(()=>((e,t)=>{const n=new Map;for(let a=0;a<7;a++){const r=[];e.forEach(e=>{if(e.allDay)return;const n=sr(e,t);if(n.length>0){const o=n.find(e=>e.dayIndex===a);if(o){const n=o.endHour>=24?23.99:o.endHour,l=Object.assign(Object.assign({},e),{start:N(Y(le(t,a),o.startHour)),end:N(Y(le(t,a),n)),day:a});r.push(l)}}else e.day===a&&r.push(e)});const o=Za.calculateDayEventLayouts(r,{viewType:"week"});n.set(a,o)}return n})(ne,I),[ne,I]),{handleMoveStart:se,handleCreateStart:de,handleResizeStart:ce,handleCreateAllDayEvent:ue,dragState:ge,isDragging:he}=tr(e,{calendarRef:o,allDayRowRef:T?J:void 0,viewType:exports.ViewType.WEEK,onEventsUpdate:(t,n)=>{const a=t(ne),r=new Set(a.map(e=>e.id)),o=ne.filter(e=>!r.has(e.id)),l=new Set(ne.map(e=>e.id)),i=a.filter(e=>!l.has(e.id)),s=a.filter(e=>{if(!l.has(e.id))return!1;const t=ne.find(t=>t.id===e.id);return t&&(H(t.start).getTime()!==H(e.start).getTime()||H(t.end).getTime()!==H(e.end).getTime()||t.day!==e.day||j(t.start)!==j(e.start)||j(t.end)!==j(e.end)||t.title!==e.title)});e.applyEventsChanges({delete:o.map(e=>e.id),add:i,update:s.map(e=>({id:e.id,updates:e}))},n)},onEventCreate:t=>{p?(X(t),q(!0)):(e.addEvent(t),B(t.id))},onEventEdit:()=>{},currentWeekStart:I,events:ne,calculateNewEventLayout:(e,t,n)=>((e,t,n,a)=>{const r=new Date,o=new Date;r.setHours(Math.floor(t),t%1*60,0,0),o.setHours(Math.floor(n),n%1*60,0,0);const l={id:"-1",title:"Temp",day:e,start:N(r),end:N(o),calendarId:"blue",allDay:!1},i=[...a.filter(t=>t.day===e&&!t.allDay),l];return Za.calculateDayEventLayouts(i,{viewType:"week"}).get("-1")||null})(e,t,n,ne),calculateDragLayout:(e,t,n,a)=>((e,t,n,a,r)=>{const o=r.map(r=>{if(r.id!==e.id)return r;const o=H(r.start),l=Y(o,n),i=Y(o,a),s=N(l),d=N(i);return Object.assign(Object.assign({},r),{day:t,start:s,end:d})}).filter(e=>e.day===t&&!e.allDay);return 0===o.length?null:Za.calculateDayEventLayouts(o,{viewType:"week"}).get(e.id)||null})(e,t,n,a,ne),TIME_COLUMN_WIDTH:y,isMobile:p}),{handleDrop:me,handleDragOver:ve}=nr({app:e,onEventCreated:e=>{B(e.id)}}),fe=r.useMemo(()=>g(h,"short"),[h,g]),pe=r.useMemo(()=>{if(!p)return[];const e=h.split("-")[0].toLowerCase();return"zh"===e||"ja"===e?g(h,"narrow"):fe.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)})},[p,h,g,fe]),be=r.useMemo(()=>u("allDay"),[u]),xe=Array.from({length:24},(e,t)=>({hour:t+C,label:Z(t+C)})),De=r.useMemo(()=>{const e=new Date;return e.setHours(0,0,0,0),fe.map((t,n)=>{const a=new Date(I);a.setDate(I.getDate()+n);const r=new Date(a);return r.setHours(0,0,0,0),{date:a.getDate(),month:a.toLocaleString(h,{month:"short"}),fullDate:new Date(a),isToday:r.getTime()===e.getTime()}})},[I,fe,h]),we=t=>{e.updateEvent(t.id,t)},Ce=t=>{e.deleteEvent(t)},Ee=r.useMemo(()=>{const e=new Date,t=br(e);return I.getTime()===t.getTime()},[I]);r.useEffect(()=>{O(new Date);const e=setInterval(()=>O(new Date),6e4);return()=>clearInterval(e)},[]);const ke=p?"175%":"100%";return ye("div",{className:"df-calendar relative flex flex-col bg-white dark:bg-gray-900 w-full overflow-hidden h-full select-none df-week-view",children:[ye(or,{calendar:e,viewType:exports.ViewType.WEEK,currentDate:m,onPrevious:()=>e.goToPrevious(),onNext:()=>e.goToNext(),onToday:()=>e.goToToday()}),ye(Cr,{app:e,weekDaysLabels:fe,mobileWeekDaysLabels:pe,weekDates:De,currentWeekStart:I,gridWidth:ke,allDayAreaHeight:oe,organizedAllDaySegments:re,allDayLabelText:be,isMobile:p,isTouch:x,showAllDay:T,calendarRef:o,allDayRowRef:J,topFrozenContentRef:ee,ALL_DAY_HEIGHT:k,HOUR_HEIGHT:w,FIRST_HOUR:C,dragState:ge,isDragging:he,handleMoveStart:se,handleResizeStart:ce,handleEventUpdate:we,handleEventDelete:Ce,onDateChange:s,newlyCreatedEventId:W,setNewlyCreatedEventId:B,selectedEventId:z,setSelectedEventId:V,detailPanelEventId:F,setDetailPanelEventId:_,handleCreateAllDayEvent:ue,handleDragOver:ve,handleDrop:me,customDetailPanelContent:n,customEventDetailDialog:a,events:v,setDraftEvent:X,setIsDrawerOpen:q}),ye(Er,{app:e,timeSlots:xe,weekDaysLabels:fe,currentWeekStart:I,currentWeekEvents:ne,eventLayouts:ie,gridWidth:ke,isMobile:p,isTouch:x,scrollerRef:Q,timeGridRef:b,leftFrozenContentRef:te,calendarRef:o,handleScroll:e=>{const{scrollTop:t,scrollLeft:n}=e.currentTarget;ee.current&&(ee.current.style.transform=`translateX(${-n}px)`),te.current&&(te.current.style.transform=`translateY(${-t}px)`)},handleCreateStart:de,handleTouchStart:(e,t,n)=>{if(!p&&!x)return;const a=e.touches[0],r=a.clientX,o=a.clientY,l=e.currentTarget;G.current=setTimeout(()=>{null==de||de({preventDefault:()=>{},stopPropagation:()=>{},touches:[{clientX:r,clientY:o}],changedTouches:[{clientX:r,clientY:o}],target:l,currentTarget:l,cancelable:!0},t,n)},500)},handleTouchEnd:()=>{G.current&&(clearTimeout(G.current),G.current=null)},handleTouchMove:()=>{G.current&&(clearTimeout(G.current),G.current=null)},handleDragOver:ve,handleDrop:me,dragState:ge,isDragging:he,handleMoveStart:se,handleResizeStart:ce,handleEventUpdate:we,handleEventDelete:Ce,onDateChange:s,newlyCreatedEventId:W,setNewlyCreatedEventId:B,selectedEventId:z,setSelectedEventId:V,detailPanelEventId:F,setDetailPanelEventId:_,customDetailPanelContent:n,customEventDetailDialog:a,events:v,setDraftEvent:X,setIsDrawerOpen:q,isCurrentWeek:Ee,currentTime:R,HOUR_HEIGHT:w,FIRST_HOUR:C,LAST_HOUR:E,showStartOfDayLabel:S}),ye(M,{isOpen:U,onClose:()=>{q(!1),X(null)},onSave:t=>{v.find(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),q(!1),X(null)},draftEvent:K,app:e})]})},Tr={enableDrag:!0,enableResize:!0,enableCreate:!0,showWeekends:!0,showAllDay:!0,startOfWeek:1,scrollToCurrentTime:!0,hourHeight:72,firstHour:0,lastHour:24,dragConfig:{supportedViews:[exports.ViewType.WEEK],enableAllDayCreate:!0},eventsConfig:{enableAutoRecalculate:!0,enableValidation:!0}},Sr=(e={})=>{const t=Object.assign(Object.assign({},Tr),e),a=e=>n.h(ya,{viewType:exports.ViewType.WEEK,originalComponent:kr,app:e.app,config:t,className:"week-view-factory",customDetailPanelContent:e.customDetailPanelContent,customEventDetailDialog:e.customEventDetailDialog,calendarRef:e.calendarRef,switcherMode:e.switcherMode,meta:e.meta,selectedEventId:e.selectedEventId,detailPanelEventId:e.detailPanelEventId,onEventSelect:e.onEventSelect,onDetailPanelToggle:e.onDetailPanelToggle});return a.displayName="WeekViewAdapter",{type:exports.ViewType.WEEK,component:a,config:t}},Nr=o.memo(({currentMonth:e,currentYear:n,newlyCreatedEventId:a,screenSize:o,isScrolling:l,isDragging:i,item:s,weekHeight:d,events:c,dragState:u,calendarRef:g,onEventUpdate:h,onEventDelete:v,onMoveStart:f,onCreateStart:p,onResizeStart:y,onDetailPanelOpen:b,onMoreEventsClick:x,onChangeView:D,onSelectDate:w,selectedEventId:C,onEventSelect:E,onEventLongPress:k,detailPanelEventId:T,onDetailPanelToggle:S,customDetailPanelContent:N,customEventDetailDialog:M,onCalendarDrop:I,onCalendarDragOver:R,app:O,enableTouch:P})=>{const{t:A,locale:L}=Ue(),[$,Y]=r.useState(!1),z=r.useRef(null),F=r.useRef(null),V=r.useRef(null),[_,W]=r.useState(null),B=r.useMemo(()=>{const e=d-33;if(e<=0)return{maxSlots:0,maxSlotsWithMore:0};const t=e-20;return{maxSlots:Math.min(4,Math.floor(e/17)),maxSlotsWithMore:Math.min(4,Math.max(0,Math.floor(t/17)))}},[d]);r.useEffect(()=>l?(Y(!0),z.current&&(clearTimeout(z.current),z.current=null),()=>{z.current&&(clearTimeout(z.current),z.current=null)}):$?(z.current=setTimeout(()=>{Y(!1),z.current=null},100),()=>{z.current&&(clearTimeout(z.current),z.current=null)}):void 0,[l,$]);const{weekData:U}=s,Z=U.days.find(e=>1===e.day),q=`${d}px`,K=r.useMemo(()=>ir(c,U.startDate),[c,U.startDate]),X=r.useMemo(()=>((e,n)=>{const a=[],r=new Date(n);return r.setDate(r.getDate()+6),r.setHours(23,59,59,999),e.forEach(e=>{if(!e.start||!e.end)return void m.warn("Event missing start or end date:",e);const o=H(e.start),l=H(e.end),i=new Date(o);i.setHours(0,0,0,0);const s=new Date(l);s.setHours(0,0,0,0);let d=new Date(s);if(!e.allDay&&0===l.getHours()&&0===l.getMinutes()&&0===l.getSeconds()){const e=l.getTime()-o.getTime();e>0&&e<864e5&&(d=new Date(s),d.setDate(d.getDate()-1))}const c=i.toDateString()!==d.toDateString();if(!c||e.allDay)if(c&&e.allDay){let i=new Date(o);i<n&&(i=new Date(n),i.setHours(0,0,0,0));const s=l>r?r:l;for(;i<=s;){const n=t.Temporal.PlainDate.from({year:i.getFullYear(),month:i.getMonth()+1,day:i.getDate()});a.push(Object.assign(Object.assign({},e),{start:n,end:n,day:i.getDay()})),i.setDate(i.getDate()+1)}}else a.push(Object.assign(Object.assign({},e),{start:e.start,end:e.end,day:o.getDay()}))}),a})(c,U.startDate),[c,U.startDate]),G=r.useMemo(()=>(e=>{const t=[...e].sort((e,t)=>{const n=e.endDayIndex-e.startDayIndex+1,a=t.endDayIndex-t.startDayIndex+1;return e.startDayIndex>t.startDayIndex?1:n!==a?a-n:e.startDayIndex-t.startDayIndex}),n=[];t.forEach(e=>{let t=0,a=!1;for(;!a;)n.some(n=>{var a;const r=Math.abs((null!==(a=n.yPosition)&&void 0!==a?a:0)-t)<16,o=!(e.endDayIndex<n.startDayIndex||e.startDayIndex>n.endDayIndex);return r&&o})?t+=16:a=!0;n.push(Object.assign(Object.assign({},e),{yPosition:t}))});const a=[];return n.forEach(e=>{var t;const n=Math.floor((null!==(t=e.yPosition)&&void 0!==t?t:0)/16);a[n]||(a[n]=[]),a[n].push(e)}),a.forEach(e=>{e.sort((e,t)=>e.startDayIndex-t.startDayIndex)}),a})(K),[K]),J=r.useMemo(()=>{const e=Array(7).fill(0);return G.forEach((t,n)=>{t.forEach(t=>{for(let a=t.startDayIndex;a<=t.endDayIndex;a++)e[a]=Math.max(e[a],n+1)})}),e},[G]),Q=r.useMemo(()=>{const e=Array.from({length:7},()=>new Set);return G.forEach((t,n)=>{t.forEach(t=>{for(let a=t.startDayIndex;a<=t.endDayIndex;a++)a>=0&&a<7&&e[a].add(n)})}),e},[G]),ee=r.useMemo(()=>{const e=G.flat();for(let t=0;t<U.days.length;t++){const n=U.days[t],a=X.filter(e=>{if(!e.start||!e.end)return H(e.start).toDateString()===n.date.toDateString();const t=H(e.start),a=H(e.end);if(!e.allDay){if(!(0!==a.getHours()||0!==a.getMinutes()||0!==a.getSeconds())){const e=a.getTime()-t.getTime();if(e>0&&e<864e5)return t.toDateString()===n.date.toDateString()}}return t.toDateString()===n.date.toDateString()||a.toDateString()===n.date.toDateString()}).filter(t=>{if(!t.allDay)return!0;return!e.some(e=>e.originalEventId===t.id)}),r=Q[t],o=J[t]-1;let l=0;for(let e=0;e<=o;e++)r.has(e)||l++;if(o+1+Math.max(0,a.length-l)>B.maxSlots)return B.maxSlotsWithMore}return B.maxSlots},[U.days,X,G,J,Q,B.maxSlots,B.maxSlotsWithMore]),te=r.useMemo(()=>Math.max(0,17*G.length),[G]),ne=(t,r)=>{var l;const s=t.date.toLocaleDateString(L,{month:L.startsWith("zh")||L.startsWith("ja")?"short":"long"})===e&&t.year===n;var d;const c=(e=>[...e].sort((e,t)=>e.allDay!==t.allDay?e.allDay?-1:1:e.allDay&&t.allDay?0:j(e.start)-j(t.start)))((d=t.date,X.filter(e=>{if(!e.start||!e.end)return H(e.start).toDateString()===d.toDateString();const t=H(e.start),n=H(e.end);if(!e.allDay&&0===n.getHours()&&0===n.getMinutes()&&0===n.getSeconds()){const e=n.getTime()-t.getTime();if(e>0&&e<864e5)return t.toDateString()===d.toDateString()}return t.toDateString()===d.toDateString()||n.toDateString()===d.toDateString()}))),m=G.flat(),$=c.filter(e=>{if(!e.allDay)return!0;return!m.some(t=>t.originalEventId===e.id)}),Y=Q[r],z=(null!==(l=J[r])&&void 0!==l?l:0)-1,_=[];for(let e=0;e<=z;e++)Y.has(e)||_.push(e);const U=$.length,Z=Math.max(0,U-_.length),K=Math.max(z+1,0)+Z,ee=K>B.maxSlots,te=ee?B.maxSlotsWithMore:B.maxSlots,ne=_.filter(e=>e<te).length,ae=Math.max(0,te-Math.max(z+1,0)),re=Math.min(U,ne+ae),oe=$.slice(0,re),le=U-re,ie=[];let se=0;const de=Math.min(te,K);for(let e=0;e<de;e++)if(Y.has(e))ie.push(ye("div",{className:"shrink-0",style:{height:"17px",minHeight:"17px"}},`placeholder-layer-${e}-${t.date.getTime()}`));else if(se<oe.length){const e=oe[se];ie.push(ye(pr,{event:e,isAllDay:!!e.allDay,isMonthView:!0,isBeingDragged:i&&u.eventId===e.id&&"move"===u.mode,calendarRef:g,hourHeight:72,firstHour:0,onEventUpdate:h,onEventDelete:v,onMoveStart:f,onResizeStart:y,onDetailPanelOpen:b,onEventSelect:E,onEventLongPress:k,newlyCreatedEventId:a,selectedEventId:C,detailPanelEventId:T,onDetailPanelToggle:S,customDetailPanelContent:N,customEventDetailDialog:M,app:O,isMobile:"desktop"!==o,enableTouch:P},`${e.id}-${e.day}-${j(e.start)}-${se}`)),se++}return ye("div",{className:In("df-month-day-cell relative flex flex-col border-r border-gray-200 dark:border-gray-700",s?"text-gray-800 dark:text-gray-100":"text-gray-400 dark:text-gray-600","desktop"!==o&&6===r?"border-r-0":"last:border-r"),style:{height:q},"data-date":(ce=t.date,`${ce.getFullYear()}-${String(ce.getMonth()+1).padStart(2,"0")}-${String(ce.getDate()).padStart(2,"0")}`),onDblClick:e=>null==p?void 0:p(e,t.date),onTouchStart:e=>{if("mobile"!==o&&!P)return;const n=e.touches[0],a=n.clientX,r=n.clientY;V.current={x:a,y:r},F.current=setTimeout(()=>{null==p||p(e,t.date),F.current=null,navigator.vibrate&&navigator.vibrate(50)},500)},onTouchMove:e=>{if(F.current&&V.current){const t=Math.abs(e.touches[0].clientX-V.current.x),n=Math.abs(e.touches[0].clientY-V.current.y);(t>10||n>10)&&(clearTimeout(F.current),F.current=null)}},onTouchEnd:()=>{F.current&&(clearTimeout(F.current),F.current=null),V.current=null},onDragOver:R,onDrop:e=>null==I?void 0:I(e,t.date),onContextMenu:e=>((e,t)=>{e.preventDefault(),"mobile"!==o&&W({x:e.clientX,y:e.clientY,date:t})})(e,t.date),children:[ye("div",{className:"df-month-date-number-container text-right px-2 h-[33px] relative z-20",children:ye("span",{className:`\n df-month-date-number inline-flex items-center justify-center h-6 min-w-6 rounded-full text-sm font-medium whitespace-nowrap px-1\n ${t.isToday?"bg-primary text-primary-foreground":s?"text-gray-900 dark:text-gray-100":"text-gray-400 dark:text-gray-600"}\n `,children:1===t.day&&"desktop"===o?t.date.toLocaleDateString(L,{month:"short",day:"numeric"}):t.day})}),ye("div",{className:"flex-1 overflow-hidden px-1",children:[ie,ee&&ye("div",{className:In("df-month-more-events text-xs text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 cursor-pointer hover:underline relative z-20 bg-white dark:bg-gray-900","desktop"===o?"text-left font-normal":"text-center font-medium"),onClick:e=>{e.stopPropagation(),x?x(t.date):(null==w||w(t.date),null==D||D(exports.ViewType.DAY))},children:["+",le,"desktop"===o?` ${A("more")}`:""]})]})]},`day-${t.date.getTime()}`);var ce},ae=r.useMemo(()=>Z?Z.date.toLocaleDateString(L,{month:"long",year:"numeric"}):"",[Z,L]);return ye("div",{className:"relative select-none border-b border-gray-200 dark:border-gray-700",style:{height:q},children:[Z&&ye("div",{className:`\n df-month-title absolute top-10 left-0 z-30 bg-white/50 dark:bg-gray-900/50 py-2 px-2 duration-300\n ${$?"opacity-100 pointer-events-auto":"opacity-0 pointer-events-none"}\n `,style:{transition:"opacity 0.5s ease",maxWidth:"fit-content"},onContextMenu:e=>e.preventDefault(),children:ye("span",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:ae})}),ye("div",{className:"h-full flex flex-col",children:ye("div",{className:"calendar-week relative h-full",children:[ye("div",{className:"grid grid-cols-7 h-full",children:U.days.map((e,t)=>ne(e,t))}),G.length>0&&ye("div",{className:"absolute left-0 right-0 pointer-events-none",style:{top:"33px",height:`${te}px`,zIndex:10},children:G.slice(0,ee).map((e,t)=>ye("div",{className:"absolute inset-0",children:e.map(e=>ye(pr,{event:e.event,isAllDay:!!e.event.allDay,segment:e,segmentIndex:t,isMonthView:!0,isMultiDay:!0,calendarRef:g,hourHeight:72,firstHour:0,onEventUpdate:h,onEventDelete:v,onMoveStart:f,onResizeStart:y,isBeingDragged:i&&u.eventId===e.event.id&&"move"===u.mode,isBeingResized:i&&u.eventId===e.event.id&&"resize"===u.mode,newlyCreatedEventId:a,onDetailPanelOpen:b,selectedEventId:C,onEventSelect:E,onEventLongPress:k,detailPanelEventId:T,onDetailPanelToggle:S,customDetailPanelContent:N,customEventDetailDialog:M,app:O,isMobile:"desktop"!==o,enableTouch:P},e.id))},`layer-${t}`))})]})}),_&&ye(Wt,{x:_.x,y:_.y,date:_.date,viewType:exports.ViewType.MONTH,onClose:()=>W(null),app:O,onCreateEvent:()=>{if(p){const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:_.x,clientY:_.y};p(e,_.date)}}})]})});Nr.displayName="WeekComponent";const Mr=({app:e,customDetailPanelContent:t,customEventDetailDialog:n,calendarRef:a,selectedEventId:o,onEventSelect:l,detailPanelEventId:d,onDetailPanelToggle:c})=>{const{getWeekDaysLabels:u,getMonthLabels:g,locale:h}=Ue(),m=e.getCurrentDate(),v=e.getEvents(),f=e.getCalendars().map(e=>e.id+e.colors.lineColor).join("-"),p=r.useRef(null),y=r.useMemo(()=>{const e=p.current;return e&&e.length===v.length&&e.every((e,t)=>e===v[t])?e:(p.current=v,v)},[v]),b=r.useMemo(()=>{const e=new Map,t=e=>{const t=new Date(e);t.setHours(0,0,0,0);const n=t.getDay(),a=0===n?-6:1-n;return t.setDate(t.getDate()+a),t.setHours(0,0,0,0),t},n=(t,n)=>{const a=e.get(t);a?a.push(n):e.set(t,[n])};return y.forEach(e=>{if(!e.start)return;const a=H(e.start),r=e.end?H(e.end):a,o=new Date(a);o.setHours(0,0,0,0);const l=new Date(r);l.setHours(0,0,0,0);let i=new Date(l);if(!e.allDay){0!==r.getHours()||0!==r.getMinutes()||0!==r.getSeconds()||0!==r.getMilliseconds()||i.setDate(i.getDate()-1)}i<o&&(i=new Date(o));const s=t(o),d=t(i);let c=s.getTime();const u=d.getTime();for(;c<=u;){n(c,e);const t=new Date(c);t.setDate(t.getDate()+7),t.setHours(0,0,0,0),c=t.getTime()}}),e},[y]),{screenSize:x}=Qn(),[D,w]=r.useState(!1);r.useEffect(()=>{w("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const C=e.getCustomMobileEventRenderer()||ha,[E,k]=r.useState(119),[T,S]=r.useState(!1),N=r.useRef(E),M=r.useRef([]),[I,R]=r.useState(null),[O,P]=r.useState(!1),[A,L]=r.useState(null),[$,Y]=r.useState(null),[z,F]=r.useState(null),V=void 0!==o?o:$,_=void 0!==d?d:z,W=e=>{l?l(e):Y(e)},B=e=>{c?c(e):F(e)},U=r.useRef(e.state.highlightedEventId);r.useEffect(()=>{e.state.highlightedEventId?W(e.state.highlightedEventId):U.current&&W(null),U.current=e.state.highlightedEventId},[e.state.highlightedEventId]);const Z=r.useMemo(()=>{const e=m.getDay(),t=m.getDate()-e+(0===e?-6:1),n=new Date(m);return n.setDate(t),n.setHours(0,0,0,0),n},[m]),{handleMoveStart:q,handleCreateStart:K,handleResizeStart:X,dragState:G,isDragging:J}=tr(e,{calendarRef:a,viewType:exports.ViewType.MONTH,onEventsUpdate:(t,n)=>{const a=t(y),r=new Set(a.map(e=>e.id)),o=y.filter(e=>!r.has(e.id)),l=new Set(y.map(e=>e.id)),i=a.filter(e=>!l.has(e.id)),s=a.filter(e=>{if(!l.has(e.id))return!1;const t=y.find(t=>t.id===e.id);return t&&(H(t.start).getTime()!==H(e.start).getTime()||H(t.end).getTime()!==H(e.end).getTime()||t.day!==e.day||j(t.start)!==j(e.start)||j(t.end)!==j(e.end)||t.title!==e.title||(null==t?void 0:t.start)!==(null==e?void 0:e.start)||(null==t?void 0:t.end)!==(null==e?void 0:e.end))});e.applyEventsChanges({delete:o.map(e=>e.id),add:i,update:s.map(e=>({id:e.id,updates:e}))},n)},onEventCreate:t=>{"desktop"!==x?(L(t),P(!0)):e.addEvent(t)},onEventEdit:e=>{R(e.id)},currentWeekStart:Z,events:y}),{handleDrop:Q,handleDragOver:ee}=nr({app:e,onEventCreated:e=>{R(e.id)}}),te=r.useMemo(()=>u(h,"short"),[h,u]),{currentMonth:ae,currentYear:oe,isScrolling:le,virtualData:ie,scrollElementRef:se,handleScroll:de,handlePreviousMonth:ce,handleNextMonth:ue,handleToday:ge,setScrollTop:he}=(({currentDate:e,weekHeight:t,onCurrentMonthChange:n,initialWeeksToLoad:a=104,locale:o="en-US",isEnabled:l=!0})=>{const d=r.useRef(null),c=r.useCallback((e,t)=>{const n=new Date(t,e,1),a=o.startsWith("zh")||o.startsWith("ja");return n.toLocaleDateString(o,{month:a?"short":"long"})},[o]),u=r.useMemo(()=>{const t=new Date(e);return t.setDate(1),t.setHours(0,0,0,0),re(t,a)},[e,a]),g=r.useMemo(()=>{const n=new Date(e);n.setDate(1),n.setHours(0,0,0,0);const a=u.findIndex(e=>e.days.some(e=>e.date.toDateString()===n.toDateString()));return a>0?a*t:0},[u,e,t]),[h,m]=r.useState(g),[v,f]=r.useState(600),[p,y]=r.useState(c(e.getMonth(),e.getFullYear())),[b,x]=r.useState(e.getFullYear()),[D,w]=r.useState(!1),[C,E]=r.useState(u),[k,T]=r.useState(!1),S=r.useRef(!1),[N,M]=r.useState(!1),I=r.useRef(e),H=r.useRef(null),R=r.useRef(null),O=r.useRef(new s),P=r.useRef(0),A=r.useRef(0),L=r.useRef(!1),$=r.useCallback(e=>{e&&(H.current=e)},[]),j=r.useCallback(e=>{let t=O.current.get(e);return console.log("weekData",t),t||(t=ne(e),O.current.set(e,t)),t},[]),Y=r.useCallback((e,n=26)=>{L.current||(L.current=!0,setTimeout(()=>{try{if("future"===e){const e=C[C.length-1],t=[];for(let a=1;a<=n;a++){const n=new Date(e.startDate);n.setDate(n.getDate()+7*a),t.push(j(n))}E(e=>[...e,...t])}else{const e=C[0],a=[];for(let t=n;t>=1;t--){const n=new Date(e.startDate);n.setDate(n.getDate()-7*t),a.push(j(n))}const r=a.length*t;E(e=>[...a,...e]),requestAnimationFrame(()=>{m(e=>e+r),H.current&&(H.current.scrollTop+=r)})}}finally{setTimeout(()=>{L.current=!1},200)}},0))},[C,j,t]),z=r.useMemo(()=>{const e=C.length*t,n=Math.floor(h/t);let a=Math.max(0,n);a=Math.min(a,Math.max(0,C.length-6));const r=Math.min(C.length-1,a+6-1),o=Math.max(0,a-15),l=Math.min(C.length-1,r+15),i=[];for(let e=o;e<=l;e++)i.push({index:e,weekData:C[e],top:e*t,height:t});return{totalHeight:e,visibleItems:i,displayStartIndex:a}},[h,v,t,C]),F=r.useCallback(e=>{if(k||D||0===e.length||!N)return;const t=h+v/2,a=e.find(e=>e.top<=t&&e.top+e.height>t)||e[Math.floor(e.length/2)];if(!a)return;const r={};a.weekData.days.forEach(e=>{const t=`${c(e.month,e.year)}-${e.year}`;r[t]=(r[t]||0)+1});let o="",l=0,i=0;Object.entries(r).forEach(([e,t])=>{if(t>i){i=t;const[n,a]=e.split("-");o=n,l=parseInt(a)}}),o&&l&&(d.current?o===d.current.month&&l===d.current.year&&(d.current=null,o===p&&l===b||(y(o),x(l),null==n||n(o,l))):o===p&&l===b||(y(o),x(l),null==n||n(o,l)))},[v,p,b,k,D,n,h,N]),V=r.useCallback(e=>{const n=performance.now();if(n-P.current<i.SCROLL_THROTTLE)return;P.current=n;const a=e.currentTarget,r=a.scrollTop;A.current=r,m(r),k||requestAnimationFrame(()=>{const{scrollHeight:e,clientHeight:n}=a;r+n>e-10*t&&!L.current&&Y("future",26),r<10*t&&!L.current&&Y("past",26)}),w(!0),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>{w(!1)},i.SCROLL_DEBOUNCE)},[t,Y,k]),_=r.useCallback((e,n=!0)=>{if(!H.current)return;T(!0),S.current=!0;const a=()=>{setTimeout(()=>{T(!1),S.current=!1},n?500:200)},r=C.findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(-1!==r){const e=r*t;return H.current.scrollTo({top:e,behavior:n?"smooth":"auto"}),void a()}const o=e.getDay(),l=0===o?6:o-1,i=new Date(e);i.setDate(e.getDate()-l),i.setHours(0,0,0,0);const s=C[0],d=C[C.length-1];let c=0,u=!1,g=!1;i<s.startDate?(c=Math.ceil((s.startDate.getTime()-i.getTime())/6048e5),u=!0):i>d.startDate&&(c=Math.ceil((i.getTime()-d.startDate.getTime())/6048e5),g=!0);const h=Math.min(c+10,52);if(u){const r=[];for(let e=h;e>=1;e--){const t=new Date(s.startDate);t.setDate(t.getDate()-7*e),r.push(j(t))}const o=r.length*t;E(e=>[...r,...e]),requestAnimationFrame(()=>{const l=[...r,...C].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(H.current&&-1!==l){const e=l*t;H.current.scrollTop+=o,m(e=>e+o),setTimeout(()=>{H.current&&H.current.scrollTo({top:e,behavior:n?"smooth":"auto"})},50)}a()})}else if(g){const r=[];for(let e=1;e<=h;e++){const t=new Date(d.startDate);t.setDate(t.getDate()+7*e),r.push(j(t))}E(e=>[...e,...r]),requestAnimationFrame(()=>{const o=[...C,...r].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"})}a()})}else a()},[C,t,j]),W=r.useCallback(()=>{const e=C[z.displayStartIndex].days[0].date,t=new Date(e.getFullYear(),e.getMonth()-1,1);_(t)},[z.displayStartIndex,C,_]),B=r.useCallback(()=>{const e=C[z.displayStartIndex].days[0].date,t=new Date(e.getFullYear(),e.getMonth()+1,1);_(t)},[z.displayStartIndex,C,_]),U=r.useCallback(()=>{const e=new Date,a=c(e.getMonth(),e.getFullYear()),r=e.getFullYear(),o=new Date(r,e.getMonth(),1);d.current={month:a,year:r},y(a),x(r),null==n||n(a,r);const l=C.findIndex(e=>e.days.some(e=>e.date.toDateString()===o.toDateString()));if(-1!==l){const e=l*t,n=H.current;n&&(T(!0),S.current=!0,requestAnimationFrame(()=>{m(e),requestAnimationFrame(()=>{n&&(n.scrollTop=e,setTimeout(()=>{S.current=!1,T(!1)},200))})}))}else T(!0),S.current=!0,requestAnimationFrame(()=>{_(o,!0),setTimeout(()=>{S.current=!1,T(!1)},200)})},[C,t,n,_]);return r.useEffect(()=>{F(z.visibleItems)},[z.visibleItems,F]),r.useEffect(()=>{const t=I.current,a=t.getMonth(),r=t.getFullYear(),o=e.getMonth(),l=e.getFullYear();if(a!==o||r!==l){const e=new Date(l,o,1),t=c(o,l);d.current={month:t,year:l},y(t),x(l),null==n||n(t,l),_(e,!0)}I.current=e},[e,n,_]),r.useEffect(()=>{const e=H.current;if(!e)return;const t=new ResizeObserver(([e])=>{f(e.contentRect.height)});return t.observe(e),()=>t.disconnect()},[]),r.useEffect(()=>{const e=H.current;e&&!N&&l&&requestAnimationFrame(()=>{e&&g>0?(e.scrollTop=g,m(g),M(!0)):e&&M(!0)})},[N,g,l]),r.useEffect(()=>()=>{R.current&&clearTimeout(R.current)},[]),{scrollTop:h,containerHeight:v,currentMonth:p,currentYear:b,isScrolling:D,virtualData:z,scrollElementRef:H,handleScroll:V,scrollToDate:_,handlePreviousMonth:W,handleNextMonth:B,handleToday:U,setScrollTop:m,setContainerHeight:f,setCurrentMonth:y,setCurrentYear:x,setIsScrolling:w,cache:O.current,scrollElementRefCallback:$,weeksData:C}})({currentDate:m,weekHeight:E,onCurrentMonthChange:(t,n)=>{const a=h.startsWith("zh")||h.startsWith("ja"),r=g(h,a?"short":"long").indexOf(t);r>=0&&e.setVisibleMonth(new Date(n,r,1))},initialWeeksToLoad:156,locale:h,isEnabled:T}),me=r.useRef(0),[ve,fe]=r.useState(0),pe=r.useMemo(()=>ve-6*E,[ve,E]),{visibleWeeks:be,startIndex:xe}=r.useMemo(()=>{const{visibleItems:e,displayStartIndex:t}=ie,n=e.findIndex(e=>e.index===t);if(-1===n)return M.current.length>0?{visibleWeeks:M.current,startIndex:me.current}:{visibleWeeks:[],startIndex:t};const a=e.slice(n,n+8);return a.length>=6&&(M.current=a,me.current=t),{visibleWeeks:a,startIndex:t}},[ie]),De=r.useMemo(()=>xe*E,[xe,E]),we=r.useMemo(()=>{const e=ie.totalHeight,t=xe*E+16*E+pe;return Math.max(0,e-t)},[ie.totalHeight,xe,E,pe]);r.useEffect(()=>{const e=se.current;if(!e)return;const t=new ResizeObserver(t=>{for(const n of t){const t=n.contentRect.height;if(fe(t),!T&&t>0){const n=Math.max(80,Math.floor(t/6));if(n!==N.current){const t=e.scrollTop;if(t>0){const a=Math.round(t/N.current)*n;e.scrollTop=a,he(a)}}k(n),N.current=n,requestAnimationFrame(()=>{S(!0)})}}});return t.observe(e),()=>{t.disconnect()}},[se,T,he]),r.useEffect(()=>{const e=window.innerHeight-150,t=Math.max(80,Math.floor(e/6));k(t)},[]);const Ce=t=>{e.updateEvent(t.id,t)},Ee=t=>{e.deleteEvent(t)},ke=t=>{e.changeView(t)};return ye("div",{className:Xt,children:[ye(or,{calendar:e,viewType:exports.ViewType.MONTH,currentDate:m,customTitle:h.startsWith("zh")||h.startsWith("ja")?`${oe}年${ae}`:`${ae} ${oe}`,onPrevious:()=>{e.goToPrevious(),ce()},onNext:()=>{e.goToNext(),ue()},onToday:()=>{e.goToToday(),ge()}}),ye("div",{className:"df-week-header-row sticky top-0 z-10 bg-white dark:bg-gray-900 border-b border-gray-200 dark:border-gray-700",onContextMenu:e=>e.preventDefault(),children:ye("div",{className:"grid grid-cols-7 px-2",children:te.map((e,t)=>ye("div",{className:"text-right text-gray-500 dark:text-gray-400 text-sm py-2 pr-2 select-none",children:e},t))})}),ye("div",{ref:se,className:tn,style:{scrollSnapType:"y mandatory",overflow:"hidden auto",visibility:T?"visible":"hidden"},onScroll:de,children:[ye("div",{style:{height:De}}),be.map((r,o)=>{var l;const i=null!==(l=b.get(r.weekData.startDate.getTime()))&&void 0!==l?l:[],s=5===o?Object.assign(Object.assign({},r),{height:r.height+pe}):r;return ye(Nr,{item:s,weekHeight:E,currentMonth:ae,currentYear:oe,screenSize:x,isScrolling:le,calendarRef:a,events:i,onEventUpdate:Ce,onEventDelete:Ee,onMoveStart:q,onCreateStart:K,onResizeStart:X,isDragging:J,dragState:G,newlyCreatedEventId:I,onDetailPanelOpen:()=>R(null),onMoreEventsClick:e.onMoreEventsClick,onChangeView:ke,onSelectDate:e.selectDate,selectedEventId:V,onEventSelect:t=>{const n=!1!==e.getReadOnlyConfig().viewable;if(("desktop"!==x||D)&&t&&n){const e=y.find(e=>e.id===t);if(e)return L(e),void P(!0)}W(t)},onEventLongPress:e=>{("desktop"!==x||D)&&W(e)},detailPanelEventId:_,onDetailPanelToggle:B,customDetailPanelContent:t,customEventDetailDialog:n,onCalendarDrop:Q,onCalendarDragOver:ee,calendarSignature:f,app:e,enableTouch:D},`week-${r.weekData.startDate.getTime()}`)}),ye("div",{style:{height:we}})]}),ye(C,{isOpen:O,onClose:()=>{P(!1),L(null)},onSave:t=>{y.find(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),P(!1),L(null)},draftEvent:A,app:e})]})},Ir={enableDrag:!0,enableResize:!1,enableCreate:!0,showOtherMonth:!0,weekHeight:120,showWeekNumbers:!1,enableVirtualScroll:!0,initialWeeksToLoad:156,dragConfig:{supportedViews:[exports.ViewType.MONTH],enableAllDayCreate:!1},eventsConfig:{enableAutoRecalculate:!0,enableValidation:!0},virtualScrollConfig:{weekHeight:120,initialWeeksToLoad:156,enableVirtualScroll:!0,enableKeyboardNavigation:!0,supportedViews:[exports.ViewType.MONTH]}},Hr=(e={})=>{const t=Object.assign(Object.assign({},Ir),e),a=e=>n.h(ya,{viewType:exports.ViewType.MONTH,originalComponent:Mr,app:e.app,config:t,className:"month-view-factory",customDetailPanelContent:e.customDetailPanelContent,customEventDetailDialog:e.customEventDetailDialog,calendarRef:e.calendarRef,switcherMode:e.switcherMode,meta:e.meta,selectedEventId:e.selectedEventId,detailPanelEventId:e.detailPanelEventId,onEventSelect:e.onEventSelect,onDetailPanelToggle:e.onDetailPanelToggle});return a.displayName="MonthViewAdapter",{type:exports.ViewType.MONTH,component:a,config:t}};const Rr=o.memo(({date:e,isToday:t,locale:n,onSelectDate:a,onCreateStart:r,onMoreEventsClick:o,moreCount:l=0,onContextMenu:i})=>{const{t:s}=Ue(),d=e.getDate(),c=1===d,u=e.toLocaleDateString(n,{month:"short"}).toUpperCase();return ye("div",{className:`\n relative flex flex-col border-r border-b border-gray-100 dark:border-gray-800\n ${c?"border-l-2 border-l-primary dark:border-l-primary":""}\n overflow-hidden bg-white dark:bg-gray-900 select-none\n `,style:{aspectRatio:"1/1"},onClick:()=>a(e),onDblClick:t=>null==r?void 0:r(t,e),onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),null==i||i(t,e)},"data-date":`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,children:[ye("div",{className:"flex items-center px-1 py-1 shrink-0 h-6",children:[c&&ye("span",{className:"text-[9px] font-bold text-primary-foreground bg-primary px-1 py-0.5 rounded-sm leading-none",children:u}),ye("span",{className:"text-[10px] font-medium ml-auto "+(t?"bg-primary text-primary-foreground rounded-full w-5 h-5 flex items-center justify-center":"text-gray-700 dark:text-gray-300"),children:d})]}),l>0&&ye("div",{className:"absolute bottom-0.5 left-1 z-20",children:ye("span",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 cursor-pointer hover:underline",onClick:t=>{t.stopPropagation(),null==o||o(e)},children:["+",l," ",s("more")]})})]})});Rr.displayName="YearDayCell";const Or=({segment:e,columnsPerRow:t,isDragging:a,isSelected:l,onMoveStart:i,onResizeStart:s,onEventSelect:d,detailPanelEventId:c,onDetailPanelToggle:u,newlyCreatedEventId:g,onDetailPanelOpen:h,customDetailPanelContent:m,customEventDetailDialog:v,app:f,calendarRef:p})=>{const{event:y,startCellIndex:b,endCellIndex:x,visualRowIndex:D,isFirstSegment:w,isLastSegment:C}=e,E=r.useRef(null),k=r.useRef(null),[T,S]=r.useState(null),[N,M]=r.useState(null),I=c===e.id,H=!(null==f?void 0:f.state.readOnly),R=b/t*100,O=(x-b+1)/t*100,P=y.calendarId||"blue",A=l?W(P):V(P),L=l?"#fff":_(P),$=B(P),j=!!y.allDay,Y=j?lr(y):null,z=18*D,F=r.useCallback(()=>{if(!E.current||!(null==p?void 0:p.current))return;const e=p.current.getBoundingClientRect(),t=E.current.getBoundingClientRect(),n=Math.min(window.innerWidth,e.right),a=Math.min(window.innerHeight,e.bottom);requestAnimationFrame(()=>{if(!k.current)return void requestAnimationFrame(()=>{if(!k.current)return;const r=k.current.getBoundingClientRect(),o=r.width||340,l=r.height||240;let i,s;const d=n-t.right,c=t.left-e.left;i=d>=o+20?t.right+10:c>=o+20?t.left-o-10:d>c?Math.max(e.left+10,n-o-10):e.left+10;const u=t.top-l/2+t.height/2,g=Math.max(10,e.top+10),h=a-10;s=u<g?g:u+l>h?Math.max(g,h-l):u,S({top:s,left:i,eventHeight:t.height,eventMiddleY:t.top+t.height/2,isSunday:i<t.left})});const r=k.current.getBoundingClientRect(),o=r.width||340,l=r.height||240;let i,s;const d=n-t.right,c=t.left-e.left;i=d>=o+20?t.right+10:c>=o+20?t.left-o-10:d>c?Math.max(e.left+10,n-o-10):e.left+10;const u=t.top-l/2+t.height/2,g=Math.max(10,e.top+10),h=a-10;s=u<g?g:u+l>h?Math.max(g,h-l):u,S({top:s,left:i,eventHeight:t.height,eventMiddleY:t.top+t.height/2,isSunday:i<t.left})})},[p,T]),U=()=>{null==u||u(e.id)};r.useEffect(()=>{g===y.id&&!I&&w&&setTimeout(()=>{U(),null==h||h()},50)},[g,y.id,I,h,w]),r.useEffect(()=>{I&&!T&&(S({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>{F()}))},[I,T,F]),r.useEffect(()=>{if(!I)return;const e=()=>{F()};return window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[I,F]);const Z=e=>{const t="left"===e,n=t?w:C;return y.allDay&&n&&s&&H?ye("div",{className:`resize-handle absolute ${t?"left-0":"right-0"} top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20`,onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),s(e,y,t?"left":"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}}):null},q=x-b+1;return ye(n.Fragment,{children:[ye("div",{ref:E,className:"df-year-event absolute z-30 text-[12px] px-1 overflow-hidden whitespace-nowrap cursor-pointer transition-colors group",style:{left:`calc(${R}% + 2px)`,top:`${z}px`,height:"16px",backgroundColor:A,color:L,opacity:1,width:`calc(${O}% - 4px)`,pointerEvents:a?"none":"auto",borderRadius:w&&C?"0.25rem":w?"0.25rem 0 0 0.25rem":C?"0 0.25rem 0.25rem 0":"0"},"data-segment-days":q,"data-event-id":y.id,onMouseDown:e=>{e.stopPropagation(),i&&i(e,y)},onClick:e=>{e.preventDefault(),e.stopPropagation(),d&&d(y.id)},onDblClick:e=>{e.preventDefault(),e.stopPropagation(),U()},onTouchStart:e=>{e.stopPropagation(),d&&d(y.id),i&&i(e,y)},onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),d&&d(y.id),M({x:e.clientX,y:e.clientY})},title:y.title,children:[Z("left"),(()=>{if(y.allDay){const t=()=>e.isFirstSegment?y.title:"···";return ye("div",{className:"df-year-event-content flex items-center min-w-0 w-full pointer-events-auto h-full",children:[e.isFirstSegment&&lr(y)&&ye("div",{className:"df-year-event-icon shrink-0 mr-1",children:ye("div",{className:"rounded-full p-0.5 text-white flex items-center justify-center",style:{backgroundColor:B(P),width:"12px",height:"12px"},children:lr(y)})}),ye("div",{className:"flex-1 min-w-0",children:ye("div",{className:"df-year-event-title text-[12px] leading-none whitespace-nowrap overflow-hidden",style:{maskImage:"linear-gradient(to right, black 70%, transparent 100%)",WebkitMaskImage:"linear-gradient(to right, black 70%, transparent 100%)"},children:t()})}),e.isLastSegment&&!e.isFirstSegment&&ye("div",{className:"shrink-0 ml-1 text-white/80 dark:text-white/90",children:ye("div",{className:"w-1.5 h-1.5 rounded-full bg-white/60 dark:bg-white/80"})})]})}const t=e.isFirstSegment?y.title:"";return ye("div",{className:"df-year-event-content w-full h-full flex items-center overflow-hidden gap-1 pointer-events-auto",children:[!j&&ye("span",{style:{backgroundColor:$},className:"df-year-event-indicator inline-block w-0.75 h-3 shrink-0 rounded-full"}),j&&Y&&ye("div",{className:"df-year-event-icon shrink-0 flex items-center justify-center opacity-80 scale-75",children:Y}),ye("span",{className:"df-year-event-title w-full block font-medium whitespace-nowrap overflow-hidden leading-none",style:{maskImage:"linear-gradient(to right, black 70%, transparent 100%)",WebkitMaskImage:"linear-gradient(to right, black 70%, transparent 100%)"},children:t})]})})(),Z("right")]}),(()=>{if(!I||!p)return null;const e=()=>{null==u||u(null),d&&d(null)};if(v){const t=v,n={event:y,isOpen:I,isAllDay:j,onClose:e,app:f,onEventUpdate:e=>null==f?void 0:f.updateEvent(e.id,e),onEventDelete:e=>null==f?void 0:f.deleteEvent(e)};if("undefined"==typeof window||"undefined"==typeof document)return null;const a=document.body;return a?o.createPortal(ye(t,Object.assign({},n)),a):null}return T?m?ye(ur,{event:y,position:T,panelRef:k,isAllDay:j,onClose:e,contentRenderer:m,onEventUpdate:e=>null==f?void 0:f.updateEvent(e.id,e),onEventDelete:e=>null==f?void 0:f.deleteEvent(e),eventVisibility:"visible",calendarRef:p,selectedEventElementRef:E}):ye(cr,{event:y,position:T,panelRef:k,isAllDay:j,onClose:e,app:f,onEventUpdate:e=>null==f?void 0:f.updateEvent(e.id,e),onEventDelete:e=>null==f?void 0:f.deleteEvent(e),eventVisibility:"visible",calendarRef:p,selectedEventElementRef:E}):null})(),N&&f&&ye(Bt,{event:y,x:N.x,y:N.y,onClose:()=>M(null),app:f,onDetailPanelToggle:u,detailPanelKey:e.id})]})},Pr=o.memo(({rowDays:e,events:t,columnsPerRow:n,app:a,calendarRef:o,locale:l,isDragging:i,dragState:s,onMoveStart:d,onResizeStart:c,onCreateStart:u,selectedEventId:g,onEventSelect:h,onMoreEventsClick:m,newlyCreatedEventId:v,onDetailPanelOpen:f,detailPanelEventId:p,onDetailPanelToggle:y,customDetailPanelContent:b,customEventDetailDialog:x})=>{const D=new Date;D.setHours(0,0,0,0);const[w,C]=r.useState(null),E=(e,t)=>{e.preventDefault(),e.stopPropagation(),C({x:e.clientX,y:e.clientY,date:t})},k=r.useMemo(()=>function(e,t,n){if(0===t.length)return[];const a=t[0],r=t[t.length-1],o=new Date(a.getFullYear(),a.getMonth(),a.getDate()).getTime(),l=new Date(r.getFullYear(),r.getMonth(),r.getDate(),23,59,59,999).getTime(),i=e.filter(e=>{if(!e.start)return!1;const t=H(e.start),n=e.end?H(e.end):t,a=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),r=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime();return a<=l&&r>=o});i.sort((e,t)=>{const n=H(e.start).getTime(),a=e.end?H(e.end).getTime():n,r=H(t.start).getTime(),o=a-n,l=(t.end?H(t.end).getTime():r)-r;return o!==l?l-o:n-r});const s=[],d=[];return i.forEach(e=>{const r=H(e.start),i=e.end?H(e.end):r,c=new Date(r.getFullYear(),r.getMonth(),r.getDate()).getTime(),u=new Date(i.getFullYear(),i.getMonth(),i.getDate()).getTime();let g=-1,h=-1;const m=Math.round((c-o)/864e5);g=m>=0?m:0;const v=Math.round((u-o)/864e5);h=v<t.length?v:t.length-1,g=Math.max(0,Math.min(g,n-1)),h=Math.max(0,Math.min(h,n-1));const f=c>=o,p=u<=l;let y=0;for(;;){let e=!1;d[y]||(d[y]=[]);for(let t=g;t<=h;t++)if(d[y][t]){e=!0;break}if(!e){for(let e=g;e<=h;e++)d[y][e]=!0;break}y++}s.push({id:`${e.id}_${a.getTime()}`,event:e,startCellIndex:g,endCellIndex:h,isFirstSegment:f,isLastSegment:p,visualRowIndex:y})}),s}(t,e,n),[t,e,n]),{visibleSegments:T,moreCounts:S}=r.useMemo(()=>{const t=new Array(e.length).fill(0);k.forEach(n=>{const a=Math.max(0,n.startCellIndex),r=Math.min(e.length-1,n.endCellIndex);for(let e=a;e<=r;e++)t[e]++});const n=[],a=new Array(e.length).fill(0);return k.forEach(r=>{let o=!0;const l=Math.max(0,r.startCellIndex),i=Math.min(e.length-1,r.endCellIndex);for(let e=l;e<=i;e++){const n=t[e]>3?1:2;if(r.visualRowIndex>n){o=!1;break}}if(o)n.push(r);else for(let e=l;e<=i;e++)a[e]++}),{visibleSegments:n,moreCounts:a}},[k,e.length]);return ye("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()===D.getTime();return ye(Rr,{date:e,isToday:n,locale:l,onSelectDate:e=>{a.selectDate(e)},onCreateStart:u,onMoreEventsClick:m,moreCount:S[t],onContextMenu:E},e.getTime())}),ye("div",{className:"absolute inset-0 pointer-events-none",style:{top:26,bottom:0,left:0,right:0},onContextMenu:e=>e.preventDefault(),children:ye("div",{className:"relative w-full h-full",children:T.map(e=>ye("div",{className:"pointer-events-auto",children:ye(Or,{segment:e,columnsPerRow:n,isDragging:i&&s.eventId===e.event.id,isSelected:g===e.event.id,onMoveStart:d,onResizeStart:c,onEventSelect:h,onDetailPanelToggle:y,newlyCreatedEventId:v,onDetailPanelOpen:f,calendarRef:o,app:a,detailPanelEventId:p,customDetailPanelContent:b,customEventDetailDialog:x})},e.id))})}),w&&ye(Wt,{x:w.x,y:w.y,date:w.date,viewType:exports.ViewType.YEAR,onClose:()=>C(null),app:a,onCreateEvent:()=>{if(u){const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:w.x,clientY:w.y};u(e,w.date)}}})]})});Pr.displayName="YearRowComponent";const Ar=({app:e,calendarRef:n,customDetailPanelContent:a,customEventDetailDialog:o,config:l,selectedEventId:i,onEventSelect:s,detailPanelEventId:d,onDetailPanelToggle:c})=>{var u;const{t:g,locale:h}=Ue(),m=e.getCurrentDate(),v=m.getFullYear(),f=e.getEvents(),p=r.useRef(null),[y,b]=r.useState(()=>"undefined"!=typeof window?Math.max(1,Math.floor(window.innerWidth/80)):7),[x,D]=r.useState(!1),[w,C]=r.useState(null),[E,k]=r.useState(null),T=void 0!==i?i:w,S=void 0!==d?d:E,N=e=>{s?s(e):C(e)},M=e=>{c?c(e):k(e)},[I,R]=r.useState(null);r.useEffect(()=>{const e=e=>{const t=e.target,n=t.closest("[data-event-id]"),a=t.closest("[data-event-detail-panel]");n||a||(N(null),M(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),r.useEffect(()=>{const e=p.current;if(!e)return;const t=new ResizeObserver(e=>{const t=e[0].contentRect.width,n=Math.floor(t/80);b(Math.max(1,n)),D(!0)});return t.observe(e),()=>t.disconnect()},[]);const O=r.useRef(e.state.highlightedEventId);r.useEffect(()=>{e.state.highlightedEventId?N(e.state.highlightedEventId):O.current&&N(null),O.current=e.state.highlightedEventId},[e.state.highlightedEventId]);const{handleMoveStart:P,handleResizeStart:A,handleCreateStart:L,dragState:$,isDragging:j}=tr(e,{calendarRef:n,viewType:exports.ViewType.YEAR,onEventsUpdate:(t,n)=>{t(f).forEach(t=>{const a=f.find(e=>e.id===t.id);!a||a.start===t.start&&a.end===t.end||e.updateEvent(t.id,t,n)})},currentWeekStart:new Date,events:f,onEventCreate:t=>{e.addEvent(t)},onEventEdit:e=>{R(e.id)}}),Y=null!==(u=null==l?void 0:l.showTimedEventsInYearView)&&void 0!==u&&u,z=r.useCallback((n,a)=>{if(Y)null==L||L(n,a);else{const n=t.Temporal.PlainDate.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate()}),r={id:`event-${Date.now()}`,title:g("newEvent")||"New Event",start:n,end:n,allDay:!0};e.addEvent(r),R(r.id)}},[Y,L,e]),F=r.useMemo(()=>{const e=[],t=new Date(v,0,1),n=new Date(v,11,31),a=new Date(t);for(;a<=n;)e.push(new Date(a)),a.setDate(a.getDate()+1);return e},[v]),V=r.useMemo(()=>function(e,t){const n=[];for(let a=0;a<e.length;a+=t)n.push(e.slice(a,a+t));return n}(F,y),[F,y]),_=r.useMemo(()=>{const e=new Date(v,0,1),t=new Date(v,11,31,23,59,59);return f.filter(n=>{if(!n.start)return!1;if(!Y&&!n.allDay)return!1;const a=H(n.start),r=n.end?H(n.end):a;return a<=t&&r>=e})},[f,v,Y]);return ye("div",{className:Xt,onContextMenu:e=>e.preventDefault(),children:[ye(or,{calendar:e,viewType:exports.ViewType.YEAR,currentDate:m,customTitle:h.startsWith("zh")||h.startsWith("ja")?`${v}年`:`${v}`,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()}}),ye("div",{ref:p,className:`${tn} ${nn}`,style:{overflow:"hidden auto"},children:ye("div",{className:"w-full flex flex-col border-t border-l border-gray-100 dark:border-gray-800",style:{opacity:x?1:0,transition:"opacity 0.2s ease"},children:V.map((t,r)=>ye(Pr,{rowDays:t,events:_,columnsPerRow:y,app:e,calendarRef:n,locale:h,isDragging:j,dragState:$,onMoveStart:P,onResizeStart:A,onCreateStart:z,selectedEventId:T,onEventSelect:N,onMoreEventsClick:e.onMoreEventsClick,newlyCreatedEventId:I,onDetailPanelOpen:()=>R(null),detailPanelEventId:S,onDetailPanelToggle:M,customDetailPanelContent:a,customEventDetailDialog:o},r))})})]})};function Lr(e,t,n){const a=new Date(n,t,1),r=new Date(n,t+1,0).getDate(),o=a.getDay(),l=a.getTime(),i=new Date(n,t,r,23,59,59,999).getTime(),s=e.filter(e=>{if(!e.start)return!1;const t=H(e.start),n=e.end?H(e.end):t,a=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),r=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime();return a<=i&&r>=l});s.sort((e,t)=>{const n=H(e.start).getTime(),a=e.end?H(e.end).getTime():n,r=H(t.start).getTime(),o=a-n,l=(t.end?H(t.end).getTime():r)-r;return o!==l?l-o:n-r});const d=[],c=[];s.forEach(e=>{const a=H(e.start),r=e.end?H(e.end):a,s=new Date(Math.max(a.getTime(),l)),u=new Date(Math.min(r.getTime(),i)),g=s.getDate(),h=u.getDate(),m=o+(g-1),v=o+(h-1),f=a.getMonth()===t&&a.getFullYear()===n,p=r.getMonth()===t&&r.getFullYear()===n;let y=0;for(;;){let e=!1;c[y]||(c[y]=[]);for(let t=m;t<=v;t++)if(c[y][t]){e=!0;break}if(!e){for(let e=m;e<=v;e++)c[y][e]=!0;break}y++}d.push({id:`${e.id}_month_${t}`,event:e,startCellIndex:m,endCellIndex:v,isFirstSegment:f,isLastSegment:p,visualRowIndex:y,monthIndex:t})});const u=d.length>0?Math.max(...d.map(e=>e.visualRowIndex)):-1;return{segments:d,maxVisualRow:u}}const $r=({app:e,calendarRef:n,customDetailPanelContent:a,customEventDetailDialog:o,config:l,selectedEventId:i,onEventSelect:s,detailPanelEventId:d,onDetailPanelToggle:c})=>{var u;const{t:g,locale:h,getWeekDaysLabels:m}=Ue(),v=e.getCurrentDate(),f=v.getFullYear(),p=e.getEvents(),y=new Date;y.setHours(0,0,0,0);const b=r.useRef(null),x=r.useRef(null),D=r.useRef(null),[w,C]=r.useState(0),[E,k]=r.useState(0),[T,S]=r.useState(null),[N,M]=r.useState(null),I=void 0!==i?i:T,R=void 0!==d?d:N,O=e=>{s?s(e):S(e)},P=e=>{c?c(e):M(e)},[A,L]=r.useState(null),[$,j]=r.useState(null);r.useEffect(()=>{const e=e=>{const t=e.target,n=t.closest("[data-event-id]"),a=t.closest("[data-event-detail-panel]");n||a||(O(null),P(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const Y=r.useMemo(()=>{let e=0;for(let t=0;t<12;t++){const n=new Date(f,t,1),a=new Date(f,t+1,0).getDate(),r=n.getDay()+a;r>e&&(e=r)}return e},[f]),{handleMoveStart:z,handleResizeStart:F,handleCreateStart:V,dragState:_,isDragging:W}=tr(e,{calendarRef:n,viewType:exports.ViewType.YEAR,onEventsUpdate:(t,n)=>{t(p).forEach(t=>{const a=p.find(e=>e.id===t.id);!a||a.start===t.start&&a.end===t.end||e.updateEvent(t.id,t,n)})},currentWeekStart:new Date,events:p,onEventCreate:t=>{e.addEvent(t)},onEventEdit:e=>{L(e.id)}}),B=null!==(u=null==l?void 0:l.showTimedEventsInYearView)&&void 0!==u&&u,U=r.useCallback((n,a)=>{if(B)null==V||V(n,a);else{const n=t.Temporal.PlainDate.from({year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate()}),r={id:`event-${Date.now()}`,title:g("newEvent")||"New Event",start:n,end:n,allDay:!0};e.addEvent(r),L(r.id)}},[B,V,e]),Z=r.useMemo(()=>{const e=m(h,"short"),t=[e[6],...e.slice(0,6)].map(e=>{if(h.startsWith("zh"))return e.charAt(e.length-1);const t=e.substring(0,2);return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}),n=[];for(let e=0;e<Y;e++)n.push(t[e%7]);return n},[h,m,Y]),q=r.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 a=H(n.start),r=n.end?H(n.end):a;return a<=t&&r>=e})},[p,f,B]),K=r.useMemo(()=>{const e=[];for(let t=0;t<12;t++){const n=new Date(f,t,1),a=new Date(f,t+1,0).getDate(),r=n.getDay(),o=[];for(let e=0;e<r;e++)o.push(null);for(let e=1;e<=a;e++)o.push(new Date(f,t,e));for(;o.length<Y;)o.push(null);const l=n.toLocaleDateString(h,{month:"short"}),i=l.charAt(0).toUpperCase()+l.slice(1).toLowerCase(),{segments:s,maxVisualRow:d}=Lr(q,t,f),c=d+1,u=Math.max(60,20+18*c);e.push({monthIndex:t,monthName:i,days:o,eventSegments:s,minHeight:u})}return e},[f,h,Y,q]),X=r.useCallback(e=>{const t=e.currentTarget;b.current&&(b.current.scrollLeft=t.scrollLeft),x.current&&(x.current.scrollTop=t.scrollTop)},[]);r.useEffect(()=>{const e=()=>{if(D.current){const e=D.current,t=e.offsetHeight-e.clientHeight,n=e.offsetWidth-e.clientWidth;k(e=>e!==t?t:e),C(e=>e!==n?n:e)}},t=D.current;if(!t)return;e();const n=new ResizeObserver(()=>{e()});return n.observe(t),()=>{n.disconnect()}},[K]);return ye("div",{className:"h-full bg-white dark:bg-gray-900 overflow-hidden select-none",style:{display:"grid",gridTemplateColumns:"3rem 1fr",gridTemplateRows:"auto auto 1fr"},onContextMenu:e=>e.preventDefault(),children:[ye("div",{className:"col-span-2",children:ye(or,{calendar:e,viewType:exports.ViewType.YEAR,currentDate:v,customTitle:h.startsWith("zh")||h.startsWith("ja")?`${f}年`:`${f}`,onPrevious:()=>{const t=new Date(v);t.setFullYear(t.getFullYear()-1),e.setCurrentDate(t)},onNext:()=>{const t=new Date(v);t.setFullYear(t.getFullYear()+1),e.setCurrentDate(t)},onToday:()=>{e.goToToday()}})}),ye("div",{className:"bg-gray-50 dark:bg-gray-900 border-r border-b border-gray-200 dark:border-gray-800 z-30"}),ye("div",{ref:b,className:"overflow-hidden bg-gray-50 dark:bg-gray-900 border-b border-gray-200 dark:border-gray-800",children:ye("div",{className:"flex",style:{minWidth:`calc(1352px + ${w}px)`},children:[ye("div",{className:"grid flex-1",style:{gridTemplateColumns:`repeat(${Y}, minmax(0, 1fr))`,minWidth:"1352px"},children:Z.map((e,t)=>{const n=t%7;return ye("div",{className:"text-center py-2 text-[10px] font-bold tracking-wider border-r border-gray-200 dark:border-gray-700 text-gray-500 dark:text-gray-400 "+(0===n||6===n?"df-year-view-weekend-header":""),children:e},t)})}),w>0&&ye("div",{className:"shrink-0 bg-gray-50 dark:bg-gray-900",style:{width:`${w}px`}})]})}),ye("div",{ref:x,className:"overflow-hidden bg-white dark:bg-gray-900 border-r border-gray-200 dark:border-gray-700",children:ye("div",{className:"flex flex-col min-h-full",children:[K.map(e=>ye("div",{className:"flex items-center justify-center border-b border-gray-200 dark:border-gray-700 font-bold text-[10px] text-gray-500 dark:text-gray-400 flex-grow shrink-0",style:{minHeight:`${e.minHeight}px`},children:e.monthName},e.monthIndex)),E>0&&ye("div",{className:"shrink-0 bg-white dark:bg-gray-900",style:{height:`${E}px`}})]})}),ye("div",{ref:D,className:`overflow-auto ${nn}`,onScroll:X,children:ye("div",{className:"flex flex-col min-h-full",style:{minWidth:"1352px"},children:K.map(t=>ye("div",{className:"relative flex-grow shrink-0",style:{minHeight:`${t.minHeight}px`},children:[ye("div",{className:"grid absolute inset-0 z-0",style:{gridTemplateColumns:`repeat(${Y}, minmax(0, 1fr))`},children:t.days.map((t,n)=>{const a=n%7,r=0===a||6===a;if(!t)return ye("div",{className:"bg-gray-50/80 dark:bg-gray-800/40 border-r border-b border-gray-200 dark:border-gray-700 "+(r?"df-year-view-weekend-cell":"")},`empty-${n}`);const o=(e=>e.getTime()===y.getTime())(t);return ye("div",{"data-date":`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`,className:`\n relative flex items-start justify-end p-0.5 border-r border-b border-gray-200 dark:border-gray-700\n cursor-pointer hover:bg-blue-100 dark:hover:bg-primary/20 transition-colors\n ${r?"bg-blue-50 dark:bg-blue-900/30 df-year-view-weekend-cell":""}\n `,onClick:()=>e.selectDate(t),onDblClick:e=>U(e,t),onContextMenu:e=>((e,t)=>{e.preventDefault(),e.stopPropagation(),j({x:e.clientX,y:e.clientY,date:t})})(e,t),children:ye("span",{className:`\n text-[10px] font-medium w-5 h-5 flex items-center justify-center rounded-full\n ${o?"bg-primary text-primary-foreground font-bold shadow-sm":"text-gray-700 dark:text-gray-300"}\n `,children:t.getDate()})},t.getTime())})}),t.eventSegments.length>0&&ye("div",{className:"absolute inset-0 pointer-events-none z-20",style:{top:20},children:ye("div",{className:"relative w-full h-full",children:t.eventSegments.map(t=>ye("div",{className:"pointer-events-auto",children:ye(Or,{segment:t,columnsPerRow:Y,isDragging:W&&_.eventId===t.event.id,isSelected:I===t.event.id,onMoveStart:z,onResizeStart:F,onEventSelect:O,onDetailPanelToggle:P,newlyCreatedEventId:A,onDetailPanelOpen:()=>L(null),calendarRef:n,app:e,detailPanelEventId:R,customDetailPanelContent:a,customEventDetailDialog:o})},t.id))})})]},t.monthIndex))})}),$&&ye(Wt,{x:$.x,y:$.y,date:$.date,viewType:exports.ViewType.YEAR,onClose:()=>j(null),app:e,onCreateEvent:()=>{const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:$.x,clientY:$.y};U(e,$.date)}})]})},jr=e=>{var t;return ye("fixed-week"===((null===(t=e.config)||void 0===t?void 0:t.mode)||"year-canvas")?$r:Ar,Object.assign({},e))},Yr={enableDrag:!1,enableResize:!1,enableCreate:!1,enableVirtualScroll:!0,showDebugInfo:!1,eventsConfig:{enableAutoRecalculate:!1,enableValidation:!0}};const zr={enableAutoRecalculate:!0,enableValidation:!0,defaultEvents:[],maxEventsPerDay:50};exports.CalendarApp=class{constructor(e){var t,n,a,r,o;this.undoStack=[],this.pendingSnapshot=null,this.MAX_UNDO_STACK=50,this.subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e)),this.notify=()=>{this.listeners.forEach(e=>e(this))},this.pushToUndo=e=>{this.undoStack.push({type:"events_snapshot",data:e||[...this.state.events]}),this.undoStack.length>this.MAX_UNDO_STACK&&this.undoStack.shift()},this.undo=()=>{if(0===this.undoStack.length)return;const e=this.undoStack.pop();"events_snapshot"===(null==e?void 0:e.type)&&(this.state.events=e.data,this.triggerRender(),this.notify())},this.getReadOnlyConfig=()=>{var e,t;const n=this.state.readOnly;return!0===n?{draggable:!1,viewable:!1}:!1===n?{draggable:!0,viewable:!0}:{draggable:null!==(e=n.draggable)&&void 0!==e&&e,viewable:null!==(t=n.viewable)&&void 0!==t&&t}},this.isInternalEditable=()=>!0!==this.state.readOnly&&"object"!=typeof this.state.readOnly,this.changeView=e=>{var t,n;if(!this.state.views.has(e))throw new Error(`View ${e} is not registered`);this.state.currentView=e,this.state.highlightedEventId=null,null===(n=(t=this.callbacks).onViewChange)||void 0===n||n.call(t,e),this.notify()},this.getCurrentView=()=>{const e=this.state.views.get(this.state.currentView);if(!e)throw new Error(`Current view ${this.state.currentView} is not registered`);return e},this.setCurrentDate=e=>{var t,n;this.state.currentDate=new Date(e),null===(n=(t=this.callbacks).onDateChange)||void 0===n||n.call(t,this.state.currentDate),this.setVisibleMonth(this.state.currentDate),this.notify()},this.getCurrentDate=()=>new Date(this.state.currentDate),this.setVisibleMonth=e=>{var t,n;const a=new Date(e.getFullYear(),e.getMonth(),1);this.visibleMonth.getFullYear()===a.getFullYear()&&this.visibleMonth.getMonth()===a.getMonth()||(this.visibleMonth=a,null===(n=(t=this.callbacks).onVisibleMonthChange)||void 0===n||n.call(t,new Date(this.visibleMonth)),this.notify())},this.getVisibleMonth=()=>new Date(this.visibleMonth),this.goToToday=()=>{this.setCurrentDate(new Date)},this.goToPrevious=()=>{const e=new Date(this.state.currentDate);switch(this.state.currentView){case exports.ViewType.DAY:e.setDate(e.getDate()-1);break;case exports.ViewType.WEEK:e.setDate(e.getDate()-7);break;case exports.ViewType.MONTH:e.setMonth(e.getMonth()-1);break;case exports.ViewType.YEAR:e.setFullYear(e.getFullYear()-1)}this.setCurrentDate(e)},this.goToNext=()=>{const e=new Date(this.state.currentDate);switch(this.state.currentView){case exports.ViewType.DAY:e.setDate(e.getDate()+1);break;case exports.ViewType.WEEK:e.setDate(e.getDate()+7);break;case exports.ViewType.MONTH:e.setMonth(e.getMonth()+1);break;case exports.ViewType.YEAR:e.setFullYear(e.getFullYear()+1)}this.setCurrentDate(e)},this.selectDate=e=>{var t,n;this.setCurrentDate(e),null===(n=(t=this.callbacks).onDateChange)||void 0===n||n.call(t,new Date(e))},this.applyEventsChanges=(e,t)=>{if(!this.isInternalEditable()&&!t)return;t?this.pendingSnapshot||(this.pendingSnapshot=[...this.state.events]):this.pendingSnapshot?(this.pushToUndo(this.pendingSnapshot),this.pendingSnapshot=null):this.pushToUndo();let n=[...this.state.events];if(e.delete){const t=new Set(e.delete);n=n.filter(e=>!t.has(e.id))}e.update&&e.update.forEach(({id:e,updates:t})=>{const a=n.findIndex(t=>t.id===e);-1!==a&&(n[a]=Object.assign(Object.assign({},n[a]),t))}),e.add&&(n=[...n,...e.add]),this.state.events=n,t||(e.add&&e.add.forEach(e=>{var t,n;return null===(n=(t=this.callbacks).onEventCreate)||void 0===n?void 0:n.call(t,e)}),e.delete&&e.delete.forEach(e=>{var t,n;return null===(n=(t=this.callbacks).onEventDelete)||void 0===n?void 0:n.call(t,e)}),e.update&&this.callbacks.onEventUpdate&&e.update.forEach(({id:e})=>{var t,n;const a=this.state.events.find(t=>t.id===e);a&&(null===(n=(t=this.callbacks).onEventUpdate)||void 0===n||n.call(t,a))})),this.notify()},this.addEvent=e=>{var t,n;this.isInternalEditable()?(this.pendingSnapshot=null,this.pushToUndo(),this.state.events=[...this.state.events,e],null===(n=(t=this.callbacks).onEventCreate)||void 0===n||n.call(t,e),this.notify()):m.warn("Cannot add event in read-only mode")},this.updateEvent=(e,t,n)=>{var a,r;if(!this.isInternalEditable()&&!n)return void m.warn("Cannot update event in read-only mode");if(!this.isInternalEditable())return;const o=this.state.events.findIndex(t=>t.id===e);if(-1===o)throw new Error(`Event with id ${e} not found`);n?this.pendingSnapshot||(this.pendingSnapshot=[...this.state.events]):this.pendingSnapshot?(this.pushToUndo(this.pendingSnapshot),this.pendingSnapshot=null):this.pushToUndo();const l=Object.assign(Object.assign({},this.state.events[o]),t);this.state.events=[...this.state.events.slice(0,o),l,...this.state.events.slice(o+1)],n||null===(r=(a=this.callbacks).onEventUpdate)||void 0===r||r.call(a,l),this.notify()},this.deleteEvent=e=>{var t,n;if(!this.isInternalEditable())return void m.warn("Cannot delete event in read-only mode");const a=this.state.events.findIndex(t=>t.id===e);if(-1===a)throw new Error(`Event with id ${e} not found`);this.pendingSnapshot=null,this.pushToUndo(),this.state.events=[...this.state.events.slice(0,a),...this.state.events.slice(a+1)],null===(n=(t=this.callbacks).onEventDelete)||void 0===n||n.call(t,e),this.notify()},this.getAllEvents=()=>[...this.state.events],this.onEventClick=e=>{var t,n;null===(n=(t=this.callbacks).onEventClick)||void 0===n||n.call(t,e)},this.onMoreEventsClick=e=>{var t,n;null===(n=(t=this.callbacks).onMoreEventsClick)||void 0===n||n.call(t,e)},this.highlightEvent=e=>{var t,n;this.state.highlightedEventId!==e&&(this.state.highlightedEventId=e,null===(n=(t=this.callbacks).onRender)||void 0===n||n.call(t),this.notify())},this.getEvents=()=>{const e=this.getAllEvents(),t=new Set(this.calendarRegistry.getAll().filter(e=>!1!==e.isVisible).map(e=>e.id));return e.filter(e=>!e.calendarId||(!this.calendarRegistry.has(e.calendarId)||t.has(e.calendarId)))},this.getCalendars=()=>this.calendarRegistry.getAll(),this.reorderCalendars=(e,t)=>{var n,a;this.calendarRegistry.reorder(e,t),null===(a=(n=this.callbacks).onRender)||void 0===a||a.call(n),this.notify()},this.setCalendarVisibility=(e,t)=>{var n,a;this.calendarRegistry.setVisibility(e,t),null===(a=(n=this.callbacks).onRender)||void 0===a||a.call(n),this.notify()},this.setAllCalendarsVisibility=e=>{var t,n;this.calendarRegistry.setAllVisibility(e),null===(n=(t=this.callbacks).onRender)||void 0===n||n.call(t),this.notify()},this.updateCalendar=(e,t,n)=>{var a,r,o,l;if(this.calendarRegistry.updateCalendar(e,t),n)return void this.notify();const i=this.calendarRegistry.get(e);i&&(null===(r=(a=this.callbacks).onCalendarUpdate)||void 0===r||r.call(a,i)),null===(l=(o=this.callbacks).onRender)||void 0===l||l.call(o),this.notify()},this.createCalendar=e=>{var t,n,a,r;this.calendarRegistry.register(e),null===(n=(t=this.callbacks).onCalendarCreate)||void 0===n||n.call(t,e),null===(r=(a=this.callbacks).onRender)||void 0===r||r.call(a),this.notify()},this.deleteCalendar=e=>{var t,n,a,r;this.calendarRegistry.unregister(e),null===(n=(t=this.callbacks).onCalendarDelete)||void 0===n||n.call(t,e),null===(r=(a=this.callbacks).onRender)||void 0===r||r.call(a),this.notify()},this.mergeCalendars=(e,t)=>{var n,a,r,o;this.state.events.filter(t=>t.calendarId===e).forEach(e=>{this.updateEvent(e.id,{calendarId:t})}),this.deleteCalendar(e),null===(a=(n=this.callbacks).onCalendarMerge)||void 0===a||a.call(n,e,t),null===(o=(r=this.callbacks).onRender)||void 0===o||o.call(r),this.notify()},this.getSidebarConfig=()=>this.sidebarConfig,this.getCalendarHeaderConfig=()=>this.useCalendarHeader,this.installPlugin=e=>{this.state.plugins.has(e.name)?m.warn(`Plugin ${e.name} is already installed`):(this.state.plugins.set(e.name,e),e.install(this))},this.getPlugin=e=>{const t=this.state.plugins.get(e);return null==t?void 0:t.api},this.hasPlugin=e=>this.state.plugins.has(e),this.getPluginConfig=e=>{const t=this.state.plugins.get(e);return(null==t?void 0:t.config)||{}},this.updatePluginConfig=(e,t)=>{const n=this.state.plugins.get(e);n&&(n.config=Object.assign(Object.assign({},n.config),t),this.notify())},this.getViewConfig=e=>{const t=this.state.views.get(e);return(null==t?void 0:t.config)||{}},this.triggerRender=()=>{var e,t;null===(t=(e=this.callbacks).onRender)||void 0===t||t.call(e),this.notify()},this.getCalendarRegistry=()=>this.calendarRegistry,this.getUseEventDetailDialog=()=>this.useEventDetailDialog,this.getCustomMobileEventRenderer=()=>this.customMobileEventRenderer,this.updateConfig=e=>{var t;let n=!1;if(void 0!==e.customMobileEventRenderer&&e.customMobileEventRenderer!==this.customMobileEventRenderer&&(this.customMobileEventRenderer=e.customMobileEventRenderer,n=!0),void 0!==e.useEventDetailDialog&&e.useEventDetailDialog!==this.useEventDetailDialog&&(this.useEventDetailDialog=e.useEventDetailDialog,n=!0),void 0!==e.useCalendarHeader&&e.useCalendarHeader!==this.useCalendarHeader&&(this.useCalendarHeader=e.useCalendarHeader,n=!0),void 0===e.readOnly||ge(e.readOnly,this.state.readOnly)||(this.state.readOnly=e.readOnly,n=!0),e.callbacks&&(this.callbacks=Object.assign(Object.assign({},this.callbacks),e.callbacks)),void 0!==(null===(t=e.theme)||void 0===t?void 0:t.mode)&&e.theme.mode!==this.getTheme()&&this.setTheme(e.theme.mode),void 0!==e.useSidebar){const t=me(e.useSidebar);ge(t,this.sidebarConfig)||(this.sidebarConfig=t,this.state.sidebar=this.sidebarConfig,n=!0)}if(void 0!==e.switcherMode&&e.switcherMode!==this.state.switcherMode&&(this.state.switcherMode=e.switcherMode,n=!0),void 0!==e.locale){const t=this.resolveLocale(e.locale);ge(t,this.state.locale)||(this.state.locale=t,n=!0)}n&&(this.triggerRender(),this.notify())},this.setTheme=e=>{var t,n;this.calendarRegistry.setTheme(e),this.themeChangeListeners.forEach(t=>{t(e)}),null===(n=(t=this.callbacks).onRender)||void 0===n||n.call(t),this.notify()},this.getTheme=()=>this.calendarRegistry.getTheme(),this.subscribeThemeChange=e=>(this.themeChangeListeners.add(e),()=>{this.unsubscribeThemeChange(e)}),this.unsubscribeThemeChange=e=>{this.themeChangeListeners.delete(e)},this.state={currentView:e.defaultView||exports.ViewType.WEEK,currentDate:e.initialDate||new Date,events:e.events||[],switcherMode:e.switcherMode||"buttons",plugins:new Map,views:new Map,locale:this.resolveLocale(e.locale),highlightedEventId:null,readOnly:e.readOnly||!1},this.callbacks=e.callbacks||{},this.themeChangeListeners=new Set,this.listeners=new Set,this.calendarRegistry=new c(e.calendars,e.defaultCalendar,(null===(t=e.theme)||void 0===t?void 0:t.mode)||"light"),o=this.calendarRegistry,u=o,this.sidebarConfig=me(e.useSidebar),this.state.sidebar=this.sidebarConfig;const l=this.state.currentDate;this.visibleMonth=new Date(l.getFullYear(),l.getMonth(),1),this.useEventDetailDialog=null!==(n=e.useEventDetailDialog)&&void 0!==n&&n,this.useCalendarHeader=null===(a=e.useCalendarHeader)||void 0===a||a,this.customMobileEventRenderer=e.customMobileEventRenderer,e.views.forEach(e=>{this.state.views.set(e.type,e)}),null===(r=e.plugins)||void 0===r||r.forEach(e=>{this.installPlugin(e)})}resolveLocale(e){return e?"string"==typeof e?T(e)?e:"en-US":e&&"object"==typeof e&&!T(e.code)?Object.assign(Object.assign({},e),{code:"en-US"}):e:"en-US"}},exports.CalendarRegistry=c,exports.CalendarRenderer=class{constructor(e){this.app=e,this.container=null,this.customRenderingStore=new ve,this.unsubscribe=null,this.renderRequested=!1,this.unsubscribe=e.subscribe(()=>this.requestRender())}requestRender(){this.renderRequested||(this.renderRequested=!0,requestAnimationFrame(()=>{this.render(),this.renderRequested=!1}))}mount(e){this.container=e,this.requestRender()}unmount(){this.container&&(n.render(null,this.container),this.container=null),this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null)}getCustomRenderingStore(){return this.customRenderingStore}render(){this.container&&n.render(n.h(fe.Provider,{value:this.customRenderingStore},n.h(pa,{app:this.app})),this.container)}},exports.CustomRenderingStore=ve,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=E,exports.LocaleContext=Be,exports.TIME_STEP=U,exports.VIRTUAL_MONTH_SCROLL_CONFIG=i,exports.WeekDataCache=s,exports.addDays=$,exports.buildParseRegExp=ft,exports.calculateDayIndex=se,exports.capitalize=Fe,exports.conditionalTheme=(e,t,n)=>e?t:n,exports.convertDateEvent=function(e,t,n,a,r=!1,o){return Et(Object.assign({id:e,title:t,start:n,end:a,allDay:r},o))},exports.convertDateEventWithTimeZone=function(e,t,n,a,r,o){return kt(Object.assign({id:e,title:t,start:n,end:a,timeZone:r},o))},exports.createAllDayEvent=function(e,t,n,a){return Et(Object.assign({id:e,title:t,start:n,end:n,allDay:!0},a))},exports.createDateWithHour=Y,exports.createDayView=wr,exports.createDragPlugin=function(e={}){const t=Object.assign({enableDrag:!0,enableResize:!0,enableCreate:!0,enableAllDayCreate:!0,supportedViews:[exports.ViewType.DAY,exports.ViewType.WEEK,exports.ViewType.MONTH,exports.ViewType.YEAR]},e),n={getConfig:()=>t,updateConfig:e=>{Object.assign(t,e)},isViewSupported:e=>t.supportedViews.includes(e)};return{name:"drag",config:t,install:()=>{m.log("Drag plugin installed - providing drag capabilities")},api:n}},exports.createEvent=Et,exports.createEventWithDate=(e,t)=>{var n,a;const r=le(t,null!==(n=e.day)&&void 0!==n?n:0),o=null!==(a=e.allDay)&&void 0!==a&&a;return Object.assign(Object.assign({},e),{start:ie(r,o),end:ie(r,o)})},exports.createEventWithRealDate=(e,t)=>{var n,a;const r=new Date(t);r.setDate(t.getDate()+(null!==(n=e.day)&&void 0!==n?n:0));const o=null!==(a=e.allDay)&&void 0!==a&&a;return Object.assign(Object.assign({},e),{start:ie(r,o),end:ie(r,o)})},exports.createEvents=function(e){return e.map(e=>Et(e))},exports.createEventsPlugin=function(e={}){const t=Object.assign(Object.assign({},zr),e);let n;const a={getAll:()=>n.getAllEvents(),getById:e=>n.getAllEvents().find(t=>t.id===e),add:e=>{if(t.enableValidation){const t=a.validateEvent(e);if(t.length>0)throw new Error(`Event validation failed: ${t.join(", ")}`)}if(t.maxEventsPerDay&&void 0!==e.day){if(a.getByDay(e.day,n.getCurrentDate()).length>=t.maxEventsPerDay)throw new Error(`Maximum events per day (${t.maxEventsPerDay}) exceeded`)}if(n.addEvent(e),t.enableAutoRecalculate){const e=r(n.getCurrentDate()),t=de(n.getAllEvents(),e);n.state.events=t}},update:(e,o)=>{const l=a.getById(e);if(!l)throw new Error(`Event with id ${e} not found`);const i=Object.assign(Object.assign({},l),o);if(t.enableValidation){const e=a.validateEvent(i);if(e.length>0)throw new Error(`Event validation failed: ${e.join(", ")}`)}if(n.updateEvent(e,o),t.enableAutoRecalculate){const e=r(n.getCurrentDate()),t=de(n.getAllEvents(),e);n.state.events=t}return n.getAllEvents().find(t=>t.id===e)},delete:e=>{n.deleteEvent(e)},getByDate:e=>n.getAllEvents().filter(t=>{const n=H(t.start);n.setHours(0,0,0,0);const a=new Date(e);return a.setHours(0,0,0,0),n.getTime()===a.getTime()}),getByDateRange:(e,t)=>n.getAllEvents().filter(n=>{const a=H(n.start),r=H(n.end);return a>=e&&a<=t||r>=e&&r<=t||a<=e&&r>=t}),getByDay:(e,t)=>n.getAllEvents().filter(t=>t.day===e),getAllDayEvents:(e,t)=>t.filter(t=>t.day===e&&t.allDay),recalculateEventDays:(e,t)=>de(e,t),validateEvent:e=>{const t=[];return e.title&&""!==e.title.trim()||t.push("Event title is required"),e.start||t.push("Event start time is required"),e.end||t.push("Event end time is required"),e.start&&e.end&&!e.allDay&&e.start>=e.end&&t.push("Start time must be before end time"),e.id&&"string"!=typeof e.id&&t.push("Event ID must be a string"),t},filterEvents:(e,t)=>e.filter(t)};function r(e){const t=e.getDay(),n=e.getDate()-t+(0===t?-6:1),a=new Date(e);return a.setDate(n),a.setHours(0,0,0,0),a}return{name:"events",config:t,install:e=>{n=e,m.log("Events plugin installed - providing event management services")},api:a}},exports.createMonthView=Hr,exports.createStandardViews=function(e){return[wr(null==e?void 0:e.day),Sr(null==e?void 0:e.week),Hr(null==e?void 0:e.month)]},exports.createTemporalWithHour=R,exports.createTimedEvent=function(e,t,n,a,r){return Et(Object.assign({id:e,title:t,start:n,end:a},r))},exports.createTimezoneEvent=kt,exports.createTimezoneEvents=function(e){return e.map(e=>kt(e))},exports.createWeekView=Sr,exports.createYearView=(e={})=>{const t=Object.assign(Object.assign({},Yr),e);e.mode&&(t.viewConfig=Object.assign(Object.assign({},t.viewConfig),{mode:e.mode}));const a=e=>n.h(ya,{viewType:exports.ViewType.YEAR,originalComponent:jr,app:e.app,config:t,className:"year-view-factory",customDetailPanelContent:e.customDetailPanelContent,customEventDetailDialog:e.customEventDetailDialog,calendarRef:e.calendarRef,meta:e.meta,selectedEventId:e.selectedEventId,detailPanelEventId:e.detailPanelEventId,onEventSelect:e.onEventSelect,onDetailPanelToggle:e.onDetailPanelToggle});return a.displayName="YearViewAdapter",{type:exports.ViewType.YEAR,component:a,config:t}},exports.dateToPlainDate=st,exports.dateToPlainDateTime=dt,exports.dateToZonedDateTime=ct,exports.daysBetween=function(e,n){const a=e=>S(e)?e:"function"==typeof e.toPlainDate?e.toPlainDate():t.Temporal.PlainDate.from({year:e.year,month:e.month,day:e.day}),r=a(e),o=a(n);return r.until(o).days},exports.daysDifference=L,exports.de=w,exports.downloadICS=zt,exports.en=p,exports.es=C,exports.extractHourFromDate=j,exports.extractHourFromTemporal=function(e){return e instanceof Date?e.getHours()+e.getMinutes()/60:rt(e)?0:e.hour+e.minute/60},exports.formatDate=e=>{const t=e.year,n=e.month;return`${e.day} ${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][n-1]} ${t}`},exports.formatDateConsistent=at,exports.formatDateToICSTimestamp=At,exports.formatEventTimeRange=q,exports.formatICSDate=Pt,exports.formatMonthYear=e=>`${["January","February","March","April","May","June","July","August","September","October","November","December"][e.getMonth()]} ${e.getFullYear()}`,exports.formatTemporal=xt,exports.formatTime=Z,exports.fr=D,exports.generateDayData=te,exports.generateICS=Yt,exports.generateUniKey=ue,exports.generateWeekData=ne,exports.generateWeekRange=re,exports.generateWeeksData=(e,t=3)=>{const n=5*t,{monday:a}=ee(e),r=[],o=Math.floor(n/2),l=new Date(a);l.setDate(l.getDate()-7*o);for(let e=0;e<n;e++){const t=new Date(l);t.setDate(t.getDate()+7*e),r.push(ne(t))}return r},exports.getAllDayEventsForDay=(e,t,n)=>t.filter(t=>{if(!t.allDay)return!1;if(!n)return t.day===e;const a=new Date(n);a.setDate(n.getDate()+e),a.setHours(0,0,0,0);const r=H(t.start);r.setHours(0,0,0,0);const o=H(t.end);return o.setHours(0,0,0,0),a>=r&&a<=o}),exports.getCurrentWeekDates=()=>{const e=new Date,t=new Date,n=e.getDay(),a=e.getDate()-n+(0===n?-6:1);return G.map((n,r)=>{const o=new Date(e);return o.setDate(a+r),{date:o.getDate(),month:o.toLocaleString("default",{month:"short"}),isToday:o.getDate()===t.getDate()&&o.getMonth()===t.getMonth()&&o.getFullYear()===t.getFullYear()}})},exports.getDateByDayIndex=le,exports.getDateObj=Tt,exports.getDayIndexByDate=(e,t)=>{const n=new Date(e);n.setHours(0,0,0,0);const a=new Date(t);a.setHours(0,0,0,0);const r=a.getTime()-n.getTime();return Math.floor(r/864e5)},exports.getEndOfDay=z,exports.getEndOfTemporal=A,exports.getEventBgColor=V,exports.getEventEndHour=X,exports.getEventTextColor=_,exports.getEventsForDay=oe,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 a=H(e.start);return a>=t&&a<=n}).map(e=>{const n=se(H(e.start),t);return Object.assign(Object.assign({},e),{day:n})})},exports.getIntlLabel=ze,exports.getLineColor=B,exports.getMonthLabels=_e,exports.getMonthYearOfWeek=ae,exports.getPlainDate=ut,exports.getSearchHeaderInfo=Nt,exports.getSelectedBgColor=W,exports.getStartOfDay=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(0,0,0,0),t}return P(e)},exports.getStartOfTemporal=P,exports.getTestEvents=function(){const e=new Date,n=e.getDay(),a=new Date(e),r=0===n?-6:1-n;return a.setDate(e.getDate()+r),a.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(a);if(n.setDate(a.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 r=Math.floor(e.startHour),o=Math.round(60*(e.startHour-r)),l=Math.floor(e.endHour),i=Math.round(60*(e.endHour-l));return{id:e.id,title:e.title,start:t.Temporal.ZonedDateTime.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate(),hour:r,minute:o,timeZone:t.Temporal.Now.timeZoneId()}),end:t.Temporal.ZonedDateTime.from({year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate(),hour:l,minute:i,timeZone:t.Temporal.Now.timeZoneId()}),allDay:!1,calendarId:e.calendarId,day:e.day}})},exports.getWeekDaysLabels=Ve,exports.getWeekRange=ee,exports.getZoneId=yt,exports.groupSearchResults=Mt,exports.importICSFile=_t,exports.isDate=function(e){return e instanceof Date},exports.isDeepEqual=ge,exports.isEventEqual=ce,exports.isEventInWeek=(e,t)=>{const n=se(e,t);return n>=0&&n<=6},exports.isMultiDayEvent=(e,t)=>!F(e,t),exports.isMultiDayTemporalEvent=function(e,t){return!O(e,t)},exports.isPlainDate=rt,exports.isPlainDateTime=ot,exports.isSameDay=F,exports.isSamePlainDate=O,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=ut(e),a=ut(t);return n.equals(a)},exports.isValidLocale=T,exports.isZonedDateTime=lt,exports.ja=b,exports.ko=x,exports.mergeClasses=(...e)=>e.filter(Boolean).join(" "),exports.mergeFormatTemplate=mt,exports.monthNames=J,exports.normalizeCssWidth=v,exports.normalizeDate=St,exports.normalizeLocale=k,exports.normalizeToZoned=bt,exports.now=function(e=t.Temporal.Now.timeZoneId()){return t.Temporal.Now.zonedDateTimeISO(e)},exports.pad=ht,exports.parseICS=$t,exports.parseICSDate=Ot,exports.parseTemporalString=pt,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=de,exports.resolveAppliedTheme=Dt,exports.roundToTimeStep=K,exports.scrollbarTakesSpace=f,exports.setHourInTemporal=function(e,t){const n=Math.floor(t),a=Math.round(60*(t-n));return lt(e),e.with({hour:n,minute:a,second:0,millisecond:0})},exports.shortMonthNames=Q,exports.t=We,exports.temporalToDate=it,exports.themeClasses={container:"bg-white dark:bg-gray-900",card:"bg-white dark:bg-gray-800",sidebar:"bg-gray-50 dark:bg-gray-900",text:"text-gray-900 dark:text-gray-100",textMuted:"text-gray-500 dark:text-gray-400",textSubtle:"text-gray-600 dark:text-gray-300",textEmphasis:"text-gray-900 dark:text-white",border:"border-gray-200 dark:border-gray-700",borderLight:"border-gray-100 dark:border-gray-800",borderStrong:"border-gray-300 dark:border-gray-600",bgPrimary:"bg-white dark:bg-gray-900",bgSecondary:"bg-gray-50 dark:bg-gray-800",bgTertiary:"bg-gray-100 dark:bg-gray-700",bgMuted:"bg-gray-100 dark:bg-gray-800",hover:"hover:bg-gray-100 dark:hover:bg-gray-800",hoverSubtle:"hover:bg-gray-50 dark:hover:bg-gray-900",active:"bg-gray-200 dark:bg-gray-700",focus:"focus:ring-primary",input:"bg-white dark:bg-gray-700 border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100",inputFocus:"focus:border-primary focus:ring-primary",buttonPrimary:"bg-primary text-primary-foreground hover:bg-primary/90",buttonSecondary:"bg-gray-200 dark:bg-gray-700 text-gray-900 dark:text-gray-100 hover:bg-gray-300 dark:hover:bg-gray-600",buttonDanger:"bg-destructive text-destructive-foreground hover:bg-destructive/90",buttonSuccess:"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-200 hover:bg-blue-200 dark:hover:bg-blue-800",shadow:"shadow-sm dark:shadow-gray-900/50",shadowMd:"shadow-md dark:shadow-gray-900/50",shadowLg:"shadow-lg dark:shadow-gray-900/50",divider:"border-gray-200 dark:border-gray-700"},exports.themeCn=(e,t,n)=>`${e} ${t} ${n.split(" ").filter(Boolean).map(e=>`dark:${e}`).join(" ")}`.trim(),exports.today=function(e=t.Temporal.Now.timeZoneId()){return t.Temporal.Now.plainDateISO(e)},exports.updateEventDateAndDay=(e,n,a)=>{const r=le(a,n);return Object.assign(Object.assign({},e),{day:n,start:e.allDay?t.Temporal.PlainDate.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate()}):t.Temporal.ZonedDateTime.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate(),hour:r.getHours(),minute:r.getMinutes(),timeZone:t.Temporal.Now.timeZoneId()}),end:e.allDay?t.Temporal.PlainDate.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate()}):t.Temporal.ZonedDateTime.from({year:r.getFullYear(),month:r.getMonth()+1,day:r.getDate(),hour:r.getHours(),minute:r.getMinutes(),timeZone:t.Temporal.Now.timeZoneId()})})},exports.updateEventWithRealDate=(e,t,n)=>{var a;const r=new Date(n);r.setDate(n.getDate()+t);const o=null!==(a=e.allDay)&&void 0!==a&&a;return Object.assign(Object.assign({},e),{day:t,start:ie(r,o),end:ie(r,o)})},exports.useLocale=Ue,exports.weekDays=G,exports.weekDaysFullName=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],exports.zh=y,exports.zonedDateTimeToDate=I;