@innosolutions/inno-calendar 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/dist/agenda-dropdown-BtVd7oeX.cjs +2 -0
  2. package/dist/agenda-dropdown-BtVd7oeX.cjs.map +1 -0
  3. package/dist/agenda-dropdown-CU74g7uM.js +3393 -0
  4. package/dist/agenda-dropdown-CU74g7uM.js.map +1 -0
  5. package/dist/agenda-view-CgPn9KUd.js +2390 -0
  6. package/dist/agenda-view-CgPn9KUd.js.map +1 -0
  7. package/dist/agenda-view-WMI-YjDn.cjs +11 -0
  8. package/dist/agenda-view-WMI-YjDn.cjs.map +1 -0
  9. package/dist/components/calendar.d.ts +43 -0
  10. package/dist/components/calendar.d.ts.map +1 -0
  11. package/dist/components/event/event-card.d.ts +106 -0
  12. package/dist/components/event/event-card.d.ts.map +1 -0
  13. package/dist/components/event/event-popover.d.ts +138 -0
  14. package/dist/components/event/event-popover.d.ts.map +1 -0
  15. package/dist/components/event/index.d.ts +6 -0
  16. package/dist/components/event/index.d.ts.map +1 -0
  17. package/dist/components/filters/calendar-filter-sidebar.d.ts +54 -0
  18. package/dist/components/filters/calendar-filter-sidebar.d.ts.map +1 -0
  19. package/dist/components/filters/index.d.ts +9 -0
  20. package/dist/components/filters/index.d.ts.map +1 -0
  21. package/dist/components/filters/schedule-type-filter.d.ts +31 -0
  22. package/dist/components/filters/schedule-type-filter.d.ts.map +1 -0
  23. package/dist/components/filters/user-filter.d.ts +31 -0
  24. package/dist/components/filters/user-filter.d.ts.map +1 -0
  25. package/dist/components/header/calendar-header.d.ts +55 -0
  26. package/dist/components/header/calendar-header.d.ts.map +1 -0
  27. package/dist/components/header/components/date-navigator.d.ts +22 -0
  28. package/dist/components/header/components/date-navigator.d.ts.map +1 -0
  29. package/dist/components/header/components/index.d.ts +8 -0
  30. package/dist/components/header/components/index.d.ts.map +1 -0
  31. package/dist/components/header/components/today-button.d.ts +15 -0
  32. package/dist/components/header/components/today-button.d.ts.map +1 -0
  33. package/dist/components/header/index.d.ts +7 -0
  34. package/dist/components/header/index.d.ts.map +1 -0
  35. package/dist/components/index.cjs +2 -0
  36. package/dist/components/index.cjs.map +1 -0
  37. package/dist/components/index.d.ts +25 -0
  38. package/dist/components/index.d.ts.map +1 -0
  39. package/dist/components/index.mjs +45 -0
  40. package/dist/components/index.mjs.map +1 -0
  41. package/dist/components/inno-calendar.d.ts +37 -0
  42. package/dist/components/inno-calendar.d.ts.map +1 -0
  43. package/dist/components/integrated-calendar.d.ts +37 -0
  44. package/dist/components/integrated-calendar.d.ts.map +1 -0
  45. package/dist/components/primitives/calendar-timeline.d.ts +13 -0
  46. package/dist/components/primitives/calendar-timeline.d.ts.map +1 -0
  47. package/dist/components/primitives/index.d.ts +7 -0
  48. package/dist/components/primitives/index.d.ts.map +1 -0
  49. package/dist/components/primitives/multi-day-banner.d.ts +14 -0
  50. package/dist/components/primitives/multi-day-banner.d.ts.map +1 -0
  51. package/dist/components/primitives/selectable-slot.d.ts +62 -0
  52. package/dist/components/primitives/selectable-slot.d.ts.map +1 -0
  53. package/dist/components/settings/badge-variant-setting.d.ts +25 -0
  54. package/dist/components/settings/badge-variant-setting.d.ts.map +1 -0
  55. package/dist/components/settings/index.d.ts +10 -0
  56. package/dist/components/settings/index.d.ts.map +1 -0
  57. package/dist/components/settings/slot-duration-setting.d.ts +20 -0
  58. package/dist/components/settings/slot-duration-setting.d.ts.map +1 -0
  59. package/dist/components/settings/visible-hours-setting.d.ts +23 -0
  60. package/dist/components/settings/visible-hours-setting.d.ts.map +1 -0
  61. package/dist/components/settings/working-hours-setting.d.ts +41 -0
  62. package/dist/components/settings/working-hours-setting.d.ts.map +1 -0
  63. package/dist/components/ui/badge.d.ts +10 -0
  64. package/dist/components/ui/badge.d.ts.map +1 -0
  65. package/dist/components/ui/button.d.ts +13 -0
  66. package/dist/components/ui/button.d.ts.map +1 -0
  67. package/dist/components/ui/dropdown-menu.d.ts +34 -0
  68. package/dist/components/ui/dropdown-menu.d.ts.map +1 -0
  69. package/dist/components/ui/index.d.ts +12 -0
  70. package/dist/components/ui/index.d.ts.map +1 -0
  71. package/dist/components/ui/popover.d.ts +8 -0
  72. package/dist/components/ui/popover.d.ts.map +1 -0
  73. package/dist/components/ui/select.d.ts +12 -0
  74. package/dist/components/ui/select.d.ts.map +1 -0
  75. package/dist/components/ui/tooltip.d.ts +8 -0
  76. package/dist/components/ui/tooltip.d.ts.map +1 -0
  77. package/dist/components/views/agenda-view.d.ts +28 -0
  78. package/dist/components/views/agenda-view.d.ts.map +1 -0
  79. package/dist/components/views/day-view.d.ts +40 -0
  80. package/dist/components/views/day-view.d.ts.map +1 -0
  81. package/dist/components/views/index.d.ts +10 -0
  82. package/dist/components/views/index.d.ts.map +1 -0
  83. package/dist/components/views/month-view.d.ts +32 -0
  84. package/dist/components/views/month-view.d.ts.map +1 -0
  85. package/dist/components/views/timeline-view.d.ts +33 -0
  86. package/dist/components/views/timeline-view.d.ts.map +1 -0
  87. package/dist/components/views/week-view.d.ts +44 -0
  88. package/dist/components/views/week-view.d.ts.map +1 -0
  89. package/dist/components/views/year-view.d.ts +16 -0
  90. package/dist/components/views/year-view.d.ts.map +1 -0
  91. package/dist/components/widget/agenda-dropdown.d.ts +20 -0
  92. package/dist/components/widget/agenda-dropdown.d.ts.map +1 -0
  93. package/dist/components/widget/agenda-widget.d.ts +27 -0
  94. package/dist/components/widget/agenda-widget.d.ts.map +1 -0
  95. package/dist/components/widget/index.d.ts +6 -0
  96. package/dist/components/widget/index.d.ts.map +1 -0
  97. package/dist/core/constants.d.ts +78 -0
  98. package/dist/core/constants.d.ts.map +1 -0
  99. package/dist/core/context/calendar-context.d.ts +65 -0
  100. package/dist/core/context/calendar-context.d.ts.map +1 -0
  101. package/dist/core/context/drag-drop-context.d.ts +58 -0
  102. package/dist/core/context/drag-drop-context.d.ts.map +1 -0
  103. package/dist/core/context/index.d.ts +5 -0
  104. package/dist/core/context/index.d.ts.map +1 -0
  105. package/dist/core/context/inno-calendar-provider.d.ts +121 -0
  106. package/dist/core/context/inno-calendar-provider.d.ts.map +1 -0
  107. package/dist/core/context/slot-selection-context.d.ts +42 -0
  108. package/dist/core/context/slot-selection-context.d.ts.map +1 -0
  109. package/dist/core/hooks/index.d.ts +5 -0
  110. package/dist/core/hooks/index.d.ts.map +1 -0
  111. package/dist/core/hooks/use-calendar-time-config.d.ts +31 -0
  112. package/dist/core/hooks/use-calendar-time-config.d.ts.map +1 -0
  113. package/dist/core/hooks/use-calendar.d.ts +63 -0
  114. package/dist/core/hooks/use-calendar.d.ts.map +1 -0
  115. package/dist/core/hooks/use-preferences.d.ts +21 -0
  116. package/dist/core/hooks/use-preferences.d.ts.map +1 -0
  117. package/dist/core/hooks/use-slot-selection.d.ts +39 -0
  118. package/dist/core/hooks/use-slot-selection.d.ts.map +1 -0
  119. package/dist/core/index.cjs +2 -0
  120. package/dist/core/index.cjs.map +1 -0
  121. package/dist/core/index.d.ts +13 -0
  122. package/dist/core/index.d.ts.map +1 -0
  123. package/dist/core/index.mjs +157 -0
  124. package/dist/core/index.mjs.map +1 -0
  125. package/dist/core/preferences/index.d.ts +9 -0
  126. package/dist/core/preferences/index.d.ts.map +1 -0
  127. package/dist/core/preferences/types.d.ts +153 -0
  128. package/dist/core/preferences/types.d.ts.map +1 -0
  129. package/dist/core/preferences/use-preferences.d.ts +54 -0
  130. package/dist/core/preferences/use-preferences.d.ts.map +1 -0
  131. package/dist/core/types.d.ts +466 -0
  132. package/dist/core/types.d.ts.map +1 -0
  133. package/dist/core/utils/date-utils.d.ts +254 -0
  134. package/dist/core/utils/date-utils.d.ts.map +1 -0
  135. package/dist/core/utils/event-utils.d.ts +91 -0
  136. package/dist/core/utils/event-utils.d.ts.map +1 -0
  137. package/dist/core/utils/grid-utils.d.ts +69 -0
  138. package/dist/core/utils/grid-utils.d.ts.map +1 -0
  139. package/dist/core/utils/index.d.ts +5 -0
  140. package/dist/core/utils/index.d.ts.map +1 -0
  141. package/dist/core/utils/position-utils.d.ts +33 -0
  142. package/dist/core/utils/position-utils.d.ts.map +1 -0
  143. package/dist/index-D2U2F80P.cjs +2 -0
  144. package/dist/index-D2U2F80P.cjs.map +1 -0
  145. package/dist/index-DtaLkIY8.js +2777 -0
  146. package/dist/index-DtaLkIY8.js.map +1 -0
  147. package/dist/index.cjs +2 -0
  148. package/dist/index.cjs.map +1 -0
  149. package/dist/index.d.ts +41 -0
  150. package/dist/index.d.ts.map +1 -0
  151. package/dist/index.mjs +204 -0
  152. package/dist/index.mjs.map +1 -0
  153. package/dist/inno-calendar-provider-B0e1XLeo.js +556 -0
  154. package/dist/inno-calendar-provider-B0e1XLeo.js.map +1 -0
  155. package/dist/inno-calendar-provider-BwP6uUAq.cjs +2 -0
  156. package/dist/inno-calendar-provider-BwP6uUAq.cjs.map +1 -0
  157. package/dist/lib/index.cjs +2 -0
  158. package/dist/lib/index.cjs.map +1 -0
  159. package/dist/lib/index.d.ts +2 -0
  160. package/dist/lib/index.d.ts.map +1 -0
  161. package/dist/lib/index.mjs +5 -0
  162. package/dist/lib/index.mjs.map +1 -0
  163. package/dist/lib/utils.d.ts +6 -0
  164. package/dist/lib/utils.d.ts.map +1 -0
  165. package/dist/presets/default/default-calendar.d.ts +44 -0
  166. package/dist/presets/default/default-calendar.d.ts.map +1 -0
  167. package/dist/presets/default/index.d.ts +2 -0
  168. package/dist/presets/default/index.d.ts.map +1 -0
  169. package/dist/presets/index.cjs +2 -0
  170. package/dist/presets/index.cjs.map +1 -0
  171. package/dist/presets/index.d.ts +3 -0
  172. package/dist/presets/index.d.ts.map +1 -0
  173. package/dist/presets/index.mjs +6 -0
  174. package/dist/presets/index.mjs.map +1 -0
  175. package/dist/presets/tailwind/index.d.ts +2 -0
  176. package/dist/presets/tailwind/index.d.ts.map +1 -0
  177. package/dist/presets/tailwind/tailwind-calendar.d.ts +122 -0
  178. package/dist/presets/tailwind/tailwind-calendar.d.ts.map +1 -0
  179. package/dist/slot-selection-context-BCNnYGHC.js +1069 -0
  180. package/dist/slot-selection-context-BCNnYGHC.js.map +1 -0
  181. package/dist/slot-selection-context-C52lU9W4.cjs +2 -0
  182. package/dist/slot-selection-context-C52lU9W4.cjs.map +1 -0
  183. package/dist/tailwind-calendar-CC9RHr10.cjs +2 -0
  184. package/dist/tailwind-calendar-CC9RHr10.cjs.map +1 -0
  185. package/dist/tailwind-calendar-D-D8H4FV.js +414 -0
  186. package/dist/tailwind-calendar-D-D8H4FV.js.map +1 -0
  187. package/dist/use-calendar-time-config-CtKkXw_L.js +191 -0
  188. package/dist/use-calendar-time-config-CtKkXw_L.js.map +1 -0
  189. package/dist/use-calendar-time-config-F-8WV_Sd.cjs +2 -0
  190. package/dist/use-calendar-time-config-F-8WV_Sd.cjs.map +1 -0
  191. package/package.json +128 -0
@@ -0,0 +1,2 @@
1
+ "use strict";const e=require("react/jsx-runtime"),Z=require("./inno-calendar-provider-BwP6uUAq.cjs"),d=require("./index-D2U2F80P.cjs"),y=require("react"),T=require("./slot-selection-context-C52lU9W4.cjs"),u=require("./agenda-view-WMI-YjDn.cjs");function Te({view:t,className:s=""}){return e.jsx("div",{className:s,style:{display:"flex",alignItems:"center",justifyContent:"center",minHeight:"400px",backgroundColor:"#f9fafb",borderRadius:"0.5rem",border:"1px dashed #d1d5db"},children:e.jsxs("div",{style:{textAlign:"center",color:"#6b7280"},children:[e.jsxs("p",{style:{fontSize:"1.125rem",fontWeight:500},children:[t.charAt(0).toUpperCase()+t.slice(1)," View"]}),e.jsx("p",{style:{fontSize:"0.875rem"},children:"Implementation pending"})]})})}function me({view:t,className:s}){return e.jsx(Te,{view:t,className:s})}function ze(t){const{events:s,resources:n,scheduleTypes:r,initialView:o="week",initialDate:i,initialFilters:c,preferences:x,locale:l,slots:f,renderEvent:p,onViewChange:N,onDateChange:v,onEventClick:w,onSlotSelect:k,onFiltersChange:D,className:C,children:j}=t,M=Z.useOptionalCalendarContext();if(M)return e.jsx("div",{className:C,style:{position:"relative"},children:j??e.jsx(me,{view:M.view,className:C})});const z=Z.useCalendar({events:s,resources:n,scheduleTypes:r,initialView:o,initialDate:i,initialFilters:c,preferences:x,locale:l,onViewChange:N,onDateChange:v,onEventClick:w,onSlotSelect:k,onFiltersChange:D});return e.jsx(Z.CalendarProvider,{value:z,children:e.jsx("div",{className:C,style:{position:"relative"},children:j??e.jsx(me,{view:z.view,className:C})})})}const Se=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Ee=["January","February","March","April","May","June","July","August","September","October","November","December"];function he(t){const s=t.hexColor;return s?{backgroundColor:s}:{}}function Le({day:t,date:s,events:n,isCurrentMonth:r,onDayClick:o}){const i=T.isToday(s),c=3,x=n.length;return e.jsxs("button",{type:"button",onClick:()=>o?.(s),className:d.cn("flex h-9 sm:h-11 flex-1 flex-col items-center justify-start gap-0.5 rounded-md pt-0.5 sm:pt-1","hover:bg-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","transition-colors",!r&&"opacity-40"),children:[e.jsx("div",{className:d.cn("flex size-5 sm:size-6 items-center justify-center rounded-full text-[10px] sm:text-xs font-medium",i&&"bg-primary font-semibold text-primary-foreground"),children:t}),x>0&&e.jsx("div",{className:"mt-0.5 flex items-center gap-0.5",children:x<=c?n.map(l=>e.jsx("div",{className:"size-1 sm:size-1.5 rounded-full bg-primary",style:he(l)},l.id)):e.jsxs(e.Fragment,{children:[n.slice(0,c).map(l=>e.jsx("div",{className:"size-1 sm:size-1.5 rounded-full bg-primary",style:he(l)},l.id)),e.jsxs("span",{className:"text-[6px] sm:text-[7px] font-medium text-muted-foreground",children:["+",x-c]})]})})]})}function Ie({date:t,events:s,onMonthClick:n,onDayClick:r}){const o=y.useMemo(()=>T.generateMonthGrid(t,0),[t]);return e.jsxs("div",{className:"flex flex-col",children:[e.jsx("button",{type:"button",onClick:()=>n?.(t),className:d.cn("w-full rounded-t-lg border px-2 sm:px-3 py-1.5 sm:py-2 text-xs sm:text-sm font-semibold","hover:bg-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","transition-colors"),children:Ee[t.getMonth()]}),e.jsxs("div",{className:"flex-1 space-y-1.5 sm:space-y-2 rounded-b-lg border border-t-0 p-2 sm:p-3",children:[e.jsx("div",{className:"grid grid-cols-7 gap-x-0.5 text-center",children:Se.map((i,c)=>e.jsxs("div",{className:"text-[9px] sm:text-xs font-medium text-muted-foreground",children:[e.jsx("span",{className:"sm:hidden",children:i[0]}),e.jsx("span",{className:"hidden sm:inline",children:i})]},c))}),e.jsx("div",{className:"grid grid-cols-7 gap-x-0.5 gap-y-1",children:o.map((i,c)=>{const x=T.getEventsForDay(s,i.date);return e.jsx(Le,{day:i.date.getDate(),date:i.date,events:x,isCurrentMonth:i.isCurrentMonth,onDayClick:r},`${c+1}-${i.date.toISOString()}`)})})]})]})}function Ce({events:t,year:s,onMonthClick:n,onDayClick:r,className:o}){const i=y.useMemo(()=>T.getYearMonths(s),[s]);return e.jsxs("div",{className:d.cn("flex flex-col h-full",o),children:[e.jsx("div",{className:"flex items-center justify-center border-b px-4 py-3",children:e.jsx("h2",{className:"text-lg font-semibold",children:s})}),e.jsx("div",{className:"flex-1 overflow-auto p-4",children:e.jsx("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:i.map(c=>e.jsx(Ie,{date:c,events:t,onMonthClick:n,onDayClick:r},c.getMonth()))})})]})}function He({className:t}){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:e.jsx("path",{d:"m15 18-6-6 6-6"})})}function $e({className:t}){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:e.jsx("path",{d:"m9 18 6-6-6-6"})})}const le=44,fe=4,We=56,ge=8,oe=80,ee=140,Fe=8,Be=18;function Pe(t){return t.split(" ").map(s=>s[0]).join("").toUpperCase().slice(0,2)}function Ae(t,s){const n=[];for(let r=0;r<s;r++){const o=new Date(t);o.setDate(o.getDate()+r),n.push(o)}return n}function Oe(t,s,n){const r=[];return t.forEach((o,i)=>{for(let c=s;c<n;c++)r.push({hour:c,dayIndex:i,date:o})}),r}function _e(t){return`${t.toString().padStart(2,"0")}:00`}function Re(t){return t.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric"})}function Ve(t,s){const n=t.toLocaleDateString("en-US",{month:"short"}),r=s.toLocaleDateString("en-US",{month:"short"}),o=t.getDate(),i=s.getDate(),c=s.getFullYear();return n===r?`${n} ${o} - ${i}, ${c}`:`${n} ${o} - ${r} ${i}, ${c}`}function pe(t){const s=[...t].sort((o,i)=>o.startCol!==i.startCol?o.startCol-i.startCol:i.spanCols-o.spanCols),n=[],r=[];for(const o of s){let i=0;for(;r[i]!==void 0&&r[i]>o.startCol;)i++;r[i]=o.startCol+o.spanCols,n.push({...o,stackIndex:i})}return n}function Ue({src:t,alt:s,fallback:n,className:r}){return e.jsx("div",{className:d.cn("relative flex shrink-0 overflow-hidden rounded-sm border bg-muted",r),children:t?e.jsx("img",{src:t,alt:s,className:"aspect-square h-full w-full object-cover"}):e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-muted text-muted-foreground",children:n})})}const Ye=7;function ie({daysToShow:t=Ye,events:s,users:n=[],selectedDate:r,onDateChange:o,onEventClick:i,visibleHours:c,className:x,getEventUserId:l,renderPopover:f}){const p=y.useRef(null),N=r??new Date,v=!0,w=c?.from??Fe,k=c?.to??Be,D=k-w,C=y.useMemo(()=>{const a=new Date(N);if(t===1||t===3)return a.setHours(0,0,0,0),a;const g=a.getDay(),b=g===0?-6:1-g;return a.setDate(a.getDate()+b),a.setHours(0,0,0,0),a},[N,t]),j=y.useMemo(()=>Ae(C,t),[C,t]),M=y.useMemo(()=>Oe(j,w,k),[v,j,w,k]),L=l??(a=>{if(a.user?.id)return a.user.id;const g=a.data;if(g?.userId)return String(g.userId);if(g?.user&&typeof g.user=="object"&&g.user.id)return String(g.user.id);if(a.participants?.[0]?.id)return a.participants[0].id}),$=y.useMemo(()=>{const a=new Map;for(const g of n)a.set(g.id,{id:g.id,name:g.name,avatar:g.avatar??void 0,email:g.email});for(const g of s){g.user?.id&&!a.has(g.user.id)&&a.set(g.user.id,{id:g.user.id,name:g.user.name,avatar:g.user.avatar??void 0,email:g.user.email});for(const b of g.participants||[])b.id&&!a.has(b.id)&&a.set(b.id,{id:b.id,name:b.name,avatar:b.avatar??void 0,email:b.email})}return Array.from(a.values())},[n,s]),B=y.useMemo(()=>{const a=[],g=new Map;for(const I of $)g.set(I.id,[]);g.set("unassigned",[]);for(const I of s){const P=L(I)??"unassigned";(g.get(P)??g.get("unassigned")).push(I)}const b=I=>{const P=[];for(const H of I){const A=H.startDate.getHours()+H.startDate.getMinutes()/60,K=H.endDate.getHours()+H.endDate.getMinutes()/60;for(let V=0;V<j.length;V++){const J=j[V],ne=T.startOfDay(J),re=T.endOfDay(J);if(H.startDate<=re&&H.endDate>=ne){let q=w,G=k;if(H.startDate>=ne&&(q=Math.max(w,A)),H.endDate<=re&&(G=Math.min(k,K)),q=Math.max(w,Math.min(k,q)),G=Math.max(w,Math.min(k,G)),G>q){const W=V*D+Math.floor(q-w),Q=V*D+Math.ceil(G-w);P.push({event:H,startCol:W,spanCols:Math.max(1,Q-W)})}}}}return P};for(const I of $){const P=g.get(I.id)??[],H=b(P),A=pe(H),K=A.reduce((V,J)=>Math.max(V,J.stackIndex+1),0);a.push({user:I,events:A,maxStack:Math.max(K,1)})}const S=g.get("unassigned")??[];if(S.length>0){const I=b(S),P=pe(I),H=P.reduce((A,K)=>Math.max(A,K.stackIndex+1),0);a.push({user:{id:"unassigned",name:"Unassigned",avatar:void 0,email:void 0},events:P,maxStack:Math.max(H,1)})}return a},[$,s,j,v,D,w,k,L]),F=a=>Math.max(We,a*(le+fe)+ge*2),O=()=>{const a=new Date(C);a.setDate(a.getDate()-t),o?.(a)},_=()=>{const a=new Date(C);a.setDate(a.getDate()+t),o?.(a)},R=M.length,h=oe,E=ee+R*h,m=y.useMemo(()=>{const a=j[0],g=j[j.length-1];return!a||!g?"":t===1?a.toLocaleDateString("en-US",{weekday:"long",month:"short",day:"numeric",year:"numeric"}):Ve(a,g)},[j,t]);return e.jsxs("div",{className:d.cn("flex h-full flex-col",x),children:[e.jsxs("div",{className:"flex items-center justify-between border-b bg-white px-2 sm:px-4 py-2 sm:py-3 gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1 sm:gap-2 shrink-0",children:[e.jsx(u.Button,{variant:"outline",size:"icon",className:"size-7 sm:size-8",onClick:O,children:e.jsx(He,{className:"size-3.5 sm:size-4"})}),e.jsx(u.Button,{variant:"outline",size:"icon",className:"size-7 sm:size-8",onClick:_,children:e.jsx($e,{className:"size-3.5 sm:size-4"})})]}),e.jsx("span",{className:"text-xs sm:text-sm font-medium truncate",children:m}),e.jsx("div",{className:"w-8 sm:w-16 shrink-0"})," "]}),e.jsx("div",{className:"flex-1 overflow-auto",ref:p,children:e.jsxs("div",{className:"relative",style:{minWidth:E},children:[e.jsxs("div",{className:"sticky top-0 z-20 flex flex-col border-b bg-white",children:[t>1&&e.jsxs("div",{className:"flex border-b",children:[e.jsx("div",{className:"flex shrink-0 items-center border-r bg-white px-2 py-1",style:{width:ee},children:e.jsx("span",{className:"text-[10px] font-medium uppercase text-muted-foreground",children:"Resources"})}),j.map(a=>{const g=T.isToday(a);return e.jsx("div",{className:d.cn("flex shrink-0 items-center justify-center border-r py-1.5 font-medium",g?"bg-primary/10 text-primary":"bg-muted/30"),style:{width:D*oe},children:e.jsx("span",{className:"text-xs",children:Re(a)})},`day-${a.toISOString()}`)})]}),e.jsxs("div",{className:"flex",children:[t===1&&e.jsx("div",{className:"flex shrink-0 items-center border-r bg-white px-2 py-2",style:{width:ee},children:e.jsx("span",{className:"text-[10px] font-medium uppercase text-muted-foreground",children:"Resources"})}),t>1&&e.jsx("div",{className:"shrink-0 border-r bg-background",style:{width:ee}}),M.map((a,g)=>{const b=a.hour===w,S=T.isToday(a.date);return e.jsx("div",{className:d.cn("flex shrink-0 items-center justify-center py-1.5 text-[10px] text-muted-foreground",b&&g>0?"border-l-2 border-l-border":"border-r border-r-border/50",S&&"bg-primary/5"),style:{width:oe},children:_e(a.hour)},`hour-${a.dayIndex}-${a.hour}`)})]})]}),B.map(a=>{const g=F(a.maxStack);return e.jsxs("div",{className:"relative flex border-b",style:{height:g},children:[e.jsxs("div",{className:"sticky left-0 z-10 flex shrink-0 items-center gap-2 sm:gap-3 border-r bg-white px-2 sm:px-4",style:{width:ee},children:[e.jsx(Ue,{className:"size-7",src:a.user.avatar,alt:a.user.name,fallback:Pe(a.user.name)}),e.jsx("span",{className:"truncate text-xs sm:text-sm font-medium",children:a.user.name})]}),e.jsxs("div",{className:"relative flex flex-1",children:[M.map((b,S)=>{const I=b.hour===w&&S>0;return e.jsx("div",{className:d.cn("shrink-0",I?"border-l-2 border-l-border":"border-r border-r-border/50",T.isToday(b.date)&&"bg-primary/5"),style:{width:oe}},`cell-${b.dayIndex}-${b.hour}`)}),a.events.map(b=>{const S=b.startCol*h+2,I=b.spanCols*h-4,P=ge+b.stackIndex*(le+fe);return e.jsx("div",{className:"absolute",style:{left:S,width:I,top:P,height:le},children:e.jsx(u.EventCard,{event:b.event,variant:"compact",onClick:i,renderPopover:f,className:"h-full w-full"})},b.event.id)})]})]},a.user.id)}),B.length===0&&e.jsx("div",{className:"flex items-center justify-center py-20 text-muted-foreground",children:"No users or events to display"})]})})]})}function Ge(t){switch(t){case"day":case"week":return"time";default:return"day"}}function Ke({onEventClick:t,onSlotClick:s,onSlotSelect:n,onAddEvent:r,className:o,showHeader:i=!0,minSelectionMinutes:c=30,settingsContent:x,filterContent:l,renderPopover:f}){const{view:p,setView:N,selectedDate:v,setSelectedDate:w,slotDuration:k,filteredEvents:D,users:C,visibleHours:j,workingHours:M,badgeVariant:z}=Z.useInnoCalendar(),L=y.useMemo(()=>({startHour:j.start,endHour:j.end}),[j]),$=y.useMemo(()=>Ge(p),[p]),B=y.useCallback(h=>{if(n){n(h);return}if(s){const E=h.startDate.getHours();s(h.startDate,E)}},[n,s]),F=y.useCallback(h=>{N("day"),w(h,"day")},[w,N]),O=y.useCallback(h=>{N("month"),w(h,"month")},[w,N]),_=y.useCallback(h=>{t?.(h)},[t]),R=()=>{const h=D,E=_,m=f;switch(p){case"day":return e.jsx(u.DayView,{events:h,date:v,visibleHours:L,workingHours:M,slotDuration:k,badgeVariant:z,onEventClick:E,renderPopover:m});case"week":return e.jsx(u.WeekView,{events:h,date:v,visibleHours:L,workingHours:M,slotDuration:k,badgeVariant:z,onEventClick:E,renderPopover:m});case"month":return e.jsx(u.MonthView,{events:h,date:v,badgeVariant:z,onEventClick:E,onDayClick:F,renderPopover:m});case"year":return e.jsx(Ce,{events:h,year:v.getFullYear(),onMonthClick:O,onDayClick:F});case"agenda":return e.jsx(u.AgendaView,{events:h,date:v,onEventClick:E,renderPopover:m});case"timeline-day":return e.jsx(ie,{daysToShow:1,events:h,users:C,selectedDate:v,visibleHours:{from:j.start,to:j.end},onEventClick:E,renderPopover:m});case"timeline-3day":return e.jsx(ie,{daysToShow:3,events:h,users:C,selectedDate:v,visibleHours:{from:j.start,to:j.end},onEventClick:E,renderPopover:m});case"timeline-week":return e.jsx(ie,{daysToShow:7,events:h,users:C,selectedDate:v,visibleHours:{from:j.start,to:j.end},onEventClick:E,renderPopover:m});default:return e.jsx(u.MonthView,{events:h,date:v,badgeVariant:z,onEventClick:E,onDayClick:F})}};return e.jsx(T.SlotSelectionProvider,{mode:$,onSelect:B,minDurationMinutes:c,slotDurationMinutes:k,enabled:!!(n||s),children:e.jsxs("div",{className:d.cn("flex flex-col h-full p-4",o),children:[i&&e.jsx(u.CalendarHeader,{currentDate:v,view:p,events:D,onViewChange:N,onNavigateToday:()=>w(new Date,p),onNavigatePrev:()=>{const h=new Date(v);p==="day"||p==="timeline-day"?h.setDate(h.getDate()-1):p==="timeline-3day"?h.setDate(h.getDate()-3):p==="week"||p==="timeline-week"?h.setDate(h.getDate()-7):p==="month"?h.setMonth(h.getMonth()-1):p==="year"?h.setFullYear(h.getFullYear()-1):h.setDate(h.getDate()-7),w(h,p)},onNavigateNext:()=>{const h=new Date(v);p==="day"||p==="timeline-day"?h.setDate(h.getDate()+1):p==="timeline-3day"?h.setDate(h.getDate()+3):p==="week"||p==="timeline-week"?h.setDate(h.getDate()+7):p==="month"?h.setMonth(h.getMonth()+1):p==="year"?h.setFullYear(h.getFullYear()+1):h.setDate(h.getDate()+7),w(h,p)},availableViews:["day","week","month","year","agenda"],showTimelineViews:!0,showSettings:!!x,...r&&{onAddEvent:r},settingsContent:x,filterContent:l}),e.jsx("div",{className:"flex-1 overflow-hidden border rounded-lg bg-white dark:bg-gray-900",children:R()})]})})}function Je({events:t,users:s=[],scheduleTypes:n=[],initialView:r="week",initialDate:o,initialSelectedUserId:i,initialScheduleTypeIds:c,initialParticipantIds:x,initialWorkingHoursView:l,initialSearchQuery:f,preferencesConfig:p,onEventClick:N,onSlotClick:v,onSlotSelect:w,onAddEvent:k,onEventDrop:D,onDateChange:C,onViewChange:j,className:M,showHeader:z=!0,minSelectionMinutes:L=30,renderPopover:$,settingsContent:B,filterContent:F}){return e.jsx(T.DragDropProvider,{...D&&{onEventDrop:D},children:e.jsx(Z.InnoCalendarProvider,{initialEvents:t,initialUsers:s,initialScheduleTypes:n,initialView:r,...o&&{initialDate:o},...i&&{initialSelectedUserId:i},...c&&{initialScheduleTypeIds:c},...x&&{initialParticipantIds:x},...l&&{initialWorkingHoursView:l},...f&&{initialSearchQuery:f},...p&&{preferencesConfig:p},...C&&{onDateChange:C},...j&&{onViewChange:j},children:e.jsx(Ke,{...N&&{onEventClick:N},...v&&{onSlotClick:v},...w&&{onSlotSelect:w},...k&&{onAddEvent:k},...$&&{renderPopover:$},className:M,showHeader:z,minSelectionMinutes:L,settingsContent:B,filterContent:F})})})}const Y=y.forwardRef(({className:t,children:s,...n},r)=>e.jsx("select",{ref:r,className:d.cn("flex h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-sm shadow-sm","ring-offset-background","focus:outline-none focus:ring-1 focus:ring-ring","disabled:cursor-not-allowed disabled:opacity-50","[&>option]:bg-background",t),...n,children:s}));Y.displayName="Select";const U=y.forwardRef(({className:t,...s},n)=>e.jsx("label",{ref:n,className:d.cn("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",t),...s}));U.displayName="Label";function qe({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"}),e.jsx("path",{d:"m15 5 4 4"})]})}function De({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("path",{d:"M3 6h18"}),e.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),e.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"}),e.jsx("line",{x1:"10",x2:"10",y1:"11",y2:"17"}),e.jsx("line",{x1:"14",x2:"14",y1:"11",y2:"17"})]})}function ae({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("path",{d:"M18 6 6 18"}),e.jsx("path",{d:"m6 6 12 12"})]})}function Qe({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"m4.9 4.9 14.2 14.2"})]})}function te({className:t}){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:e.jsx("path",{d:"M20 6 9 17l-5-5"})})}function Xe({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"m9 12 2 2 4-4"})]})}function Ze({className:t}){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:e.jsx("path",{d:"m6 9 6 6 6-6"})})}function et({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"9",cy:"7",r:"4"}),e.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),e.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}function tt({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0"}),e.jsx("circle",{cx:"12",cy:"10",r:"3"})]})}function st({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("path",{d:"M8 2v4"}),e.jsx("path",{d:"M16 2v4"}),e.jsx("rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}),e.jsx("path",{d:"M3 10h18"})]})}function nt({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),e.jsx("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),e.jsx("path",{d:"M10 9H8"}),e.jsx("path",{d:"M16 13H8"}),e.jsx("path",{d:"M16 17H8"})]})}function X({className:t}){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:d.cn("animate-spin",t),children:e.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})}const rt={edit:"Edit",delete:"Delete",cancel:"Cancel Event",close:"Close",going:"Going",notGoing:"Not Going",confirmMeeting:"Confirm meeting took place",completed:"Completed",canceled:"Canceled",participants:"Participants",guest:"guest",guests:"guests",confirmed:"confirmed",organizer:"Organizer",client:"Client",more:"more",noDateProvided:"No date provided",eventNotFound:"Event not found",cancellationNote:"Cancellation Note",canceledOn:"Canceled on",acceptThisEvent:"Accept this event only",acceptAllEvents:"Accept all events",deleteConfirmTitle:"Delete Event",deleteConfirmDescription:"Are you sure you want to delete this event? This action cannot be undone."},se=y.forwardRef(({onClick:t,label:s,children:n,className:r,variant:o="ghost",...i},c)=>e.jsxs(u.Tooltip,{children:[e.jsx(u.TooltipTrigger,{asChild:!0,children:e.jsx("button",{type:"button",ref:c,onClick:t,className:d.cn("h-8 w-8 rounded-full flex items-center justify-center transition-colors",o==="ghost"&&"hover:bg-zinc-100 dark:hover:bg-zinc-800 text-zinc-600 dark:text-zinc-400",o==="destructive"&&"hover:bg-red-50 dark:hover:bg-red-950/30 text-zinc-600 dark:text-zinc-400 hover:text-red-600",r),"aria-label":s,...i,children:n})}),e.jsx(u.TooltipContent,{side:"bottom",className:"text-xs",children:s})]}));se.displayName="IconButton";function ot({src:t,alt:s,initials:n,className:r,isClient:o}){const[i,c]=y.useState(!1);return e.jsx("div",{className:d.cn("relative h-7 w-7 rounded-full overflow-hidden shrink-0",r),children:t&&!i?e.jsx("img",{src:t,alt:s,className:"h-full w-full object-cover",onError:()=>c(!0)}):e.jsx("div",{className:d.cn("h-full w-full flex items-center justify-center text-[10px] font-medium",o?"bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-300":"bg-zinc-200 dark:bg-zinc-700 text-zinc-700 dark:text-zinc-300"),children:n})})}function je({participant:t,isEventCanceled:s=!1,labels:n}){const r=t.name||"Unknown",o=r.split(" ").map(v=>v[0]).join("").toUpperCase().slice(0,2),i=t.isOrganizer??!1,c=t.isConfirmed,x=c===!0,l=c===!1,f=t.isClient??!1,p=t.profilePicture||t.avatar,N=s;return e.jsxs("div",{className:d.cn("flex items-center gap-3 py-0",N&&"opacity-60"),children:[e.jsxs("div",{className:"relative",children:[e.jsx(ot,{src:p,alt:r,initials:o,isClient:f,className:d.cn(N&&"grayscale")}),N||l?e.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 h-3.5 w-3.5 rounded-full bg-white dark:bg-zinc-900 flex items-center justify-center",children:e.jsx("div",{className:"h-3 w-3 rounded-full bg-red-100 dark:bg-red-900/50 flex items-center justify-center",children:e.jsx(ae,{className:"h-2 w-2 text-red-600 dark:text-red-400 stroke-[3]"})})}):x?e.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 h-3.5 w-3.5 rounded-full bg-white dark:bg-zinc-900 flex items-center justify-center",children:e.jsx("div",{className:"h-3 w-3 rounded-full bg-green-100 dark:bg-green-900/50 flex items-center justify-center",children:e.jsx(te,{className:"h-2 w-2 text-green-600 dark:text-green-400 stroke-[3]"})})}):null]}),e.jsxs("div",{className:"!h-fit min-w-0 gap-0",children:[e.jsx("div",{className:"gap-0",children:e.jsx("span",{className:d.cn("text-sm text-zinc-900 dark:text-zinc-100 truncate",N&&"line-through text-zinc-500 dark:text-zinc-500"),children:r})}),f&&e.jsx("div",{className:"text-[10px] px-1.5 w-fit py-0.5 rounded bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-300 font-medium",children:n.client}),i&&!N&&e.jsx("div",{className:"text-xs text-zinc-500",children:n.organizer})]})]})}function it({open:t,onOpenChange:s,title:n,children:r}){return y.useEffect(()=>{if(!t)return;const o=i=>{i.key==="Escape"&&s(!1)};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[t,s]),y.useEffect(()=>(t?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[t]),t?e.jsxs("div",{className:"fixed inset-0 z-50",children:[e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>s(!1),onKeyDown:o=>{(o.key==="Enter"||o.key===" ")&&s(!1)}}),e.jsx("div",{className:"fixed inset-x-4 top-[50%] translate-y-[-50%] max-w-md mx-auto",children:e.jsxs("div",{className:"bg-white dark:bg-zinc-900 rounded-2xl shadow-xl overflow-hidden",children:[n&&e.jsx("div",{className:"sr-only",children:n}),r]})})]}):null}function at({open:t,onOpenChange:s,title:n,description:r,cancelLabel:o,confirmLabel:i,onConfirm:c,isLoading:x}){return t?e.jsxs("div",{className:"fixed inset-0 z-[60]",children:[e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>s(!1),onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&s(!1)}}),e.jsx("div",{className:"fixed inset-x-4 top-[50%] translate-y-[-50%] max-w-md mx-auto",children:e.jsxs("div",{className:"bg-white dark:bg-zinc-900 rounded-lg shadow-xl p-6",children:[e.jsx("h2",{className:"text-lg font-semibold text-zinc-900 dark:text-zinc-100",children:n}),e.jsx("p",{className:"mt-2 text-sm text-zinc-600 dark:text-zinc-400",children:r}),e.jsxs("div",{className:"mt-4 flex justify-end gap-3",children:[e.jsx(u.Button,{variant:"outline",size:"sm",onClick:()=>s(!1),children:o}),e.jsxs(u.Button,{variant:"destructive",size:"sm",onClick:c,disabled:x,children:[x&&e.jsx(X,{className:"h-4 w-4 mr-2"}),e.jsx(De,{className:"h-4 w-4 mr-2"}),i]})]})]})})]}):null}function lt(t,s){return t.toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric"})}function ct(t,s){const n={hour:"2-digit",minute:"2-digit",hour12:!1};return`${t.toLocaleTimeString(void 0,n)} – ${s.toLocaleTimeString(void 0,n)}`}function dt(t){return t.toLocaleDateString(void 0,{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}function xt(t){const[s,n]=y.useState(()=>typeof window<"u"?window.matchMedia(t).matches:!1);return y.useEffect(()=>{if(typeof window>"u")return;const r=window.matchMedia(t),o=i=>n(i.matches);return r.addEventListener("change",o),()=>r.removeEventListener("change",o)},[t]),s}function ve({event:t,labels:s,isLoading:n,onClose:r,onEdit:o,onDelete:i,onCancel:c,onAccept:x,onDecline:l,onConfirmMeeting:f,canEdit:p=!0,canDelete:N=!1,canCancel:v=!0,isCurrentUserParticipant:w=!1,isCurrentUserClient:k=!1,currentUserAcceptStatus:D,isAcceptLoading:C=!1,isDeclineLoading:j=!1,isConfirmLoading:M=!1,isDeleteLoading:z=!1,renderParticipant:L,renderHeaderActions:$,renderCancelReason:B,renderDeleteConfirmation:F,formatDate:O=lt,formatTimeRange:_=ct}){const[R,h]=y.useState(!1),E=!(t.isCanceled||t.meetingTookPlace),m=t.isRecurring??!1,a=t.participantDetails,g=t.participantsNames||[],b=a&&a.length>0,S=D===!0,I=D===!1,P=w&&!k&&E,H=b?a.filter(W=>W.isConfirmed).length:t.isAccepted?g.length:0,A=b?a.length:g.length,K=t.scheduleTypeColor||t.hexColor||"#039BE5",V=y.useCallback(()=>t.startDate?O(t.startDate):s.noDateProvided,[t.startDate,O,s.noDateProvided]),J=y.useCallback(()=>t.startDate&&t.endDate?_(t.startDate,t.endDate):null,[t.startDate,t.endDate,_]),ne=()=>{r(),o?.(t)},re=()=>{r(),c?.(t)},q=()=>{h(!0)},G=()=>{i?.(t),h(!1)};return n?e.jsx("div",{className:"flex h-48 items-center justify-center",children:e.jsx(X,{className:"h-6 w-6 text-zinc-400"})}):e.jsxs(u.TooltipProvider,{delayDuration:300,children:[e.jsxs("div",{className:"flex flex-col gap-0.5 p-3",children:[e.jsx("div",{className:"flex items-start justify-end gap-0.5",children:$?$({onClose:r}):e.jsxs(e.Fragment,{children:[E&&p&&o&&e.jsx(se,{onClick:ne,label:s.edit,children:e.jsx(qe,{className:"h-[18px] w-[18px]"})}),E&&v&&c&&e.jsx(se,{onClick:re,label:s.cancel,children:e.jsx(Qe,{className:"h-[18px] w-[18px]"})}),N&&i&&e.jsx(se,{onClick:q,label:s.delete,variant:"destructive",children:e.jsx(De,{className:"h-[18px] w-[18px]"})}),e.jsx(se,{onClick:r,label:s.close,children:e.jsx(ae,{className:"h-[18px] w-[18px]"})})]})}),e.jsx("div",{children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded mt-1 shrink-0",style:{backgroundColor:K}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h2",{className:d.cn("text-[22px] font-normal text-zinc-900 dark:text-zinc-100 leading-tight",t.isCanceled&&"line-through opacity-60"),children:t.title}),t.meetingTookPlace&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400 text-xs font-medium",children:[e.jsx(Xe,{className:"h-3 w-3"}),s.completed]}),t.isCanceled&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-400 text-xs font-medium",children:[e.jsx(ae,{className:"h-3 w-3"}),s.canceled]})]}),e.jsxs("div",{className:"mt-1 text-sm text-zinc-600 dark:text-zinc-400",children:[e.jsx("span",{children:V()}),J()&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mx-1.5",children:"·"}),e.jsx("span",{children:J()})]})]}),m&&t.recurrenceSummary&&e.jsx("div",{className:"text-sm text-zinc-500 dark:text-zinc-500",children:t.recurrenceSummary})]})]})}),t.isCanceled&&e.jsx("div",{className:"mx-4 p-3 rounded-lg bg-red-50 dark:bg-red-950/30",children:B?B(t):e.jsx("div",{className:"flex items-start gap-0",children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-red-700 dark:text-red-400",children:s.cancellationNote}),t.cancelReason&&e.jsxs("div",{className:"mt-1 text-sm text-red-600/80 dark:text-red-400/80 italic",children:['"',t.cancelReason,'"']}),t.canceledDate&&e.jsxs("div",{className:"mt-1.5 text-xs text-red-500/70 dark:text-red-400/60",children:[s.canceledOn," ",dt(t.canceledDate)]})]})})}),e.jsxs("div",{className:"space-y-0.5",children:[t.address&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(tt,{className:"h-5 w-5 text-zinc-400 mt-0.5 shrink-0"}),e.jsx("span",{className:"text-sm text-zinc-700 dark:text-zinc-300",children:t.address})]}),(b||g.length>0)&&e.jsxs("div",{className:"flex items-start gap-2 py-0",children:[e.jsx(et,{className:"h-5 w-5 text-zinc-400 mt-0.5 shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-0",children:[e.jsxs("span",{className:"text-sm text-zinc-900 dark:text-zinc-100 font-medium",children:[A," ",A!==1?s.guests:s.guest]}),A>0&&e.jsxs("span",{className:"text-xs text-zinc-500",children:["(",H," ",s.confirmed,")"]})]}),e.jsxs("div",{className:"mt-2 space-y-2",children:[b?a.slice(0,6).map((W,Q)=>L?L(W,Q):e.jsx(je,{participant:W,isEventCanceled:t.isCanceled,labels:s},W.id)):g.slice(0,6).map((W,Q)=>{const ue={id:String(Q),name:W,email:"",isConfirmed:t.isAccepted,isOrganizer:Q===0,isClient:!1};return L?L(ue,Q):e.jsx(je,{participant:ue,isEventCanceled:t.isCanceled,labels:s},W)}),A>6&&e.jsxs("div",{className:"text-xs text-zinc-500 py-1.5 pl-10",children:["+",A-6," ",s.more]})]})]})]}),t.description&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(nt,{className:"h-5 w-5 text-zinc-400 mt-0.5 shrink-0"}),e.jsx("p",{className:"text-sm text-zinc-700 dark:text-zinc-300 whitespace-pre-wrap",children:t.description})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(st,{className:"h-5 w-5 text-zinc-400 mt-0.5 shrink-0"}),e.jsx("div",{className:"text-sm text-zinc-700 dark:text-zinc-300",children:b&&a.find(W=>W.isOrganizer)?.name||g[0]||"Calendar"})]})]}),P&&x&&l&&e.jsx("div",{className:"border-t border-zinc-100 dark:border-zinc-800 mt-3 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[m?e.jsxs(u.DropdownMenu,{children:[e.jsx(u.DropdownMenuTrigger,{asChild:!0,children:e.jsxs("div",{className:"flex",children:[e.jsx(u.Button,{size:"sm",variant:"outline",className:d.cn("rounded-r-none gap-1.5 h-8 !border-none !bg-green-100 text-green-800 hover:!bg-green-200",S&&"!bg-green-700 !text-white hover:!bg-green-700"),onClick:W=>{W.stopPropagation(),S||x(t)},disabled:C,children:C?e.jsx(X,{className:"h-3.5 w-3.5"}):e.jsxs(e.Fragment,{children:[S&&e.jsx(te,{className:"h-3.5 w-3.5"}),s.going]})}),e.jsx(u.Button,{size:"sm",variant:"outline",className:d.cn("rounded-l-none px-1.5 h-8 !border-none !bg-green-100 text-green-800 hover:!bg-green-200",S&&"!bg-green-700 !text-white hover:!bg-green-700"),children:e.jsx(Ze,{className:"h-3.5 w-3.5"})})]})}),e.jsxs(u.DropdownMenuContent,{align:"start",children:[e.jsxs(u.DropdownMenuItem,{className:d.cn("gap-1.5 h-8 !border-none !bg-green-50 text-green-800 hover:!bg-green-100",S&&"!bg-green-700 !text-white hover:!bg-green-700"),onClick:()=>x(t),children:[e.jsx(te,{className:"h-3.5 w-3.5 mr-2 text-green-600"}),s.acceptThisEvent]}),e.jsxs(u.DropdownMenuItem,{onClick:()=>x(t),children:[e.jsx(te,{className:"h-3.5 w-3.5 mr-2 text-green-600"}),s.acceptAllEvents]})]})]}):e.jsx(u.Button,{size:"sm",variant:"outline",className:d.cn("gap-1.5 h-8 !border-none !bg-green-100 text-green-800 hover:!bg-green-200",S&&"!bg-green-700 !text-white hover:!bg-green-700"),onClick:()=>{S||x(t)},disabled:C,children:C?e.jsx(X,{className:"h-3.5 w-3.5"}):e.jsxs(e.Fragment,{children:[S&&e.jsx(te,{className:"h-3.5 w-3.5"}),s.going]})}),e.jsx(u.Button,{size:"sm",variant:"outline",className:d.cn("gap-1.5 h-8 !border-none !bg-rose-100 text-rose-800 hover:!bg-rose-200",I&&"!bg-rose-700 !text-white hover:!bg-rose-700"),onClick:()=>{I||l(t)},disabled:j,children:j?e.jsx(X,{className:"h-3.5 w-3.5"}):e.jsxs(e.Fragment,{children:[I&&e.jsx(ae,{className:"h-3.5 w-3.5"}),s.notGoing]})})]})}),w&&S&&!t.meetingTookPlace&&!t.isCanceled&&f&&e.jsx("div",{className:"border-t border-zinc-100 dark:border-zinc-800 py-3",children:e.jsxs(u.Button,{size:"sm",variant:"outline",className:"w-full h-9 hover:!bg-green-100 hover:text-green-700 text-green-700 !bg-green-100 !border-none dark:text-green-400 dark:hover:bg-green-950/30",onClick:()=>f(t),disabled:M,children:[M&&e.jsx(X,{className:"h-4 w-4 mr-2"}),s.confirmMeeting]})})]}),F?R&&F({onConfirm:G,onCancel:()=>h(!1),isLoading:z}):e.jsx(at,{open:R,onOpenChange:h,title:s.deleteConfirmTitle,description:s.deleteConfirmDescription,cancelLabel:s.cancel,confirmLabel:s.delete,onConfirm:G,isLoading:z})]})}function ut({event:t,children:s,open:n,onOpenChange:r,isLoading:o,labels:i,onEdit:c,onDelete:x,onCancel:l,onAccept:f,onDecline:p,onConfirmMeeting:N,canEdit:v=!0,canDelete:w=!1,canCancel:k=!0,isCurrentUserParticipant:D,isCurrentUserClient:C,currentUserAcceptStatus:j,isAcceptLoading:M,isDeclineLoading:z,isConfirmLoading:L,isDeleteLoading:$,renderParticipant:B,renderHeaderActions:F,renderCancelReason:O,renderDeleteConfirmation:_,formatDate:R,formatTimeRange:h,className:E,width:m=360}){const a=xt("(min-width: 768px)"),g={...rt,...i},b=y.useCallback(()=>{r?.(!1)},[r]),S={event:t,labels:g,isLoading:o,onClose:b,onEdit:c,onDelete:x,onCancel:l,onAccept:f,onDecline:p,onConfirmMeeting:N,canEdit:v,canDelete:w,canCancel:k,isCurrentUserParticipant:D,isCurrentUserClient:C,currentUserAcceptStatus:j,isAcceptLoading:M,isDeclineLoading:z,isConfirmLoading:L,isDeleteLoading:$,renderParticipant:B,renderHeaderActions:F,renderCancelReason:O,renderDeleteConfirmation:_,formatDate:R,formatTimeRange:h};return a?e.jsxs(u.Popover,{open:n??!1,onOpenChange:r??(()=>{}),children:[e.jsx(u.PopoverTrigger,{asChild:!0,children:s}),e.jsx(u.PopoverContent,{className:d.cn("p-0 shadow-lg !rounded-2xl bg-white dark:bg-zinc-900 overflow-hidden border z-50",E),style:{width:m},align:"center",side:"bottom",sideOffset:4,children:e.jsx(ve,{...S})})]}):e.jsxs(e.Fragment,{children:[s,e.jsx(it,{open:n??!1,onOpenChange:r??(()=>{}),title:t.title,children:e.jsx(ve,{...S})})]})}function mt({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 16v-4"}),e.jsx("path",{d:"M12 8h.01"})]})}function ht({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}const ft=[{value:15,label:"15 minutes"},{value:30,label:"30 minutes"},{value:60,label:"1 hour"}];function gt({value:t,onChange:s,isLocked:n=!1,className:r,labels:o={}}){const i={title:"Slot duration",lockedMessage:"This setting is locked by the administrator",infoMessage:"Set the time slot duration for day and week calendar views.",...o},c=x=>{n||s(Number(x.target.value))};return e.jsxs("div",{className:d.cn("flex flex-col gap-3",r),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(U,{className:"text-sm font-semibold",children:i.title}),n?e.jsx(u.TooltipProvider,{delayDuration:100,children:e.jsxs(u.Tooltip,{children:[e.jsx(u.TooltipTrigger,{children:e.jsx(ht,{className:"size-3 text-muted-foreground"})}),e.jsx(u.TooltipContent,{children:e.jsx("p",{children:i.lockedMessage})})]})}):e.jsx(u.TooltipProvider,{delayDuration:100,children:e.jsxs(u.Tooltip,{children:[e.jsx(u.TooltipTrigger,{children:e.jsx(mt,{className:"size-3 text-muted-foreground"})}),e.jsx(u.TooltipContent,{className:"max-w-64 text-center",children:e.jsx("p",{children:i.infoMessage})})]})})]}),e.jsx(Y,{value:t.toString(),onChange:c,disabled:n,className:"h-9 w-[128px] text-sm",children:ft.map(x=>e.jsx("option",{value:x.value.toString(),children:x.label},x.value))})]})}function pt({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 16v-4"}),e.jsx("path",{d:"M12 8h.01"})]})}function jt({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}function vt(){return Array.from({length:25},(t,s)=>({value:s,label:`${String(s).padStart(2,"0")}:00`}))}function wt({value:t,onChange:s,isLocked:n=!1,className:r,labels:o={}}){const i={title:"Visible hours",from:"From",to:"To",lockedMessage:"This setting is locked by the administrator",infoMessage:"Set the visible hour range for day and week views. Hours outside this range will be hidden.",...o},c=vt(),x=f=>{if(n)return;const p=Number(f.target.value);p<t.endHour&&s({...t,startHour:p})},l=f=>{if(n)return;const p=Number(f.target.value);p>t.startHour&&s({...t,endHour:p})};return e.jsxs("div",{className:d.cn("flex flex-col gap-3",r),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(U,{className:"text-sm font-semibold",children:i.title}),n?e.jsx(u.TooltipProvider,{delayDuration:100,children:e.jsxs(u.Tooltip,{children:[e.jsx(u.TooltipTrigger,{children:e.jsx(jt,{className:"size-3 text-muted-foreground"})}),e.jsx(u.TooltipContent,{children:e.jsx("p",{children:i.lockedMessage})})]})}):e.jsx(u.TooltipProvider,{delayDuration:100,children:e.jsxs(u.Tooltip,{children:[e.jsx(u.TooltipTrigger,{children:e.jsx(pt,{className:"size-3 text-muted-foreground"})}),e.jsx(u.TooltipContent,{className:"max-w-64 text-center",children:e.jsx("p",{children:i.infoMessage})})]})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(U,{className:"text-xs text-muted-foreground",children:i.from}),e.jsx(Y,{value:t.startHour.toString(),onChange:x,disabled:n,className:"h-9 w-[88px] text-sm",children:c.map(f=>e.jsx("option",{value:f.value.toString(),disabled:f.value>=t.endHour,children:f.label},f.value))})]}),e.jsx("span",{className:"mt-5 text-muted-foreground",children:"—"}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(U,{className:"text-xs text-muted-foreground",children:i.to}),e.jsx(Y,{value:t.endHour.toString(),onChange:l,disabled:n,className:"h-9 w-[88px] text-sm",children:c.map(f=>e.jsx("option",{value:f.value.toString(),disabled:f.value<=t.startHour,children:f.label},f.value))})]})]})]})}function bt({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 16v-4"}),e.jsx("path",{d:"M12 8h.01"})]})}function yt({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}const Nt=[{value:"dot",label:"Dot indicator"},{value:"colored",label:"Full color"},{value:"mixed",label:"Mixed"}];function kt({value:t,onChange:s,isLocked:n=!1,className:r,labels:o={}}){const i={title:"Event display",lockedMessage:"This setting is locked by the administrator",infoMessage:"Choose how events are displayed. Dot shows a small indicator, colored fills the entire event, mixed uses both.",options:{dot:"Dot indicator",colored:"Full color",mixed:"Mixed"},...o},c=l=>i.options?.[l]??l,x=l=>{n||s(l.target.value)};return e.jsxs("div",{className:d.cn("flex flex-col gap-3",r),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(U,{className:"text-sm font-semibold",children:i.title}),n?e.jsx(u.TooltipProvider,{delayDuration:100,children:e.jsxs(u.Tooltip,{children:[e.jsx(u.TooltipTrigger,{children:e.jsx(yt,{className:"size-3 text-muted-foreground"})}),e.jsx(u.TooltipContent,{children:e.jsx("p",{children:i.lockedMessage})})]})}):e.jsx(u.TooltipProvider,{delayDuration:100,children:e.jsxs(u.Tooltip,{children:[e.jsx(u.TooltipTrigger,{children:e.jsx(bt,{className:"size-3 text-muted-foreground"})}),e.jsx(u.TooltipContent,{className:"max-w-64 text-center",children:e.jsx("p",{children:i.infoMessage})})]})})]}),e.jsx(Y,{value:t,onChange:x,disabled:n,className:"h-9 w-[128px] text-sm",children:Nt.map(l=>e.jsx("option",{value:l.value,children:c(l.value)},l.value))})]})}function Ct({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 16v-4"}),e.jsx("path",{d:"M12 8h.01"})]})}function Dt({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}function Mt({className:t}){return e.jsx("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6 9 17l-5-5"})})}const Tt=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"];function zt(){return Array.from({length:25},(t,s)=>({value:s,label:`${String(s).padStart(2,"0")}:00`}))}const we={sunday:"Sun",monday:"Mon",tuesday:"Tue",wednesday:"Wed",thursday:"Thu",friday:"Fri",saturday:"Sat"};function St({dayLabel:t,config:s,onChange:n,disabled:r,hourOptions:o}){const i=()=>{r||n({...s,enabled:!s.enabled})},c=l=>{if(r)return;const f=Number(l.target.value);f<s.to&&n({...s,from:f})},x=l=>{if(r)return;const f=Number(l.target.value);f>s.from&&n({...s,to:f})};return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",role:"checkbox","aria-checked":s.enabled,"aria-label":`Enable ${t}`,onClick:i,disabled:r,className:d.cn("flex size-5 shrink-0 items-center justify-center rounded border transition-colors",s.enabled?"border-primary bg-primary text-primary-foreground":"border-input bg-background",r&&"cursor-not-allowed opacity-50"),children:s.enabled&&e.jsx(Mt,{className:"size-3"})}),e.jsx("span",{className:d.cn("w-10 text-sm",!s.enabled&&"text-muted-foreground"),children:t}),e.jsx(Y,{value:s.from.toString(),onChange:c,disabled:r||!s.enabled,className:"h-8 w-[76px] text-xs",children:o.map(l=>e.jsx("option",{value:l.value.toString(),disabled:l.value>=s.to,children:l.label},l.value))}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"—"}),e.jsx(Y,{value:s.to.toString(),onChange:x,disabled:r||!s.enabled,className:"h-8 w-[76px] text-xs",children:o.map(l=>e.jsx("option",{value:l.value.toString(),disabled:l.value<=s.from,children:l.label},l.value))})]})}function Et({value:t,onChange:s,isLocked:n=!1,className:r,labels:o={}}){const i={title:"Working hours",lockedMessage:"This setting is locked by the administrator",infoMessage:"Configure working hours for each day of the week. Non-working hours will be grayed out in day and week views.",days:we,...o},c=zt(),x=(l,f)=>{n||s({...t,[l]:f})};return e.jsxs("div",{className:d.cn("flex flex-col gap-3",r),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(U,{className:"text-sm font-semibold",children:i.title}),n?e.jsx(u.TooltipProvider,{delayDuration:100,children:e.jsxs(u.Tooltip,{children:[e.jsx(u.TooltipTrigger,{children:e.jsx(Dt,{className:"size-3 text-muted-foreground"})}),e.jsx(u.TooltipContent,{children:e.jsx("p",{children:i.lockedMessage})})]})}):e.jsx(u.TooltipProvider,{delayDuration:100,children:e.jsxs(u.Tooltip,{children:[e.jsx(u.TooltipTrigger,{children:e.jsx(Ct,{className:"size-3 text-muted-foreground"})}),e.jsx(u.TooltipContent,{className:"max-w-64 text-center",children:e.jsx("p",{children:i.infoMessage})})]})})]}),e.jsx("div",{className:"flex flex-col gap-2",children:Tt.map(l=>e.jsx(St,{dayLabel:i.days?.[l]??we[l],config:t[l],onChange:f=>x(l,f),disabled:n,hourOptions:c},l))})]})}const Lt={sunday:{enabled:!1,from:8,to:18},monday:{enabled:!0,from:8,to:18},tuesday:{enabled:!0,from:8,to:18},wednesday:{enabled:!0,from:8,to:18},thursday:{enabled:!0,from:8,to:18},friday:{enabled:!0,from:8,to:18},saturday:{enabled:!1,from:8,to:18}};function It({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"9",cy:"7",r:"4"}),e.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),e.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}function Ht({users:t,value:s,onChange:n,allLabel:r="All users",className:o,label:i}){const c=x=>{n(x.target.value)};return e.jsxs("div",{className:d.cn("flex flex-col gap-1",o),children:[i&&e.jsx(U,{className:"text-xs text-muted-foreground",children:i}),e.jsxs("div",{className:"relative",children:[e.jsx(It,{className:"pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),e.jsxs(Y,{value:s,onChange:c,className:"h-9 w-full min-w-[120px] pl-8 pr-8 text-sm",children:[e.jsx("option",{value:"all",children:r}),t.map(x=>e.jsx("option",{value:x.id,children:x.name},x.id))]})]})]})}function $t({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z"}),e.jsx("circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor"})]})}function Wt({scheduleTypes:t,value:s,onChange:n,allLabel:r="All types",className:o,label:i}){const c=l=>{n(l.target.value)},x=t.find(l=>String(l.id)===s);return e.jsxs("div",{className:d.cn("flex flex-col gap-1",o),children:[i&&e.jsx(U,{className:"text-xs text-muted-foreground",children:i}),e.jsxs("div",{className:"relative",children:[x?e.jsx("span",{className:"pointer-events-none absolute left-2.5 top-1/2 size-3 -translate-y-1/2 rounded-full",style:{backgroundColor:x.color}}):e.jsx($t,{className:"pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),e.jsxs(Y,{value:s,onChange:c,className:"h-9 w-full min-w-[140px] pl-8 pr-8 text-sm",children:[e.jsx("option",{value:"all",children:r}),t.map(l=>e.jsx("option",{value:String(l.id),children:l.label},l.id))]})]})]})}function ce({className:t}){return e.jsx("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})})}function Ft({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function Bt({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function de({checked:t,onCheckedChange:s,className:n,children:r}){return e.jsx("button",{type:"button",role:"checkbox","aria-checked":t,onClick:()=>s(!t),className:n,children:r})}function Pt({src:t,alt:s,fallback:n,className:r}){const[o,i]=y.useState(!1);return!t||o?e.jsx("div",{className:d.cn("flex items-center justify-center bg-zinc-200 text-zinc-600 font-medium text-sm",r),children:n||"?"}):e.jsx("img",{src:t,alt:s||"",className:d.cn("object-cover",r),onError:()=>i(!0)})}function be({value:t,onChange:s,placeholder:n,className:r}){return e.jsxs("div",{className:d.cn("relative",r),children:[e.jsx(Ft,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx("input",{type:"text",value:t,onChange:o=>s(o.target.value),placeholder:n,className:"h-9 w-full rounded-lg border border-border bg-white pl-9 pr-3 text-sm placeholder:text-muted-foreground focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary"})]})}function ye(t,s,n,r=.3){if(!s.trim())return t;const o=s.toLowerCase();return t.filter(i=>n(i).some(x=>x?x.toLowerCase().includes(o):!1))}const At={title:"Filters",subtitle:"Filter calendar events",scheduleTypes:"Event Types",participants:"Participants",clearAll:"Clear all",selectAll:"Select all",unselectAll:"Unselect all",searchScheduleTypes:"Search event types...",searchParticipants:"Search participants...",noScheduleTypes:"No event types found",noParticipants:"No participants found"};function Ot({scheduleTypes:t,users:s,selectedScheduleTypeIds:n,onScheduleTypeChange:r,selectedUserIds:o,onUserChange:i,onClearAll:c,className:x,scheduleTypesLoading:l=!1,usersLoading:f=!1,labels:p,getScheduleTypeName:N}){const v={...At,...p},[w,k]=y.useState(""),[D,C]=y.useState(""),j=y.useMemo(()=>w.trim()?ye(t,w,m=>[m.name,N?.(m)||m.name]):t,[t,w,N]),M=y.useMemo(()=>D.trim()?ye(s,D,m=>[m.name,m.email||""]):s,[s,D]),z=j.length>0&&j.every(m=>n.includes(m.id)),L=M.length>0&&M.every(m=>o.includes(m.id)),$=n.length+o.length,B=(m,a)=>{const g=a?[...n,m]:n.filter(b=>b!==m);r(g)},F=()=>{if(z){const m=new Set(j.map(a=>a.id));r(n.filter(a=>!m.has(a)))}else{const m=new Set([...n,...j.map(a=>a.id)]);r(Array.from(m))}},O=(m,a)=>{const g=a?[...o,m]:o.filter(b=>b!==m);i(g)},_=()=>{if(L){const m=new Set(M.map(a=>a.id));i(o.filter(a=>!m.has(a)))}else{const m=new Set([...o,...M.map(a=>a.id)]);i(Array.from(m))}},R=()=>{r([]),i([]),c?.()},h=m=>N?N(m):m.name,E=m=>m.colorHex||m.color||"#069AD7";return e.jsxs("div",{className:d.cn("flex min-w-72 max-w-72 flex-col rounded-lg border bg-white shadow-sm",x),children:[e.jsxs("header",{className:"flex items-start justify-between gap-2 px-4 pb-2 pt-4",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("h3",{className:"text-base font-semibold text-foreground",children:v.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:v.subtitle})]}),$>0&&e.jsxs("button",{type:"button",onClick:R,className:"flex h-auto items-center gap-1 rounded-md px-2 py-1 text-xs font-medium text-destructive transition-colors hover:bg-destructive/10",children:[e.jsx(Bt,{className:"h-3.5 w-3.5"}),v.clearAll]})]}),e.jsx("div",{className:"h-px w-full bg-border/60"}),e.jsxs("section",{className:"flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground",children:v.scheduleTypes}),e.jsx("button",{type:"button",onClick:F,className:"text-xs font-medium text-primary transition-colors hover:text-primary/80",children:z?v.unselectAll:v.selectAll})]}),t.length>6&&e.jsx("div",{className:"px-4 pb-3",children:e.jsx(be,{value:w,onChange:k,placeholder:v.searchScheduleTypes})}),e.jsxs("div",{className:"flex max-h-[220px] flex-col gap-2 overflow-y-auto px-4 pb-2 scrollbar-thin",children:[l?Array.from({length:4}).map((m,a)=>e.jsxs("div",{className:"flex animate-pulse items-center gap-2 rounded-md border border-border/60 bg-muted/40 p-2",children:[e.jsx("div",{className:"h-5 w-5 rounded bg-muted-foreground/20"}),e.jsx("div",{className:"h-3 w-24 rounded bg-muted-foreground/20"})]},`skeleton-${a}`)):j.map(m=>{const a=n.includes(m.id),g=E(m);return e.jsxs(de,{checked:a,onCheckedChange:b=>B(m.id,b),className:d.cn("relative flex w-full cursor-pointer items-center justify-between gap-3 rounded-md border border-border bg-white px-3 py-2 transition-colors hover:border-primary/50",a&&"border-primary bg-primary/5"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:d.cn("flex h-4 w-4 items-center justify-center rounded border border-border text-xs transition-colors",a&&"border-primary bg-primary text-primary-foreground"),children:a&&e.jsx(ce,{className:"h-3 w-3"})}),e.jsx("span",{className:"text-sm font-medium text-foreground",children:h(m)})]}),e.jsx("div",{className:"h-4 w-4 rounded-full border",style:{backgroundColor:g,borderColor:g}})]},m.id)}),!l&&j.length===0&&e.jsx("p",{className:"px-2 py-1 text-xs text-muted-foreground",children:v.noScheduleTypes})]})]}),e.jsx("div",{className:"h-px w-full bg-border/60"}),e.jsxs("section",{className:"flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground",children:v.participants}),e.jsx(de,{checked:L,onCheckedChange:()=>_(),className:d.cn("flex h-5 w-5 items-center justify-center rounded border border-border bg-white transition-colors hover:border-primary/50",L&&"border-primary bg-primary text-primary-foreground"),children:L&&e.jsx(ce,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{className:"px-4 pb-3",children:e.jsx(be,{value:D,onChange:C,placeholder:v.searchParticipants})}),e.jsxs("div",{className:"flex max-h-[400px] flex-col gap-2 overflow-y-auto px-4 pb-4 scrollbar-thin",children:[f?Array.from({length:4}).map((m,a)=>e.jsxs("div",{className:"flex animate-pulse items-center gap-3 rounded-md border border-border/60 bg-muted/40 p-3",children:[e.jsx("div",{className:"h-5 w-5 rounded bg-muted-foreground/20"}),e.jsx("div",{className:"h-10 w-10 rounded-full bg-muted-foreground/20"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-3 w-24 rounded bg-muted-foreground/20"}),e.jsx("div",{className:"h-2 w-32 rounded bg-muted-foreground/10"})]})]},`p-skeleton-${a}`)):M.map(m=>{const a=o.includes(m.id);return e.jsxs(de,{checked:a,onCheckedChange:g=>O(m.id,g),className:d.cn("relative flex w-full cursor-pointer items-start gap-2 rounded-lg border border-border bg-white p-2 transition-colors hover:border-primary/50",a&&"border-primary bg-zinc-50"),children:[e.jsx("span",{className:d.cn("flex h-4 w-4 flex-shrink-0 items-center justify-center rounded border border-border transition-colors",a&&"border-primary bg-primary text-primary-foreground"),children:a&&e.jsx(ce,{className:"h-2.5 w-2.5"})}),e.jsxs("div",{className:"flex flex-1 items-start gap-2",children:[e.jsx(Pt,{src:m.avatar??null,alt:m.name,fallback:m.name?.[0]?.toUpperCase()??"?",className:"h-10 w-10 rounded-lg"}),e.jsxs("div",{className:"flex max-w-[140px] flex-col gap-0.5 overflow-hidden",children:[e.jsx("span",{className:"line-clamp-1 text-sm font-medium text-foreground",children:m.name}),e.jsx("span",{className:"truncate text-[11px] text-muted-foreground",title:m.email,children:m.email})]})]})]},m.id)}),!f&&M.length===0&&e.jsx("p",{className:"px-4 text-xs text-muted-foreground",children:v.noParticipants})]})]})]})}function _t({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5"}),e.jsx("path",{d:"M16 2v4"}),e.jsx("path",{d:"M8 2v4"}),e.jsx("path",{d:"M3 10h5"}),e.jsx("path",{d:"M17.5 17.5 16 16.25V14"}),e.jsx("circle",{cx:"16",cy:"16",r:"6"})]})}function Me({className:t}){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:e.jsx("path",{d:"m9 18 6-6-6-6"})})}function Rt(t){const s=new Date;return s.setDate(s.getDate()+1),t.getFullYear()===s.getFullYear()&&t.getMonth()===s.getMonth()&&t.getDate()===s.getDate()}function Ne(t){const s=t.getHours(),n=t.getMinutes(),r=s>=12?"PM":"AM";return`${s%12||12}:${n.toString().padStart(2,"0")} ${r}`}function Vt(t){return new Intl.DateTimeFormat("en-US",{weekday:"long",month:"short",day:"numeric"}).format(t)}function Ut(t){const s=Ne(t.startDate),n=Ne(t.endDate);return`${s} - ${n}`}function Yt(t){return T.isToday(t)?"Today":Rt(t)?"Tomorrow":Vt(t)}function Gt(t,s){const n=new Map;for(const r of t){const o=T.formatDateISO(r.startDate),i=n.get(o)??[];i.push(r),n.set(o,i)}return Array.from(n.entries()).map(([r,o])=>{const i=[...o].sort((x,l)=>x.startDate.getTime()-l.startDate.getTime()),c=s>0?i.slice(0,s):i;return{date:new Date(r),dateKey:r,events:c,hasMore:s>0&&i.length>s}}).sort((r,o)=>r.date.getTime()-o.date.getTime())}function Kt({event:t,onClick:s,compact:n}){return e.jsxs("button",{type:"button",onClick:()=>s?.(t),className:d.cn("w-full text-left rounded-lg transition-colors","hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","flex items-start gap-3",n?"p-2":"p-3"),children:[e.jsx("div",{className:d.cn("shrink-0 rounded-full mt-1",n?"size-2":"size-2.5"),style:{backgroundColor:t.color??"#3b82f6"}}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:d.cn("font-medium truncate",n?"text-xs":"text-sm"),children:t.title}),e.jsx("p",{className:d.cn("text-muted-foreground truncate",n?"text-[10px]":"text-xs"),children:Ut(t)})]}),s&&e.jsx(Me,{className:d.cn("shrink-0 text-muted-foreground/50",n?"size-3":"size-4")})]})}function Jt({group:t,onEventClick:s,onViewMore:n,compact:r}){return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:d.cn("flex items-center justify-between px-2",r?"py-1":"py-1.5"),children:[e.jsx("h3",{className:d.cn("font-semibold",r?"text-xs":"text-sm",T.isToday(t.date)&&"text-primary"),children:Yt(t.date)}),t.hasMore&&n&&e.jsx("button",{type:"button",onClick:()=>n(t.date),className:d.cn("text-primary hover:underline",r?"text-[10px]":"text-xs"),children:"+more"})]}),e.jsx("div",{className:"space-y-0.5",children:t.events.map(o=>e.jsx(Kt,{event:o,onClick:s,compact:r},o.id))})]})}function qt({events:t,daysAhead:s=7,maxEventsPerDay:n=3,onEventClick:r,onViewAll:o,className:i,emptyState:c,title:x="Upcoming",showHeader:l=!0,compact:f=!1}){const p=Z.useOptionalCalendarContext(),N=p?.filteredEvents,v=p?.currentDate??new Date,w=t??N??[],k=y.useMemo(()=>{const j=T.startOfDay(v),M=new Date(j);return M.setDate(M.getDate()+s),w.filter(z=>z.endDate>=j&&z.startDate<M)},[w,s,v]),D=y.useMemo(()=>Gt(k,n),[k,n]),C=k.length;return D.length===0?e.jsxs("div",{className:d.cn("rounded-lg border bg-card",i),children:[l&&e.jsx("div",{className:d.cn("border-b px-4 flex items-center justify-between",f?"py-2":"py-3"),children:e.jsx("h2",{className:d.cn("font-semibold",f?"text-sm":"text-base"),children:x})}),e.jsx("div",{className:d.cn("flex flex-col items-center justify-center text-center",f?"py-6 px-4":"py-10 px-6"),children:c??e.jsxs(e.Fragment,{children:[e.jsx(_t,{className:d.cn("text-muted-foreground/50 mb-2",f?"size-8":"size-10")}),e.jsx("p",{className:d.cn("text-muted-foreground",f?"text-xs":"text-sm"),children:"No upcoming events"})]})})]}):e.jsxs("div",{className:d.cn("rounded-lg border bg-card overflow-hidden",i),children:[l&&e.jsxs("div",{className:d.cn("border-b px-4 flex items-center justify-between",f?"py-2":"py-3"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:d.cn("font-semibold",f?"text-sm":"text-base"),children:x}),e.jsx("span",{className:d.cn("text-muted-foreground bg-muted rounded-full px-2",f?"text-[10px] py-0":"text-xs py-0.5"),children:C})]}),o&&e.jsxs("button",{type:"button",onClick:()=>o(),className:d.cn("text-primary hover:underline flex items-center gap-0.5",f?"text-xs":"text-sm"),children:["View all",e.jsx(Me,{className:"size-3"})]})]}),e.jsx("div",{className:d.cn("divide-y overflow-auto",f?"p-2 max-h-[280px]":"p-3 max-h-[400px]"),children:D.map(j=>e.jsx(Jt,{group:j,onEventClick:r,onViewMore:o?M=>o(M):void 0,compact:f},j.dateKey))})]})}function Qt({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("path",{d:"M8 2v4"}),e.jsx("path",{d:"M16 2v4"}),e.jsx("rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}),e.jsx("path",{d:"M3 10h18"}),e.jsx("path",{d:"M8 14h.01"}),e.jsx("path",{d:"M12 14h.01"}),e.jsx("path",{d:"M16 14h.01"}),e.jsx("path",{d:"M8 18h.01"}),e.jsx("path",{d:"M12 18h.01"}),e.jsx("path",{d:"M16 18h.01"})]})}function Xt({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5"}),e.jsx("path",{d:"M16 2v4"}),e.jsx("path",{d:"M8 2v4"}),e.jsx("path",{d:"M3 10h5"}),e.jsx("path",{d:"M17.5 17.5 16 16.3V14"}),e.jsx("circle",{cx:"16",cy:"16",r:"6"})]})}function Zt({className:t}){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:t,children:e.jsx("path",{d:"m9 18 6-6-6-6"})})}function es({className:t}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[e.jsx("path",{d:"M15 3h6v6"}),e.jsx("path",{d:"M10 14 21 3"}),e.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"})]})}function ts(t){const s=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${s}-${n}-${r}`}function ke(t){const s=t.getHours(),n=t.getMinutes(),r=s>=12?"PM":"AM",o=s%12||12,i=String(n).padStart(2,"0");return`${o}:${i} ${r}`}function ss(t){const s=ke(t.startDate),n=ke(t.endDate);return`${s} - ${n}`}function ns(t){const s=T.addDays(new Date,1);return t.getFullYear()===s.getFullYear()&&t.getMonth()===s.getMonth()&&t.getDate()===s.getDate()}function rs(t){if(T.isToday(t))return"Today";if(ns(t))return"Tomorrow";const s=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],r=s[t.getDay()],o=n[t.getMonth()],i=t.getDate();return`${r}, ${o} ${i}`}function os(t,s){const n=new Map;for(const r of t){const o=ts(r.startDate),i=n.get(o)??[];i.push(r),n.set(o,i)}return Array.from(n.entries()).map(([r,o])=>{const i=[...o].sort((x,l)=>x.startDate.getTime()-l.startDate.getTime()),c=s>0?i.slice(0,s):i;return{date:new Date(r),dateKey:r,events:c,hasMore:s>0&&i.length>s}}).sort((r,o)=>r.date.getTime()-o.date.getTime())}function is(t){const s=T.startOfDay(new Date),n=T.endOfDay(new Date);return t.filter(r=>r.startDate>=s&&r.startDate<=n).length}function xe({className:t}){return e.jsx("div",{className:d.cn("animate-pulse rounded-md bg-muted",t)})}function as({event:t,onClick:s}){return e.jsxs("button",{type:"button",onClick:()=>s?.(t),className:d.cn("w-full text-left rounded-lg transition-colors","hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","flex items-start gap-3 p-2"),children:[e.jsx("div",{className:"shrink-0 rounded-full mt-1.5 size-2",style:{backgroundColor:t.color??"#3b82f6"}}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:t.title}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:ss(t)})]}),s&&e.jsx(Zt,{className:"shrink-0 size-4 text-muted-foreground/50 mt-1"})]})}function ls({group:t,onEventClick:s}){return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between px-2 py-1.5",children:[e.jsx("h3",{className:d.cn("text-xs font-semibold",T.isToday(t.date)&&"text-primary"),children:rs(t.date)}),t.hasMore&&e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["+",t.events.length," more"]})]}),e.jsx("div",{className:"space-y-0.5",children:t.events.map(n=>e.jsx(as,{event:n,onClick:s},n.id))})]})}function cs({events:t,isLoading:s=!1,className:n,daysAhead:r=7,maxEventsPerDay:o=3,onEventClick:i,onNavigateToAgenda:c}){const[x,l]=y.useState(!1),f=y.useMemo(()=>{const k=T.startOfDay(new Date),D=T.addDays(k,r);return t.filter(C=>C.endDate>=k&&C.startDate<D)},[t,r]),p=y.useMemo(()=>os(f,o),[f,o]),N=y.useMemo(()=>is(t),[t]),v=k=>{l(!1),i?.(k)},w=()=>{l(!1),c?.()};return e.jsxs(u.Popover,{open:x,onOpenChange:l,children:[e.jsxs(u.PopoverTrigger,{className:d.cn("relative rounded-xl hover:text-zinc-700 hover:!bg-zinc-300 !bg-zinc-200 text-zinc-600 shadow-none !px-2.5 p-2 max-h-10",n),children:[e.jsx(Qt,{className:"h-4 w-4"}),N>0&&e.jsx(u.Badge,{variant:"destructive",className:"absolute -right-4 -top-4 m-3 flex h-5 w-5 items-center justify-center rounded-full bg-primary p-0 text-[10px] font-medium hover:bg-primary",children:N>99?"99+":N})]}),e.jsxs(u.PopoverContent,{className:"w-80 rounded-xl p-0",align:"end",side:"bottom",sideOffset:8,children:[e.jsxs("div",{className:"flex items-center justify-between border-b p-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Upcoming"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:N>0?`${N} event${N>1?"s":""} today`:"No events today"})]}),c&&e.jsxs("button",{type:"button",onClick:w,className:"text-xs text-primary hover:underline flex items-center gap-1",children:["View all",e.jsx(es,{className:"size-3"})]})]}),e.jsx("div",{className:"max-h-80 overflow-y-auto p-2",children:s?e.jsx("div",{className:"space-y-2 p-2",children:Array.from({length:3}).map((k,D)=>e.jsxs("div",{className:"flex space-x-3",children:[e.jsx(xe,{className:"h-2 w-2 rounded-full mt-2"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(xe,{className:"h-4 w-full"}),e.jsx(xe,{className:"h-3 w-3/4"})]})]},D))}):p.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(Xt,{className:"mb-2 h-8 w-8 text-muted-foreground/50"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No upcoming events"}),e.jsxs("p",{className:"text-xs text-muted-foreground/70",children:["Your schedule is clear for the next ",r," days"]})]}):e.jsx("div",{className:"space-y-3 divide-y",children:p.map(k=>e.jsx(ls,{group:k,onEventClick:v},k.dateKey))})})]})]})}exports.AgendaDropdown=cs;exports.AgendaWidget=qt;exports.BadgeVariantSetting=kt;exports.Calendar=ze;exports.CalendarFilterSidebar=Ot;exports.DEFAULT_WEEK_WORKING_HOURS=Lt;exports.EventPopover=ut;exports.InnoCalendar=Je;exports.ScheduleTypeFilter=Wt;exports.SlotDurationSetting=gt;exports.TimelineView=ie;exports.UserFilter=Ht;exports.VisibleHoursSetting=wt;exports.WorkingHoursSetting=Et;exports.YearView=Ce;
2
+ //# sourceMappingURL=agenda-dropdown-BtVd7oeX.cjs.map