@dayflow/core 2.0.3 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e,t=require("react"),n=require("temporal-polyfill"),a=require("tslib"),r=require("react/jsx-runtime"),o=require("react-dom"),s=require("react-color"),l=require("lucide-react"),i=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 d=100,c=8,u=150,g=80,m=90,h=119;class v{constructor(e=d){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 f=[{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 p{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)}):f.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 y=new p;function x(){return y}function b(e){const t=f.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 D=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 w(e,t="240px"){return"number"==typeof e?`${e}px`:"string"==typeof e&&e.trim().length>0?e:t}const C={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"}},E={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:"明天"}},k={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:"明日"}},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:"내일"}},T={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"}},S={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"}},N={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"}},M={en:C,zh:E,ja:k,ko:j,fr:T,de:S,es:N};function I(e){const t=e.split("-")[0].toLowerCase();return t in M?t:"en"}function H(e){try{return new Intl.DateTimeFormat(e),!0}catch(e){return!1}}function R(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 O(e,t=n.Temporal.Now.timeZoneId()){return n.Temporal.Instant.fromEpochMilliseconds(e.getTime()).toZonedDateTimeISO(t)}function P(e){return n.Temporal.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()})}function L(e){return new Date(e.epochMilliseconds)}function A(e,t){return R(e)?function(e,t=n.Temporal.Now.timeZoneId()){return L(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):L(e)}function $(e,t){const a=Math.floor(t),r=Math.round(60*(t-a));return R(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 z(e,t){const a=R(e)?e:e.toPlainDate(),r=R(t)?t:t.toPlainDate();return 0===n.Temporal.PlainDate.compare(a,r)}function Y(e,t=n.Temporal.Now.timeZoneId()){return(R(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(R(e)?e:e.toPlainDate()).toZonedDateTime({timeZone:t,plainTime:n.Temporal.PlainTime.from({hour:23,minute:59,second:59,millisecond:999})})}function V(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 W(e,t){const n=new Date(e);return n.setDate(n.getDate()+t),n}const B=e=>{if(e instanceof Date){return e.getHours()+e.getMinutes()/60}return R(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},Z=(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 $(e,t)},U=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 z(e instanceof Date?n.Temporal.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()}):R(e)?e:e.toPlainDate(),t instanceof Date?n.Temporal.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}):R(t)?t:t.toPlainDate())},_=(e,t)=>(t||x()).resolveColors(e).eventColor,X=(e,t)=>(t||x()).resolveColors(e).textColor,G=(e,t)=>(t||x()).resolveColors(e).eventSelectedColor,K=(e,t)=>(t||x()).resolveColors(e).lineColor,J=.25,Q=(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")}`},ee=e=>{const t=B(e.start),n=ne(e);return`${Q(t)} - ${Q(n)}`},te=e=>{const t=J;return Math.round(e/t)*t},ne=e=>{if(!e.end)return 0;const t=B(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},ae=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],re=["January","February","March","April","May","June","July","August","September","October","November","December"],oe=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],se=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}},le=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:re[a],shortMonthName:oe[a],isToday:o.getDate()===n&&o.getMonth()===a&&o.getFullYear()===r}},ie=e=>{const t=[],n=new Date(e);for(let e=0;e<7;e++){const e=new Date(n);t.push(le(e)),n.setDate(n.getDate()+1)}return{days:t,startDate:new Date(e),monthYear:de(t)}},de=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:re[r],monthIndex:r,year:o}};function ce(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(ie(t))}return n}const ue=(e,t)=>t.filter(t=>t.day===e&&!t.allDay),ge=(e,t)=>{const n=new Date(e);return n.setDate(e.getDate()+t),n},me=(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()}),he=(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=he(n,t);return Object.assign(Object.assign({},e),{day:a})}),fe=(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 pe(){return Date.now().toString(36)+Math.random().toString(36).substring(2,8)}function ye(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)||!ye(e[r],t[r]))return!1;return!0}const xe="240px",be=e=>{if(!e)return{enabled:!1,width:xe,initialCollapsed:!1};if(!0===e)return{enabled:!0,width:xe,initialCollapsed:!1};const{enabled:t=!0,width:n,initialCollapsed:a=!1,render:r,createCalendarMode:o,renderCalendarContextMenu:s,renderCreateCalendarDialog:l}=e;return{enabled:t,width:w(n,xe),initialCollapsed:a,render:r,createCalendarMode:o,renderCalendarContextMenu:s,renderCreateCalendarDialog:l}};class De{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)):D.warn("Cannot add event in read-only mode")},this.updateEvent=(e,t,n)=>{if(!this.isInternalEditable()&&!n)return void D.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 D.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)?D.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||ye(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=be(e.useSidebar);ye(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);ye(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 p(e.calendars,e.defaultCalendar,(null===(n=e.theme)||void 0===n?void 0:n.mode)||"light"),s=this.calendarRegistry,y=s,this.sidebarConfig=be(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 we(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 Ce(e){return e.charAt(0).toUpperCase()+e.slice(1)}const Ee=(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},ke=(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=we(e,t);if(n)return Ce(n)}const a=I(t),r=M[a],o=null===(n=null==r?void 0:r.messages)||void 0===n?void 0:n[e];if(o)return o;const s=M.en.messages;return(null==s?void 0:s[e])||e}const Te=t.createContext({locale:"en-US",t:e=>e,getWeekDaysLabels:()=>[],getMonthLabels:()=>[],isDefault:!0});function Se(){return t.useContext(Te)}const Ne=({x:e,y:n,onClose:a,children:s,className:l})=>{const i=t.useRef(null);t.useEffect(()=>{const e=e=>{i.current&&!i.current.contains(e.target)&&a()};document.addEventListener("mousedown",e);const t=()=>a();return window.addEventListener("scroll",t,!0),window.addEventListener("resize",t),()=>{document.removeEventListener("mousedown",e),window.removeEventListener("scroll",t,!0),window.removeEventListener("resize",t)}},[a]);const d={top:n,left:e};return o.createPortal(r.jsx("div",{ref:i,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:d,onContextMenu:e=>e.preventDefault(),children:s}),document.body)},Me=({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]}),Ie=()=>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}),Re=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],Oe=({selectedColor:e,onSelect:t,onCustomColor:n})=>{const{t:a}=Se();return r.jsxs("div",{className:"p-2",children:[r.jsx("div",{className:"grid grid-cols-7 gap-2 p-1",children:Re.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")})]})},Pe=({isCollapsed:e,onCollapseToggle:t})=>{const{t:n}=Se();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(l.PanelRightClose,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"}):r.jsx(l.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")})})]})},Le=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),[v,f]=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();f(!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(()=>{f(!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]),j=t.useCallback(e=>{u&&(i(e.id),m(e.name))},[i,u]),T=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:"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:"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:Le(e)}),l===e.id?r.jsx("input",{ref:h,type:"text",value:g,onChange:T,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:()=>j(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)})})})},$e="h-full flex flex-col bg-white dark:bg-gray-900 select-none",ze="p-2 flex justify-between",Ye="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)",Ve="inline-flex items-center justify-center h-6 w-6 rounded-full text-sm mt-1 select-none",We="flex-1 overflow-auto will-change-scroll",Be="relative h-[4.5rem] flex",Ze="absolute -top-2.5 right-2 text-[12px] text-gray-500 dark:text-gray-400 select-none",Ue="h-[4.5rem] border-t first:border-none border-gray-200 dark:border-gray-700 flex",qe="absolute left-0 top-0 flex pointer-events-none",_e="ml-2 text-primary-foreground text-xs font-bold px-1.5 bg-primary rounded-sm",Xe="flex items-center border-b border-gray-200 dark:border-gray-700 sticky",Ge="calendar-event select-none pointer-events-auto px-0.5",Ke="rounded-xl my-0.5",Je="font-medium text-xs truncate pr-1",Qe="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="text-gray-600 dark:text-gray-300",rt="text-xs",ot="text-sm",st="flex flex-col",lt="mr-1",it=({visibleMonth:e,currentDate:n,showHeader:a=!1,onMonthChange:o,onDateSelect:s})=>{const{locale:i}=Se(),d=t.useMemo(()=>(new Date).toDateString(),[]),c=n.toDateString(),u=t.useMemo(()=>Ee(i,"narrow"),[i]),g=t.useMemo(()=>e.toLocaleDateString(i,{month:"long",year:"numeric"}),[e,i]),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(l.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(l.ChevronRight,{className:"h-4 w-4"})})]}):"",r.jsxs("div",{className:"grid grid-cols-7 gap-1 text-xs justify-items-center",children:[u.map((e,t)=>r.jsx("div",{className:"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 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()))]})]})},dt=({calendars:e,currentCalendarId:n,onMergeSelect:a})=>{const{t:s}=Se(),[i,d]=t.useState(!1),c=t.useRef(null),u=t.useRef(null),[g,m]=t.useState({x:0,y:0}),h=t.useRef(),v=()=>{if(h.current&&clearTimeout(h.current),c.current){const e=c.current.getBoundingClientRect();m({x:e.right,y:e.top})}d(!0)},f=()=>{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)}}},[i]);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:v,onMouseLeave:f,children:[r.jsx("span",{children:s("merge")}),r.jsx(l.ChevronRight,{className:"h-4 w-4"})]}),i&&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:v,onMouseLeave:f,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)]})},ct=({sourceName:e,targetName:t,onConfirm:n,onCancel:a})=>{const{t:o}=Se();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")})]})]})})},ut=({calendarId:e,calendarName:n,calendars:a,step:o,onStepChange:s,onConfirmDelete:l,onCancel:i,onMergeSelect:d})=>{const[c,u]=t.useState(!1),{t:g}=Se();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")})]})]})})})},gt=({app:e,calendars:n,toggleCalendarVisibility:a,isCollapsed:l,setCollapsed:i,renderCalendarContextMenu:d,editingCalendarId:c,setEditingCalendarId:u,onCreateCalendar:g})=>{var m,h,v,f;const{t:p}=Se(),y=e.getVisibleMonth(),x=y.getFullYear(),D=y.getMonth(),[w,C]=t.useState(null),E=void 0!==c?c:w,k=u||C,[j,T]=t.useState(()=>new Date(x,D,1));t.useEffect(()=>{T(e=>e.getFullYear()===x&&e.getMonth()===D?e:new Date(x,D,1))},[x,D]);const S=t.useCallback(t=>{T(n=>{const a=new Date(n.getFullYear(),n.getMonth()+t,1);return e.setVisibleMonth(a),a})},[e]),[N,M]=t.useState(null),[I,H]=t.useState(null),[R,O]=t.useState(null),[P,L]=t.useState(null),[A,$]=t.useState(null),z=t.useCallback((e,t)=>{e.preventDefault(),e.stopPropagation(),M({x:e.clientX,y:e.clientY,calendarId:t}),H(null)},[]),Y=t.useCallback(e=>{e.preventDefault(),H({x:e.clientX,y:e.clientY}),M(null)},[]),F=t.useCallback(()=>{M(null)},[]),V=t.useCallback(()=>{H(null)},[]),W=t.useCallback(()=>{N&&($({calendarId:N.calendarId,step:"initial"}),F())},[N,F]),B=t.useCallback(t=>{if(N){const{colors:n,darkColors:a}=b(t);e.updateCalendar(N.calendarId,{colors:n,darkColors:a}),F()}},[e,N,F]),Z=t.useCallback(()=>{if(N){const e=n.find(e=>e.id===N.calendarId);e&&O({x:N.x,y:N.y,calendarId:N.calendarId,initialColor:e.colors.lineColor,currentColor:e.colors.lineColor}),F()}},[N,n,F]),U=t.useCallback(e=>{N&&(L({sourceId:N.calendarId,targetId:e}),F())},[N,F]),q=t.useCallback(()=>{if(P){const{sourceId:t,targetId:n}=P;e.mergeCalendars(t,n),L(null)}},[e,P]),_=t.useCallback(()=>{A&&(e.deleteCalendar(A.calendarId),$(null))},[e,A]),X=t.useCallback(e=>{A&&(L({sourceId:A.calendarId,targetId:e}),$(null))},[A]),G=P?(null===(m=n.find(e=>e.id===P.sourceId))||void 0===m?void 0:m.name)||"Unknown":"",K=P?(null===(h=n.find(e=>e.id===P.targetId))||void 0===h?void 0:h.name)||"Unknown":"",J=A?(null===(v=n.find(e=>e.id===A.calendarId))||void 0===v?void 0:v.name)||"Unknown":"",Q=e.getReadOnlyConfig(),ee=!e.state.readOnly,te=!1!==Q.draggable;return r.jsxs("div",{className:"flex h-full flex-col border-r border-gray-200 dark:border-gray-700 bg-white dark:bg-slate-900",onContextMenu:ee?Y:void 0,children:[r.jsx(Pe,{isCollapsed:l,onCollapseToggle:()=>i(!l)}),l?r.jsx(Ae,{calendars:n,onToggleVisibility:a,onReorder:te?e.reorderCalendars:()=>{},onRename:ee?(t,n)=>e.updateCalendar(t,{name:n}):()=>{},onContextMenu:ee?z:()=>{},editingId:E,setEditingId:k,activeContextMenuCalendarId:null==N?void 0:N.calendarId,isDraggable:te,isEditable:ee}):r.jsxs(r.Fragment,{children:[r.jsx(Ae,{calendars:n,onToggleVisibility:a,onReorder:te?e.reorderCalendars:()=>{},onRename:ee?(t,n)=>e.updateCalendar(t,{name:n}):()=>{},onContextMenu:ee?z:()=>{},editingId:E,setEditingId:k,activeContextMenuCalendarId:null==N?void 0:N.calendarId,isDraggable:te,isEditable:ee}),r.jsx("div",{className:"border-t border-gray-200 dark:border-slate-800",children:r.jsx(it,{visibleMonth:e.getVisibleMonth(),currentDate:e.getCurrentDate(),showHeader:!0,onMonthChange:S,onDateSelect:t=>e.setCurrentDate(t)})})]}),N&&r.jsx(Ne,{x:N.x,y:N.y,onClose:F,className:"w-64 p-2",children:d?d(n.find(e=>e.id===N.calendarId),F):r.jsxs(r.Fragment,{children:[r.jsx(He,{children:p("calendarOptions")}),r.jsx(dt,{calendars:n,currentCalendarId:N.calendarId,onMergeSelect:U}),r.jsx(Me,{onClick:W,children:p("delete")}),r.jsx(Ie,{}),r.jsx(Oe,{selectedColor:null===(f=n.find(e=>e.id===N.calendarId))||void 0===f?void 0:f.colors.lineColor,onSelect:B,onCustomColor:Z})]})}),I&&o.createPortal(r.jsxs(Ne,{x:I.x,y:I.y,onClose:V,className:"w-max p-2",children:[r.jsx(Me,{onClick:()=>{null==g||g(),V()},children:p("newCalendar")||"New Calendar"}),r.jsx(Me,{onClick:()=>{e.triggerRender(),V()},children:p("refreshAll")||"Refresh All"})]}),document.body),P&&o.createPortal(r.jsx(ct,{sourceName:G,targetName:K,onConfirm:q,onCancel:()=>L(null)}),document.body),A&&o.createPortal(r.jsx(ut,{calendarId:A.calendarId,calendarName:J,calendars:n,step:A.step,onStepChange:e=>$(t=>t?Object.assign(Object.assign({},t),{step:e}):null),onConfirmDelete:_,onCancel:()=>$(null),onMergeSelect:X}),document.body),R&&o.createPortal(r.jsx("div",{className:"fixed inset-0 z-50",onMouseDown:()=>O(null),children:r.jsx("div",{className:"absolute rounded-md bg-white shadow-xl border border-gray-200 dark:bg-slate-800 dark:border-gray-700",style:{top:R.y,left:R.x},onMouseDown:e=>e.stopPropagation(),children:r.jsx(s.SketchPicker,{width:"220px",color:R.currentColor,onChange:e=>{O(t=>t?Object.assign(Object.assign({},t),{currentColor:e.hex}):null)},onChangeComplete:t=>{const{colors:n,darkColors:a}=b(t.hex);e.updateCalendar(R.calendarId,{colors:n,darkColors:a})}})})}),document.body)]})},mt=({options:e,value:n,onChange:a,registry:s,variant:i="desktop"})=>{const[d,c]=t.useState(!1),[u,g]=t.useState({}),m=t.useRef(null),h=t.useRef(null),v=()=>{if(h.current){const e=h.current.getBoundingClientRect(),t="mobile"===i,n={position:"fixed",zIndex:10001,minWidth:t?"12rem":`${e.width}px`,top:`${e.bottom+4}px`};t?n.right=window.innerWidth-e.right+"px":n.left=`${e.left}px`,g(n)}};t.useEffect(()=>{const e=e=>{!m.current||m.current.contains(e.target)||e.target.closest("[data-color-picker-dropdown]")||c(!1)};return d&&(v(),window.addEventListener("mousedown",e),window.addEventListener("scroll",v,!0),window.addEventListener("resize",v)),()=>{window.removeEventListener("mousedown",e),window.removeEventListener("scroll",v,!0),window.removeEventListener("resize",v)}},[d]);const f=e=>(s||x()).resolveColors(e).lineColor,p=(e,t)=>{e.stopPropagation(),a(t),c(!1)},y=e.find(e=>e.value===n),b=()=>d&&"undefined"!=typeof window?"mobile"===i?o.createPortal(r.jsx("div",{"data-color-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(l.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:f(e.value)}})]},e.value))}),document.body):o.createPortal(r.jsx("ul",{"data-color-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(l.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:f(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"===i?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:f(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(l.ChevronsUpDown,{className:"w-4 h-4 text-gray-400"})]}),b()]}):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:f(n)}}),r.jsx(l.ChevronsUpDown,{className:"w-4 h-4 text-gray-600 dark:text-gray-300"})]}),b()]})},ht=/(YYYY|YY|MM|DD|HH|mm)/g,vt=e=>e.toString().padStart(2,"0"),ft=(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`)},pt=e=>e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),yt=e=>{let t,n=0,a="^";for(;null!==(t=ht.exec(e));){a+=pt(e.slice(n,t.index));const r=t[0];a+=`(?<${r}>\\d{${"YYYY"===r?4:2}})`,n=t.index+r.length}return a+=pt(e.slice(n))+"$",new RegExp(a)},xt=(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}},bt=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()},Dt=(e,t,a)=>{var r,o,s,l,i,d,c,u,g,m,h,v,f,p,y,x,b,D,w,C,E,k,j,T;if(!e){const e=null!=t?t:a?bt(a):n.Temporal.Now.timeZoneId();return null!=a?a:n.Temporal.Now.zonedDateTimeISO(e)}if(R(e)){const a=null!=t?t:n.Temporal.Now.timeZoneId(),r=`${e.year}-${vt(e.month)}-${vt(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?bt(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!==(v=null==o?void 0:o.day)&&void 0!==v?v:l.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!==(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!==(T=null!==(j=null==o?void 0:o.nanosecond)&&void 0!==j?j:null==a?void 0:a.nanosecond)&&void 0!==T?T:0})}},wt=(e,t,n)=>{const a=ft(t,n),r={YYYY:e.year.toString(),YY:vt(e.year%100),MM:vt(e.month),DD:vt(e.day),HH:vt(e.hour),mm:vt(e.minute)};return a.replace(ht,e=>{var t;return null!==(t=r[e])&&void 0!==t?t:e})},Ct=Array.from({length:24},(e,t)=>t),Et=Array.from({length:60},(e,t)=>t),kt=({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(l.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(l.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(l.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(l.ChevronsRight,{width:14,height:12})})]})]}),jt=(e,t)=>n.Temporal.PlainDate.compare(e,t),Tt=({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===jt(e,n),d=0===jt(e,a),c=jt(e,n)>=0&&jt(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())})})]}),St=({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=Et.includes(d)?Et:[...Et,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:Ct.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:vt(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:vt(e)},e)})})})]})]})},Nt=({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:v,onMinuteSelect:f,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(kt,{visibleMonth:e,monthLabels:t,disabled:i,onMonthChange:g,onYearChange:m}),r.jsx(Tt,{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(St,{focusedField:s,draftRange:o,disabled:i,onHourSelect:v,onMinuteSelect:f,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"})})]})})},Mt=({value:e,format:a="YYYY-MM-DD HH:mm",showTimeFormat:s="HH:mm",showTime:i=!0,onChange:d,onOk:c,timeZone:u,disabled:g=!1,placement:m="bottomLeft",autoAdjustOverflow:h=!0,getPopupContainer:v,matchTriggerWidth:f=!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===i||("object"==typeof i||Boolean(i)),[i]),b=t.useMemo(()=>ke(y,"short"),[y]),D=t.useMemo(()=>Ee(y,"narrow"),[y]),w=t.useMemo(()=>x?"object"==typeof i&&(null==i?void 0:i.format)?i.format:s:"",[x,i,s]),C=t.useMemo(()=>ft(a,w),[a,w]),E=t.useMemo(()=>yt(C),[C]),k=t.useMemo(()=>{const t=null!=u?u:R(e[0])?R(e[1])?n.Temporal.Now.timeZoneId():bt(e[1]):bt(e[0]),a=Dt(e[0],t);return[a,Dt(e[1],t,a)]},[e,u]),[j,T]=t.useState(k),S=t.useRef(k),[N,M]=t.useState("start"),[I,H]=t.useState([wt(k[0],a,w),wt(k[1],a,w)]),O=t.useRef([wt(k[0],a,w),wt(k[1],a,w)]),P=t.useRef(k),[L,A]=t.useState(k[0].toPlainDate().with({day:1})),[$,z]=t.useState(!1),Y=t.useCallback(e=>{z(e)},[]),[F,V]=t.useState(m),W=t.useRef(m),B=t.useRef(null),Z=t.useRef(null),U=t.useRef({start:{hour:null,minute:null},end:{hour:null,minute:null}}),q=t.useRef(!1);t.useEffect(()=>{O.current=I},[I]),t.useEffect(()=>{P.current=j},[j]),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)&&T(k),S.current=k},[k]),t.useEffect(()=>{A(k[0].toPlainDate().with({day:1}))},[k[0]]);const _=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})},[]),X=t.useCallback(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=U.current[e];["hour","minute"].forEach(e=>{const n=t[e];if(!n)return;const a=n.querySelector('[data-active="true"]');a&&_(n,a,0)})})})},[_]);t.useEffect(()=>{$&&x&&X(N)},[N,$,X,x]);const G=j[0].epochMilliseconds,K=j[0].offsetNanoseconds,J=j[1].epochMilliseconds,Q=j[1].offsetNanoseconds;t.useEffect(()=>{const[e,t]=P.current,n=wt(e,a,w),r=wt(t,a,w),[o,s]=O.current;o===n&&s===r||(O.current=[n,r],H([n,r]))},[G,K,J,Q,a,w]),t.useEffect(()=>{if(!$)return;const e=e=>{var t,n;const a=e.target;if(null===(t=B.current)||void 0===t?void 0:t.contains(a))return;if(null===(n=Z.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)}},[$]),t.useEffect(()=>{$||(M("start"),q.current||T(k),q.current=!1)},[$,k]);const ee=t.useCallback(e=>{d&&d(e,[wt(e[0],a,w),wt(e[1],a,w)])},[w,a,d]),te=t.useCallback(e=>{c&&c(e,[wt(e[0],a,w),wt(e[1],a,w)])},[w,a,c]),ne=t.useCallback((e,t)=>{T(a=>{const r=[...a];if("start"===e){const e=Dt(r[1],bt(t),t),a=n.Temporal.ZonedDateTime.compare(t,e)>0?t:e;return[t,a]}const o=Dt(r[0],bt(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=bt(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(j[0],e),a=j[1].epochMilliseconds-j[0].epochMilliseconds,r=n.add({milliseconds:a});return void T([n,r])}const a=t(j[1],e),r=j[1].epochMilliseconds-j[0].epochMilliseconds;if(n.Temporal.ZonedDateTime.compare(a,j[0])<0){const n=t(j[0],e),a=n.add({milliseconds:r});return void T([n,a])}const o=[j[0],a];T(o),A(a.toPlainDate().with({day:1}))},re=t.useCallback((e,t)=>{if(g)return;const a="start"===e?0:1;T(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=Dt(r[1],bt(s),s);return[s,n.Temporal.ZonedDateTime.compare(s,e)>0?s:e]}const l=Dt(r[0],bt(s),s);return[n.Temporal.ZonedDateTime.compare(l,s)>0?s:l,s]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=U.current[e].hour;if(!t)return;const n=t.querySelector('[data-active="true"]');n&&_(t,n,0)})})},[g]),oe=t.useCallback((e,t)=>{if(g)return;const a="start"===e?0:1;T(r=>{const o=r[a].with({minute:t,second:0,millisecond:0,microsecond:0,nanosecond:0});if("start"===e){const e=Dt(r[1],bt(o),o);return[o,n.Temporal.ZonedDateTime.compare(o,e)>0?o:e]}const s=Dt(r[0],bt(o),o);return[n.Temporal.ZonedDateTime.compare(s,o)>0?o:s,o]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=U.current[e].minute;if(!t)return;const n=t.querySelector('[data-active="true"]');n&&_(t,n,0)})})},[g]),se=t.useCallback((e,t)=>{const n="start"===e?0:1;H(e=>{const a=[...e];return a[n]=t,a})},[]),le=t.useCallback((e,t)=>{const n="start"===e?0:1,r=j[n],o=bt(r),s=xt(t,E,r,o);if(s){ne(e,s);const t=s.toPlainDate().with({day:1});return A(t),"start"===e&&M("end"),!0}return H(e=>{const t=[...e];return t[n]=wt(j[n],a,w),t}),!1},[j,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($)return;const a=t.relatedTarget;a&&(null===(n=B.current)||void 0===n?void 0:n.contains(a))||le(e,t.target.value)},[le,g,$]),ce=t.useCallback(e=>t=>{"Enter"===t.key&&(t.preventDefault(),le(e,t.currentTarget.value)),"Escape"===t.key&&t.currentTarget.blur()},[le]),ue=()=>{q.current=!0,ee(j),te(j),Y(!1)},ge=e=>{A(t=>t.add({months:e}).with({day:1}))},me=e=>{A(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]),ve=t.useCallback((e=m)=>{if(!h||!B.current)return e;const t=B.current.getBoundingClientRect(),n=f?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,f,m]),fe=t.useCallback(()=>{const e=ve();W.current!==e&&(W.current=e,V(e))},[ve]),pe=e=>{if(g)return;M(e);const t=j["start"===e?0:1].toPlainDate().with({day:1});A(t);const n=ve();W.current!==n&&(W.current=n,V(n)),Y(!0)};t.useEffect(()=>{if(!$)return;fe();const e=()=>fe();return window.addEventListener("resize",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e,!0)}},[$,fe]);const ye=()=>{if(!B.current)return{};const e=B.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,f&&(n.width=`${e.width}px`),n};return r.jsxs("div",{className:"relative max-w-100",ref:B,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":$?"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&&$?" 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(l.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&&$?"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})})]}),$&&(v?o.createPortal(r.jsx(Nt,{visibleMonth:L,monthLabels:b,weekDayLabels:D,calendarDays:he,draftRange:j,focusedField:N,isTimeEnabled:!!x,disabled:g,matchTriggerWidth:f,popupRef:Z,timeListRefs:U,onMonthChange:ge,onYearChange:me,onDaySelect:ae,onHourSelect:re,onMinuteSelect:oe,onOk:ue,getPopupStyle:ye}),v()):o.createPortal(r.jsx(Nt,{visibleMonth:L,monthLabels:b,weekDayLabels:D,calendarDays:he,draftRange:j,focusedField:N,isTimeEnabled:!!x,disabled:g,matchTriggerWidth:f,popupRef:Z,timeListRefs:U,onMonthChange:ge,onYearChange:me,onDaySelect:ae,onHourSelect:re,onMinuteSelect:oe,onOk:ue,getPopupStyle:ye}),document.body))]})},It=({event:e,isOpen:a,isAllDay:s,onEventUpdate:l,onEventDelete:i,onClose:d,app:c})=>{var u;const[g,m]=t.useState(e),{t:h}=Se();t.useEffect(()=>{m(e)},[e]);const v=t.useMemo(()=>(c?c.getCalendarRegistry():x()).getVisible().map(e=>({label:e.name,value:e.id})),[c,null==c?void 0:c.getCalendars()]),f=t.useMemo(()=>!fe(e,g),[e,g]),p=t.useMemo(()=>R(g.start)?g.end&&!R(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()}))},b=!(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:"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:!b,disabled:!b,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"})}),b&&r.jsx(mt,{options:v,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(Mt,{value:[g.start,g.end],format:"YYYY-MM-DD",showTime:!1,timeZone:p,matchTriggerWidth:!0,disabled:!b,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(Mt,{value:[g.start,g.end],timeZone:p,disabled:!b,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:!b,disabled:!b,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")})]}),b&&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=R(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=R(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 "+(f?"hover:bg-primary/90 shadow-lg shadow-primary/20":"opacity-50 cursor-not-allowed grayscale-[0.5]"),onClick:()=>{l(g),d()},disabled:!f,children:h("save")})]})]})]})]}),C=document.body;return C?o.createPortal(w,C):null},Ht=({calendar:e,mode:n="buttons"})=>{const[a,o]=t.useState(!1),s=t.useRef(null),{t:i}=Se(),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:i(c)}),r.jsx("span",{className:"text-gray-500 dark:text-gray-400 transition-transform duration-200 "+(a?"rotate-180":""),children:r.jsx(l.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:i(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:i(t)},t))}))},Rt=0,Ot=1970,Pt=2100,Lt=8,At=100,$t=1200,zt=900,Yt=700;class Ft{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}}}Ft.metrics={scrollEvents:0,renderTime:[],cacheHits:0,cacheMisses:0,startTime:Date.now(),frameDrops:0,avgScrollDelta:0,totalScrollDistance:0};const Vt=e=>{if(!e)return"";let t,a,r;e instanceof Date?(t=e.getFullYear(),a=e.getMonth()+1,r=e.getDate()):R(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}`};function Wt(e){return!("hour"in e)}function Bt(e){return"hour"in e&&!("timeZone"in e)}function Zt(e){return"timeZone"in e}function Ut(e){return n.Temporal.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()})}function qt(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 _t(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 Xt=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 Gt(e,t=!1){if(e instanceof n.Temporal.PlainDate||e instanceof n.Temporal.PlainDateTime)return e;if(e instanceof Date)return t?Ut(e):qt(e);throw new Error("Invalid time type: "+typeof e)}function Kt(e,t){if(e instanceof n.Temporal.ZonedDateTime)return e;if(e instanceof Date)return _t(e,t);throw new Error("Invalid time type: "+typeof e)}function Jt(e){var t;const n=Gt(e.start,e.allDay),a=Gt(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 Qt(e){const t=Kt(e.start,e.timeZone),n=Kt(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 en=e=>{try{return e instanceof Date?e:"string"==typeof e?new Date(e):A(e)}catch(e){return new Date}},tn=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},nn=(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}},an=(e,t)=>{const n=new Map;e.forEach(e=>{var t;const a=en(e.start),r=tn(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 rn=null;const on=()=>{const[e,n]=t.useState(()=>rn||{weekHeight:h,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(g,a),screenSize:"mobile",weeksPerView:6}:e<1024?{weekHeight:Math.max(m,a),screenSize:"tablet",weeksPerView:6}:{weekHeight:Math.max(h,a),screenSize:"desktop",weeksPerView:6};rn&&rn.screenSize===r.screenSize&&rn.weekHeight===r.weekHeight&&rn.weeksPerView===r.weeksPerView||(rn=r,n(r))};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e},sn=({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),ce(t,r)},[e,r]),g=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(g),[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),[j,T]=t.useState(!1),S=t.useRef(!1),[N,M]=t.useState(!1),I=t.useRef(e),H=t.useRef(null),R=t.useRef(null),O=t.useRef(new v),P=t.useRef(0),L=t.useRef(0),A=t.useRef(!1),$=t.useCallback(e=>{e&&(H.current=e)},[]),z=t.useCallback(e=>{let t=O.current.get(e);return console.log("weekData",t),t||(t=ie(e),O.current.set(e,t)),t},[]),Y=t.useCallback((e,t=26)=>{A.current||(A.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),H.current&&(H.current.scrollTop+=r)})}}finally{setTimeout(()=>{A.current=!1},200)}},0))},[E,z,n]),F=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]),V=t.useCallback(e=>{if(j||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,j,w,a,m,N]),W=t.useCallback(e=>{const t=performance.now();if(t-P.current<c)return;P.current=t;const a=e.currentTarget,r=a.scrollTop;L.current=r,h(r),j||requestAnimationFrame(()=>{const{scrollHeight:e,clientHeight:t}=a;r+t>e-10*n&&!A.current&&Y("future",26),r<10*n&&!A.current&&Y("past",26)}),C(!0),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>{C(!1)},u)},[n,Y,j]),B=t.useCallback((e,t=!0)=>{if(!H.current)return;T(!0),S.current=!0;const a=()=>{setTimeout(()=>{T(!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 H.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(H.current&&-1!==s){const e=s*n;H.current.scrollTop+=o,h(e=>e+o),setTimeout(()=>{H.current&&H.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(H.current&&-1!==o){const e=o*n;H.current.scrollTo({top:e,behavior:t?"smooth":"auto"})}a()})}else a()},[E,n,z]),Z=t.useCallback(()=>{const e=E[F.displayStartIndex].days[0].date,t=new Date(e.getFullYear(),e.getMonth()-1,1);B(t)},[F.displayStartIndex,E,B]),U=t.useCallback(()=>{const e=E[F.displayStartIndex].days[0].date,t=new Date(e.getFullYear(),e.getMonth()+1,1);B(t)},[F.displayStartIndex,E,B]),q=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=H.current;t&&(T(!0),S.current=!0,requestAnimationFrame(()=>{h(e),requestAnimationFrame(()=>{t&&(t.scrollTop=e,setTimeout(()=>{S.current=!1,T(!1)},200))})}))}else T(!0),S.current=!0,requestAnimationFrame(()=>{B(o,!0),setTimeout(()=>{S.current=!1,T(!1)},200)})},[E,n,a,B]);return t.useEffect(()=>{V(F.visibleItems)},[F.visibleItems,V]),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),B(e,!0)}I.current=e},[e,a,B]),t.useEffect(()=>{const e=H.current;if(!e)return;const t=new ResizeObserver(([e])=>{p(e.contentRect.height)});return t.observe(e),()=>t.disconnect()},[]),t.useEffect(()=>{const e=H.current;e&&!N&&s&&requestAnimationFrame(()=>{e&&g>0?(e.scrollTop=g,h(g),M(!0)):e&&M(!0)})},[N,g,s]),t.useEffect(()=>()=>{R.current&&clearTimeout(R.current)},[]),{scrollTop:m,containerHeight:f,currentMonth:y,currentYear:b,isScrolling:w,virtualData:F,scrollElementRef:H,handleScroll:W,scrollToDate:B,handlePreviousMonth:Z,handleNextMonth:U,handleToday:q,setScrollTop:h,setContainerHeight:p,setCurrentMonth:x,setCurrentYear:D,setIsScrolling:C,cache:O.current,scrollElementRefCallback:$,weeksData:E}},ln=({calendar:e,switcherMode:t="buttons",onAddCalendar:n,onSearchChange:a,onSearchClick:o,searchValue:s="",isSearchOpen:i=!1,isEditable:d=!0})=>{const c="buttons"===t,u=e.state.currentView===exports.ViewType.DAY,{screenSize:g}=on(),m="mobile"===g,{t:h}=Se();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||i?"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:"flex h-7 w-7 items-center justify-center rounded hover:bg-gray-100 dark:hover:bg-slate-800 transition-colors",title:m?h("newEvent")||"New Event":h("createCalendar")||"Add Calendar",children:r.jsx(l.Plus,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"})})}),r.jsx("div",{className:"flex-1 flex justify-center",children:c&&r.jsx(Ht,{mode:t,calendar:e})}),!c&&r.jsx(Ht,{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 flex h-7 w-7 items-center justify-center rounded hover:bg-gray-100 dark:hover:bg-slate-800 transition-colors",children:r.jsx(l.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(l.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"})]})})]})]})]})},dn=t.createContext(void 0),cn=({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=Xt(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(dn.Provider,{value:u,children:e})},un=()=>{const e=t.useContext(dn);if(void 0===e)throw new Error("useTheme must be used within a ThemeProvider");return e},gn=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],mn=({onClose:e,onCreate:n})=>{const[a,l]=t.useState(""),[i,d]=t.useState(gn[Math.floor(Math.random()*gn.length)]),[c,u]=t.useState(!1),[g,m]=t.useState(""),{effectiveTheme:h}=un(),{t:v}=Se(),f="dark"===h,p={default:{picker:{background:f?"#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:f?"1px solid #4b5563":"1px solid #e5e7eb"},head:{background:f?"#1e293b":"#ffffff",borderBottom:f?"1px solid #4b5563":"1px solid #e5e7eb",boxShadow:"none"},body:{background:f?"#1e293b":"#ffffff"},controls:{border:f?"1px solid #4b5563":"1px solid #e5e7eb"},input:{background:f?"#374151":"#ffffff",color:f?"#f3f4f6":"#1f2937",border:f?"1px solid #4b5563":"1px solid #e5e7eb",boxShadow:"none"},previews:{border:f?"1px solid #4b5563":"1px solid #e5e7eb"},actions:{borderTop:f?"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-background animate-in fade-in zoom-in-95",onClick:e=>e.stopPropagation(),children:[r.jsx("h2",{className:"mb-4 text-lg font-semibold text-gray-900 dark:text-white",children:v("createCalendar")}),r.jsxs("form",{onSubmit:t=>{if(t.preventDefault(),!a.trim())return;const{colors:r,darkColors:o}=b(i),s={id:pe(),name:a.trim(),colors:r,darkColors:o,isVisible:!0,isDefault:!1};n(s),e()},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:i}}),r.jsx("input",{type:"text",value:a,onChange:e=>l(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:v("calendarNamePlaceholder"),autoFocus:!0})]})}),r.jsxs("div",{className:"mb-6",children:[r.jsx("div",{className:"grid grid-cols-7 gap-6",children:gn.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 "+(i===e?"ring-2 ring-primary ring-offset-2 dark:ring-offset-slate-800":""),style:{backgroundColor:e},onClick:()=>d(e)},e))}),r.jsxs("div",{className:"mt-2 relative",children:[r.jsx("button",{type:"button",onClick:()=>{m(i),u(!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:v("customColor")}),c&&r.jsx("div",{className:"absolute left-0 top-full z-10001 mt-2",children:r.jsx(s.PhotoshopPicker,{color:i,onChange:e=>{d(e.hex)},onAccept:()=>{u(!1)},onCancel:()=>{d(g),u(!1)},styles:p})})]})]}),r.jsxs("div",{className:"flex justify-end space-x-3",children:[r.jsx("button",{type:"button",onClick:e,className:Fe,children:v("cancel")}),r.jsx("button",{type:"submit",disabled:!a.trim(),className:"rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:v("create")})]})]})]})}),document.body)},hn=({loading:e,results:n,keyword:a,onResultClick:o,emptyText:s})=>{const{t:i,locale:d}=Se(),c=t.useMemo(()=>tn(new Date),[]),u=t.useMemo(()=>an(n,c),[n,c]),g=e=>en(e);return e?r.jsxs("div",{className:"flex flex-col items-center justify-center h-40 text-gray-500",children:[r.jsx(l.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(vn,{}),r.jsx("span",{className:"mt-2 text-sm",children:"string"==typeof s?s:s&&"object"==typeof s?s[d]||s.en||"No results found":i("noResults")||"No results found"})]}):null:r.jsx("div",{className:"space-y-6",children:u.map(e=>{const{title:n,colorClass:a}=nn(e.date,c,d,i);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"},l=e.allDay?i("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:l}),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())})})},vn=()=>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"})}),fn=({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(hn,{loading:n,results:a,keyword:o,onResultClick:s,emptyText:l})})}),pn=({isOpen:e,onClose:n,keyword:a,onSearchChange:s,results:i,loading:d,onResultClick:c,emptyText:u})=>{const g=t.useRef(null),{t:m}=Se();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(l.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(l.X,{className:"w-4 h-4"})})]})]}),r.jsx("div",{className:"flex-1 overflow-y-auto p-2 select-none",children:r.jsx(hn,{loading:d,results:i,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}=Se(),[i,d]=t.useState(""),[c,u]=t.useState(0),[g,m]=t.useState(!1),h=t.useRef(null),v=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&&v.current&&!v.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[f,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&&v.current){const e=n.current.getBoundingClientRect(),t=v.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=pe(),r={id:n,title:t.title,start:O(t.start),end:O(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:v,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:f.top,left:f.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},xn=({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":"")})}),bn=({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),[v,f]=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,f(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),f(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,v),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"})]})},Dn=({isOpen:e,onClose:n,onSave:a,draftEvent:s,app:l})=>{const{locale:i,t:d}=Se(),[c,u]=t.useState(""),[g,m]=t.useState(""),[h,v]=t.useState(!1),[f,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),[j,T]=t.useState(null),[S,N]=t.useState(e),[M,I]=t.useState(!1),[H,R]=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);R(e)}},[e,s,l]);const P=l.getCalendars(),L=P.map(e=>({label:e.name,value:e.id}));t.useEffect(()=>{if(e&&P.length>0){P.some(e=>e.id===g)||"blue"!==g&&""!==g||m(P[0].id)}},[P,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=P[0])||void 0===t?void 0:t.id)||"blue"),v(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=P[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(f),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:O(t),end:O(n)});return!fe(s,a)},[e,s,c,g,h,f,y,b]);if(!S)return null;const z=e=>{T(t=>t===e?null:e)},Y=e=>e.toLocaleDateString(i,{day:"numeric",month:"short",year:"numeric"}),F=(e,t)=>{if("start"===e){const e=new Date(t);e.setHours(f.getHours(),f.getMinutes());const n=e.getTime()-f.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)}},V=(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(H?"editEvent":"newEvent")}),r.jsx("button",{onClick:()=>{if(!s)return;let e=new Date(f),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:O(e),end:O(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(H?"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})}),P.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(mt,{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(xn,{checked:h,onChange:v})]}),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"===j?"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(f)}),!h&&r.jsx("button",{className:"px-3 py-1 rounded-md transition-colors "+("start-time"===j?"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:Q(f.getHours()+f.getMinutes()/60)})]})]}),r.jsx("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("start-date"===j?"max-h-100":"max-h-0"),children:r.jsx("div",{className:"",children:r.jsx(it,{currentDate:f,visibleMonth:w,onDateSelect:e=>F("start",e),onMonthChange:e=>V("start",e),showHeader:!0})})}),r.jsx("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("start-time"===j?"max-h-75":"max-h-0"),children:r.jsx("div",{className:"",children:r.jsx(bn,{date:f,onChange:e=>{const t=y.getTime()-f.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"===j?"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"===j?"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:Q(y.getHours()+y.getMinutes()/60)})]})]}),r.jsx("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("end-date"===j?"max-h-100":"max-h-0"),children:r.jsx("div",{className:"",children:r.jsx(it,{currentDate:y,visibleMonth:E,onDateSelect:e=>F("end",e),onMonthChange:e=>V("end",e),showHeader:!0})})}),r.jsx("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("end-time"===j?"max-h-75":"max-h-0"),children:r.jsx("div",{className:"",children:r.jsx(bn,{date:y,onChange:e=>{if(e<f){const t=y.getTime()-f.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)},wn=({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:Ee,getMonthLabels:ke,isDefault:!1}},[o,n]);return r.jsx(Te.Provider,{value:s,children:a})},Cn=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],En=({locale:e,messages:t,children:n})=>Se().isDefault?r.jsx(wn,{locale:e,messages:t,children:n}):r.jsx(r.Fragment,{children:n}),kn=({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,v=g.getSidebarConfig(),f=null!==(c=null==v?void 0:v.enabled)&&void 0!==c&&c,[p,y]=t.useState(0),[x,D]=t.useState(null!==(u=null==v?void 0:v.initialCollapsed)&&void 0!==u&&u),{t:C}=Se(),[E,k]=t.useState(!1),[j,T]=t.useState(null),[S,N]=t.useState(!1),M=t.useRef(null),[I,H]=t.useState(!1),[R,P]=t.useState(!1),[L,$]=t.useState(null),[z,Y]=t.useState(()=>g.getTheme()),[F,V]=t.useState(""),[W,B]=t.useState(!1),[Z,U]=t.useState(!1),[q,_]=t.useState(!1),[X,G]=t.useState([]);t.useEffect(()=>{const e=()=>{H(window.matchMedia("(max-width: 768px)").matches)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),t.useEffect(()=>{var e;if(!F.trim())return B(!1),G([]),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;_(!0),B(!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:F,events:e})}else if(null==d?void 0:d.onSearch)t=yield d.onSearch(F);else{const e=F.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})})}G(t),null===(e=null==d?void 0:d.onSearchStateChange)||void 0===e||e.call(d,{keyword:F,loading:!1,results:t})}catch(e){console.error("Search failed",e),G([])}finally{_(!1)}}),t);return()=>clearTimeout(n)},[F,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),Z&&U(!1)};t.useEffect(()=>{var e;D(null!==(e=null==v?void 0:v.initialCollapsed)&&void 0!==e&&e)},[null==v?void 0:v.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"===(v.createCalendarMode||"inline"))return void k(!0);const e=Cn[Math.floor(Math.random()*Cn.length)],{colors:t,darkColors:n}=b(e),a=pe(),r={id:a,name:C("untitled"),colors:t,darkColors:n,isVisible:!0,isDefault:!1};g.createCalendar(r),T(a),Q()},[g,v.createCalendarMode,C,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:pe(),title:"",start:O(e),end:O(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 P(!0)}f?S?N(!1):(M.current=e.currentTarget,N(!0)):ae()}},[f,I,S,ae,g]),oe=t.useRef(null),se=l||(g.getUseEventDetailDialog()?It: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:D,renderCalendarContextMenu:v.renderCalendarContextMenu,createCalendarMode:v.createCalendarMode,renderCreateCalendarDialog:v.renderCreateCalendarDialog,editingCalendarId:j,setEditingCalendarId:T,onCreateCalendar:ae},de=w(null==v?void 0:v.width,"240px"),ce=g.getCalendarHeaderConfig(),ue={calendar:g,switcherMode:g.state.switcherMode,onAddCalendar:re,onSearchChange:V,onSearchClick:()=>{V(""),U(!0)},searchValue:F,isSearchOpen:W,isEditable:!g.state.readOnly},ge=g.getCustomMobileEventRenderer()||Dn;return r.jsx(cn,{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:[f&&r.jsx("aside",{className:"absolute top-0 bottom-0 left-0 z-0 h-full",style:{width:de},children:f?v.render?v.render(ie):r.jsx(gt,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:f?x?"50px":de:0},children:[!1===ce?null:"function"==typeof ce?ce(ue):r.jsx(ln,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(fn,{isOpen:W,onClose:()=>{B(!1),V(""),g.highlightEvent(null)},loading:q,results:X,keyword:F,onResultClick:K,emptyText:null==d?void 0:d.emptyText})]}),r.jsx(pn,{isOpen:Z,onClose:()=>{U(!1),V(""),g.highlightEvent(null)},keyword:F,onSearchChange:V,results:X,loading:q,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:R,onClose:()=>{P(!1),$(null)},onSave:e=>{g.addEvent(e),P(!1),$(null)},draftEvent:L,app:g}),E&&(v.renderCreateCalendarDialog?v.renderCreateCalendarDialog({onClose:()=>k(!1),onCreate:e=>{g.createCalendar(e),k(!1),Q()}}):r.jsx(mn,{onClose:()=>k(!1),onCreate:e=>{g.createCalendar(e),k(!1),Q()}}))]})})},jn=({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(),v=t.useCallback(e=>{c?c.update(e.id,e):n.updateEvent(e.id,e)},[c,n]),f=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:v,onEventDelete:f,onEventCreate:p,onDateChange:y,onViewChange:x,config:b}),[n,g,m,h,v,f,p,y,x,b]),w=t.useMemo(()=>{const e={currentDate:g,events:h,setEvents:e=>{h.forEach(e=>f(e.id)),e.forEach(e=>p(e))},updateEvent:v,deleteEvent:f,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,v,f,p,y,x,D,c,u,o,s,l,i,d]);return r.jsx(e,Object.assign({},w))};function Tn(e){return Object.assign(Object.assign({},e),{parentId:void 0,children:[],_startHour:e.allDay?0:B(e.start),_endHour:e.allDay?0:ne(e)})}function Sn(e){var t;return null!==(t=e._startHour)&&void 0!==t?t:B(e.start)}function Nn(e){var t;return null!==(t=e._endHour)&&void 0!==t?t:ne(e)}const Mn=.25,In=.5,Hn=25,Rn=1,On=.9;class Pn{static getIndentStepPercent(e){return"day"===e?.5:2.5}static calculateDayEventLayouts(e,t={}){const n=e.map(Tn);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&&(Sn(e)<Nn(t)&&Sn(t)<Nn(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-On,zIndex:0,level:0,isPrimary:!0,indentOffset:0,importance:1})}static calculateComplexGroupLayout(e,t,n={}){const a=[...e].sort((e,t)=>{const n=Sn(e),a=Sn(t);if(n!==a)return n-a;return Nn(t)-Sn(t)-(Nn(e)-Sn(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(Sn(a)-Sn(t))<=Mn&&(r.push(t),n.add(t.id))}r.sort((e,t)=>Sn(e)-Sn(t));const o={events:r,startHour:Math.min(...r.map(e=>Sn(e))),endHour:Math.max(...r.map(e=>Nn(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(Sn(e)-Sn(t));if(n<=Mn)return!0;if(n>Mn&&n<In)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=Nn(e)-Sn(e);if(n<1.25)return!1;const a=Sn(e)+.4*n,r=Sn(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<In)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(Sn(e)-Sn(n));if(t<=Mn)return!0;if(t>Mn&&t<In)return!0}return!1}static canEventContain(e,t){const n=Sn(e)<=Sn(t)&&Nn(e)>=Nn(t),a=Sn(e)<=Sn(t)&&Sn(t)<Nn(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=Nn(e)-Sn(e);return Nn(t)-Sn(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 Nn(e)-Sn(e)>Math.max(...o.map(e=>{const t=n.find(t=>t.id===e);return t?Nn(t)-Sn(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(Sn(e)-Sn(t.parent))-Math.abs(Sn(e)-Sn(n.parent))});return r[0].parent}static calculateLayoutFromStructure(e,t,n={}){const a=100-On;if(1===e.length)this.calculateNodeLayoutWithVirtualParallel(e[0],0,a,t,n);else{const r=e.length,o=(a-Rn*(r-1))/r;e.forEach((e,a)=>{const r=a*(o+Rn);this.calculateNodeLayoutWithVirtualParallel(e,r,Math.max(o,Hn),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=Nn(e.event)-Sn(e.event);return Nn(t.event)-Sn(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?Rn*(d?.15:.3):Rn*(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=Nn(e.event)-Sn(e.event);return Nn(t.event)-Sn(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=Nn(e)-Sn(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 Ln={HOUR_HEIGHT:72,FIRST_HOUR:0,LAST_HOUR:24,MIN_DURATION:.25,TIME_COLUMN_WIDTH:80,ALL_DAY_HEIGHT:28,getLineColor:e=>K(e),getDynamicPadding:e=>e.endHour-e.startHour<=.25?"px-1 py-0":"p-1"};const An=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}},$n={renderAllDayContent:({title:e,color:t})=>r.jsxs("div",{className:"h-full flex items-center overflow-hidden pl-3 pt-1",children:[r.jsx(l.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})})]})},zn=({drag:e,color:t,title:n,layout:a,allDay:o,formatTime:s,getLineColor:l,getDynamicPadding:i,renderer:d=$n,isMobile:c})=>{const{t:u}=Se(),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})})},Yn=({event:e,isCreating:t,isMultiDay:n=!1,startDate:a,endDate:o})=>{const{t:s}=Se(),i=(()=>{if(t)return{title:s("newEvent"),icon:r.jsx(l.Calendar,{className:"h-3 w-3"}),showDateRange:!1};if(n&&a&&o){const t=V(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:i.icon}),r.jsx("div",{className:"flex-1 min-w-0",children:r.jsx("div",{className:"truncate font-medium",children:i.title})})]})},Fn=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}},Vn=e=>{const n=t.useMemo(()=>Object.assign(Object.assign(Object.assign({},Ln),e),{getLineColor:t=>{var n;return e.getLineColor?e.getLineColor(t):K(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]),v=t.useCallback(e=>!(c||!(null==a?void 0:a.current))&&e<=a.current.getBoundingClientRect().bottom,[a,c]),f=t.useMemo(()=>864e5,[]);return{pixelYToHour:g,getColumnDayIndex:m,checkIfInAllDayArea:v,handleDirectScroll:h,daysDifference:t.useCallback((e,t)=>V(e,t),[]),addDaysToDate:t.useCallback((e,t)=>W(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:f}})(n),s=An(n),l=(e=>{const{t:n,locale:a}=Se(),{calendarRef:r,allDayRowRef:o,viewType:s,getLineColor:l,getDynamicPadding:d,renderer:c,HOUR_HEIGHT:u=72,FIRST_HOUR:g=0,TIME_COLUMN_WIDTH:m=80,ALL_DAY_HEIGHT:h=60,app:v,isMobile:f}=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 j,T,S,N,M,I,H,R,P;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!==(T=null!==(j=e.currentSegmentDays)&&void 0!==j?j:e.eventDurationDays)&&void 0!==T?T: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=i.createRoot(L);const l=O(new Date),d=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(wn,{locale:a},t.createElement(Yn,{event:d,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(${f&&!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(${f?"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(${f&&!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(${f&&!y?"175%":"100%"} / 7)`;L.style.left=y?`${m}px`:`calc(${t} * ${e.dayIndex})`,L.style.width=`calc(${t} - 3px)`}}e.allDay?null===(H=null==o?void 0:o.current)||void 0===H||H.appendChild(L):null===(P=null===(R=r.current)||void 0===R?void 0:R.querySelector(".calendar-content"))||void 0===P||P.appendChild(L),D.current={drag:e,color:s,title:C,layout:E},b.current=i.createRoot(L),b.current.render(t.createElement(wn,{locale:a},t.createElement(zn,{drag:e,color:s,title:C,layout:E,allDay:e.allDay,formatTime:Q,getLineColor:l||(()=>""),getDynamicPadding:d||(()=>"0px"),renderer:c,isMobile:f})))}s?(L.style.backgroundColor=G(s,null==v?void 0:v.getCalendarRegistry()),L.style.color=X(s,null==v?void 0:v.getCalendarRegistry())):L.className+=" bg-primary/10 text-primary border border-dashed border-primary/50",x.current=L},[w,p,y,o,r,Q,l,d,c,m,h,g,u]),E=t.useCallback((...e)=>{var n,s;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==o?void 0:o.current))null===(n=null==o?void 0:o.current)||void 0===n||n.appendChild(i);else if(!w){const e=null===(s=r.current)||void 0===s?void 0:s.querySelector(".calendar-content");i.parentElement!==e&&(null==e||e.appendChild(i))}if(w){if(y)i.style.left=`${m}px`,i.style.width=`calc(100% - ${m}px - 2px)`;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=h-4+"px",i.style.marginBottom="3px",i.className=i.className.replace("rounded-sm","rounded-xl")}else{const e=(p-g)*u,t=(x-p)*u;i.style.top=`${e+3}px`,i.style.height=t-4+"px",i.style.marginBottom="0",i.className=i.className.replace("rounded-xl","rounded-sm");const n=f&&!y?"175%":"100%";if(C){if(y)i.style.left=`${m}px`,i.style.width=`calc(((100% - ${m}px) * ${C.width/100}) - 3px)`;else{const e=`calc(${n} / 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% - ${m}px)`:`calc(${n} / 7)`;i.style.left=y?`${m}px`:`calc(${e} * ${v})`,i.style.width=`calc(${e} - 3px)`}}if(i.style.cursor="grabbing",b.current&&D.current){const e=Object.assign(Object.assign({},D.current.drag),{dayIndex:v,startHour:p,endHour:x,allDay:w});D.current.drag=e,b.current.render(t.createElement(wn,{locale:a},t.createElement(zn,{drag:e,color:D.current.color,title:D.current.title,layout:C||D.current.layout,allDay:w,formatTime:Q,getLineColor:l||(()=>""),getDynamicPadding:d||(()=>"0px"),renderer:c,isMobile:f})))}}},[p,o,Q,r,y,h,m,g,u,l,d,c]);return{dragIndicatorRef:x,reactRootRef:b,removeDragIndicator:w,createDragIndicator:C,updateDragIndicator:E}})(n),d=(e=>{const{t:n}=Se(),{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:v=0,LAST_HOUR:f=24,MIN_DURATION:p=.25,app:y}=a,{dragRef:x,currentDragRef:b,setDragState:D,resetDragState:w,throttledSetEvents:C}=o,{removeDragIndicator:E,createDragIndicator:k,updateDragIndicator:j}=s,{pixelYToHour:T,getColumnDayIndex:S,checkIfInAllDayArea:N,handleDirectScroll:M,daysDifference:I,addDaysToDate:H,getTargetDateFromPosition:R}=r,L=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},F=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}=Fn(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?ge(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})),j(c,0,0,!0)}else{M(i);const e=T(i);if(null!==(t=s.startDragDayIndex)&&void 0!==t||s.originalDay,s.dayIndex,s.allDay){s.allDay=!1,s.startHour=te(e),s.endHour=s.startHour+1,s.duration=1,s.hourOffset=0,s.eventDate=m?ge(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=te(e+(null!==(n=s.hourOffset)&&void 0!==n?n:0));t=Math.max(v,Math.min(f-s.duration,t)),s.startHour=t,s.endHour=t+s.duration}s.dayIndex=c,s.eventDate=m?ge(m,c):new Date,D(e=>Object.assign(Object.assign({},e),{dayIndex:c,startHour:te(s.startHour),endHour:te(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,te(s.startHour),te(s.endHour)))}j(c,te(s.startHour),te(s.endHour),!1,a)}},[g,N,k,m,h,v,S,M,f,$,T,E,j,x,D]),V=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",F),document.removeEventListener("mouseup",V),document.removeEventListener("touchmove",F,{capture:!0}),document.removeEventListener("touchend",V),void w();if("move"!==e.mode||!e.eventId)return;let r=e.startHour,o=e.endHour;e.allDay||(r=te(e.startHour),o=te(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?ge(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=P(a),d=P(U(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=O(e),d=O(t)}else{const t=m?ge(m,e.dayIndex):new Date,n=Z(t,r),a=Z(t,o);i=O(n),d=O(a)}}const c=e.originalDay+l;return Object.assign(Object.assign({},t),{day:c,start:i,end:d,allDay:e.allDay})})),document.removeEventListener("mousemove",F),document.removeEventListener("mouseup",V),document.removeEventListener("touchmove",F,{capture:!0}),document.removeEventListener("touchend",V),E(),w()},[F,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:F}=Fn(e);if(D&&D.active)if("resize"===D.mode?L||D.allDay?document.body.style.cursor="ew-resize":document.body.style.cursor="ns-resize":document.body.style.cursor="grabbing",L){if("resize"!==D.mode){if("move"===D.mode){const e=Math.hypot(z-D.startX,F-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&&j(z,F)}const e=R(z,F);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?P(n):O(n),i=D.originalEvent.allDay?P(a):O(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=H(D.originalStartDate,n),r=H(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(F),D.lastClientY=F;const e=T(F);if("create"===D.mode&&D.allDay){const e=Math.hypot(z-D.startX,F-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 j(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?ge(m,e):new Date,t>n&&(t=n)):"right"===D.resizeDirection&&(n=m?ge(m,e):new Date,n<t&&(n=t)),D.originalStartDate=new Date(t.getTime()),D.originalEndDate=new Date(n.getTime());const a=P(t),r=P(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(v,Math.min(f,o))):(s=r,o>D.originalEndHour?(t=D.originalEndHour,n=o,D.hourOffset=n-e):(t=Math.max(v,o),D.originalEndHour-t<J&&(t=D.originalEndHour-J)))}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(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<J&&(n=D.startHour+J))}else if("right"===D.resizeDirection){const e=$?D.dayIndex:S(z);o=Math.max(D.dayIndex,e)}o===s&&([t,n]=[Math.max(v,Math.min(t,n)),Math.min(f,Math.max(t,n))]);const[u,g]=[te(t),te(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=Z(m?ge(m,s):t,u),a=m?ge(m,o):t,r=Z(a,g),l=O(n),i=O(r);return Object.assign(Object.assign({},e),{start:l,end:i,day:s})}),D.mode),j(D.dayIndex,u,g,!1)}else if("create"===D.mode){if(a.isMobile){const t=te(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=te(e),[n,a]=F<D.startY?[t,Math.max(t+J,D.endHour)]:[D.startHour,Math.max(D.startHour+J,t)];D.startHour=n,D.endHour=a}const t=null==u?void 0:u(D.dayIndex,D.startHour,D.endHour);j(D.dayIndex,D.startHour,D.endHour,!1,t)}else if("move"===D.mode){const t=$?D.dayIndex:S(z);let n=te(e+(null!==(b=D.hourOffset)&&void 0!==b?b: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==h?void 0:h.find(e=>e.id===D.eventId);e&&(r=g(e,t,te(n),te(a)))}j(t,te(n),te(a),!1,r)}}},[L,$,j,R,C,I,H,v,f,u,S,T,M,g,h,x,k]),q=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",q),document.removeEventListener("touchmove",W,{capture:!0}),document.removeEventListener("touchend",q),void w();const{clientX:u,clientY:g}=Fn(e);if(o&&o.active){if(L){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?P(o.originalStartDate):O(o.originalStartDate),a=e?P(o.originalEndDate):O(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?P(o.originalStartDate):O(o.originalStartDate),n=e?P(o.originalEndDate):O(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=R(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?P(r):O(r),i=t.allDay?P(s):O(s);return Object.assign(Object.assign({},t),{start:l,end:i})})))}}else{let[e,t]=[te(o.startHour),te(o.endHour)];if(t-e<p&&("top"===o.resizeDirection?e=t-p:t=e+p),"create"===o.mode){const a=m?ge(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=Z(a,e),s=Z(a,t),l=o.allDay,i=l?P(r):O(r),c=l?P(s):O(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",q),document.removeEventListener("touchmove",W,{capture:!0}),document.removeEventListener("touchend",q),E(),o.indicatorVisible=!1,o.sourceElement=null,w()}},[L,W,E,w,R,C,p,m,d,i,x,D]),_=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}=Fn(e);if(L){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=O(a),s=O(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=te(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?ge(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",q),document.addEventListener("touchmove",W,{capture:!0,passive:!1}),document.addEventListener("touchend",q)}},[L,d,c,m,u,k,W,q,x,D]),X=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}=Fn(e),i=x.current;if(!i)return;const d=e.currentTarget;if(L){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",q),document.addEventListener("touchmove",W,{capture:!0,passive:!1}),document.addEventListener("touchend",q)}else{const e=T(l),n=t._segmentInfo,c=!!n,u=c?n.dayIndex:null!==(a=t.day)&&void 0!==a?a:0,g=c?n.startHour:B(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:ne(t),originalDay:null!==(r=t.day)&&void 0!==r?r:0,originalStartHour:B(t.start),originalEndHour:ne(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:B(t.start),endHour:ne(t),allDay:t.allDay||!1}),i.sourceElement=d,i.indicatorVisible=!1,document.addEventListener("mousemove",F),document.addEventListener("mouseup",V),document.addEventListener("touchmove",F,{capture:!0,passive:!1}),document.addEventListener("touchend",V)}},[L,k,q,W,F,V,T,x,b,D]),G=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}=Fn(e),u=x.current;if(u){if(L){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=T(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:B(t.start),endHour:ne(t),originalDay:null!==(l=t.day)&&void 0!==l?l:0,originalStartHour:B(t.start),originalEndHour:ne(t),resizeDirection:n,lastUpdateTime:Date.now(),initialMouseY:e,hourOffset:"top"===n?B(t.start)-e:ne(t)-e,allDay:!1}),D({active:!0,mode:"resize",eventId:t.id,dayIndex:null!==(i=t.day)&&void 0!==i?i:0,startHour:B(t.start),endHour:ne(t),allDay:!1})}document.addEventListener("mousemove",W),document.addEventListener("mouseup",q),document.addEventListener("touchmove",W,{capture:!0,passive:!1}),document.addEventListener("touchend",q)}},[L,W,q,T,x,D]);return{handleDragMove:W,handleDragEnd:q,handleCreateStart:_,handleMoveStart:X,handleResizeStart:G,handleUniversalDragMove:F,handleUniversalDragEnd:V}})({options:n,common:o,state:s,manager:l}),c=(e=>{const{t:n}=Se(),{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:v,getColumnDayIndex:f}=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?ge(c,t):new Date,r=P(e),o=P(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?ge(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:v,getColumnDayIndex:f}})({options:n,common:o,state:s,manager:l,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:o});return Object.assign({createDragIndicator:l.createDragIndicator,updateDragIndicator:l.updateDragIndicator,removeDragIndicator:l.removeDragIndicator,handleCreateStart:d.handleCreateStart,handleMoveStart:d.handleMoveStart,handleResizeStart:d.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 Wn(e,t){const n=e.getPlugin("drag"),a=Vn(Object.assign(Object.assign({},t),{app:e}));if(!n)return D.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 Bn(e){const{app:a,onEventCreated:r}=e,{t:o}=Se(),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 Zn=({handlePreviousMonth:e,handleToday:t,handleNextMonth:n})=>{const{t:a}=Se();return r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("button",{className:"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",onClick:e,"aria-label":"Previous month",children:r.jsx(l.ChevronLeft,{className:"h-4 w-4 transition-transform group-hover:scale-110"})}),r.jsx("button",{className:"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:"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",onClick:n,"aria-label":"Next month",children:r.jsx(l.ChevronRight,{className:"h-4 w-4 transition-transform group-hover:scale-110"})})]})},Un=({app:e,currentDate:t,visibleMonth:n,currentDayEvents:a,selectedEvent:o,setSelectedEvent:s,handleMonthChange:l,handleDateSelect:i,switcherMode:d})=>{const{t:c,locale:u}=Se();return r.jsx("div",{className:"hidden md:block flex-none w-[30%] bg-white dark:bg-gray-900",children:r.jsxs("div",{className:`${st} h-full`,children:[r.jsx("div",{className:"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:ze,style:{position:"relative"},children:r.jsx("div",{children:r.jsx("h1",{className:Ye,children:" "})})}),r.jsx(Zn,{handlePreviousMonth:()=>e.goToPrevious(),handleNextMonth:()=>e.goToNext(),handleToday:()=>e.goToToday()})]}),r.jsx(it,{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:`text-gray-500 dark:text-gray-400 ${ot}`,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:K(t.calendarId||"blue")},onClick:()=>{s(t),e.onEventClick(t)},children:[r.jsx("div",{className:`font-medium ${ot}`,children:t.title}),!t.allDay&&r.jsxs("div",{className:`${rt} ${at}`,children:[Q(B(t.start))," -"," ",Q(ne(t))]}),t.allDay&&r.jsx("div",{className:`${rt} ${at}`,children:c("allDay")})]},t.id))})]})]})})},qn=({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}=Se(),h=void 0===i||i,v=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""}})(),f="day"===e?l||("day"===e?t.toLocaleDateString(m,{weekday:"long"}):null):null;return r.jsxs("div",{className:ze,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:Ye,style:{position:"absolute",top:0,left:0,transform:`translateY(-${c}px)`,willChange:"transform"},children:d}),u&&r.jsx("h1",{className:Ye,style:{position:"absolute",top:0,left:0,transform:`translateY(${g}px)`,willChange:"transform"},children:u})]}):r.jsxs("div",{children:[r.jsx("div",{className:`${Ye} text-gray-900 dark:text-white`,children:v}),f&&r.jsx("div",{className:"mt-3 text-gray-600 dark:text-gray-400",children:f})]})}),h&&n&&a&&o&&r.jsx("div",{className:"flex items-center gap-2",children:r.jsx(Zn,{handlePreviousMonth:n,handleNextMonth:a,handleToday:o})})]})},_n=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(l.Gift,{className:"h-3 w-3"}):t.includes("birthday")||t.includes("anniversary")||t.includes("生日")?r.jsx(l.Heart,{className:"h-3 w-3"}):t.includes("conference")||t.includes("meeting")||t.includes("会议")||t.includes("研讨")?r.jsx(l.Star,{className:"h-3 w-3"}):t.includes("trip")||t.includes("travel")||t.includes("旅行")?r.jsx(l.MapPin,{className:"h-3 w-3"}):r.jsx(l.CalendarDays,{className:"h-3 w-3"})},Xn=(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=V(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)),v=Math.min(6,Math.floor((m.getTime()-t.getTime())/864e5)),f=c>=t,p=u<=a,y=0===h||6===v;let x;x=f&&p?"single":f?y&&6===v?"start-week-end":"start":p?y&&0===h?"end-week-start":"end":"middle";const b=V(c,u)+1;n.push({id:`${e.id}-week-${t.getTime()}`,originalEventId:e.id,event:e,startDayIndex:h,endDayIndex:v,segmentType:x,totalDays:b,segmentIndex:0,isFirstSegment:f,isLastSegment:p})}),n},Gn=(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=V(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},Kn=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,v=`calc(${e.startDayIndex/7*100}% + 2px)`,f=`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:v,width:f,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:G(b),color:"#fff"}:{backgroundColor:_(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} (${Vt(e.event.start)} - ${Vt(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:K(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:K(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=B(e.event.start),o=ne(e.event),s=Q(a),l=Q(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&&_n(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:K(n),width:"12px",height:"12px"},children:_n(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:K(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});Kn.displayName="MultiDayEvent";const Jn=({event:e,position:a,panelRef:s,isAllDay:l,eventVisibility:i,calendarRef:d,selectedEventElementRef:c,onEventUpdate:u,onEventDelete:g,app:m})=>{var h;const{effectiveTheme:v}=un(),f=Xt(v),{t:p}=Se(),y="dark"===f||"undefined"!=typeof document&&document.documentElement.classList.contains("dark"),b=!(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():x()).getVisible().map(e=>({label:e.name,value:e.id})),[m,null==m?void 0:m.getCalendars()]),E=t.useMemo(()=>R(e.start)?e.end&&!R(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()}))},j=(()=>{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})(),T=r.jsxs("div",{ref:s,className:"fixed bg-white dark:bg-gray-800 shadow-lg border border-gray-200 dark:border-gray-700 rounded-lg 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:j}),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:!b,disabled:!b,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"})}),b&&r.jsx(mt,{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(Mt,{value:[e.start,e.end],format:"YYYY-MM-DD",showTime:!1,timeZone:E,matchTriggerWidth:!0,disabled:!b,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(Mt,{value:[e.start,e.end],timeZone:E,disabled:!b,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:!b,disabled:!b,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")})]}),b&&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=R(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=R(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(T,S):null},Qn=({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}=un(),h=Xt(m),v="dark"===h?"#1f2937":"white",f="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:v,transform:"rotate(45deg)",transformOrigin:"center",top:e-6+"px",borderRight:""+(t.isSunday?`1px solid ${f}`:"none"),borderTop:""+(t.isSunday?`1px solid ${f}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${f}`),borderBottom:""+(t.isSunday?"none":`1px solid ${f}`)},t.isSunday?{right:"-6px"}:{left:"-6px"})}}else if("sticky-bottom"===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:v,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 ${f}`:"none"),borderTop:""+(t.isSunday?`1px solid ${f}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${f}`),borderBottom:""+(t.isSunday?"none":`1px solid ${f}`)}}else if(t&&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:v,transform:"rotate(45deg)",transformOrigin:"center",top:h-6+"px",borderRight:""+(t.isSunday?`1px solid ${f}`:"none"),borderTop:""+(t.isSunday?`1px solid ${f}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${f}`),borderBottom:""+(t.isSunday?"none":`1px solid ${f}`)},t.isSunday?{right:"-6px"}:{left:"-6px"})}}return a})(),y=r.jsxs("div",{ref:n,className:"fixed bg-white dark:bg-gray-800 shadow-lg border border-gray-200 dark:border-gray-700 rounded-lg 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)},ea=({event:e,app:t,isEventSelected:n,hideTime:a})=>{const o=`${Math.floor(B(e.start)).toString().padStart(2,"0")}:${Math.round(B(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:K(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())},className:`inline-block w-0.75 h-3 ${lt} 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:`${rt} ml-1 shrink-0 ${n?"text-white":""} hidden md:block`,style:n?void 0:{opacity:.8},children:o})]})},ta=({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:`${lt} shrink-0`,children:a}):e.title.toLowerCase().includes("easter")||e.title.toLowerCase().includes("holiday")?r.jsx("span",{className:`inline-block ${lt} shrink-0 ${t?"text-yellow-200":"text-yellow-600"}`,children:"⭐"}):r.jsx(l.CalendarDays,{className:`${et} ${t?"text-white":""}`})),r.jsx("span",{className:"truncate "+(t?"text-white":""),children:e.title})]})},na=({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(l.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()}})]})},aa=({event:e,app:t,multiDaySegmentInfo:n,isEditable:a,isTouchEnabled:o,isEventSelected:s,onResizeStart:l})=>{const i=n?n.startHour:B(e.start),d=n?n.endHour:ne(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:K(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())}}),r.jsxs("div",{className:"h-full flex flex-col overflow-hidden pl-3 "+(ne(e)-B(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:"text-xs opacity-80 truncate",children:n?`${Q(i)} - ${Q(d)}`:ee(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:K(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:K(m,null==t?void 0:t.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),l(t,e,"bottom")}})]})]})},ra=({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:v,firstHour:f,selectedEventId:p,detailPanelEventId:y,onMoveStart:x,onResizeStart:b,onEventUpdate:D,onEventDelete:w,newlyCreatedEventId:C,onDetailPanelOpen:E,onEventSelect:k,onEventLongPress:j,onDetailPanelToggle:T,customDetailPanelContent:S,customEventDetailDialog:N,multiDaySegmentInfo:M,app:I,isMobile:H=!1,enableTouch:R,hideTime:O})=>{const P=null!=R?R:H,[L,A]=t.useState(!1),[$,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,F=y===Y,[V,W]=t.useState(null),[Z,U]=t.useState("visible"),q=t.useRef(null),K=t.useRef(null),J=t.useRef(null),Q=t.useRef(null),ee=t.useRef(null),te=t.useRef(null),ae=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=H?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=H?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:B(e.start),o=M?M.endHour:ne(e),s=(r-f)*v,i=s+Math.max((o-r)*v,v/4),d=n.scrollTop,c=n.clientHeight;if(s>=d&&i<=d+c)return void t();const g=((r+o)/2-f)*v-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||!K.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=H?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(!K.current)return;if(!J.current)return;const y=K.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:B(e.start),r=M?M.endHour:ne(e),s=(n-f)*v,i=Math.max((r-n)*v,v/4),d=t.getBoundingClientRect(),c=t.scrollTop,u=d.top+s-c,g=null===(o=q.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=H?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 j=C.top-b/2+C.height/2,T=Math.max(10,t.top+10),S=i-10;w=j<T?T:j+b>S?S-b:j,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,f,v,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(!ae||!F||!q.current||!l.current||a||u)return;const t=l.current.querySelector(".calendar-content");if(!t)return;const n=M?M.startHour:B(e.start),r=M?M.endHour:ne(e),o=(n-f)*v,s=o+Math.max((r-n)*v,v/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),U(c?"sticky-top":g?"sticky-bottom":"visible"),me()},[L,F,l,a,u,B(e.start),ne(e),f,v,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(!ae||!F||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()}},[ae,F,a,he,me,l,Z]),t.useEffect(()=>{if(!ae&&!F)return;const t=t=>{var n,a;const r=t.target,o=null===(n=q.current)||void 0===n?void 0:n.contains(r),s=null!==r.closest(`[data-event-id="${e.id}"]`),l=null===(a=K.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-color-picker-dropdown]");F?o||s||l||i||d||c||(k&&k(null),de(null),A(!1),null==T||T(null)):!ae||o||s||c||(k&&k(null),de(null),A(!1),null==T||T(null))};return document.addEventListener("mousedown",t),()=>{document.removeEventListener("mousedown",t)}},[ae,F,k,T,e.id]),t.useEffect(()=>{g&&m&&!m.isFirstSegment||C!==e.id||F||setTimeout(()=>{var t,n;if(q.current){let a=q.current;if(g){const e=q.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,A(!0),null==T||T(Y),W({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>{me()})}null==E||E()},150)},[C,e.id,F,E,me,g,m,T,Y]);const ve=t.useRef(null);t.useEffect(()=>{let t,n=!0;const a=null==I?void 0:I.state.highlightedEventId;return ae&&a===e.id?ve.current!==a&&(ve.current=a,ge().then(()=>{n&&(z(!0),t=setTimeout(()=>{n&&z(!1)},150))})):z(!1),a!==e.id&&(ve.current=null),()=>{n=!1,t&&clearTimeout(t)}},[ae,null==I?void 0:I.state.highlightedEventId,e.id]);const fe=()=>m?r.jsx(Kn,{segment:m,segmentIndex:null!=h?h:0,isDragging:i||ae,isResizing:d,isSelected:ae,onMoveStart:x||(()=>{}),onResizeStart:b,isMobile:H,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:q,"data-event-id":e.id,className:u?`\n ${Ge}\n ${a?pe():"rounded-sm"}\n `:`\n ${Ge}\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:ae||F?1e3:1,transform:$?"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:ae||F?1e3:1,transform:$?"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:B(e.start),b=M?M.endHour:ne(e),D={top:`${(x-f)*v+3}px`,height:Math.max((b-x)*v,v/4)-4+"px",position:"absolute",opacity:i?.3:1,zIndex:ae||F?1e3:null!==(t=null==n?void 0:n.zIndex)&&void 0!==t?t:1,transform:$?"scale(1.12)":void 0,transition:"transform 0.1s ease-in-out",cursor:le||se?"pointer":"default"};if(ae&&F&&("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=H?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=q.current)||void 0===y?void 0:y.getBoundingClientRect(),v=null==h?void 0:h.left,f=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?v:s}px`,width:`${c?f: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?v:s}px`,width:`${c?f: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"})})()),ae?{backgroundColor:G(ye,null==I?void 0:I.getCalendarRegistry()),color:"#fff"}:{backgroundColor:_(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&&A(!0),null==T||T(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(()=>{A(!0),H||(null==T||T(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;j?j(e.id):A(!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&&A(!0),I&&I.onEventClick(e),null==T||T(null),W(null)),te.current=null},children:u?g&&m?fe():e.allDay?g?fe():r.jsx(ta,{event:e,isEventSelected:ae}):r.jsx(ea,{event:e,app:I,isEventSelected:ae,hideTime:O}):e.allDay?r.jsx(na,{event:e,isEditable:!!oe,onResizeStart:b}):r.jsx(aa,{event:e,app:I,multiDaySegmentInfo:M,isEditable:!!oe,isTouchEnabled:!!P,isEventSelected:ae,onResizeStart:b})}),F&&r.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:9998,pointerEvents:"none"}}),(()=>{if(!F)return null;const t=()=>{k&&k(null),de(null),A(!1),null==T||T(null)};if(N){const n=N,s={event:e,isOpen:F,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 V?S?r.jsx(Qn,{event:e,position:V,panelRef:K,isAllDay:a,eventVisibility:Z,calendarRef:l,selectedEventElementRef:J,onEventUpdate:D,onEventDelete:w,onClose:t,contentRenderer:S}):r.jsx(Jn,{event:e,position:V,panelRef:K,isAllDay:a,eventVisibility:Z,calendarRef:l,selectedEventElementRef:J,onEventUpdate:D,onEventDelete:w,onClose:t,app:I}):null})()]})},oa=({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:v,setNewlyCreatedEventId:f,detailPanelEventId:p,setDetailPanelEventId:y,dragState:x,isDragging:b,handleMoveStart:D,handleResizeStart:w,handleCreateStart:C,handleCreateAllDayEvent:E,handleTouchStart:k,handleTouchEnd:j,handleTouchMove:T,handleDragOver:S,handleDrop:N,handleEventUpdate:M,handleEventDelete:I,customDetailPanelContent:H,customEventDetailDialog:R,calendarRef:O,allDayRowRef:P,switcherMode:L,isMobile:A,isTouch:$,setDraftEvent:z,setIsDrawerOpen:Y,ALL_DAY_HEIGHT:F,HOUR_HEIGHT:V,FIRST_HOUR:W,LAST_HOUR:B})=>{const{t:Z,locale:U}=Se(),q=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 ${st} h-full`,children:[r.jsx(qn,{calendar:e,viewType:exports.ViewType.DAY,currentDate:n,customSubtitle:n.toLocaleDateString(U,{weekday:"long"})}),r.jsxs("div",{className:`${Xe} pt-px`,ref:P,children:[r.jsx("div",{className:"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:Z("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(ra,{event:t,isAllDay:!0,isDayView:!0,segmentIndex:t.row,allDayHeight:F,calendarRef:O,isBeingDragged:b&&(null==x?void 0:x.eventId)===t.id&&"move"===(null==x?void 0:x.mode),hourHeight:V,firstHour:W,onMoveStart:D,onEventUpdate:M,onEventDelete:I,newlyCreatedEventId:v,onDetailPanelOpen:()=>f(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),q.current=null))},onEventLongPress:e=>{(A||$)&&h(e)},customDetailPanelContent:H,customEventDetailDialog:R,app:e,isMobile:A,enableTouch:$},t.id))})})]}),r.jsx("div",{className:"relative overflow-y-auto calendar-content",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>B)return null;const n=(t-W)*V;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:_e,children:Q(t)})]}),r.jsx("div",{className:"flex-1 flex items-center",children:r.jsx("div",{className:"h-0.5 w-full bg-primary relative"})})]})})(),r.jsx("div",{className:"flex-shrink-0 border-gray-200 dark:border-gray-700 w-12 md:w-20",children:d.map((e,t)=>r.jsx("div",{className:Be,children:r.jsx("div",{className:`${Ze} 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:Ue,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/V)},onTouchStart:e=>{const t=Math.floor((n.getTime()-a.getTime())/864e5);k(e,t)},onTouchEnd:j,onTouchMove:T,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/V);N(e,n,i)},onContextMenu:e=>A&&e.preventDefault()},t)),r.jsx("div",{className:"h-3 border-t border-gray-200 dark:border-gray-700 relative",children:r.jsx("div",{className:"absolute -top-2.5 -left-9 text-[12px] text-gray-500 dark:text-gray-400",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(ra,{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:V,firstHour:W,onMoveStart:D,onResizeStart:w,onEventUpdate:M,onEventDelete:I,newlyCreatedEventId:v,onDetailPanelOpen:()=>f(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),q.current=null))},onEventLongPress:e=>{(A||$)&&h(e)},customDetailPanelContent:H,customEventDetailDialog:R,app:e,isMobile:A,enableTouch:$},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},la=({app:e,customDetailPanelContent:n,customEventDetailDialog:a,calendarRef:o,switcherMode:s="buttons"})=>{const l=e.getEvents(),{t:i,locale:d}=Se(),{screenSize:c}=on(),u="desktop"!==c,[g,m]=t.useState(!1);t.useEffect(()=>{m("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const h=e.getCustomMobileEventRenderer()||Dn,[v,f]=t.useState(null),[p,y]=t.useState(null),[x,b]=t.useState(null),[D,w]=t.useState(null),[C,E]=t.useState(!1),[k,j]=t.useState(null),T=t.useRef(null),S=e.getCurrentDate(),N=e.getVisibleMonth();N.getFullYear(),N.getMonth();const[M,I]=t.useState(S),H=t.useRef(S.getTime());S.getTime()!==H.current&&(H.current=S.getTime(),S.getFullYear()===M.getFullYear()&&S.getMonth()===M.getMonth()||I(S));const R=t.useCallback(t=>{I(n=>{const a=new Date(n.getFullYear(),n.getMonth()+t,1);return e.setVisibleMonth(a),a})},[e]),{HOUR_HEIGHT:P,FIRST_HOUR:L,LAST_HOUR:$,TIME_COLUMN_WIDTH:z,ALL_DAY_HEIGHT:Y}=Ln,F=t.useRef(e.state.highlightedEventId);t.useEffect(()=>{var t;if(e.state.highlightedEventId!==F.current)if(e.state.highlightedEventId){const n=e.getEvents().find(t=>t.id===e.state.highlightedEventId);if(n&&(y(n),!n.allDay)){const e=B(n.start),a=null===(t=o.current)||void 0===t?void 0:t.querySelector(".calendar-content");if(a){const t=(e-L)*P;requestAnimationFrame(()=>{a.scrollTo({top:Math.max(0,t-100),behavior:"smooth"})})}}}else y(null);F.current=e.state.highlightedEventId},[e.state.highlightedEventId,L,P,o,e]);const V=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]),U=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=O(n),l=!0),r>a&&(s=O(a),l=!0),Object.assign(Object.assign({},e),{start:l?o:e.start,end:l?s:e.end,day:0})})})(Z,S),[Z,S]),q=t.useMemo(()=>Pn.calculateDayEventLayouts(U,{viewType:"day"}),[U]),_=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]),X=t.useMemo(()=>{if(0===_.length)return Y;return(Math.max(..._.map(e=>e.row))+1)*Y},[_,Y]),{handleMoveStart:G,handleCreateStart:K,handleResizeStart:J,handleCreateAllDayEvent:ee,dragState:te,isDragging:ne}=Wn(e,{calendarRef:o,allDayRowRef:V,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||B(t.start)!==B(e.start)||B(t.end)!==B(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?(j(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:O(o),end:O(s),calendarId:"blue",allDay:!1}];return Pn.calculateDayEventLayouts(l,{viewType:"day"}).get("-1")||null})(0,t,n,S,U),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:O(i),end:O(d),day:0})];return 0===c.length?null:Pn.calculateDayEventLayouts(c,{viewType:"day"}).get(e.id)||null})(e,0,n,a,S,U),TIME_COLUMN_WIDTH:u?48:80,isMobile:u}),{handleDrop:ae,handleDragOver:re}=Bn({app:e,onEventCreated:e=>{w(e.id)}}),oe=Array.from({length:24},(e,t)=>({hour:t+L,label:Q(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(()=>{f(new Date);const e=setInterval(()=>f(new Date),6e4);return()=>clearInterval(e)},[]),r.jsxs("div",{className:"flex h-full bg-gray-50 dark:bg-gray-800",children:[r.jsx(oa,{app:e,currentDate:S,currentWeekStart:W,events:l,currentDayEvents:Z,organizedAllDayEvents:_,allDayAreaHeight:X,timeSlots:oe,eventLayouts:q,isToday:le,currentTime:v,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:G,handleResizeStart:J,handleCreateStart:K,handleCreateAllDayEvent:ee,handleTouchStart:(e,t)=>{if(!u&&!g)return;const n=e.touches[0],a=n.clientX,r=n.clientY,s=e.currentTarget;T.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/P)},500)},handleTouchEnd:()=>{T.current&&(clearTimeout(T.current),T.current=null)},handleTouchMove:()=>{T.current&&(clearTimeout(T.current),T.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:V,switcherMode:s,isMobile:u,isTouch:g,setDraftEvent:j,setIsDrawerOpen:E,ALL_DAY_HEIGHT:Y,HOUR_HEIGHT:P,FIRST_HOUR:L,LAST_HOUR:$}),r.jsx(Un,{app:e,currentDate:S,visibleMonth:M,currentDayEvents:Z,selectedEvent:p,setSelectedEvent:y,handleMonthChange:R,handleDateSelect:se,switcherMode:s}),r.jsx(h,{isOpen:C,onClose:()=>{E(!1),j(null)},onSave:t=>{l.find(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),E(!1),j(null)},draftEvent:k,app:e})]})},ia={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}},da=({app:e,weekDaysLabels:t,mobileWeekDaysLabels:n,weekDates:a,currentWeekStart:o,timeGridWidth:s,sidebarWidth:l,allDayAreaHeight:i,organizedAllDaySegments:d,allDayLabelText:c,isMobile:u,isTouch:g,calendarRef:m,allDayRowRef:h,topFrozenContentRef:v,ALL_DAY_HEIGHT:f,HOUR_HEIGHT:p,FIRST_HOUR:y,dragState:x,isDragging:b,handleMoveStart:D,handleResizeStart:w,handleEventUpdate:C,handleEventDelete:E,newlyCreatedEventId:k,setNewlyCreatedEventId:j,selectedEventId:T,setSelectedEventId:S,detailPanelEventId:N,setDetailPanelEventId:M,handleCreateAllDayEvent:I,handleDragOver:H,handleDrop:R,customDetailPanelContent:O,customEventDetailDialog:P,events:L,setDraftEvent:A,setIsDrawerOpen:$})=>{const z={flexShrink:0};return r.jsx("div",{className:"flex flex-none border-b border-gray-200 dark:border-gray-700 relative z-10",children:r.jsx("div",{ref:v,className:"flex-1 overflow-hidden relative",children:r.jsxs("div",{className:"flex flex-col min-w-full",children:[r.jsxs("div",{className:"flex w-full",children:[r.jsxs("div",{className:"flex shrink-0",style:{width:s?s+l:"100%"},children:[r.jsx("div",{className:"w-12 md:w-20 shrink-0 sticky left-0 bg-white dark:bg-gray-900 z-20 border-b border-gray-200 dark:border-gray-700"}),r.jsx("div",{className:"flex border-b border-gray-200 dark:border-gray-700 flex-1",children:t.map((e,t)=>r.jsx("div",{className:"flex flex-1 justify-center items-center text-center text-gray-500 dark:text-gray-400 text-sm p-1 select-none "+(u?"flex-col gap-0":""),style:z,children:u?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:`${Ve} 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:`${Ve} ${a[t].isToday?nt:""}`,children:a[t].date})]})},t))})]}),r.jsx("div",{className:"flex-1 border-b border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900"})]}),r.jsxs("div",{className:"flex w-full",children:[r.jsxs("div",{className:"flex shrink-0",style:{width:s?s+l:"100%"},children:[r.jsx("div",{className:"w-12 md:w-20 shrink-0 flex items-center justify-end p-1 text-[10px] md:text-xs font-medium text-gray-500 dark:text-gray-400 select-none bg-white dark:bg-gray-900 sticky left-0 z-20 ",children:c}),r.jsx("div",{className:`${Xe} border-none flex-1`,ref:h,style:{minHeight:`${i}px`},children:r.jsxs("div",{className:"flex flex-1 relative",style:{minHeight:`${i}px`},children:[t.map((e,n)=>{const a=new Date(o);return a.setDate(o.getDate()+n),r.jsx("div",{className:"flex-1 border-r border-gray-200 dark:border-gray-700 relative "+(u&&n===t.length-1?"border-r-0":""),style:Object.assign({minHeight:`${i}px`},z),onMouseDown:e=>null==I?void 0:I(e,n),onDoubleClick:e=>null==I?void 0:I(e,n),onDragOver:H,onDrop:e=>{R(e,a,void 0,!0)}},`allday-${n}`)}),r.jsx("div",{className:"absolute inset-0 pointer-events-none",children:d.map(t=>r.jsx(ra,{event:t.event,segment:t,segmentIndex:t.row,isAllDay:!0,isMultiDay:!0,allDayHeight:f,calendarRef:m,isBeingDragged:b&&(null==x?void 0:x.eventId)===t.event.id&&"move"===(null==x?void 0:x.mode),hourHeight:p,firstHour:y,onMoveStart:D,onResizeStart:w,onEventUpdate:C,onEventDelete:E,newlyCreatedEventId:k,onDetailPanelOpen:()=>j(null),selectedEventId:T,detailPanelEventId:N,onEventSelect:t=>{const n=!1!==e.getReadOnlyConfig().viewable,a=e.state.readOnly;if((u||g)&&t&&n&&!a){const e=L.find(e=>e.id===t);if(e)return A(e),void $(!0)}S(t)},onEventLongPress:e=>{(u||g)&&S(e)},onDetailPanelToggle:e=>M(e),customDetailPanelContent:O,customEventDetailDialog:P,app:e,isMobile:u,enableTouch:g},t.id))})]})})]}),r.jsx("div",{className:"flex-1 bg-white dark:bg-gray-900"})]})]})})})},ca=({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:v,handleCreateStart:f,handleTouchStart:p,handleTouchEnd:y,handleTouchMove:x,handleDragOver:b,handleDrop:D,dragState:w,isDragging:C,handleMoveStart:E,handleResizeStart:k,handleEventUpdate:j,handleEventDelete:T,newlyCreatedEventId:S,setNewlyCreatedEventId:N,selectedEventId:M,setSelectedEventId:I,detailPanelEventId:H,setDetailPanelEventId:R,customDetailPanelContent:O,customEventDetailDialog:P,events:L,setDraftEvent:A,setIsDrawerOpen:$,isCurrentWeek:z,currentTime:Y,HOUR_HEIGHT:F,FIRST_HOUR:V,LAST_HOUR:W})=>{const B={flexShrink:0},Z=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:Be,children:r.jsx("div",{className:`${Ze} text-[10px] md:text-[12px]`,children:0===t?"":e.label})},t)),r.jsx("div",{className:"relative",children:r.jsx("div",{className:`${Ze} text-[10px] md:text-[12px]`,children:"00:00"})}),z&&Y&&(()=>{const e=Y,t=e.getHours()+e.getMinutes()/60;if(t<V||t>W)return null;const n=(t-V)*F;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:_e,children:Q(t)})})})()]})}),r.jsx("div",{ref:u,className:"flex-1 overflow-auto relative calendar-content snap-x snap-mandatory",onScroll:v,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<V||t>W)return null;const n=e.getDay(),o=0===n?6:n-1,s=(t-V)*F;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:Ue,children:a.map((n,s)=>{const l=new Date(o);return l.setDate(o.getDate()+s),r.jsx("div",{className:"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:B,onDoubleClick:t=>{null==f||f(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:"h-3 border-t border-gray-200 dark:border-gray-700 flex relative",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:B},`24-${t}`))}),a.map((t,n)=>{const a=ue(n,s),i=[];return a.forEach(e=>{const t=Gn(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=Gn(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(ra,{event:t,layout:s,calendarRef:h,isBeingDragged:C&&(null==w?void 0:w.eventId)===t.id&&"move"===(null==w?void 0:w.mode),hourHeight:F,firstHour:V,onMoveStart:E,onResizeStart:k,onEventUpdate:j,onEventDelete:T,newlyCreatedEventId:S,onDetailPanelOpen:()=>N(null),selectedEventId:M,detailPanelEventId:H,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 A(e),void $(!0)}I(t),e.state.highlightedEventId&&(e.highlightEvent(null),Z.current=null)},onEventLongPress:e=>{(d||c)&&I(e)},onDetailPanelToggle:e=>R(e),customDetailPanelContent:O,customEventDetailDialog:P,multiDaySegmentInfo:a,app:e,isMobile:d,enableTouch:c},a?`${t.id}-seg-${n}`:t.id)})},`events-day-${n}`)})]})]})})]})},ua=({app:e,customDetailPanelContent:n,customEventDetailDialog:a,calendarRef:o})=>{const{t:s,getWeekDaysLabels:l,locale:i}=Se(),d=e.getCurrentDate(),c=e.getEvents(),{screenSize:u}=on(),g="desktop"!==u,m="mobile"===u?48:80,[h,v]=t.useState(0),f=t.useRef(null),[p,y]=t.useState(!1);t.useEffect(()=>{y("ontouchstart"in window||navigator.maxTouchPoints>0)},[]),t.useLayoutEffect(()=>{const e=f.current;if(!e)return;const t=()=>{v(e.offsetWidth)};t();const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);const x=e.getCustomMobileEventRenderer()||Dn,b=t.useMemo(()=>sa(d),[d]),[D,w]=t.useState(null),[C,E]=t.useState(null),[k,j]=t.useState(null),[T,S]=t.useState(null),[N,M]=t.useState(!1),[I,H]=t.useState(null),R=t.useRef(null),{HOUR_HEIGHT:P,FIRST_HOUR:L,LAST_HOUR:$,TIME_COLUMN_WIDTH:z,ALL_DAY_HEIGHT:Y}=Ln,F=t.useRef(null),V=t.useRef(null),W=t.useRef(null),U=t.useRef(null),q=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,b),[c,b]),_=t.useRef(e.state.highlightedEventId);t.useEffect(()=>{if(e.state.highlightedEventId!==_.current)if(e.state.highlightedEventId){j(e.state.highlightedEventId);const t=q.find(t=>t.id===e.state.highlightedEventId);if(t&&!t.allDay){const e=B(t.start),n=V.current;if(n){const t=(e-L)*P;requestAnimationFrame(()=>{n.scrollTo({top:Math.max(0,t-100),behavior:"smooth"})})}}}else j(null);_.current=e.state.highlightedEventId},[e.state.highlightedEventId,q,L,P]);const X=t.useMemo(()=>((e,t)=>{const n=Xn(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})(q,b),[q,b]),G=t.useMemo(()=>{if(0===X.length)return Y;const e=Math.max(...X.map(e=>e.row));return Y+e*Y},[X,Y]),K=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=Gn(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:O(Z(ge(t,a),o.startHour)),end:O(Z(ge(t,a),n)),day:a});r.push(s)}}else e.day===a&&r.push(e)});const o=Pn.calculateDayEventLayouts(r,{viewType:"week"});n.set(a,o)}return n})(q,b),[q,b]),{handleMoveStart:J,handleCreateStart:ee,handleResizeStart:te,handleCreateAllDayEvent:ne,dragState:ae,isDragging:re}=Wn(e,{calendarRef:o,allDayRowRef:F,viewType:exports.ViewType.WEEK,onEventsUpdate:(t,n)=>{const a=t(q),r=new Set(a.map(e=>e.id)),o=q.filter(e=>!r.has(e.id)),s=new Set(q.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=q.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||B(t.start)!==B(e.start)||B(t.end)!==B(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?(H(t),M(!0)):(e.addEvent(t),S(t.id))},onEventEdit:()=>{},currentWeekStart:b,events:q,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:O(r),end:O(o),calendarId:"blue",allDay:!1},l=[...a.filter(t=>t.day===e&&!t.allDay),s];return Pn.calculateDayEventLayouts(l,{viewType:"week"}).get("-1")||null})(e,t,n,q),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=Z(o,n),l=Z(o,a),i=O(s),d=O(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:Pn.calculateDayEventLayouts(o,{viewType:"week"}).get(e.id)||null})(e,t,n,a,q),TIME_COLUMN_WIDTH:m,isMobile:g}),{handleDrop:oe,handleDragOver:se}=Bn({app:e,onEventCreated:e=>{S(e.id)}}),le=t.useMemo(()=>l(i,"short"),[i,l]),ie=t.useMemo(()=>{if(!g)return[];const e=i.split("-")[0].toLowerCase();return"zh"===e||"ja"===e?l(i,"narrow"):le.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,le]),de=t.useMemo(()=>s("allDay"),[s]),ce=Array.from({length:24},(e,t)=>({hour:t+L,label:Q(t+L)})),ue=t.useMemo(()=>{const e=new Date;return e.setHours(0,0,0,0),le.map((t,n)=>{const a=new Date(b);a.setDate(b.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()}})},[b,le,i]),me=t=>{e.updateEvent(t.id,t)},he=t=>{e.deleteEvent(t)},ve=t.useMemo(()=>{const e=new Date,t=sa(e);return b.getTime()===t.getTime()},[b]);t.useEffect(()=>{w(new Date);const e=setInterval(()=>w(new Date),6e4);return()=>clearInterval(e)},[]);const fe=g?"175%":"100%";return r.jsxs("div",{className:"relative flex flex-col bg-white dark:bg-gray-900 w-full overflow-hidden h-full select-none",children:[r.jsx(qn,{calendar:e,viewType:exports.ViewType.WEEK,currentDate:d,onPrevious:()=>e.goToPrevious(),onNext:()=>e.goToNext(),onToday:()=>e.goToToday()}),r.jsx(da,{app:e,weekDaysLabels:le,mobileWeekDaysLabels:ie,weekDates:ue,currentWeekStart:b,timeGridWidth:h,sidebarWidth:m,allDayAreaHeight:G,organizedAllDaySegments:X,allDayLabelText:de,isMobile:g,isTouch:p,calendarRef:o,allDayRowRef:F,topFrozenContentRef:W,ALL_DAY_HEIGHT:Y,HOUR_HEIGHT:P,FIRST_HOUR:L,dragState:ae,isDragging:re,handleMoveStart:J,handleResizeStart:te,handleEventUpdate:me,handleEventDelete:he,newlyCreatedEventId:T,setNewlyCreatedEventId:S,selectedEventId:k,setSelectedEventId:j,detailPanelEventId:C,setDetailPanelEventId:E,handleCreateAllDayEvent:ne,handleDragOver:se,handleDrop:oe,customDetailPanelContent:n,customEventDetailDialog:a,events:c,setDraftEvent:H,setIsDrawerOpen:M}),r.jsx(ca,{app:e,timeSlots:ce,weekDaysLabels:le,currentWeekStart:b,currentWeekEvents:q,eventLayouts:K,gridWidth:fe,isMobile:g,isTouch:p,scrollerRef:V,timeGridRef:f,leftFrozenContentRef:U,calendarRef:o,handleScroll:e=>{const{scrollTop:t,scrollLeft:n}=e.currentTarget;W.current&&(W.current.scrollLeft=n),U.current&&(U.current.style.transform=`translateY(${-t}px)`)},handleCreateStart:ee,handleTouchStart:(e,t,n)=>{if(!g&&!p)return;const a=e.touches[0],r=a.clientX,o=a.clientY,s=e.currentTarget;R.current=setTimeout(()=>{null==ee||ee({preventDefault:()=>{},stopPropagation:()=>{},touches:[{clientX:r,clientY:o}],changedTouches:[{clientX:r,clientY:o}],target:s,currentTarget:s,cancelable:!0},t,n)},500)},handleTouchEnd:()=>{R.current&&(clearTimeout(R.current),R.current=null)},handleTouchMove:()=>{R.current&&(clearTimeout(R.current),R.current=null)},handleDragOver:se,handleDrop:oe,dragState:ae,isDragging:re,handleMoveStart:J,handleResizeStart:te,handleEventUpdate:me,handleEventDelete:he,newlyCreatedEventId:T,setNewlyCreatedEventId:S,selectedEventId:k,setSelectedEventId:j,detailPanelEventId:C,setDetailPanelEventId:E,customDetailPanelContent:n,customEventDetailDialog:a,events:c,setDraftEvent:H,setIsDrawerOpen:M,isCurrentWeek:ve,currentTime:D,HOUR_HEIGHT:P,FIRST_HOUR:L,LAST_HOUR:$}),r.jsx(x,{isOpen:N,onClose:()=>{M(!1),H(null)},onSave:t=>{c.find(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),M(!1),H(null)},draftEvent:I,app:e})]})},ga={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}},ma=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:v,onMoveStart:f,onCreateStart:p,onResizeStart:y,onDetailPanelOpen:x,onMoreEventsClick:b,onChangeView:w,onSelectDate:C,selectedEventId:E,onEventSelect:k,onEventLongPress:j,detailPanelEventId:T,onDetailPanelToggle:S,customDetailPanelContent:N,customEventDetailDialog:M,onCalendarDrop:I,onCalendarDragOver:H,app:R,enableTouch:O})=>{const{t:P,locale:L}=Se(),[$,z]=t.useState(!1),Y=t.useRef(null),F=t.useRef(null),V=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,U=Z.days.find(e=>1===e.day),q=`${c}px`,_=t.useMemo(()=>Xn(u,Z.startDate),[u,Z.startDate]),X=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 D.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]),G=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})(_),[_]),K=t.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]),J=t.useMemo(()=>{for(const e of Z.days){if(X.filter(t=>{if(!t.start||!t.end)return A(t.start).toDateString()===e.date.toDateString();const n=A(t.start),a=A(t.end);if(!t.allDay){if(!(0!==a.getHours()||0!==a.getMinutes()||0!==a.getSeconds())){const t=a.getTime()-n.getTime();if(t>0&&t<864e5)return n.toDateString()===e.date.toDateString()}}return n.toDateString()===e.date.toDateString()||a.toDateString()===e.date.toDateString()}).length>W.maxSlots)return W.maxSlotsWithMore}return W.maxSlots},[Z.days,X,W.maxSlots,W.maxSlotsWithMore]),Q=t.useMemo(()=>Math.max(0,17*G.length),[G]),ee=(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:B(e.start)-B(t.start)))((c=t.date,X.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()}))),D=u.length;let $=0;$=D<=W.maxSlots?D:W.maxSlotsWithMore;const z=u.slice(0,$),Y=D-$,Z=Y>0,U=[],_=$,J=Math.min(null!==(l=K[n])&&void 0!==l?l:0,_);for(let e=0;e<J;e++)U.push(r.jsx("div",{className:"shrink-0",style:{height:"17px",minHeight:"17px"}},`placeholder-layer-${e}-${t.date.getTime()}`));return z.forEach((e,t)=>{const n=G.flat().find(t=>t.originalEventId===e.id);e.allDay&&n||U.push(r.jsx(ra,{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:v,onMoveStart:f,onResizeStart:y,onDetailPanelOpen:x,onEventSelect:k,onEventLongPress:j,newlyCreatedEventId:o,selectedEventId:E,detailPanelEventId:T,onDetailPanelToggle:S,customDetailPanelContent:N,customEventDetailDialog:M,app:R,isMobile:"desktop"!==s,enableTouch:O},`${e.id}-${e.day}-${B(e.start)}-${t}`))}),r.jsxs("div",{className:`\n 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:q},"data-date":(Q=t.date,`${Q.getFullYear()}-${String(Q.getMonth()+1).padStart(2,"0")}-${String(Q.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;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:H,onDrop:e=>null==I?void 0:I(e,t.date),children:[r.jsxs("div",{className:"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 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:[U,Z&&r.jsxs("div",{className:"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==w||w(exports.ViewType.DAY))},children:["+",Y," ",r.jsx("span",{className:"hidden md:inline",children:P("more")})]})]})]},`day-${t.date.getTime()}`);var Q},te=t.useMemo(()=>U?U.date.toLocaleDateString(L,{month:"long",year:"numeric"}):"",[U,L]);return r.jsxs("div",{className:"relative select-none border-b border-gray-200 dark:border-gray-700",style:{height:q},children:[U&&r.jsx("div",{className:`\n 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:te})}),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)=>ee(e,t))}),G.length>0&&r.jsx("div",{className:"absolute left-0 right-0 pointer-events-none",style:{top:"33px",height:`${Q}px`,zIndex:10},children:G.slice(0,J).map((e,t)=>r.jsx("div",{className:"absolute inset-0",children:e.map(e=>r.jsx(ra,{event:e.event,isAllDay:!!e.event.allDay,segment:e,segmentIndex:t,isMonthView:!0,isMultiDay:!0,calendarRef:m,hourHeight:72,firstHour:0,onEventUpdate:h,onEventDelete:v,onMoveStart:f,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:j,detailPanelEventId:T,onDetailPanelToggle:S,customDetailPanelContent:N,customEventDetailDialog:M,app:R,isMobile:"desktop"!==s,enableTouch:O},e.id))},`layer-${t}`))})]})})]})});ma.displayName="WeekComponent";const ha=({app:e,customDetailPanelContent:n,customEventDetailDialog:a,calendarRef:o})=>{const{getWeekDaysLabels:s,getMonthLabels:l,locale:i}=Se(),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:v}=on(),[f,p]=t.useState(!1);t.useEffect(()=>{p("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const y=e.getCustomMobileEventRenderer()||Dn,[x,b]=t.useState(119),[D,w]=t.useState(!1),C=t.useRef(x),E=t.useRef([]),[k,j]=t.useState(null),[T,S]=t.useState(!1),[N,M]=t.useState(null),[I,H]=t.useState(null),R=t.useRef(e.state.highlightedEventId);t.useEffect(()=>{e.state.highlightedEventId?H(e.state.highlightedEventId):R.current&&H(null),R.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:F,isDragging:V}=Wn(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||B(t.start)!==B(e.start)||B(t.end)!==B(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"!==v?(M(t),S(!0)):e.addEvent(t)},onEventEdit:e=>{j(e.id)},currentWeekStart:L,events:m}),{handleDrop:W,handleDragOver:Z}=Bn({app:e,onEventCreated:e=>{j(e.id)}}),U=t.useMemo(()=>s(i,"short"),[i,s]),{currentMonth:q,currentYear:_,isScrolling:X,virtualData:G,scrollElementRef:K,handleScroll:J,handlePreviousMonth:Q,handleNextMonth:ee,handleToday:te,setScrollTop:ne}=sn({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}=G,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}},[G]),de=t.useMemo(()=>ie*x,[ie,x]),ce=t.useMemo(()=>{const e=G.totalHeight,t=ie*x+16*x+se;return Math.max(0,e-t)},[G.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:$e,children:[r.jsx(qn,{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:"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:U.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:We,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(ma,{item:d,weekHeight:x,currentMonth:q,currentYear:_,screenSize:v,isScrolling:X,calendarRef:o,events:i,onEventUpdate:ue,onEventDelete:ge,onMoveStart:$,onCreateStart:z,onResizeStart:Y,isDragging:V,dragState:F,newlyCreatedEventId:k,onDetailPanelOpen:()=>j(null),onMoreEventsClick:e.onMoreEventsClick,onChangeView:me,onSelectDate:e.selectDate,selectedEventId:I,onEventSelect:t=>{const n=!1!==e.getReadOnlyConfig().viewable;if(("desktop"!==v||f)&&t&&n){const e=m.find(e=>e.id===t);if(e)return M(e),void S(!0)}H(t)},onEventLongPress:e=>{("desktop"!==v||f)&&H(e)},detailPanelEventId:O,onDetailPanelToggle:P,customDetailPanelContent:n,customEventDetailDialog:a,onCalendarDrop:W,onCalendarDragOver:Z,calendarSignature:u,app:e,enableTouch:f},`week-${t.weekData.startDate.getTime()}`)}),r.jsx("div",{style:{height:ce}})]}),r.jsx(y,{isOpen:T,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})]})},va={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 fa=t.memo(({date:e,isToday:t,locale:n,onSelectDate:a,onCreateStart:o,onMoreEventsClick:s,moreCount:l=0})=>{const{t:i}=Se(),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")]})})]})});fa.displayName="YearDayCell";const pa=({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:v,app:f,calendarRef:p})=>{const{event:y,startCellIndex:x,endCellIndex:b,visualRowIndex:D,isFirstSegment:w,isLastSegment:C}=e,E=t.useRef(null),k=t.useRef(null),[j,T]=t.useState(null),S=c===e.id,N=!(null==f?void 0:f.state.readOnly),M=x/n*100,I=(b-x+1)/n*100,H=y.calendarId||"blue",R=s?G(H):_(H),O=s?"#fff":X(H),P=K(H),L=!!y.allDay,A=L?_n(y):null,$=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),T({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},F=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:`${$}px`,height:"16px",backgroundColor:R,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":F,"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&&_n(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:K(H),width:"12px",height:"12px"},children:_n(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&&A&&r.jsx("div",{className:"df-year-event-icon shrink-0 flex items-center justify-center opacity-80 scale-75",children:A}),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(v){const t=v,n={event:y,isOpen:S,isAllDay:L,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(r.jsx(t,Object.assign({},n)),a):null}return j?h?r.jsx(Qn,{event:y,position:j,panelRef:k,isAllDay:L,onClose:e,contentRenderer:h,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}):r.jsx(Jn,{event:y,position:j,panelRef:k,isAllDay:L,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})()]})},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:v,newlyCreatedEventId:f,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 v=Math.round((u-o)/864e5);m=v<t.length?v:t.length-1,g=Math.max(0,Math.min(g,n-1)),m=Math.max(0,Math.min(m,n-1));const f=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:f,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(fa,{date:e,isToday:n,locale:l,onSelectDate:e=>{o.selectDate(e)},onCreateStart:g,onMoreEventsClick:v,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(pa,{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:f,onDetailPanelOpen:p,calendarRef:s,app:o,detailPanelEventId:y,customDetailPanelContent:b,customEventDetailDialog:D})},e.id))})})]})});ya.displayName="YearRowComponent";const xa=({app:e,calendarRef:a,customDetailPanelContent:o,customEventDetailDialog:s,config:l})=>{var i;const{locale:d}=Se(),c=e.getCurrentDate(),u=c.getFullYear(),g=e.getEvents(),m=t.useRef(null),[h,v]=t.useState(()=>"undefined"!=typeof window?Math.max(1,Math.floor(window.innerWidth/80)):7),[f,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);v(Math.max(1,n)),p(!0)});return t.observe(e),()=>t.disconnect()},[]);const{handleMoveStart:E,handleResizeStart:k,handleCreateStart:j,dragState:T,isDragging:S}=Wn(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==j||j(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,j,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]),H=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]),R=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:$e,children:[r.jsx(qn,{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:`${We}`,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:f?1:0,transition:"opacity 0.2s ease"},children:H.map((t,n)=>r.jsx(ya,{rowDays:t,events:R,columnsPerRow:h,app:e,calendarRef:a,locale:d,isDragging:S,dragState:T,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 ba(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),v=o+(m-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=h;t<=v;t++)if(c[y][t]){e=!0;break}if(!e){for(let e=h;e<=v;e++)c[y][e]=!0;break}y++}d.push({id:`${e.id}_month_${t}`,event:e,startCellIndex:h,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 Da=({app:e,calendarRef:a,customDetailPanelContent:o,customEventDetailDialog:s,config:l})=>{var i;const{locale:d,getWeekDaysLabels:c}=Se(),u=e.getCurrentDate(),g=u.getFullYear(),m=e.getEvents(),h=new Date;h.setHours(0,0,0,0);const v=t.useRef(null),f=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),[j,T]=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:H,isDragging:R}=Wn(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=>{T(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),T(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}=ba($,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;v.current&&(v.current.scrollLeft=t.scrollLeft),f.current&&(f.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(qn,{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:v,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:f,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(pa,{segment:t,columnsPerRow:S,isDragging:R&&H.eventId===t.event.id,isSelected:w===t.event.id,onMoveStart:N,onResizeStart:M,onEventSelect:C,onDetailPanelToggle:k,newlyCreatedEventId:j,onDetailPanelOpen:()=>T(null),calendarRef:a,app:e,detailPanelEventId:E,customDetailPanelContent:o,customEventDetailDialog:s})},t.id))})})]},t.monthIndex))})})]})},wa=e=>{var t;return"fixed-week"===((null===(t=e.config)||void 0===t?void 0:t.mode)||"year-canvas")?r.jsx(Da,Object.assign({},e,{config:e.config})):r.jsx(xa,Object.assign({},e,{config:e.config}))},Ca={enableDrag:!1,enableResize:!1,enableCreate:!1,enableVirtualScroll:!0,showDebugInfo:!1,eventsConfig:{enableAutoRecalculate:!1,enableValidation:!0},viewConfig:{enableVirtualScroll:!0,showDebugInfo:!1}},Ea={enableAutoRecalculate:!0,enableValidation:!0,defaultEvents:[],maxEventsPerDay:50};exports.CalendarApp=De,exports.CalendarEvent=ra,exports.CalendarRegistry=p,exports.ColorPicker=mt,exports.DayFlowCalendar=e=>{const{calendar:t,customMessages:n}=e,a=t.app;return r.jsx(En,{locale:a.state.locale,messages:n,children:r.jsx(kn,Object.assign({},e))})},exports.DefaultEventDetailDialog=It,exports.DefaultEventDetailPanel=Jn,exports.EventDetailPanelWithContent=Qn,exports.EventLayoutCalculator=Pn,exports.LOCALES=M,exports.LocaleContext=Te,exports.TIME_STEP=J,exports.ThemeProvider=cn,exports.ViewHeader=qn,exports.addDays=W,exports.buildParseRegExp=yt,exports.calculateDayIndex=he,exports.capitalize=Ce,exports.conditionalTheme=(e,t,n)=>e?t:n,exports.convertDateEvent=function(e,t,n,a,r=!1,o){return Jt(Object.assign({id:e,title:t,start:n,end:a,allDay:r},o))},exports.convertDateEventWithTimeZone=function(e,t,n,a,r,o){return Qt(Object.assign({id:e,title:t,start:n,end:a,timeZone:r},o))},exports.createAllDayEvent=function(e,t,n,a){return Jt(Object.assign({id:e,title:t,start:n,end:n,allDay:!0},a))},exports.createDateWithHour=Z,exports.createDayView=(e={})=>{const n=Object.assign(Object.assign({},ia),e),a=e=>t.createElement(jn,{viewType:exports.ViewType.DAY,originalComponent:la,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:()=>{D.log("Drag plugin installed - providing drag capabilities")},api:n}},exports.createEvent=Jt,exports.createEventWithDate=(e,t)=>{var n,a;const r=ge(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:me(r,o),end:me(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:me(r,o),end:me(r,o)})},exports.createEvents=function(e){return e.map(e=>Jt(e))},exports.createEventsPlugin=function(e={}){const t=Object.assign(Object.assign({},Ea),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,D.log("Events plugin installed - providing event management services")},api:a}},exports.createMonthView=(e={})=>{const n=Object.assign(Object.assign({},va),e),a=e=>t.createElement(jn,{viewType:exports.ViewType.MONTH,originalComponent:ha,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=$,exports.createTimedEvent=function(e,t,n,a,r){return Jt(Object.assign({id:e,title:t,start:n,end:a},r))},exports.createTimezoneEvent=Qt,exports.createTimezoneEvents=function(e){return e.map(e=>Qt(e))},exports.createWeekView=(e={})=>{const n=Object.assign(Object.assign({},ga),e),a=e=>t.createElement(jn,{viewType:exports.ViewType.WEEK,originalComponent:ua,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({},Ca),e);e.mode&&(n.viewConfig=Object.assign(Object.assign({},n.viewConfig),{mode:e.mode}));const a=e=>t.createElement(jn,{viewType:exports.ViewType.YEAR,originalComponent:wa,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=Ut,exports.dateToPlainDateTime=qt,exports.dateToZonedDateTime=_t,exports.daysBetween=function(e,t){const n=R(e)?e:e.toPlainDate(),a=R(t)?t:t.toPlainDate();return n.until(a).days},exports.daysDifference=V,exports.de=S,exports.en=C,exports.es=N,exports.extractHourFromDate=B,exports.extractHourFromTemporal=function(e){return Wt(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=Vt,exports.formatEventTimeRange=ee,exports.formatMonthYear=e=>`${["January","February","March","April","May","June","July","August","September","October","November","December"][e.getMonth()]} ${e.getFullYear()}`,exports.formatTemporal=wt,exports.formatTime=Q,exports.fr=T,exports.generateDayData=le,exports.generateUniKey=pe,exports.generateWeekData=ie,exports.generateWeekRange=ce,exports.generateWeeksData=(e,t=3)=>{const n=5*t,{monday:a}=se(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(ie(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 ae.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=ge,exports.getDateObj=en,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=U,exports.getEndOfTemporal=F,exports.getEventBgColor=_,exports.getEventEndHour=ne,exports.getEventTextColor=X,exports.getEventsForDay=ue,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=he(A(e.start),t);return Object.assign(Object.assign({},e),{day:n})})},exports.getIntlLabel=we,exports.getLineColor=K,exports.getMonthLabels=ke,exports.getMonthYearOfWeek=de,exports.getPlainDate=function(e){return Wt(e)?e:(Bt(e),e.toPlainDate())},exports.getSearchHeaderInfo=nn,exports.getSelectedBgColor=G,exports.getStartOfDay=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(0,0,0,0),t}return Y(e)},exports.getStartOfTemporal=Y,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=Ee,exports.getWeekRange=se,exports.getZoneId=bt,exports.groupSearchResults=an,exports.isDate=function(e){return e instanceof Date},exports.isDeepEqual=ye,exports.isEventEqual=fe,exports.isEventInWeek=(e,t)=>{const n=he(e,t);return n>=0&&n<=6},exports.isMultiDayEvent=(e,t)=>!q(e,t),exports.isMultiDayTemporalEvent=function(e,t){return!z(e,t)},exports.isPlainDate=Wt,exports.isPlainDateTime=Bt,exports.isSameDay=q,exports.isSamePlainDate=z,exports.isSameTemporal=function(e,t){const n=Wt(e)?e:(Bt(e),e.toPlainDate()),a=Wt(t)?t:(Bt(t),t.toPlainDate());return n.equals(a)},exports.isValidLocale=H,exports.isZonedDateTime=Zt,exports.ja=k,exports.ko=j,exports.mergeClasses=(...e)=>e.filter(Boolean).join(" "),exports.mergeFormatTemplate=ft,exports.monthNames=re,exports.normalizeCssWidth=w,exports.normalizeDate=tn,exports.normalizeLocale=I,exports.normalizeToZoned=Dt,exports.now=function(e=n.Temporal.Now.timeZoneId()){return n.Temporal.Now.zonedDateTimeISO(e)},exports.pad=vt,exports.parseTemporalString=xt,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=Xt,exports.roundToTimeStep=te,exports.setHourInTemporal=function(e,t){const n=Math.floor(t),a=Math.round(60*(t-n));return Zt(e),e.with({hour:n,minute:a,second:0,millisecond:0})},exports.shortMonthNames=oe,exports.t=je,exports.temporalToDate=function(e){if(Wt(e))return new Date(e.year,e.month-1,e.day);if(Bt(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=ge(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:me(r,o),end:me(r,o)})},exports.useCalendarApp=function(e){const n=t.useMemo(()=>new De(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 v=n.updateCalendar;n.updateCalendar=(e,t)=>{v(e,t),g()};const f=n.createCalendar;n.createCalendar=e=>{f(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(()=>{ye(m.current,e)||(n.updateConfig(e),m.current=e)},[n,e]);const h=t.useCallback(e=>{n.changeView(e)},[n]),v=t.useCallback(e=>{n.setCurrentDate(e)},[n]),f=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:v,addEvent:f,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=Vn,exports.useDragForView=Wn,exports.useLocale=Se,exports.useResponsiveConfig=()=>{const[e,n]=t.useState({yearHeight:Yt,screenSize:"desktop"});return t.useEffect(()=>{const e=()=>{const e=window.innerWidth;n(e<640?{yearHeight:$t,screenSize:"mobile"}:e<900?{yearHeight:zt,screenSize:"tablet"}:{yearHeight:Yt,screenSize:"desktop"})};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e},exports.useResponsiveMonthConfig=on,exports.useTheme=un,exports.useVirtualMonthScroll=sn,exports.useVirtualScroll=({currentDate:e,yearHeight:n,onCurrentYearChange:a})=>{const r=e.getFullYear(),o=(r-Ot)*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),v=t.useRef(null),f=t.useRef(0),p=t.useRef(0),y=t.useRef(n);t.useEffect(()=>{if(y.current===n)return;y.current=n;const e=(c-Ot)*n;l(e),p.current=e,h.current&&(h.current.scrollTop=e)},[n,c]);const x=t.useMemo(()=>{const e=performance.now(),t=Pt-Ot+1,a=t*n,r=Math.floor(s/n),o=Math.min(t-1,Math.ceil((s+i)/n)),l=Math.max(0,r-Rt),d=Math.min(t-1,o+Rt),c=[];for(let e=l;e<=d;e++)c.push({index:e,year:Ot+e,top:e*n,height:n});const u=performance.now()-e;return Ft.trackRenderTime(u),{totalHeight:a,visibleItems:c}},[s,i,n]),b=t.useCallback(e=>{const t=performance.now();if(t-f.current<Lt)return;f.current=t;const r=e.currentTarget.scrollTop,o=Math.abs(r-p.current);p.current=r,Ft.trackScrollEvent(o),requestAnimationFrame(()=>{l(r);const e=r,t=Math.floor(Ot+e/n);t!==c&&t>=Ot&&t<=Pt&&(u(t),null==a||a(t))}),m(!0),v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{m(!1)},At)},[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-Ot)*n;h.current.scrollTo({top:Math.max(0,a),behavior:t?"smooth":"auto"})},[n]),w=t.useCallback(()=>{const e=Math.max(Ot,c-1);u(e),D(e)},[c,D]),C=t.useCallback(()=>{const e=Math.min(Pt,c+1);u(e),D(e)},[c,D]),E=t.useCallback(()=>{const e=(new Date).getFullYear();u(e),D(e)},[D]);return t.useEffect(()=>()=>{v.current&&clearTimeout(v.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=ae,exports.weekDaysFullName=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],exports.zh=E,exports.zonedDateTimeToDate=L;
1
+ "use strict";var e,t=require("react"),n=require("temporal-polyfill"),a=require("tslib"),r=require("react/jsx-runtime"),o=require("react-dom"),l=require("react-color"),s=require("lucide-react"),i=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 d=100,c=8,u=150,g=80,m=90,h=119;class v{constructor(e=d){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 f=[{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 p{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)}):f.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 y=new p;function x(){return y}function b(e){const t=f.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 D=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 w(e,t="240px"){return"number"==typeof e?`${e}px`:"string"==typeof e&&e.trim().length>0?e:t}const C={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"}},E={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:"明天"}},k={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:"明日"}},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:"내일"}},T={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"}},S={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"}},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"}},N={en:C,zh:E,ja:k,ko:j,fr:T,de:S,es:M};function I(e){const t=e.split("-")[0].toLowerCase();return t in N?t:"en"}function H(e){try{return new Intl.DateTimeFormat(e),!0}catch(e){return!1}}function R(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 O(e,t=n.Temporal.Now.timeZoneId()){return n.Temporal.Instant.fromEpochMilliseconds(e.getTime()).toZonedDateTimeISO(t)}function P(e){return n.Temporal.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()})}function L(e){return new Date(e.epochMilliseconds)}function A(e,t){return R(e)?function(e,t=n.Temporal.Now.timeZoneId()){return L(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):L(e)}function $(e,t){const a=Math.floor(t),r=Math.round(60*(t-a));return R(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 z(e,t){const a=R(e)?e:e.toPlainDate(),r=R(t)?t:t.toPlainDate();return 0===n.Temporal.PlainDate.compare(a,r)}function Y(e,t=n.Temporal.Now.timeZoneId()){return(R(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(R(e)?e:e.toPlainDate()).toZonedDateTime({timeZone:t,plainTime:n.Temporal.PlainTime.from({hour:23,minute:59,second:59,millisecond:999})})}function V(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 W(e,t){const n=new Date(e);return n.setDate(n.getDate()+t),n}const B=e=>{if(e instanceof Date){return e.getHours()+e.getMinutes()/60}return R(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},Z=(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 $(e,t)},U=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 z(e instanceof Date?n.Temporal.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()}):R(e)?e:e.toPlainDate(),t instanceof Date?n.Temporal.PlainDate.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}):R(t)?t:t.toPlainDate())},_=(e,t)=>(t||x()).resolveColors(e).eventColor,X=(e,t)=>(t||x()).resolveColors(e).textColor,G=(e,t)=>(t||x()).resolveColors(e).eventSelectedColor,K=(e,t)=>(t||x()).resolveColors(e).lineColor,J=.25,Q=(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")}`},ee=e=>{const t=B(e.start),n=ne(e);return`${Q(t)} - ${Q(n)}`},te=e=>{const t=J;return Math.round(e/t)*t},ne=e=>{if(!e.end)return 0;const t=B(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},ae=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],re=["January","February","March","April","May","June","July","August","September","October","November","December"],oe=["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}},se=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:re[a],shortMonthName:oe[a],isToday:o.getDate()===n&&o.getMonth()===a&&o.getFullYear()===r}},ie=e=>{const t=[],n=new Date(e);for(let e=0;e<7;e++){const e=new Date(n);t.push(se(e)),n.setDate(n.getDate()+1)}return{days:t,startDate:new Date(e),monthYear:de(t)}},de=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:re[r],monthIndex:r,year:o}};function ce(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 s=new Date(r);s.setDate(s.getDate()-7*a);for(let e=0;e<t;e++){const t=new Date(s);t.setDate(t.getDate()+7*e),n.push(ie(t))}return n}const ue=(e,t)=>t.filter(t=>t.day===e&&!t.allDay),ge=(e,t)=>{const n=new Date(e);return n.setDate(e.getDate()+t),n},me=(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()}),he=(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=he(n,t);return Object.assign(Object.assign({},e),{day:a})}),fe=(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 pe(){return Date.now().toString(36)+Math.random().toString(36).substring(2,8)}function ye(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)||!ye(e[r],t[r]))return!1;return!0}const xe="240px",be=e=>{if(!e)return{enabled:!1,width:xe,initialCollapsed:!1};if(!0===e)return{enabled:!0,width:xe,initialCollapsed:!1};const{enabled:t=!0,width:n,initialCollapsed:a=!1,render:r,createCalendarMode:o,renderCalendarContextMenu:l,renderCreateCalendarDialog:s}=e;return{enabled:t,width:w(n,xe),initialCollapsed:a,render:r,createCalendarMode:o,renderCalendarContextMenu:l,renderCreateCalendarDialog:s}};class De{constructor(e){var n,a,r,o,l;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)):D.warn("Cannot add event in read-only mode")},this.updateEvent=(e,t,n)=>{if(!this.isInternalEditable()&&!n)return void D.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 D.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 l=this.calendarRegistry.get(e);l&&(null===(a=(n=this.callbacks).onCalendarUpdate)||void 0===a||a.call(n,l)),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)?D.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||ye(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=be(e.useSidebar);ye(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);ye(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 p(e.calendars,e.defaultCalendar,(null===(n=e.theme)||void 0===n?void 0:n.mode)||"light"),l=this.calendarRegistry,y=l,this.sidebarConfig=be(e.useSidebar),this.state.sidebar=this.sidebarConfig;const s=this.state.currentDate;this.visibleMonth=new Date(s.getFullYear(),s.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 we(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 Ce(e){return e.charAt(0).toUpperCase()+e.slice(1)}const Ee=(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},ke=(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=we(e,t);if(n)return Ce(n)}const a=I(t),r=N[a],o=null===(n=null==r?void 0:r.messages)||void 0===n?void 0:n[e];if(o)return o;const l=N.en.messages;return(null==l?void 0:l[e])||e}const Te=t.createContext({locale:"en-US",t:e=>e,getWeekDaysLabels:()=>[],getMonthLabels:()=>[],isDefault:!0});function Se(){return t.useContext(Te)}const Me=({x:e,y:n,onClose:a,children:l,className:s})=>{const i=t.useRef(null);t.useEffect(()=>{const e=e=>{i.current&&!i.current.contains(e.target)&&a()};document.addEventListener("mousedown",e);const t=()=>a();return window.addEventListener("scroll",t,!0),window.addEventListener("resize",t),()=>{document.removeEventListener("mousedown",e),window.removeEventListener("scroll",t,!0),window.removeEventListener("resize",t)}},[a]);const d={top:n,left:e};return o.createPortal(r.jsx("div",{ref:i,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 ${s||""}`,style:d,onContextMenu:e=>e.preventDefault(),children:l}),document.body)},Ne=({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]}),Ie=()=>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}),Re=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],Oe=({selectedColor:e,onSelect:t,onCustomColor:n})=>{const{t:a}=Se();return r.jsxs("div",{className:"p-2",children:[r.jsx("div",{className:"grid grid-cols-7 gap-2 p-1",children:Re.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")})]})},Pe=({isCollapsed:e,onCollapseToggle:t})=>{const{t:n}=Se();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(s.PanelRightClose,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"}):r.jsx(s.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")})})]})},Le=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:l,editingId:s,setEditingId:i,activeContextMenuCalendarId:d,isDraggable:c=!0,isEditable:u=!0})=>{const[g,m]=t.useState(""),h=t.useRef(null),[v,f]=t.useState(!1),[p,y]=t.useState(null),[x,b]=t.useState(null),D=t.useCallback((e,t)=>{if(s||!c)return void t.preventDefault();f(!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"},[s]),w=t.useCallback(()=>{f(!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]),j=t.useCallback(e=>{u&&(i(e.id),m(e.name))},[i,u]),T=t.useCallback(e=>{m(e.target.value)},[]),S=t.useCallback(()=>{if(s&&g.trim()){const t=e.find(e=>e.id===s);t&&t.name!==g.trim()&&o(s,g.trim())}i(null),m("")},[s,g,e,o,i]),M=t.useCallback(()=>{i(null),m("")},[i]),N=t.useCallback(e=>{"Enter"===e.key?S():"Escape"===e.key&&M()},[S,M]);return t.useEffect(()=>{s&&h.current&&(h.current.focus(),h.current.select())},[s]),t.useEffect(()=>{if(s){const t=e.find(e=>e.id===s);t&&m(t.name)}},[s,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||s===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=>l(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&&!s,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:Le(e)}),s===e.id?r.jsx("input",{ref:h,type:"text",value:g,onChange:T,onBlur:S,onKeyDown:N,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:()=>j(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)})})})},$e="df-month-view h-full flex flex-col bg-white dark:bg-gray-900 select-none",ze="df-header p-2 flex justify-between",Ye="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)",Ve="df-date-number inline-flex items-center justify-center h-6 w-6 rounded-full text-sm mt-1 select-none",We="flex-1 overflow-auto will-change-scroll",Be="df-time-slot relative h-[4.5rem] flex",Ze="df-time-label absolute -top-2.5 right-2 text-[12px] text-gray-500 dark:text-gray-400 select-none",Ue="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",_e="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",Ge="rounded-xl my-0.5",Ke="df-event-title font-medium text-xs truncate pr-1",Je="df-event-color-bar absolute left-1 top-1 bottom-1 w-[3px] rounded-full",Qe="h-3 w-3 mr-1",et="resize-handle absolute right-0 top-0 bottom-0 w-1 cursor-ew-resize opacity-0 group-hover:opacity-100 transition-opacity z-20",tt="bg-primary rounded-full text-primary-foreground",nt="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",at="h-4 w-4 transition-transform group-hover:scale-110",rt="df-event-detail-panel fixed bg-white dark:bg-gray-800 shadow-lg border border-gray-200 dark:border-gray-700 rounded-lg",ot="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",st="text-gray-500 dark:text-gray-400",it="text-gray-600 dark:text-gray-300",dt="text-xs",ct="text-sm",ut="flex flex-col",gt="mr-1",mt=({visibleMonth:e,currentDate:n,showHeader:a=!1,onMonthChange:o,onDateSelect:l})=>{const{locale:i}=Se(),d=t.useMemo(()=>(new Date).toDateString(),[]),c=n.toDateString(),u=t.useMemo(()=>Ee(i,"narrow"),[i]),g=t.useMemo(()=>e.toLocaleDateString(i,{month:"long",year:"numeric"}),[e,i]),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),l=o.toDateString();r.push({date:o.getDate(),fullDate:o,isCurrentMonth:o.getMonth()===n,isToday:l===d,isSelected:l===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(s.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(s.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?tt: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:()=>l(e.fullDate),children:e.date},e.fullDate.getTime()))]})]})},ht=({calendars:e,currentCalendarId:n,onMergeSelect:a})=>{const{t:l}=Se(),[i,d]=t.useState(!1),c=t.useRef(null),u=t.useRef(null),[g,m]=t.useState({x:0,y:0}),h=t.useRef(),v=()=>{if(h.current&&clearTimeout(h.current),c.current){const e=c.current.getBoundingClientRect();m({x:e.right,y:e.top})}d(!0)},f=()=>{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)}}},[i]);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:v,onMouseLeave:f,children:[r.jsx("span",{children:l("merge")}),r.jsx(s.ChevronRight,{className:"h-4 w-4"})]}),i&&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:v,onMouseLeave:f,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}=Se();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")})]})]})})},ft=({calendarId:e,calendarName:n,calendars:a,step:o,onStepChange:l,onConfirmDelete:s,onCancel:i,onMergeSelect:d})=>{const[c,u]=t.useState(!1),{t:g}=Se();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:()=>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")})]})]})]}):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:s,className:"rounded-md bg-destructive px-4 py-2 text-sm font-medium text-destructive-foreground hover:bg-destructive/90",children:g("delete")})]})]})})})},pt=({app:e,calendars:n,toggleCalendarVisibility:a,isCollapsed:s,setCollapsed:i,renderCalendarContextMenu:d,editingCalendarId:c,setEditingCalendarId:u,onCreateCalendar:g})=>{var m,h,v,f;const{t:p}=Se(),y=e.getVisibleMonth(),x=y.getFullYear(),D=y.getMonth(),[w,C]=t.useState(null),E=void 0!==c?c:w,k=u||C,[j,T]=t.useState(()=>new Date(x,D,1));t.useEffect(()=>{T(e=>e.getFullYear()===x&&e.getMonth()===D?e:new Date(x,D,1))},[x,D]);const S=t.useCallback(t=>{T(n=>{const a=new Date(n.getFullYear(),n.getMonth()+t,1);return e.setVisibleMonth(a),a})},[e]),[M,N]=t.useState(null),[I,H]=t.useState(null),[R,O]=t.useState(null),[P,L]=t.useState(null),[A,$]=t.useState(null),z=t.useCallback((e,t)=>{e.preventDefault(),e.stopPropagation(),N({x:e.clientX,y:e.clientY,calendarId:t}),H(null)},[]),Y=t.useCallback(e=>{e.preventDefault(),H({x:e.clientX,y:e.clientY}),N(null)},[]),F=t.useCallback(()=>{N(null)},[]),V=t.useCallback(()=>{H(null)},[]),W=t.useCallback(()=>{M&&($({calendarId:M.calendarId,step:"initial"}),F())},[M,F]),B=t.useCallback(t=>{if(M){const{colors:n,darkColors:a}=b(t);e.updateCalendar(M.calendarId,{colors:n,darkColors:a}),F()}},[e,M,F]),Z=t.useCallback(()=>{if(M){const e=n.find(e=>e.id===M.calendarId);e&&O({x:M.x,y:M.y,calendarId:M.calendarId,initialColor:e.colors.lineColor,currentColor:e.colors.lineColor}),F()}},[M,n,F]),U=t.useCallback(e=>{M&&(L({sourceId:M.calendarId,targetId:e}),F())},[M,F]),q=t.useCallback(()=>{if(P){const{sourceId:t,targetId:n}=P;e.mergeCalendars(t,n),L(null)}},[e,P]),_=t.useCallback(()=>{A&&(e.deleteCalendar(A.calendarId),$(null))},[e,A]),X=t.useCallback(e=>{A&&(L({sourceId:A.calendarId,targetId:e}),$(null))},[A]),G=P?(null===(m=n.find(e=>e.id===P.sourceId))||void 0===m?void 0:m.name)||"Unknown":"",K=P?(null===(h=n.find(e=>e.id===P.targetId))||void 0===h?void 0:h.name)||"Unknown":"",J=A?(null===(v=n.find(e=>e.id===A.calendarId))||void 0===v?void 0:v.name)||"Unknown":"",Q=e.getReadOnlyConfig(),ee=!e.state.readOnly,te=!1!==Q.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:ee?Y:void 0,children:[r.jsx(Pe,{isCollapsed:s,onCollapseToggle:()=>i(!s)}),s?r.jsx(Ae,{calendars:n,onToggleVisibility:a,onReorder:te?e.reorderCalendars:()=>{},onRename:ee?(t,n)=>e.updateCalendar(t,{name:n}):()=>{},onContextMenu:ee?z:()=>{},editingId:E,setEditingId:k,activeContextMenuCalendarId:null==M?void 0:M.calendarId,isDraggable:te,isEditable:ee}):r.jsxs(r.Fragment,{children:[r.jsx(Ae,{calendars:n,onToggleVisibility:a,onReorder:te?e.reorderCalendars:()=>{},onRename:ee?(t,n)=>e.updateCalendar(t,{name:n}):()=>{},onContextMenu:ee?z:()=>{},editingId:E,setEditingId:k,activeContextMenuCalendarId:null==M?void 0:M.calendarId,isDraggable:te,isEditable:ee}),r.jsx("div",{className:"border-t border-gray-200 dark:border-slate-800",children:r.jsx(mt,{visibleMonth:e.getVisibleMonth(),currentDate:e.getCurrentDate(),showHeader:!0,onMonthChange:S,onDateSelect:t=>e.setCurrentDate(t)})})]}),M&&r.jsx(Me,{x:M.x,y:M.y,onClose:F,className:"w-64 p-2",children:d?d(n.find(e=>e.id===M.calendarId),F):r.jsxs(r.Fragment,{children:[r.jsx(He,{children:p("calendarOptions")}),r.jsx(ht,{calendars:n,currentCalendarId:M.calendarId,onMergeSelect:U}),r.jsx(Ne,{onClick:W,children:p("delete")}),r.jsx(Ie,{}),r.jsx(Oe,{selectedColor:null===(f=n.find(e=>e.id===M.calendarId))||void 0===f?void 0:f.colors.lineColor,onSelect:B,onCustomColor:Z})]})}),I&&o.createPortal(r.jsxs(Me,{x:I.x,y:I.y,onClose:V,className:"w-max p-2",children:[r.jsx(Ne,{onClick:()=>{null==g||g(),V()},children:p("newCalendar")||"New Calendar"}),r.jsx(Ne,{onClick:()=>{e.triggerRender(),V()},children:p("refreshAll")||"Refresh All"})]}),document.body),P&&o.createPortal(r.jsx(vt,{sourceName:G,targetName:K,onConfirm:q,onCancel:()=>L(null)}),document.body),A&&o.createPortal(r.jsx(ft,{calendarId:A.calendarId,calendarName:J,calendars:n,step:A.step,onStepChange:e=>$(t=>t?Object.assign(Object.assign({},t),{step:e}):null),onConfirmDelete:_,onCancel:()=>$(null),onMergeSelect:X}),document.body),R&&o.createPortal(r.jsx("div",{className:"fixed inset-0 z-50",onMouseDown:()=>O(null),children:r.jsx("div",{className:"absolute rounded-md bg-white shadow-xl border border-gray-200 dark:bg-slate-800 dark:border-gray-700",style:{top:R.y,left:R.x},onMouseDown:e=>e.stopPropagation(),children:r.jsx(l.SketchPicker,{width:"220px",color:R.currentColor,onChange:e=>{O(t=>t?Object.assign(Object.assign({},t),{currentColor:e.hex}):null)},onChangeComplete:t=>{const{colors:n,darkColors:a}=b(t.hex);e.updateCalendar(R.calendarId,{colors:n,darkColors:a})}})})}),document.body)]})},yt=({options:e,value:n,onChange:a,registry:l,variant:i="desktop"})=>{const[d,c]=t.useState(!1),[u,g]=t.useState({}),m=t.useRef(null),h=t.useRef(null),v=()=>{if(h.current){const e=h.current.getBoundingClientRect(),t="mobile"===i,n={position:"fixed",zIndex:10001,minWidth:t?"12rem":`${e.width}px`,top:`${e.bottom+4}px`};t?n.right=window.innerWidth-e.right+"px":n.left=`${e.left}px`,g(n)}};t.useEffect(()=>{const e=e=>{!m.current||m.current.contains(e.target)||e.target.closest("[data-color-picker-dropdown]")||c(!1)};return d&&(v(),window.addEventListener("mousedown",e),window.addEventListener("scroll",v,!0),window.addEventListener("resize",v)),()=>{window.removeEventListener("mousedown",e),window.removeEventListener("scroll",v,!0),window.removeEventListener("resize",v)}},[d]);const f=e=>(l||x()).resolveColors(e).lineColor,p=(e,t)=>{e.stopPropagation(),a(t),c(!1)},y=e.find(e=>e.value===n),b=()=>d&&"undefined"!=typeof window?"mobile"===i?o.createPortal(r.jsx("div",{"data-color-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(s.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:f(e.value)}})]},e.value))}),document.body):o.createPortal(r.jsx("ul",{"data-color-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(s.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:f(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"===i?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:f(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(s.ChevronsUpDown,{className:"w-4 h-4 text-gray-400"})]}),b()]}):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:f(n)}}),r.jsx(s.ChevronsUpDown,{className:"w-4 h-4 text-gray-600 dark:text-gray-300"})]}),b()]})},xt=/(YYYY|YY|MM|DD|HH|mm)/g,bt=e=>e.toString().padStart(2,"0"),Dt=(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`)},wt=e=>e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),Ct=e=>{let t,n=0,a="^";for(;null!==(t=xt.exec(e));){a+=wt(e.slice(n,t.index));const r=t[0];a+=`(?<${r}>\\d{${"YYYY"===r?4:2}})`,n=t.index+r.length}return a+=wt(e.slice(n))+"$",new RegExp(a)},Et=(e,t,a,r)=>{const o=e.trim();if(!o)return null;const l=o.match(t),s=null==l?void 0:l.groups;if(!s)return null;const i=s.YYYY?Number(s.YYYY):s.YY?Number(s.YY)+2e3:a.year,d=s.MM?Number(s.MM):a.month,c=s.DD?Number(s.DD):a.day,u=s.HH?Number(s.HH):a.hour,g=s.mm?Number(s.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}},kt=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()},jt=(e,t,a)=>{var r,o,l,s,i,d,c,u,g,m,h,v,f,p,y,x,b,D,w,C,E,k,j,T;if(!e){const e=null!=t?t:a?kt(a):n.Temporal.Now.timeZoneId();return null!=a?a:n.Temporal.Now.zonedDateTimeISO(e)}if(R(e)){const a=null!=t?t:n.Temporal.Now.timeZoneId(),r=`${e.year}-${bt(e.month)}-${bt(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!==(l=e.microsecond)&&void 0!==l?l:0,nanosecond:null!==(s=e.nanosecond)&&void 0!==s?s:0})}try{return n.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===(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?kt(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:l})}catch(e){}const s=null!=a?a:n.Temporal.Now.zonedDateTimeISO(l);return n.Temporal.ZonedDateTime.from({timeZone:l,year:null!==(m=null==o?void 0:o.year)&&void 0!==m?m:s.year,month:null!==(h=null==o?void 0:o.month)&&void 0!==h?h:s.month,day:null!==(v=null==o?void 0:o.day)&&void 0!==v?v:s.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!==(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!==(T=null!==(j=null==o?void 0:o.nanosecond)&&void 0!==j?j:null==a?void 0:a.nanosecond)&&void 0!==T?T:0})}},Tt=(e,t,n)=>{const a=Dt(t,n),r={YYYY:e.year.toString(),YY:bt(e.year%100),MM:bt(e.month),DD:bt(e.day),HH:bt(e.hour),mm:bt(e.minute)};return a.replace(xt,e=>{var t;return null!==(t=r[e])&&void 0!==t?t:e})},St=Array.from({length:24},(e,t)=>t),Mt=Array.from({length:60},(e,t)=>t),Nt=({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(s.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(s.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(s.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(s.ChevronsRight,{width:14,height:12})})]})]}),It=(e,t)=>n.Temporal.PlainDate.compare(e,t),Ht=({calendarDays:e,visibleMonth:t,startDate:n,endDate:a,weekDayLabels:o,disabled:l,onDaySelect:s})=>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===It(e,n),d=0===It(e,a),c=It(e,n)>=0&&It(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:l,onClick:()=>s(e),className:`flex h-9 w-9 items-center justify-center rounded-md text-sm transition ${u}`,children:e.day},e.toString())})})]}),Rt=({focusedField:e,draftRange:t,disabled:n,onHourSelect:a,onMinuteSelect:o,timeListRefs:l})=>{const s=e,i=t["start"===s?0:1],d=i.minute,c=Mt.includes(d)?Mt:[...Mt,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=>{l.current[s]&&(l.current[s].hour=e)},children:St.map(e=>{const t=e===i.hour;return r.jsx("button",{type:"button",role:"option","aria-selected":t,disabled:n,onClick:()=>a(s,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:bt(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=>{l.current[s]&&(l.current[s].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(s,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:bt(e)},e)})})})]})]})},Ot=({visibleMonth:e,monthLabels:t,weekDayLabels:n,calendarDays:a,draftRange:o,focusedField:l,isTimeEnabled:s,disabled:i,matchTriggerWidth:d,popupRef:c,timeListRefs:u,onMonthChange:g,onYearChange:m,onDaySelect:h,onHourSelect:v,onMinuteSelect:f,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(Nt,{visibleMonth:e,monthLabels:t,disabled:i,onMonthChange:g,onYearChange:m}),r.jsx(Ht,{calendarDays:a,visibleMonth:e,startDate:x,endDate:b,weekDayLabels:n,disabled:i,onDaySelect:h})]}),s&&r.jsx("div",{className:"flex flex-1 justify-end sm:w-32",children:r.jsx(Rt,{focusedField:l,draftRange:o,disabled:i,onHourSelect:v,onMinuteSelect:f,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"})})]})})},Pt=({value:e,format:a="YYYY-MM-DD HH:mm",showTimeFormat:l="HH:mm",showTime:i=!0,onChange:d,onOk:c,timeZone:u,disabled:g=!1,placement:m="bottomLeft",autoAdjustOverflow:h=!0,getPopupContainer:v,matchTriggerWidth:f=!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===i||("object"==typeof i||Boolean(i)),[i]),b=t.useMemo(()=>ke(y,"short"),[y]),D=t.useMemo(()=>Ee(y,"narrow"),[y]),w=t.useMemo(()=>x?"object"==typeof i&&(null==i?void 0:i.format)?i.format:l:"",[x,i,l]),C=t.useMemo(()=>Dt(a,w),[a,w]),E=t.useMemo(()=>Ct(C),[C]),k=t.useMemo(()=>{const t=null!=u?u:R(e[0])?R(e[1])?n.Temporal.Now.timeZoneId():kt(e[1]):kt(e[0]),a=jt(e[0],t);return[a,jt(e[1],t,a)]},[e,u]),[j,T]=t.useState(k),S=t.useRef(k),[M,N]=t.useState("start"),[I,H]=t.useState([Tt(k[0],a,w),Tt(k[1],a,w)]),O=t.useRef([Tt(k[0],a,w),Tt(k[1],a,w)]),P=t.useRef(k),[L,A]=t.useState(k[0].toPlainDate().with({day:1})),[$,z]=t.useState(!1),Y=t.useCallback(e=>{z(e)},[]),[F,V]=t.useState(m),W=t.useRef(m),B=t.useRef(null),Z=t.useRef(null),U=t.useRef({start:{hour:null,minute:null},end:{hour:null,minute:null}}),q=t.useRef(!1);t.useEffect(()=>{O.current=I},[I]),t.useEffect(()=>{P.current=j},[j]),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)&&T(k),S.current=k},[k]),t.useEffect(()=>{A(k[0].toPlainDate().with({day:1}))},[k[0]]);const _=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,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})},[]),X=t.useCallback(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=U.current[e];["hour","minute"].forEach(e=>{const n=t[e];if(!n)return;const a=n.querySelector('[data-active="true"]');a&&_(n,a,0)})})})},[_]);t.useEffect(()=>{$&&x&&X(M)},[M,$,X,x]);const G=j[0].epochMilliseconds,K=j[0].offsetNanoseconds,J=j[1].epochMilliseconds,Q=j[1].offsetNanoseconds;t.useEffect(()=>{const[e,t]=P.current,n=Tt(e,a,w),r=Tt(t,a,w),[o,l]=O.current;o===n&&l===r||(O.current=[n,r],H([n,r]))},[G,K,J,Q,a,w]),t.useEffect(()=>{if(!$)return;const e=e=>{var t,n;const a=e.target;if(null===(t=B.current)||void 0===t?void 0:t.contains(a))return;if(null===(n=Z.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)}},[$]),t.useEffect(()=>{$||(N("start"),q.current||T(k),q.current=!1)},[$,k]);const ee=t.useCallback(e=>{d&&d(e,[Tt(e[0],a,w),Tt(e[1],a,w)])},[w,a,d]),te=t.useCallback(e=>{c&&c(e,[Tt(e[0],a,w),Tt(e[1],a,w)])},[w,a,c]),ne=t.useCallback((e,t)=>{T(a=>{const r=[...a];if("start"===e){const e=jt(r[1],kt(t),t),a=n.Temporal.ZonedDateTime.compare(t,e)>0?t:e;return[t,a]}const o=jt(r[0],kt(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,l;const s=kt(e);return n.Temporal.ZonedDateTime.from({timeZone:s,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!==(l=e.nanosecond)&&void 0!==l?l:0})};if("start"===M){const n=t(j[0],e),a=j[1].epochMilliseconds-j[0].epochMilliseconds,r=n.add({milliseconds:a});return void T([n,r])}const a=t(j[1],e),r=j[1].epochMilliseconds-j[0].epochMilliseconds;if(n.Temporal.ZonedDateTime.compare(a,j[0])<0){const n=t(j[0],e),a=n.add({milliseconds:r});return void T([n,a])}const o=[j[0],a];T(o),A(a.toPlainDate().with({day:1}))},re=t.useCallback((e,t)=>{if(g)return;const a="start"===e?0:1;T(r=>{const o=r[a],l=o.with({hour:t,minute:o.minute,second:0,millisecond:0,microsecond:0,nanosecond:0});if("start"===e){const e=jt(r[1],kt(l),l);return[l,n.Temporal.ZonedDateTime.compare(l,e)>0?l:e]}const s=jt(r[0],kt(l),l);return[n.Temporal.ZonedDateTime.compare(s,l)>0?l:s,l]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=U.current[e].hour;if(!t)return;const n=t.querySelector('[data-active="true"]');n&&_(t,n,0)})})},[g]),oe=t.useCallback((e,t)=>{if(g)return;const a="start"===e?0:1;T(r=>{const o=r[a].with({minute:t,second:0,millisecond:0,microsecond:0,nanosecond:0});if("start"===e){const e=jt(r[1],kt(o),o);return[o,n.Temporal.ZonedDateTime.compare(o,e)>0?o:e]}const l=jt(r[0],kt(o),o);return[n.Temporal.ZonedDateTime.compare(l,o)>0?o:l,o]}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=U.current[e].minute;if(!t)return;const n=t.querySelector('[data-active="true"]');n&&_(t,n,0)})})},[g]),le=t.useCallback((e,t)=>{const n="start"===e?0:1;H(e=>{const a=[...e];return a[n]=t,a})},[]),se=t.useCallback((e,t)=>{const n="start"===e?0:1,r=j[n],o=kt(r),l=Et(t,E,r,o);if(l){ne(e,l);const t=l.toPlainDate().with({day:1});return A(t),"start"===e&&N("end"),!0}return H(e=>{const t=[...e];return t[n]=Tt(j[n],a,w),t}),!1},[j,w,a,E,ne]),ie=t.useCallback(e=>t=>{le(e,t.target.value)},[le]),de=t.useCallback(e=>t=>{var n;if(g)return;if($)return;const a=t.relatedTarget;a&&(null===(n=B.current)||void 0===n?void 0:n.contains(a))||se(e,t.target.value)},[se,g,$]),ce=t.useCallback(e=>t=>{"Enter"===t.key&&(t.preventDefault(),se(e,t.currentTarget.value)),"Escape"===t.key&&t.currentTarget.blur()},[se]),ue=()=>{q.current=!0,ee(j),te(j),Y(!1)},ge=e=>{A(t=>t.add({months:e}).with({day:1}))},me=e=>{A(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]),ve=t.useCallback((e=m)=>{if(!h||!B.current)return e;const t=B.current.getBoundingClientRect(),n=f?t.width:480,a=window.innerHeight-t.bottom,r=t.top,o=window.innerWidth-t.left,l=t.right;let s=e;return s.startsWith("bottom")&&a<500&&r>a?s=s.replace("bottom","top"):s.startsWith("top")&&r<500&&a>r&&(s=s.replace("top","bottom")),s.endsWith("Left")&&o<n&&l>o?s=s.replace("Left","Right"):s.endsWith("Right")&&l<n&&o>l&&(s=s.replace("Right","Left")),s},[h,f,m]),fe=t.useCallback(()=>{const e=ve();W.current!==e&&(W.current=e,V(e))},[ve]),pe=e=>{if(g)return;N(e);const t=j["start"===e?0:1].toPlainDate().with({day:1});A(t);const n=ve();W.current!==n&&(W.current=n,V(n)),Y(!0)};t.useEffect(()=>{if(!$)return;fe();const e=()=>fe();return window.addEventListener("resize",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e,!0)}},[$,fe]);const ye=()=>{if(!B.current)return{};const e=B.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,f&&(n.width=`${e.width}px`),n};return r.jsxs("div",{className:"relative max-w-100",ref:B,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":$?"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"===M&&$?" 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(s.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"===M&&$?"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})})]}),$&&(v?o.createPortal(r.jsx(Ot,{visibleMonth:L,monthLabels:b,weekDayLabels:D,calendarDays:he,draftRange:j,focusedField:M,isTimeEnabled:!!x,disabled:g,matchTriggerWidth:f,popupRef:Z,timeListRefs:U,onMonthChange:ge,onYearChange:me,onDaySelect:ae,onHourSelect:re,onMinuteSelect:oe,onOk:ue,getPopupStyle:ye}),v()):o.createPortal(r.jsx(Ot,{visibleMonth:L,monthLabels:b,weekDayLabels:D,calendarDays:he,draftRange:j,focusedField:M,isTimeEnabled:!!x,disabled:g,matchTriggerWidth:f,popupRef:Z,timeListRefs:U,onMonthChange:ge,onYearChange:me,onDaySelect:ae,onHourSelect:re,onMinuteSelect:oe,onOk:ue,getPopupStyle:ye}),document.body))]})},Lt=({event:e,isOpen:a,isAllDay:l,onEventUpdate:s,onEventDelete:i,onClose:d,app:c})=>{var u;const[g,m]=t.useState(e),{t:h}=Se();t.useEffect(()=>{m(e)},[e]);const v=t.useMemo(()=>(c?c.getCalendarRegistry():x()).getVisible().map(e=>({label:e.name,value:e.id})),[c,null==c?void 0:c.getCalendars()]),f=t.useMemo(()=>!fe(e,g),[e,g]),p=t.useMemo(()=>R(g.start)?g.end&&!R(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()}))},b=!(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:!b,disabled:!b,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"})}),b&&r.jsx(yt,{options:v,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(Pt,{value:[g.start,g.end],format:"YYYY-MM-DD",showTime:!1,timeZone:p,matchTriggerWidth:!0,disabled:!b,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(Pt,{value:[g.start,g.end],timeZone:p,disabled:!b,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:!b,disabled:!b,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")})]}),b&&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=R(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=R(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 "+(f?"hover:bg-primary/90 shadow-lg shadow-primary/20":"opacity-50 cursor-not-allowed grayscale-[0.5]"),onClick:()=>{s(g),d()},disabled:!f,children:h("save")})]})]})]})]}),C=document.body;return C?o.createPortal(w,C):null},At=({calendar:e,mode:n="buttons"})=>{const[a,o]=t.useState(!1),l=t.useRef(null),{t:i}=Se(),d=Array.from(e.state.views.keys()),c=e.state.currentView;return d.length<=1?null:(t.useEffect(()=>{const e=e=>{l.current&&!l.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:l,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:i(c)}),r.jsx("span",{className:`${st} transition-transform duration-200 ${a?"rotate-180":""}`,children:r.jsx(s.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:i(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:i(t)},t))}))},$t=0,zt=1970,Yt=2100,Ft=8,Vt=100,Wt=1200,Bt=900,Zt=700;class Ut{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}}}Ut.metrics={scrollEvents:0,renderTime:[],cacheHits:0,cacheMisses:0,startTime:Date.now(),frameDrops:0,avgScrollDelta:0,totalScrollDistance:0};const qt=e=>{if(!e)return"";let t,a,r;e instanceof Date?(t=e.getFullYear(),a=e.getMonth()+1,r=e.getDate()):R(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}`};function _t(e){return!("hour"in e)}function Xt(e){return"hour"in e&&!("timeZone"in e)}function Gt(e){return"timeZone"in e}function Kt(e){return n.Temporal.PlainDate.from({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()})}function Jt(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 Qt(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 en=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 tn(e,t=!1){if(e instanceof n.Temporal.PlainDate||e instanceof n.Temporal.PlainDateTime)return e;if(e instanceof Date)return t?Kt(e):Jt(e);throw new Error("Invalid time type: "+typeof e)}function nn(e,t){if(e instanceof n.Temporal.ZonedDateTime)return e;if(e instanceof Date)return Qt(e,t);throw new Error("Invalid time type: "+typeof e)}function an(e){var t;const n=tn(e.start,e.allDay),a=tn(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 rn(e){const t=nn(e.start,e.timeZone),n=nn(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 on=e=>{try{return e instanceof Date?e:"string"==typeof e?new Date(e):A(e)}catch(e){return new Date}},ln=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},sn=(e,t,n,a)=>{const r=e.getTime()-t.getTime(),o=Math.round(r/864e5);let l="",s="text-gray-500 dark:text-gray-400";if(0===o)l=a("today")||"Today",s="text-primary";else if(1===o||2===o)try{const e=new Intl.RelativeTimeFormat(n,{numeric:"auto"}).format(o,"day");l=e.charAt(0).toUpperCase()+e.slice(1),s="text-black dark:text-white"}catch(t){l=e.toLocaleDateString(n,{weekday:"long"})}else l=e.toLocaleDateString(n,{year:"numeric",month:"long",day:"numeric",weekday:"long"});return{title:l,colorClass:s}},dn=(e,t)=>{const n=new Map;e.forEach(e=>{var t;const a=on(e.start),r=ln(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 cn=null;const un=()=>{const[e,n]=t.useState(()=>cn||{weekHeight:h,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(g,a),screenSize:"mobile",weeksPerView:6}:e<1024?{weekHeight:Math.max(m,a),screenSize:"tablet",weeksPerView:6}:{weekHeight:Math.max(h,a),screenSize:"desktop",weeksPerView:6};cn&&cn.screenSize===r.screenSize&&cn.weekHeight===r.weekHeight&&cn.weeksPerView===r.weeksPerView||(cn=r,n(r))};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e},gn=({currentDate:e,weekHeight:n,onCurrentMonthChange:a,initialWeeksToLoad:r=104,locale:o="en-US",isEnabled:l=!0})=>{const s=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),ce(t,r)},[e,r]),g=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(g),[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),[j,T]=t.useState(!1),S=t.useRef(!1),[M,N]=t.useState(!1),I=t.useRef(e),H=t.useRef(null),R=t.useRef(null),O=t.useRef(new v),P=t.useRef(0),L=t.useRef(0),A=t.useRef(!1),$=t.useCallback(e=>{e&&(H.current=e)},[]),z=t.useCallback(e=>{let t=O.current.get(e);return console.log("weekData",t),t||(t=ie(e),O.current.set(e,t)),t},[]),Y=t.useCallback((e,t=26)=>{A.current||(A.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),H.current&&(H.current.scrollTop+=r)})}}finally{setTimeout(()=>{A.current=!1},200)}},0))},[E,z,n]),F=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),l=Math.min(E.length-1,r+15),s=[];for(let e=o;e<=l;e++)s.push({index:e,weekData:E[e],top:e*n,height:n});return{totalHeight:e,visibleItems:s,displayStartIndex:a}},[m,f,n,E]),V=t.useCallback(e=>{if(j||w||0===e.length||!M)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="",l=0,d=0;Object.entries(r).forEach(([e,t])=>{if(t>d){d=t;const[n,a]=e.split("-");o=n,l=parseInt(a)}}),o&&l&&(s.current?o===s.current.month&&l===s.current.year&&(s.current=null,o===y&&l===b||(x(o),D(l),null==a||a(o,l))):o===y&&l===b||(x(o),D(l),null==a||a(o,l)))},[f,y,b,j,w,a,m,M]),W=t.useCallback(e=>{const t=performance.now();if(t-P.current<c)return;P.current=t;const a=e.currentTarget,r=a.scrollTop;L.current=r,h(r),j||requestAnimationFrame(()=>{const{scrollHeight:e,clientHeight:t}=a;r+t>e-10*n&&!A.current&&Y("future",26),r<10*n&&!A.current&&Y("past",26)}),C(!0),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>{C(!1)},u)},[n,Y,j]),B=t.useCallback((e,t=!0)=>{if(!H.current)return;T(!0),S.current=!0;const a=()=>{setTimeout(()=>{T(!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 H.current.scrollTo({top:e,behavior:t?"smooth":"auto"}),void a()}const o=e.getDay(),l=0===o?6:o-1,s=new Date(e);s.setDate(e.getDate()-l),s.setHours(0,0,0,0);const i=E[0],d=E[E.length-1];let c=0,u=!1,g=!1;s<i.startDate?(c=Math.ceil((i.startDate.getTime()-s.getTime())/6048e5),u=!0):s>d.startDate&&(c=Math.ceil((s.getTime()-d.startDate.getTime())/6048e5),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 l=[...r,...E].findIndex(t=>t.days.some(t=>t.date.toDateString()===e.toDateString()));if(H.current&&-1!==l){const e=l*n;H.current.scrollTop+=o,h(e=>e+o),setTimeout(()=>{H.current&&H.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(H.current&&-1!==o){const e=o*n;H.current.scrollTo({top:e,behavior:t?"smooth":"auto"})}a()})}else a()},[E,n,z]),Z=t.useCallback(()=>{const e=E[F.displayStartIndex].days[0].date,t=new Date(e.getFullYear(),e.getMonth()-1,1);B(t)},[F.displayStartIndex,E,B]),U=t.useCallback(()=>{const e=E[F.displayStartIndex].days[0].date,t=new Date(e.getFullYear(),e.getMonth()+1,1);B(t)},[F.displayStartIndex,E,B]),q=t.useCallback(()=>{const e=new Date,t=i(e.getMonth(),e.getFullYear()),r=e.getFullYear(),o=new Date(r,e.getMonth(),1);s.current={month:t,year:r},x(t),D(r),null==a||a(t,r);const l=E.findIndex(e=>e.days.some(e=>e.date.toDateString()===o.toDateString()));if(-1!==l){const e=l*n,t=H.current;t&&(T(!0),S.current=!0,requestAnimationFrame(()=>{h(e),requestAnimationFrame(()=>{t&&(t.scrollTop=e,setTimeout(()=>{S.current=!1,T(!1)},200))})}))}else T(!0),S.current=!0,requestAnimationFrame(()=>{B(o,!0),setTimeout(()=>{S.current=!1,T(!1)},200)})},[E,n,a,B]);return t.useEffect(()=>{V(F.visibleItems)},[F.visibleItems,V]),t.useEffect(()=>{const t=I.current,n=t.getMonth(),r=t.getFullYear(),o=e.getMonth(),l=e.getFullYear();if(n!==o||r!==l){const e=new Date(l,o,1),t=i(o,l);s.current={month:t,year:l},x(t),D(l),null==a||a(t,l),B(e,!0)}I.current=e},[e,a,B]),t.useEffect(()=>{const e=H.current;if(!e)return;const t=new ResizeObserver(([e])=>{p(e.contentRect.height)});return t.observe(e),()=>t.disconnect()},[]),t.useEffect(()=>{const e=H.current;e&&!M&&l&&requestAnimationFrame(()=>{e&&g>0?(e.scrollTop=g,h(g),N(!0)):e&&N(!0)})},[M,g,l]),t.useEffect(()=>()=>{R.current&&clearTimeout(R.current)},[]),{scrollTop:m,containerHeight:f,currentMonth:y,currentYear:b,isScrolling:w,virtualData:F,scrollElementRef:H,handleScroll:W,scrollToDate:B,handlePreviousMonth:Z,handleNextMonth:U,handleToday:q,setScrollTop:h,setContainerHeight:p,setCurrentMonth:x,setCurrentYear:D,setIsScrolling:C,cache:O.current,scrollElementRefCallback:$,weeksData:E}},mn=({calendar:e,switcherMode:t="buttons",onAddCalendar:n,onSearchChange:a,onSearchClick:o,searchValue:l="",isSearchOpen:i=!1,isEditable:d=!0})=>{const c="buttons"===t,u=e.state.currentView===exports.ViewType.DAY,{screenSize:g}=un(),m="mobile"===g,{t:h}=Se();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||i?"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(s.Plus,{className:`h-4 w-4 ${st}`})})}),r.jsx("div",{className:"flex-1 flex justify-center",children:c&&r.jsx(At,{mode:t,calendar:e})}),!c&&r.jsx(At,{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(s.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(s.Search,{width:16,height:16})})}),r.jsx("input",{type:"text",placeholder:"Search",value:l,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"}),l&&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"})]})})]})]})]})},hn=t.createContext(void 0),vn=({children:e,initialTheme:n="light",onThemeChange:a})=>{const[o,l]=t.useState(n),[s,i]=t.useState("light"),d="auto"===o?s:o;t.useEffect(()=>{l(n)},[n]);const c=t.useCallback(e=>{l(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=en(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,s]),t.useEffect(()=>{a&&a(o,d)},[o,d,a]);const u={theme:o,effectiveTheme:d,setTheme:c};return r.jsx(hn.Provider,{value:u,children:e})},fn=()=>{const e=t.useContext(hn);if(void 0===e)throw new Error("useTheme must be used within a ThemeProvider");return e},pn=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],yn=({onClose:e,onCreate:n})=>{const[a,s]=t.useState(""),[i,d]=t.useState(pn[Math.floor(Math.random()*pn.length)]),[c,u]=t.useState(!1),[g,m]=t.useState(""),{effectiveTheme:h}=fn(),{t:v}=Se(),f="dark"===h,p={default:{picker:{background:f?"#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:f?"1px solid #4b5563":"1px solid #e5e7eb"},head:{background:f?"#1e293b":"#ffffff",borderBottom:f?"1px solid #4b5563":"1px solid #e5e7eb",boxShadow:"none"},body:{background:f?"#1e293b":"#ffffff"},controls:{border:f?"1px solid #4b5563":"1px solid #e5e7eb"},input:{background:f?"#374151":"#ffffff",color:f?"#f3f4f6":"#1f2937",border:f?"1px solid #4b5563":"1px solid #e5e7eb",boxShadow:"none"},previews:{border:f?"1px solid #4b5563":"1px solid #e5e7eb"},actions:{borderTop:f?"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-background animate-in fade-in zoom-in-95",onClick:e=>e.stopPropagation(),children:[r.jsx("h2",{className:"mb-4 text-lg font-semibold text-gray-900 dark:text-white",children:v("createCalendar")}),r.jsxs("form",{onSubmit:t=>{if(t.preventDefault(),!a.trim())return;const{colors:r,darkColors:o}=b(i),l={id:pe(),name:a.trim(),colors:r,darkColors:o,isVisible:!0,isDefault:!1};n(l),e()},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:i}}),r.jsx("input",{type:"text",value:a,onChange:e=>s(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:v("calendarNamePlaceholder"),autoFocus:!0})]})}),r.jsxs("div",{className:"mb-6",children:[r.jsx("div",{className:"grid grid-cols-7 gap-6",children:pn.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 "+(i===e?"ring-2 ring-primary ring-offset-2 dark:ring-offset-slate-800":""),style:{backgroundColor:e},onClick:()=>d(e)},e))}),r.jsxs("div",{className:"mt-2 relative",children:[r.jsx("button",{type:"button",onClick:()=>{m(i),u(!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:v("customColor")}),c&&r.jsx("div",{className:"absolute left-0 top-full z-10001 mt-2",children:r.jsx(l.PhotoshopPicker,{color:i,onChange:e=>{d(e.hex)},onAccept:()=>{u(!1)},onCancel:()=>{d(g),u(!1)},styles:p})})]})]}),r.jsxs("div",{className:"flex justify-end space-x-3",children:[r.jsx("button",{type:"button",onClick:e,className:Fe,children:v("cancel")}),r.jsx("button",{type:"submit",disabled:!a.trim(),className:"rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:v("create")})]})]})]})}),document.body)},xn=({loading:e,results:n,keyword:a,onResultClick:o,emptyText:l})=>{const{t:i,locale:d}=Se(),c=t.useMemo(()=>ln(new Date),[]),u=t.useMemo(()=>dn(n,c),[n,c]),g=e=>on(e);return e?r.jsxs("div",{className:"flex flex-col items-center justify-center h-40 text-gray-500",children:[r.jsx(s.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(bn,{}),r.jsx("span",{className:"mt-2 text-sm",children:"string"==typeof l?l:l&&"object"==typeof l?l[d]||l.en||"No results found":i("noResults")||"No results found"})]}):null:r.jsx("div",{className:"space-y-6",children:u.map(e=>{const{title:n,colorClass:a}=sn(e.date,c,d,i);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),l={hour:"2-digit",minute:"2-digit"},s=e.allDay?i("allDay")||"All Day":n.toLocaleTimeString(d,l),c=e.allDay?"":a.toLocaleTimeString(d,l);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:s}),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())})})},bn=()=>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"})}),Dn=({isOpen:e,onClose:t,loading:n,results:a,keyword:o,onResultClick:l,emptyText:s})=>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(xn,{loading:n,results:a,keyword:o,onResultClick:l,emptyText:s})})}),wn=({isOpen:e,onClose:n,keyword:a,onSearchChange:l,results:i,loading:d,onResultClick:c,emptyText:u})=>{const g=t.useRef(null),{t:m}=Se();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(s.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=>l(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:()=>l(""),className:"absolute inset-y-0 right-0 pr-3 flex items-center text-gray-400",children:r.jsx(s.X,{className:"w-4 h-4"})})]})]}),r.jsx("div",{className:"flex-1 overflow-y-auto p-2 select-none",children:r.jsx(xn,{loading:d,results:i,keyword:a,onResultClick:e=>{null==c||c(e)},emptyText:u})})]}),document.body):null},Cn=({app:e,anchorRef:n,onClose:a,isOpen:l})=>{const{t:s}=Se(),[i,d]=t.useState(""),[c,u]=t.useState(0),[g,m]=t.useState(!1),h=t.useRef(null),v=t.useRef(null);t.useEffect(()=>{l||m(!1)},[l]),t.useEffect(()=>{l&&(setTimeout(()=>{var e;return null===(e=h.current)||void 0===e?void 0:e.focus()},50),d(""),u(0))},[l]),t.useEffect(()=>{const e=e=>{l&&v.current&&!v.current.contains(e.target)&&n.current&&!n.current.contains(e.target)&&a()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[l,a,n]);const[f,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}},[l]),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 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: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(l&&n.current&&v.current){const e=n.current.getBoundingClientRect(),t=v.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 s=e.left+e.width/2;D(s-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)}},[l,n,C]);const E=t=>{if(!t.calendarId)return;const n=pe(),r={id:n,title:t.title,start:O(t.start),end:O(t.end),calendarId:t.calendarId,allDay:!1};e.addEvent(r),e.setCurrentDate(t.start),e.highlightEvent(n),a()};t.useEffect(()=>{if(!l)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)},[l,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 l?o.createPortal(r.jsxs("div",{ref:v,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:f.top,left:f.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:s("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:s("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:s("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?s("today"):s("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},En=({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":"")})}),kn=({date:e,onChange:n})=>{const a=Array.from({length:24},(e,t)=>t),o=Array.from({length:12},(e,t)=>5*t),l=[...a,...a,...a],s=[...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),[v,f]=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,f(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),f(o)}x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{((t,a)=>{const r=Math.round(a/i);if("hour"===t){const t=l[r];if(void 0!==t&&t!==e.getHours()){const a=new Date(e);a.setHours(t),n(a)}}else{const t=s[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}}),l.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}}),s.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,v),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"})]})},jn=({isOpen:e,onClose:n,onSave:a,draftEvent:l,app:s})=>{const{locale:i,t:d}=Se(),[c,u]=t.useState(""),[g,m]=t.useState(""),[h,v]=t.useState(!1),[f,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),[j,T]=t.useState(null),[S,M]=t.useState(e),[N,I]=t.useState(!1),[H,R]=t.useState(!1);t.useEffect(()=>{if(!e){I(!0);const e=setTimeout(()=>{M(!1),I(!1)},300);return()=>clearTimeout(e)}M(!0),I(!1)},[e]),t.useEffect(()=>{if(e&&l){const e=s.getEvents().some(e=>e.id===l.id);R(e)}},[e,l,s]);const P=s.getCalendars(),L=P.map(e=>({label:e.name,value:e.id}));t.useEffect(()=>{if(e&&P.length>0){P.some(e=>e.id===g)||"blue"!==g&&""!==g||m(P[0].id)}},[P,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&&l){if(u(l.title||""),m(l.calendarId||(null===(t=P[0])||void 0===t?void 0:t.id)||"blue"),v(l.allDay||!1),l.start)try{const e=A(l.start);p(e),C(e)}catch(e){console.error("Failed to parse start date",e);const t=new Date;p(t),C(t)}if(l.end)try{const e=A(l.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&&!l){m((null===(n=P[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,l]);const $=t.useMemo(()=>{if(!e||!l)return!1;let t=new Date(f),n=new Date(y);h&&(t.setHours(0,0,0,0),n.setHours(0,0,0,0));const a=Object.assign(Object.assign({},l),{title:c,calendarId:g,allDay:h,description:b,start:O(t),end:O(n)});return!fe(l,a)},[e,l,c,g,h,f,y,b]);if(!S)return null;const z=e=>{T(t=>t===e?null:e)},Y=e=>e.toLocaleDateString(i,{day:"numeric",month:"short",year:"numeric"}),F=(e,t)=>{if("start"===e){const e=new Date(t);e.setHours(f.getHours(),f.getMinutes());const n=e.getTime()-f.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)}},V=(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 "+(N?"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 "+(N?"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(H?"editEvent":"newEvent")}),r.jsx("button",{onClick:()=>{if(!l)return;let e=new Date(f),t=new Date(y);h&&(e.setHours(0,0,0,0),t.setHours(0,0,0,0));const n=Object.assign(Object.assign({},l),{title:c,calendarId:g,allDay:h,start:O(e),end:O(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(H?"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})}),P.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(yt,{options:L,value:g,onChange:m,registry:s.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(En,{checked:h,onChange:v})]}),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"===j?"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(f)}),!h&&r.jsx("button",{className:"px-3 py-1 rounded-md transition-colors "+("start-time"===j?"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:Q(f.getHours()+f.getMinutes()/60)})]})]}),r.jsx("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("start-date"===j?"max-h-100":"max-h-0"),children:r.jsx("div",{className:"",children:r.jsx(mt,{currentDate:f,visibleMonth:w,onDateSelect:e=>F("start",e),onMonthChange:e=>V("start",e),showHeader:!0})})}),r.jsx("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("start-time"===j?"max-h-75":"max-h-0"),children:r.jsx("div",{className:"",children:r.jsx(kn,{date:f,onChange:e=>{const t=y.getTime()-f.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"===j?"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"===j?"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:Q(y.getHours()+y.getMinutes()/60)})]})]}),r.jsx("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("end-date"===j?"max-h-100":"max-h-0"),children:r.jsx("div",{className:"",children:r.jsx(mt,{currentDate:y,visibleMonth:E,onDateSelect:e=>F("end",e),onMonthChange:e=>V("end",e),showHeader:!0})})}),r.jsx("div",{className:"overflow-hidden transition-all duration-300 ease-in-out "+("end-time"===j?"max-h-75":"max-h-0"),children:r.jsx("div",{className:"",children:r.jsx(kn,{date:y,onChange:e=>{if(e<f){const t=y.getTime()-f.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)},Tn=({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]),l=t.useMemo(()=>{const e=o.code;return{locale:e,t:(t,a)=>{var r,l,s;let i=null!==(s=null!==(r=null==n?void 0:n[t])&&void 0!==r?r:null===(l=o.messages)||void 0===l?void 0:l[t])&&void 0!==s?s:je(t,e);return a&&Object.entries(a).forEach(([e,t])=>{i=i.replace(new RegExp(`{${e}}`,"g"),t)}),i},getWeekDaysLabels:Ee,getMonthLabels:ke,isDefault:!1}},[o,n]);return r.jsx(Te.Provider,{value:l,children:a})},Sn=["#ea426b","#f19a38","#f7cf46","#83d754","#51aaf2","#b672d0","#957e5e"],Mn=({locale:e,messages:t,children:n})=>Se().isDefault?r.jsx(Tn,{locale:e,messages:t,children:n}):r.jsx(r.Fragment,{children:n}),Nn=({calendar:e,className:n,style:o,customDetailPanelContent:l,customEventDetailDialog:s,meta:i,search:d})=>{var c,u;const g=e.app,m=g.getCurrentView(),h=m.component,v=g.getSidebarConfig(),f=null!==(c=null==v?void 0:v.enabled)&&void 0!==c&&c,[p,y]=t.useState(0),[x,D]=t.useState(null!==(u=null==v?void 0:v.initialCollapsed)&&void 0!==u&&u),{t:C}=Se(),[E,k]=t.useState(!1),[j,T]=t.useState(null),[S,M]=t.useState(!1),N=t.useRef(null),[I,H]=t.useState(!1),[R,P]=t.useState(!1),[L,$]=t.useState(null),[z,Y]=t.useState(()=>g.getTheme()),[F,V]=t.useState(""),[W,B]=t.useState(!1),[Z,U]=t.useState(!1),[q,_]=t.useState(!1),[X,G]=t.useState([]);t.useEffect(()=>{const e=()=>{H(window.matchMedia("(max-width: 768px)").matches)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),t.useEffect(()=>{var e;if(!F.trim())return B(!1),G([]),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;_(!0),B(!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:F,events:e})}else if(null==d?void 0:d.onSearch)t=yield d.onSearch(F);else{const e=F.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})})}G(t),null===(e=null==d?void 0:d.onSearchStateChange)||void 0===e||e.call(d,{keyword:F,loading:!1,results:t})}catch(e){console.error("Search failed",e),G([])}finally{_(!1)}}),t);return()=>clearTimeout(n)},[F,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),Z&&U(!1)};t.useEffect(()=>{var e;D(null!==(e=null==v?void 0:v.initialCollapsed)&&void 0!==e&&e)},[null==v?void 0:v.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"===(v.createCalendarMode||"inline"))return void k(!0);const e=Sn[Math.floor(Math.random()*Sn.length)],{colors:t,darkColors:n}=b(e),a=pe(),r={id:a,name:C("untitled"),colors:t,darkColors:n,isVisible:!0,isDefault:!1};g.createCalendar(r),T(a),Q()},[g,v.createCalendarMode,C,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:pe(),title:"",start:O(e),end:O(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 P(!0)}f?S?M(!1):(N.current=e.currentTarget,M(!0)):ae()}},[f,I,S,ae,g]),oe=t.useRef(null),le=s||(g.getUseEventDetailDialog()?Lt:void 0),se={app:g,config:m.config||{},customDetailPanelContent:l,customEventDetailDialog:le,switcherMode:g.state.switcherMode,calendarRef:oe,meta:i},ie={app:g,calendars:ee,toggleCalendarVisibility:te,toggleAll:ne,isCollapsed:x,setCollapsed:D,renderCalendarContextMenu:v.renderCalendarContextMenu,createCalendarMode:v.createCalendarMode,renderCreateCalendarDialog:v.renderCreateCalendarDialog,editingCalendarId:j,setEditingCalendarId:T,onCreateCalendar:ae},de=w(null==v?void 0:v.width,"240px"),ce=g.getCalendarHeaderConfig(),ue={calendar:g,switcherMode:g.state.switcherMode,onAddCalendar:re,onSearchChange:V,onSearchClick:()=>{V(""),U(!0)},searchValue:F,isSearchOpen:W,isEditable:!g.state.readOnly},ge=g.getCustomMobileEventRenderer()||jn;return r.jsx(vn,{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:[f&&r.jsx("aside",{className:"absolute top-0 bottom-0 left-0 z-0 h-full",style:{width:de},children:f?v.render?v.render(ie):r.jsx(pt,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:f?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({},se))}),r.jsx(Dn,{isOpen:W,onClose:()=>{B(!1),V(""),g.highlightEvent(null)},loading:q,results:X,keyword:F,onResultClick:K,emptyText:null==d?void 0:d.emptyText})]}),r.jsx(wn,{isOpen:Z,onClose:()=>{U(!1),V(""),g.highlightEvent(null)},keyword:F,onSearchChange:V,results:X,loading:q,onResultClick:K,emptyText:null==d?void 0:d.emptyText})]})]}),r.jsx(Cn,{app:g,anchorRef:N,isOpen:S,onClose:()=>M(!1)}),r.jsx(ge,{isOpen:R,onClose:()=>{P(!1),$(null)},onSave:e=>{g.addEvent(e),P(!1),$(null)},draftEvent:L,app:g}),E&&(v.renderCreateCalendarDialog?v.renderCreateCalendarDialog({onClose:()=>k(!1),onCreate:e=>{g.createCalendar(e),k(!1),Q()}}):r.jsx(yn,{onClose:()=>k(!1),onCreate:e=>{g.createCalendar(e),k(!1),Q()}}))]})})},In=({originalComponent:e,app:n,config:a,customDetailPanelContent:o,customEventDetailDialog:l,calendarRef:s,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(),v=t.useCallback(e=>{c?c.update(e.id,e):n.updateEvent(e.id,e)},[c,n]),f=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:v,onEventDelete:f,onEventCreate:p,onDateChange:y,onViewChange:x,config:b}),[n,g,m,h,v,f,p,y,x,b]),w=t.useMemo(()=>{const e={currentDate:g,events:h,setEvents:e=>{h.forEach(e=>f(e.id)),e.forEach(e=>p(e))},updateEvent:v,deleteEvent:f,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:l,calendarRef:s,switcherMode:i,meta:d})},[g,h,m,v,f,p,y,x,D,c,u,o,l,s,i,d]);return r.jsx(e,Object.assign({},w))};function Hn(e){return Object.assign(Object.assign({},e),{parentId:void 0,children:[],_startHour:e.allDay?0:B(e.start),_endHour:e.allDay?0:ne(e)})}function Rn(e){var t;return null!==(t=e._startHour)&&void 0!==t?t:B(e.start)}function On(e){var t;return null!==(t=e._endHour)&&void 0!==t?t:ne(e)}const Pn=.25,Ln=.5,An=25,$n=1,zn=.9;class Yn{static getIndentStepPercent(e){return"day"===e?.5:2.5}static calculateDayEventLayouts(e,t={}){const n=e.map(Hn);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&&(Rn(e)<On(t)&&Rn(t)<On(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-zn,zIndex:0,level:0,isPrimary:!0,indentOffset:0,importance:1})}static calculateComplexGroupLayout(e,t,n={}){const a=[...e].sort((e,t)=>{const n=Rn(e),a=Rn(t);if(n!==a)return n-a;return On(t)-Rn(t)-(On(e)-Rn(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(Rn(a)-Rn(t))<=Pn&&(r.push(t),n.add(t.id))}r.sort((e,t)=>Rn(e)-Rn(t));const o={events:r,startHour:Math.min(...r.map(e=>Rn(e))),endHour:Math.max(...r.map(e=>On(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(Rn(e)-Rn(t));if(n<=Pn)return!0;if(n>Pn&&n<Ln)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=On(e)-Rn(e);if(n<1.25)return!1;const a=Rn(e)+.4*n,r=Rn(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],l=o.events.map(e=>r.get(e.id));let s=!1;for(let i=n-1;i>=0&&!s;i--){const n=e[i],d={events:n.events.map(e=>r.get(e.id)),startHour:n.startHour,endHour:n.endHour};if(this.canGroupContain(d,{events:l,startHour:o.startHour,endHour:o.endHour})){const e=this.optimizeChildAssignments(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)}s=!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 l=o.children.filter(e=>1===e.depth&&e.event.id!==r.event.id);let s=1/0,i=null;for(const e of l){const t=this.calculateBranchLoad(e);t<s&&(s=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<Ln)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(Rn(e)-Rn(n));if(t<=Pn)return!0;if(t>Pn&&t<Ln)return!0}return!1}static canEventContain(e,t){const n=Rn(e)<=Rn(t)&&On(e)>=On(t),a=Rn(e)<=Rn(t)&&Rn(t)<On(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=On(e)-Rn(e);return On(t)-Rn(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],l=o.slice(t*e,(t+1)*e);for(const e of l)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 On(e)-Rn(e)>Math.max(...o.map(e=>{const t=n.find(t=>t.id===e);return t?On(t)-Rn(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(Rn(e)-Rn(t.parent))-Math.abs(Rn(e)-Rn(n.parent))});return r[0].parent}static calculateLayoutFromStructure(e,t,n={}){const a=100-zn;if(1===e.length)this.calculateNodeLayoutWithVirtualParallel(e[0],0,a,t,n);else{const r=e.length,o=(a-$n*(r-1))/r;e.forEach((e,a)=>{const r=a*(o+$n);this.calculateNodeLayoutWithVirtualParallel(e,r,Math.max(o,An),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 l=0;const s="day"===r.viewType;1===e.depth?l=s?.5:1.5:2===e.depth?l=s?-.01:-1:e.depth>=3&&(l=s?.55:-3.5);const i=t+o+l;let d=n-(o+l);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=On(e.event)-Rn(e.event);return On(t.event)-Rn(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,l=e[0].depth,s=l*this.getIndentStepPercent(r.viewType);let i;const d="day"===r.viewType;i=1===l?d?.5:1.5:2===l?d?-.01:-1:d?.55:-3.5;const c=t+s+i,u=n-(s+i);if(u<=0)return void e.forEach(e=>{this.calculateNodeLayoutWithVirtualParallel(e,t,n,a,r)});let g;g=1===l?$n*(d?.15:.3):$n*(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:s*(r.containerWidth||320)/100,importance:this.calculateEventImportance(e.event)}),e.children.length>0){const t=[...e.children].sort((e,t)=>{const n=On(e.event)-Rn(e.event);return On(t.event)-Rn(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=On(e)-Rn(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 l=t.filter(e=>e.depth===o);for(const e of l){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 Fn={HOUR_HEIGHT:72,FIRST_HOUR:0,LAST_HOUR:24,MIN_DURATION:.25,TIME_COLUMN_WIDTH:80,ALL_DAY_HEIGHT:28,getLineColor:e=>K(e),getDynamicPadding:e=>e.endHour-e.startHour<=.25?"px-1 py-0":"p-1"};const Vn=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}),l=t.useRef({x:0,y:0}),s=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(s),c=t.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)=>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:l,dragState:i,setDragState:d,resetDragState:u,throttledSetEvents:c}},Wn={renderAllDayContent:({title:e,color:t})=>r.jsxs("div",{className:"h-full flex items-center overflow-hidden pl-3 pt-1",children:[r.jsx(s.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:l,color:s,isMobile:i})=>r.jsxs(r.Fragment,{children:[r.jsx("div",{className:Je,style:{backgroundColor:o(s||"blue")}}),r.jsxs("div",{className:`h-full flex flex-col overflow-hidden pl-3 text-white ${l(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(s||"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(s||"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})})]})},Bn=({drag:e,color:t,title:n,layout:a,allDay:o,formatTime:l,getLineColor:s,getDynamicPadding:i,renderer:d=Wn,isMobile:c})=>{const{t:u}=Se(),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:l,getLineColor:s,getDynamicPadding:i,isMobile:c}):d.renderRegularContent({drag:e,color:t,title:g,layout:a,allDay:o,formatTime:l,getLineColor:s,getDynamicPadding:i,isMobile:c}):d.renderDefaultContent({drag:e,color:t,title:g,layout:a,allDay:o,formatTime:l,getLineColor:s,getDynamicPadding:i,isMobile:c})})},Zn=({event:e,isCreating:t,isMultiDay:n=!1,startDate:a,endDate:o})=>{const{t:l}=Se(),i=(()=>{if(t)return{title:l("newEvent"),icon:r.jsx(s.Calendar,{className:"h-3 w-3"}),showDateRange:!1};if(n&&a&&o){const t=V(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:i.icon}),r.jsx("div",{className:"flex-1 min-w-0",children:r.jsx("div",{className:"truncate font-medium",children:i.title})})]})},Un=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}},qn=e=>{const n=t.useMemo(()=>Object.assign(Object.assign(Object.assign({},Fn),e),{getLineColor:t=>{var n;return e.getLineColor?e.getLineColor(t):K(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:l=0,LAST_HOUR:s=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 l;const t=n.current.querySelector(".calendar-content");if(!t)return l;const a=t.getBoundingClientRect(),r=t.scrollTop,i=window.getComputedStyle(t),d=parseInt(i.paddingTop,10)||0,u=(e-a.top+r-d)/o+l;return Math.max(l,Math.min(s,u))},[n,l,o,s,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,l=Math.floor(n/t);return Math.max(0,Math.min(6,l))}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]),v=t.useCallback(e=>!(c||!(null==a?void 0:a.current))&&e<=a.current.getBoundingClientRect().bottom,[a,c]),f=t.useMemo(()=>864e5,[]);return{pixelYToHour:g,getColumnDayIndex:m,checkIfInAllDayArea:v,handleDirectScroll:h,daysDifference:t.useCallback((e,t)=>V(e,t),[]),addDaysToDate:t.useCallback((e,t)=>W(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,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},[n,r]),ONE_DAY_MS:f}})(n),l=Vn(n),s=(e=>{const{t:n,locale:a}=Se(),{calendarRef:r,allDayRowRef:o,viewType:l,getLineColor:s,getDynamicPadding:d,renderer:c,HOUR_HEIGHT:u=72,FIRST_HOUR:g=0,TIME_COLUMN_WIDTH:m=80,ALL_DAY_HEIGHT:h=60,app:v,isMobile:f}=e,p=l===exports.ViewType.MONTH||l===exports.ViewType.YEAR,y=l===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,l,C,E,k)=>{var j,T,S,M,N,I,H,R,P;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!==(T=null!==(j=e.currentSegmentDays)&&void 0!==j?j:e.eventDurationDays)&&void 0!==T?T: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=i.createRoot(L);const s=O(new Date),d=e.originalEvent||{id:String(Date.now()),color:l||"blue",title:C||n("newEvent"),start:s,end:s,allDay:!1,day:0};b.current.render(t.createElement(Tn,{locale:a},t.createElement(Zn,{event:d,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===(N=null===(M=r.current)||void 0===M?void 0:M.querySelector(".calendar-content"))||void 0===N?void 0:N.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(${f&&!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"),l=(null==o?void 0:o.scrollLeft)||0;L.style.left=`${t.left-n.left+l}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(${f?"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(${f&&!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(${f&&!y?"175%":"100%"} / 7)`;L.style.left=y?`${m}px`:`calc(${t} * ${e.dayIndex})`,L.style.width=`calc(${t} - 3px)`}}e.allDay?null===(H=null==o?void 0:o.current)||void 0===H||H.appendChild(L):null===(P=null===(R=r.current)||void 0===R?void 0:R.querySelector(".calendar-content"))||void 0===P||P.appendChild(L),D.current={drag:e,color:l,title:C,layout:E},b.current=i.createRoot(L),b.current.render(t.createElement(Tn,{locale:a},t.createElement(Bn,{drag:e,color:l,title:C,layout:E,allDay:e.allDay,formatTime:Q,getLineColor:s||(()=>""),getDynamicPadding:d||(()=>"0px"),renderer:c,isMobile:f})))}l?(L.style.backgroundColor=G(l,null==v?void 0:v.getCalendarRegistry()),L.style.color=X(l,null==v?void 0:v.getCalendarRegistry())):L.className+=" bg-primary/10 text-primary border border-dashed border-primary/50",x.current=L},[w,p,y,o,r,Q,s,d,c,m,h,g,u]),E=t.useCallback((...e)=>{var n,l;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==o?void 0:o.current))null===(n=null==o?void 0:o.current)||void 0===n||n.appendChild(i);else if(!w){const e=null===(l=r.current)||void 0===l?void 0:l.querySelector(".calendar-content");i.parentElement!==e&&(null==e||e.appendChild(i))}if(w){if(y)i.style.left=`${m}px`,i.style.width=`calc(100% - ${m}px - 2px)`;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=h-4+"px",i.style.marginBottom="3px",i.className=i.className.replace("rounded-sm","rounded-xl")}else{const e=(p-g)*u,t=(x-p)*u;i.style.top=`${e+3}px`,i.style.height=t-4+"px",i.style.marginBottom="0",i.className=i.className.replace("rounded-xl","rounded-sm");const n=f&&!y?"175%":"100%";if(C){if(y)i.style.left=`${m}px`,i.style.width=`calc(((100% - ${m}px) * ${C.width/100}) - 3px)`;else{const e=`calc(${n} / 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% - ${m}px)`:`calc(${n} / 7)`;i.style.left=y?`${m}px`:`calc(${e} * ${v})`,i.style.width=`calc(${e} - 3px)`}}if(i.style.cursor="grabbing",b.current&&D.current){const e=Object.assign(Object.assign({},D.current.drag),{dayIndex:v,startHour:p,endHour:x,allDay:w});D.current.drag=e,b.current.render(t.createElement(Tn,{locale:a},t.createElement(Bn,{drag:e,color:D.current.color,title:D.current.title,layout:C||D.current.layout,allDay:w,formatTime:Q,getLineColor:s||(()=>""),getDynamicPadding:d||(()=>"0px"),renderer:c,isMobile:f})))}}},[p,o,Q,r,y,h,m,g,u,s,d,c]);return{dragIndicatorRef:x,reactRootRef:b,removeDragIndicator:w,createDragIndicator:C,updateDragIndicator:E}})(n),d=(e=>{const{t:n}=Se(),{options:a,common:r,state:o,manager:l}=e,{viewType:s,onEventsUpdate:i,onEventCreate:d,onEventEdit:c,calculateNewEventLayout:u,calculateDragLayout:g,currentWeekStart:m,events:h,FIRST_HOUR:v=0,LAST_HOUR:f=24,MIN_DURATION:p=.25,app:y}=a,{dragRef:x,currentDragRef:b,setDragState:D,resetDragState:w,throttledSetEvents:C}=o,{removeDragIndicator:E,createDragIndicator:k,updateDragIndicator:j}=l,{pixelYToHour:T,getColumnDayIndex:S,checkIfInAllDayArea:M,handleDirectScroll:N,daysDifference:I,addDaysToDate:H,getTargetDateFromPosition:R}=r,L=s===exports.ViewType.MONTH||s===exports.ViewType.YEAR,$=s===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},F=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),l=x.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:s,clientY:i}=Un(e);if(!l||!l.active)return;if("move"===l.mode&&!l.indicatorVisible){if(Math.hypot(s-l.startX,i-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=M(i),c=$?l.dayIndex:S(s);if(d){if(!l.allDay){l.allDay=!0,l.startHour=0,l.endHour=0,l.eventDate=m?ge(m,c):new Date,E(),l.indicatorVisible=!1;const e=null==h?void 0:h.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})),j(c,0,0,!0)}else{N(i);const e=T(i);if(null!==(t=l.startDragDayIndex)&&void 0!==t||l.originalDay,l.dayIndex,l.allDay){l.allDay=!1,l.startHour=te(e),l.endHour=l.startHour+1,l.duration=1,l.hourOffset=0,l.eventDate=m?ge(m,c):new Date,E(),l.indicatorVisible=!1;const t=null==h?void 0:h.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=te(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=m?ge(m,c):new Date,D(e=>Object.assign(Object.assign({},e),{dayIndex:c,startHour:te(l.startHour),endHour:te(l.endHour),allDay:!1}));let a=null;if("move"===l.mode&&l.eventId&&g){const e=null==h?void 0:h.find(e=>e.id===l.eventId);e&&(a=g(e,c,te(l.startHour),te(l.endHour)))}j(c,te(l.startHour),te(l.endHour),!1,a)}},[g,M,k,m,h,v,S,N,f,$,T,E,j,x,D]),V=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",F),document.removeEventListener("mouseup",V),document.removeEventListener("touchmove",F,{capture:!0}),document.removeEventListener("touchend",V),void w();if("move"!==e.mode||!e.eventId)return;let r=e.startHour,o=e.endHour;e.allDay||(r=te(e.startHour),o=te(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?ge(m,e.dayIndex):A(t.start);const l=null!==(n=e.startDragDayIndex)&&void 0!==n?n:e.originalDay,s=e.dayIndex-l;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()+s);const r=new Date(a);e.eventDurationDays&&e.eventDurationDays>0&&r.setDate(r.getDate()+e.eventDurationDays),i=P(a),d=P(U(r))}else{const n=A(t.start),l=A(t.end),c=t.allDay;if(Y(n,l,null!==(a=t.allDay)&&void 0!==a&&a)>0&&!c){const e=new Date(n);e.setDate(e.getDate()+s);const t=new Date(l);t.setDate(t.getDate()+s),i=O(e),d=O(t)}else{const t=m?ge(m,e.dayIndex):new Date,n=Z(t,r),a=Z(t,o);i=O(n),d=O(a)}}const c=e.originalDay+s;return Object.assign(Object.assign({},t),{day:c,start:i,end:d,allDay:e.allDay})})),document.removeEventListener("mousemove",F),document.removeEventListener("mouseup",V),document.removeEventListener("touchmove",F,{capture:!0}),document.removeEventListener("touchend",V),E(),w()},[F,E,w,i,p,m,x]),W=t.useCallback(e=>{var t,r,o,l,s,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),M=!(null==y?void 0:y.state.readOnly);if("move"===D.mode&&!E)return;if(("resize"===D.mode||"create"===D.mode)&&!M)return;e.cancelable&&(e.preventDefault(),e.stopPropagation());const{clientX:z,clientY:F}=Un(e);if(D&&D.active)if("resize"===D.mode?L||D.allDay?document.body.style.cursor="ew-resize":document.body.style.cursor="ns-resize":document.body.style.cursor="grabbing",L){if("resize"!==D.mode){if("move"===D.mode){const e=Math.hypot(z-D.startX,F-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&&j(z,F)}const e=R(z,F);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,l=D.originalEndTime;if("left"===D.resizeDirection){n=new Date(e),r(n,o);const s=A(D.originalEvent.end)||t;a=new Date(s),r(a,l),n>a&&(n=a)}else{const s=A(D.originalEvent.start)||t;n=new Date(s),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 s=D.originalEvent.allDay?P(n):O(n),i=D.originalEvent.allDay?P(a):O(a);C(e=>e.map(e=>e.id===D.eventId?Object.assign(Object.assign({},e),{start:s,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=H(D.originalStartDate,n),r=H(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{N(F),D.lastClientY=F;const e=T(F);if("create"===D.mode&&D.allDay){const e=Math.hypot(z-D.startX,F-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 j(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?ge(m,e):new Date,t>n&&(t=n)):"right"===D.resizeDirection&&(n=m?ge(m,e):new Date,n<t&&(n=t)),D.originalStartDate=new Date(t.getTime()),D.originalEndDate=new Date(n.getTime());const a=P(t),r=P(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!==(s=a.allDay)&&void 0!==s&&s);r=(null!==(i=a.day)&&void 0!==i?i:0)+n}let o=r,l=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?(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<J&&(t=D.originalEndHour-J)))}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(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<J&&(n=D.startHour+J))}else if("right"===D.resizeDirection){const e=$?D.dayIndex:S(z);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]=[te(t),te(n)];D.startHour=t,D.endHour=n,D.dayIndex=l,C(e=>e.map(e=>{if(e.id!==D.eventId)return e;const t=A(e.start),n=Z(m?ge(m,l):t,u),a=m?ge(m,o):t,r=Z(a,g),s=O(n),i=O(r);return Object.assign(Object.assign({},e),{start:s,end:i,day:l})}),D.mode),j(D.dayIndex,u,g,!1)}else if("create"===D.mode){if(a.isMobile){const t=te(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=te(e),[n,a]=F<D.startY?[t,Math.max(t+J,D.endHour)]:[D.startHour,Math.max(D.startHour+J,t)];D.startHour=n,D.endHour=a}const t=null==u?void 0:u(D.dayIndex,D.startHour,D.endHour);j(D.dayIndex,D.startHour,D.endHour,!1,t)}else if("move"===D.mode){const t=$?D.dayIndex:S(z);let n=te(e+(null!==(b=D.hourOffset)&&void 0!==b?b: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==h?void 0:h.find(e=>e.id===D.eventId);e&&(r=g(e,t,te(n),te(a)))}j(t,te(n),te(a),!1,r)}}},[L,$,j,R,C,I,H,v,f,u,S,T,N,g,h,x,k]),q=t.useCallback(e=>{var t,a,r;const o=x.current;if(!o||!o.active)return;const l=null==y?void 0:y.getReadOnlyConfig(),s=!1!==(null==l?void 0:l.draggable),c=!(null==y?void 0:y.state.readOnly);if("move"===o.mode&&!s)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",q),document.removeEventListener("touchmove",W,{capture:!0}),document.removeEventListener("touchend",q),void w();const{clientX:u,clientY:g}=Un(e);if(o&&o.active){if(L){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?P(o.originalStartDate):O(o.originalStartDate),a=e?P(o.originalEndDate):O(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?P(o.originalStartDate):O(o.originalStartDate),n=e?P(o.originalEndDate):O(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=R(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 l=new Date(e);l.setHours(a.getHours(),a.getMinutes(),0,0);const s=t.allDay?P(r):O(r),i=t.allDay?P(l):O(l);return Object.assign(Object.assign({},t),{start:s,end:i})})))}}else{let[e,t]=[te(o.startHour),te(o.endHour)];if(t-e<p&&("top"===o.resizeDirection?e=t-p:t=e+p),"create"===o.mode){const a=m?ge(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=Z(a,e),l=Z(a,t),s=o.allDay,i=s?P(r):O(r),c=s?P(l):O(l);null==d||d({id:String(Date.now()),title:n(s?"newAllDayEvent":"newEvent"),day:o.dayIndex,start:i,end:c,calendarId:"blue",allDay:s})}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",q),document.removeEventListener("touchmove",W,{capture:!0}),document.removeEventListener("touchend",q),E(),o.indicatorVisible=!1,o.sourceElement=null,w()}},[L,W,E,w,R,C,p,m,d,i,x,D]),_=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:l}=Un(e);if(L){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=O(a),l=O(r),s={id:String(Date.now()),title:n("newEvent"),start:o,end:l,day:e.getDay(),calendarId:"blue",allDay:!1};null==d||d(s),c&&setTimeout(()=>{c(s)},50)}else{const[e,r]=t,s=x.current;if(!s)return;const i=1,d=!!a.isMobile?-i/2:0,c=te(r+d);Object.assign(s,{active:!0,mode:"create",eventId:null,startX:o,startY:l,dayIndex:e,startHour:c,endHour:c+i,allDay:!1,eventDate:m?ge(m,e):new Date,duration:i,hourOffset:d}),D({active:!0,mode:"create",eventId:null,dayIndex:e,startHour:s.startHour,endHour:s.endHour,allDay:!1});const g=null==u?void 0:u(e,s.startHour,s.endHour);k(s,"blue",n("newEvent"),g),s.sourceElement=null,s.indicatorVisible=!0,document.addEventListener("mousemove",W),document.addEventListener("mouseup",q),document.addEventListener("touchmove",W,{capture:!0,passive:!1}),document.addEventListener("touchend",q)}},[L,d,c,m,u,k,W,q,x,D]),X=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:l,clientY:s}=Un(e),i=x.current;if(!i)return;const d=e.currentTarget;if(L){b.current={x:l-d.getBoundingClientRect().left,y:s-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=l,i.startY=s,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",q),document.addEventListener("touchmove",W,{capture:!0,passive:!1}),document.addEventListener("touchend",q)}else{const e=T(s),n=t._segmentInfo,c=!!n,u=c?n.dayIndex:null!==(a=t.day)&&void 0!==a?a:0,g=c?n.startHour:B(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:l,startY:s,dayIndex:u,startHour:g,endHour:c?n.endHour:ne(t),originalDay:null!==(r=t.day)&&void 0!==r?r:0,originalStartHour:B(t.start),originalEndHour:ne(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:B(t.start),endHour:ne(t),allDay:t.allDay||!1}),i.sourceElement=d,i.indicatorVisible=!1,document.addEventListener("mousemove",F),document.addEventListener("mouseup",V),document.addEventListener("touchmove",F,{capture:!0,passive:!1}),document.addEventListener("touchend",V)}},[L,k,q,W,F,V,T,x,b,D]),G=t.useCallback((e,t,n)=>{var a,r,o,l,s,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}=Un(e),u=x.current;if(u){if(L){const e=A(t.start),a=A(t.start),r=A(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=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=T(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:B(t.start),endHour:ne(t),originalDay:null!==(s=t.day)&&void 0!==s?s:0,originalStartHour:B(t.start),originalEndHour:ne(t),resizeDirection:n,lastUpdateTime:Date.now(),initialMouseY:e,hourOffset:"top"===n?B(t.start)-e:ne(t)-e,allDay:!1}),D({active:!0,mode:"resize",eventId:t.id,dayIndex:null!==(i=t.day)&&void 0!==i?i:0,startHour:B(t.start),endHour:ne(t),allDay:!1})}document.addEventListener("mousemove",W),document.addEventListener("mouseup",q),document.addEventListener("touchmove",W,{capture:!0,passive:!1}),document.addEventListener("touchend",q)}},[L,W,q,T,x,D]);return{handleDragMove:W,handleDragEnd:q,handleCreateStart:_,handleMoveStart:X,handleResizeStart:G,handleUniversalDragMove:F,handleUniversalDragEnd:V}})({options:n,common:o,state:l,manager:s}),c=(e=>{const{t:n}=Se(),{options:a,common:r,state:o,manager:l,handleDragMove:s,handleDragEnd:i}=e,{viewType:d,currentWeekStart:c,app:u}=a,{dragRef:g,setDragState:m}=o,{createDragIndicator:h}=l,{pixelYToHour:v,getColumnDayIndex:f}=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?ge(c,t):new Date,r=P(e),o=P(e),l={id:String(Date.now()),title:n("newAllDayEvent"),day:t,start:r,end:o,calendarId:"blue",allDay:!0};return void a.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:t,allDay:!0,eventDate:c?ge(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",s),document.addEventListener("mouseup",i))},[p,c,i,s,g,m,null==u?void 0:u.state.locale,a]),pixelYToHour:v,getColumnDayIndex:f}})({options:n,common:o,state:l,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:o});return Object.assign({createDragIndicator:s.createDragIndicator,updateDragIndicator:s.updateDragIndicator,removeDragIndicator:s.removeDragIndicator,handleCreateStart:d.handleCreateStart,handleMoveStart:d.handleMoveStart,handleResizeStart:d.handleResizeStart,dragState:l.dragState,isDragging:l.dragState.active},r?{daysDifference:u.daysDifference,addDaysToDate:u.addDaysToDate,getTargetDateFromPosition:u.getTargetDateFromPosition}:{handleCreateAllDayEvent:c.handleCreateAllDayEvent,pixelYToHour:c.pixelYToHour,getColumnDayIndex:c.getColumnDayIndex})};function _n(e,t){const n=e.getPlugin("drag"),a=qn(Object.assign(Object.assign({},t),{app:e}));if(!n)return D.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,s=!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&&s?a.handleCreateStart:()=>{},handleResizeStart:o&&r.enableResize&&s?a.handleResizeStart:void 0,handleCreateAllDayEvent:o&&r.enableAllDayCreate&&s?a.handleCreateAllDayEvent:()=>{},dragState:a.dragState,isDragging:!(!o||!l)&&a.isDragging}}function Xn(e){const{app:a,onEventCreated:r}=e,{t:o}=Se(),l=t.useCallback(e=>{e.dataTransfer.types.includes("application/x-dayflow-calendar")&&(e.preventDefault(),e.dataTransfer.dropEffect="copy")},[]);return{handleDrop:t.useCallback((e,t,l,s)=>{e.preventDefault();const i=e.dataTransfer.getData("application/x-dayflow-calendar");if(!i)return null;try{const e=JSON.parse(i);let d,c,u=!1;s?(d=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!==l?(d=n.Temporal.PlainDateTime.from({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:l,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:l}}const Gn=({handlePreviousMonth:e,handleToday:t,handleNextMonth:n})=>{const{t:a}=Se();return r.jsxs("div",{className:"df-navigation flex items-center gap-1",children:[r.jsx("button",{className:nt,onClick:e,"aria-label":"Previous month",children:r.jsx(s.ChevronLeft,{className:at})}),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:nt,onClick:n,"aria-label":"Next month",children:r.jsx(s.ChevronRight,{className:at})})]})},Kn=({app:e,currentDate:t,visibleMonth:n,currentDayEvents:a,selectedEvent:o,setSelectedEvent:l,handleMonthChange:s,handleDateSelect:i,switcherMode:d})=>{const{t:c,locale:u}=Se();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:`${ut} 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:ze,style:{position:"relative"},children:r.jsx("div",{children:r.jsx("h1",{className:Ye,children:" "})})}),r.jsx(Gn,{handlePreviousMonth:()=>e.goToPrevious(),handleNextMonth:()=>e.goToNext(),handleToday:()=>e.goToToday()})]}),r.jsx(mt,{visibleMonth:n,currentDate:t,showHeader:!0,onMonthChange:s,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:`${st} ${ct}`,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:K(t.calendarId||"blue")},onClick:()=>{l(t),e.onEventClick(t)},children:[r.jsx("div",{className:`font-medium ${ct}`,children:t.title}),!t.allDay&&r.jsxs("div",{className:`${dt} ${it}`,children:[Q(B(t.start))," -"," ",Q(ne(t))]}),t.allDay&&r.jsx("div",{className:`${dt} ${it}`,children:c("allDay")})]},t.id))})]})]})})},Jn=({viewType:e,currentDate:t,onPrevious:n,onNext:a,onToday:o,customTitle:l,customSubtitle:s,showTodayBox:i,stickyYear:d,stickyYearOffset:c=0,nextYear:u,nextYearOffset:g=0})=>{const{locale:m}=Se(),h=void 0===i||i,v=l||(()=>{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""}})(),f="day"===e?s||("day"===e?t.toLocaleDateString(m,{weekday:"long"}):null):null;return r.jsxs("div",{className:ze,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:Ye,style:{position:"absolute",top:0,left:0,transform:`translateY(-${c}px)`,willChange:"transform"},children:d}),u&&r.jsx("h1",{className:Ye,style:{position:"absolute",top:0,left:0,transform:`translateY(${g}px)`,willChange:"transform"},children:u})]}):r.jsxs("div",{children:[r.jsx("div",{className:`${Ye} text-gray-900 dark:text-white`,children:v}),f&&r.jsx("div",{className:"mt-3 text-gray-600 dark:text-gray-400",children:f})]})}),h&&n&&a&&o&&r.jsx("div",{className:"flex items-center gap-2",children:r.jsx(Gn,{handlePreviousMonth:n,handleNextMonth:a,handleToday:o})})]})},Qn=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(s.Gift,{className:"h-3 w-3"}):t.includes("birthday")||t.includes("anniversary")||t.includes("生日")?r.jsx(s.Heart,{className:"h-3 w-3"}):t.includes("conference")||t.includes("meeting")||t.includes("会议")||t.includes("研讨")?r.jsx(s.Star,{className:"h-3 w-3"}):t.includes("trip")||t.includes("travel")||t.includes("旅行")?r.jsx(s.MapPin,{className:"h-3 w-3"}):r.jsx(s.CalendarDays,{className:"h-3 w-3"})},ea=(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),l=new Date(r);l.setHours(0,0,0,0);const s=new Date(o);s.setHours(0,0,0,0);let i=new Date(s);if(!e.allDay){if(!(0!==o.getHours()||0!==o.getMinutes()||0!==o.getSeconds())){const e=o.getTime()-r.getTime();e>0&&e<864e5&&(i=new Date(s),i.setDate(i.getDate()-1))}}const d=V(l,i)>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(s),u.setHours(23,59,59,999);else{0!==o.getHours()||0!==o.getMinutes()||0!==o.getSeconds()?(u=new Date(s),u.setHours(23,59,59,999)):(u=new Date(s),u.setTime(u.getTime()-1))}if(u<t||c>a)return;const g=c<t?t:c,m=u>a?a:u,h=Math.max(0,Math.floor((g.getTime()-t.getTime())/864e5)),v=Math.min(6,Math.floor((m.getTime()-t.getTime())/864e5)),f=c>=t,p=u<=a,y=0===h||6===v;let x;x=f&&p?"single":f?y&&6===v?"start-week-end":"start":p?y&&0===h?"end-week-start":"end":"middle";const b=V(c,u)+1;n.push({id:`${e.id}-week-${t.getTime()}`,originalEventId:e.id,event:e,startDayIndex:h,endDayIndex:v,segmentType:x,totalDays:b,segmentIndex:0,isFirstSegment:f,isLastSegment:p})}),n},ta=(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 l=V(r,o);if(0===l)return[];const s=0!==a.getHours()||0!==a.getMinutes()||0!==a.getSeconds()||0!==a.getMilliseconds(),i=a.getTime()-n.getTime();if(!e.allDay&&1===l&&!s&&i<864e5)return[];const d=s?l:Math.max(0,l-1),c=[];for(let e=0;e<=d;e++){const o=new Date(r);o.setDate(r.getDate()+e);const l=Math.floor((o.getTime()-t.getTime())/864e5);if(l<0||l>6)continue;const i=0===e,u=e===d,g=i?n.getHours()+n.getMinutes()/60:0,m=u&&s?a.getHours()+a.getMinutes()/60:24;c.push({dayIndex:l,startHour:g,endHour:m,isFirst:i,isLast:u})}return c},na=t.memo(({segment:e,segmentIndex:n,isDragging:a,isResizing:o=!1,isSelected:l=!1,onMoveStart:s,onResizeStart:i,onEventLongPress:d,isMobile:c=!1,isDraggable:u=!0,isEditable:g=!0,viewable:m=!0})=>{const h=17*n,v=`calc(${e.startDayIndex/7*100}% + 2px)`,f=`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:v,width:f,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},l||a?{backgroundColor:G(b),color:"#fff"}:{backgroundColor:_(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&&s(t,e.event)},onTouchStart:t=>{if(!s||!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&&s({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} (${qt(e.event.start)} - ${qt(e.event.end)})`,children:[c&&l&&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:K(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:K(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=B(e.event.start),o=ne(e.event),l=Q(a),s=Q(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&&Qn(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:K(n),width:"12px",height:"12px"},children:Qn(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:K(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:l}),e.isLastSegment&&!e.event.allDay&&24!==o&&r.jsx("span",{className:"text-xs font-medium whitespace-nowrap ml-auto hidden md:inline",children:`ends ${s}`})]})})()}),x("right")]});var w});na.displayName="MultiDayEvent";const aa=({event:e,position:a,panelRef:l,isAllDay:s,eventVisibility:i,calendarRef:d,selectedEventElementRef:c,onEventUpdate:u,onEventDelete:g,app:m})=>{var h;const{effectiveTheme:v}=fn(),f=en(v),{t:p}=Se(),y="dark"===f||"undefined"!=typeof document&&document.documentElement.classList.contains("dark"),b=!(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():x()).getVisible().map(e=>({label:e.name,value:e.id})),[m,null==m?void 0:m.getCalendars()]),E=t.useMemo(()=>R(e.start)?e.end&&!R(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()}))},j=(()=>{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=l.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),s=Math.min(e.bottom,r.bottom),i=Math.max(0,s-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=l.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})(),T=r.jsxs("div",{ref:l,className:`${rt} 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:j}),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:!b,disabled:!b,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"})}),b&&r.jsx(yt,{options:C,value:e.calendarId||"blue",onChange:t=>{u(Object.assign(Object.assign({},e),{calendarId:t}))},registry:null==m?void 0:m.getCalendarRegistry()})]}),s?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(Pt,{value:[e.start,e.end],format:"YYYY-MM-DD",showTime:!1,timeZone:E,matchTriggerWidth:!0,disabled:!b,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(Pt,{value:[e.start,e.end],timeZone:E,disabled:!b,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:!b,disabled:!b,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")})]}),b&&r.jsxs("div",{className:"flex space-x-2",children:[s?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=R(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=R(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(T,S):null},ra=({event:e,position:t,panelRef:n,isAllDay:a,eventVisibility:l,calendarRef:s,selectedEventElementRef:i,onEventUpdate:d,onEventDelete:c,onClose:u,contentRenderer:g})=>{const{effectiveTheme:m}=fn(),h=en(m),v="dark"===h?"#1f2937":"white",f="dark"===h?"rgb(55, 65, 81)":"rgb(229, 231, 235)",p=(()=>{var e;let a={};if("sticky-top"===l){const n=null===(e=s.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:v,transform:"rotate(45deg)",transformOrigin:"center",top:e-6+"px",borderRight:""+(t.isSunday?`1px solid ${f}`:"none"),borderTop:""+(t.isSunday?`1px solid ${f}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${f}`),borderBottom:""+(t.isSunday?"none":`1px solid ${f}`)},t.isSunday?{right:"-6px"}:{left:"-6px"})}}else if("sticky-bottom"===l){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:v,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 ${f}`:"none"),borderTop:""+(t.isSunday?`1px solid ${f}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${f}`),borderBottom:""+(t.isSunday?"none":`1px solid ${f}`)}}else if(t&&i.current&&s.current){const e=i.current.getBoundingClientRect(),r=s.current.querySelector(".calendar-content");if(r){const o=r.getBoundingClientRect(),l=Math.max(e.top,o.top),s=Math.min(e.bottom,o.bottom),i=Math.max(0,s-l);let d;d=i===e.height?e.top+e.height/2:i>0?l+i/2:e.top+e.height/2;const c=d-t.top,u=n.current;let 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:v,transform:"rotate(45deg)",transformOrigin:"center",top:h-6+"px",borderRight:""+(t.isSunday?`1px solid ${f}`:"none"),borderTop:""+(t.isSunday?`1px solid ${f}`:"none"),borderLeft:""+(t.isSunday?"none":`1px solid ${f}`),borderBottom:""+(t.isSunday?"none":`1px solid ${f}`)},t.isSunday?{right:"-6px"}:{left:"-6px"})}}return a})(),y=r.jsxs("div",{ref:n,className:`${rt} 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)},oa=({event:e,app:t,isEventSelected:n,hideTime:a})=>{const o=`${Math.floor(B(e.start)).toString().padStart(2,"0")}:${Math.round(B(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:K(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())},className:`inline-block w-0.75 h-3 ${gt} 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:`${dt} ml-1 shrink-0 ${n?"text-white":""} hidden md:block`,style:n?void 0:{opacity:.8},children:o})]})},la=({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:`${gt} shrink-0`,children:a}):e.title.toLowerCase().includes("easter")||e.title.toLowerCase().includes("holiday")?r.jsx("span",{className:`inline-block ${gt} shrink-0 ${t?"text-yellow-200":"text-yellow-600"}`,children:"⭐"}):r.jsx(s.CalendarDays,{className:`${Qe} ${t?"text-white":""}`})),r.jsx("span",{className:"truncate "+(t?"text-white":""),children:e.title})]})},sa=({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(s.CalendarDays,{className:Qe})),r.jsx("div",{className:`${Ke} pr-1`,style:{lineHeight:"1.2"},children:e.title}),n&&t&&r.jsx("div",{className:et,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),n(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]})},ia=({event:e,app:t,multiDaySegmentInfo:n,isEditable:a,isTouchEnabled:o,isEventSelected:l,onResizeStart:s})=>{const i=n?n.startHour:B(e.start),d=n?n.endHour:ne(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:Je,style:{backgroundColor:K(e.calendarId||"blue",null==t?void 0:t.getCalendarRegistry())}}),r.jsxs("div",{className:"h-full flex flex-col overflow-hidden pl-3 "+(ne(e)-B(e.start)<=.25?"px-1 py-0":"p-1"),children:[r.jsx("div",{className:`${Ke} 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?`${Q(i)} - ${Q(d)}`:ee(e)})]}),s&&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=>s(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=>s(t,e,"bottom")}),!u&&g&&n&&r.jsx("div",{className:et,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),s(t,e,"right")},onClick:e=>{e.preventDefault(),e.stopPropagation()}})]}),o&&l&&s&&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:K(m,null==t?void 0:t.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),s(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:K(m,null==t?void 0:t.getCalendarRegistry())},onTouchStart:t=>{t.stopPropagation(),s(t,e,"bottom")}})]})]})},da=({event:e,layout:n,isAllDay:a=!1,allDayHeight:l=28,calendarRef:s,isBeingDragged:i=!1,isBeingResized:d=!1,isDayView:c=!1,isMonthView:u=!1,isMultiDay:g=!1,segment:m,segmentIndex:h=0,hourHeight:v,firstHour:f,selectedEventId:p,detailPanelEventId:y,onMoveStart:x,onResizeStart:b,onEventUpdate:D,onEventDelete:w,newlyCreatedEventId:C,onDetailPanelOpen:E,onEventSelect:k,onEventLongPress:j,onDetailPanelToggle:T,customDetailPanelContent:S,customEventDetailDialog:M,multiDaySegmentInfo:N,app:I,isMobile:H=!1,enableTouch:R,hideTime:O})=>{const P=null!=R?R:H,[L,A]=t.useState(!1),[$,z]=t.useState(!1),Y=g&&m?`${e.id}::${m.id}`:void 0!==(null==N?void 0:N.dayIndex)?`${e.id}::day-${N.dayIndex}`:e.id,F=y===Y,[V,W]=t.useState(null),[Z,U]=t.useState("visible"),q=t.useRef(null),K=t.useRef(null),J=t.useRef(null),Q=t.useRef(null),ee=t.useRef(null),te=t.useRef(null),ae=void 0!==p?p===e.id:L,re=null==I?void 0:I.getReadOnlyConfig(),oe=!(null==I?void 0:I.state.readOnly),le=!1!==(null==re?void 0:re.viewable),se=!1!==(null==re?void 0:re.draggable),ie=e=>{if(!s.current)return null;const t=s.current.getBoundingClientRect();if(u){const n=t.width/7;return{left:t.left+e*n,width:n}}const n=H?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==N?void 0:N.dayIndex)?N.dayIndex:m?m.startDayIndex:null!==(t=e.day)&&void 0!==t?t:0},ue=e=>{if(!s.current)return null;const t=s.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=H?48:80,a=c?1:7,r=(t.width-n)/a,o=e-t.left-n,l=Math.floor(o/r);return Number.isFinite(l)?Math.max(0,Math.min(a-1,l)):null},ge=()=>new Promise(t=>{if(!s.current||a||u)return void t();const n=s.current.querySelector(".calendar-content");if(!n)return void t();const r=N?N.startHour:B(e.start),o=N?N.endHour:ne(e),l=(r-f)*v,i=l+Math.max((o-r)*v,v/4),d=n.scrollTop,c=n.clientHeight;if(l>=d&&i<=d+c)return void t();const g=((r+o)/2-f)*v-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||!s.current||!K.current)return;const t=s.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=H?48:80;o=(t.width-e)/7,r=t.left+e+n*o}const l=Math.min(window.innerWidth,t.right),i=Math.min(window.innerHeight,t.bottom);requestAnimationFrame(()=>{var a,o,d,h,p;if(!K.current)return;if(!J.current)return;const y=K.current.getBoundingClientRect(),x=y.width,b=y.height;let D,w,C;if("sticky-top"===Z||"sticky-bottom"===Z){const t=null===(a=s.current)||void 0===a?void 0:a.querySelector(".calendar-content");if(!t)return;const n=N?N.startHour:B(e.start),r=N?N.endHour:ne(e),l=(n-f)*v,i=Math.max((r-n)*v,v/4),d=t.getBoundingClientRect(),c=t.scrollTop,u=d.top+l-c,g=null===(o=q.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==N?void 0:N.dayIndex)&&void 0!==p?p:ce(),n=H?48:80,a=c?1:7,r=(t.width-n)/a,o=ie(e),l=o?o.left:t.left+n+e*r,s=o?o.width:r,i=Math.max(0,c?C.width:s-3),d=c?C.left:l;C=Object.assign(Object.assign({},C),{left:d,right:d+i,width:i})}const E=l-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,l-x-10):t.left+10;const j=C.top-b/2+C.height/2,T=Math.max(10,t.top+10),S=i-10;w=j<T?T:j+b>S?S-b:j,W(e=>e?Object.assign(Object.assign({},e),{top:w,left:D,isSunday:D<r}):null)})},[s,e.day,e.start,e.end,Z,u,f,v,g,null==m?void 0:m.startDayIndex,null==m?void 0:m.endDayIndex,null==N?void 0:N.dayIndex,y,Y]),he=t.useCallback(()=>{if(!ae||!F||!q.current||!s.current||a||u)return;const t=s.current.querySelector(".calendar-content");if(!t)return;const n=N?N.startHour:B(e.start),r=N?N.endHour:ne(e),o=(n-f)*v,l=o+Math.max((r-n)*v,v/4),i=t.getBoundingClientRect(),d=t.scrollTop;let c=l<d+6,g=o>d+i.height-6;const m=i.bottom<0,h=i.top>window.innerHeight;m?c=!0:h&&(g=!0),U(c?"sticky-top":g?"sticky-bottom":"visible"),me()},[L,F,s,a,u,B(e.start),ne(e),f,v,me,null==N?void 0:N.startHour,null==N?void 0:N.endHour,null==N?void 0:N.dayIndex,y,Y]);t.useEffect(()=>{var e,t;if(!ae||!F||a)return;const n=null===(e=s.current)||void 0===e?void 0:e.querySelector(".calendar-content");if(!n)return;const r=()=>he(),o=()=>{he(),me()},l=[n];let i=null===(t=s.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||l.push(i),i=i.parentElement}l.forEach(e=>{e.addEventListener("scroll",r)}),window.addEventListener("scroll",r,!0),window.addEventListener("resize",o);let d=null;return s.current&&(d=new ResizeObserver(()=>{o()}),d.observe(s.current)),he(),()=>{l.forEach(e=>{e.removeEventListener("scroll",r)}),window.removeEventListener("scroll",r,!0),window.removeEventListener("resize",o),d&&d.disconnect()}},[ae,F,a,he,me,s,Z]),t.useEffect(()=>{if(!ae&&!F)return;const t=t=>{var n,a;const r=t.target,o=null===(n=q.current)||void 0===n?void 0:n.contains(r),l=null!==r.closest(`[data-event-id="${e.id}"]`),s=null===(a=K.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-color-picker-dropdown]");F?o||l||s||i||d||c||(k&&k(null),de(null),A(!1),null==T||T(null)):!ae||o||l||c||(k&&k(null),de(null),A(!1),null==T||T(null))};return document.addEventListener("mousedown",t),()=>{document.removeEventListener("mousedown",t)}},[ae,F,k,T,e.id]),t.useEffect(()=>{g&&m&&!m.isFirstSegment||C!==e.id||F||setTimeout(()=>{var t,n;if(q.current){let a=q.current;if(g){const e=q.current.querySelector("div");e&&(a=e)}g?m?de(m.startDayIndex):void 0!==(null==N?void 0:N.dayIndex)?de(N.dayIndex):de(null!==(t=e.day)&&void 0!==t?t:null):de(null!==(n=e.day)&&void 0!==n?n:null),J.current=a,A(!0),null==T||T(Y),W({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>{me()})}null==E||E()},150)},[C,e.id,F,E,me,g,m,T,Y]);const ve=t.useRef(null);t.useEffect(()=>{let t,n=!0;const a=null==I?void 0:I.state.highlightedEventId;return ae&&a===e.id?ve.current!==a&&(ve.current=a,ge().then(()=>{n&&(z(!0),t=setTimeout(()=>{n&&z(!1)},150))})):z(!1),a!==e.id&&(ve.current=null),()=>{n=!1,t&&clearTimeout(t)}},[ae,null==I?void 0:I.state.highlightedEventId,e.id]);const fe=()=>m?r.jsx(na,{segment:m,segmentIndex:null!=h?h:0,isDragging:i||ae,isResizing:d,isSelected:ae,onMoveStart:x||(()=>{}),onResizeStart:b,isMobile:H,isDraggable:se,isEditable:oe,viewable:le}):null,pe=()=>{if(g&&m){const{segmentType:e}=m;if("single"===e||"start"===e)return Ge;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 Ge},ye=e.calendarId||"blue";return r.jsxs(r.Fragment,{children:[r.jsx("div",{ref:q,"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:ae||F?1e3:1,transform:$?"scale(1.15)":void 0,transition:"transform 0.1s ease-in-out",cursor:se||le?"pointer":"default"};if(a){const e={height:l-4+"px",opacity:i?.3:1,zIndex:ae||F?1e3:1,transform:$?"scale(1.12)":void 0,transition:"transform 0.1s ease-in-out",cursor:se||le?"pointer":"default"},t=h*l;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=N?N.startHour:B(e.start),b=N?N.endHour:ne(e),D={top:`${(x-f)*v+3}px`,height:Math.max((b-x)*v,v/4)-4+"px",position:"absolute",opacity:i?.3:1,zIndex:ae||F?1e3:null!==(t=null==n?void 0:n.zIndex)&&void 0!==t?t:1,transform:$?"scale(1.12)":void 0,transition:"transform 0.1s ease-in-out",cursor:se||le?"pointer":"default"};if(ae&&F&&("sticky-top"===Z||"sticky-bottom"===Z)){const e=null===(r=s.current)||void 0===r?void 0:r.getBoundingClientRect();if(e){const t=null!==(o=null==N?void 0:N.dayIndex)&&void 0!==o?o:ce(),n=H?48:80,a=c?1:7;let r=(e.width-n)/a,l=e.left+n+t*r;u&&(r=e.width/7,l=e.left+t*r);const i=ie(t);i&&(l=i.left,r=i.width);let g=null===(d=s.current)||void 0===d?void 0:d.querySelector(".calendar-content");g||(g=null===(p=s.current)||void 0===p?void 0:p.querySelector(".calendar-renderer"));const m=null==g?void 0:g.getBoundingClientRect(),h=null===(y=q.current)||void 0===y?void 0:y.getBoundingClientRect(),v=null==h?void 0:h.left,f=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?v:l}px`,width:`${c?f: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?v:l}px`,width:`${c?f: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"})})()),ae?{backgroundColor:G(ye,null==I?void 0:I.getCalendarRegistry()),color:"#fff"}:{backgroundColor:_(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==N?void 0:N.dayIndex)?de(N.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):le&&A(!0),null==T||T(null),W(null)},onDoubleClick:P?void 0:t=>{var n,a;if(!le)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==N?void 0:N.dayIndex)?de(N.dayIndex):de(null!==(n=e.day)&&void 0!==n?n:null);else de(null!==(a=e.day)&&void 0!==a?a:null);ge().then(()=>{A(!0),H||(null==T||T(Y),W({top:-9999,left:-9999,eventHeight:0,eventMiddleY:0,isSunday:!1}),requestAnimationFrame(()=>{me()}))})},onMouseDown:x?t=>{var n;if(N){const a=Object.assign(Object.assign({},e),{day:null!==(n=N.dayIndex)&&void 0!==n?n:e.day,_segmentInfo:N});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;j?j(e.id):A(!0);const n={preventDefault:()=>{},stopPropagation:()=>{},currentTarget:o,touches:[{clientX:a,clientY:r}],cancelable:!1};if(N){const a=Object.assign(Object.assign({},e),{day:null!==(t=N.dayIndex)&&void 0!==t?t:e.day,_segmentInfo:N});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):le&&A(!0),I&&I.onEventClick(e),null==T||T(null),W(null)),te.current=null},children:u?g&&m?fe():e.allDay?g?fe():r.jsx(la,{event:e,isEventSelected:ae}):r.jsx(oa,{event:e,app:I,isEventSelected:ae,hideTime:O}):e.allDay?r.jsx(sa,{event:e,isEditable:!!oe,onResizeStart:b}):r.jsx(ia,{event:e,app:I,multiDaySegmentInfo:N,isEditable:!!oe,isTouchEnabled:!!P,isEventSelected:ae,onResizeStart:b})}),F&&r.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:9998,pointerEvents:"none"}}),(()=>{if(!F)return null;const t=()=>{k&&k(null),de(null),A(!1),null==T||T(null)};if(M){const n=M,l={event:e,isOpen:F,isAllDay:a,onEventUpdate:D,onEventDelete:w,onClose:t,app:I};if("undefined"==typeof window||"undefined"==typeof document)return null;const s=document.body;return s?o.createPortal(r.jsx(n,Object.assign({},l)),s):null}return V?S?r.jsx(ra,{event:e,position:V,panelRef:K,isAllDay:a,eventVisibility:Z,calendarRef:s,selectedEventElementRef:J,onEventUpdate:D,onEventDelete:w,onClose:t,contentRenderer:S}):r.jsx(aa,{event:e,position:V,panelRef:K,isAllDay:a,eventVisibility:Z,calendarRef:s,selectedEventElementRef:J,onEventUpdate:D,onEventDelete:w,onClose:t,app:I}):null})()]})},ca=({app:e,currentDate:n,currentWeekStart:a,events:o,currentDayEvents:l,organizedAllDayEvents:s,allDayAreaHeight:i,timeSlots:d,eventLayouts:c,isToday:u,currentTime:g,selectedEventId:m,setSelectedEventId:h,newlyCreatedEventId:v,setNewlyCreatedEventId:f,detailPanelEventId:p,setDetailPanelEventId:y,dragState:x,isDragging:b,handleMoveStart:D,handleResizeStart:w,handleCreateStart:C,handleCreateAllDayEvent:E,handleTouchStart:k,handleTouchEnd:j,handleTouchMove:T,handleDragOver:S,handleDrop:M,handleEventUpdate:N,handleEventDelete:I,customDetailPanelContent:H,customEventDetailDialog:R,calendarRef:O,allDayRowRef:P,switcherMode:L,isMobile:A,isTouch:$,setDraftEvent:z,setIsDrawerOpen:Y,ALL_DAY_HEIGHT:F,HOUR_HEIGHT:V,FIRST_HOUR:W,LAST_HOUR:B})=>{const{t:Z,locale:U}=Se(),q=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 ${ut} h-full`,children:[r.jsx(Jn,{calendar:e,viewType:exports.ViewType.DAY,currentDate:n,customSubtitle:n.toLocaleDateString(U,{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:Z("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=>{M(e,n,void 0,!0)},children:s.map(t=>r.jsx(da,{event:t,isAllDay:!0,isDayView:!0,segmentIndex:t.row,allDayHeight:F,calendarRef:O,isBeingDragged:b&&(null==x?void 0:x.eventId)===t.id&&"move"===(null==x?void 0:x.mode),hourHeight:V,firstHour:W,onMoveStart:D,onEventUpdate:N,onEventDelete:I,newlyCreatedEventId:v,onDetailPanelOpen:()=>f(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),q.current=null))},onEventLongPress:e=>{(A||$)&&h(e)},customDetailPanelContent:H,customEventDetailDialog:R,app:e,isMobile:A,enableTouch:$},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>B)return null;const n=(t-W)*V;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:_e,children:Q(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:Be,children:r.jsx("div",{className:`${Ze} 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:Ue,onDoubleClick:e=>{var t,r,o,l;const s=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===(l=null===(o=O.current)||void 0===o?void 0:o.querySelector(".calendar-content"))||void 0===l?void 0:l.scrollTop)||0;null==C||C(e,s,W+d/V)},onTouchStart:e=>{const t=Math.floor((n.getTime()-a.getTime())/864e5);k(e,t)},onTouchEnd:j,onTouchMove:T,onDragOver:S,onDrop:e=>{var t,a,r,o;const l=null===(a=null===(t=O.current)||void 0===t?void 0:t.querySelector(".calendar-content"))||void 0===a?void 0:a.getBoundingClientRect();if(!l)return;const s=e.clientY-l.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+s/V);M(e,n,i)},onContextMenu:e=>A&&e.preventDefault()},t)),r.jsx("div",{className:ot,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:l.filter(e=>!e.allDay).map(t=>{const n=c.get(t.id);return r.jsx(da,{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:V,firstHour:W,onMoveStart:D,onResizeStart:w,onEventUpdate:N,onEventDelete:I,newlyCreatedEventId:v,onDetailPanelOpen:()=>f(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),q.current=null))},onEventLongPress:e=>{(A||$)&&h(e)},customDetailPanelContent:H,customEventDetailDialog:R,app:e,isMobile:A,enableTouch:$},t.id)})})]})]})})]})})},ua=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},ga=({app:e,customDetailPanelContent:n,customEventDetailDialog:a,calendarRef:o,switcherMode:l="buttons"})=>{const s=e.getEvents(),{t:i,locale:d}=Se(),{screenSize:c}=un(),u="desktop"!==c,[g,m]=t.useState(!1);t.useEffect(()=>{m("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const h=e.getCustomMobileEventRenderer()||jn,[v,f]=t.useState(null),[p,y]=t.useState(null),[x,b]=t.useState(null),[D,w]=t.useState(null),[C,E]=t.useState(!1),[k,j]=t.useState(null),T=t.useRef(null),S=e.getCurrentDate(),M=e.getVisibleMonth();M.getFullYear(),M.getMonth();const[N,I]=t.useState(S),H=t.useRef(S.getTime());S.getTime()!==H.current&&(H.current=S.getTime(),S.getFullYear()===N.getFullYear()&&S.getMonth()===N.getMonth()||I(S));const R=t.useCallback(t=>{I(n=>{const a=new Date(n.getFullYear(),n.getMonth()+t,1);return e.setVisibleMonth(a),a})},[e]),{HOUR_HEIGHT:P,FIRST_HOUR:L,LAST_HOUR:$,TIME_COLUMN_WIDTH:z,ALL_DAY_HEIGHT:Y}=Fn,F=t.useRef(e.state.highlightedEventId);t.useEffect(()=>{var t;if(e.state.highlightedEventId!==F.current)if(e.state.highlightedEventId){const n=e.getEvents().find(t=>t.id===e.state.highlightedEventId);if(n&&(y(n),!n.allDay)){const e=B(n.start),a=null===(t=o.current)||void 0===t?void 0:t.querySelector(".calendar-content");if(a){const t=(e-L)*P;requestAnimationFrame(()=>{a.scrollTo({top:Math.max(0,t-100),behavior:"smooth"})})}}}else y(null);F.current=e.state.highlightedEventId},[e.state.highlightedEventId,L,P,o,e]);const V=t.useRef(null),W=t.useMemo(()=>ua(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})})})(s,S,W),[s,S,W]),U=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,l=e.end,s=!1;return t<n&&(o=O(n),s=!0),r>a&&(l=O(a),s=!0),Object.assign(Object.assign({},e),{start:s?o:e.start,end:s?l:e.end,day:0})})})(Z,S),[Z,S]),q=t.useMemo(()=>Yn.calculateDayEventLayouts(U,{viewType:"day"}),[U]),_=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]),X=t.useMemo(()=>{if(0===_.length)return Y;return(Math.max(..._.map(e=>e.row))+1)*Y},[_,Y]),{handleMoveStart:G,handleCreateStart:K,handleResizeStart:J,handleCreateAllDayEvent:ee,dragState:te,isDragging:ne}=_n(e,{calendarRef:o,allDayRowRef:V,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)),l=n.filter(e=>!o.has(e.id)),s=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||B(t.start)!==B(e.start)||B(t.end)!==B(e.end)||t.title!==e.title)});r.forEach(t=>e.deleteEvent(t.id)),l.forEach(t=>e.addEvent(t)),s.forEach(t=>e.updateEvent(t.id,t))},onEventCreate:t=>{u?(j(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),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 s=[...r,{id:"-1",title:"Temp",day:0,start:O(o),end:O(l),calendarId:"blue",allDay:!1}];return Yn.calculateDayEventLayouts(s,{viewType:"day"}).get("-1")||null})(0,t,n,S,U),calculateDragLayout:(e,t,n,a)=>((e,t,n,a,r,o)=>{const l=o.filter(t=>t.id!==e.id),s=new Date(r),i=new Date(s);i.setHours(Math.floor(n),n%1*60,0,0);const d=new Date(s);d.setHours(Math.floor(a),a%1*60,0,0);const c=[...l,Object.assign(Object.assign({},e),{start:O(i),end:O(d),day:0})];return 0===c.length?null:Yn.calculateDayEventLayouts(c,{viewType:"day"}).get(e.id)||null})(e,0,n,a,S,U),TIME_COLUMN_WIDTH:u?48:80,isMobile:u}),{handleDrop:ae,handleDragOver:re}=Xn({app:e,onEventCreated:e=>{w(e.id)}}),oe=Array.from({length:24},(e,t)=>({hour:t+L,label:Q(t+L)})),le=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]),se=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(()=>{f(new Date);const e=setInterval(()=>f(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(ca,{app:e,currentDate:S,currentWeekStart:W,events:s,currentDayEvents:Z,organizedAllDayEvents:_,allDayAreaHeight:X,timeSlots:oe,eventLayouts:q,isToday:se,currentTime:v,selectedEventId:p?p.id:null,setSelectedEventId:e=>{if(e){const t=s.find(t=>t.id===e);y(t||null)}else y(null)},newlyCreatedEventId:D,setNewlyCreatedEventId:w,detailPanelEventId:x,setDetailPanelEventId:b,dragState:te,isDragging:ne,handleMoveStart:G,handleResizeStart:J,handleCreateStart:K,handleCreateAllDayEvent:ee,handleTouchStart:(e,t)=>{if(!u&&!g)return;const n=e.touches[0],a=n.clientX,r=n.clientY,l=e.currentTarget;T.current=setTimeout(()=>{var e,n,s;const i=null===(n=null===(e=o.current)||void 0===e?void 0:e.querySelector(".calendar-content"))||void 0===n?void 0:n.getBoundingClientRect();if(!i)return;const d=null===(s=o.current)||void 0===s?void 0:s.querySelector(".calendar-content"),c=d?d.scrollTop:0,u=r-i.top+c;null==K||K({preventDefault:()=>{},stopPropagation:()=>{},touches:[{clientX:a,clientY:r}],changedTouches:[{clientX:a,clientY:r}],target:l,currentTarget:l,cancelable:!0},t,L+u/P)},500)},handleTouchEnd:()=>{T.current&&(clearTimeout(T.current),T.current=null)},handleTouchMove:()=>{T.current&&(clearTimeout(T.current),T.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:V,switcherMode:l,isMobile:u,isTouch:g,setDraftEvent:j,setIsDrawerOpen:E,ALL_DAY_HEIGHT:Y,HOUR_HEIGHT:P,FIRST_HOUR:L,LAST_HOUR:$}),r.jsx(Kn,{app:e,currentDate:S,visibleMonth:N,currentDayEvents:Z,selectedEvent:p,setSelectedEvent:y,handleMonthChange:R,handleDateSelect:le,switcherMode:l}),r.jsx(h,{isOpen:C,onClose:()=>{E(!1),j(null)},onSave:t=>{s.find(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),E(!1),j(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}},ha=({app:e,weekDaysLabels:t,mobileWeekDaysLabels:n,weekDates:a,currentWeekStart:o,timeGridWidth:l,sidebarWidth:s,allDayAreaHeight:i,organizedAllDaySegments:d,allDayLabelText:c,isMobile:u,isTouch:g,calendarRef:m,allDayRowRef:h,topFrozenContentRef:v,ALL_DAY_HEIGHT:f,HOUR_HEIGHT:p,FIRST_HOUR:y,dragState:x,isDragging:b,handleMoveStart:D,handleResizeStart:w,handleEventUpdate:C,handleEventDelete:E,newlyCreatedEventId:k,setNewlyCreatedEventId:j,selectedEventId:T,setSelectedEventId:S,detailPanelEventId:M,setDetailPanelEventId:N,handleCreateAllDayEvent:I,handleDragOver:H,handleDrop:R,customDetailPanelContent:O,customEventDetailDialog:P,events:L,setDraftEvent:A,setIsDrawerOpen:$})=>{const z={flexShrink:0};return r.jsx("div",{className:"flex flex-none border-b border-gray-200 dark:border-gray-700 relative z-10",children:r.jsx("div",{ref:v,className:"flex-1 overflow-hidden relative",children:r.jsxs("div",{className:"flex flex-col min-w-full",children:[r.jsxs("div",{className:"flex w-full",children:[r.jsxs("div",{className:"flex shrink-0",style:{width:l?l+s:"100%"},children:[r.jsx("div",{className:"w-12 md:w-20 shrink-0 sticky left-0 bg-white dark:bg-gray-900 z-20 border-b border-gray-200 dark:border-gray-700"}),r.jsx("div",{className:"df-week-header flex border-b border-gray-200 dark:border-gray-700 flex-1",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 "+(u?"flex-col gap-0":""),style:z,children:u?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:`${Ve} w-7 h-7 text-base font-medium ${a[t].isToday?tt:""}`,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:`${Ve} ${a[t].isToday?tt:""}`,children:a[t].date})]})},t))})]}),r.jsx("div",{className:"flex-1 border-b border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900"})]}),r.jsxs("div",{className:"flex w-full",children:[r.jsxs("div",{className:"flex shrink-0",style:{width:l?l+s:"100%"},children:[r.jsx("div",{className:"w-12 md:w-20 shrink-0 flex items-center justify-end p-1 text-[10px] md:text-xs font-medium text-gray-500 dark:text-gray-400 select-none bg-white dark:bg-gray-900 sticky left-0 z-20 ",children:c}),r.jsx("div",{className:`${Xe} border-none flex-1`,ref:h,style:{minHeight:`${i}px`},children:r.jsxs("div",{className:"df-all-day-content flex flex-1 relative",style:{minHeight:`${i}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 "+(u&&n===t.length-1?"border-r-0":""),style:Object.assign({minHeight:`${i}px`},z),onMouseDown:e=>null==I?void 0:I(e,n),onDoubleClick:e=>null==I?void 0:I(e,n),onDragOver:H,onDrop:e=>{R(e,a,void 0,!0)}},`allday-${n}`)}),r.jsx("div",{className:"absolute inset-0 pointer-events-none",children:d.map(t=>r.jsx(da,{event:t.event,segment:t,segmentIndex:t.row,isAllDay:!0,isMultiDay:!0,allDayHeight:f,calendarRef:m,isBeingDragged:b&&(null==x?void 0:x.eventId)===t.event.id&&"move"===(null==x?void 0:x.mode),hourHeight:p,firstHour:y,onMoveStart:D,onResizeStart:w,onEventUpdate:C,onEventDelete:E,newlyCreatedEventId:k,onDetailPanelOpen:()=>j(null),selectedEventId:T,detailPanelEventId:M,onEventSelect:t=>{const n=!1!==e.getReadOnlyConfig().viewable,a=e.state.readOnly;if((u||g)&&t&&n&&!a){const e=L.find(e=>e.id===t);if(e)return A(e),void $(!0)}S(t)},onEventLongPress:e=>{(u||g)&&S(e)},onDetailPanelToggle:e=>N(e),customDetailPanelContent:O,customEventDetailDialog:P,app:e,isMobile:u,enableTouch:g},t.id))})]})})]}),r.jsx("div",{className:"flex-1 bg-white dark:bg-gray-900"})]})]})})})},va=({app:e,timeSlots:n,weekDaysLabels:a,currentWeekStart:o,currentWeekEvents:l,eventLayouts:s,gridWidth:i,isMobile:d,isTouch:c,scrollerRef:u,timeGridRef:g,leftFrozenContentRef:m,calendarRef:h,handleScroll:v,handleCreateStart:f,handleTouchStart:p,handleTouchEnd:y,handleTouchMove:x,handleDragOver:b,handleDrop:D,dragState:w,isDragging:C,handleMoveStart:E,handleResizeStart:k,handleEventUpdate:j,handleEventDelete:T,newlyCreatedEventId:S,setNewlyCreatedEventId:M,selectedEventId:N,setSelectedEventId:I,detailPanelEventId:H,setDetailPanelEventId:R,customDetailPanelContent:O,customEventDetailDialog:P,events:L,setDraftEvent:A,setIsDrawerOpen:$,isCurrentWeek:z,currentTime:Y,HOUR_HEIGHT:F,FIRST_HOUR:V,LAST_HOUR:W})=>{const B={flexShrink:0},Z=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:Be,children:r.jsx("div",{className:`${Ze} text-[10px] md:text-[12px]`,children:0===t?"":e.label})},t)),r.jsx("div",{className:"relative",children:r.jsx("div",{className:`${Ze} text-[10px] md:text-[12px]`,children:"00:00"})}),z&&Y&&(()=>{const e=Y,t=e.getHours()+e.getMinutes()/60;if(t<V||t>W)return null;const n=(t-V)*F;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:_e,children:Q(t)})})})()]})}),r.jsx("div",{ref:u,className:"flex-1 overflow-auto relative calendar-content snap-x snap-mandatory",onScroll:v,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<V||t>W)return null;const n=e.getDay(),o=0===n?6:n-1,l=(t-V)*F;return r.jsxs("div",{className:qe,style:{top:`${l}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:Ue,children:a.map((n,l)=>{const s=new Date(o);return s.setDate(o.getDate()+l),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&&l===a.length-1?"border-r-0":""),style:B,onDoubleClick:t=>{null==f||f(t,l,e.hour)},onTouchStart:t=>p(t,l,e.hour),onTouchEnd:y,onTouchMove:x,onDragOver:b,onDrop:t=>{D(t,s,e.hour)},onContextMenu:e=>d&&e.preventDefault()},`${t}-${l}`)})},t)),r.jsx("div",{className:`${ot} 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:B},`24-${t}`))}),a.map((t,n)=>{const a=ue(n,l),i=[];return a.forEach(e=>{const t=ta(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})}),l.forEach(e=>{if(e.allDay||e.day===n)return;const t=ta(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=s.get(n),l=null==o?void 0:o.get(t.id);return r.jsx(da,{event:t,layout:l,calendarRef:h,isBeingDragged:C&&(null==w?void 0:w.eventId)===t.id&&"move"===(null==w?void 0:w.mode),hourHeight:F,firstHour:V,onMoveStart:E,onResizeStart:k,onEventUpdate:j,onEventDelete:T,newlyCreatedEventId:S,onDetailPanelOpen:()=>M(null),selectedEventId:N,detailPanelEventId:H,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 A(e),void $(!0)}I(t),e.state.highlightedEventId&&(e.highlightEvent(null),Z.current=null)},onEventLongPress:e=>{(d||c)&&I(e)},onDetailPanelToggle:e=>R(e),customDetailPanelContent:O,customEventDetailDialog:P,multiDaySegmentInfo:a,app:e,isMobile:d,enableTouch:c},a?`${t.id}-seg-${n}`:t.id)})},`events-day-${n}`)})]})]})})]})},fa=({app:e,customDetailPanelContent:n,customEventDetailDialog:a,calendarRef:o})=>{const{t:l,getWeekDaysLabels:s,locale:i}=Se(),d=e.getCurrentDate(),c=e.getEvents(),{screenSize:u}=un(),g="desktop"!==u,m="mobile"===u?48:80,[h,v]=t.useState(0),f=t.useRef(null),[p,y]=t.useState(!1);t.useEffect(()=>{y("ontouchstart"in window||navigator.maxTouchPoints>0)},[]),t.useLayoutEffect(()=>{const e=f.current;if(!e)return;const t=()=>{v(e.offsetWidth)};t();const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);const x=e.getCustomMobileEventRenderer()||jn,b=t.useMemo(()=>ua(d),[d]),[D,w]=t.useState(null),[C,E]=t.useState(null),[k,j]=t.useState(null),[T,S]=t.useState(null),[M,N]=t.useState(!1),[I,H]=t.useState(null),R=t.useRef(null),{HOUR_HEIGHT:P,FIRST_HOUR:L,LAST_HOUR:$,TIME_COLUMN_WIDTH:z,ALL_DAY_HEIGHT:Y}=Fn,F=t.useRef(null),V=t.useRef(null),W=t.useRef(null),U=t.useRef(null),q=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,b),[c,b]),_=t.useRef(e.state.highlightedEventId);t.useEffect(()=>{if(e.state.highlightedEventId!==_.current)if(e.state.highlightedEventId){j(e.state.highlightedEventId);const t=q.find(t=>t.id===e.state.highlightedEventId);if(t&&!t.allDay){const e=B(t.start),n=V.current;if(n){const t=(e-L)*P;requestAnimationFrame(()=>{n.scrollTo({top:Math.max(0,t-100),behavior:"smooth"})})}}}else j(null);_.current=e.state.highlightedEventId},[e.state.highlightedEventId,q,L,P]);const X=t.useMemo(()=>((e,t)=>{const n=ea(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})(q,b),[q,b]),G=t.useMemo(()=>{if(0===X.length)return Y;const e=Math.max(...X.map(e=>e.row));return Y+e*Y},[X,Y]),K=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=ta(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:O(Z(ge(t,a),o.startHour)),end:O(Z(ge(t,a),n)),day:a});r.push(l)}}else e.day===a&&r.push(e)});const o=Yn.calculateDayEventLayouts(r,{viewType:"week"});n.set(a,o)}return n})(q,b),[q,b]),{handleMoveStart:J,handleCreateStart:ee,handleResizeStart:te,handleCreateAllDayEvent:ne,dragState:ae,isDragging:re}=_n(e,{calendarRef:o,allDayRowRef:F,viewType:exports.ViewType.WEEK,onEventsUpdate:(t,n)=>{const a=t(q),r=new Set(a.map(e=>e.id)),o=q.filter(e=>!r.has(e.id)),l=new Set(q.map(e=>e.id)),s=a.filter(e=>!l.has(e.id)),i=a.filter(e=>{if(!l.has(e.id))return!1;const t=q.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||B(t.start)!==B(e.start)||B(t.end)!==B(e.end)||t.title!==e.title)});o.forEach(t=>e.deleteEvent(t.id)),s.forEach(t=>e.addEvent(t)),i.forEach(t=>e.updateEvent(t.id,t,n))},onEventCreate:t=>{g?(H(t),N(!0)):(e.addEvent(t),S(t.id))},onEventEdit:()=>{},currentWeekStart:b,events:q,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:O(r),end:O(o),calendarId:"blue",allDay:!1},s=[...a.filter(t=>t.day===e&&!t.allDay),l];return Yn.calculateDayEventLayouts(s,{viewType:"week"}).get("-1")||null})(e,t,n,q),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),l=Z(o,n),s=Z(o,a),i=O(l),d=O(s);return Object.assign(Object.assign({},r),{day:t,start:i,end:d})}).filter(e=>e.day===t&&!e.allDay);return 0===o.length?null:Yn.calculateDayEventLayouts(o,{viewType:"week"}).get(e.id)||null})(e,t,n,a,q),TIME_COLUMN_WIDTH:m,isMobile:g}),{handleDrop:oe,handleDragOver:le}=Xn({app:e,onEventCreated:e=>{S(e.id)}}),se=t.useMemo(()=>s(i,"short"),[i,s]),ie=t.useMemo(()=>{if(!g)return[];const e=i.split("-")[0].toLowerCase();return"zh"===e||"ja"===e?s(i,"narrow"):se.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,s,se]),de=t.useMemo(()=>l("allDay"),[l]),ce=Array.from({length:24},(e,t)=>({hour:t+L,label:Q(t+L)})),ue=t.useMemo(()=>{const e=new Date;return e.setHours(0,0,0,0),se.map((t,n)=>{const a=new Date(b);a.setDate(b.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()}})},[b,se,i]),me=t=>{e.updateEvent(t.id,t)},he=t=>{e.deleteEvent(t)},ve=t.useMemo(()=>{const e=new Date,t=ua(e);return b.getTime()===t.getTime()},[b]);t.useEffect(()=>{w(new Date);const e=setInterval(()=>w(new Date),6e4);return()=>clearInterval(e)},[]);const fe=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(Jn,{calendar:e,viewType:exports.ViewType.WEEK,currentDate:d,onPrevious:()=>e.goToPrevious(),onNext:()=>e.goToNext(),onToday:()=>e.goToToday()}),r.jsx(ha,{app:e,weekDaysLabels:se,mobileWeekDaysLabels:ie,weekDates:ue,currentWeekStart:b,timeGridWidth:h,sidebarWidth:m,allDayAreaHeight:G,organizedAllDaySegments:X,allDayLabelText:de,isMobile:g,isTouch:p,calendarRef:o,allDayRowRef:F,topFrozenContentRef:W,ALL_DAY_HEIGHT:Y,HOUR_HEIGHT:P,FIRST_HOUR:L,dragState:ae,isDragging:re,handleMoveStart:J,handleResizeStart:te,handleEventUpdate:me,handleEventDelete:he,newlyCreatedEventId:T,setNewlyCreatedEventId:S,selectedEventId:k,setSelectedEventId:j,detailPanelEventId:C,setDetailPanelEventId:E,handleCreateAllDayEvent:ne,handleDragOver:le,handleDrop:oe,customDetailPanelContent:n,customEventDetailDialog:a,events:c,setDraftEvent:H,setIsDrawerOpen:N}),r.jsx(va,{app:e,timeSlots:ce,weekDaysLabels:se,currentWeekStart:b,currentWeekEvents:q,eventLayouts:K,gridWidth:fe,isMobile:g,isTouch:p,scrollerRef:V,timeGridRef:f,leftFrozenContentRef:U,calendarRef:o,handleScroll:e=>{const{scrollTop:t,scrollLeft:n}=e.currentTarget;W.current&&(W.current.scrollLeft=n),U.current&&(U.current.style.transform=`translateY(${-t}px)`)},handleCreateStart:ee,handleTouchStart:(e,t,n)=>{if(!g&&!p)return;const a=e.touches[0],r=a.clientX,o=a.clientY,l=e.currentTarget;R.current=setTimeout(()=>{null==ee||ee({preventDefault:()=>{},stopPropagation:()=>{},touches:[{clientX:r,clientY:o}],changedTouches:[{clientX:r,clientY:o}],target:l,currentTarget:l,cancelable:!0},t,n)},500)},handleTouchEnd:()=>{R.current&&(clearTimeout(R.current),R.current=null)},handleTouchMove:()=>{R.current&&(clearTimeout(R.current),R.current=null)},handleDragOver:le,handleDrop:oe,dragState:ae,isDragging:re,handleMoveStart:J,handleResizeStart:te,handleEventUpdate:me,handleEventDelete:he,newlyCreatedEventId:T,setNewlyCreatedEventId:S,selectedEventId:k,setSelectedEventId:j,detailPanelEventId:C,setDetailPanelEventId:E,customDetailPanelContent:n,customEventDetailDialog:a,events:c,setDraftEvent:H,setIsDrawerOpen:N,isCurrentWeek:ve,currentTime:D,HOUR_HEIGHT:P,FIRST_HOUR:L,LAST_HOUR:$}),r.jsx(x,{isOpen:M,onClose:()=>{N(!1),H(null)},onSave:t=>{c.find(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),N(!1),H(null)},draftEvent:I,app:e})]})},pa={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}},ya=t.memo(({currentMonth:e,currentYear:a,newlyCreatedEventId:o,screenSize:l,isScrolling:s,isDragging:i,item:d,weekHeight:c,events:u,dragState:g,calendarRef:m,onEventUpdate:h,onEventDelete:v,onMoveStart:f,onCreateStart:p,onResizeStart:y,onDetailPanelOpen:x,onMoreEventsClick:b,onChangeView:w,onSelectDate:C,selectedEventId:E,onEventSelect:k,onEventLongPress:j,detailPanelEventId:T,onDetailPanelToggle:S,customDetailPanelContent:M,customEventDetailDialog:N,onCalendarDrop:I,onCalendarDragOver:H,app:R,enableTouch:O})=>{const{t:P,locale:L}=Se(),[$,z]=t.useState(!1),Y=t.useRef(null),F=t.useRef(null),V=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(()=>s?(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,[s,$]);const{weekData:Z}=d,U=Z.days.find(e=>1===e.day),q=`${c}px`,_=t.useMemo(()=>ea(u,Z.startDate),[u,Z.startDate]),X=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 D.warn("Event missing start or end date:",e);const o=A(e.start),l=A(e.end),s=new Date(o);s.setHours(0,0,0,0);const i=new Date(l);i.setHours(0,0,0,0);let d=new Date(i);if(!e.allDay&&0===l.getHours()&&0===l.getMinutes()&&0===l.getSeconds()){const e=l.getTime()-o.getTime();e>0&&e<864e5&&(d=new Date(i),d.setDate(d.getDate()-1))}const c=s.toDateString()!==d.toDateString();if(!c||e.allDay)if(c&&e.allDay){let s=new Date(o);s<t&&(s=new Date(t),s.setHours(0,0,0,0));const i=l>r?r:l;for(;s<=i;){const t=n.Temporal.PlainDate.from({year:s.getFullYear(),month:s.getMonth()+1,day:s.getDate()});a.push(Object.assign(Object.assign({},e),{start:t,end:t,day:s.getDay()})),s.setDate(s.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]),G=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})(_),[_]),K=t.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]),J=t.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]),Q=t.useMemo(()=>{const e=G.flat();for(let t=0;t<Z.days.length;t++){const n=Z.days[t],a=X.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 l=0;for(let e=0;e<=o;e++)r.has(e)||l++;if(o+1+Math.max(0,a.length-l)>W.maxSlots)return W.maxSlotsWithMore}return W.maxSlots},[Z.days,X,G,K,J,W.maxSlots,W.maxSlotsWithMore]),ee=t.useMemo(()=>Math.max(0,17*G.length),[G]),te=(t,n)=>{var s;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:B(e.start)-B(t.start)))((c=t.date,X.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()}))),D=G.flat(),$=u.filter(e=>{if(!e.allDay)return!0;return!D.some(t=>t.originalEventId===e.id)}),z=J[n],Y=(null!==(s=K[n])&&void 0!==s?s:0)-1,Z=[];for(let e=0;e<=Y;e++)z.has(e)||Z.push(e);const U=$.length,_=Math.max(0,U-Z.length),Q=Math.max(Y+1,0)+_,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(U,ne+ae),oe=$.slice(0,re),le=U-re,se=[];let ie=0;const de=Math.min(te,Q);for(let e=0;e<de;e++)if(z.has(e))se.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];se.push(r.jsx(da,{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:v,onMoveStart:f,onResizeStart:y,onDetailPanelOpen:x,onEventSelect:k,onEventLongPress:j,newlyCreatedEventId:o,selectedEventId:E,detailPanelEventId:T,onDetailPanelToggle:S,customDetailPanelContent:M,customEventDetailDialog:N,app:R,isMobile:"desktop"!==l,enableTouch:O},`${e.id}-${e.day}-${B(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:q},"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"!==l&&!O)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:H,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"===l?t.date.toLocaleDateString(L,{month:"short",day:"numeric"}):t.day})})]}),r.jsxs("div",{className:"flex-1 overflow-hidden px-1",children:[se,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==w||w(exports.ViewType.DAY))},children:["+",le," ",r.jsx("span",{className:"hidden md:inline",children:P("more")})]})]})]},`day-${t.date.getTime()}`);var ce},ne=t.useMemo(()=>U?U.date.toLocaleDateString(L,{month:"long",year:"numeric"}):"",[U,L]);return r.jsxs("div",{className:"relative select-none border-b border-gray-200 dark:border-gray-700",style:{height:q},children:[U&&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))}),G.length>0&&r.jsx("div",{className:"absolute left-0 right-0 pointer-events-none",style:{top:"33px",height:`${ee}px`,zIndex:10},children:G.slice(0,Q).map((e,t)=>r.jsx("div",{className:"absolute inset-0",children:e.map(e=>r.jsx(da,{event:e.event,isAllDay:!!e.event.allDay,segment:e,segmentIndex:t,isMonthView:!0,isMultiDay:!0,calendarRef:m,hourHeight:72,firstHour:0,onEventUpdate:h,onEventDelete:v,onMoveStart:f,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:j,detailPanelEventId:T,onDetailPanelToggle:S,customDetailPanelContent:M,customEventDetailDialog:N,app:R,isMobile:"desktop"!==l,enableTouch:O},e.id))},`layer-${t}`))})]})})]})});ya.displayName="WeekComponent";const xa=({app:e,customDetailPanelContent:n,customEventDetailDialog:a,calendarRef:o})=>{const{getWeekDaysLabels:l,getMonthLabels:s,locale:i}=Se(),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 l=new Date(r);l.setHours(0,0,0,0);let s=new Date(l);if(!e.allDay){0!==r.getHours()||0!==r.getMinutes()||0!==r.getSeconds()||0!==r.getMilliseconds()||s.setDate(s.getDate()-1)}s<o&&(s=new Date(o));const i=t(o),d=t(s);let c=i.getTime();const u=d.getTime();for(;c<=u;){n(c,e);const t=new Date(c);t.setDate(t.getDate()+7),t.setHours(0,0,0,0),c=t.getTime()}}),e},[m]),{screenSize:v}=un(),[f,p]=t.useState(!1);t.useEffect(()=>{p("ontouchstart"in window||navigator.maxTouchPoints>0)},[]);const y=e.getCustomMobileEventRenderer()||jn,[x,b]=t.useState(119),[D,w]=t.useState(!1),C=t.useRef(x),E=t.useRef([]),[k,j]=t.useState(null),[T,S]=t.useState(!1),[M,N]=t.useState(null),[I,H]=t.useState(null),R=t.useRef(e.state.highlightedEventId);t.useEffect(()=>{e.state.highlightedEventId?H(e.state.highlightedEventId):R.current&&H(null),R.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:F,isDragging:V}=_n(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)),l=new Set(m.map(e=>e.id)),s=a.filter(e=>!l.has(e.id)),i=a.filter(e=>{if(!l.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||B(t.start)!==B(e.start)||B(t.end)!==B(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)),s.forEach(t=>e.addEvent(t)),i.forEach(t=>e.updateEvent(t.id,t,n))},onEventCreate:t=>{"desktop"!==v?(N(t),S(!0)):e.addEvent(t)},onEventEdit:e=>{j(e.id)},currentWeekStart:L,events:m}),{handleDrop:W,handleDragOver:Z}=Xn({app:e,onEventCreated:e=>{j(e.id)}}),U=t.useMemo(()=>l(i,"short"),[i,l]),{currentMonth:q,currentYear:_,isScrolling:X,virtualData:G,scrollElementRef:K,handleScroll:J,handlePreviousMonth:Q,handleNextMonth:ee,handleToday:te,setScrollTop:ne}=gn({currentDate:d,weekHeight:x,onCurrentMonthChange:(t,n)=>{const a=i.startsWith("zh")||i.startsWith("ja"),r=s(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),le=t.useMemo(()=>re-6*x,[re,x]),{visibleWeeks:se,startIndex:ie}=t.useMemo(()=>{const{visibleItems:e,displayStartIndex:t}=G,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}},[G]),de=t.useMemo(()=>ie*x,[ie,x]),ce=t.useMemo(()=>{const e=G.totalHeight,t=ie*x+16*x+le;return Math.max(0,e-t)},[G.totalHeight,ie,x,le]);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:$e,children:[r.jsx(Jn,{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:U.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:We,style:{scrollSnapType:"y mandatory",overflow:"hidden auto",visibility:D?"visible":"hidden"},onScroll:J,children:[r.jsx("div",{style:{height:de}}),se.map((t,l)=>{var s;const i=null!==(s=h.get(t.weekData.startDate.getTime()))&&void 0!==s?s:[],d=5===l?Object.assign(Object.assign({},t),{height:t.height+le}):t;return r.jsx(ya,{item:d,weekHeight:x,currentMonth:q,currentYear:_,screenSize:v,isScrolling:X,calendarRef:o,events:i,onEventUpdate:ue,onEventDelete:ge,onMoveStart:$,onCreateStart:z,onResizeStart:Y,isDragging:V,dragState:F,newlyCreatedEventId:k,onDetailPanelOpen:()=>j(null),onMoreEventsClick:e.onMoreEventsClick,onChangeView:me,onSelectDate:e.selectDate,selectedEventId:I,onEventSelect:t=>{const n=!1!==e.getReadOnlyConfig().viewable;if(("desktop"!==v||f)&&t&&n){const e=m.find(e=>e.id===t);if(e)return N(e),void S(!0)}H(t)},onEventLongPress:e=>{("desktop"!==v||f)&&H(e)},detailPanelEventId:O,onDetailPanelToggle:P,customDetailPanelContent:n,customEventDetailDialog:a,onCalendarDrop:W,onCalendarDragOver:Z,calendarSignature:u,app:e,enableTouch:f},`week-${t.weekData.startDate.getTime()}`)}),r.jsx("div",{style:{height:ce}})]}),r.jsx(y,{isOpen:T,onClose:()=>{S(!1),N(null)},onSave:t=>{m.find(e=>e.id===t.id)?e.updateEvent(t.id,t):e.addEvent(t),S(!1),N(null)},draftEvent:M,app:e})]})},ba={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 Da=t.memo(({date:e,isToday:t,locale:n,onSelectDate:a,onCreateStart:o,onMoreEventsClick:l,moreCount:s=0})=>{const{t:i}=Se(),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})]}),s>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==l||l(e)},children:["+",s," ",i("more")]})})]})});Da.displayName="YearDayCell";const wa=({segment:e,columnsPerRow:n,isDragging:a,isSelected:l,onMoveStart:s,onResizeStart:i,onEventSelect:d,detailPanelEventId:c,onDetailPanelToggle:u,newlyCreatedEventId:g,onDetailPanelOpen:m,customDetailPanelContent:h,customEventDetailDialog:v,app:f,calendarRef:p})=>{const{event:y,startCellIndex:x,endCellIndex:b,visualRowIndex:D,isFirstSegment:w,isLastSegment:C}=e,E=t.useRef(null),k=t.useRef(null),[j,T]=t.useState(null),S=c===e.id,M=!(null==f?void 0:f.state.readOnly),N=x/n*100,I=(b-x+1)/n*100,H=y.calendarId||"blue",R=l?G(H):_(H),O=l?"#fff":X(H),P=K(H),L=!!y.allDay,A=L?Qn(y):null,$=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),T({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&&M?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},F=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(${N}% + 2px)`,top:`${$}px`,height:"16px",backgroundColor:R,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":F,"data-event-id":y.id,onMouseDown:e=>{e.stopPropagation(),s&&s(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),s&&s(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&&Qn(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:K(H),width:"12px",height:"12px"},children:Qn(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&&A&&r.jsx("div",{className:"df-year-event-icon shrink-0 flex items-center justify-center opacity-80 scale-75",children:A}),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(v){const t=v,n={event:y,isOpen:S,isAllDay:L,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(r.jsx(t,Object.assign({},n)),a):null}return j?h?r.jsx(ra,{event:y,position:j,panelRef:k,isAllDay:L,onClose:e,contentRenderer:h,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}):r.jsx(aa,{event:y,position:j,panelRef:k,isAllDay:L,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})()]})},Ca=t.memo(({rowDays:e,events:n,columnsPerRow:a,app:o,calendarRef:l,locale:s,isDragging:i,dragState:d,onMoveStart:c,onResizeStart:u,onCreateStart:g,selectedEventId:m,onEventSelect:h,onMoreEventsClick:v,newlyCreatedEventId:f,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(),l=new Date(r.getFullYear(),r.getMonth(),r.getDate(),23,59,59,999).getTime(),s=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>=o});s.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,l=(t.end?A(t.end).getTime():r)-r;return o!==l?l-o:n-r});const i=[],d=[];return s.forEach(e=>{const r=A(e.start),s=e.end?A(e.end):r,c=new Date(r.getFullYear(),r.getMonth(),r.getDate()).getTime(),u=new Date(s.getFullYear(),s.getMonth(),s.getDate()).getTime();let g=-1,m=-1;const h=Math.round((c-o)/864e5);g=h>=0?h:0;const v=Math.round((u-o)/864e5);m=v<t.length?v:t.length-1,g=Math.max(0,Math.min(g,n-1)),m=Math.max(0,Math.min(m,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<=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:f,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 l=Math.max(0,r.startCellIndex),s=Math.min(e.length-1,r.endCellIndex);for(let e=l;e<=s;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<=s;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(Da,{date:e,isToday:n,locale:s,onSelectDate:e=>{o.selectDate(e)},onCreateStart:g,onMoreEventsClick:v,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(wa,{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:f,onDetailPanelOpen:p,calendarRef:l,app:o,detailPanelEventId:y,customDetailPanelContent:b,customEventDetailDialog:D})},e.id))})})]})});Ca.displayName="YearRowComponent";const Ea=({app:e,calendarRef:a,customDetailPanelContent:o,customEventDetailDialog:l,config:s})=>{var i;const{locale:d}=Se(),c=e.getCurrentDate(),u=c.getFullYear(),g=e.getEvents(),m=t.useRef(null),[h,v]=t.useState(()=>"undefined"!=typeof window?Math.max(1,Math.floor(window.innerWidth/80)):7),[f,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);v(Math.max(1,n)),p(!0)});return t.observe(e),()=>t.disconnect()},[]);const{handleMoveStart:E,handleResizeStart:k,handleCreateStart:j,dragState:T,isDragging:S}=_n(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)}}),M=null!==(i=null==s?void 0:s.showTimedEventsInYearView)&&void 0!==i&&i,N=t.useCallback((t,a)=>{if(M)null==j||j(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)}},[M,j,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]),H=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]),R=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(!M&&!n.allDay)return!1;const a=A(n.start),r=n.end?A(n.end):a;return a<=t&&r>=e})},[g,u,M]);return r.jsxs("div",{className:$e,children:[r.jsx(Jn,{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:`${We}`,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:f?1:0,transition:"opacity 0.2s ease"},children:H.map((t,n)=>r.jsx(Ca,{rowDays:t,events:R,columnsPerRow:h,app:e,calendarRef:a,locale:d,isDragging:S,dragState:T,onMoveStart:E,onResizeStart:k,onCreateStart:N,selectedEventId:y,onEventSelect:x,onMoreEventsClick:e.onMoreEventsClick,newlyCreatedEventId:w,onDetailPanelOpen:()=>C(null),detailPanelEventId:b,onDetailPanelToggle:D,customDetailPanelContent:o,customEventDetailDialog:l},n))})})]})};function ka(e,t,n){const a=new Date(n,t,1),r=new Date(n,t+1,0).getDate(),o=a.getDay(),l=a.getTime(),s=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<=s&&r>=l});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,l=(t.end?A(t.end).getTime():r)-r;return o!==l?l-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(),l)),u=new Date(Math.min(r.getTime(),s)),g=i.getDate(),m=u.getDate(),h=o+(g-1),v=o+(m-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=h;t<=v;t++)if(c[y][t]){e=!0;break}if(!e){for(let e=h;e<=v;e++)c[y][e]=!0;break}y++}d.push({id:`${e.id}_month_${t}`,event:e,startCellIndex:h,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 ja=({app:e,calendarRef:a,customDetailPanelContent:o,customEventDetailDialog:l,config:s})=>{var i;const{locale:d,getWeekDaysLabels:c}=Se(),u=e.getCurrentDate(),g=u.getFullYear(),m=e.getEvents(),h=new Date;h.setHours(0,0,0,0);const v=t.useRef(null),f=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),[j,T]=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:M,handleResizeStart:N,handleCreateStart:I,dragState:H,isDragging:R}=_n(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=>{T(e.id)}}),O=null!==(i=null==s?void 0:s.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),T(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 l=n.toLocaleDateString(d,{month:"short"}),s=l.charAt(0).toUpperCase()+l.slice(1).toLowerCase(),{segments:i,maxVisualRow:c}=ka($,t,g),u=c+1,m=Math.max(60,20+18*u);e.push({monthIndex:t,monthName:s,days:o,eventSegments:i,minHeight:m})}return e},[g,d,S,$]),Y=t.useCallback(e=>{const t=e.currentTarget;v.current&&(v.current.scrollLeft=t.scrollLeft),f.current&&(f.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(Jn,{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:v,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:f,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 l=(e=>e.getTime()===h.getTime())(t),s=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`;return r.jsx("div",{"data-date":s,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 ${l?"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(wa,{segment:t,columnsPerRow:S,isDragging:R&&H.eventId===t.event.id,isSelected:w===t.event.id,onMoveStart:M,onResizeStart:N,onEventSelect:C,onDetailPanelToggle:k,newlyCreatedEventId:j,onDetailPanelOpen:()=>T(null),calendarRef:a,app:e,detailPanelEventId:E,customDetailPanelContent:o,customEventDetailDialog:l})},t.id))})})]},t.monthIndex))})})]})},Ta=e=>{var t;return"fixed-week"===((null===(t=e.config)||void 0===t?void 0:t.mode)||"year-canvas")?r.jsx(ja,Object.assign({},e,{config:e.config})):r.jsx(Ea,Object.assign({},e,{config:e.config}))},Sa={enableDrag:!1,enableResize:!1,enableCreate:!1,enableVirtualScroll:!0,showDebugInfo:!1,eventsConfig:{enableAutoRecalculate:!1,enableValidation:!0},viewConfig:{enableVirtualScroll:!0,showDebugInfo:!1}},Ma={enableAutoRecalculate:!0,enableValidation:!0,defaultEvents:[],maxEventsPerDay:50};exports.CalendarApp=De,exports.CalendarEvent=da,exports.CalendarRegistry=p,exports.ColorPicker=yt,exports.DayFlowCalendar=e=>{const{calendar:t,customMessages:n}=e,a=t.app;return r.jsx(Mn,{locale:a.state.locale,messages:n,children:r.jsx(Nn,Object.assign({},e))})},exports.DefaultEventDetailDialog=Lt,exports.DefaultEventDetailPanel=aa,exports.EventDetailPanelWithContent=ra,exports.EventLayoutCalculator=Yn,exports.LOCALES=N,exports.LocaleContext=Te,exports.TIME_STEP=J,exports.ThemeProvider=vn,exports.ViewHeader=Jn,exports.addDays=W,exports.buildParseRegExp=Ct,exports.calculateDayIndex=he,exports.capitalize=Ce,exports.conditionalTheme=(e,t,n)=>e?t:n,exports.convertDateEvent=function(e,t,n,a,r=!1,o){return an(Object.assign({id:e,title:t,start:n,end:a,allDay:r},o))},exports.convertDateEventWithTimeZone=function(e,t,n,a,r,o){return rn(Object.assign({id:e,title:t,start:n,end:a,timeZone:r},o))},exports.createAllDayEvent=function(e,t,n,a){return an(Object.assign({id:e,title:t,start:n,end:n,allDay:!0},a))},exports.createDateWithHour=Z,exports.createDayView=(e={})=>{const n=Object.assign(Object.assign({},ma),e),a=e=>t.createElement(In,{viewType:exports.ViewType.DAY,originalComponent:ga,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:()=>{D.log("Drag plugin installed - providing drag capabilities")},api:n}},exports.createEvent=an,exports.createEventWithDate=(e,t)=>{var n,a;const r=ge(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:me(r,o),end:me(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:me(r,o),end:me(r,o)})},exports.createEvents=function(e){return e.map(e=>an(e))},exports.createEventsPlugin=function(e={}){const t=Object.assign(Object.assign({},Ma),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 l=a.getById(e);if(!l)throw new Error(`Event with id ${e} not found`);const s=Object.assign(Object.assign({},l),o);if(t.enableValidation){const e=a.validateEvent(s);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,D.log("Events plugin installed - providing event management services")},api:a}},exports.createMonthView=(e={})=>{const n=Object.assign(Object.assign({},ba),e),a=e=>t.createElement(In,{viewType:exports.ViewType.MONTH,originalComponent:xa,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=$,exports.createTimedEvent=function(e,t,n,a,r){return an(Object.assign({id:e,title:t,start:n,end:a},r))},exports.createTimezoneEvent=rn,exports.createTimezoneEvents=function(e){return e.map(e=>rn(e))},exports.createWeekView=(e={})=>{const n=Object.assign(Object.assign({},pa),e),a=e=>t.createElement(In,{viewType:exports.ViewType.WEEK,originalComponent:fa,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({},Sa),e);e.mode&&(n.viewConfig=Object.assign(Object.assign({},n.viewConfig),{mode:e.mode}));const a=e=>t.createElement(In,{viewType:exports.ViewType.YEAR,originalComponent:Ta,app:e.app,config:n,className:"year-view-factory",customDetailPanelContent:e.customDetailPanelContent,customEventDetailDialog:e.customEventDetailDialog,calendarRef:e.calendarRef,meta:e.meta});return a.displayName="YearViewAdapter",{type:exports.ViewType.YEAR,component:a,config:n}},exports.dateToPlainDate=Kt,exports.dateToPlainDateTime=Jt,exports.dateToZonedDateTime=Qt,exports.daysBetween=function(e,t){const n=R(e)?e:e.toPlainDate(),a=R(t)?t:t.toPlainDate();return n.until(a).days},exports.daysDifference=V,exports.de=S,exports.en=C,exports.es=M,exports.extractHourFromDate=B,exports.extractHourFromTemporal=function(e){return _t(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=qt,exports.formatEventTimeRange=ee,exports.formatMonthYear=e=>`${["January","February","March","April","May","June","July","August","September","October","November","December"][e.getMonth()]} ${e.getFullYear()}`,exports.formatTemporal=Tt,exports.formatTime=Q,exports.fr=T,exports.generateDayData=se,exports.generateUniKey=pe,exports.generateWeekData=ie,exports.generateWeekRange=ce,exports.generateWeeksData=(e,t=3)=>{const n=5*t,{monday:a}=le(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(ie(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 ae.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=ge,exports.getDateObj=on,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=U,exports.getEndOfTemporal=F,exports.getEventBgColor=_,exports.getEventEndHour=ne,exports.getEventTextColor=X,exports.getEventsForDay=ue,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=he(A(e.start),t);return Object.assign(Object.assign({},e),{day:n})})},exports.getIntlLabel=we,exports.getLineColor=K,exports.getMonthLabels=ke,exports.getMonthYearOfWeek=de,exports.getPlainDate=function(e){return _t(e)?e:(Xt(e),e.toPlainDate())},exports.getSearchHeaderInfo=sn,exports.getSelectedBgColor=G,exports.getStartOfDay=e=>{if(e instanceof Date){const t=new Date(e);return t.setHours(0,0,0,0),t}return Y(e)},exports.getStartOfTemporal=Y,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)),l=Math.floor(e.endHour),s=Math.round(60*(e.endHour-l));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:l,minute:s,timeZone:n.Temporal.Now.timeZoneId()}),allDay:!1,calendarId:e.calendarId,day:e.day}})},exports.getWeekDaysLabels=Ee,exports.getWeekRange=le,exports.getZoneId=kt,exports.groupSearchResults=dn,exports.isDate=function(e){return e instanceof Date},exports.isDeepEqual=ye,exports.isEventEqual=fe,exports.isEventInWeek=(e,t)=>{const n=he(e,t);return n>=0&&n<=6},exports.isMultiDayEvent=(e,t)=>!q(e,t),exports.isMultiDayTemporalEvent=function(e,t){return!z(e,t)},exports.isPlainDate=_t,exports.isPlainDateTime=Xt,exports.isSameDay=q,exports.isSamePlainDate=z,exports.isSameTemporal=function(e,t){const n=_t(e)?e:(Xt(e),e.toPlainDate()),a=_t(t)?t:(Xt(t),t.toPlainDate());return n.equals(a)},exports.isValidLocale=H,exports.isZonedDateTime=Gt,exports.ja=k,exports.ko=j,exports.mergeClasses=(...e)=>e.filter(Boolean).join(" "),exports.mergeFormatTemplate=Dt,exports.monthNames=re,exports.normalizeCssWidth=w,exports.normalizeDate=ln,exports.normalizeLocale=I,exports.normalizeToZoned=jt,exports.now=function(e=n.Temporal.Now.timeZoneId()){return n.Temporal.Now.zonedDateTimeISO(e)},exports.pad=bt,exports.parseTemporalString=Et,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=en,exports.roundToTimeStep=te,exports.setHourInTemporal=function(e,t){const n=Math.floor(t),a=Math.round(60*(t-n));return Gt(e),e.with({hour:n,minute:a,second:0,millisecond:0})},exports.shortMonthNames=oe,exports.t=je,exports.temporalToDate=function(e){if(_t(e))return new Date(e.year,e.month-1,e.day);if(Xt(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=ge(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:me(r,o),end:me(r,o)})},exports.useCalendarApp=function(e){const n=t.useMemo(()=>new De(e),[]),[a,r]=t.useState(n.state.currentView),[o,l]=t.useState(n.state.currentDate),[s,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),l(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 s=n.deleteEvent;n.deleteEvent=e=>{s(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 v=n.updateCalendar;n.updateCalendar=(e,t)=>{v(e,t),g()};const f=n.createCalendar;n.createCalendar=e=>{f(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),l(n.state.currentDate),i(n.getEvents())},[n]);const m=t.useRef(e);t.useEffect(()=>{ye(m.current,e)||(n.updateConfig(e),m.current=e)},[n,e]);const h=t.useCallback(e=>{n.changeView(e)},[n]),v=t.useCallback(e=>{n.setCurrentDate(e)},[n]),f=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:s,changeView:h,setCurrentDate:v,addEvent:f,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=qn,exports.useDragForView=_n,exports.useLocale=Se,exports.useResponsiveConfig=()=>{const[e,n]=t.useState({yearHeight:Zt,screenSize:"desktop"});return t.useEffect(()=>{const e=()=>{const e=window.innerWidth;n(e<640?{yearHeight:Wt,screenSize:"mobile"}:e<900?{yearHeight:Bt,screenSize:"tablet"}:{yearHeight:Zt,screenSize:"desktop"})};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e},exports.useResponsiveMonthConfig=un,exports.useTheme=fn,exports.useVirtualMonthScroll=gn,exports.useVirtualScroll=({currentDate:e,yearHeight:n,onCurrentYearChange:a})=>{const r=e.getFullYear(),o=(r-zt)*n,[l,s]=t.useState(o),[i,d]=t.useState(600),[c,u]=t.useState(r),[g,m]=t.useState(!1),h=t.useRef(null),v=t.useRef(null),f=t.useRef(0),p=t.useRef(0),y=t.useRef(n);t.useEffect(()=>{if(y.current===n)return;y.current=n;const e=(c-zt)*n;s(e),p.current=e,h.current&&(h.current.scrollTop=e)},[n,c]);const x=t.useMemo(()=>{const e=performance.now(),t=Yt-zt+1,a=t*n,r=Math.floor(l/n),o=Math.min(t-1,Math.ceil((l+i)/n)),s=Math.max(0,r-$t),d=Math.min(t-1,o+$t),c=[];for(let e=s;e<=d;e++)c.push({index:e,year:zt+e,top:e*n,height:n});const u=performance.now()-e;return Ut.trackRenderTime(u),{totalHeight:a,visibleItems:c}},[l,i,n]),b=t.useCallback(e=>{const t=performance.now();if(t-f.current<Ft)return;f.current=t;const r=e.currentTarget.scrollTop,o=Math.abs(r-p.current);p.current=r,Ut.trackScrollEvent(o),requestAnimationFrame(()=>{s(r);const e=r,t=Math.floor(zt+e/n);t!==c&&t>=zt&&t<=Yt&&(u(t),null==a||a(t))}),m(!0),v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{m(!1)},Vt)},[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-zt)*n;h.current.scrollTo({top:Math.max(0,a),behavior:t?"smooth":"auto"})},[n]),w=t.useCallback(()=>{const e=Math.max(zt,c-1);u(e),D(e)},[c,D]),C=t.useCallback(()=>{const e=Math.min(Yt,c+1);u(e),D(e)},[c,D]),E=t.useCallback(()=>{const e=(new Date).getFullYear();u(e),D(e)},[D]);return t.useEffect(()=>()=>{v.current&&clearTimeout(v.current)},[]),{scrollTop:l,containerHeight:i,currentYear:c,isScrolling:g,virtualData:x,scrollElementRef:h,handleScroll:b,scrollToYear:D,handlePreviousYear:w,handleNextYear:C,handleToday:E,setScrollTop:s,setContainerHeight:d,setCurrentYear:u,setIsScrolling:m}},exports.weekDays=ae,exports.weekDaysFullName=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],exports.zh=E,exports.zonedDateTimeToDate=L;