ezux 1.1.11 → 1.1.13
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/{EzContextMenu-C3eDRS7E.cjs → EzContextMenu-B6HBUjWv.cjs} +1 -1
- package/dist/{EzContextMenu-BsHdOgtL.js → EzContextMenu-BSA_B6Pr.js} +1 -1
- package/dist/{EzEventModal-FP2rs1pp.js → EzEventModal-BUMp_BFi.js} +6 -6
- package/dist/{EzEventModal-DkowH9rh.cjs → EzEventModal-xzHfzi0O.cjs} +1 -1
- package/dist/{EzGroupingPanel-DuKrZuqq.js → EzGroupingPanel-BUsIYDRi.js} +5 -5
- package/dist/EzGroupingPanel-D0HdSomF.cjs +1 -0
- package/dist/{EzSchedulerQuickAdd-s2jtG8vH.js → EzSchedulerQuickAdd-C653LTGh.js} +5 -5
- package/dist/{EzSchedulerQuickAdd-BLF22CDh.cjs → EzSchedulerQuickAdd-UnOWCpJd.cjs} +1 -1
- package/dist/{EzSchedulerToolbar-CaVVmnjt.cjs → EzSchedulerToolbar-C-5OdRY6.cjs} +1 -1
- package/dist/{EzSchedulerToolbar-tz6h80GC.js → EzSchedulerToolbar-CO5jjDQg.js} +15 -15
- package/dist/{EzSignature-CPoQLAyS.cjs → EzSignature-BaNesxwC.cjs} +1 -1
- package/dist/{EzSignature-D7134EQo.js → EzSignature-D4EYwo9W.js} +2 -2
- package/dist/{EzTableEditDialog-3eU6i9cv.js → EzTableEditDialog-Cd948V1C.js} +3 -3
- package/dist/{EzTableEditDialog-ftpeOKI_.cjs → EzTableEditDialog-NiOubaMT.cjs} +1 -1
- package/dist/{EzTableFooter-BiyI1m1O.cjs → EzTableFooter-CWjfGCjL.cjs} +1 -1
- package/dist/{EzTableFooter-DuAaOcLd.js → EzTableFooter-DveD12RC.js} +1 -1
- package/dist/{EzTableToolbar-DmAb94U-.js → EzTableToolbar-Bz8UWv6j.js} +50 -54
- package/dist/EzTableToolbar-DHE7Bb1R.cjs +1 -0
- package/dist/{HighlightText-C0sUEoCH.js → HighlightText-8D6KEyBw.js} +9 -11
- package/dist/HighlightText-LtZmzCle.cjs +1 -0
- package/dist/{NotificationPanel-xjIHKnlE.js → NotificationPanel-D2Y-_ahk.js} +3 -3
- package/dist/NotificationPanel-zLxrtTGf.cjs +1 -0
- package/dist/{TooltipWrapper-Bv7F-Gk4.js → TooltipWrapper-BrRTi5EJ.js} +1 -1
- package/dist/{TooltipWrapper-CgYlx0Jq.cjs → TooltipWrapper-DWts4bAI.cjs} +1 -1
- package/dist/{avatar-BkA_3sri.js → avatar-BeK0E4mn.js} +1 -1
- package/dist/{avatar-CJH7L2Or.cjs → avatar-DZAaTK2f.cjs} +1 -1
- package/dist/bell-DAz8P0BR.js +14 -0
- package/dist/bell-DOX2y38e.cjs +1 -0
- package/dist/{calendar-ChRJyGvt.cjs → calendar-BMZ8ddOf.cjs} +1 -1
- package/dist/{calendar-CCxXqG5a.js → calendar-Dy3rVMW2.js} +4 -4
- package/dist/{checkbox-_Uxyw6xN.cjs → checkbox-B0lGHUyy.cjs} +1 -1
- package/dist/{checkbox-DTLp-Oqj.js → checkbox-boJRxICT.js} +1 -1
- package/dist/circle-x-Cv7bfIC_.js +9 -0
- package/dist/circle-x-DwVXxhXr.cjs +1 -0
- package/dist/{date-time-picker-BPwpIWxg.cjs → date-time-picker-DTxHdPgQ.cjs} +1 -1
- package/dist/{date-time-picker-B9QBboUX.js → date-time-picker-Dj2eftJI.js} +6 -6
- package/dist/ezux.css +1 -1
- package/dist/grip-vertical-CSyDKBul.js +12 -0
- package/dist/grip-vertical-DZNBW1Dn.cjs +1 -0
- package/dist/{index-BmjgUrNF.cjs → index-B3ipEEhH.cjs} +2 -2
- package/dist/index-BPPb7bcs.js +3220 -0
- package/dist/{index-pr_yrvsV.js → index-BQKw_Vho.js} +4026 -1904
- package/dist/{index-B7foCkRR.js → index-C5STgBSy.js} +678 -677
- package/dist/{index-CpEN0z3t.js → index-C6NfgycP.js} +357 -357
- package/dist/index-D4f2ZdrG.cjs +2 -0
- package/dist/index-DUY1SqMo.cjs +1 -0
- package/dist/index-c1Zg--dt.cjs +7 -0
- package/dist/index.cjs +2 -2
- package/dist/index.d.ts +67 -14
- package/dist/index.es.js +136 -135
- package/dist/{input-D1zXv4Kl.cjs → input-BgM_la4k.cjs} +1 -1
- package/dist/{input-DG8ycH6m.js → input-jYQ5VKNR.js} +1 -1
- package/dist/{isBefore-DdLSsf0_.js → isBefore-C3Y_wbk3.js} +1 -1
- package/dist/{isBefore-BAixcVtb.cjs → isBefore-Cp1ttk6q.cjs} +1 -1
- package/dist/kanban.cjs +1 -1
- package/dist/kanban.es.js +4 -4
- package/dist/{label-Ch1wkGGP.js → label-ClOW9UCt.js} +2 -2
- package/dist/{label-DrUloKDN.cjs → label-Dx6oDB-X.cjs} +1 -1
- package/dist/layout.cjs +1 -1
- package/dist/layout.d.ts +29 -1
- package/dist/layout.es.js +3 -3
- package/dist/{popover-4Ng-GmwM.cjs → popover-BJq1CKmi.cjs} +1 -1
- package/dist/{popover-DstiJFa3.js → popover-Cmlb7w3R.js} +1 -1
- package/dist/scheduler.cjs +1 -1
- package/dist/scheduler.es.js +5 -5
- package/dist/{scroll-area-mGPAChYm.js → scroll-area-9fwpVNxT.js} +1 -1
- package/dist/{scroll-area-B_yufXtG.cjs → scroll-area-CwwZSSA4.cjs} +1 -1
- package/dist/select-GxA46anr.cjs +1 -0
- package/dist/select-mDCun_IR.js +35 -0
- package/dist/{settings-HCrwja-A.js → settings-CvyjK75A.js} +14 -14
- package/dist/settings-DKPknrt8.cjs +1 -0
- package/dist/signature.cjs +1 -1
- package/dist/signature.es.js +1 -1
- package/dist/{sortable.esm-DDmDbyCC.cjs → sortable.esm-CsRPuXyD.cjs} +1 -1
- package/dist/{sortable.esm-eBjUK76c.js → sortable.esm-CzMCDPet.js} +1 -1
- package/dist/table.cjs +1 -1
- package/dist/table.d.ts +18 -0
- package/dist/table.es.js +10 -9
- package/dist/theme-vars.css +2 -2
- package/dist/{tooltip-CDLAzCi8.cjs → tooltip-B41iztKT.cjs} +1 -1
- package/dist/{tooltip-C216fkmP.js → tooltip-BCtrEe0z.js} +1 -1
- package/dist/treeview.cjs +1 -2
- package/dist/treeview.es.js +558 -543
- package/dist/{useInitCoreServices-DSudhSFo.cjs → useInitCoreServices-CwXv2p4S.cjs} +1 -1
- package/dist/{useInitCoreServices-BC7QMeLn.js → useInitCoreServices-D1WaWlaI.js} +4 -3
- package/dist/{useService-DBnjCLOu.cjs → useService-8OoezWr8.cjs} +1 -1
- package/dist/{useService-BKWyN7jJ.js → useService-BUi3uAqE.js} +1 -1
- package/dist/{useServiceState-MlrHzngO.cjs → useServiceState-BjpCjUn2.cjs} +1 -1
- package/dist/{useServiceState-DWb3cncq.js → useServiceState-VE-viK8b.js} +1 -1
- package/package.json +21 -20
- package/dist/EzGroupingPanel-Dw4bbefz.cjs +0 -1
- package/dist/EzTableToolbar-qlNVxvsL.cjs +0 -1
- package/dist/HighlightText-BDclEh_K.cjs +0 -1
- package/dist/NotificationPanel-juBrjjOY.cjs +0 -1
- package/dist/index-BKsqtcvu.cjs +0 -2
- package/dist/index-D2HX-sbl.js +0 -3092
- package/dist/index-DEIRrhVY.cjs +0 -1
- package/dist/index-DGhcUfqi.cjs +0 -7
- package/dist/info-BY2cfl1l.cjs +0 -1
- package/dist/info-BuURqzhx.js +0 -14
- package/dist/select-BxcAKVaB.cjs +0 -1
- package/dist/select-BxiFqo8j.js +0 -35
- package/dist/settings-BuS8Pqjb.cjs +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const o=require("react/jsx-runtime"),b=require("react"),Y=require("./useInitCoreServices-DSudhSFo.cjs"),ar=require("@tanstack/react-store"),ir=require("@tanstack/store"),Re=require("./TooltipWrapper-CgYlx0Jq.cjs"),mn=require("rrule"),ze=require("./EzErrorBoundary-CEdz_hDo.cjs"),_e=require("./EzContextMenu-C3eDRS7E.cjs"),cr=require("./useServiceState-MlrHzngO.cjs"),Ke=require("./tooltip-CDLAzCi8.cjs"),Xe=require("./avatar-CJH7L2Or.cjs"),lr=require("react-dom");const dr=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],_n=ze.createLucideIcon("clock",dr);function Vt(e){const[t,n]=b.useState(()=>typeof window<"u"?window.matchMedia(e).matches:!1);return b.useEffect(()=>{if(typeof window>"u")return;const r=window.matchMedia(e),s=()=>n(r.matches);return r.addEventListener?r.addEventListener("change",s):r.addListener(s),()=>{r.removeEventListener?r.removeEventListener("change",s):r.removeListener(s)}},[e]),t}function Qt(e=6e4){const[t,n]=b.useState(()=>new Date);return b.useEffect(()=>{const r=setInterval(()=>{n(new Date)},e);return()=>clearInterval(r)},[e]),t}const Cn=({totalItems:e,columns:t=1,onSelect:n,onAction:r,onCancel:s,wrap:i=!0,enabled:l=!0})=>{const[d,f]=b.useState(-1),g=b.useCallback(u=>{if(!l||e===0)return;let c=d;switch(u.key){case"ArrowDown":d===-1?c=0:(c=d+t,c>=e&&(c=i?c%t:d)),u.preventDefault();break;case"ArrowUp":if(d===-1)c=e-1;else if(c=d-t,c<0)if(i){const N=d%t;c=(Math.ceil(e/t)-1)*t+N,c>=e&&(c-=t)}else c=d;u.preventDefault();break;case"ArrowRight":d===-1?c=0:(c=d+1,c>=e&&(c=i?0:d)),u.preventDefault();break;case"ArrowLeft":d===-1?c=e-1:(c=d-1,c<0&&(c=i?e-1:d)),u.preventDefault();break;case"Enter":d!==-1&&r&&(r(d),u.preventDefault());break;case"Escape":s&&(s(),u.preventDefault()),f(-1);break;default:return}c!==d&&(f(c),n?.(c))},[d,e,t,n,r,s,i,l]);return b.useEffect(()=>{if(l)return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[l,g]),{selectedIndex:d,setSelectedIndex:f}},On=6048e5,ur=864e5,Xt=6e4,fr=36e5,mr=1e3,hn=Symbol.for("constructDateFrom");function je(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&hn in e?e[hn](t):e instanceof Date?new e.constructor(t):new Date(t)}function oe(e,t){return je(t||e,e)}function dt(e,t,n){const r=oe(e,n?.in);return isNaN(t)?je(n?.in||e,NaN):(t&&r.setDate(r.getDate()+t),r)}function Kt(e,t,n){const r=oe(e,n?.in);if(isNaN(t))return je(e,NaN);if(!t)return r;const s=r.getDate(),i=je(e,r.getTime());i.setMonth(r.getMonth()+t+1,0);const l=i.getDate();return s>=l?i:(r.setFullYear(i.getFullYear(),i.getMonth(),s),r)}let hr={};function ut(){return hr}function nt(e,t){const n=ut(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,s=oe(e,t?.in),i=s.getDay(),l=(i<r?7:0)+i-r;return s.setDate(s.getDate()-l),s.setHours(0,0,0,0),s}function vt(e,t){return nt(e,{...t,weekStartsOn:1})}function An(e,t){const n=oe(e,t?.in),r=n.getFullYear(),s=je(n,0);s.setFullYear(r+1,0,4),s.setHours(0,0,0,0);const i=vt(s),l=je(n,0);l.setFullYear(r,0,4),l.setHours(0,0,0,0);const d=vt(l);return n.getTime()>=i.getTime()?r+1:n.getTime()>=d.getTime()?r:r-1}function Ht(e){const t=oe(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function _t(e,...t){const n=je.bind(null,t.find(r=>typeof r=="object"));return t.map(n)}function Ie(e,t){const n=oe(e,t?.in);return n.setHours(0,0,0,0),n}function gr(e,t,n){const[r,s]=_t(n?.in,e,t),i=Ie(r),l=Ie(s),d=+i-Ht(i),f=+l-Ht(l);return Math.round((d-f)/ur)}function pr(e,t){const n=An(e,t),r=je(e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),vt(r)}function Je(e,t,n){const r=oe(e,n?.in);return r.setTime(r.getTime()+t*Xt),r}function In(e,t,n){return dt(e,t*7,n)}function Mt(e,t,n){const[r,s]=[+oe(e.start,n?.in),+oe(e.end,n?.in)].sort((d,f)=>d-f),[i,l]=[+oe(t.start,n?.in),+oe(t.end,n?.in)].sort((d,f)=>d-f);return r<l&&i<s}function fe(e,t,n){const[r,s]=_t(n?.in,e,t);return+Ie(r)==+Ie(s)}function xr(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function Rn(e){return!(!xr(e)&&typeof e!="number"||isNaN(+oe(e)))}function br(e){return t=>{const n=Math.trunc,r=n(t);return r===0?0:r}}function wr(e,t){return+oe(e)-+oe(t)}function yr(e,t,n){const r=wr(e,t)/Xt;return br()(r)}function It(e,t){const n=oe(e,t?.in);return n.setHours(23,59,59,999),n}function Bt(e,t){const n=oe(e,t?.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}function Sr(e,t){const[n,r]=_t(e,t.start,t.end);return{start:n,end:r}}function jn(e,t){const{start:n,end:r}=Sr(t?.in,e);let s=+n>+r;const i=s?+n:+r,l=s?r:n;l.setHours(0,0,0,0);let d=1;const f=[];for(;+l<=i;)f.push(je(n,l)),l.setDate(l.getDate()+d),l.setHours(0,0,0,0);return s?f.reverse():f}function Ut(e,t){const n=oe(e,t?.in);return n.setDate(1),n.setHours(0,0,0,0),n}function vr(e,t){const n=oe(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function Yt(e,t){const n=ut(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,s=oe(e,t?.in),i=s.getDay(),l=(i<r?-7:0)+6-(i-r);return s.setDate(s.getDate()+l),s.setHours(23,59,59,999),s}const Er={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},kr=(e,t,n)=>{let r;const s=Er[e];return typeof s=="string"?r=s:t===1?r=s.one:r=s.other.replace("{{count}}",t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function Rt(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const Tr={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},Dr={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Mr={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Nr={date:Rt({formats:Tr,defaultWidth:"full"}),time:Rt({formats:Dr,defaultWidth:"full"}),dateTime:Rt({formats:Mr,defaultWidth:"full"})},_r={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Cr=(e,t,n,r)=>_r[e];function ht(e){return(t,n)=>{const r=n?.context?String(n.context):"standalone";let s;if(r==="formatting"&&e.formattingValues){const l=e.defaultFormattingWidth||e.defaultWidth,d=n?.width?String(n.width):l;s=e.formattingValues[d]||e.formattingValues[l]}else{const l=e.defaultWidth,d=n?.width?String(n.width):e.defaultWidth;s=e.values[d]||e.values[l]}const i=e.argumentCallback?e.argumentCallback(t):t;return s[i]}}const Or={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Ar={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Ir={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},Rr={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},jr={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},Pr={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},Lr=(e,t)=>{const n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},zr={ordinalNumber:Lr,era:ht({values:Or,defaultWidth:"wide"}),quarter:ht({values:Ar,defaultWidth:"wide",argumentCallback:e=>e-1}),month:ht({values:Ir,defaultWidth:"wide"}),day:ht({values:Rr,defaultWidth:"wide"}),dayPeriod:ht({values:jr,defaultWidth:"wide",formattingValues:Pr,defaultFormattingWidth:"wide"})};function gt(e){return(t,n={})=>{const r=n.width,s=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],i=t.match(s);if(!i)return null;const l=i[0],d=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],f=Array.isArray(d)?Wr(d,c=>c.test(l)):Fr(d,c=>c.test(l));let g;g=e.valueCallback?e.valueCallback(f):f,g=n.valueCallback?n.valueCallback(g):g;const u=t.slice(l.length);return{value:g,rest:u}}}function Fr(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function Wr(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function Hr(e){return(t,n={})=>{const r=t.match(e.matchPattern);if(!r)return null;const s=r[0],i=t.match(e.parsePattern);if(!i)return null;let l=e.valueCallback?e.valueCallback(i[0]):i[0];l=n.valueCallback?n.valueCallback(l):l;const d=t.slice(s.length);return{value:l,rest:d}}}const Br=/^(\d+)(th|st|nd|rd)?/i,Ur=/\d+/i,Yr={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},$r={any:[/^b/i,/^(a|c)/i]},Gr={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},qr={any:[/1/i,/2/i,/3/i,/4/i]},Vr={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},Qr={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},Xr={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},Kr={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},Jr={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Zr={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},es={ordinalNumber:Hr({matchPattern:Br,parsePattern:Ur,valueCallback:e=>parseInt(e,10)}),era:gt({matchPatterns:Yr,defaultMatchWidth:"wide",parsePatterns:$r,defaultParseWidth:"any"}),quarter:gt({matchPatterns:Gr,defaultMatchWidth:"wide",parsePatterns:qr,defaultParseWidth:"any",valueCallback:e=>e+1}),month:gt({matchPatterns:Vr,defaultMatchWidth:"wide",parsePatterns:Qr,defaultParseWidth:"any"}),day:gt({matchPatterns:Xr,defaultMatchWidth:"wide",parsePatterns:Kr,defaultParseWidth:"any"}),dayPeriod:gt({matchPatterns:Jr,defaultMatchWidth:"any",parsePatterns:Zr,defaultParseWidth:"any"})},Pn={code:"en-US",formatDistance:kr,formatLong:Nr,formatRelative:Cr,localize:zr,match:es,options:{weekStartsOn:0,firstWeekContainsDate:1}};function ts(e,t){const n=oe(e,t?.in);return gr(n,vr(n))+1}function Jt(e,t){const n=oe(e,t?.in),r=+vt(n)-+pr(n);return Math.round(r/On)+1}function Zt(e,t){const n=oe(e,t?.in),r=n.getFullYear(),s=ut(),i=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??s.firstWeekContainsDate??s.locale?.options?.firstWeekContainsDate??1,l=je(t?.in||e,0);l.setFullYear(r+1,0,i),l.setHours(0,0,0,0);const d=nt(l,t),f=je(t?.in||e,0);f.setFullYear(r,0,i),f.setHours(0,0,0,0);const g=nt(f,t);return+n>=+d?r+1:+n>=+g?r:r-1}function ns(e,t){const n=ut(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,s=Zt(e,t),i=je(t?.in||e,0);return i.setFullYear(s,0,r),i.setHours(0,0,0,0),nt(i,t)}function St(e,t){const n=oe(e,t?.in),r=+nt(n,t)-+ns(n,t);return Math.round(r/On)+1}function re(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r}const tt={y(e,t){const n=e.getFullYear(),r=n>0?n:1-n;return re(t==="yy"?r%100:r,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):re(n+1,2)},d(e,t){return re(e.getDate(),t.length)},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];default:return n==="am"?"a.m.":"p.m."}},h(e,t){return re(e.getHours()%12||12,t.length)},H(e,t){return re(e.getHours(),t.length)},m(e,t){return re(e.getMinutes(),t.length)},s(e,t){return re(e.getSeconds(),t.length)},S(e,t){const n=t.length,r=e.getMilliseconds(),s=Math.trunc(r*Math.pow(10,n-3));return re(s,t.length)}},lt={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},gn={G:function(e,t,n){const r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});default:return n.era(r,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const r=e.getFullYear(),s=r>0?r:1-r;return n.ordinalNumber(s,{unit:"year"})}return tt.y(e,t)},Y:function(e,t,n,r){const s=Zt(e,r),i=s>0?s:1-s;if(t==="YY"){const l=i%100;return re(l,2)}return t==="Yo"?n.ordinalNumber(i,{unit:"year"}):re(i,t.length)},R:function(e,t){const n=An(e);return re(n,t.length)},u:function(e,t){const n=e.getFullYear();return re(n,t.length)},Q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return re(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return re(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,n){const r=e.getMonth();switch(t){case"M":case"MM":return tt.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,n){const r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return re(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,n,r){const s=St(e,r);return t==="wo"?n.ordinalNumber(s,{unit:"week"}):re(s,t.length)},I:function(e,t,n){const r=Jt(e);return t==="Io"?n.ordinalNumber(r,{unit:"week"}):re(r,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):tt.d(e,t)},D:function(e,t,n){const r=ts(e);return t==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):re(r,t.length)},E:function(e,t,n){const r=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,n,r){const s=e.getDay(),i=(s-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(i);case"ee":return re(i,2);case"eo":return n.ordinalNumber(i,{unit:"day"});case"eee":return n.day(s,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(s,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(s,{width:"short",context:"formatting"});default:return n.day(s,{width:"wide",context:"formatting"})}},c:function(e,t,n,r){const s=e.getDay(),i=(s-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(i);case"cc":return re(i,t.length);case"co":return n.ordinalNumber(i,{unit:"day"});case"ccc":return n.day(s,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(s,{width:"narrow",context:"standalone"});case"cccccc":return n.day(s,{width:"short",context:"standalone"});default:return n.day(s,{width:"wide",context:"standalone"})}},i:function(e,t,n){const r=e.getDay(),s=r===0?7:r;switch(t){case"i":return String(s);case"ii":return re(s,t.length);case"io":return n.ordinalNumber(s,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,n){const s=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(s,{width:"narrow",context:"formatting"});default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},b:function(e,t,n){const r=e.getHours();let s;switch(r===12?s=lt.noon:r===0?s=lt.midnight:s=r/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(s,{width:"narrow",context:"formatting"});default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},B:function(e,t,n){const r=e.getHours();let s;switch(r>=17?s=lt.evening:r>=12?s=lt.afternoon:r>=4?s=lt.morning:s=lt.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(s,{width:"narrow",context:"formatting"});default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let r=e.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return tt.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):tt.H(e,t)},K:function(e,t,n){const r=e.getHours()%12;return t==="Ko"?n.ordinalNumber(r,{unit:"hour"}):re(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t==="ko"?n.ordinalNumber(r,{unit:"hour"}):re(r,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):tt.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):tt.s(e,t)},S:function(e,t){return tt.S(e,t)},X:function(e,t,n){const r=e.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return xn(r);case"XXXX":case"XX":return at(r);default:return at(r,":")}},x:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"x":return xn(r);case"xxxx":case"xx":return at(r);default:return at(r,":")}},O:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+pn(r,":");default:return"GMT"+at(r,":")}},z:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+pn(r,":");default:return"GMT"+at(r,":")}},t:function(e,t,n){const r=Math.trunc(+e/1e3);return re(r,t.length)},T:function(e,t,n){return re(+e,t.length)}};function pn(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),s=Math.trunc(r/60),i=r%60;return i===0?n+String(s):n+String(s)+t+re(i,2)}function xn(e,t){return e%60===0?(e>0?"-":"+")+re(Math.abs(e)/60,2):at(e,t)}function at(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),s=re(Math.trunc(r/60),2),i=re(r%60,2);return n+s+t+i}const bn=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});default:return t.date({width:"full"})}},Ln=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});default:return t.time({width:"full"})}},rs=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],r=n[1],s=n[2];if(!s)return bn(e,t);let i;switch(r){case"P":i=t.dateTime({width:"short"});break;case"PP":i=t.dateTime({width:"medium"});break;case"PPP":i=t.dateTime({width:"long"});break;default:i=t.dateTime({width:"full"});break}return i.replace("{{date}}",bn(r,t)).replace("{{time}}",Ln(s,t))},zn={p:Ln,P:rs},ss=/^D+$/,os=/^Y+$/,as=["D","DD","YY","YYYY"];function Fn(e){return ss.test(e)}function Wn(e){return os.test(e)}function Hn(e,t,n){const r=is(e,t,n);if(console.warn(r),as.includes(e))throw new RangeError(r)}function is(e,t,n){const r=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const cs=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,ls=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,ds=/^'([^]*?)'?$/,us=/''/g,fs=/[a-zA-Z]/;function de(e,t,n){const r=ut(),s=r.locale??Pn,i=r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,l=r.weekStartsOn??r.locale?.options?.weekStartsOn??0,d=oe(e,n?.in);if(!Rn(d))throw new RangeError("Invalid time value");let f=t.match(ls).map(u=>{const c=u[0];if(c==="p"||c==="P"){const N=zn[c];return N(u,s.formatLong)}return u}).join("").match(cs).map(u=>{if(u==="''")return{isToken:!1,value:"'"};const c=u[0];if(c==="'")return{isToken:!1,value:ms(u)};if(gn[c])return{isToken:!0,value:u};if(c.match(fs))throw new RangeError("Format string contains an unescaped latin alphabet character `"+c+"`");return{isToken:!1,value:u}});s.localize.preprocessor&&(f=s.localize.preprocessor(d,f));const g={firstWeekContainsDate:i,weekStartsOn:l,locale:s};return f.map(u=>{if(!u.isToken)return u.value;const c=u.value;(Wn(c)||Fn(c))&&Hn(c,t,String(e));const N=gn[c[0]];return N(d,c,s.localize,g)}).join("")}function ms(e){const t=e.match(ds);return t?t[1].replace(us,"'"):e}function Bn(e,t,n){const[r,s]=_t(n?.in,e,t);return r.getFullYear()===s.getFullYear()&&r.getMonth()===s.getMonth()}function wn(e,t,n){const r=+oe(e,n?.in),[s,i]=[+oe(t.start,n?.in),+oe(t.end,n?.in)].sort((l,d)=>l-d);return r>=s&&r<=i}function hs(e,t,n){return dt(e,-1,n)}function Un(e,t,n){return Kt(e,-1,n)}function gs(e,t,n){return In(e,-1,n)}const ps=e=>new ir.Store({events:[],resources:[],view:"week",currentDate:new Date,selectedDate:new Date,selectedEventId:null,slotDuration:30,is24Hour:!0,...e}),xs=e=>({setEvents:t=>{e.setState(n=>({...n,events:t}))},addEvent:t=>{e.setState(n=>({...n,events:[...n.events,t]}))},updateEvent:t=>{e.setState(n=>({...n,events:n.events.map(r=>r.id===t.id?t:r)}))},deleteEvent:t=>{e.setState(n=>({...n,events:n.events.filter(r=>r.id!==t)}))},setResources:t=>{e.setState(n=>({...n,resources:t}))},setView:t=>{e.setState(n=>({...n,view:t}))},setCurrentDate:t=>{e.setState(n=>({...n,currentDate:t}))},setSelectedDate:t=>{e.setState(n=>({...n,selectedDate:t}))},setSelectedEventId:t=>{e.setState(n=>({...n,selectedEventId:t}))},setSlotDuration:t=>{e.setState(n=>({...n,slotDuration:t}))},setIs24Hour:t=>{e.setState(n=>({...n,is24Hour:t}))}}),be={events:new Map,resources:new Map};class Yn{name="SchedulerService";constructor(t=[]){this.initializeWithData(t)}async init(){console.log("[SchedulerService] Initialized")}async cleanup(){}initializeWithData(t,n=[]){be.events.clear(),be.resources.clear(),t.forEach(r=>{be.events.set(String(r.id),JSON.parse(JSON.stringify(r)))}),n.forEach(r=>{be.resources.set(String(r.id),JSON.parse(JSON.stringify(r)))})}async getEvents(t,n){return await this.simulateLatency(),!t||!n?Array.from(be.events.values()):Array.from(be.events.values()).filter(s=>{const i=new Date(s.start),l=new Date(s.end);return i>=t&&i<n||l>t&&l<=n||i<=t&&l>=n}).map(s=>({...s,start:new Date(s.start),end:new Date(s.end)}))}async addEvent(t){await this.simulateLatency();const n={id:t.id||Math.random().toString(36).substring(2,9),title:t.title||"Untitled Event",start:t.start||new Date,end:t.end||new Date(new Date().getTime()+3600*1e3),description:t.description,resourceId:t.resourceId,resourceIds:t.resourceIds,allDay:t.allDay||!1,...t};return be.events.set(n.id,n),n}async updateEvent(t){console.log("[SchedulerService] Updating event:",t.id,t.start,t.end),await this.simulateLatency();const n=String(t.id);if(be.events.has(n)){const s={...be.events.get(n),...t,id:n};return be.events.set(n,s),console.log("[SchedulerService] Event updated in DB:",s),s}else if(be.events.has(t.id)){const s={...be.events.get(t.id),...t};return be.events.set(t.id,s),s}throw console.error("[SchedulerService] Event not found in DB:",t.id,"Keys:",Array.from(be.events.keys())),new Error(`Event with ID ${t.id} not found`)}async deleteEvent(t){await this.simulateLatency();const n=String(t);be.events.has(n)?be.events.delete(n):be.events.has(t)&&be.events.delete(t)}async getResources(){return await this.simulateLatency(),Array.from(be.resources.values())}async addResource(t){return await this.simulateLatency(),t.id||(t.id=Math.random().toString(36).substring(2,9)),be.resources.set(t.id,t),t}simulateLatency(){return new Promise(t=>setTimeout(t,300))}}class bs{name="RecurrenceEngine";expandEvents(t,n,r){const s=[];return t.forEach(i=>{if(i.recurrenceRule||i.rrule)try{const l=i.recurrenceRule||i.rrule||"";if(!l)return;const d=new Date(i.start),f=new Date(i.end),g=mn.RRule.parseString(l);g.dtstart=d;const c=new mn.RRule(g).between(n,r,!0),N=new Set;i.exdate&&Array.isArray(i.exdate)?i.exdate.forEach(p=>{const h=new Date(p).getTime();isNaN(h)||N.add(h)}):typeof i.recurrenceException=="string"&&i.recurrenceException.split(",").forEach(p=>{const h=new Date(p).getTime();isNaN(h)||N.add(h)}),c.forEach(p=>{if(N.has(p.getTime()))return;const h=f.getTime()-d.getTime();if(isNaN(h))return;const _=new Date(p.getTime()+h);s.push({...i,id:`${i.id}-${p.getTime()}`,recurrenceId:String(i.id),start:p,end:_,originalStart:d})})}catch(l){console.error(`Error processing recurrence rule for event ${i.id}:`,l),s.push(i)}else s.push(i)}),s}cleanup(){}}const ws=(e,t,n)=>{const r=Y.useEzServiceRegistry(),{events:s,serviceRegistry:i=r,showWeekend:l=!0,recurrenceEngine:d,onEventCreate:f,onEventChange:g,onEventDelete:u}=e,c=Re.useQueryClient(),N=ze.getOrRegisterService(i,"SchedulerService",()=>new Yn(s||[])),p=d||ze.getOrRegisterService(i,"RecurrenceEngine",()=>new bs);b.useEffect(()=>{s&&s.length>0&&(N.initializeWithData(s),c.invalidateQueries({queryKey:["scheduler-events"]}))},[s,N,c]);const h=b.useMemo(()=>{let k,M;if(t==="day"||t==="timeline-day")k=Ie(n),M=It(n);else if(t==="month"||t==="timeline-month")k=t==="month"?nt(Ut(n),{weekStartsOn:0}):Ut(n),M=t==="month"?Yt(Bt(n),{weekStartsOn:0}):Bt(n);else if(t==="week"||t==="workweek"||t==="timeline-week"){const v=nt(n,{weekStartsOn:0});k=t==="workweek"?dt(v,1):v,M=t==="workweek"?dt(v,5):Yt(n,{weekStartsOn:0})}else k=Ie(n),M=It(n);try{const v=jn({start:k,end:M});return l?v:v.filter(K=>{const $=K.getDay();return $!==0&&$!==6})}catch{return[n]}},[t,n,l]),_=h.length>0?Ie(h[0]):new Date,P=h.length>0?It(h[h.length-1]):new Date,{data:G=[]}=Re.useQuery({queryKey:["scheduler-events",_.toISOString(),P.toISOString()],queryFn:()=>N.getEvents(_,P),placeholderData:s||[]}),D=b.useMemo(()=>h.length===0?[]:p.expandEvents(G,_,P),[G,h,p,_,P]),H=b.useMemo(()=>h.length?D.filter(k=>wn(k.start,{start:_,end:P})||wn(k.end,{start:_,end:P})||k.start<_&&k.end>P):[],[D,h,_,P]),z=Re.useMutation({mutationFn:async k=>{const M=await N.addEvent(k);return f&&await f(M),M},onMutate:async k=>{const M=["scheduler-events",_.toISOString(),P.toISOString()];await c.cancelQueries({queryKey:M});const v=c.getQueryData(M);return c.setQueryData(M,(K=[])=>{const $={...k,id:k.id||Date.now().toString(),start:k.start||new Date,end:k.end||new Date};return[...K,$]}),{previousEvents:v,queryKey:M}},onError:(k,M,v)=>{v?.previousEvents&&c.setQueryData(v.queryKey,v.previousEvents)},onSettled:()=>{c.invalidateQueries({queryKey:["scheduler-events"]})}}),se=Re.useMutation({mutationFn:async k=>{const M=await N.updateEvent(k);return g&&await g(M),M},onMutate:async k=>{const M=["scheduler-events",_.toISOString(),P.toISOString()];await c.cancelQueries({queryKey:M});const v=c.getQueryData(M);return c.setQueryData(M,(K=[])=>K.map($=>$.id===k.id?k:$)),{previousEvents:v,queryKey:M}},onError:(k,M,v)=>{v?.previousEvents&&c.setQueryData(v.queryKey,v.previousEvents)},onSettled:()=>{c.invalidateQueries({queryKey:["scheduler-events"]})}}),y=Re.useMutation({mutationFn:async k=>(await N.deleteEvent(k),u&&await u(k.toString()),k),onMutate:async k=>{const M=["scheduler-events",_.toISOString(),P.toISOString()];await c.cancelQueries({queryKey:M});const v=c.getQueryData(M);return c.setQueryData(M,(K=[])=>K.filter($=>$.id!==k)),{previousEvents:v,queryKey:M}},onError:(k,M,v)=>{v?.previousEvents&&c.setQueryData(v.queryKey,v.previousEvents)},onSettled:()=>{c.invalidateQueries({queryKey:["scheduler-events"]})}});return{schedulerService:N,recurrenceEngine:p,daysInView:h,visibleEvents:H,allEvents:G,addEvent:z.mutateAsync,updateEvent:se.mutateAsync,deleteEvent:y.mutateAsync,isUpdating:z.isPending||se.isPending||y.isPending}},ys=e=>{const{overscanCount:t=2,startHour:n="00:00",endHour:r="24:00"}=e,s=parseInt(n.split(":")[0],10),i=parseInt(r.split(":")[0],10),d=60/(e.slotDuration||30),f=Math.max(1,(i-s)*d),{rowVirtualizer:g,columnVirtualizer:u,parentRef:c}=_e.useVirtualization({rowCount:f,rowHeight:64,overscanCount:t,progressiveRendering:e.progressiveRendering,prefetchDistance:e.prefetchDistance,enableColumnVirtualization:e.view?.startsWith("timeline"),columnCount:e.view?.startsWith("timeline")?f:0,columnWidth:100,id:e.id,debug:e.debugVirtualization,onScrollStart:()=>{e.virtualScrollStart&&e.virtualScrollStart({virtualizer:{}})},onScrollStop:()=>{e.virtualScrollStop&&e.virtualScrollStop({virtualizer:{}})}});return{parentRef:c,rowVirtualizer:g,columnVirtualizer:u}},Ss=(e,t,n,r)=>{const s=f=>{t(f),r?.(f)};return{next:()=>{let f=e;n==="day"||n==="timeline-day"?f=dt(e,1):n==="week"||n==="workweek"||n==="timeline-week"?f=In(e,1):(n==="month"||n==="timeline-month")&&(f=Kt(e,1)),s(f)},prev:()=>{let f=e;n==="day"||n==="timeline-day"?f=hs(e):n==="week"||n==="workweek"||n==="timeline-week"?f=gs(e):(n==="month"||n==="timeline-month")&&(f=Un(e)),s(f)},today:()=>{s(new Date)}}};class vs extends Y.BaseService{name="HistoryService";undoStack=[];redoStack=[];maxHistorySize=50;constructor(){super({canUndo:!1,canRedo:!1})}record(t){const n={...t,timestamp:Date.now()};this.undoStack.push(n),this.undoStack.length>this.maxHistorySize&&this.undoStack.shift(),this.redoStack=[],this.updateState()}undo(){if(this.undoStack.length===0)return null;const t=this.undoStack.pop();return this.redoStack.push(t),this.updateState(),t}redo(){if(this.redoStack.length===0)return null;const t=this.redoStack.pop();return this.undoStack.push(t),this.updateState(),t}clear(){this.undoStack=[],this.redoStack=[],this.updateState()}updateState(){this.setState({canUndo:this.undoStack.length>0,canRedo:this.redoStack.length>0})}cleanup(){this.clear(),super.cleanup()}}class Es{name="SearchService";search(t,n,r={}){if(!n||!n.trim())return t;const s=r.matchCase?n:n.toLowerCase(),i=r.fields||["title","description","location"];return t.filter(l=>i.some(d=>{const f=l[d];return typeof f!="string"?!1:r.matchCase?f.includes(s):f.toLowerCase().includes(s)}))}cleanup(){}}class ks{name="TimezoneService";constructor(){}toTimezone(t,n){if(!n||n==="UTC"||n==="Local")return new Date(t);try{const s=new Date(t).toLocaleString("en-US",{timeZone:n});return new Date(s)}catch(r){return console.warn(`TimezoneService: Invalid timezone ${n}`,r),new Date(t)}}formatInTimezone(t,n,r){try{return new Intl.DateTimeFormat("en-US",{...r,timeZone:n}).format(new Date(t))}catch(s){return console.error("TimezoneService formatting error:",s),""}}getLocalTimezone(){return Intl.DateTimeFormat().resolvedOptions().timeZone}cleanup(){}}class Ts{name="AttendeeService";constructor(){}isValidEmail(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}getStatusLabel(t){switch(t){case"accepted":return"Accepted";case"declined":return"Declined";case"tentative":return"Tentative";case"needs-action":return"Needs Action";default:return"Unknown"}}cleanup(){}}class Ds{name="ReminderService";timer=null;checkInterval=6e4;onReminderTriggered;constructor(){}start(t){this.onReminderTriggered=t,this.timer&&clearInterval(this.timer),this.timer=setInterval(()=>this.checkReminders(),this.checkInterval)}stop(){this.timer&&(clearInterval(this.timer),this.timer=null)}checkReminders(){console.log("[ReminderService] Checking for due reminders...",this.onReminderTriggered)}getTriggerTime(t,n){return new Date(t.getTime()-n*6e4)}cleanup(){this.stop()}}const $n=e=>{const t=Y.useBaseComponent(e),{serviceRegistry:n,state:r,api:s}=t,l=cr.useServiceState("I18nService")?.dir||"ltr",f=e.dir==="auto"||!e.dir?l:e.dir,g=b.useMemo(()=>ps({events:e.events||[],resources:e.resources||[],view:e.view?e.view.toLowerCase():"week",currentDate:e.selectedDate||new Date,selectedDate:e.selectedDate||new Date,slotDuration:e.slotDuration||30,is24Hour:e.is24Hour??!0}),[]),u=b.useMemo(()=>xs(g),[g]),c=ar.useStore(g,F=>F);b.useEffect(()=>{e.events&&u.setEvents(e.events)},[e.events]),b.useEffect(()=>{e.resources&&u.setResources(e.resources)},[e.resources]),b.useEffect(()=>{if(e.view){const F=e.view.toLowerCase().replace(/[^a-z]/g,""),R={day:"day",week:"week",workweek:"workweek",month:"month",timelineday:"timeline-day",timelineweek:"timeline-week",timelineworkweek:"timeline-week",timelinemonth:"timeline-month",agenda:"agenda",timeline:"timeline-day"};u.setView(R[F]||F)}},[e.view,u]),b.useEffect(()=>{e.selectedDate&&(u.setCurrentDate(e.selectedDate),u.setSelectedDate(e.selectedDate))},[e.selectedDate]),b.useEffect(()=>{e.slotDuration!==void 0&&u.setSlotDuration(e.slotDuration)},[e.slotDuration]),b.useEffect(()=>{e.is24Hour!==void 0&&u.setIs24Hour(e.is24Hour)},[e.is24Hour]);const{view:N,currentDate:p,events:h}=c,{schedulerService:_,recurrenceEngine:P,daysInView:G,visibleEvents:D,allEvents:H,addEvent:z,updateEvent:se,deleteEvent:y,isUpdating:k}=ws({...e,events:h},N,p),{parentRef:M,rowVirtualizer:v,columnVirtualizer:K}=ys(e),{next:$,prev:q,today:De}=Ss(p,u.setCurrentDate,N,e.onDateChange),[X,ne]=b.useState(null),{selectedIndex:Me,setSelectedIndex:me}=Cn({totalItems:D.length,enabled:!0,onSelect:F=>{const R=D[F];R&&(ne(R.id),(document.getElementById(`event-${R.id}`)||document.querySelector(`[data-event-id="${R.id}"]`))?.scrollIntoView({behavior:"smooth",block:"nearest"}))},onAction:F=>{const R=D[F];R&&e.onEventClick&&e.onEventClick(R)}}),Se=b.useMemo(()=>({showWeekend:e.showWeekend??!0,timeFormat:e.timeFormat,weekRule:e.weekRule||"FirstDay",monthsCount:e.monthsCount||1,eventDragArea:e.eventDragArea,dir:f||"ltr"}),[e.showWeekend,e.timeFormat,e.weekRule,e.monthsCount,e.eventDragArea,f]),ie=ze.getOrRegisterService(n,"HistoryService",()=>new vs),ue=ze.getOrRegisterService(n,"SearchService",()=>new Es),Z=ze.getOrRegisterService(n,"TimezoneService",()=>new ks),he=ze.getOrRegisterService(n,"AttendeeService",()=>new Ts),ee=ze.getOrRegisterService(n,"ReminderService",()=>new Ds);return{state:{currentView:c.view,selectedDate:c.selectedDate,currentDate:p,events:c.events,resources:c.resources,viewEvents:D,daysInView:G,allEvents:H,slotDuration:c.slotDuration,is24Hour:c.is24Hour,isUpdating:k,selectedIndex:Me,highlightedEventId:X},actions:{nextPeriod:$,prevPeriod:q,today:De,setView:u.setView,setDate:u.setSelectedDate,setCurrentDate:u.setCurrentDate,addEvent:z,updateEvent:se,deleteEvent:y,setSlotDuration:u.setSlotDuration,setIs24Hour:u.setIs24Hour,setSelectedIndex:me,setHighlightedEventId:ne},services:{schedulerService:_,recurrenceEngine:P,historyService:ie,searchService:ue,timezoneService:Z,attendeeService:he,reminderService:ee,serviceRegistry:n},config:Se,refs:{parentRef:M,rowVirtualizer:v,columnVirtualizer:K},baseState:r,baseApi:s,dir:f}},Ms=(e,t,n,r,s,i,l={})=>{const d=b.useMemo(()=>{const f=Re.createNavigationMethods(s.scrollToIndex),g=Re.createCRUDMethods(()=>n.getEvents(),p=>n.addEvent(p),p=>n.updateEvent(p),p=>n.deleteEvent(p)),u=Re.createSpinnerMethods(s.showSpinner,s.hideSpinner),c=Re.createRefreshMethods(()=>{},s.forceUpdate),N=Re.createExportMethods(()=>l.onExportExcel?.(r),()=>l.onExportICS?.(r),()=>{window.print()});return{changeView:s.changeView,changeCurrentView:s.changeView,next:s.next,prev:s.prev,today:s.today,...f,scrollTo:(p,h=0)=>{const P=parseInt(p.split(":")[0])*60+h,D=Math.floor(P/30);s.scrollToIndex(D)},scrollToTime:(p,h)=>{const _=p*60+h,G=Math.floor(_/30);s.scrollToIndex(G)},...g,getEvents:async()=>n.getEvents(),getEventsInDateRange:async(p,h)=>n.getEvents(p,h),addEvent:async p=>{await n.addEvent(p)},saveEvent:async p=>{await n.updateEvent(p)},deleteEvent:async p=>{await n.deleteEvent(p)},getCurrentViewEvents:()=>r,addResource:async p=>{s.setResources(h=>[...h,p])},removeResource:async p=>{s.setResources(h=>h.filter(_=>_.id!==p))},openEditor:(p,h="Add")=>{s.setEditorState({isOpen:!0,mode:h==="Edit"?"edit":h==="view"?"view":"create",event:p})},closeEditor:()=>s.setEditorState({isOpen:!1,mode:"create",event:void 0}),closeQuickInfoPopup:s.closeQuickInfoPopup,...u,...c,...N,currentView:e,...l}},[e,t,r,s,n,l]);ze.useComponentImperativeAPI(i,d)},Ns=({resources:e})=>{const t=b.useMemo(()=>!e||e.length===0?[]:"dataSource"in e[0]?e.flatMap(s=>s.dataSource):e,[e]),[n,r]=b.useState(t);return b.useEffect(()=>{r(t)},[t]),{resources:t,internalResources:n,setInternalResources:r}},_s=({events:e,onEventChange:t,slotDuration:n=30})=>{const r=b.useCallback(i=>{const{active:l,over:d,delta:f}=i,g=e.find(c=>c.id===l.id||c.id===(l.data?.current?.eventId||l.data?.current?.id));if(!g)return;if(l.data?.current?.type?.startsWith("resize-")){const c=l.data.current.type,N=l.data.current,p=N?.orientation||"vertical",h=N?.pixelsPerSlot||64,_=p==="vertical"?f.y:f.x,P=Math.round(_/h)*n;if(P===0)return;if(c==="resize-bottom"){const G=new Date(g.end.getTime()+P*60*1e3),D=new Date(g.start.getTime()+n*60*1e3),H=G<D?D:G;t?.({...g,end:H})}else if(c==="resize-top"){const G=new Date(g.start.getTime()+P*60*1e3),D=new Date(g.end.getTime()-n*60*1e3),H=G>D?D:G;t?.({...g,start:H})}return}if(typeof d.id=="string"&&d.id.startsWith("slot-")){const c=d.data?.current?.date,N=d.data?.current?.resourceId;if(c){const p=g.end.getTime()-g.start.getTime(),h=new Date(c),_=new Date(h.getTime()+p);t?.({...g,start:h,end:_,resourceId:N==="none"?void 0:N})}return}const u=typeof d.id=="string"&&d.id.startsWith("header-")?d.id.replace("header-",""):null;if(u){const c={...g,resourceId:u};t?.(c)}},[e,t,n]);return{sensors:_e.useSensors(_e.useSensor(_e.PointerSensor,{activationConstraint:{distance:8}})),handleDragEnd:r}},Cs=()=>o.jsx("div",{className:"flex flex-col items-center justify-center min-h-screen p-4",children:o.jsxs("div",{className:"flex flex-col items-center gap-4 max-w-md w-full",children:[o.jsx("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-destructive/10",children:o.jsx(ze.TriangleAlert,{className:"w-8 h-8 text-destructive"})}),o.jsxs("div",{className:"flex flex-col items-center gap-2 text-center",children:[o.jsx("h2",{className:"text-lg font-semibold",children:"Scheduler Error"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Something went wrong with the scheduler. Please refresh the page or try again."})]}),o.jsxs("button",{onClick:()=>window.location.reload(),className:"flex items-center gap-2 px-4 py-2 text-sm font-medium text-primary hover:bg-primary/10 rounded-md transition-colors",children:[o.jsx(ze.RefreshCw,{className:"w-4 h-4"}),"Refresh Page"]})]})}),Os=({variant:e="primary",text:t="Loading",className:n})=>{const r="absolute inset-0 bg-background/40 backdrop-blur-[2px] z-[100] flex items-center justify-center transition-all duration-300",s={md:"w-10 h-10"},i={primary:"border-primary/20 border-t-primary",secondary:"border-muted-foreground/20 border-t-muted-foreground"};return o.jsx("div",{className:Y.cn(r,n),children:o.jsxs("div",{className:"flex flex-col items-center gap-3",children:[o.jsx("div",{className:Y.cn(s.md,i[e],"rounded-full animate-spin")}),o.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest text-primary animate-pulse",children:t})]})})},As=()=>o.jsx(Os,{text:"Synchronizing"}),Gn=({event:e,style:t,onClick:n,onDoubleClick:r,onDelete:s,orientation:i="vertical",resizable:l=!1,className:d,showTime:f=!0,isBlocked:g=!1,isPast:u=!1,isHighlighted:c=!1,slotDuration:N=30,pixelsPerSlot:p})=>{const h=g||e.isBlock,_=h||u,{attributes:P,listeners:G,setNodeRef:D,transform:H,isDragging:z}=_e.useDraggable({id:e.id,data:e,disabled:_}),se=p||(i==="vertical"?64:80),{attributes:y,listeners:k,setNodeRef:M,transform:v,isDragging:K}=_e.useDraggable({id:`resize-bottom-${e.id}`,data:{type:"resize-bottom",eventId:e.id,orientation:i,pixelsPerSlot:se},disabled:!l||_}),{attributes:$,listeners:q,setNodeRef:De,transform:X,isDragging:ne}=_e.useDraggable({id:`resize-top-${e.id}`,data:{type:"resize-top",eventId:e.id,orientation:i,pixelsPerSlot:se},disabled:!l||_}),Me=K||ne,me=se/N;let Se=new Date(e.start),ie=new Date(e.end);if(z&&H){const F=i==="vertical"?H.y:H.x,R=Math.round(F/me/15)*15;Se=Je(Se,R),ie=Je(ie,R)}else if(ne&&X){const F=i==="vertical"?X.y:X.x,R=Math.round(F/me/15)*15;Se=Je(Se,R)}else if(K&&v){const F=i==="vertical"?v.y:v.x,R=Math.round(F/me/15)*15;ie=Je(ie,R)}const ue=t?.borderColor||e.color||"hsl(var(--primary))",Z=h?{backgroundImage:"repeating - linear - gradient(45deg, transparent, transparent 10px, rgba(0, 0, 0, 0.05) 10px, rgba(0, 0, 0, 0.05) 20px)",backgroundColor:"rgba(0,0,0,0.02)",color:"gray",borderLeftWidth:"4px",borderColor:"#d1d5db",borderStyle:"solid",opacity:1}:{},he={...t,transform:_e.CSS.Translate.toString(H),opacity:z?.6:u?.7:1,zIndex:z||Me?100:_?10:20,touchAction:"none",pointerEvents:z||Me?"none":"auto",position:"absolute",backgroundColor:`color-mix(in srgb, ${ue} 12%, transparent)`,color:`color-mix(in srgb, ${ue} 90%, black)`,borderLeftWidth:"4px",borderColor:ue,...h?Z:{},...K&&i==="vertical"&&v?{height:`${Math.max((parseInt(t?.height)||0)+v.y,24)}px`}:{},...ne&&i==="vertical"&&X?{top:`${(parseInt(t?.top)||0)+X.y}px`,height:`${Math.max((parseInt(t?.height)||0)-X.y,24)}px`}:{},...K&&i==="horizontal"&&v?{width:`${Math.max((parseInt(t?.width)||0)+v.x,24)}px`}:{},...ne&&i==="horizontal"&&X?{left:`${(parseInt(t?.left)||0)+X.x}px`,width:`${Math.max((parseInt(t?.width)||0)-X.x,24)}px`}:{}},ee=o.jsxs("div",{ref:D,style:he,...P,...G,className:Y.cn("absolute rounded-md text-xs border overflow-hidden group select-none flex flex-col","bg-primary/10 border-primary/20 text-foreground shadow-sm hover:shadow-md transition-shadow",z&&"opacity-50 z-50 shadow-xl scale-105 cursor-grabbing ring-2 ring-primary ring-offset-2",c&&"ring-2 ring-primary ring-offset-1 bg-primary/20 shadow-md transition-all duration-300",h&&"bg-muted/50 border-muted opacity-80",!h&&"pointer-events-auto",h&&"pointer-events-auto select-none grayscale",d),onClick:F=>{!z&&!Me&&(F.stopPropagation(),n?.(e))},onDoubleClick:F=>{F.stopPropagation(),r?.(e)},role:"button","aria-label":`Event: ${e.title}`,children:[o.jsxs("div",{className:"flex-1 min-h-0 relative px-2 py-1",children:[o.jsxs("div",{className:"flex items-start justify-between gap-1",children:[o.jsx("div",{className:"font-semibold truncate pr-4 leading-tight",children:e.title}),!h&&o.jsx("button",{className:"opacity-0 group-hover:opacity-100 transition-opacity p-0.5 hover:bg-destructive/10 rounded absolute top-0 right-0 z-10",onClick:F=>{F.stopPropagation(),s?.(e.id)},onPointerDown:F=>F.stopPropagation(),children:o.jsx(Ke.X,{className:"h-3 w-3 text-muted-foreground hover:text-destructive"})})]}),f&&!h&&o.jsxs("div",{className:"text-[10px] text-muted-foreground truncate leading-tight",children:[de(Se,"h:mm a")," - ",de(ie,"h:mm a")]}),e.description&&o.jsx("div",{className:"text-[10px] text-muted-foreground line-clamp-2 leading-tight mt-0.5",children:e.description}),h&&o.jsx("div",{className:"flex items-center justify-center h-full",children:o.jsx("span",{className:"text-xs font-medium text-muted-foreground opacity-70 -rotate-45 select-none",children:"BLOCKED"})})]}),l&&!h&&o.jsxs(o.Fragment,{children:[o.jsx("div",{ref:M,...y,...k,className:Y.cn("absolute z-20 hover:bg-primary/20 transition-colors flex items-center justify-center opacity-0 group-hover:opacity-100",i==="vertical"?"bottom-0 left-0 right-0 h-3 cursor-ns-resize":"right-0 top-0 bottom-0 w-3 cursor-ew-resize"),style:{touchAction:"none"},children:o.jsx("div",{className:Y.cn("bg-primary/40 rounded-full",i==="vertical"?"w-10 h-1":"h-10 w-1")})}),o.jsx("div",{ref:De,...$,...q,className:Y.cn("absolute z-20 hover:bg-primary/20 transition-colors flex items-center justify-center opacity-0 group-hover:opacity-100",i==="vertical"?"top-0 left-0 right-0 h-3 cursor-ns-resize":"left-0 top-0 bottom-0 w-3 cursor-ew-resize"),style:{touchAction:"none"},children:o.jsx("div",{className:Y.cn("bg-primary/40 rounded-full",i==="vertical"?"w-10 h-1 shadow-[0_-1px_0_rgba(0,0,0,0.1)]":"h-10 w-1 shadow-[-1px_0_0_rgba(0,0,0,0.1)]")})})]})]});return o.jsx(Re.TooltipWrapper,{content:e.description,enabled:!!e.description&&!z,children:o.jsx(_e.EzContextMenu,{contextId:"scheduler-event",data:e,children:ee})})},Is=({date:e,resourceId:t,children:n,className:r,style:s,onClick:i,onDoubleClick:l,onMouseDown:d,onMouseEnter:f,onContextMenu:g,data:u,isSelected:c,isWorkHour:N})=>{const{active:p}=_e.useDndContext(),{setNodeRef:h,isOver:_}=_e.useDroppable({id:`slot-${e.toISOString()}-${t||"none"}`,data:{date:e,resourceId:t,...u||{}}}),P=!!p;return o.jsx("div",{ref:h,"data-testid":"scheduler-slot","data-shaded":N===!1,className:Y.cn("relative transition-all duration-200",c&&"bg-primary/15",!c&&N===!1&&"bg-background",P&&"before:absolute before:inset-0 before:border before:border-dashed before:border-primary/10 before:pointer-events-none before:z-0",_&&"bg-primary/20 ring-2 ring-primary ring-inset z-10 before:opacity-0",r),style:s,onClick:i,onDoubleClick:l,onMouseDown:d,onMouseEnter:f,onContextMenu:g,children:n})};const{entries:qn,setPrototypeOf:yn,isFrozen:Rs,getPrototypeOf:js,getOwnPropertyDescriptor:Ps}=Object;let{freeze:Ce,seal:Fe,create:$t}=Object,{apply:Gt,construct:qt}=typeof Reflect<"u"&&Reflect;Ce||(Ce=function(t){return t});Fe||(Fe=function(t){return t});Gt||(Gt=function(t,n){for(var r=arguments.length,s=new Array(r>2?r-2:0),i=2;i<r;i++)s[i-2]=arguments[i];return t.apply(n,s)});qt||(qt=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return new t(...r)});const Tt=Oe(Array.prototype.forEach),Ls=Oe(Array.prototype.lastIndexOf),Sn=Oe(Array.prototype.pop),pt=Oe(Array.prototype.push),zs=Oe(Array.prototype.splice),Nt=Oe(String.prototype.toLowerCase),jt=Oe(String.prototype.toString),Pt=Oe(String.prototype.match),xt=Oe(String.prototype.replace),Fs=Oe(String.prototype.indexOf),Ws=Oe(String.prototype.trim),Be=Oe(Object.prototype.hasOwnProperty),Ne=Oe(RegExp.prototype.test),bt=Hs(TypeError);function Oe(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return Gt(e,t,r)}}function Hs(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return qt(e,n)}}function Q(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Nt;yn&&yn(e,null);let r=t.length;for(;r--;){let s=t[r];if(typeof s=="string"){const i=n(s);i!==s&&(Rs(t)||(t[r]=i),s=i)}e[s]=!0}return e}function Bs(e){for(let t=0;t<e.length;t++)Be(e,t)||(e[t]=null);return e}function Ge(e){const t=$t(null);for(const[n,r]of qn(e))Be(e,n)&&(Array.isArray(r)?t[n]=Bs(r):r&&typeof r=="object"&&r.constructor===Object?t[n]=Ge(r):t[n]=r);return t}function wt(e,t){for(;e!==null;){const r=Ps(e,t);if(r){if(r.get)return Oe(r.get);if(typeof r.value=="function")return Oe(r.value)}e=js(e)}function n(){return null}return n}const vn=Ce(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Lt=Ce(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),zt=Ce(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Us=Ce(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Ft=Ce(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Ys=Ce(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),En=Ce(["#text"]),kn=Ce(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),Wt=Ce(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Tn=Ce(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Dt=Ce(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),$s=Fe(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Gs=Fe(/<%[\w\W]*|[\w\W]*%>/gm),qs=Fe(/\$\{[\w\W]*/gm),Vs=Fe(/^data-[\-\w.\u00B7-\uFFFF]+$/),Qs=Fe(/^aria-[\-\w]+$/),Vn=Fe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Xs=Fe(/^(?:\w+script|data):/i),Ks=Fe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Qn=Fe(/^html$/i),Js=Fe(/^[a-z][.\w]*(-[.\w]+)+$/i);var Dn=Object.freeze({__proto__:null,ARIA_ATTR:Qs,ATTR_WHITESPACE:Ks,CUSTOM_ELEMENT:Js,DATA_ATTR:Vs,DOCTYPE_NAME:Qn,ERB_EXPR:Gs,IS_ALLOWED_URI:Vn,IS_SCRIPT_OR_DATA:Xs,MUSTACHE_EXPR:$s,TMPLIT_EXPR:qs});const yt={element:1,text:3,progressingInstruction:7,comment:8,document:9},Zs=function(){return typeof window>"u"?null:window},eo=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const s="data-tt-policy-suffix";n&&n.hasAttribute(s)&&(r=n.getAttribute(s));const i="dompurify"+(r?"#"+r:"");try{return t.createPolicy(i,{createHTML(l){return l},createScriptURL(l){return l}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},Mn=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Xn(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Zs();const t=O=>Xn(O);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==yt.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const r=n,s=r.currentScript,{DocumentFragment:i,HTMLTemplateElement:l,Node:d,Element:f,NodeFilter:g,NamedNodeMap:u=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:c,DOMParser:N,trustedTypes:p}=e,h=f.prototype,_=wt(h,"cloneNode"),P=wt(h,"remove"),G=wt(h,"nextSibling"),D=wt(h,"childNodes"),H=wt(h,"parentNode");if(typeof l=="function"){const O=n.createElement("template");O.content&&O.content.ownerDocument&&(n=O.content.ownerDocument)}let z,se="";const{implementation:y,createNodeIterator:k,createDocumentFragment:M,getElementsByTagName:v}=n,{importNode:K}=r;let $=Mn();t.isSupported=typeof qn=="function"&&typeof H=="function"&&y&&y.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:q,ERB_EXPR:De,TMPLIT_EXPR:X,DATA_ATTR:ne,ARIA_ATTR:Me,IS_SCRIPT_OR_DATA:me,ATTR_WHITESPACE:Se,CUSTOM_ELEMENT:ie}=Dn;let{IS_ALLOWED_URI:ue}=Dn,Z=null;const he=Q({},[...vn,...Lt,...zt,...Ft,...En]);let ee=null;const F=Q({},[...kn,...Wt,...Tn,...Dt]);let R=Object.seal($t(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),We=null,we=null;const Pe=Object.seal($t(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let S=!0,B=!0,V=!1,le=!0,ae=!1,Ze=!0,He=!1,Ue=!1,Le=!1,x=!1,A=!1,w=!1,C=!0,E=!1;const I="user-content-";let W=!0,U=!1,j={},L=null;const te=Q({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let J=null;const ve=Q({},["audio","video","img","source","image","track"]);let ge=null;const Ye=Q({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),rt="http://www.w3.org/1998/Math/MathML",qe="http://www.w3.org/2000/svg",pe="http://www.w3.org/1999/xhtml";let et=pe,ft=!1,Ee=null;const st=Q({},[rt,qe,pe],jt);let Et=Q({},["mi","mo","mn","ms","mtext"]),kt=Q({},["annotation-xml"]);const er=Q({},["title","style","font","a","script"]);let mt=null;const tr=["application/xhtml+xml","text/html"],nr="text/html";let ye=null,it=null;const rr=n.createElement("form"),en=function(a){return a instanceof RegExp||a instanceof Function},Ct=function(){let a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(it&&it===a)){if((!a||typeof a!="object")&&(a={}),a=Ge(a),mt=tr.indexOf(a.PARSER_MEDIA_TYPE)===-1?nr:a.PARSER_MEDIA_TYPE,ye=mt==="application/xhtml+xml"?jt:Nt,Z=Be(a,"ALLOWED_TAGS")?Q({},a.ALLOWED_TAGS,ye):he,ee=Be(a,"ALLOWED_ATTR")?Q({},a.ALLOWED_ATTR,ye):F,Ee=Be(a,"ALLOWED_NAMESPACES")?Q({},a.ALLOWED_NAMESPACES,jt):st,ge=Be(a,"ADD_URI_SAFE_ATTR")?Q(Ge(Ye),a.ADD_URI_SAFE_ATTR,ye):Ye,J=Be(a,"ADD_DATA_URI_TAGS")?Q(Ge(ve),a.ADD_DATA_URI_TAGS,ye):ve,L=Be(a,"FORBID_CONTENTS")?Q({},a.FORBID_CONTENTS,ye):te,We=Be(a,"FORBID_TAGS")?Q({},a.FORBID_TAGS,ye):Ge({}),we=Be(a,"FORBID_ATTR")?Q({},a.FORBID_ATTR,ye):Ge({}),j=Be(a,"USE_PROFILES")?a.USE_PROFILES:!1,S=a.ALLOW_ARIA_ATTR!==!1,B=a.ALLOW_DATA_ATTR!==!1,V=a.ALLOW_UNKNOWN_PROTOCOLS||!1,le=a.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ae=a.SAFE_FOR_TEMPLATES||!1,Ze=a.SAFE_FOR_XML!==!1,He=a.WHOLE_DOCUMENT||!1,x=a.RETURN_DOM||!1,A=a.RETURN_DOM_FRAGMENT||!1,w=a.RETURN_TRUSTED_TYPE||!1,Le=a.FORCE_BODY||!1,C=a.SANITIZE_DOM!==!1,E=a.SANITIZE_NAMED_PROPS||!1,W=a.KEEP_CONTENT!==!1,U=a.IN_PLACE||!1,ue=a.ALLOWED_URI_REGEXP||Vn,et=a.NAMESPACE||pe,Et=a.MATHML_TEXT_INTEGRATION_POINTS||Et,kt=a.HTML_INTEGRATION_POINTS||kt,R=a.CUSTOM_ELEMENT_HANDLING||{},a.CUSTOM_ELEMENT_HANDLING&&en(a.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(R.tagNameCheck=a.CUSTOM_ELEMENT_HANDLING.tagNameCheck),a.CUSTOM_ELEMENT_HANDLING&&en(a.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(R.attributeNameCheck=a.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),a.CUSTOM_ELEMENT_HANDLING&&typeof a.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(R.allowCustomizedBuiltInElements=a.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),ae&&(B=!1),A&&(x=!0),j&&(Z=Q({},En),ee=[],j.html===!0&&(Q(Z,vn),Q(ee,kn)),j.svg===!0&&(Q(Z,Lt),Q(ee,Wt),Q(ee,Dt)),j.svgFilters===!0&&(Q(Z,zt),Q(ee,Wt),Q(ee,Dt)),j.mathMl===!0&&(Q(Z,Ft),Q(ee,Tn),Q(ee,Dt))),a.ADD_TAGS&&(typeof a.ADD_TAGS=="function"?Pe.tagCheck=a.ADD_TAGS:(Z===he&&(Z=Ge(Z)),Q(Z,a.ADD_TAGS,ye))),a.ADD_ATTR&&(typeof a.ADD_ATTR=="function"?Pe.attributeCheck=a.ADD_ATTR:(ee===F&&(ee=Ge(ee)),Q(ee,a.ADD_ATTR,ye))),a.ADD_URI_SAFE_ATTR&&Q(ge,a.ADD_URI_SAFE_ATTR,ye),a.FORBID_CONTENTS&&(L===te&&(L=Ge(L)),Q(L,a.FORBID_CONTENTS,ye)),a.ADD_FORBID_CONTENTS&&(L===te&&(L=Ge(L)),Q(L,a.ADD_FORBID_CONTENTS,ye)),W&&(Z["#text"]=!0),He&&Q(Z,["html","head","body"]),Z.table&&(Q(Z,["tbody"]),delete We.tbody),a.TRUSTED_TYPES_POLICY){if(typeof a.TRUSTED_TYPES_POLICY.createHTML!="function")throw bt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof a.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw bt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');z=a.TRUSTED_TYPES_POLICY,se=z.createHTML("")}else z===void 0&&(z=eo(p,s)),z!==null&&typeof se=="string"&&(se=z.createHTML(""));Ce&&Ce(a),it=a}},tn=Q({},[...Lt,...zt,...Us]),nn=Q({},[...Ft,...Ys]),sr=function(a){let m=H(a);(!m||!m.tagName)&&(m={namespaceURI:et,tagName:"template"});const T=Nt(a.tagName),ce=Nt(m.tagName);return Ee[a.namespaceURI]?a.namespaceURI===qe?m.namespaceURI===pe?T==="svg":m.namespaceURI===rt?T==="svg"&&(ce==="annotation-xml"||Et[ce]):!!tn[T]:a.namespaceURI===rt?m.namespaceURI===pe?T==="math":m.namespaceURI===qe?T==="math"&&kt[ce]:!!nn[T]:a.namespaceURI===pe?m.namespaceURI===qe&&!kt[ce]||m.namespaceURI===rt&&!Et[ce]?!1:!nn[T]&&(er[T]||!tn[T]):!!(mt==="application/xhtml+xml"&&Ee[a.namespaceURI]):!1},$e=function(a){pt(t.removed,{element:a});try{H(a).removeChild(a)}catch{P(a)}},ot=function(a,m){try{pt(t.removed,{attribute:m.getAttributeNode(a),from:m})}catch{pt(t.removed,{attribute:null,from:m})}if(m.removeAttribute(a),a==="is")if(x||A)try{$e(m)}catch{}else try{m.setAttribute(a,"")}catch{}},rn=function(a){let m=null,T=null;if(Le)a="<remove></remove>"+a;else{const xe=Pt(a,/^[\r\n\t ]+/);T=xe&&xe[0]}mt==="application/xhtml+xml"&&et===pe&&(a='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+a+"</body></html>");const ce=z?z.createHTML(a):a;if(et===pe)try{m=new N().parseFromString(ce,mt)}catch{}if(!m||!m.documentElement){m=y.createDocument(et,"template",null);try{m.documentElement.innerHTML=ft?se:ce}catch{}}const Te=m.body||m.documentElement;return a&&T&&Te.insertBefore(n.createTextNode(T),Te.childNodes[0]||null),et===pe?v.call(m,He?"html":"body")[0]:He?m.documentElement:Te},sn=function(a){return k.call(a.ownerDocument||a,a,g.SHOW_ELEMENT|g.SHOW_COMMENT|g.SHOW_TEXT|g.SHOW_PROCESSING_INSTRUCTION|g.SHOW_CDATA_SECTION,null)},Ot=function(a){return a instanceof c&&(typeof a.nodeName!="string"||typeof a.textContent!="string"||typeof a.removeChild!="function"||!(a.attributes instanceof u)||typeof a.removeAttribute!="function"||typeof a.setAttribute!="function"||typeof a.namespaceURI!="string"||typeof a.insertBefore!="function"||typeof a.hasChildNodes!="function")},on=function(a){return typeof d=="function"&&a instanceof d};function Ve(O,a,m){Tt(O,T=>{T.call(t,a,m,it)})}const an=function(a){let m=null;if(Ve($.beforeSanitizeElements,a,null),Ot(a))return $e(a),!0;const T=ye(a.nodeName);if(Ve($.uponSanitizeElement,a,{tagName:T,allowedTags:Z}),Ze&&a.hasChildNodes()&&!on(a.firstElementChild)&&Ne(/<[/\w!]/g,a.innerHTML)&&Ne(/<[/\w!]/g,a.textContent)||a.nodeType===yt.progressingInstruction||Ze&&a.nodeType===yt.comment&&Ne(/<[/\w]/g,a.data))return $e(a),!0;if(!(Pe.tagCheck instanceof Function&&Pe.tagCheck(T))&&(!Z[T]||We[T])){if(!We[T]&&ln(T)&&(R.tagNameCheck instanceof RegExp&&Ne(R.tagNameCheck,T)||R.tagNameCheck instanceof Function&&R.tagNameCheck(T)))return!1;if(W&&!L[T]){const ce=H(a)||a.parentNode,Te=D(a)||a.childNodes;if(Te&&ce){const xe=Te.length;for(let Ae=xe-1;Ae>=0;--Ae){const Qe=_(Te[Ae],!0);Qe.__removalCount=(a.__removalCount||0)+1,ce.insertBefore(Qe,G(a))}}}return $e(a),!0}return a instanceof f&&!sr(a)||(T==="noscript"||T==="noembed"||T==="noframes")&&Ne(/<\/no(script|embed|frames)/i,a.innerHTML)?($e(a),!0):(ae&&a.nodeType===yt.text&&(m=a.textContent,Tt([q,De,X],ce=>{m=xt(m,ce," ")}),a.textContent!==m&&(pt(t.removed,{element:a.cloneNode()}),a.textContent=m)),Ve($.afterSanitizeElements,a,null),!1)},cn=function(a,m,T){if(C&&(m==="id"||m==="name")&&(T in n||T in rr))return!1;if(!(B&&!we[m]&&Ne(ne,m))){if(!(S&&Ne(Me,m))){if(!(Pe.attributeCheck instanceof Function&&Pe.attributeCheck(m,a))){if(!ee[m]||we[m]){if(!(ln(a)&&(R.tagNameCheck instanceof RegExp&&Ne(R.tagNameCheck,a)||R.tagNameCheck instanceof Function&&R.tagNameCheck(a))&&(R.attributeNameCheck instanceof RegExp&&Ne(R.attributeNameCheck,m)||R.attributeNameCheck instanceof Function&&R.attributeNameCheck(m,a))||m==="is"&&R.allowCustomizedBuiltInElements&&(R.tagNameCheck instanceof RegExp&&Ne(R.tagNameCheck,T)||R.tagNameCheck instanceof Function&&R.tagNameCheck(T))))return!1}else if(!ge[m]){if(!Ne(ue,xt(T,Se,""))){if(!((m==="src"||m==="xlink:href"||m==="href")&&a!=="script"&&Fs(T,"data:")===0&&J[a])){if(!(V&&!Ne(me,xt(T,Se,"")))){if(T)return!1}}}}}}}return!0},ln=function(a){return a!=="annotation-xml"&&Pt(a,ie)},dn=function(a){Ve($.beforeSanitizeAttributes,a,null);const{attributes:m}=a;if(!m||Ot(a))return;const T={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ee,forceKeepAttr:void 0};let ce=m.length;for(;ce--;){const Te=m[ce],{name:xe,namespaceURI:Ae,value:Qe}=Te,ct=ye(xe),At=Qe;let ke=xe==="value"?At:Ws(At);if(T.attrName=ct,T.attrValue=ke,T.keepAttr=!0,T.forceKeepAttr=void 0,Ve($.uponSanitizeAttribute,a,T),ke=T.attrValue,E&&(ct==="id"||ct==="name")&&(ot(xe,a),ke=I+ke),Ze&&Ne(/((--!?|])>)|<\/(style|title|textarea)/i,ke)){ot(xe,a);continue}if(ct==="attributename"&&Pt(ke,"href")){ot(xe,a);continue}if(T.forceKeepAttr)continue;if(!T.keepAttr){ot(xe,a);continue}if(!le&&Ne(/\/>/i,ke)){ot(xe,a);continue}ae&&Tt([q,De,X],fn=>{ke=xt(ke,fn," ")});const un=ye(a.nodeName);if(!cn(un,ct,ke)){ot(xe,a);continue}if(z&&typeof p=="object"&&typeof p.getAttributeType=="function"&&!Ae)switch(p.getAttributeType(un,ct)){case"TrustedHTML":{ke=z.createHTML(ke);break}case"TrustedScriptURL":{ke=z.createScriptURL(ke);break}}if(ke!==At)try{Ae?a.setAttributeNS(Ae,xe,ke):a.setAttribute(xe,ke),Ot(a)?$e(a):Sn(t.removed)}catch{ot(xe,a)}}Ve($.afterSanitizeAttributes,a,null)},or=function O(a){let m=null;const T=sn(a);for(Ve($.beforeSanitizeShadowDOM,a,null);m=T.nextNode();)Ve($.uponSanitizeShadowNode,m,null),an(m),dn(m),m.content instanceof i&&O(m.content);Ve($.afterSanitizeShadowDOM,a,null)};return t.sanitize=function(O){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},m=null,T=null,ce=null,Te=null;if(ft=!O,ft&&(O="<!-->"),typeof O!="string"&&!on(O))if(typeof O.toString=="function"){if(O=O.toString(),typeof O!="string")throw bt("dirty is not a string, aborting")}else throw bt("toString is not a function");if(!t.isSupported)return O;if(Ue||Ct(a),t.removed=[],typeof O=="string"&&(U=!1),U){if(O.nodeName){const Qe=ye(O.nodeName);if(!Z[Qe]||We[Qe])throw bt("root node is forbidden and cannot be sanitized in-place")}}else if(O instanceof d)m=rn("<!---->"),T=m.ownerDocument.importNode(O,!0),T.nodeType===yt.element&&T.nodeName==="BODY"||T.nodeName==="HTML"?m=T:m.appendChild(T);else{if(!x&&!ae&&!He&&O.indexOf("<")===-1)return z&&w?z.createHTML(O):O;if(m=rn(O),!m)return x?null:w?se:""}m&&Le&&$e(m.firstChild);const xe=sn(U?O:m);for(;ce=xe.nextNode();)an(ce),dn(ce),ce.content instanceof i&&or(ce.content);if(U)return O;if(x){if(A)for(Te=M.call(m.ownerDocument);m.firstChild;)Te.appendChild(m.firstChild);else Te=m;return(ee.shadowroot||ee.shadowrootmode)&&(Te=K.call(r,Te,!0)),Te}let Ae=He?m.outerHTML:m.innerHTML;return He&&Z["!doctype"]&&m.ownerDocument&&m.ownerDocument.doctype&&m.ownerDocument.doctype.name&&Ne(Qn,m.ownerDocument.doctype.name)&&(Ae="<!DOCTYPE "+m.ownerDocument.doctype.name+`>
|
|
2
|
-
`+Ae),ae&&Tt([q,De,X],Qe=>{Ae=xt(Ae,Qe," ")}),z&&w?z.createHTML(Ae):Ae},t.setConfig=function(){let O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ct(O),Ue=!0},t.clearConfig=function(){it=null,Ue=!1},t.isValidAttribute=function(O,a,m){it||Ct({});const T=ye(O),ce=ye(a);return cn(T,ce,m)},t.addHook=function(O,a){typeof a=="function"&&pt($[O],a)},t.removeHook=function(O,a){if(a!==void 0){const m=Ls($[O],a);return m===-1?void 0:zs($[O],m,1)[0]}return Sn($[O])},t.removeHooks=function(O){$[O]=[]},t.removeAllHooks=function(){$=Mn()},t}var to=Xn();function Nn(e,t=!0){return t?to.sanitize(e,{ALLOWED_TAGS:["b","i","em","strong","u","span","div","p","br","h1","h2","h3","h4","h5","h6","ul","ol","li","a","img","table","thead","tbody","tr","th","td"],ALLOWED_ATTR:["class","style","href","src","alt","title"],ALLOW_DATA_ATTR:!1}):e}function no(e,t,n=!0){if(!e)return null;if(typeof e=="function"){const r=e(t);return typeof r=="string"?{__html:Nn(r,n)}:r}return typeof e=="string"?{__html:Nn(e,n)}:null}function ro(e,t="FirstDay"){switch(t){case"FirstDay":return St(e,{weekStartsOn:0});case"FirstFourDayWeek":return Jt(e);case"FirstFullWeek":return St(e,{weekStartsOn:0,firstWeekContainsDate:1});default:return St(e)}}const so=(e,t,n,r,s,i,l,d,f,g=!0,u=!1)=>{let c=0,N=0;if(g){const G=s/r,D=G/l;c=t*s+n*G+i*D,N=D*.98}else{const G=s/r,D=G/l;c=n*s+t*G+i*D,N=D*.98}const h=((e.start.getHours()-d)*60+e.start.getMinutes())/f*64,P=(e.end.getTime()-e.start.getTime())/(1e3*60)/f*64;return{top:`${h}px`,height:`${Math.max(P,24)}px`,[u?"right":"left"]:`${c}%`,width:`${N}%`,[u?"borderRightWidth":"borderLeftWidth"]:"4px",borderColor:e.color||"hsl(var(--primary))"}},oo=({startHour:e,slotDuration:t,isRtl:n})=>{const r=Qt(),i=((r.getHours()-e)*60+r.getMinutes())/t*64;return i<0?null:o.jsxs("div",{className:Y.cn("absolute inset-x-0 z-50 pointer-events-none flex items-center"),style:{top:`${i}px`},children:[o.jsx("div",{className:"w-full border-t-2 border-primary"}),o.jsx("div",{className:Y.cn("absolute w-3 h-3 bg-primary rounded-full shadow-sm ring-2 ring-background",n?"-right-1.5":"-left-1.5")})]})},ao=({daysInView:e,visibleEvents:t,rowVirtualizer:n,resources:r=[],showResourcesInDayView:s=!1,onEventClick:i,onEventDoubleClick:l,onEventDelete:d,scrollRef:f,onViewChange:g,onDateChange:u,locale:c,onRangeSelect:N,onSlotClick:p,onSlotDoubleClick:h,dateHeaderTemplate:_,showWeekNumber:P=!1,weekRule:G="FirstDay",cellTemplate:D,enableHtmlSanitizer:H=!0,showUnassignedLane:z=!1,startHour:se="00:00",slotDuration:y=30,is24Hour:k=!0,setIs24Hour:M,group:v,onCellContextMenu:K,dir:$})=>{const q=$==="rtl",De=Qt(),X=parseInt(se.split(":")[0],10),[ne,Me]=b.useState(null),[me,Se]=b.useState(!1),ie=b.useRef(null),ue=(w,C,E)=>t.some(W=>(W.isHoliday||W.isFullyBooked)&&fe(W.start,w))?!0:t.some(W=>W.isBlock&&(W.resourceId===E||!W.resourceId&&!E)&&Mt({start:W.start,end:W.end},{start:w,end:C})),Z=(w,C)=>{const E=Je(w,y);if(ue(w,E,C))return;Se(!0);const I={start:w,end:E,resourceId:C};Me(I),ie.current=I},he=w=>{if(!me||!ie.current)return;const C=new Date(w.getTime()+y*60*1e3),E={...ie.current,end:C};Me(E),ie.current=E};b.useEffect(()=>{const w=C=>{if(me&&ie.current){const{start:E,end:I,resourceId:W}=ie.current,U=E<I?E:I,j=E<I?I:E;ue(U,j,W)||(N?.(U,j,W,{x:C.clientX,y:C.clientY}),p?.(U,W))}Se(!1),Me(null),ie.current=null};return window.addEventListener("mouseup",w),()=>window.removeEventListener("mouseup",w)},[me,N,p]);const ee=Vt("(max-width: 768px)"),F=b.useMemo(()=>{let w=s&&r.length>0?[...r]:[];return(z||s&&w.length===0)&&(w.find(C=>C.id===""||C.id==="unassigned")||w.unshift({id:"unassigned",name:"Unassigned",type:"Global Inbox",color:"hsl(var(--muted-foreground))"})),w.length>0?w:[{id:"",name:""}]},[r,s,z]),R=ee&&s&&F.length>1,We=!ee&&(F.length>3||e.length>3&&F.length>1),we=R||We,B=e.length*F.length*150,V={width:we&&B>0?`${B}px`:"100%",minWidth:"100%"},le=new Intl.DateTimeFormat(c,{day:"numeric"}),ae=v?.byDate??!0,Ze=ae?e:F,He=ae?F:e,Ue=Ze,Le=He,x=100/Ue.length,A=100/Le.length;return o.jsxs("div",{ref:f,"data-testid":"scheduler-scroll-container","data-view":"day-week",style:{scrollbarGutter:"stable"},className:Y.cn("flex-1 flex flex-col min-h-0 relative overflow-auto bg-background select-none border border-border rounded-lg",we&&"snap-x snap-mandatory"),children:[o.jsxs("div",{className:"sticky top-0 z-50 bg-background/95 backdrop-blur-md border-b border-border flex shrink-0",style:V,children:[P&&o.jsx("div",{className:Y.cn("w-12 shrink-0 sticky z-50 bg-background border-e border-border flex items-center justify-center",q?"right-0":"left-0"),children:o.jsx("span",{className:"text-[9px] font-bold text-muted-foreground uppercase tracking-wider",children:"WK"})}),o.jsxs("div",{className:Y.cn("w-24 shrink-0 sticky bg-background border-e border-border z-50 cursor-pointer hover:bg-muted/50 transition-colors flex flex-col items-center justify-center gap-1 group",P?q?"right-12":"left-12":q?"right-0":"left-0"),onClick:()=>M?.(!k),title:"Toggle 24h / AM-PM format",children:[o.jsx(_n,{className:"w-4 h-4 text-muted-foreground group-hover:text-primary transition-colors"}),o.jsx("span",{className:"text-[9px] font-bold uppercase text-muted-foreground/60 group-hover:text-primary/70",children:k?"24 Hours":"AM / PM"})]}),o.jsx("div",{className:"flex flex-1",style:we?{width:"100%"}:void 0,children:Ue.map(w=>{const C=ae,E=C?w:null,I=C?null:w,W=C&&fe(E,new Date);return o.jsxs("div",{style:{width:`${x}%`},className:"flex flex-col border-e border-border last:border-e-0",children:[o.jsx("div",{className:Y.cn("flex flex-col items-center justify-center py-3 transition-colors shrink-0 border-e-2 border-foreground/20",W&&"bg-background"),children:C?(()=>{const U=t.find(j=>(j.isHoliday||j.isFullyBooked)&&fe(j.start,E));return o.jsxs("div",{className:"flex flex-col items-center relative w-full",children:[U?.isHoliday&&o.jsx("span",{className:"absolute -top-1 px-1.5 py-0.5 bg-destructive/10 text-destructive text-[9px] font-black uppercase tracking-tighter rounded-full border border-destructive/20 mb-1 leading-none shadow-sm",children:"Holiday"}),U?.isFullyBooked&&o.jsx("span",{className:"absolute -top-1 px-1.5 py-0.5 bg-warning/10 text-warning-foreground text-[9px] font-black uppercase tracking-tighter rounded-full border border-warning/20 mb-1 leading-none shadow-sm",children:"Fully Booked"}),_?o.jsx("div",{className:"h-full w-full flex items-center justify-center pt-2",children:typeof _=="function"?_({date:E,type:"Day",text:le.format(E)}):_}):o.jsx("div",{className:"flex flex-col items-center cursor-pointer hover:bg-muted/50 transition-colors pt-2",onClick:()=>{g&&u&&(u(E),g("day"))},children:e.length>1&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:Y.cn("text-base font-medium mt-0.5",W?"text-primary font-bold":"text-foreground"),children:de(E,"dd MMM yyyy")}),o.jsx("span",{className:Y.cn("text-sm font-medium uppercase tracking-wider",W?"text-primary":"text-muted-foreground/80"),children:de(E,"EEE")})]})})]})})():o.jsxs("div",{className:"flex items-center gap-2 px-2",children:[o.jsxs(Xe.Avatar,{className:"h-8 w-8 shadow-sm border border-background",children:[I.avatar&&o.jsx(Xe.AvatarImage,{src:I.avatar}),o.jsx(Xe.AvatarFallback,{className:"text-xs font-bold",children:I.name?.charAt(0)})]}),o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{className:"text-sm font-bold truncate",children:I.name}),o.jsx("span",{className:"text-[10px] text-muted-foreground truncate",children:I.type||"Resource"})]})]})}),Le.length>0&&o.jsx("div",{className:"flex w-full border-t border-border bg-background h-10 shrink-0",children:Le.map((U,j)=>{const L=C?null:U,te=C?U:null,J=L?t.find(ge=>ge.isHoliday&&fe(ge.start,L)):null,ve=L?t.find(ge=>ge.isFullyBooked&&fe(ge.start,L)):null;return o.jsx("div",{style:{width:`${A}%`},className:Y.cn("flex items-center justify-center px-1 border-e border-border/30 last:border-e-0 group",we&&"snap-center",(j%2===0,"bg-background")),children:C?o.jsxs(o.Fragment,{children:[o.jsxs(Xe.Avatar,{className:"h-4 w-4 me-1 shadow-sm border border-background",children:[te.avatar&&o.jsx(Xe.AvatarImage,{src:te.avatar}),o.jsx(Xe.AvatarFallback,{className:"text-[7px] font-bold",children:te.name?.charAt(0)})]}),o.jsx("span",{className:"text-[9px] font-bold text-muted-foreground truncate group-hover:text-foreground transition-colors",children:te.name})]}):o.jsxs("div",{className:"flex flex-col items-center justify-center",children:[J&&o.jsx("span",{className:"text-xs font-black uppercase tracking-wider text-destructive bg-destructive/10 px-2 py-0.5 rounded-sm mb-0.5",children:"Holiday"}),ve&&o.jsx("span",{className:"text-xs font-black uppercase tracking-wider text-warning-foreground bg-warning/10 px-2 py-0.5 rounded-sm mb-0.5",children:"Fully Booked"}),o.jsx("span",{className:Y.cn("text-[10px] font-bold text-muted-foreground uppercase",J&&"text-destructive",ve&&"text-amber-600"),children:de(L,"EEE d")})]})},L?L.toISOString():te.id)})})]},C?E.toISOString():I.id)})})]}),o.jsxs("div",{"data-testid":"scheduler-virtual-body",className:"relative shrink-0",style:{height:`${n.getTotalSize()}px`,...V},children:[n.getVirtualItems().map(w=>{const C=w.index*y,E=X+Math.floor(C/60),I=C%60;let W="";if(k)W=`${E<10?"0"+E:E}:${I<10?"0"+I:I}`;else{const U=E>=12?"PM":"AM",j=E%12||12;W=`${j<10?"0"+j:j}:${I<10?"0"+I:I} ${U}`}return o.jsxs("div",{className:"absolute left-0 w-full flex",style:{height:"64px",top:`${w.start}px`},children:[o.jsxs("div",{className:Y.cn("w-24 shrink-0 flex flex-col items-end justify-center pe-3 border-e border-border bg-background z-50 sticky backdrop-blur-md",q?"right-0":"left-0"),children:[W&&o.jsx("span",{className:"text-sm text-foreground font-black bg-background px-1 relative z-50 uppercase tracking-tighter tabular-nums",children:W}),P&&E===0&&o.jsxs("span",{className:"text-[9px] text-muted-foreground/60 font-semibold mt-1",children:["W",ro(e[0],G)]})]}),o.jsxs("div",{className:"flex flex-1 relative",style:{height:"64px"},children:[o.jsx("div",{className:"absolute bottom-0 left-0 w-full border-b border-border/40"}),o.jsx("div",{className:"absolute top-1/2 left-0 w-full border-b border-dashed border-border/20 h-px"}),Ue.map(U=>o.jsx("div",{style:{width:`${x}%`},className:"h-full flex relative border-e-2 border-foreground/20 last:border-e-0",children:Le.map((j,L)=>{const te=ae?U:j,J=ae?j:U,ve=w.index+X,ge=te.getDay(),Ye=t.find(Ee=>Ee.isHoliday&&fe(Ee.start,te)),rt=t.find(Ee=>Ee.isFullyBooked&&fe(Ee.start,te));let qe=!0;J.workingHours?qe=J.workingHours.days.includes(ge)&&ve>=J.workingHours.start&&ve<J.workingHours.end:qe=ge!==0&&ge!==6&&ve>=9&&ve<17;const pe=new Date(new Date(te).setHours(E,I,0,0)),et=fe(te,new Date),ft=!!ne&&ne.resourceId===J.id&&pe>=ne.start&&pe<ne.end;return o.jsx(Is,{date:pe,resourceId:J.id,isWorkHour:qe,isSelected:ft,onMouseDown:()=>Z(pe,J.id),onMouseEnter:()=>he(pe),onDoubleClick:()=>{const Ee=Je(pe,y);ue(pe,Ee,J.id)||h?.(pe,J.id)},onContextMenu:Ee=>{Ee.preventDefault(),K?.({date:pe,x:Ee.clientX,y:Ee.clientY})},style:{width:`${A}%`,minWidth:"auto",height:"100%"},className:Y.cn("border-e border-border/30 relative cursor-pointer hover:bg-primary/5 transition-colors pointer-events-auto",L===Le.length-1&&"border-e-0",we&&"snap-center",Ye&&"bg-[repeating-linear-gradient(-45deg,hsl(var(--destructive)/0.05)_0px,hsl(var(--destructive)/0.05)_10px,transparent_10px,transparent_20px)] bg-destructive/[0.02]",rt&&"bg-[repeating-linear-gradient(-45deg,theme(colors.warning/0.05)_0px,theme(colors.warning/0.05)_10px,transparent_10px,transparent_20px)] bg-warning/[0.02]",!Ye&&!rt&&"bg-background"),children:D?(()=>{const Ee={date:pe,resourceId:J.id,isWorkHour:qe,isToday:et},st=no(D,Ee,H);return st&&typeof st=="object"&&"__html"in st?o.jsx("div",{className:"w-full h-full",dangerouslySetInnerHTML:st}):o.jsx("div",{className:"w-full h-full",children:st})})():null},ae?J.id||L:te.toISOString()||L)})},ae?U.toISOString():U.id))]})]},w.index)}),o.jsxs("div",{className:"absolute top-0 h-full z-10",style:{width:"calc(100% - 6rem)",[q?"right":"left"]:"6rem",pointerEvents:"none"},children:[o.jsx(oo,{startHour:X,slotDuration:y,isRtl:q}),e.map((w,C)=>{const E=t.filter(W=>fe(w,W.start));E.sort((W,U)=>W.start.getTime()-U.start.getTime());const I=new Map;return E.forEach(W=>{let U=W.resourceId;!U&&z&&(U="unassigned");let j=F.findIndex(L=>L.id===U);if(j===-1)if(F.length===1&&(F[0].id===""||!s))j=0;else return;I.has(j)||I.set(j,[]),I.get(j).push(W)}),[...I.entries()].map(([W,U])=>{const j=[];return U.forEach(L=>{let te=!1;for(const J of j)if(J.some(ve=>Mt({start:ve.start,end:ve.end},{start:L.start,end:L.end}))){J.push(L),te=!0;break}te||j.push([L])}),j.map(L=>{const te=[];return L.forEach(J=>{let ve=!1;for(let ge=0;ge<te.length;ge++)if(!te[ge].some(Ye=>Mt({start:Ye.start,end:Ye.end},{start:J.start,end:J.end}))){te[ge].push(J),ve=!0;break}ve||te.push([J])}),L.map(J=>{const ve=te.findIndex(Ye=>Ye.includes(J)),ge=so(J,C,W,ae?F.length:e.length,x,ve,te.length,X,y,ae,q);return o.jsx(Gn,{event:J,style:ge,onClick:i,onDoubleClick:l,onDelete:d,orientation:"vertical",resizable:!0,isBlocked:J.isBlock,isPast:J.end<De,slotDuration:y,pixelsPerSlot:64},J.id)})})})})]})]})]})},io=({currentDate:e,daysInView:t,visibleEvents:n,onSlotClick:r,onSlotDoubleClick:s,onEventClick:i,moreEventsClick:l,dir:d})=>{const f=d==="rtl",g=u=>n.filter(c=>fe(c.start,u));return o.jsx(Ke.TooltipProvider,{children:o.jsxs("div",{className:"flex flex-col h-full w-full bg-background rounded-xl border border-border overflow-hidden shadow-sm",children:[o.jsx("div",{className:"grid grid-cols-7 border-b border-border bg-muted/30",children:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map((u,c)=>o.jsx("div",{className:"py-3 text-center text-xs font-semibold uppercase text-muted-foreground tracking-widest",children:u},c))}),o.jsx("div",{className:"grid grid-cols-7 grid-rows-6 flex-1 min-h-0 bg-muted/20 gap-px",children:t.map(u=>{const c=g(u).filter(D=>!D.isBlock),N=Bn(u,e),p=fe(u,new Date),h=4,_=c.slice(0,h),P=c.length-h,G=c.length;return o.jsxs("div",{onClick:()=>r?.(u),onDoubleClick:()=>s?.(u),className:Y.cn("relative flex flex-col p-2 transition-colors group bg-background focus-visible:z-10",!N&&"bg-muted/5 text-muted-foreground/50",N&&"hover:bg-muted/30","min-h-[100px]"),children:[o.jsxs("div",{className:Y.cn("flex items-center justify-between mb-1"),children:[o.jsx("span",{className:Y.cn("text-sm font-medium w-7 h-7 flex items-center justify-center rounded-full transition-all",p?"bg-primary text-primary-foreground shadow-sm font-bold scale-110":"text-foreground group-hover:bg-muted/50",!N&&"text-muted-foreground opacity-50"),children:de(u,"d")}),G>0&&o.jsx("span",{className:"text-[10px] text-muted-foreground font-medium px-1.5 py-0.5 rounded-full bg-muted/50",children:G})]}),o.jsxs("div",{className:"flex-1 flex flex-col gap-1.5 min-w-0",children:[_.map(D=>o.jsxs(Ke.Tooltip,{delayDuration:300,children:[o.jsx(Ke.TooltipTrigger,{asChild:!0,children:o.jsxs("div",{onClick:H=>{H.stopPropagation(),i?.(D)},className:Y.cn("group/event relative","flex items-center gap-2 px-2 py-1 rounded-md text-xs font-medium cursor-pointer transition-all shadow-sm hover:shadow-md border border-transparent hover:border-border/50 overflow-hidden bg-card hover:bg-accent/50",!N&&"opacity-60 grayscale"),style:{[f?"borderRight":"borderLeft"]:`3px solid ${D.color||"oklch(var(--primary))"}`},children:[o.jsx("div",{className:"flex-1 truncate leading-tight",children:D.title}),D.start&&o.jsx("span",{className:"text-[10px] text-muted-foreground/70 tabular-nums shrink-0",children:de(D.start,"h:mm a")})]})}),o.jsx(Ke.TooltipContent,{className:"p-3 max-w-xs bg-popover/95 backdrop-blur-sm border-border/50 shadow-xl",sideOffset:5,children:o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs("div",{className:"flex items-center gap-2 border-b border-border/50 pb-1.5",children:[o.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:D.color||"oklch(var(--primary))"}}),o.jsx("span",{className:"font-semibold text-sm truncate",children:D.title})]}),o.jsxs("div",{className:"text-xs text-muted-foreground space-y-0.5",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"font-medium text-foreground/80",children:"Time:"}),o.jsxs("span",{children:[de(D.start,"MMM d, h:mm a")," - ",de(D.end,"h:mm a")]})]}),D.location&&o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"font-medium text-foreground/80",children:"Location:"}),o.jsx("span",{children:D.location})]}),D.description&&o.jsx("div",{className:"pt-1 mt-1 border-t border-border/30 text-muted-foreground/80 line-clamp-3",children:D.description})]})]})})]},D.id)),P>0&&o.jsxs("button",{onClick:D=>{D.stopPropagation(),l?.({date:u})},className:"mt-auto self-start text-[10px] bg-muted/50 hover:bg-muted text-muted-foreground hover:text-foreground font-medium px-2 py-1 rounded-md transition-colors w-full text-left",children:["+",P," more"]})]})]},u.toISOString())})})]})})},co=({view:e,daysInView:t,visibleEvents:n,resources:r=[],onSlotClick:s,onSlotDoubleClick:i,onEventClick:l,onEventDelete:d,onRangeSelect:f,currentTimeIndicator:g,showResourceHeaders:u=!0,group:c,showUnassignedLane:N=!1,startHour:p="00:00",endHour:h="24:00",slotDuration:_=60,is24Hour:P=!1,scrollRef:G,dir:D})=>{const H=D==="rtl",z=Qt(),se=p?parseInt(p.split(":")[0],10):0,y=h?parseInt(h.split(":")[0],10):24,k=y-se,[M,v]=b.useState(null),[K,$]=b.useState(!1),q=b.useRef(null),De=b.useRef(null),X=e==="timeline-month",ne=X?1440:_,Me=60/ne,me=X?1:k*Me,Se=t.length*me,ie=X?120:80,ue=Se*ie,Z=b.useMemo(()=>{const x=r.length>0?[...r]:[];return(N||x.length===0)&&(x.find(A=>A.id==="unassigned")||x.unshift({id:"unassigned",name:"Unassigned",type:"Global Inbox",color:"hsl(var(--muted-foreground))"})),x},[r,N]),he=b.useMemo(()=>{if(!c||!c.resources||c.resources.length===0)return{isGrouped:!1,groups:[{name:"All",resources:Z}]};const x=c.resources[0],A=new Map;Z.forEach(C=>{const E=C[x]||"Unassigned";A.has(E)||A.set(E,[]),A.get(E)?.push(C)});const w=[];return A.forEach((C,E)=>{w.push({name:E,resources:C})}),{isGrouped:!0,groups:w}},[Z,c]),ee=b.useMemo(()=>he.groups.flatMap(x=>x.resources),[he]),F=x=>{if(X)return Ie(t[x]);const A=Math.floor(x/me),w=x%me,C=Ie(t[A]);return Je(C,se*60+w*ne)},R=x=>{if(X){const I=t.findIndex(W=>fe(W,Ie(x)));return I!==-1?I*ie:-1}const A=Ie(x),w=t.findIndex(I=>fe(I,A));if(w===-1)return-1;const E=yr(x,A)-se*60;return(w*k*60+E)/ne*ie},we=(()=>{if(X){const w=Ie(t[0]),C=Ie(t[t.length-1]);return z<w||z>C?null:R(z)}const x=R(z),A=z.getHours();return x===-1||A<se||A>=y?null:x})(),Pe=b.useRef(!1);b.useEffect(()=>{G?.current&&we!==null&&!Pe.current&&setTimeout(()=>{G.current&&(H?G.current.scrollLeft=-we:G.current.scrollLeft=we,Pe.current=!0)},50)},[G,we,e]);const S=(x,A)=>{const w=F(x);if(n.some(I=>(I.isHoliday||I.isFullyBooked)&&fe(I.start,w)))return;$(!0);const E={startSlot:x,endSlot:x,resourceId:A};v(E),q.current=E},B=x=>{if(!K||!q.current)return;const A={...q.current,endSlot:x};v(A),q.current=A};b.useEffect(()=>{const x=A=>{if(K&&q.current){const{startSlot:w,endSlot:C,resourceId:E}=q.current,I=Math.min(w,C),W=Math.max(w,C),U=F(I),j=F(W+1);n.some(te=>(te.isHoliday||te.isFullyBooked)&&fe(te.start,U))||(f?.(U,j,E,{x:A.clientX,y:A.clientY}),s?.(U,E))}$(!1),v(null),q.current=null};return window.addEventListener("mouseup",x),()=>window.removeEventListener("mouseup",x)},[K,f,s,t]);const V=(x,A)=>{if(!M||M.resourceId!==A)return!1;const w=Math.min(M.startSlot,M.endSlot),C=Math.max(M.startSlot,M.endSlot);return x>=w&&x<=C},{resourceMap:le,maxLevels:ae}=b.useMemo(()=>{const x=new Map,A=new Map;return ee.forEach(w=>{x.set(w.id,[]),A.set(w.id,1)}),n.forEach(w=>{const C=w.resourceId||"unassigned",E=String(C);x.has(E)?x.get(E)?.push(w):x.has("unassigned")}),x.forEach((w,C)=>{const E=[...w].sort((U,j)=>U.start.getTime()-j.start.getTime()),I=[],W=E.map(U=>{let j=0;const L=300*1e3;for(;I[j]!==void 0&&I[j]>U.start.getTime()+L;)j++;return I[j]=U.end.getTime(),{...U,level:j}});x.set(C,W),A.set(C,I.length||1)}),{resourceMap:x,maxLevels:A}},[n,ee]),Ze=x=>{const A=R(x.start),w=R(x.end);if(A===-1&&w===-1)return{display:"none"};const C=Math.max(0,A),E=w===-1?ue:Math.min(ue,w),I=Math.max(0,E-C);if(I<=4)return{display:"none"};const W=36,j=20+x.level*(W+10),L=x.color||"hsl(var(--primary))";return{[H?"right":"left"]:`${C}px`,width:`${Math.max(I,4)}px`,top:`${j}px`,height:`${W}px`,background:`linear-gradient(135deg, color-mix(in srgb, ${L} 20%, transparent), color-mix(in srgb, ${L} 10%, transparent))`,backdropFilter:"blur(4px)",[H?"borderRight":"borderLeft"]:`4px solid ${L}`,borderTop:`1px solid color-mix(in srgb, ${L} 30%, transparent)`,[H?"borderLeft":"borderRight"]:`1px solid color-mix(in srgb, ${L} 30%, transparent)`,borderBottom:`1px solid color-mix(in srgb, ${L} 30%, transparent)`,color:"hsl(var(--foreground))",borderRadius:"6px",boxShadow:"0 2px 8px -2px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",fontSize:"12px",fontWeight:"600",paddingInlineStart:"12px",paddingInlineEnd:"8px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",zIndex:20+x.level,cursor:"pointer"}},He=40,Ue=240,Le=u?he.isGrouped?He+Ue:Ue:0;return o.jsxs("div",{className:"flex flex-col h-full w-full overflow-hidden border border-border/40 rounded-xl bg-background shadow-sm",children:[o.jsxs("div",{className:"flex bg-background z-40 sticky top-0 border-b border-border/40 shadow-[0_1px_2px_rgba(0,0,0,0.03)] items-center",children:[u&&he.isGrouped&&o.jsx("div",{className:Y.cn("w-[40px] shrink-0 border-e border-border/40 p-1 flex items-center justify-center bg-background select-none sticky z-50",H?"right-0":"left-0"),children:o.jsx("div",{className:"writing-mode-vertical rotate-180 font-bold text-[10px] uppercase tracking-widest text-muted-foreground/70",children:"Group"})}),u&&o.jsx("div",{className:Y.cn("w-[240px] shrink-0 border-e border-border/40 px-6 py-4 font-bold text-[11px] uppercase tracking-widest flex items-center bg-background text-muted-foreground select-none sticky z-50",he.isGrouped?H?"right-[40px]":"left-[40px]":H?"right-0":"left-0"),children:"RESOURCES"}),o.jsx("div",{ref:De,className:"overflow-hidden flex-1 relative",children:o.jsx("div",{className:"flex",style:{width:ue},children:t.map(x=>{const A=t.length===1,w=x.getDay()===0||x.getDay()===6;return X?o.jsxs("div",{className:Y.cn("flex shrink-0 border-e border-border/30 h-14 flex-col justify-center items-center transition-colors select-none",w?"bg-muted/10":"bg-transparent hover:bg-muted/5"),style:{width:ie},children:[o.jsx("span",{className:Y.cn("text-[10px] font-bold uppercase mb-0.5 tracking-wider",w?"text-muted-foreground":"text-primary"),children:de(x,"EEE")}),o.jsx("span",{className:Y.cn("text-xs font-semibold",w?"text-muted-foreground/70":"text-foreground/80"),children:de(x,"d")})]},x.toISOString()):o.jsx("div",{className:"flex shrink-0 border-e border-border/40",style:{width:ue/t.length},children:Array.from({length:me}).map((C,E)=>{const I=E*ne,W=se+Math.floor(I/60),U=I%60,j=new Date(new Date().setHours(W,U,0,0));let L="";return P?L=de(j,"HH:mm"):L=ne<60||U!==0?de(j,"h:mm a"):de(j,"ha"),o.jsxs("div",{className:"flex flex-col justify-end pb-2 border-e border-border/10 last:border-e-0 relative h-14",style:{width:ie},children:[!A&&E===0&&o.jsx("div",{className:Y.cn("absolute top-2 px-2 py-0.5 rounded text-[10px] font-bold text-foreground/80 bg-muted/50 border border-border/20 whitespace-nowrap",H?"right-2":"left-2"),children:de(x,"EEE, MMM d")}),o.jsx("span",{className:"text-[11px] font-black text-foreground text-center px-1 select-none tabular-nums truncate",children:L})]},E)})},x.toISOString())})})})]}),o.jsx("div",{ref:G,"data-testid":"scheduler-scroll-container",className:"flex-1 overflow-auto relative custom-scrollbar bg-background",onScroll:x=>{De.current&&(De.current.scrollLeft=x.currentTarget.scrollLeft)},children:o.jsxs("div",{className:"relative min-w-max",style:{width:ue+Le,minHeight:"100%"},children:[we!==null&&g!==!1&&o.jsxs("div",{className:"current-time-indicator z-50 pointer-events-none",style:{[H?"right":"left"]:`${we+Le}px`,height:"100%"},children:[o.jsx("div",{className:"absolute top-0 -translate-x-1/2 w-[2px] h-full bg-red-500 shadow-[0_0_8px_rgba(239,68,68,0.6)]"}),o.jsx("div",{className:"absolute top-0 -translate-x-1/2 -mt-1 w-2.5 h-2.5 rounded-full bg-red-500 shadow-md border-2 border-background"})]}),he.groups.map(x=>o.jsxs("div",{className:"flex border-b border-border/30 relative",children:[u&&he.isGrouped&&o.jsxs("div",{className:Y.cn("w-[40px] shrink-0 sticky z-30 bg-background border-e border-border/40 flex items-center justify-center p-1",H?"right-0":"left-0"),style:{height:"auto"},children:[o.jsx("div",{className:"absolute inset-0 bg-background/80"}),o.jsx("div",{className:"relative writing-mode-vertical transform rotate-180 text-[10px] font-bold uppercase tracking-wide text-foreground/70 whitespace-nowrap py-2 overflow-hidden text-ellipsis max-h-full",children:x.name})]}),o.jsx("div",{className:"flex flex-col w-full",children:x.resources.map((A,w)=>{const E=(ae.get(A.id)||1)*46+40;return o.jsxs("div",{className:Y.cn("flex border-b border-border/30 last:border-b-0 group/row hover:bg-muted/5 transition-colors",(w%2===0,"bg-background")),style:{height:`${E}px`},children:[o.jsx("div",{className:Y.cn("w-[240px] shrink-0 sticky z-30 bg-background/95 backdrop-blur border-e border-border/40 px-6 py-4 flex items-center gap-4 transition-all shadow-[1px_0_4px_rgba(0,0,0,0.02)]",he.isGrouped?H?"right-[40px]":"left-[40px]":H?"right-0":"left-0",!u&&"hidden"),children:o.jsxs(o.Fragment,{children:[o.jsxs(Xe.Avatar,{className:"h-9 w-9 border border-border/60 shadow-sm",children:[A.avatar&&o.jsx(Xe.AvatarImage,{src:A.avatar,alt:A.name,className:"object-cover"}),o.jsx(Xe.AvatarFallback,{className:"text-xs font-bold bg-primary/5 text-primary",children:A.name.charAt(0)})]}),o.jsxs("div",{className:"flex flex-col min-w-0",children:[o.jsx("span",{className:"text-[13px] font-semibold truncate text-foreground/90 tracking-tight leading-none mb-1.5",children:A.name}),o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:Y.cn("w-1.5 h-1.5 rounded-full",A.type==="Internal"?"bg-primary shadow-[0_0_6px_var(--primary)]/50":"bg-success shadow-[0_0_6px_var(--success)]/50")}),o.jsx("span",{className:"text-[10px] text-muted-foreground font-medium uppercase tracking-wider",children:A.type||"Available"})]})]})]})}),o.jsx(lo,{resource:A,totalSlots:Se,slotWidth:ie,totalWidth:ue,slotToDate:F,onSlotMouseDown:S,onSlotMouseEnter:B,onSlotDoubleClick:i,isSlotSelected:V,resourceMap:le,getEventStyle:Ze,onEventClick:l,onEventDelete:d,slotDuration:ne,now:z,visibleEvents:n,slotsPerDay:me,daysInView:t,dir:D})]},A.id)})})]},x.name))]})})]})},lo=({resource:e,totalSlots:t,slotWidth:n,totalWidth:r,slotToDate:s,onSlotMouseDown:i,onSlotMouseEnter:l,onSlotDoubleClick:d,isSlotSelected:f,resourceMap:g,getEventStyle:u,onEventClick:c,onEventDelete:N,slotDuration:p,now:h,visibleEvents:_,slotsPerDay:P,daysInView:G,dir:D})=>{const H=D==="rtl",{setNodeRef:z,isOver:se}=_e.useDroppable({id:`row-${e.id}`,data:{resourceId:e.id}});return o.jsxs("div",{ref:z,className:Y.cn("relative flex-1 group/interactive",se&&"bg-primary/5 shadow-inner"),style:{width:r},onMouseMove:y=>{const k=y.currentTarget.getBoundingClientRect(),M=y.clientX-k.left,v=Math.floor(H?(k.width-M)/n:M/n);v>=0&&v<t&&l(v)},onMouseDown:y=>{const k=y.currentTarget.getBoundingClientRect(),M=y.clientX-k.left,v=Math.floor(H?(k.width-M)/n:M/n);v>=0&&v<t&&i(v,e.id)},onDoubleClick:y=>{const k=y.currentTarget.getBoundingClientRect(),M=y.clientX-k.left,v=Math.floor(H?(k.width-M)/n:M/n);if(v>=0&&v<t){const K=s(v);_.some(q=>(q.isHoliday||q.isFullyBooked)&&fe(q.start,K))||d?.(K,e.id)}},children:[o.jsx("div",{className:"absolute inset-0 pointer-events-none",style:{backgroundImage:`repeating-linear-gradient(${H?"to left":"to right"}, transparent, transparent ${n-1}px, hsl(var(--border) / 0.1) ${n-1}px, hsl(var(--border) / 0.1) ${n}px)`,backgroundSize:`${n}px 100%`}}),o.jsx("div",{className:"absolute inset-0 pointer-events-none flex",children:G.map((y,k)=>{const M=_.find(K=>K.isHoliday&&fe(K.start,y)),v=_.find(K=>K.isFullyBooked&&fe(K.start,y));return!M&&!v?o.jsx("div",{style:{width:P*n}},k):o.jsx("div",{style:{width:P*n},className:Y.cn("h-full border-e border-border/10",M&&"bg-[repeating-linear-gradient(-45deg,hsl(var(--destructive)/0.05)_0px,hsl(var(--destructive)/0.05)_10px,transparent_10px,transparent_20px)] bg-destructive/[0.02]",v&&"bg-[repeating-linear-gradient(-45deg,theme(colors.amber.500/0.05)_0px,theme(colors.amber.500/0.05)_10px,transparent_10px,transparent_20px)] bg-amber-500/[0.02]")},k)})}),o.jsx(uo,{totalSlots:t,resourceId:e.id,slotWidth:n,isSlotSelected:f,isRtl:H}),g.get(e.id)?.map(y=>o.jsx(Gn,{event:y,style:u(y),onClick:c,onDelete:N,orientation:"horizontal",resizable:!0,isBlocked:y.isBlock,isPast:y.end<h,slotDuration:p,pixelsPerSlot:n},y.id))]})},uo=b.memo(({totalSlots:e,resourceId:t,slotWidth:n,isSlotSelected:r,isRtl:s})=>{const i=[];let l=null;for(let d=0;d<e;d++)r(d,t)?l?l.length++:(l={start:d,length:1},i.push(l)):l=null;return o.jsx(o.Fragment,{children:i.map((d,f)=>o.jsx("div",{className:"absolute top-0 bottom-0 bg-primary/20 border-x border-primary/30 z-10 pointer-events-none",style:{[s?"right":"left"]:`${d.start*n}px`,width:`${d.length*n}px`}},f))})}),fo=({daysInView:e,visibleEvents:t,onEventClick:n})=>o.jsx("div",{"data-testid":"scheduler-scroll-container",className:"flex flex-col h-full w-full bg-background overflow-y-auto border border-border rounded-lg",children:e.map(r=>{const s=t.filter(l=>fe(l.start,r)).sort((l,d)=>l.start.getTime()-d.start.getTime()),i=fe(r,new Date);return o.jsxs("div",{className:"flex flex-col border-b border-border pb-2 last:border-b-0",children:[o.jsxs("div",{className:Y.cn("flex items-center px-4 py-2 sticky top-0 bg-background/95 backdrop-blur z-10 border-b border-border",i&&"text-primary font-semibold"),children:[o.jsxs("div",{className:"flex flex-col items-center mr-4 w-12 shrink-0",children:[o.jsx("span",{className:"text-[10px] uppercase font-bold text-muted-foreground",children:de(r,"EEE")}),o.jsx("span",{className:"text-xl font-bold leading-none",children:de(r,"d")})]}),o.jsx("div",{className:"text-sm font-medium text-muted-foreground",children:de(r,"MMMM yyyy")})]}),o.jsx("div",{className:"flex flex-col px-2 py-1 gap-2",children:s.length===0?o.jsx("div",{className:"text-sm text-muted-foreground px-4 py-2 italic opacity-50",children:"No events"}):s.map(l=>o.jsx(_e.EzContextMenu,{contextId:"scheduler-event",data:l,children:o.jsxs("div",{"data-testid":`scheduler-event-${l.id}`,className:Y.cn("flex items-center p-3 rounded-lg border bg-card text-card-foreground shadow-sm cursor-pointer hover:bg-muted/50 transition-colors",l.color&&`border-l-4 border-l-[${l.color}]`),style:{borderLeftColor:l.color},onClick:()=>n?.(l),children:[o.jsxs("div",{className:"flex flex-col mr-4 min-w-[80px] shrink-0",children:[o.jsx("span",{className:"text-sm font-bold",children:de(l.start,"h:mm a")}),o.jsx("span",{className:"text-xs text-muted-foreground",children:de(l.end,"h:mm a")})]}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"font-semibold truncate",children:l.title}),l.description&&o.jsx("div",{className:"text-xs text-muted-foreground truncate",children:l.description})]}),l.resourceId&&o.jsx("div",{className:"hidden sm:block ml-2 px-2 py-0.5 rounded-full bg-muted text-[10px] text-muted-foreground",children:l.resourceId})]})},l.id))})]},r.toISOString())})});function mo({view:e,daysInView:t,visibleEvents:n,rowVirtualizer:r,resources:s,handleSlotDoubleClick:i,handleEventDoubleClick:l,handleEventDelete:d,parentRef:f,setView:g,setCurrentDate:u,props:c,handleRangeSelect:N,currentDate:p,showUnassignedLane:h,slotDuration:_,is24Hour:P,setIs24Hour:G,dir:D}){const H=Vt("(max-width: 768px)"),z=typeof c.cell=="function"?c.cell:void 0;switch(H&&(e==="week"||e==="workweek")?"agenda":e){case"day":case"week":case"workweek":return o.jsx(ao,{daysInView:t,visibleEvents:n,rowVirtualizer:r,resources:s,onSlotDoubleClick:i,onEventDoubleClick:l,onEventDelete:d,scrollRef:f,onViewChange:g,onDateChange:u,onRangeSelect:N,onSlotClick:(y,k)=>c.onCellClick?.(y,k),onEventClick:y=>c.onEventClick?.(y),showResourcesInDayView:c.showResourcesInDayView,showWeekNumber:c.showWeekNumber,weekRule:c.weekRule,cellTemplate:z,enableHtmlSanitizer:c.enableHtmlSanitizer,showUnassignedLane:h,startHour:c.startHour,endHour:c.endHour,slotDuration:_,is24Hour:P,setIs24Hour:G,group:c.group,onCellContextMenu:c.onCellContextMenu,dir:D});case"month":return o.jsx(io,{currentDate:p,daysInView:t,visibleEvents:n,onSlotClick:y=>c.onCellClick?.(y),onSlotDoubleClick:y=>i(y),onEventClick:y=>c.onEventClick?.(y)||l(y),monthsCount:c.monthsCount,dir:D});case"timeline":case"timeline-day":case"timelineday":case"timeline-week":case"timelineweek":case"timeline-month":case"timelinemonth":return o.jsx(co,{view:e,currentDate:p,daysInView:t,visibleEvents:n,resources:s,onSlotClick:(y,k)=>c.onCellClick?.(y,k),onSlotDoubleClick:i,onEventClick:y=>c.onEventClick?.(y)||l(y),onEventDelete:d,onRangeSelect:N,currentTimeIndicator:c.currentTimeIndicator,showResourceHeaders:c.showResourceHeaders,group:c.group,showUnassignedLane:c.showUnassignedLane,startHour:c.startHour,endHour:c.endHour,slotDuration:_,is24Hour:P,scrollRef:f,dir:D});case"agenda":return o.jsx(fo,{daysInView:t,visibleEvents:n,onEventClick:y=>c.onEventClick?.(y)||l(y)});default:return o.jsxs("div",{children:["View ",e," not implemented"]})}}const Kn=({isOpen:e,onClose:t,title:n,children:r,footer:s,className:i,size:l="md",closeOnBackdropClick:d=!0,showCloseButton:f=!0})=>{if(b.useEffect(()=>{if(e)return document.body.style.overflow="hidden",()=>{document.body.style.overflow="unset"}},[e]),!e)return null;const g={sm:"max-w-sm",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl",full:"max-w-[95vw] h-[95vh]"},u=o.jsxs("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center p-4 sm:p-6",role:"dialog","aria-modal":"true",children:[o.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm transition-opacity animate-in fade-in duration-200",onClick:d?t:void 0,"aria-hidden":"true"}),o.jsxs("div",{className:Y.cn("relative w-full bg-background rounded-xl border border-border shadow-2xl flex flex-col overflow-hidden animate-in zoom-in-95 slide-in-from-bottom-2 duration-200",g[l],i),children:[(n||f)&&o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border bg-muted/10 shrink-0",children:[o.jsx("div",{className:"text-lg font-semibold leading-none tracking-tight",children:n}),f&&o.jsxs(Ke.Button,{variant:"ghost",size:"icon",onClick:t,className:"h-8 w-8 rounded-full p-0 text-muted-foreground hover:bg-muted",children:[o.jsx(Ke.X,{className:"h-4 w-4"}),o.jsx("span",{className:"sr-only",children:"Close"})]})]}),o.jsx("div",{className:"flex-1 overflow-y-auto p-6 custom-scrollbar",children:r}),s&&o.jsx("div",{className:"flex items-center justify-end gap-2 px-6 py-4 border-t border-border bg-muted/5 shrink-0",children:s})]})]});return lr.createPortal(u,document.body)},ho=b.lazy(()=>Promise.resolve().then(()=>require("./EzEventModal-DkowH9rh.cjs")).then(e=>({default:e.EzEventModal}))),go=b.lazy(()=>Promise.resolve().then(()=>require("./EzSchedulerQuickAdd-BLF22CDh.cjs")).then(e=>({default:e.EzSchedulerQuickAdd}))),po=b.lazy(()=>Promise.resolve().then(()=>require("./EzSchedulerToolbar-CaVVmnjt.cjs")).then(e=>e.EzSchedulerToolbar$1).then(e=>({default:e.EzSchedulerToolbar}))),xo=new Re.QueryClient,Jn=b.forwardRef((e,t)=>(Y.useInitCoreServices(),o.jsx(Re.QueryClientProvider,{client:xo,children:o.jsx(Zn,{...e,ref:t})})));Jn.displayName="EzScheduler";const Zn=b.forwardRef((e,t)=>{const n=$n({...e,view:e.view||e.defaultView||"Week",selectedDate:e.selectedDate??e.defaultSelectedDate}),{state:r,actions:s,services:i,refs:l,baseApi:d,dir:f}=n,{currentView:g,currentDate:u,viewEvents:c,daysInView:N,slotDuration:p,is24Hour:h}=r,{setView:_,setCurrentDate:P}=s,{rowVirtualizer:G,parentRef:D}=l,{schedulerService:H,serviceRegistry:z}=i,se=S=>{if(!S.start||!S.end)return{hasBlockOverlap:!1,hasRegularOverlap:!1,overlappingEvents:[]};const B=c.filter(V=>V.id===S.id||!(V.resourceId===S.resourceId||V.resourceIds?.some(ae=>S.resourceId===ae)||!V.resourceId&&!S.resourceId)?!1:Mt({start:V.start,end:V.end},{start:S.start,end:S.end}));return{hasBlockOverlap:B.some(V=>V.isBlock),hasRegularOverlap:B.length>0,overlappingEvents:B}},y=(S="regular")=>{const B=z.get("NotificationService");if(B){let V="",le="warning";S==="block"?(V="Cannot place event here: This time is blocked (e.g. Lunch Break).",le="error"):S==="past"?(V="Cannot move or create events in the past.",le="error"):(V="Warning: This event overlaps with an existing event.",le="warning"),B.add({type:le,message:V,duration:5e3})}},{sensors:k,handleDragEnd:M}=_s({events:c,slotDuration:p,onEventChange:S=>{if(!e.allowPastEvents&&S.start<new Date){y("past");return}const{hasBlockOverlap:B,hasRegularOverlap:V,overlappingEvents:le}=se(S);if(B){y("block");return}if(V){if(e.onEventOverlap){const ae={event:S,existingEvents:le,cancel:!1};if(e.onEventOverlap(ae),ae.cancel)return}y("regular")}console.log("[EzScheduler] Calling scheduler.updateEvent",S),s.updateEvent(S)}}),{internalResources:v,setInternalResources:K}=Ns({resources:e.resources}),[$,q]=b.useState({isOpen:!1,mode:"create"}),[De,X]=b.useState(!1),[ne,Me]=b.useState(null),[me,Se]=b.useState({x:0,y:0}),ie=b.useMemo(()=>({...n.baseApi,onExportExcel:e.onExportExcel,onExportCSV:e.onExportCSV,onExportICS:e.onExportICS,get currentView(){return g},destroy:()=>{e.destroyed&&e.destroyed({})}}),[n.baseApi,g,e.destroyed,e.onExportExcel,e.onExportCSV,e.onExportICS]);Ms(g,u,H,c,{setEditorState:q,setResources:K,scrollToIndex:S=>{D.current&&(D.current.scrollTop=S*64)},forceUpdate:()=>{},showSpinner:d.showSpinner,hideSpinner:d.hideSpinner,closeQuickInfoPopup:()=>X(!1),changeView:S=>_(S.toLowerCase()),next:s.nextPeriod,prev:s.prevPeriod,today:s.today},t,ie);const ue=(S,B)=>{e.onCellDoubleClick?e.onCellDoubleClick(S,B):q({isOpen:!0,mode:"create",event:{start:S,end:Je(S,30),resourceId:B,resourceIds:B?[B]:[]}})},Z=S=>{if(e.onEventDoubleClick)e.onEventDoubleClick(S);else{const B=S.end<new Date;q({isOpen:!0,mode:B?"view":"edit",event:S})}},he=async S=>{if(!e.allowPastEvents&&S.start&&S.start<new Date){y("past");return}const{hasBlockOverlap:B,hasRegularOverlap:V}=se(S);if(B){y("block");return}V&&y("regular"),$.mode==="create"?(await e.onEventCreate?.(S),s.addEvent(S)):(await e.onEventChange?.(S),s.updateEvent(S)),q(le=>({...le,isOpen:!1}))},[ee,F]=b.useState({isOpen:!1}),R=async S=>{F({isOpen:!0,eventId:S})},We=async()=>{const S=ee.eventId;if(!S)return;const B=c.find(V=>V.id===S);if(B){await e.onEventDelete?.(S),s.deleteEvent(S);const V=z.get("NotificationService");if(V){const le=de(B.start,"MMM d, yyyy h:mm a");V.add({type:"success",message:`Event "${B.title}" on ${le} has been cancelled.`,duration:5e3})}}F({isOpen:!1})},we=S=>{if(!e.allowPastEvents&&S.start&&S.start<new Date){y("past");return}s.addEvent(S),e.onEventCreate?.(S),X(!1)},Pe=(S,B,V,le)=>{e.showQuickInfoPopup&&(Me({start:S,end:B,resourceId:V}),Se({x:le?.x||0,y:le?.y||0}),X(!0))};return o.jsx(ze.EzErrorBoundary,{fallback:o.jsx(Cs,{}),children:o.jsxs("div",{className:Y.cn("ez-scheduler flex flex-col w-full h-full bg-background select-none overflow-hidden",e.className),dir:f,children:[e.showHeaderBar!==!1&&o.jsx(b.Suspense,{fallback:o.jsx("div",{className:"h-12 w-full animate-pulse bg-muted/20 rounded-md mb-4"}),children:(()=>{const S=e.slots?.toolbar;return S?o.jsx(S,{view:g,setView:_,currentDate:u,next:s.nextPeriod,prev:s.prevPeriod,today:s.today,onAddClick:b.useCallback(()=>q({isOpen:!0,mode:"create",event:{}}),[]),slotDuration:p,setSlotDuration:s.setSlotDuration,setCurrentDate:P,onPrev:s.prevPeriod,onNext:s.nextPeriod,onToday:s.today,currentView:g,onViewChange:B=>{const V=B.toLowerCase().replace(/[^a-z]/g,""),ae={day:"day",week:"week",workweek:"workweek",month:"month",timelineday:"timeline-day",timelineweek:"timeline-week",timelineworkweek:"timeline-week",timelinemonth:"timeline-month",agenda:"agenda",timeline:"timeline-day"}[V]||V;_(ae)},views:e.views||["Day","Week","Month"],onExportExcel:b.useCallback(()=>e.onExportExcel?.(c),[e.onExportExcel,c]),onExportCSV:b.useCallback(()=>e.onExportCSV?.(c),[e.onExportCSV,c]),onExportICS:b.useCallback(()=>e.onExportICS?.(c),[e.onExportICS,c]),dir:f,...e.slotProps?.toolbar}):o.jsx(po,{view:g,setView:_,currentDate:u,next:s.nextPeriod,prev:s.prevPeriod,today:s.today,onAddClick:b.useCallback(()=>q({isOpen:!0,mode:"create",event:{}}),[]),slotDuration:p,setSlotDuration:s.setSlotDuration,setCurrentDate:P,onPrev:s.prevPeriod,onNext:s.nextPeriod,onToday:s.today,currentView:g,onViewChange:B=>{const V=B.toLowerCase().replace(/[^a-z]/g,""),ae={day:"day",week:"week",workweek:"workweek",month:"month",timelineday:"timeline-day",timelineweek:"timeline-week",timelineworkweek:"timeline-week",timelinemonth:"timeline-month",agenda:"agenda",timeline:"timeline-day"}[V]||V;_(ae)},views:e.views||["Day","Week","Month"],onExportExcel:b.useCallback(()=>e.onExportExcel?.(c),[e.onExportExcel,c]),onExportCSV:b.useCallback(()=>e.onExportCSV?.(c),[e.onExportCSV,c]),onExportICS:b.useCallback(()=>e.onExportICS?.(c),[e.onExportICS,c]),dir:f})})()}),o.jsxs(_e.DndContext,{sensors:k,onDragEnd:M,collisionDetection:_e.closestCenter,children:[o.jsxs("div",{className:"flex-1 overflow-hidden relative flex flex-col",children:[o.jsx(mo,{view:g,daysInView:N,visibleEvents:c,rowVirtualizer:G,resources:v,handleSlotDoubleClick:ue,handleEventDoubleClick:Z,handleEventDelete:R,parentRef:D,setView:_,setCurrentDate:P,props:e,handleRangeSelect:Pe,currentDate:u,showUnassignedLane:e.showUnassignedLane,slotDuration:p,is24Hour:h,setIs24Hour:s.setIs24Hour,dir:f}),e.isLoading&&o.jsx(As,{})]}),(()=>{if(De&&ne){const S=e.slots?.quickAdd;return S?o.jsx(b.Suspense,{fallback:null,children:o.jsx(S,{start:ne.start,end:ne.end,resourceId:ne.resourceId,resources:v,onSave:we,onCancel:()=>X(!1),onMoreOptions:B=>{X(!1),q({isOpen:!0,mode:"create",event:B})},position:me,...e.slotProps?.quickAdd})}):o.jsx(b.Suspense,{fallback:null,children:o.jsx(go,{start:ne.start,end:ne.end,resourceId:ne.resourceId,resources:v,onSave:we,onCancel:()=>X(!1),onMoreOptions:B=>{X(!1),q({isOpen:!0,mode:"create",event:B})},position:me})})}return null})(),(()=>{const S=e.slots?.eventModal;return S?o.jsx(b.Suspense,{fallback:null,children:o.jsx(S,{isOpen:$.isOpen,onClose:()=>q(B=>({...B,isOpen:!1})),mode:$.mode,event:$.event,onSave:he,onDelete:R,resources:v,locale:e.locale,...e.slotProps?.eventModal})}):o.jsx(b.Suspense,{fallback:null,children:o.jsx(ho,{isOpen:$.isOpen,onClose:()=>q(B=>({...B,isOpen:!1})),mode:$.mode,event:$.event,onSave:he,onDelete:R,resources:v,locale:e.locale})})})(),o.jsx(Kn,{isOpen:ee.isOpen,onClose:()=>F({isOpen:!1}),title:"Delete Event",footer:o.jsxs("div",{className:"flex gap-2",children:[o.jsx(Ke.Button,{variant:"ghost",onClick:()=>F({isOpen:!1}),children:"Cancel"}),o.jsx(Ke.Button,{variant:"destructive",onClick:We,children:"Delete"})]}),children:o.jsx("p",{className:"text-sm text-muted-foreground",children:"Are you sure you want to delete this event? This action cannot be undone."})})]})]})})});Zn.displayName="EzSchedulerInner";exports.Clock=_n;exports.EzScheduler=Jn;exports.Modal=Kn;exports.SchedulerService=Yn;exports.addDays=dt;exports.addMinutes=Je;exports.addMonths=Kt;exports.constructFrom=je;exports.eachDayOfInterval=jn;exports.enUS=Pn;exports.endOfMonth=Bt;exports.endOfWeek=Yt;exports.format=de;exports.getDefaultOptions=ut;exports.getISOWeek=Jt;exports.getTimezoneOffsetInMilliseconds=Ht;exports.getWeek=St;exports.getWeekYear=Zt;exports.isProtectedDayOfYearToken=Fn;exports.isProtectedWeekYearToken=Wn;exports.isSameDay=fe;exports.isSameMonth=Bn;exports.isValid=Rn;exports.longFormatters=zn;exports.millisecondsInHour=fr;exports.millisecondsInMinute=Xt;exports.millisecondsInSecond=mr;exports.startOfDay=Ie;exports.startOfISOWeek=vt;exports.startOfMonth=Ut;exports.startOfWeek=nt;exports.subMonths=Un;exports.toDate=oe;exports.useEzScheduler=$n;exports.useKeyboardNavigation=Cn;exports.useMediaQuery=Vt;exports.warnOrThrowProtectedError=Hn;
|
|
1
|
+
"use strict";const o=require("react/jsx-runtime"),b=require("react"),Y=require("./useInitCoreServices-CwXv2p4S.cjs"),ar=require("@tanstack/react-store"),ir=require("@tanstack/store"),Pe=require("./TooltipWrapper-DWts4bAI.cjs"),mn=require("rrule"),Fe=require("./EzErrorBoundary-CEdz_hDo.cjs"),_e=require("./EzContextMenu-B6HBUjWv.cjs"),cr=require("./useServiceState-BjpCjUn2.cjs"),Ke=require("./tooltip-B41iztKT.cjs"),Xe=require("./avatar-DZAaTK2f.cjs"),lr=require("react-dom");const dr=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],_n=Fe.createLucideIcon("clock",dr);function Vt(e){const[t,n]=b.useState(()=>typeof window<"u"?window.matchMedia(e).matches:!1);return b.useEffect(()=>{if(typeof window>"u")return;const r=window.matchMedia(e),s=()=>n(r.matches);return r.addEventListener?r.addEventListener("change",s):r.addListener(s),()=>{r.removeEventListener?r.removeEventListener("change",s):r.removeListener(s)}},[e]),t}function Qt(e=6e4){const[t,n]=b.useState(()=>new Date);return b.useEffect(()=>{const r=setInterval(()=>{n(new Date)},e);return()=>clearInterval(r)},[e]),t}const Cn=({totalItems:e,columns:t=1,onSelect:n,onAction:r,onCancel:s,wrap:i=!0,enabled:l=!0})=>{const[d,m]=b.useState(-1),g=b.useCallback(u=>{if(!l||e===0)return;let c=d;switch(u.key){case"ArrowDown":d===-1?c=0:(c=d+t,c>=e&&(c=i?c%t:d)),u.preventDefault();break;case"ArrowUp":if(d===-1)c=e-1;else if(c=d-t,c<0)if(i){const N=d%t;c=(Math.ceil(e/t)-1)*t+N,c>=e&&(c-=t)}else c=d;u.preventDefault();break;case"ArrowRight":d===-1?c=0:(c=d+1,c>=e&&(c=i?0:d)),u.preventDefault();break;case"ArrowLeft":d===-1?c=e-1:(c=d-1,c<0&&(c=i?e-1:d)),u.preventDefault();break;case"Enter":d!==-1&&r&&(r(d),u.preventDefault());break;case"Escape":s&&(s(),u.preventDefault()),m(-1);break;default:return}c!==d&&(m(c),n?.(c))},[d,e,t,n,r,s,i,l]);return b.useEffect(()=>{if(l)return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[l,g]),{selectedIndex:d,setSelectedIndex:m}},On=6048e5,ur=864e5,Xt=6e4,fr=36e5,mr=1e3,hn=Symbol.for("constructDateFrom");function Le(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&hn in e?e[hn](t):e instanceof Date?new e.constructor(t):new Date(t)}function oe(e,t){return Le(t||e,e)}function dt(e,t,n){const r=oe(e,n?.in);return isNaN(t)?Le(n?.in||e,NaN):(t&&r.setDate(r.getDate()+t),r)}function Kt(e,t,n){const r=oe(e,n?.in);if(isNaN(t))return Le(e,NaN);if(!t)return r;const s=r.getDate(),i=Le(e,r.getTime());i.setMonth(r.getMonth()+t+1,0);const l=i.getDate();return s>=l?i:(r.setFullYear(i.getFullYear(),i.getMonth(),s),r)}let hr={};function ut(){return hr}function nt(e,t){const n=ut(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,s=oe(e,t?.in),i=s.getDay(),l=(i<r?7:0)+i-r;return s.setDate(s.getDate()-l),s.setHours(0,0,0,0),s}function vt(e,t){return nt(e,{...t,weekStartsOn:1})}function An(e,t){const n=oe(e,t?.in),r=n.getFullYear(),s=Le(n,0);s.setFullYear(r+1,0,4),s.setHours(0,0,0,0);const i=vt(s),l=Le(n,0);l.setFullYear(r,0,4),l.setHours(0,0,0,0);const d=vt(l);return n.getTime()>=i.getTime()?r+1:n.getTime()>=d.getTime()?r:r-1}function Bt(e){const t=oe(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function Ct(e,...t){const n=Le.bind(null,t.find(r=>typeof r=="object"));return t.map(n)}function Re(e,t){const n=oe(e,t?.in);return n.setHours(0,0,0,0),n}function gr(e,t,n){const[r,s]=Ct(n?.in,e,t),i=Re(r),l=Re(s),d=+i-Bt(i),m=+l-Bt(l);return Math.round((d-m)/ur)}function pr(e,t){const n=An(e,t),r=Le(e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),vt(r)}function Je(e,t,n){const r=oe(e,n?.in);return r.setTime(r.getTime()+t*Xt),r}function In(e,t,n){return dt(e,t*7,n)}function Mt(e,t,n){const[r,s]=[+oe(e.start,n?.in),+oe(e.end,n?.in)].sort((d,m)=>d-m),[i,l]=[+oe(t.start,n?.in),+oe(t.end,n?.in)].sort((d,m)=>d-m);return r<l&&i<s}function fe(e,t,n){const[r,s]=Ct(n?.in,e,t);return+Re(r)==+Re(s)}function xr(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function Rn(e){return!(!xr(e)&&typeof e!="number"||isNaN(+oe(e)))}function br(e){return t=>{const n=Math.trunc,r=n(t);return r===0?0:r}}function wr(e,t){return+oe(e)-+oe(t)}function yr(e,t,n){const r=wr(e,t)/Xt;return br()(r)}function Rt(e,t){const n=oe(e,t?.in);return n.setHours(23,59,59,999),n}function Ut(e,t){const n=oe(e,t?.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}function Sr(e,t){const[n,r]=Ct(e,t.start,t.end);return{start:n,end:r}}function jn(e,t){const{start:n,end:r}=Sr(t?.in,e);let s=+n>+r;const i=s?+n:+r,l=s?r:n;l.setHours(0,0,0,0);let d=1;const m=[];for(;+l<=i;)m.push(Le(n,l)),l.setDate(l.getDate()+d),l.setHours(0,0,0,0);return s?m.reverse():m}function Yt(e,t){const n=oe(e,t?.in);return n.setDate(1),n.setHours(0,0,0,0),n}function vr(e,t){const n=oe(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function $t(e,t){const n=ut(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,s=oe(e,t?.in),i=s.getDay(),l=(i<r?-7:0)+6-(i-r);return s.setDate(s.getDate()+l),s.setHours(23,59,59,999),s}const Er={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},kr=(e,t,n)=>{let r;const s=Er[e];return typeof s=="string"?r=s:t===1?r=s.one:r=s.other.replace("{{count}}",t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function jt(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const Tr={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},Dr={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Mr={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Nr={date:jt({formats:Tr,defaultWidth:"full"}),time:jt({formats:Dr,defaultWidth:"full"}),dateTime:jt({formats:Mr,defaultWidth:"full"})},_r={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Cr=(e,t,n,r)=>_r[e];function ht(e){return(t,n)=>{const r=n?.context?String(n.context):"standalone";let s;if(r==="formatting"&&e.formattingValues){const l=e.defaultFormattingWidth||e.defaultWidth,d=n?.width?String(n.width):l;s=e.formattingValues[d]||e.formattingValues[l]}else{const l=e.defaultWidth,d=n?.width?String(n.width):e.defaultWidth;s=e.values[d]||e.values[l]}const i=e.argumentCallback?e.argumentCallback(t):t;return s[i]}}const Or={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Ar={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Ir={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},Rr={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},jr={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},Pr={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},Lr=(e,t)=>{const n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},zr={ordinalNumber:Lr,era:ht({values:Or,defaultWidth:"wide"}),quarter:ht({values:Ar,defaultWidth:"wide",argumentCallback:e=>e-1}),month:ht({values:Ir,defaultWidth:"wide"}),day:ht({values:Rr,defaultWidth:"wide"}),dayPeriod:ht({values:jr,defaultWidth:"wide",formattingValues:Pr,defaultFormattingWidth:"wide"})};function gt(e){return(t,n={})=>{const r=n.width,s=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],i=t.match(s);if(!i)return null;const l=i[0],d=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],m=Array.isArray(d)?Wr(d,c=>c.test(l)):Fr(d,c=>c.test(l));let g;g=e.valueCallback?e.valueCallback(m):m,g=n.valueCallback?n.valueCallback(g):g;const u=t.slice(l.length);return{value:g,rest:u}}}function Fr(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function Wr(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function Hr(e){return(t,n={})=>{const r=t.match(e.matchPattern);if(!r)return null;const s=r[0],i=t.match(e.parsePattern);if(!i)return null;let l=e.valueCallback?e.valueCallback(i[0]):i[0];l=n.valueCallback?n.valueCallback(l):l;const d=t.slice(s.length);return{value:l,rest:d}}}const Br=/^(\d+)(th|st|nd|rd)?/i,Ur=/\d+/i,Yr={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},$r={any:[/^b/i,/^(a|c)/i]},Gr={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},qr={any:[/1/i,/2/i,/3/i,/4/i]},Vr={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},Qr={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},Xr={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},Kr={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},Jr={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Zr={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},es={ordinalNumber:Hr({matchPattern:Br,parsePattern:Ur,valueCallback:e=>parseInt(e,10)}),era:gt({matchPatterns:Yr,defaultMatchWidth:"wide",parsePatterns:$r,defaultParseWidth:"any"}),quarter:gt({matchPatterns:Gr,defaultMatchWidth:"wide",parsePatterns:qr,defaultParseWidth:"any",valueCallback:e=>e+1}),month:gt({matchPatterns:Vr,defaultMatchWidth:"wide",parsePatterns:Qr,defaultParseWidth:"any"}),day:gt({matchPatterns:Xr,defaultMatchWidth:"wide",parsePatterns:Kr,defaultParseWidth:"any"}),dayPeriod:gt({matchPatterns:Jr,defaultMatchWidth:"any",parsePatterns:Zr,defaultParseWidth:"any"})},Pn={code:"en-US",formatDistance:kr,formatLong:Nr,formatRelative:Cr,localize:zr,match:es,options:{weekStartsOn:0,firstWeekContainsDate:1}};function ts(e,t){const n=oe(e,t?.in);return gr(n,vr(n))+1}function Jt(e,t){const n=oe(e,t?.in),r=+vt(n)-+pr(n);return Math.round(r/On)+1}function Zt(e,t){const n=oe(e,t?.in),r=n.getFullYear(),s=ut(),i=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??s.firstWeekContainsDate??s.locale?.options?.firstWeekContainsDate??1,l=Le(t?.in||e,0);l.setFullYear(r+1,0,i),l.setHours(0,0,0,0);const d=nt(l,t),m=Le(t?.in||e,0);m.setFullYear(r,0,i),m.setHours(0,0,0,0);const g=nt(m,t);return+n>=+d?r+1:+n>=+g?r:r-1}function ns(e,t){const n=ut(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,s=Zt(e,t),i=Le(t?.in||e,0);return i.setFullYear(s,0,r),i.setHours(0,0,0,0),nt(i,t)}function St(e,t){const n=oe(e,t?.in),r=+nt(n,t)-+ns(n,t);return Math.round(r/On)+1}function re(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r}const tt={y(e,t){const n=e.getFullYear(),r=n>0?n:1-n;return re(t==="yy"?r%100:r,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):re(n+1,2)},d(e,t){return re(e.getDate(),t.length)},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];default:return n==="am"?"a.m.":"p.m."}},h(e,t){return re(e.getHours()%12||12,t.length)},H(e,t){return re(e.getHours(),t.length)},m(e,t){return re(e.getMinutes(),t.length)},s(e,t){return re(e.getSeconds(),t.length)},S(e,t){const n=t.length,r=e.getMilliseconds(),s=Math.trunc(r*Math.pow(10,n-3));return re(s,t.length)}},lt={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},gn={G:function(e,t,n){const r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});default:return n.era(r,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const r=e.getFullYear(),s=r>0?r:1-r;return n.ordinalNumber(s,{unit:"year"})}return tt.y(e,t)},Y:function(e,t,n,r){const s=Zt(e,r),i=s>0?s:1-s;if(t==="YY"){const l=i%100;return re(l,2)}return t==="Yo"?n.ordinalNumber(i,{unit:"year"}):re(i,t.length)},R:function(e,t){const n=An(e);return re(n,t.length)},u:function(e,t){const n=e.getFullYear();return re(n,t.length)},Q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return re(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return re(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,n){const r=e.getMonth();switch(t){case"M":case"MM":return tt.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,n){const r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return re(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,n,r){const s=St(e,r);return t==="wo"?n.ordinalNumber(s,{unit:"week"}):re(s,t.length)},I:function(e,t,n){const r=Jt(e);return t==="Io"?n.ordinalNumber(r,{unit:"week"}):re(r,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):tt.d(e,t)},D:function(e,t,n){const r=ts(e);return t==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):re(r,t.length)},E:function(e,t,n){const r=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,n,r){const s=e.getDay(),i=(s-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(i);case"ee":return re(i,2);case"eo":return n.ordinalNumber(i,{unit:"day"});case"eee":return n.day(s,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(s,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(s,{width:"short",context:"formatting"});default:return n.day(s,{width:"wide",context:"formatting"})}},c:function(e,t,n,r){const s=e.getDay(),i=(s-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(i);case"cc":return re(i,t.length);case"co":return n.ordinalNumber(i,{unit:"day"});case"ccc":return n.day(s,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(s,{width:"narrow",context:"standalone"});case"cccccc":return n.day(s,{width:"short",context:"standalone"});default:return n.day(s,{width:"wide",context:"standalone"})}},i:function(e,t,n){const r=e.getDay(),s=r===0?7:r;switch(t){case"i":return String(s);case"ii":return re(s,t.length);case"io":return n.ordinalNumber(s,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,n){const s=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(s,{width:"narrow",context:"formatting"});default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},b:function(e,t,n){const r=e.getHours();let s;switch(r===12?s=lt.noon:r===0?s=lt.midnight:s=r/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(s,{width:"narrow",context:"formatting"});default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},B:function(e,t,n){const r=e.getHours();let s;switch(r>=17?s=lt.evening:r>=12?s=lt.afternoon:r>=4?s=lt.morning:s=lt.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(s,{width:"narrow",context:"formatting"});default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let r=e.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return tt.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):tt.H(e,t)},K:function(e,t,n){const r=e.getHours()%12;return t==="Ko"?n.ordinalNumber(r,{unit:"hour"}):re(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t==="ko"?n.ordinalNumber(r,{unit:"hour"}):re(r,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):tt.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):tt.s(e,t)},S:function(e,t){return tt.S(e,t)},X:function(e,t,n){const r=e.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return xn(r);case"XXXX":case"XX":return at(r);default:return at(r,":")}},x:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"x":return xn(r);case"xxxx":case"xx":return at(r);default:return at(r,":")}},O:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+pn(r,":");default:return"GMT"+at(r,":")}},z:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+pn(r,":");default:return"GMT"+at(r,":")}},t:function(e,t,n){const r=Math.trunc(+e/1e3);return re(r,t.length)},T:function(e,t,n){return re(+e,t.length)}};function pn(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),s=Math.trunc(r/60),i=r%60;return i===0?n+String(s):n+String(s)+t+re(i,2)}function xn(e,t){return e%60===0?(e>0?"-":"+")+re(Math.abs(e)/60,2):at(e,t)}function at(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),s=re(Math.trunc(r/60),2),i=re(r%60,2);return n+s+t+i}const bn=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});default:return t.date({width:"full"})}},Ln=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});default:return t.time({width:"full"})}},rs=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],r=n[1],s=n[2];if(!s)return bn(e,t);let i;switch(r){case"P":i=t.dateTime({width:"short"});break;case"PP":i=t.dateTime({width:"medium"});break;case"PPP":i=t.dateTime({width:"long"});break;default:i=t.dateTime({width:"full"});break}return i.replace("{{date}}",bn(r,t)).replace("{{time}}",Ln(s,t))},zn={p:Ln,P:rs},ss=/^D+$/,os=/^Y+$/,as=["D","DD","YY","YYYY"];function Fn(e){return ss.test(e)}function Wn(e){return os.test(e)}function Hn(e,t,n){const r=is(e,t,n);if(console.warn(r),as.includes(e))throw new RangeError(r)}function is(e,t,n){const r=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const cs=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,ls=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,ds=/^'([^]*?)'?$/,us=/''/g,fs=/[a-zA-Z]/;function de(e,t,n){const r=ut(),s=r.locale??Pn,i=r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,l=r.weekStartsOn??r.locale?.options?.weekStartsOn??0,d=oe(e,n?.in);if(!Rn(d))throw new RangeError("Invalid time value");let m=t.match(ls).map(u=>{const c=u[0];if(c==="p"||c==="P"){const N=zn[c];return N(u,s.formatLong)}return u}).join("").match(cs).map(u=>{if(u==="''")return{isToken:!1,value:"'"};const c=u[0];if(c==="'")return{isToken:!1,value:ms(u)};if(gn[c])return{isToken:!0,value:u};if(c.match(fs))throw new RangeError("Format string contains an unescaped latin alphabet character `"+c+"`");return{isToken:!1,value:u}});s.localize.preprocessor&&(m=s.localize.preprocessor(d,m));const g={firstWeekContainsDate:i,weekStartsOn:l,locale:s};return m.map(u=>{if(!u.isToken)return u.value;const c=u.value;(Wn(c)||Fn(c))&&Hn(c,t,String(e));const N=gn[c[0]];return N(d,c,s.localize,g)}).join("")}function ms(e){const t=e.match(ds);return t?t[1].replace(us,"'"):e}function Bn(e,t,n){const[r,s]=Ct(n?.in,e,t);return r.getFullYear()===s.getFullYear()&&r.getMonth()===s.getMonth()}function wn(e,t,n){const r=+oe(e,n?.in),[s,i]=[+oe(t.start,n?.in),+oe(t.end,n?.in)].sort((l,d)=>l-d);return r>=s&&r<=i}function hs(e,t,n){return dt(e,-1,n)}function Un(e,t,n){return Kt(e,-1,n)}function gs(e,t,n){return In(e,-1,n)}const ps=e=>new ir.Store({events:[],resources:[],view:"week",currentDate:new Date,selectedDate:new Date,selectedEventId:null,slotDuration:30,is24Hour:!0,...e}),xs=e=>({setEvents:t=>{e.setState(n=>({...n,events:t}))},addEvent:t=>{e.setState(n=>({...n,events:[...n.events,t]}))},updateEvent:t=>{e.setState(n=>({...n,events:n.events.map(r=>r.id===t.id?t:r)}))},deleteEvent:t=>{e.setState(n=>({...n,events:n.events.filter(r=>r.id!==t)}))},setResources:t=>{e.setState(n=>({...n,resources:t}))},setView:t=>{e.setState(n=>({...n,view:t}))},setCurrentDate:t=>{e.setState(n=>({...n,currentDate:t}))},setSelectedDate:t=>{e.setState(n=>({...n,selectedDate:t}))},setSelectedEventId:t=>{e.setState(n=>({...n,selectedEventId:t}))},setSlotDuration:t=>{e.setState(n=>({...n,slotDuration:t}))},setIs24Hour:t=>{e.setState(n=>({...n,is24Hour:t}))}}),we={events:new Map,resources:new Map};class Yn{name="SchedulerService";constructor(t=[]){this.initializeWithData(t)}async init(){console.log("[SchedulerService] Initialized")}async cleanup(){}initializeWithData(t,n=[]){we.events.clear(),we.resources.clear(),t.forEach(r=>{we.events.set(String(r.id),JSON.parse(JSON.stringify(r)))}),n.forEach(r=>{we.resources.set(String(r.id),JSON.parse(JSON.stringify(r)))})}async getEvents(t,n){return await this.simulateLatency(),!t||!n?Array.from(we.events.values()):Array.from(we.events.values()).filter(s=>{const i=new Date(s.start),l=new Date(s.end);return i>=t&&i<n||l>t&&l<=n||i<=t&&l>=n}).map(s=>({...s,start:new Date(s.start),end:new Date(s.end)}))}async addEvent(t){await this.simulateLatency();const n={id:t.id||Math.random().toString(36).substring(2,9),title:t.title||"Untitled Event",start:t.start||new Date,end:t.end||new Date(new Date().getTime()+3600*1e3),description:t.description,resourceId:t.resourceId,resourceIds:t.resourceIds,allDay:t.allDay||!1,...t};return we.events.set(n.id,n),n}async updateEvent(t){console.log("[SchedulerService] Updating event:",t.id,t.start,t.end),await this.simulateLatency();const n=String(t.id);if(we.events.has(n)){const s={...we.events.get(n),...t,id:n};return we.events.set(n,s),console.log("[SchedulerService] Event updated in DB:",s),s}else if(we.events.has(t.id)){const s={...we.events.get(t.id),...t};return we.events.set(t.id,s),s}throw console.error("[SchedulerService] Event not found in DB:",t.id,"Keys:",Array.from(we.events.keys())),new Error(`Event with ID ${t.id} not found`)}async deleteEvent(t){await this.simulateLatency();const n=String(t);we.events.has(n)?we.events.delete(n):we.events.has(t)&&we.events.delete(t)}async getResources(){return await this.simulateLatency(),Array.from(we.resources.values())}async addResource(t){return await this.simulateLatency(),t.id||(t.id=Math.random().toString(36).substring(2,9)),we.resources.set(t.id,t),t}simulateLatency(){return new Promise(t=>setTimeout(t,300))}}class bs{name="RecurrenceEngine";expandEvents(t,n,r){const s=[];return t.forEach(i=>{if(i.recurrenceRule||i.rrule)try{const l=i.recurrenceRule||i.rrule||"";if(!l)return;const d=new Date(i.start),m=new Date(i.end),g=mn.RRule.parseString(l);g.dtstart=d;const c=new mn.RRule(g).between(n,r,!0),N=new Set;i.exdate&&Array.isArray(i.exdate)?i.exdate.forEach(p=>{const h=new Date(p).getTime();isNaN(h)||N.add(h)}):typeof i.recurrenceException=="string"&&i.recurrenceException.split(",").forEach(p=>{const h=new Date(p).getTime();isNaN(h)||N.add(h)}),c.forEach(p=>{if(N.has(p.getTime()))return;const h=m.getTime()-d.getTime();if(isNaN(h))return;const _=new Date(p.getTime()+h);s.push({...i,id:`${i.id}-${p.getTime()}`,recurrenceId:String(i.id),start:p,end:_,originalStart:d})})}catch(l){console.error(`Error processing recurrence rule for event ${i.id}:`,l),s.push(i)}else s.push(i)}),s}cleanup(){}}const ws=(e,t,n)=>{const r=Y.useEzServiceRegistry(),{events:s,serviceRegistry:i=r,showWeekend:l=!0,recurrenceEngine:d,onEventCreate:m,onEventChange:g,onEventDelete:u}=e,c=Pe.useQueryClient(),N=Fe.getOrRegisterService(i,"SchedulerService",()=>new Yn(s||[])),p=d||Fe.getOrRegisterService(i,"RecurrenceEngine",()=>new bs);b.useEffect(()=>{s&&s.length>0&&(N.initializeWithData(s),c.invalidateQueries({queryKey:["scheduler-events"]}))},[s,N,c]);const h=b.useMemo(()=>{let k,M;if(t==="day"||t==="timeline-day")k=Re(n),M=Rt(n);else if(t==="month"||t==="timeline-month")k=t==="month"?nt(Yt(n),{weekStartsOn:0}):Yt(n),M=t==="month"?$t(Ut(n),{weekStartsOn:0}):Ut(n);else if(t==="week"||t==="workweek"||t==="timeline-week"){const v=nt(n,{weekStartsOn:0});k=t==="workweek"?dt(v,1):v,M=t==="workweek"?dt(v,5):$t(n,{weekStartsOn:0})}else k=Re(n),M=Rt(n);try{const v=jn({start:k,end:M});return l?v:v.filter(K=>{const $=K.getDay();return $!==0&&$!==6})}catch{return[n]}},[t,n,l]),_=h.length>0?Re(h[0]):new Date,P=h.length>0?Rt(h[h.length-1]):new Date,{data:G=[]}=Pe.useQuery({queryKey:["scheduler-events",_.toISOString(),P.toISOString()],queryFn:()=>N.getEvents(_,P),placeholderData:s||[]}),D=b.useMemo(()=>h.length===0?[]:p.expandEvents(G,_,P),[G,h,p,_,P]),H=b.useMemo(()=>h.length?D.filter(k=>wn(k.start,{start:_,end:P})||wn(k.end,{start:_,end:P})||k.start<_&&k.end>P):[],[D,h,_,P]),z=Pe.useMutation({mutationFn:async k=>{const M=await N.addEvent(k);return m&&await m(M),M},onMutate:async k=>{const M=["scheduler-events",_.toISOString(),P.toISOString()];await c.cancelQueries({queryKey:M});const v=c.getQueryData(M);return c.setQueryData(M,(K=[])=>{const $={...k,id:k.id||Date.now().toString(),start:k.start||new Date,end:k.end||new Date};return[...K,$]}),{previousEvents:v,queryKey:M}},onError:(k,M,v)=>{v?.previousEvents&&c.setQueryData(v.queryKey,v.previousEvents)},onSettled:()=>{c.invalidateQueries({queryKey:["scheduler-events"]})}}),se=Pe.useMutation({mutationFn:async k=>{const M=await N.updateEvent(k);return g&&await g(M),M},onMutate:async k=>{const M=["scheduler-events",_.toISOString(),P.toISOString()];await c.cancelQueries({queryKey:M});const v=c.getQueryData(M);return c.setQueryData(M,(K=[])=>K.map($=>$.id===k.id?k:$)),{previousEvents:v,queryKey:M}},onError:(k,M,v)=>{v?.previousEvents&&c.setQueryData(v.queryKey,v.previousEvents)},onSettled:()=>{c.invalidateQueries({queryKey:["scheduler-events"]})}}),y=Pe.useMutation({mutationFn:async k=>(await N.deleteEvent(k),u&&await u(k.toString()),k),onMutate:async k=>{const M=["scheduler-events",_.toISOString(),P.toISOString()];await c.cancelQueries({queryKey:M});const v=c.getQueryData(M);return c.setQueryData(M,(K=[])=>K.filter($=>$.id!==k)),{previousEvents:v,queryKey:M}},onError:(k,M,v)=>{v?.previousEvents&&c.setQueryData(v.queryKey,v.previousEvents)},onSettled:()=>{c.invalidateQueries({queryKey:["scheduler-events"]})}});return{schedulerService:N,recurrenceEngine:p,daysInView:h,visibleEvents:H,allEvents:G,addEvent:z.mutateAsync,updateEvent:se.mutateAsync,deleteEvent:y.mutateAsync,isUpdating:z.isPending||se.isPending||y.isPending}},ys=e=>{const{overscanCount:t=2,startHour:n="00:00",endHour:r="24:00"}=e,s=parseInt(n.split(":")[0],10),i=parseInt(r.split(":")[0],10),d=60/(e.slotDuration||30),m=Math.max(1,(i-s)*d),{rowVirtualizer:g,columnVirtualizer:u,parentRef:c}=_e.useVirtualization({rowCount:m,rowHeight:64,overscanCount:t,progressiveRendering:e.progressiveRendering,prefetchDistance:e.prefetchDistance,enableColumnVirtualization:e.view?.startsWith("timeline"),columnCount:e.view?.startsWith("timeline")?m:0,columnWidth:100,id:e.id,debug:e.debugVirtualization,onScrollStart:()=>{e.virtualScrollStart&&e.virtualScrollStart({virtualizer:{}})},onScrollStop:()=>{e.virtualScrollStop&&e.virtualScrollStop({virtualizer:{}})}});return{parentRef:c,rowVirtualizer:g,columnVirtualizer:u}},Ss=(e,t,n,r)=>{const s=m=>{t(m),r?.(m)};return{next:()=>{let m=e;n==="day"||n==="timeline-day"?m=dt(e,1):n==="week"||n==="workweek"||n==="timeline-week"?m=In(e,1):(n==="month"||n==="timeline-month")&&(m=Kt(e,1)),s(m)},prev:()=>{let m=e;n==="day"||n==="timeline-day"?m=hs(e):n==="week"||n==="workweek"||n==="timeline-week"?m=gs(e):(n==="month"||n==="timeline-month")&&(m=Un(e)),s(m)},today:()=>{s(new Date)}}};class vs extends Y.BaseService{name="HistoryService";undoStack=[];redoStack=[];maxHistorySize=50;constructor(){super({canUndo:!1,canRedo:!1})}record(t){const n={...t,timestamp:Date.now()};this.undoStack.push(n),this.undoStack.length>this.maxHistorySize&&this.undoStack.shift(),this.redoStack=[],this.updateState()}undo(){if(this.undoStack.length===0)return null;const t=this.undoStack.pop();return this.redoStack.push(t),this.updateState(),t}redo(){if(this.redoStack.length===0)return null;const t=this.redoStack.pop();return this.undoStack.push(t),this.updateState(),t}clear(){this.undoStack=[],this.redoStack=[],this.updateState()}updateState(){this.setState({canUndo:this.undoStack.length>0,canRedo:this.redoStack.length>0})}cleanup(){this.clear(),super.cleanup()}}class Es{name="SearchService";search(t,n,r={}){if(!n||!n.trim())return t;const s=r.matchCase?n:n.toLowerCase(),i=r.fields||["title","description","location"];return t.filter(l=>i.some(d=>{const m=l[d];return typeof m!="string"?!1:r.matchCase?m.includes(s):m.toLowerCase().includes(s)}))}cleanup(){}}class ks{name="TimezoneService";constructor(){}toTimezone(t,n){if(!n||n==="UTC"||n==="Local")return new Date(t);try{const s=new Date(t).toLocaleString("en-US",{timeZone:n});return new Date(s)}catch(r){return console.warn(`TimezoneService: Invalid timezone ${n}`,r),new Date(t)}}formatInTimezone(t,n,r){try{return new Intl.DateTimeFormat("en-US",{...r,timeZone:n}).format(new Date(t))}catch(s){return console.error("TimezoneService formatting error:",s),""}}getLocalTimezone(){return Intl.DateTimeFormat().resolvedOptions().timeZone}cleanup(){}}class Ts{name="AttendeeService";constructor(){}isValidEmail(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}getStatusLabel(t){switch(t){case"accepted":return"Accepted";case"declined":return"Declined";case"tentative":return"Tentative";case"needs-action":return"Needs Action";default:return"Unknown"}}cleanup(){}}class Ds{name="ReminderService";timer=null;checkInterval=6e4;onReminderTriggered;constructor(){}start(t){this.onReminderTriggered=t,this.timer&&clearInterval(this.timer),this.timer=setInterval(()=>this.checkReminders(),this.checkInterval)}stop(){this.timer&&(clearInterval(this.timer),this.timer=null)}checkReminders(){console.log("[ReminderService] Checking for due reminders...",this.onReminderTriggered)}getTriggerTime(t,n){return new Date(t.getTime()-n*6e4)}cleanup(){this.stop()}}const $n=e=>{const t=Y.useBaseComponent(e),{serviceRegistry:n,state:r,api:s}=t,l=cr.useServiceState("I18nService")?.dir||"ltr",m=e.dir==="auto"||!e.dir?l:e.dir,g=b.useMemo(()=>ps({events:e.events||[],resources:e.resources||[],view:e.view?e.view.toLowerCase():"week",currentDate:e.selectedDate||new Date,selectedDate:e.selectedDate||new Date,slotDuration:e.slotDuration||30,is24Hour:e.is24Hour??!0}),[]),u=b.useMemo(()=>xs(g),[g]),c=ar.useStore(g,F=>F);b.useEffect(()=>{e.events&&u.setEvents(e.events)},[e.events]),b.useEffect(()=>{e.resources&&u.setResources(e.resources)},[e.resources]),b.useEffect(()=>{if(e.view){const F=e.view.toLowerCase().replace(/[^a-z]/g,""),R={day:"day",week:"week",workweek:"workweek",month:"month",timelineday:"timeline-day",timelineweek:"timeline-week",timelineworkweek:"timeline-week",timelinemonth:"timeline-month",agenda:"agenda",timeline:"timeline-day"};u.setView(R[F]||F)}},[e.view,u]),b.useEffect(()=>{e.selectedDate&&(u.setCurrentDate(e.selectedDate),u.setSelectedDate(e.selectedDate))},[e.selectedDate]),b.useEffect(()=>{e.slotDuration!==void 0&&u.setSlotDuration(e.slotDuration)},[e.slotDuration]),b.useEffect(()=>{e.is24Hour!==void 0&&u.setIs24Hour(e.is24Hour)},[e.is24Hour]);const{view:N,currentDate:p,events:h}=c,{schedulerService:_,recurrenceEngine:P,daysInView:G,visibleEvents:D,allEvents:H,addEvent:z,updateEvent:se,deleteEvent:y,isUpdating:k}=ws({...e,events:h},N,p),{parentRef:M,rowVirtualizer:v,columnVirtualizer:K}=ys(e),{next:$,prev:q,today:De}=Ss(p,u.setCurrentDate,N,e.onDateChange),[X,ne]=b.useState(null),{selectedIndex:Me,setSelectedIndex:me}=Cn({totalItems:D.length,enabled:!0,onSelect:F=>{const R=D[F];R&&(ne(R.id),(document.getElementById(`event-${R.id}`)||document.querySelector(`[data-event-id="${R.id}"]`))?.scrollIntoView({behavior:"smooth",block:"nearest"}))},onAction:F=>{const R=D[F];R&&e.onEventClick&&e.onEventClick(R)}}),Se=b.useMemo(()=>({showWeekend:e.showWeekend??!0,timeFormat:e.timeFormat,weekRule:e.weekRule||"FirstDay",monthsCount:e.monthsCount||1,eventDragArea:e.eventDragArea,dir:m||"ltr"}),[e.showWeekend,e.timeFormat,e.weekRule,e.monthsCount,e.eventDragArea,m]),ie=Fe.getOrRegisterService(n,"HistoryService",()=>new vs),ue=Fe.getOrRegisterService(n,"SearchService",()=>new Es),Z=Fe.getOrRegisterService(n,"TimezoneService",()=>new ks),he=Fe.getOrRegisterService(n,"AttendeeService",()=>new Ts),ee=Fe.getOrRegisterService(n,"ReminderService",()=>new Ds);return{state:{currentView:c.view,selectedDate:c.selectedDate,currentDate:p,events:c.events,resources:c.resources,viewEvents:D,daysInView:G,allEvents:H,slotDuration:c.slotDuration,is24Hour:c.is24Hour,isUpdating:k,selectedIndex:Me,highlightedEventId:X},actions:{nextPeriod:$,prevPeriod:q,today:De,setView:u.setView,setDate:u.setSelectedDate,setCurrentDate:u.setCurrentDate,addEvent:z,updateEvent:se,deleteEvent:y,setSlotDuration:u.setSlotDuration,setIs24Hour:u.setIs24Hour,setSelectedIndex:me,setHighlightedEventId:ne},services:{schedulerService:_,recurrenceEngine:P,historyService:ie,searchService:ue,timezoneService:Z,attendeeService:he,reminderService:ee,serviceRegistry:n},config:Se,refs:{parentRef:M,rowVirtualizer:v,columnVirtualizer:K},baseState:r,baseApi:s,dir:m}},Ms=(e,t,n,r,s,i,l={})=>{const d=b.useMemo(()=>{const m=Pe.createNavigationMethods(s.scrollToIndex),g=Pe.createCRUDMethods(()=>n.getEvents(),p=>n.addEvent(p),p=>n.updateEvent(p),p=>n.deleteEvent(p)),u=Pe.createSpinnerMethods(s.showSpinner,s.hideSpinner),c=Pe.createRefreshMethods(()=>{},s.forceUpdate),N=Pe.createExportMethods(()=>l.onExportExcel?.(r),()=>l.onExportICS?.(r),()=>{window.print()});return{changeView:s.changeView,changeCurrentView:s.changeView,next:s.next,prev:s.prev,today:s.today,...m,scrollTo:(p,h=0)=>{const P=parseInt(p.split(":")[0])*60+h,D=Math.floor(P/30);s.scrollToIndex(D)},scrollToTime:(p,h)=>{const _=p*60+h,G=Math.floor(_/30);s.scrollToIndex(G)},...g,getEvents:async()=>n.getEvents(),getEventsInDateRange:async(p,h)=>n.getEvents(p,h),addEvent:async p=>{await n.addEvent(p)},saveEvent:async p=>{await n.updateEvent(p)},deleteEvent:async p=>{await n.deleteEvent(p)},getCurrentViewEvents:()=>r,addResource:async p=>{s.setResources(h=>[...h,p])},removeResource:async p=>{s.setResources(h=>h.filter(_=>_.id!==p))},openEditor:(p,h="Add")=>{s.setEditorState({isOpen:!0,mode:h==="Edit"?"edit":h==="view"?"view":"create",event:p})},closeEditor:()=>s.setEditorState({isOpen:!1,mode:"create",event:void 0}),closeQuickInfoPopup:s.closeQuickInfoPopup,...u,...c,...N,currentView:e,...l}},[e,t,r,s,n,l]);Fe.useComponentImperativeAPI(i,d)},Ns=({resources:e})=>{const t=b.useMemo(()=>!e||e.length===0?[]:"dataSource"in e[0]?e.flatMap(s=>s.dataSource):e,[e]),[n,r]=b.useState(t);return b.useEffect(()=>{r(t)},[t]),{resources:t,internalResources:n,setInternalResources:r}},_s=({events:e,onEventChange:t,slotDuration:n=30})=>{const r=b.useCallback(i=>{const{active:l,over:d,delta:m}=i,g=e.find(c=>c.id===l.id||c.id===(l.data?.current?.eventId||l.data?.current?.id));if(!g)return;if(l.data?.current?.type?.startsWith("resize-")){const c=l.data.current.type,N=l.data.current,p=N?.orientation||"vertical",h=N?.pixelsPerSlot||64,_=p==="vertical"?m.y:m.x,P=Math.round(_/h)*n;if(P===0)return;if(c==="resize-bottom"){const G=new Date(g.end.getTime()+P*60*1e3),D=new Date(g.start.getTime()+n*60*1e3),H=G<D?D:G;t?.({...g,end:H})}else if(c==="resize-top"){const G=new Date(g.start.getTime()+P*60*1e3),D=new Date(g.end.getTime()-n*60*1e3),H=G>D?D:G;t?.({...g,start:H})}return}if(typeof d.id=="string"&&d.id.startsWith("slot-")){const c=d.data?.current?.date,N=d.data?.current?.resourceId;if(c){const p=g.end.getTime()-g.start.getTime(),h=new Date(c),_=new Date(h.getTime()+p);t?.({...g,start:h,end:_,resourceId:N==="none"?void 0:N})}return}const u=typeof d.id=="string"&&d.id.startsWith("header-")?d.id.replace("header-",""):null;if(u){const c={...g,resourceId:u};t?.(c)}},[e,t,n]);return{sensors:_e.useSensors(_e.useSensor(_e.PointerSensor,{activationConstraint:{distance:8}})),handleDragEnd:r}},Cs=()=>o.jsx("div",{className:"flex flex-col items-center justify-center min-h-screen p-4",children:o.jsxs("div",{className:"flex flex-col items-center gap-4 max-w-md w-full",children:[o.jsx("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-destructive/10",children:o.jsx(Fe.TriangleAlert,{className:"w-8 h-8 text-destructive"})}),o.jsxs("div",{className:"flex flex-col items-center gap-2 text-center",children:[o.jsx("h2",{className:"text-lg font-semibold",children:"Scheduler Error"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Something went wrong with the scheduler. Please refresh the page or try again."})]}),o.jsxs("button",{onClick:()=>window.location.reload(),className:"flex items-center gap-2 px-4 py-2 text-sm font-medium text-primary hover:bg-primary/10 rounded-md transition-colors",children:[o.jsx(Fe.RefreshCw,{className:"w-4 h-4"}),"Refresh Page"]})]})}),Os=({variant:e="primary",text:t="Loading",className:n})=>{const r="absolute inset-0 bg-background/40 backdrop-blur-[2px] z-[100] flex items-center justify-center transition-all duration-300",s={md:"w-10 h-10"},i={primary:"border-primary/20 border-t-primary",secondary:"border-muted-foreground/20 border-t-muted-foreground"};return o.jsx("div",{className:Y.cn(r,n),children:o.jsxs("div",{className:"flex flex-col items-center gap-3",children:[o.jsx("div",{className:Y.cn(s.md,i[e],"rounded-full animate-spin")}),o.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest text-primary animate-pulse",children:t})]})})},As=()=>o.jsx(Os,{text:"Synchronizing"}),Gn=({event:e,style:t,onClick:n,onDoubleClick:r,onDelete:s,orientation:i="vertical",resizable:l=!1,className:d,showTime:m=!0,isBlocked:g=!1,isPast:u=!1,isHighlighted:c=!1,slotDuration:N=30,pixelsPerSlot:p})=>{const h=g||e.isBlock,_=h||u,{attributes:P,listeners:G,setNodeRef:D,transform:H,isDragging:z}=_e.useDraggable({id:e.id,data:e,disabled:_}),se=p||(i==="vertical"?64:80),{attributes:y,listeners:k,setNodeRef:M,transform:v,isDragging:K}=_e.useDraggable({id:`resize-bottom-${e.id}`,data:{type:"resize-bottom",eventId:e.id,orientation:i,pixelsPerSlot:se},disabled:!l||_}),{attributes:$,listeners:q,setNodeRef:De,transform:X,isDragging:ne}=_e.useDraggable({id:`resize-top-${e.id}`,data:{type:"resize-top",eventId:e.id,orientation:i,pixelsPerSlot:se},disabled:!l||_}),Me=K||ne,me=se/N;let Se=new Date(e.start),ie=new Date(e.end);if(z&&H){const F=i==="vertical"?H.y:H.x,R=Math.round(F/me/15)*15;Se=Je(Se,R),ie=Je(ie,R)}else if(ne&&X){const F=i==="vertical"?X.y:X.x,R=Math.round(F/me/15)*15;Se=Je(Se,R)}else if(K&&v){const F=i==="vertical"?v.y:v.x,R=Math.round(F/me/15)*15;ie=Je(ie,R)}const ue=t?.borderColor||e.color||"hsl(var(--primary))",Z=h?{backgroundImage:"repeating - linear - gradient(45deg, transparent, transparent 10px, rgba(0, 0, 0, 0.05) 10px, rgba(0, 0, 0, 0.05) 20px)",backgroundColor:"rgba(0,0,0,0.02)",color:"gray",borderLeftWidth:"4px",borderColor:"#d1d5db",borderStyle:"solid",opacity:1}:{},he={...t,transform:_e.CSS.Translate.toString(H),opacity:z?.6:u?.7:1,zIndex:z||Me?100:_?10:20,touchAction:"none",pointerEvents:z||Me?"none":"auto",position:"absolute",backgroundColor:`color-mix(in srgb, ${ue} 12%, transparent)`,color:`color-mix(in srgb, ${ue} 90%, black)`,borderLeftWidth:"4px",borderColor:ue,...h?Z:{},...K&&i==="vertical"&&v?{height:`${Math.max((parseInt(t?.height)||0)+v.y,24)}px`}:{},...ne&&i==="vertical"&&X?{top:`${(parseInt(t?.top)||0)+X.y}px`,height:`${Math.max((parseInt(t?.height)||0)-X.y,24)}px`}:{},...K&&i==="horizontal"&&v?{width:`${Math.max((parseInt(t?.width)||0)+v.x,24)}px`}:{},...ne&&i==="horizontal"&&X?{left:`${(parseInt(t?.left)||0)+X.x}px`,width:`${Math.max((parseInt(t?.width)||0)-X.x,24)}px`}:{}},ee=o.jsxs("div",{ref:D,style:he,...P,...G,className:Y.cn("absolute rounded-md text-xs border overflow-hidden group select-none flex flex-col","bg-primary/10 border-primary/20 text-foreground shadow-sm hover:shadow-md transition-shadow",z&&"opacity-50 z-50 shadow-xl scale-105 cursor-grabbing ring-2 ring-primary ring-offset-2",c&&"ring-2 ring-primary ring-offset-1 bg-primary/20 shadow-md transition-all duration-300",h&&"bg-muted/50 border-muted opacity-80",!h&&"pointer-events-auto",h&&"pointer-events-auto select-none grayscale",d),onClick:F=>{!z&&!Me&&(F.stopPropagation(),n?.(e))},onDoubleClick:F=>{F.stopPropagation(),r?.(e)},role:"button","aria-label":`Event: ${e.title}`,children:[o.jsxs("div",{className:"flex-1 min-h-0 relative px-2 py-1",children:[o.jsxs("div",{className:"flex items-start justify-between gap-1",children:[o.jsx("div",{className:"font-semibold truncate pr-4 leading-tight",children:e.title}),!h&&o.jsx("button",{className:"opacity-0 group-hover:opacity-100 transition-opacity p-0.5 hover:bg-destructive/10 rounded absolute top-0 right-0 z-10",onClick:F=>{F.stopPropagation(),s?.(e.id)},onPointerDown:F=>F.stopPropagation(),children:o.jsx(Ke.X,{className:"h-3 w-3 text-muted-foreground hover:text-destructive"})})]}),m&&!h&&o.jsxs("div",{className:"text-[10px] text-muted-foreground truncate leading-tight",children:[de(Se,"h:mm a")," - ",de(ie,"h:mm a")]}),e.description&&o.jsx("div",{className:"text-[10px] text-muted-foreground line-clamp-2 leading-tight mt-0.5",children:e.description}),h&&o.jsx("div",{className:"flex items-center justify-center h-full",children:o.jsx("span",{className:"text-xs font-medium text-muted-foreground opacity-70 -rotate-45 select-none",children:"BLOCKED"})})]}),l&&!h&&o.jsxs(o.Fragment,{children:[o.jsx("div",{ref:M,...y,...k,className:Y.cn("absolute z-20 hover:bg-primary/20 transition-colors flex items-center justify-center opacity-0 group-hover:opacity-100",i==="vertical"?"bottom-0 left-0 right-0 h-3 cursor-ns-resize":"right-0 top-0 bottom-0 w-3 cursor-ew-resize"),style:{touchAction:"none"},children:o.jsx("div",{className:Y.cn("bg-primary/40 rounded-full",i==="vertical"?"w-10 h-1":"h-10 w-1")})}),o.jsx("div",{ref:De,...$,...q,className:Y.cn("absolute z-20 hover:bg-primary/20 transition-colors flex items-center justify-center opacity-0 group-hover:opacity-100",i==="vertical"?"top-0 left-0 right-0 h-3 cursor-ns-resize":"left-0 top-0 bottom-0 w-3 cursor-ew-resize"),style:{touchAction:"none"},children:o.jsx("div",{className:Y.cn("bg-primary/40 rounded-full",i==="vertical"?"w-10 h-1 shadow-[0_-1px_0_rgba(0,0,0,0.1)]":"h-10 w-1 shadow-[-1px_0_0_rgba(0,0,0,0.1)]")})})]})]});return o.jsx(Pe.TooltipWrapper,{content:e.description,enabled:!!e.description&&!z,children:o.jsx(_e.EzContextMenu,{contextId:"scheduler-event",data:e,children:ee})})},Is=({date:e,resourceId:t,children:n,className:r,style:s,onClick:i,onDoubleClick:l,onMouseDown:d,onMouseEnter:m,onContextMenu:g,data:u,isSelected:c,isWorkHour:N})=>{const{active:p}=_e.useDndContext(),{setNodeRef:h,isOver:_}=_e.useDroppable({id:`slot-${e.toISOString()}-${t||"none"}`,data:{date:e,resourceId:t,...u||{}}}),P=!!p;return o.jsx("div",{ref:h,"data-testid":"scheduler-slot","data-shaded":N===!1,className:Y.cn("relative transition-all duration-200",c&&"bg-primary/15",!c&&N===!1&&"bg-background",P&&"before:absolute before:inset-0 before:border before:border-dashed before:border-primary/10 before:pointer-events-none before:z-0",_&&"bg-primary/20 ring-2 ring-primary ring-inset z-10 before:opacity-0",r),style:s,onClick:i,onDoubleClick:l,onMouseDown:d,onMouseEnter:m,onContextMenu:g,children:n})};const{entries:qn,setPrototypeOf:yn,isFrozen:Rs,getPrototypeOf:js,getOwnPropertyDescriptor:Ps}=Object;let{freeze:Ce,seal:We,create:Nt}=Object,{apply:Gt,construct:qt}=typeof Reflect<"u"&&Reflect;Ce||(Ce=function(t){return t});We||(We=function(t){return t});Gt||(Gt=function(t,n){for(var r=arguments.length,s=new Array(r>2?r-2:0),i=2;i<r;i++)s[i-2]=arguments[i];return t.apply(n,s)});qt||(qt=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return new t(...r)});const Tt=Oe(Array.prototype.forEach),Ls=Oe(Array.prototype.lastIndexOf),Sn=Oe(Array.prototype.pop),pt=Oe(Array.prototype.push),zs=Oe(Array.prototype.splice),_t=Oe(String.prototype.toLowerCase),Pt=Oe(String.prototype.toString),Lt=Oe(String.prototype.match),xt=Oe(String.prototype.replace),Fs=Oe(String.prototype.indexOf),Ws=Oe(String.prototype.trim),je=Oe(Object.prototype.hasOwnProperty),Ne=Oe(RegExp.prototype.test),bt=Hs(TypeError);function Oe(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return Gt(e,t,r)}}function Hs(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return qt(e,n)}}function Q(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:_t;yn&&yn(e,null);let r=t.length;for(;r--;){let s=t[r];if(typeof s=="string"){const i=n(s);i!==s&&(Rs(t)||(t[r]=i),s=i)}e[s]=!0}return e}function Bs(e){for(let t=0;t<e.length;t++)je(e,t)||(e[t]=null);return e}function Ge(e){const t=Nt(null);for(const[n,r]of qn(e))je(e,n)&&(Array.isArray(r)?t[n]=Bs(r):r&&typeof r=="object"&&r.constructor===Object?t[n]=Ge(r):t[n]=r);return t}function wt(e,t){for(;e!==null;){const r=Ps(e,t);if(r){if(r.get)return Oe(r.get);if(typeof r.value=="function")return Oe(r.value)}e=js(e)}function n(){return null}return n}const vn=Ce(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),zt=Ce(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Ft=Ce(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Us=Ce(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Wt=Ce(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Ys=Ce(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),En=Ce(["#text"]),kn=Ce(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),Ht=Ce(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Tn=Ce(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Dt=Ce(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),$s=We(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Gs=We(/<%[\w\W]*|[\w\W]*%>/gm),qs=We(/\$\{[\w\W]*/gm),Vs=We(/^data-[\-\w.\u00B7-\uFFFF]+$/),Qs=We(/^aria-[\-\w]+$/),Vn=We(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Xs=We(/^(?:\w+script|data):/i),Ks=We(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Qn=We(/^html$/i),Js=We(/^[a-z][.\w]*(-[.\w]+)+$/i);var Dn=Object.freeze({__proto__:null,ARIA_ATTR:Qs,ATTR_WHITESPACE:Ks,CUSTOM_ELEMENT:Js,DATA_ATTR:Vs,DOCTYPE_NAME:Qn,ERB_EXPR:Gs,IS_ALLOWED_URI:Vn,IS_SCRIPT_OR_DATA:Xs,MUSTACHE_EXPR:$s,TMPLIT_EXPR:qs});const yt={element:1,text:3,progressingInstruction:7,comment:8,document:9},Zs=function(){return typeof window>"u"?null:window},eo=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const s="data-tt-policy-suffix";n&&n.hasAttribute(s)&&(r=n.getAttribute(s));const i="dompurify"+(r?"#"+r:"");try{return t.createPolicy(i,{createHTML(l){return l},createScriptURL(l){return l}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},Mn=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Xn(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Zs();const t=O=>Xn(O);if(t.version="3.3.2",t.removed=[],!e||!e.document||e.document.nodeType!==yt.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const r=n,s=r.currentScript,{DocumentFragment:i,HTMLTemplateElement:l,Node:d,Element:m,NodeFilter:g,NamedNodeMap:u=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:c,DOMParser:N,trustedTypes:p}=e,h=m.prototype,_=wt(h,"cloneNode"),P=wt(h,"remove"),G=wt(h,"nextSibling"),D=wt(h,"childNodes"),H=wt(h,"parentNode");if(typeof l=="function"){const O=n.createElement("template");O.content&&O.content.ownerDocument&&(n=O.content.ownerDocument)}let z,se="";const{implementation:y,createNodeIterator:k,createDocumentFragment:M,getElementsByTagName:v}=n,{importNode:K}=r;let $=Mn();t.isSupported=typeof qn=="function"&&typeof H=="function"&&y&&y.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:q,ERB_EXPR:De,TMPLIT_EXPR:X,DATA_ATTR:ne,ARIA_ATTR:Me,IS_SCRIPT_OR_DATA:me,ATTR_WHITESPACE:Se,CUSTOM_ELEMENT:ie}=Dn;let{IS_ALLOWED_URI:ue}=Dn,Z=null;const he=Q({},[...vn,...zt,...Ft,...Wt,...En]);let ee=null;const F=Q({},[...kn,...Ht,...Tn,...Dt]);let R=Object.seal(Nt(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),He=null,ge=null;const Ae=Object.seal(Nt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let S=!0,B=!0,V=!1,le=!0,ae=!1,Ze=!0,Be=!1,Ue=!1,ze=!1,x=!1,A=!1,w=!1,C=!0,E=!1;const I="user-content-";let W=!0,U=!1,j={},L=null;const te=Q({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let J=null;const ve=Q({},["audio","video","img","source","image","track"]);let pe=null;const Ye=Q({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),rt="http://www.w3.org/1998/Math/MathML",qe="http://www.w3.org/2000/svg",xe="http://www.w3.org/1999/xhtml";let et=xe,ft=!1,Ee=null;const st=Q({},[rt,qe,xe],Pt);let Et=Q({},["mi","mo","mn","ms","mtext"]),kt=Q({},["annotation-xml"]);const er=Q({},["title","style","font","a","script"]);let mt=null;const tr=["application/xhtml+xml","text/html"],nr="text/html";let ye=null,it=null;const rr=n.createElement("form"),en=function(a){return a instanceof RegExp||a instanceof Function},Ot=function(){let a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(it&&it===a)){if((!a||typeof a!="object")&&(a={}),a=Ge(a),mt=tr.indexOf(a.PARSER_MEDIA_TYPE)===-1?nr:a.PARSER_MEDIA_TYPE,ye=mt==="application/xhtml+xml"?Pt:_t,Z=je(a,"ALLOWED_TAGS")?Q({},a.ALLOWED_TAGS,ye):he,ee=je(a,"ALLOWED_ATTR")?Q({},a.ALLOWED_ATTR,ye):F,Ee=je(a,"ALLOWED_NAMESPACES")?Q({},a.ALLOWED_NAMESPACES,Pt):st,pe=je(a,"ADD_URI_SAFE_ATTR")?Q(Ge(Ye),a.ADD_URI_SAFE_ATTR,ye):Ye,J=je(a,"ADD_DATA_URI_TAGS")?Q(Ge(ve),a.ADD_DATA_URI_TAGS,ye):ve,L=je(a,"FORBID_CONTENTS")?Q({},a.FORBID_CONTENTS,ye):te,He=je(a,"FORBID_TAGS")?Q({},a.FORBID_TAGS,ye):Ge({}),ge=je(a,"FORBID_ATTR")?Q({},a.FORBID_ATTR,ye):Ge({}),j=je(a,"USE_PROFILES")?a.USE_PROFILES:!1,S=a.ALLOW_ARIA_ATTR!==!1,B=a.ALLOW_DATA_ATTR!==!1,V=a.ALLOW_UNKNOWN_PROTOCOLS||!1,le=a.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ae=a.SAFE_FOR_TEMPLATES||!1,Ze=a.SAFE_FOR_XML!==!1,Be=a.WHOLE_DOCUMENT||!1,x=a.RETURN_DOM||!1,A=a.RETURN_DOM_FRAGMENT||!1,w=a.RETURN_TRUSTED_TYPE||!1,ze=a.FORCE_BODY||!1,C=a.SANITIZE_DOM!==!1,E=a.SANITIZE_NAMED_PROPS||!1,W=a.KEEP_CONTENT!==!1,U=a.IN_PLACE||!1,ue=a.ALLOWED_URI_REGEXP||Vn,et=a.NAMESPACE||xe,Et=a.MATHML_TEXT_INTEGRATION_POINTS||Et,kt=a.HTML_INTEGRATION_POINTS||kt,R=a.CUSTOM_ELEMENT_HANDLING||{},a.CUSTOM_ELEMENT_HANDLING&&en(a.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(R.tagNameCheck=a.CUSTOM_ELEMENT_HANDLING.tagNameCheck),a.CUSTOM_ELEMENT_HANDLING&&en(a.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(R.attributeNameCheck=a.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),a.CUSTOM_ELEMENT_HANDLING&&typeof a.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(R.allowCustomizedBuiltInElements=a.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),ae&&(B=!1),A&&(x=!0),j&&(Z=Q({},En),ee=Nt(null),j.html===!0&&(Q(Z,vn),Q(ee,kn)),j.svg===!0&&(Q(Z,zt),Q(ee,Ht),Q(ee,Dt)),j.svgFilters===!0&&(Q(Z,Ft),Q(ee,Ht),Q(ee,Dt)),j.mathMl===!0&&(Q(Z,Wt),Q(ee,Tn),Q(ee,Dt))),je(a,"ADD_TAGS")||(Ae.tagCheck=null),je(a,"ADD_ATTR")||(Ae.attributeCheck=null),a.ADD_TAGS&&(typeof a.ADD_TAGS=="function"?Ae.tagCheck=a.ADD_TAGS:(Z===he&&(Z=Ge(Z)),Q(Z,a.ADD_TAGS,ye))),a.ADD_ATTR&&(typeof a.ADD_ATTR=="function"?Ae.attributeCheck=a.ADD_ATTR:(ee===F&&(ee=Ge(ee)),Q(ee,a.ADD_ATTR,ye))),a.ADD_URI_SAFE_ATTR&&Q(pe,a.ADD_URI_SAFE_ATTR,ye),a.FORBID_CONTENTS&&(L===te&&(L=Ge(L)),Q(L,a.FORBID_CONTENTS,ye)),a.ADD_FORBID_CONTENTS&&(L===te&&(L=Ge(L)),Q(L,a.ADD_FORBID_CONTENTS,ye)),W&&(Z["#text"]=!0),Be&&Q(Z,["html","head","body"]),Z.table&&(Q(Z,["tbody"]),delete He.tbody),a.TRUSTED_TYPES_POLICY){if(typeof a.TRUSTED_TYPES_POLICY.createHTML!="function")throw bt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof a.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw bt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');z=a.TRUSTED_TYPES_POLICY,se=z.createHTML("")}else z===void 0&&(z=eo(p,s)),z!==null&&typeof se=="string"&&(se=z.createHTML(""));Ce&&Ce(a),it=a}},tn=Q({},[...zt,...Ft,...Us]),nn=Q({},[...Wt,...Ys]),sr=function(a){let f=H(a);(!f||!f.tagName)&&(f={namespaceURI:et,tagName:"template"});const T=_t(a.tagName),ce=_t(f.tagName);return Ee[a.namespaceURI]?a.namespaceURI===qe?f.namespaceURI===xe?T==="svg":f.namespaceURI===rt?T==="svg"&&(ce==="annotation-xml"||Et[ce]):!!tn[T]:a.namespaceURI===rt?f.namespaceURI===xe?T==="math":f.namespaceURI===qe?T==="math"&&kt[ce]:!!nn[T]:a.namespaceURI===xe?f.namespaceURI===qe&&!kt[ce]||f.namespaceURI===rt&&!Et[ce]?!1:!nn[T]&&(er[T]||!tn[T]):!!(mt==="application/xhtml+xml"&&Ee[a.namespaceURI]):!1},$e=function(a){pt(t.removed,{element:a});try{H(a).removeChild(a)}catch{P(a)}},ot=function(a,f){try{pt(t.removed,{attribute:f.getAttributeNode(a),from:f})}catch{pt(t.removed,{attribute:null,from:f})}if(f.removeAttribute(a),a==="is")if(x||A)try{$e(f)}catch{}else try{f.setAttribute(a,"")}catch{}},rn=function(a){let f=null,T=null;if(ze)a="<remove></remove>"+a;else{const be=Lt(a,/^[\r\n\t ]+/);T=be&&be[0]}mt==="application/xhtml+xml"&&et===xe&&(a='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+a+"</body></html>");const ce=z?z.createHTML(a):a;if(et===xe)try{f=new N().parseFromString(ce,mt)}catch{}if(!f||!f.documentElement){f=y.createDocument(et,"template",null);try{f.documentElement.innerHTML=ft?se:ce}catch{}}const Te=f.body||f.documentElement;return a&&T&&Te.insertBefore(n.createTextNode(T),Te.childNodes[0]||null),et===xe?v.call(f,Be?"html":"body")[0]:Be?f.documentElement:Te},sn=function(a){return k.call(a.ownerDocument||a,a,g.SHOW_ELEMENT|g.SHOW_COMMENT|g.SHOW_TEXT|g.SHOW_PROCESSING_INSTRUCTION|g.SHOW_CDATA_SECTION,null)},At=function(a){return a instanceof c&&(typeof a.nodeName!="string"||typeof a.textContent!="string"||typeof a.removeChild!="function"||!(a.attributes instanceof u)||typeof a.removeAttribute!="function"||typeof a.setAttribute!="function"||typeof a.namespaceURI!="string"||typeof a.insertBefore!="function"||typeof a.hasChildNodes!="function")},on=function(a){return typeof d=="function"&&a instanceof d};function Ve(O,a,f){Tt(O,T=>{T.call(t,a,f,it)})}const an=function(a){let f=null;if(Ve($.beforeSanitizeElements,a,null),At(a))return $e(a),!0;const T=ye(a.nodeName);if(Ve($.uponSanitizeElement,a,{tagName:T,allowedTags:Z}),Ze&&a.hasChildNodes()&&!on(a.firstElementChild)&&Ne(/<[/\w!]/g,a.innerHTML)&&Ne(/<[/\w!]/g,a.textContent)||a.nodeType===yt.progressingInstruction||Ze&&a.nodeType===yt.comment&&Ne(/<[/\w]/g,a.data))return $e(a),!0;if(!(Ae.tagCheck instanceof Function&&Ae.tagCheck(T))&&(!Z[T]||He[T])){if(!He[T]&&ln(T)&&(R.tagNameCheck instanceof RegExp&&Ne(R.tagNameCheck,T)||R.tagNameCheck instanceof Function&&R.tagNameCheck(T)))return!1;if(W&&!L[T]){const ce=H(a)||a.parentNode,Te=D(a)||a.childNodes;if(Te&&ce){const be=Te.length;for(let Ie=be-1;Ie>=0;--Ie){const Qe=_(Te[Ie],!0);Qe.__removalCount=(a.__removalCount||0)+1,ce.insertBefore(Qe,G(a))}}}return $e(a),!0}return a instanceof m&&!sr(a)||(T==="noscript"||T==="noembed"||T==="noframes")&&Ne(/<\/no(script|embed|frames)/i,a.innerHTML)?($e(a),!0):(ae&&a.nodeType===yt.text&&(f=a.textContent,Tt([q,De,X],ce=>{f=xt(f,ce," ")}),a.textContent!==f&&(pt(t.removed,{element:a.cloneNode()}),a.textContent=f)),Ve($.afterSanitizeElements,a,null),!1)},cn=function(a,f,T){if(ge[f]||C&&(f==="id"||f==="name")&&(T in n||T in rr))return!1;if(!(B&&!ge[f]&&Ne(ne,f))){if(!(S&&Ne(Me,f))){if(!(Ae.attributeCheck instanceof Function&&Ae.attributeCheck(f,a))){if(!ee[f]||ge[f]){if(!(ln(a)&&(R.tagNameCheck instanceof RegExp&&Ne(R.tagNameCheck,a)||R.tagNameCheck instanceof Function&&R.tagNameCheck(a))&&(R.attributeNameCheck instanceof RegExp&&Ne(R.attributeNameCheck,f)||R.attributeNameCheck instanceof Function&&R.attributeNameCheck(f,a))||f==="is"&&R.allowCustomizedBuiltInElements&&(R.tagNameCheck instanceof RegExp&&Ne(R.tagNameCheck,T)||R.tagNameCheck instanceof Function&&R.tagNameCheck(T))))return!1}else if(!pe[f]){if(!Ne(ue,xt(T,Se,""))){if(!((f==="src"||f==="xlink:href"||f==="href")&&a!=="script"&&Fs(T,"data:")===0&&J[a])){if(!(V&&!Ne(me,xt(T,Se,"")))){if(T)return!1}}}}}}}return!0},ln=function(a){return a!=="annotation-xml"&&Lt(a,ie)},dn=function(a){Ve($.beforeSanitizeAttributes,a,null);const{attributes:f}=a;if(!f||At(a))return;const T={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ee,forceKeepAttr:void 0};let ce=f.length;for(;ce--;){const Te=f[ce],{name:be,namespaceURI:Ie,value:Qe}=Te,ct=ye(be),It=Qe;let ke=be==="value"?It:Ws(It);if(T.attrName=ct,T.attrValue=ke,T.keepAttr=!0,T.forceKeepAttr=void 0,Ve($.uponSanitizeAttribute,a,T),ke=T.attrValue,E&&(ct==="id"||ct==="name")&&(ot(be,a),ke=I+ke),Ze&&Ne(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,ke)){ot(be,a);continue}if(ct==="attributename"&&Lt(ke,"href")){ot(be,a);continue}if(T.forceKeepAttr)continue;if(!T.keepAttr){ot(be,a);continue}if(!le&&Ne(/\/>/i,ke)){ot(be,a);continue}ae&&Tt([q,De,X],fn=>{ke=xt(ke,fn," ")});const un=ye(a.nodeName);if(!cn(un,ct,ke)){ot(be,a);continue}if(z&&typeof p=="object"&&typeof p.getAttributeType=="function"&&!Ie)switch(p.getAttributeType(un,ct)){case"TrustedHTML":{ke=z.createHTML(ke);break}case"TrustedScriptURL":{ke=z.createScriptURL(ke);break}}if(ke!==It)try{Ie?a.setAttributeNS(Ie,be,ke):a.setAttribute(be,ke),At(a)?$e(a):Sn(t.removed)}catch{ot(be,a)}}Ve($.afterSanitizeAttributes,a,null)},or=function O(a){let f=null;const T=sn(a);for(Ve($.beforeSanitizeShadowDOM,a,null);f=T.nextNode();)Ve($.uponSanitizeShadowNode,f,null),an(f),dn(f),f.content instanceof i&&O(f.content);Ve($.afterSanitizeShadowDOM,a,null)};return t.sanitize=function(O){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},f=null,T=null,ce=null,Te=null;if(ft=!O,ft&&(O="<!-->"),typeof O!="string"&&!on(O))if(typeof O.toString=="function"){if(O=O.toString(),typeof O!="string")throw bt("dirty is not a string, aborting")}else throw bt("toString is not a function");if(!t.isSupported)return O;if(Ue||Ot(a),t.removed=[],typeof O=="string"&&(U=!1),U){if(O.nodeName){const Qe=ye(O.nodeName);if(!Z[Qe]||He[Qe])throw bt("root node is forbidden and cannot be sanitized in-place")}}else if(O instanceof d)f=rn("<!---->"),T=f.ownerDocument.importNode(O,!0),T.nodeType===yt.element&&T.nodeName==="BODY"||T.nodeName==="HTML"?f=T:f.appendChild(T);else{if(!x&&!ae&&!Be&&O.indexOf("<")===-1)return z&&w?z.createHTML(O):O;if(f=rn(O),!f)return x?null:w?se:""}f&&ze&&$e(f.firstChild);const be=sn(U?O:f);for(;ce=be.nextNode();)an(ce),dn(ce),ce.content instanceof i&&or(ce.content);if(U)return O;if(x){if(A)for(Te=M.call(f.ownerDocument);f.firstChild;)Te.appendChild(f.firstChild);else Te=f;return(ee.shadowroot||ee.shadowrootmode)&&(Te=K.call(r,Te,!0)),Te}let Ie=Be?f.outerHTML:f.innerHTML;return Be&&Z["!doctype"]&&f.ownerDocument&&f.ownerDocument.doctype&&f.ownerDocument.doctype.name&&Ne(Qn,f.ownerDocument.doctype.name)&&(Ie="<!DOCTYPE "+f.ownerDocument.doctype.name+`>
|
|
2
|
+
`+Ie),ae&&Tt([q,De,X],Qe=>{Ie=xt(Ie,Qe," ")}),z&&w?z.createHTML(Ie):Ie},t.setConfig=function(){let O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ot(O),Ue=!0},t.clearConfig=function(){it=null,Ue=!1},t.isValidAttribute=function(O,a,f){it||Ot({});const T=ye(O),ce=ye(a);return cn(T,ce,f)},t.addHook=function(O,a){typeof a=="function"&&pt($[O],a)},t.removeHook=function(O,a){if(a!==void 0){const f=Ls($[O],a);return f===-1?void 0:zs($[O],f,1)[0]}return Sn($[O])},t.removeHooks=function(O){$[O]=[]},t.removeAllHooks=function(){$=Mn()},t}var to=Xn();function Nn(e,t=!0){return t?to.sanitize(e,{ALLOWED_TAGS:["b","i","em","strong","u","span","div","p","br","h1","h2","h3","h4","h5","h6","ul","ol","li","a","img","table","thead","tbody","tr","th","td"],ALLOWED_ATTR:["class","style","href","src","alt","title"],ALLOW_DATA_ATTR:!1}):e}function no(e,t,n=!0){if(!e)return null;if(typeof e=="function"){const r=e(t);return typeof r=="string"?{__html:Nn(r,n)}:r}return typeof e=="string"?{__html:Nn(e,n)}:null}function ro(e,t="FirstDay"){switch(t){case"FirstDay":return St(e,{weekStartsOn:0});case"FirstFourDayWeek":return Jt(e);case"FirstFullWeek":return St(e,{weekStartsOn:0,firstWeekContainsDate:1});default:return St(e)}}const so=(e,t,n,r,s,i,l,d,m,g=!0,u=!1)=>{let c=0,N=0;if(g){const G=s/r,D=G/l;c=t*s+n*G+i*D,N=D*.98}else{const G=s/r,D=G/l;c=n*s+t*G+i*D,N=D*.98}const h=((e.start.getHours()-d)*60+e.start.getMinutes())/m*64,P=(e.end.getTime()-e.start.getTime())/(1e3*60)/m*64;return{top:`${h}px`,height:`${Math.max(P,24)}px`,[u?"right":"left"]:`${c}%`,width:`${N}%`,[u?"borderRightWidth":"borderLeftWidth"]:"4px",borderColor:e.color||"hsl(var(--primary))"}},oo=({startHour:e,slotDuration:t,isRtl:n})=>{const r=Qt(),i=((r.getHours()-e)*60+r.getMinutes())/t*64;return i<0?null:o.jsxs("div",{className:Y.cn("absolute inset-x-0 z-50 pointer-events-none flex items-center"),style:{top:`${i}px`},children:[o.jsx("div",{className:"w-full border-t-2 border-primary"}),o.jsx("div",{className:Y.cn("absolute w-3 h-3 bg-primary rounded-full shadow-sm ring-2 ring-background",n?"-right-1.5":"-left-1.5")})]})},ao=({daysInView:e,visibleEvents:t,rowVirtualizer:n,resources:r=[],showResourcesInDayView:s=!1,onEventClick:i,onEventDoubleClick:l,onEventDelete:d,scrollRef:m,onViewChange:g,onDateChange:u,locale:c,onRangeSelect:N,onSlotClick:p,onSlotDoubleClick:h,dateHeaderTemplate:_,showWeekNumber:P=!1,weekRule:G="FirstDay",cellTemplate:D,enableHtmlSanitizer:H=!0,showUnassignedLane:z=!1,startHour:se="00:00",slotDuration:y=30,is24Hour:k=!0,setIs24Hour:M,group:v,onCellContextMenu:K,dir:$})=>{const q=$==="rtl",De=Qt(),X=parseInt(se.split(":")[0],10),[ne,Me]=b.useState(null),[me,Se]=b.useState(!1),ie=b.useRef(null),ue=(w,C,E)=>t.some(W=>(W.isHoliday||W.isFullyBooked)&&fe(W.start,w))?!0:t.some(W=>W.isBlock&&(W.resourceId===E||!W.resourceId&&!E)&&Mt({start:W.start,end:W.end},{start:w,end:C})),Z=(w,C)=>{const E=Je(w,y);if(ue(w,E,C))return;Se(!0);const I={start:w,end:E,resourceId:C};Me(I),ie.current=I},he=w=>{if(!me||!ie.current)return;const C=new Date(w.getTime()+y*60*1e3),E={...ie.current,end:C};Me(E),ie.current=E};b.useEffect(()=>{const w=C=>{if(me&&ie.current){const{start:E,end:I,resourceId:W}=ie.current,U=E<I?E:I,j=E<I?I:E;ue(U,j,W)||(N?.(U,j,W,{x:C.clientX,y:C.clientY}),p?.(U,W))}Se(!1),Me(null),ie.current=null};return window.addEventListener("mouseup",w),()=>window.removeEventListener("mouseup",w)},[me,N,p]);const ee=Vt("(max-width: 768px)"),F=b.useMemo(()=>{let w=s&&r.length>0?[...r]:[];return(z||s&&w.length===0)&&(w.find(C=>C.id===""||C.id==="unassigned")||w.unshift({id:"unassigned",name:"Unassigned",type:"Global Inbox",color:"hsl(var(--muted-foreground))"})),w.length>0?w:[{id:"",name:""}]},[r,s,z]),R=ee&&s&&F.length>1,He=!ee&&(F.length>3||e.length>3&&F.length>1),ge=R||He,B=e.length*F.length*150,V={width:ge&&B>0?`${B}px`:"100%",minWidth:"100%"},le=new Intl.DateTimeFormat(c,{day:"numeric"}),ae=v?.byDate??!0,Ze=ae?e:F,Be=ae?F:e,Ue=Ze,ze=Be,x=100/Ue.length,A=100/ze.length;return o.jsxs("div",{ref:m,"data-testid":"scheduler-scroll-container","data-view":"day-week",style:{scrollbarGutter:"stable"},className:Y.cn("flex-1 flex flex-col min-h-0 relative overflow-auto bg-background select-none border border-border rounded-lg",ge&&"snap-x snap-mandatory"),children:[o.jsxs("div",{className:"sticky top-0 z-50 bg-background/95 backdrop-blur-md border-b border-border flex shrink-0",style:V,children:[P&&o.jsx("div",{className:Y.cn("w-12 shrink-0 sticky z-50 bg-background border-e border-border flex items-center justify-center",q?"right-0":"left-0"),children:o.jsx("span",{className:"text-[9px] font-bold text-muted-foreground uppercase tracking-wider",children:"WK"})}),o.jsxs("div",{className:Y.cn("w-24 shrink-0 sticky bg-background border-e border-border z-50 cursor-pointer hover:bg-muted/50 transition-colors flex flex-col items-center justify-center gap-1 group",P?q?"right-12":"left-12":q?"right-0":"left-0"),onClick:()=>M?.(!k),title:"Toggle 24h / AM-PM format",children:[o.jsx(_n,{className:"w-4 h-4 text-muted-foreground group-hover:text-primary transition-colors"}),o.jsx("span",{className:"text-[9px] font-bold uppercase text-muted-foreground/60 group-hover:text-primary/70",children:k?"24 Hours":"AM / PM"})]}),o.jsx("div",{className:"flex flex-1",style:ge?{width:"100%"}:void 0,children:Ue.map(w=>{const C=ae,E=C?w:null,I=C?null:w,W=C&&fe(E,new Date);return o.jsxs("div",{style:{width:`${x}%`},className:"flex flex-col border-e border-border last:border-e-0",children:[o.jsx("div",{className:Y.cn("flex flex-col items-center justify-center py-3 transition-colors shrink-0 border-e-2 border-foreground/20",W&&"bg-background"),children:C?(()=>{const U=t.find(j=>(j.isHoliday||j.isFullyBooked)&&fe(j.start,E));return o.jsxs("div",{className:"flex flex-col items-center relative w-full",children:[U?.isHoliday&&o.jsx("span",{className:"absolute -top-1 px-1.5 py-0.5 bg-destructive/10 text-destructive text-[9px] font-black uppercase tracking-tighter rounded-full border border-destructive/20 mb-1 leading-none shadow-sm",children:"Holiday"}),U?.isFullyBooked&&o.jsx("span",{className:"absolute -top-1 px-1.5 py-0.5 bg-warning/10 text-warning-foreground text-[9px] font-black uppercase tracking-tighter rounded-full border border-warning/20 mb-1 leading-none shadow-sm",children:"Fully Booked"}),_?o.jsx("div",{className:"h-full w-full flex items-center justify-center pt-2",children:typeof _=="function"?_({date:E,type:"Day",text:le.format(E)}):_}):o.jsx("div",{className:"flex flex-col items-center cursor-pointer hover:bg-muted/50 transition-colors pt-2",onClick:()=>{g&&u&&(u(E),g("day"))},children:e.length>1&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:Y.cn("text-base font-medium mt-0.5",W?"text-primary font-bold":"text-foreground"),children:de(E,"dd MMM yyyy")}),o.jsx("span",{className:Y.cn("text-sm font-medium uppercase tracking-wider",W?"text-primary":"text-muted-foreground/80"),children:de(E,"EEE")})]})})]})})():o.jsxs("div",{className:"flex items-center gap-2 px-2",children:[o.jsxs(Xe.Avatar,{className:"h-8 w-8 shadow-sm border border-background",children:[I.avatar&&o.jsx(Xe.AvatarImage,{src:I.avatar}),o.jsx(Xe.AvatarFallback,{className:"text-xs font-bold",children:I.name?.charAt(0)})]}),o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{className:"text-sm font-bold truncate",children:I.name}),o.jsx("span",{className:"text-[10px] text-muted-foreground truncate",children:I.type||"Resource"})]})]})}),ze.length>0&&o.jsx("div",{className:"flex w-full border-t border-border bg-background h-10 shrink-0",children:ze.map((U,j)=>{const L=C?null:U,te=C?U:null,J=L?t.find(pe=>pe.isHoliday&&fe(pe.start,L)):null,ve=L?t.find(pe=>pe.isFullyBooked&&fe(pe.start,L)):null;return o.jsx("div",{style:{width:`${A}%`},className:Y.cn("flex items-center justify-center px-1 border-e border-border/30 last:border-e-0 group",ge&&"snap-center",(j%2===0,"bg-background")),children:C?o.jsxs(o.Fragment,{children:[o.jsxs(Xe.Avatar,{className:"h-4 w-4 me-1 shadow-sm border border-background",children:[te.avatar&&o.jsx(Xe.AvatarImage,{src:te.avatar}),o.jsx(Xe.AvatarFallback,{className:"text-[7px] font-bold",children:te.name?.charAt(0)})]}),o.jsx("span",{className:"text-[9px] font-bold text-muted-foreground truncate group-hover:text-foreground transition-colors",children:te.name})]}):o.jsxs("div",{className:"flex flex-col items-center justify-center",children:[J&&o.jsx("span",{className:"text-xs font-black uppercase tracking-wider text-destructive bg-destructive/10 px-2 py-0.5 rounded-sm mb-0.5",children:"Holiday"}),ve&&o.jsx("span",{className:"text-xs font-black uppercase tracking-wider text-warning-foreground bg-warning/10 px-2 py-0.5 rounded-sm mb-0.5",children:"Fully Booked"}),o.jsx("span",{className:Y.cn("text-[10px] font-bold text-muted-foreground uppercase",J&&"text-destructive",ve&&"text-amber-600"),children:de(L,"EEE d")})]})},L?L.toISOString():te.id)})})]},C?E.toISOString():I.id)})})]}),o.jsxs("div",{"data-testid":"scheduler-virtual-body",className:"relative shrink-0",style:{height:`${n.getTotalSize()}px`,...V},children:[n.getVirtualItems().map(w=>{const C=w.index*y,E=X+Math.floor(C/60),I=C%60;let W="";if(k)W=`${E<10?"0"+E:E}:${I<10?"0"+I:I}`;else{const U=E>=12?"PM":"AM",j=E%12||12;W=`${j<10?"0"+j:j}:${I<10?"0"+I:I} ${U}`}return o.jsxs("div",{className:"absolute left-0 w-full flex",style:{height:"64px",top:`${w.start}px`},children:[o.jsxs("div",{className:Y.cn("w-24 shrink-0 flex flex-col items-end justify-center pe-3 border-e border-border bg-background z-50 sticky backdrop-blur-md",q?"right-0":"left-0"),children:[W&&o.jsx("span",{className:"text-sm text-foreground font-black bg-background px-1 relative z-50 uppercase tracking-tighter tabular-nums",children:W}),P&&E===0&&o.jsxs("span",{className:"text-[9px] text-muted-foreground/60 font-semibold mt-1",children:["W",ro(e[0],G)]})]}),o.jsxs("div",{className:"flex flex-1 relative",style:{height:"64px"},children:[o.jsx("div",{className:"absolute bottom-0 left-0 w-full border-b border-border/40"}),o.jsx("div",{className:"absolute top-1/2 left-0 w-full border-b border-dashed border-border/20 h-px"}),Ue.map(U=>o.jsx("div",{style:{width:`${x}%`},className:"h-full flex relative border-e-2 border-foreground/20 last:border-e-0",children:ze.map((j,L)=>{const te=ae?U:j,J=ae?j:U,ve=w.index+X,pe=te.getDay(),Ye=t.find(Ee=>Ee.isHoliday&&fe(Ee.start,te)),rt=t.find(Ee=>Ee.isFullyBooked&&fe(Ee.start,te));let qe=!0;J.workingHours?qe=J.workingHours.days.includes(pe)&&ve>=J.workingHours.start&&ve<J.workingHours.end:qe=pe!==0&&pe!==6&&ve>=9&&ve<17;const xe=new Date(new Date(te).setHours(E,I,0,0)),et=fe(te,new Date),ft=!!ne&&ne.resourceId===J.id&&xe>=ne.start&&xe<ne.end;return o.jsx(Is,{date:xe,resourceId:J.id,isWorkHour:qe,isSelected:ft,onMouseDown:()=>Z(xe,J.id),onMouseEnter:()=>he(xe),onDoubleClick:()=>{const Ee=Je(xe,y);ue(xe,Ee,J.id)||h?.(xe,J.id)},onContextMenu:Ee=>{Ee.preventDefault(),K?.({date:xe,x:Ee.clientX,y:Ee.clientY})},style:{width:`${A}%`,minWidth:"auto",height:"100%"},className:Y.cn("border-e border-border/30 relative cursor-pointer hover:bg-primary/5 transition-colors pointer-events-auto",L===ze.length-1&&"border-e-0",ge&&"snap-center",Ye&&"bg-[repeating-linear-gradient(-45deg,hsl(var(--destructive)/0.05)_0px,hsl(var(--destructive)/0.05)_10px,transparent_10px,transparent_20px)] bg-destructive/[0.02]",rt&&"bg-[repeating-linear-gradient(-45deg,theme(colors.warning/0.05)_0px,theme(colors.warning/0.05)_10px,transparent_10px,transparent_20px)] bg-warning/[0.02]",!Ye&&!rt&&"bg-background"),children:D?(()=>{const Ee={date:xe,resourceId:J.id,isWorkHour:qe,isToday:et},st=no(D,Ee,H);return st&&typeof st=="object"&&"__html"in st?o.jsx("div",{className:"w-full h-full",dangerouslySetInnerHTML:st}):o.jsx("div",{className:"w-full h-full",children:st})})():null},ae?J.id||L:te.toISOString()||L)})},ae?U.toISOString():U.id))]})]},w.index)}),o.jsxs("div",{className:"absolute top-0 h-full z-10",style:{width:"calc(100% - 6rem)",[q?"right":"left"]:"6rem",pointerEvents:"none"},children:[o.jsx(oo,{startHour:X,slotDuration:y,isRtl:q}),e.map((w,C)=>{const E=t.filter(W=>fe(w,W.start));E.sort((W,U)=>W.start.getTime()-U.start.getTime());const I=new Map;return E.forEach(W=>{let U=W.resourceId;!U&&z&&(U="unassigned");let j=F.findIndex(L=>L.id===U);if(j===-1)if(F.length===1&&(F[0].id===""||!s))j=0;else return;I.has(j)||I.set(j,[]),I.get(j).push(W)}),[...I.entries()].map(([W,U])=>{const j=[];return U.forEach(L=>{let te=!1;for(const J of j)if(J.some(ve=>Mt({start:ve.start,end:ve.end},{start:L.start,end:L.end}))){J.push(L),te=!0;break}te||j.push([L])}),j.map(L=>{const te=[];return L.forEach(J=>{let ve=!1;for(let pe=0;pe<te.length;pe++)if(!te[pe].some(Ye=>Mt({start:Ye.start,end:Ye.end},{start:J.start,end:J.end}))){te[pe].push(J),ve=!0;break}ve||te.push([J])}),L.map(J=>{const ve=te.findIndex(Ye=>Ye.includes(J)),pe=so(J,C,W,ae?F.length:e.length,x,ve,te.length,X,y,ae,q);return o.jsx(Gn,{event:J,style:pe,onClick:i,onDoubleClick:l,onDelete:d,orientation:"vertical",resizable:!0,isBlocked:J.isBlock,isPast:J.end<De,slotDuration:y,pixelsPerSlot:64},J.id)})})})})]})]})]})},io=({currentDate:e,daysInView:t,visibleEvents:n,onSlotClick:r,onSlotDoubleClick:s,onEventClick:i,moreEventsClick:l,dir:d})=>{const m=d==="rtl",g=u=>n.filter(c=>fe(c.start,u));return o.jsx(Ke.TooltipProvider,{children:o.jsxs("div",{className:"flex flex-col h-full w-full bg-background rounded-xl border border-border overflow-hidden shadow-sm",children:[o.jsx("div",{className:"grid grid-cols-7 border-b border-border bg-muted/30",children:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map((u,c)=>o.jsx("div",{className:"py-3 text-center text-xs font-semibold uppercase text-muted-foreground tracking-widest",children:u},c))}),o.jsx("div",{className:"grid grid-cols-7 grid-rows-6 flex-1 min-h-0 bg-muted/20 gap-px",children:t.map(u=>{const c=g(u).filter(D=>!D.isBlock),N=Bn(u,e),p=fe(u,new Date),h=4,_=c.slice(0,h),P=c.length-h,G=c.length;return o.jsxs("div",{onClick:()=>r?.(u),onDoubleClick:()=>s?.(u),className:Y.cn("relative flex flex-col p-2 transition-colors group bg-background focus-visible:z-10",!N&&"bg-muted/5 text-muted-foreground/50",N&&"hover:bg-muted/30","min-h-[100px]"),children:[o.jsxs("div",{className:Y.cn("flex items-center justify-between mb-1"),children:[o.jsx("span",{className:Y.cn("text-sm font-medium w-7 h-7 flex items-center justify-center rounded-full transition-all",p?"bg-primary text-primary-foreground shadow-sm font-bold scale-110":"text-foreground group-hover:bg-muted/50",!N&&"text-muted-foreground opacity-50"),children:de(u,"d")}),G>0&&o.jsx("span",{className:"text-[10px] text-muted-foreground font-medium px-1.5 py-0.5 rounded-full bg-muted/50",children:G})]}),o.jsxs("div",{className:"flex-1 flex flex-col gap-1.5 min-w-0",children:[_.map(D=>o.jsxs(Ke.Tooltip,{delayDuration:300,children:[o.jsx(Ke.TooltipTrigger,{asChild:!0,children:o.jsxs("div",{onClick:H=>{H.stopPropagation(),i?.(D)},className:Y.cn("group/event relative","flex items-center gap-2 px-2 py-1 rounded-md text-xs font-medium cursor-pointer transition-all shadow-sm hover:shadow-md border border-transparent hover:border-border/50 overflow-hidden bg-card hover:bg-accent/50",!N&&"opacity-60 grayscale"),style:{[m?"borderRight":"borderLeft"]:`3px solid ${D.color||"oklch(var(--primary))"}`},children:[o.jsx("div",{className:"flex-1 truncate leading-tight",children:D.title}),D.start&&o.jsx("span",{className:"text-[10px] text-muted-foreground/70 tabular-nums shrink-0",children:de(D.start,"h:mm a")})]})}),o.jsx(Ke.TooltipContent,{className:"p-3 max-w-xs bg-popover/95 backdrop-blur-sm border-border/50 shadow-xl",sideOffset:5,children:o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs("div",{className:"flex items-center gap-2 border-b border-border/50 pb-1.5",children:[o.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:D.color||"oklch(var(--primary))"}}),o.jsx("span",{className:"font-semibold text-sm truncate",children:D.title})]}),o.jsxs("div",{className:"text-xs text-muted-foreground space-y-0.5",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"font-medium text-foreground/80",children:"Time:"}),o.jsxs("span",{children:[de(D.start,"MMM d, h:mm a")," - ",de(D.end,"h:mm a")]})]}),D.location&&o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"font-medium text-foreground/80",children:"Location:"}),o.jsx("span",{children:D.location})]}),D.description&&o.jsx("div",{className:"pt-1 mt-1 border-t border-border/30 text-muted-foreground/80 line-clamp-3",children:D.description})]})]})})]},D.id)),P>0&&o.jsxs("button",{onClick:D=>{D.stopPropagation(),l?.({date:u})},className:"mt-auto self-start text-[10px] bg-muted/50 hover:bg-muted text-muted-foreground hover:text-foreground font-medium px-2 py-1 rounded-md transition-colors w-full text-left",children:["+",P," more"]})]})]},u.toISOString())})})]})})},co=({view:e,daysInView:t,visibleEvents:n,resources:r=[],onSlotClick:s,onSlotDoubleClick:i,onEventClick:l,onEventDelete:d,onRangeSelect:m,currentTimeIndicator:g,showResourceHeaders:u=!0,group:c,showUnassignedLane:N=!1,startHour:p="00:00",endHour:h="24:00",slotDuration:_=60,is24Hour:P=!1,scrollRef:G,dir:D})=>{const H=D==="rtl",z=Qt(),se=p?parseInt(p.split(":")[0],10):0,y=h?parseInt(h.split(":")[0],10):24,k=y-se,[M,v]=b.useState(null),[K,$]=b.useState(!1),q=b.useRef(null),De=b.useRef(null),X=e==="timeline-month",ne=X?1440:_,Me=60/ne,me=X?1:k*Me,Se=t.length*me,ie=X?120:80,ue=Se*ie,Z=b.useMemo(()=>{const x=r.length>0?[...r]:[];return(N||x.length===0)&&(x.find(A=>A.id==="unassigned")||x.unshift({id:"unassigned",name:"Unassigned",type:"Global Inbox",color:"hsl(var(--muted-foreground))"})),x},[r,N]),he=b.useMemo(()=>{if(!c||!c.resources||c.resources.length===0)return{isGrouped:!1,groups:[{name:"All",resources:Z}]};const x=c.resources[0],A=new Map;Z.forEach(C=>{const E=C[x]||"Unassigned";A.has(E)||A.set(E,[]),A.get(E)?.push(C)});const w=[];return A.forEach((C,E)=>{w.push({name:E,resources:C})}),{isGrouped:!0,groups:w}},[Z,c]),ee=b.useMemo(()=>he.groups.flatMap(x=>x.resources),[he]),F=x=>{if(X)return Re(t[x]);const A=Math.floor(x/me),w=x%me,C=Re(t[A]);return Je(C,se*60+w*ne)},R=x=>{if(X){const I=t.findIndex(W=>fe(W,Re(x)));return I!==-1?I*ie:-1}const A=Re(x),w=t.findIndex(I=>fe(I,A));if(w===-1)return-1;const E=yr(x,A)-se*60;return(w*k*60+E)/ne*ie},ge=(()=>{if(X){const w=Re(t[0]),C=Re(t[t.length-1]);return z<w||z>C?null:R(z)}const x=R(z),A=z.getHours();return x===-1||A<se||A>=y?null:x})(),Ae=b.useRef(!1);b.useEffect(()=>{G?.current&&ge!==null&&!Ae.current&&setTimeout(()=>{G.current&&(H?G.current.scrollLeft=-ge:G.current.scrollLeft=ge,Ae.current=!0)},50)},[G,ge,e]);const S=(x,A)=>{const w=F(x);if(n.some(I=>(I.isHoliday||I.isFullyBooked)&&fe(I.start,w)))return;$(!0);const E={startSlot:x,endSlot:x,resourceId:A};v(E),q.current=E},B=x=>{if(!K||!q.current)return;const A={...q.current,endSlot:x};v(A),q.current=A};b.useEffect(()=>{const x=A=>{if(K&&q.current){const{startSlot:w,endSlot:C,resourceId:E}=q.current,I=Math.min(w,C),W=Math.max(w,C),U=F(I),j=F(W+1);n.some(te=>(te.isHoliday||te.isFullyBooked)&&fe(te.start,U))||(m?.(U,j,E,{x:A.clientX,y:A.clientY}),s?.(U,E))}$(!1),v(null),q.current=null};return window.addEventListener("mouseup",x),()=>window.removeEventListener("mouseup",x)},[K,m,s,t]);const V=(x,A)=>{if(!M||M.resourceId!==A)return!1;const w=Math.min(M.startSlot,M.endSlot),C=Math.max(M.startSlot,M.endSlot);return x>=w&&x<=C},{resourceMap:le,maxLevels:ae}=b.useMemo(()=>{const x=new Map,A=new Map;return ee.forEach(w=>{x.set(w.id,[]),A.set(w.id,1)}),n.forEach(w=>{const C=w.resourceId||"unassigned",E=String(C);x.has(E)?x.get(E)?.push(w):x.has("unassigned")}),x.forEach((w,C)=>{const E=[...w].sort((U,j)=>U.start.getTime()-j.start.getTime()),I=[],W=E.map(U=>{let j=0;const L=300*1e3;for(;I[j]!==void 0&&I[j]>U.start.getTime()+L;)j++;return I[j]=U.end.getTime(),{...U,level:j}});x.set(C,W),A.set(C,I.length||1)}),{resourceMap:x,maxLevels:A}},[n,ee]),Ze=x=>{const A=R(x.start),w=R(x.end);if(A===-1&&w===-1)return{display:"none"};const C=Math.max(0,A),E=w===-1?ue:Math.min(ue,w),I=Math.max(0,E-C);if(I<=4)return{display:"none"};const W=36,j=20+x.level*(W+10),L=x.color||"hsl(var(--primary))";return{[H?"right":"left"]:`${C}px`,width:`${Math.max(I,4)}px`,top:`${j}px`,height:`${W}px`,background:`linear-gradient(135deg, color-mix(in srgb, ${L} 20%, transparent), color-mix(in srgb, ${L} 10%, transparent))`,backdropFilter:"blur(4px)",[H?"borderRight":"borderLeft"]:`4px solid ${L}`,borderTop:`1px solid color-mix(in srgb, ${L} 30%, transparent)`,[H?"borderLeft":"borderRight"]:`1px solid color-mix(in srgb, ${L} 30%, transparent)`,borderBottom:`1px solid color-mix(in srgb, ${L} 30%, transparent)`,color:"hsl(var(--foreground))",borderRadius:"6px",boxShadow:"0 2px 8px -2px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",fontSize:"12px",fontWeight:"600",paddingInlineStart:"12px",paddingInlineEnd:"8px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",zIndex:20+x.level,cursor:"pointer"}},Be=40,Ue=240,ze=u?he.isGrouped?Be+Ue:Ue:0;return o.jsxs("div",{className:"flex flex-col h-full w-full overflow-hidden border border-border/40 rounded-xl bg-background shadow-sm",children:[o.jsxs("div",{className:"flex bg-background z-40 sticky top-0 border-b border-border/40 shadow-[0_1px_2px_rgba(0,0,0,0.03)] items-center",children:[u&&he.isGrouped&&o.jsx("div",{className:Y.cn("w-[40px] shrink-0 border-e border-border/40 p-1 flex items-center justify-center bg-background select-none sticky z-50",H?"right-0":"left-0"),children:o.jsx("div",{className:"writing-mode-vertical rotate-180 font-bold text-[10px] uppercase tracking-widest text-muted-foreground/70",children:"Group"})}),u&&o.jsx("div",{className:Y.cn("w-[240px] shrink-0 border-e border-border/40 px-6 py-4 font-bold text-[11px] uppercase tracking-widest flex items-center bg-background text-muted-foreground select-none sticky z-50",he.isGrouped?H?"right-[40px]":"left-[40px]":H?"right-0":"left-0"),children:"RESOURCES"}),o.jsx("div",{ref:De,className:"overflow-hidden flex-1 relative",children:o.jsx("div",{className:"flex",style:{width:ue},children:t.map(x=>{const A=t.length===1,w=x.getDay()===0||x.getDay()===6;return X?o.jsxs("div",{className:Y.cn("flex shrink-0 border-e border-border/30 h-14 flex-col justify-center items-center transition-colors select-none",w?"bg-muted/10":"bg-transparent hover:bg-muted/5"),style:{width:ie},children:[o.jsx("span",{className:Y.cn("text-[10px] font-bold uppercase mb-0.5 tracking-wider",w?"text-muted-foreground":"text-primary"),children:de(x,"EEE")}),o.jsx("span",{className:Y.cn("text-xs font-semibold",w?"text-muted-foreground/70":"text-foreground/80"),children:de(x,"d")})]},x.toISOString()):o.jsx("div",{className:"flex shrink-0 border-e border-border/40",style:{width:ue/t.length},children:Array.from({length:me}).map((C,E)=>{const I=E*ne,W=se+Math.floor(I/60),U=I%60,j=new Date(new Date().setHours(W,U,0,0));let L="";return P?L=de(j,"HH:mm"):L=ne<60||U!==0?de(j,"h:mm a"):de(j,"ha"),o.jsxs("div",{className:"flex flex-col justify-end pb-2 border-e border-border/10 last:border-e-0 relative h-14",style:{width:ie},children:[!A&&E===0&&o.jsx("div",{className:Y.cn("absolute top-2 px-2 py-0.5 rounded text-[10px] font-bold text-foreground/80 bg-muted/50 border border-border/20 whitespace-nowrap",H?"right-2":"left-2"),children:de(x,"EEE, MMM d")}),o.jsx("span",{className:"text-[11px] font-black text-foreground text-center px-1 select-none tabular-nums truncate",children:L})]},E)})},x.toISOString())})})})]}),o.jsx("div",{ref:G,"data-testid":"scheduler-scroll-container",className:"flex-1 overflow-auto relative custom-scrollbar bg-background",onScroll:x=>{De.current&&(De.current.scrollLeft=x.currentTarget.scrollLeft)},children:o.jsxs("div",{className:"relative min-w-max",style:{width:ue+ze,minHeight:"100%"},children:[ge!==null&&g!==!1&&o.jsxs("div",{className:"current-time-indicator z-50 pointer-events-none",style:{[H?"right":"left"]:`${ge+ze}px`,height:"100%"},children:[o.jsx("div",{className:"absolute top-0 -translate-x-1/2 w-[2px] h-full bg-red-500 shadow-[0_0_8px_rgba(239,68,68,0.6)]"}),o.jsx("div",{className:"absolute top-0 -translate-x-1/2 -mt-1 w-2.5 h-2.5 rounded-full bg-red-500 shadow-md border-2 border-background"})]}),he.groups.map(x=>o.jsxs("div",{className:"flex border-b border-border/30 relative",children:[u&&he.isGrouped&&o.jsxs("div",{className:Y.cn("w-[40px] shrink-0 sticky z-30 bg-background border-e border-border/40 flex items-center justify-center p-1",H?"right-0":"left-0"),style:{height:"auto"},children:[o.jsx("div",{className:"absolute inset-0 bg-background/80"}),o.jsx("div",{className:"relative writing-mode-vertical transform rotate-180 text-[10px] font-bold uppercase tracking-wide text-foreground/70 whitespace-nowrap py-2 overflow-hidden text-ellipsis max-h-full",children:x.name})]}),o.jsx("div",{className:"flex flex-col w-full",children:x.resources.map((A,w)=>{const E=(ae.get(A.id)||1)*46+40;return o.jsxs("div",{className:Y.cn("flex border-b border-border/30 last:border-b-0 group/row hover:bg-muted/5 transition-colors",(w%2===0,"bg-background")),style:{height:`${E}px`},children:[o.jsx("div",{className:Y.cn("w-[240px] shrink-0 sticky z-30 bg-background/95 backdrop-blur border-e border-border/40 px-6 py-4 flex items-center gap-4 transition-all shadow-[1px_0_4px_rgba(0,0,0,0.02)]",he.isGrouped?H?"right-[40px]":"left-[40px]":H?"right-0":"left-0",!u&&"hidden"),children:o.jsxs(o.Fragment,{children:[o.jsxs(Xe.Avatar,{className:"h-9 w-9 border border-border/60 shadow-sm",children:[A.avatar&&o.jsx(Xe.AvatarImage,{src:A.avatar,alt:A.name,className:"object-cover"}),o.jsx(Xe.AvatarFallback,{className:"text-xs font-bold bg-primary/5 text-primary",children:A.name.charAt(0)})]}),o.jsxs("div",{className:"flex flex-col min-w-0",children:[o.jsx("span",{className:"text-[13px] font-semibold truncate text-foreground/90 tracking-tight leading-none mb-1.5",children:A.name}),o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:Y.cn("w-1.5 h-1.5 rounded-full",A.type==="Internal"?"bg-primary shadow-[0_0_6px_var(--primary)]/50":"bg-success shadow-[0_0_6px_var(--success)]/50")}),o.jsx("span",{className:"text-[10px] text-muted-foreground font-medium uppercase tracking-wider",children:A.type||"Available"})]})]})]})}),o.jsx(lo,{resource:A,totalSlots:Se,slotWidth:ie,totalWidth:ue,slotToDate:F,onSlotMouseDown:S,onSlotMouseEnter:B,onSlotDoubleClick:i,isSlotSelected:V,resourceMap:le,getEventStyle:Ze,onEventClick:l,onEventDelete:d,slotDuration:ne,now:z,visibleEvents:n,slotsPerDay:me,daysInView:t,dir:D})]},A.id)})})]},x.name))]})})]})},lo=({resource:e,totalSlots:t,slotWidth:n,totalWidth:r,slotToDate:s,onSlotMouseDown:i,onSlotMouseEnter:l,onSlotDoubleClick:d,isSlotSelected:m,resourceMap:g,getEventStyle:u,onEventClick:c,onEventDelete:N,slotDuration:p,now:h,visibleEvents:_,slotsPerDay:P,daysInView:G,dir:D})=>{const H=D==="rtl",{setNodeRef:z,isOver:se}=_e.useDroppable({id:`row-${e.id}`,data:{resourceId:e.id}});return o.jsxs("div",{ref:z,className:Y.cn("relative flex-1 group/interactive",se&&"bg-primary/5 shadow-inner"),style:{width:r},onMouseMove:y=>{const k=y.currentTarget.getBoundingClientRect(),M=y.clientX-k.left,v=Math.floor(H?(k.width-M)/n:M/n);v>=0&&v<t&&l(v)},onMouseDown:y=>{const k=y.currentTarget.getBoundingClientRect(),M=y.clientX-k.left,v=Math.floor(H?(k.width-M)/n:M/n);v>=0&&v<t&&i(v,e.id)},onDoubleClick:y=>{const k=y.currentTarget.getBoundingClientRect(),M=y.clientX-k.left,v=Math.floor(H?(k.width-M)/n:M/n);if(v>=0&&v<t){const K=s(v);_.some(q=>(q.isHoliday||q.isFullyBooked)&&fe(q.start,K))||d?.(K,e.id)}},children:[o.jsx("div",{className:"absolute inset-0 pointer-events-none",style:{backgroundImage:`repeating-linear-gradient(${H?"to left":"to right"}, transparent, transparent ${n-1}px, hsl(var(--border) / 0.1) ${n-1}px, hsl(var(--border) / 0.1) ${n}px)`,backgroundSize:`${n}px 100%`}}),o.jsx("div",{className:"absolute inset-0 pointer-events-none flex",children:G.map((y,k)=>{const M=_.find(K=>K.isHoliday&&fe(K.start,y)),v=_.find(K=>K.isFullyBooked&&fe(K.start,y));return!M&&!v?o.jsx("div",{style:{width:P*n}},k):o.jsx("div",{style:{width:P*n},className:Y.cn("h-full border-e border-border/10",M&&"bg-[repeating-linear-gradient(-45deg,hsl(var(--destructive)/0.05)_0px,hsl(var(--destructive)/0.05)_10px,transparent_10px,transparent_20px)] bg-destructive/[0.02]",v&&"bg-[repeating-linear-gradient(-45deg,theme(colors.amber.500/0.05)_0px,theme(colors.amber.500/0.05)_10px,transparent_10px,transparent_20px)] bg-amber-500/[0.02]")},k)})}),o.jsx(uo,{totalSlots:t,resourceId:e.id,slotWidth:n,isSlotSelected:m,isRtl:H}),g.get(e.id)?.map(y=>o.jsx(Gn,{event:y,style:u(y),onClick:c,onDelete:N,orientation:"horizontal",resizable:!0,isBlocked:y.isBlock,isPast:y.end<h,slotDuration:p,pixelsPerSlot:n},y.id))]})},uo=b.memo(({totalSlots:e,resourceId:t,slotWidth:n,isSlotSelected:r,isRtl:s})=>{const i=[];let l=null;for(let d=0;d<e;d++)r(d,t)?l?l.length++:(l={start:d,length:1},i.push(l)):l=null;return o.jsx(o.Fragment,{children:i.map((d,m)=>o.jsx("div",{className:"absolute top-0 bottom-0 bg-primary/20 border-x border-primary/30 z-10 pointer-events-none",style:{[s?"right":"left"]:`${d.start*n}px`,width:`${d.length*n}px`}},m))})}),fo=({daysInView:e,visibleEvents:t,onEventClick:n})=>o.jsx("div",{"data-testid":"scheduler-scroll-container",className:"flex flex-col h-full w-full bg-background overflow-y-auto border border-border rounded-lg",children:e.map(r=>{const s=t.filter(l=>fe(l.start,r)).sort((l,d)=>l.start.getTime()-d.start.getTime()),i=fe(r,new Date);return o.jsxs("div",{className:"flex flex-col border-b border-border pb-2 last:border-b-0",children:[o.jsxs("div",{className:Y.cn("flex items-center px-4 py-2 sticky top-0 bg-background/95 backdrop-blur z-10 border-b border-border",i&&"text-primary font-semibold"),children:[o.jsxs("div",{className:"flex flex-col items-center mr-4 w-12 shrink-0",children:[o.jsx("span",{className:"text-[10px] uppercase font-bold text-muted-foreground",children:de(r,"EEE")}),o.jsx("span",{className:"text-xl font-bold leading-none",children:de(r,"d")})]}),o.jsx("div",{className:"text-sm font-medium text-muted-foreground",children:de(r,"MMMM yyyy")})]}),o.jsx("div",{className:"flex flex-col px-2 py-1 gap-2",children:s.length===0?o.jsx("div",{className:"text-sm text-muted-foreground px-4 py-2 italic opacity-50",children:"No events"}):s.map(l=>o.jsx(_e.EzContextMenu,{contextId:"scheduler-event",data:l,children:o.jsxs("div",{"data-testid":`scheduler-event-${l.id}`,className:Y.cn("flex items-center p-3 rounded-lg border bg-card text-card-foreground shadow-sm cursor-pointer hover:bg-muted/50 transition-colors",l.color&&`border-l-4 border-l-[${l.color}]`),style:{borderLeftColor:l.color},onClick:()=>n?.(l),children:[o.jsxs("div",{className:"flex flex-col mr-4 min-w-[80px] shrink-0",children:[o.jsx("span",{className:"text-sm font-bold",children:de(l.start,"h:mm a")}),o.jsx("span",{className:"text-xs text-muted-foreground",children:de(l.end,"h:mm a")})]}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"font-semibold truncate",children:l.title}),l.description&&o.jsx("div",{className:"text-xs text-muted-foreground truncate",children:l.description})]}),l.resourceId&&o.jsx("div",{className:"hidden sm:block ml-2 px-2 py-0.5 rounded-full bg-muted text-[10px] text-muted-foreground",children:l.resourceId})]})},l.id))})]},r.toISOString())})});function mo({view:e,daysInView:t,visibleEvents:n,rowVirtualizer:r,resources:s,handleSlotDoubleClick:i,handleEventDoubleClick:l,handleEventDelete:d,parentRef:m,setView:g,setCurrentDate:u,props:c,handleRangeSelect:N,currentDate:p,showUnassignedLane:h,slotDuration:_,is24Hour:P,setIs24Hour:G,dir:D}){const H=Vt("(max-width: 768px)"),z=typeof c.cell=="function"?c.cell:void 0;switch(H&&(e==="week"||e==="workweek")?"agenda":e){case"day":case"week":case"workweek":return o.jsx(ao,{daysInView:t,visibleEvents:n,rowVirtualizer:r,resources:s,onSlotDoubleClick:i,onEventDoubleClick:l,onEventDelete:d,scrollRef:m,onViewChange:g,onDateChange:u,onRangeSelect:N,onSlotClick:(y,k)=>c.onCellClick?.(y,k),onEventClick:y=>c.onEventClick?.(y),showResourcesInDayView:c.showResourcesInDayView,showWeekNumber:c.showWeekNumber,weekRule:c.weekRule,cellTemplate:z,enableHtmlSanitizer:c.enableHtmlSanitizer,showUnassignedLane:h,startHour:c.startHour,endHour:c.endHour,slotDuration:_,is24Hour:P,setIs24Hour:G,group:c.group,onCellContextMenu:c.onCellContextMenu,dir:D});case"month":return o.jsx(io,{currentDate:p,daysInView:t,visibleEvents:n,onSlotClick:y=>c.onCellClick?.(y),onSlotDoubleClick:y=>i(y),onEventClick:y=>c.onEventClick?.(y)||l(y),monthsCount:c.monthsCount,dir:D});case"timeline":case"timeline-day":case"timelineday":case"timeline-week":case"timelineweek":case"timeline-month":case"timelinemonth":return o.jsx(co,{view:e,currentDate:p,daysInView:t,visibleEvents:n,resources:s,onSlotClick:(y,k)=>c.onCellClick?.(y,k),onSlotDoubleClick:i,onEventClick:y=>c.onEventClick?.(y)||l(y),onEventDelete:d,onRangeSelect:N,currentTimeIndicator:c.currentTimeIndicator,showResourceHeaders:c.showResourceHeaders,group:c.group,showUnassignedLane:c.showUnassignedLane,startHour:c.startHour,endHour:c.endHour,slotDuration:_,is24Hour:P,scrollRef:m,dir:D});case"agenda":return o.jsx(fo,{daysInView:t,visibleEvents:n,onEventClick:y=>c.onEventClick?.(y)||l(y)});default:return o.jsxs("div",{children:["View ",e," not implemented"]})}}const Kn=({isOpen:e,onClose:t,title:n,children:r,footer:s,className:i,size:l="md",closeOnBackdropClick:d=!0,showCloseButton:m=!0})=>{if(b.useEffect(()=>{if(e)return document.body.style.overflow="hidden",()=>{document.body.style.overflow="unset"}},[e]),!e)return null;const g={sm:"max-w-sm",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl",full:"max-w-[95vw] h-[95vh]"},u=o.jsxs("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center p-4 sm:p-6",role:"dialog","aria-modal":"true",children:[o.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm transition-opacity animate-in fade-in duration-200",onClick:d?t:void 0,"aria-hidden":"true"}),o.jsxs("div",{className:Y.cn("relative w-full bg-background rounded-xl border border-border shadow-2xl flex flex-col overflow-hidden animate-in zoom-in-95 slide-in-from-bottom-2 duration-200",g[l],i),children:[(n||m)&&o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border bg-muted/10 shrink-0",children:[o.jsx("div",{className:"text-lg font-semibold leading-none tracking-tight",children:n}),m&&o.jsxs(Ke.Button,{variant:"ghost",size:"icon",onClick:t,className:"h-8 w-8 rounded-full p-0 text-muted-foreground hover:bg-muted",children:[o.jsx(Ke.X,{className:"h-4 w-4"}),o.jsx("span",{className:"sr-only",children:"Close"})]})]}),o.jsx("div",{className:"flex-1 overflow-y-auto p-6 custom-scrollbar",children:r}),s&&o.jsx("div",{className:"flex items-center justify-end gap-2 px-6 py-4 border-t border-border bg-muted/5 shrink-0",children:s})]})]});return lr.createPortal(u,document.body)},ho=b.lazy(()=>Promise.resolve().then(()=>require("./EzEventModal-xzHfzi0O.cjs")).then(e=>({default:e.EzEventModal}))),go=b.lazy(()=>Promise.resolve().then(()=>require("./EzSchedulerQuickAdd-UnOWCpJd.cjs")).then(e=>({default:e.EzSchedulerQuickAdd}))),po=b.lazy(()=>Promise.resolve().then(()=>require("./EzSchedulerToolbar-C-5OdRY6.cjs")).then(e=>e.EzSchedulerToolbar$1).then(e=>({default:e.EzSchedulerToolbar}))),xo=new Pe.QueryClient,Jn=b.forwardRef((e,t)=>(Y.useInitCoreServices(),o.jsx(Pe.QueryClientProvider,{client:xo,children:o.jsx(Zn,{...e,ref:t})})));Jn.displayName="EzScheduler";const Zn=b.forwardRef((e,t)=>{const n=$n({...e,view:e.view||e.defaultView||"Week",selectedDate:e.selectedDate??e.defaultSelectedDate}),{state:r,actions:s,services:i,refs:l,baseApi:d,dir:m}=n,{currentView:g,currentDate:u,viewEvents:c,daysInView:N,slotDuration:p,is24Hour:h}=r,{setView:_,setCurrentDate:P}=s,{rowVirtualizer:G,parentRef:D}=l,{schedulerService:H,serviceRegistry:z}=i,se=S=>{if(!S.start||!S.end)return{hasBlockOverlap:!1,hasRegularOverlap:!1,overlappingEvents:[]};const B=c.filter(V=>V.id===S.id||!(V.resourceId===S.resourceId||V.resourceIds?.some(ae=>S.resourceId===ae)||!V.resourceId&&!S.resourceId)?!1:Mt({start:V.start,end:V.end},{start:S.start,end:S.end}));return{hasBlockOverlap:B.some(V=>V.isBlock),hasRegularOverlap:B.length>0,overlappingEvents:B}},y=(S="regular")=>{const B=z.get("NotificationService");if(B){let V="",le="warning";S==="block"?(V="Cannot place event here: This time is blocked (e.g. Lunch Break).",le="error"):S==="past"?(V="Cannot move or create events in the past.",le="error"):(V="Warning: This event overlaps with an existing event.",le="warning"),B.add({type:le,message:V,duration:5e3})}},{sensors:k,handleDragEnd:M}=_s({events:c,slotDuration:p,onEventChange:S=>{if(!e.allowPastEvents&&S.start<new Date){y("past");return}const{hasBlockOverlap:B,hasRegularOverlap:V,overlappingEvents:le}=se(S);if(B){y("block");return}if(V){if(e.onEventOverlap){const ae={event:S,existingEvents:le,cancel:!1};if(e.onEventOverlap(ae),ae.cancel)return}y("regular")}console.log("[EzScheduler] Calling scheduler.updateEvent",S),s.updateEvent(S)}}),{internalResources:v,setInternalResources:K}=Ns({resources:e.resources}),[$,q]=b.useState({isOpen:!1,mode:"create"}),[De,X]=b.useState(!1),[ne,Me]=b.useState(null),[me,Se]=b.useState({x:0,y:0}),ie=b.useMemo(()=>({...n.baseApi,onExportExcel:e.onExportExcel,onExportCSV:e.onExportCSV,onExportICS:e.onExportICS,get currentView(){return g},destroy:()=>{e.destroyed&&e.destroyed({})}}),[n.baseApi,g,e.destroyed,e.onExportExcel,e.onExportCSV,e.onExportICS]);Ms(g,u,H,c,{setEditorState:q,setResources:K,scrollToIndex:S=>{D.current&&(D.current.scrollTop=S*64)},forceUpdate:()=>{},showSpinner:d.showSpinner,hideSpinner:d.hideSpinner,closeQuickInfoPopup:()=>X(!1),changeView:S=>_(S.toLowerCase()),next:s.nextPeriod,prev:s.prevPeriod,today:s.today},t,ie);const ue=(S,B)=>{e.onCellDoubleClick?e.onCellDoubleClick(S,B):q({isOpen:!0,mode:"create",event:{start:S,end:Je(S,30),resourceId:B,resourceIds:B?[B]:[]}})},Z=S=>{if(e.onEventDoubleClick)e.onEventDoubleClick(S);else{const B=S.end<new Date;q({isOpen:!0,mode:B?"view":"edit",event:S})}},he=async S=>{if(!e.allowPastEvents&&S.start&&S.start<new Date){y("past");return}const{hasBlockOverlap:B,hasRegularOverlap:V}=se(S);if(B){y("block");return}V&&y("regular"),$.mode==="create"?(await e.onEventCreate?.(S),s.addEvent(S)):(await e.onEventChange?.(S),s.updateEvent(S)),q(le=>({...le,isOpen:!1}))},[ee,F]=b.useState({isOpen:!1}),R=async S=>{F({isOpen:!0,eventId:S})},He=async()=>{const S=ee.eventId;if(!S)return;const B=c.find(V=>V.id===S);if(B){await e.onEventDelete?.(S),s.deleteEvent(S);const V=z.get("NotificationService");if(V){const le=de(B.start,"MMM d, yyyy h:mm a");V.add({type:"success",message:`Event "${B.title}" on ${le} has been cancelled.`,duration:5e3})}}F({isOpen:!1})},ge=S=>{if(!e.allowPastEvents&&S.start&&S.start<new Date){y("past");return}s.addEvent(S),e.onEventCreate?.(S),X(!1)},Ae=(S,B,V,le)=>{e.showQuickInfoPopup&&(Me({start:S,end:B,resourceId:V}),Se({x:le?.x||0,y:le?.y||0}),X(!0))};return o.jsx(Fe.EzErrorBoundary,{fallback:o.jsx(Cs,{}),children:o.jsxs("div",{className:Y.cn("ez-scheduler flex flex-col w-full h-full bg-background select-none overflow-hidden",e.className),dir:m,children:[e.showHeaderBar!==!1&&o.jsx(b.Suspense,{fallback:o.jsx("div",{className:"h-12 w-full animate-pulse bg-muted/20 rounded-md mb-4"}),children:(()=>{const S=e.slots?.toolbar;return S?o.jsx(S,{view:g,setView:_,currentDate:u,next:s.nextPeriod,prev:s.prevPeriod,today:s.today,onAddClick:b.useCallback(()=>q({isOpen:!0,mode:"create",event:{}}),[]),slotDuration:p,setSlotDuration:s.setSlotDuration,setCurrentDate:P,onPrev:s.prevPeriod,onNext:s.nextPeriod,onToday:s.today,currentView:g,onViewChange:B=>{const V=B.toLowerCase().replace(/[^a-z]/g,""),ae={day:"day",week:"week",workweek:"workweek",month:"month",timelineday:"timeline-day",timelineweek:"timeline-week",timelineworkweek:"timeline-week",timelinemonth:"timeline-month",agenda:"agenda",timeline:"timeline-day"}[V]||V;_(ae)},views:e.views||["Day","Week","Month"],onExportExcel:b.useCallback(()=>e.onExportExcel?.(c),[e.onExportExcel,c]),onExportCSV:b.useCallback(()=>e.onExportCSV?.(c),[e.onExportCSV,c]),onExportICS:b.useCallback(()=>e.onExportICS?.(c),[e.onExportICS,c]),dir:m,...e.slotProps?.toolbar}):o.jsx(po,{view:g,setView:_,currentDate:u,next:s.nextPeriod,prev:s.prevPeriod,today:s.today,onAddClick:b.useCallback(()=>q({isOpen:!0,mode:"create",event:{}}),[]),slotDuration:p,setSlotDuration:s.setSlotDuration,setCurrentDate:P,onPrev:s.prevPeriod,onNext:s.nextPeriod,onToday:s.today,currentView:g,onViewChange:B=>{const V=B.toLowerCase().replace(/[^a-z]/g,""),ae={day:"day",week:"week",workweek:"workweek",month:"month",timelineday:"timeline-day",timelineweek:"timeline-week",timelineworkweek:"timeline-week",timelinemonth:"timeline-month",agenda:"agenda",timeline:"timeline-day"}[V]||V;_(ae)},views:e.views||["Day","Week","Month"],onExportExcel:b.useCallback(()=>e.onExportExcel?.(c),[e.onExportExcel,c]),onExportCSV:b.useCallback(()=>e.onExportCSV?.(c),[e.onExportCSV,c]),onExportICS:b.useCallback(()=>e.onExportICS?.(c),[e.onExportICS,c]),dir:m})})()}),o.jsxs(_e.DndContext,{sensors:k,onDragEnd:M,collisionDetection:_e.closestCenter,children:[o.jsxs("div",{className:"flex-1 overflow-hidden relative flex flex-col",children:[o.jsx(mo,{view:g,daysInView:N,visibleEvents:c,rowVirtualizer:G,resources:v,handleSlotDoubleClick:ue,handleEventDoubleClick:Z,handleEventDelete:R,parentRef:D,setView:_,setCurrentDate:P,props:e,handleRangeSelect:Ae,currentDate:u,showUnassignedLane:e.showUnassignedLane,slotDuration:p,is24Hour:h,setIs24Hour:s.setIs24Hour,dir:m}),e.isLoading&&o.jsx(As,{})]}),(()=>{if(De&&ne){const S=e.slots?.quickAdd;return S?o.jsx(b.Suspense,{fallback:null,children:o.jsx(S,{start:ne.start,end:ne.end,resourceId:ne.resourceId,resources:v,onSave:ge,onCancel:()=>X(!1),onMoreOptions:B=>{X(!1),q({isOpen:!0,mode:"create",event:B})},position:me,...e.slotProps?.quickAdd})}):o.jsx(b.Suspense,{fallback:null,children:o.jsx(go,{start:ne.start,end:ne.end,resourceId:ne.resourceId,resources:v,onSave:ge,onCancel:()=>X(!1),onMoreOptions:B=>{X(!1),q({isOpen:!0,mode:"create",event:B})},position:me})})}return null})(),(()=>{const S=e.slots?.eventModal;return S?o.jsx(b.Suspense,{fallback:null,children:o.jsx(S,{isOpen:$.isOpen,onClose:()=>q(B=>({...B,isOpen:!1})),mode:$.mode,event:$.event,onSave:he,onDelete:R,resources:v,locale:e.locale,...e.slotProps?.eventModal})}):o.jsx(b.Suspense,{fallback:null,children:o.jsx(ho,{isOpen:$.isOpen,onClose:()=>q(B=>({...B,isOpen:!1})),mode:$.mode,event:$.event,onSave:he,onDelete:R,resources:v,locale:e.locale})})})(),o.jsx(Kn,{isOpen:ee.isOpen,onClose:()=>F({isOpen:!1}),title:"Delete Event",footer:o.jsxs("div",{className:"flex gap-2",children:[o.jsx(Ke.Button,{variant:"ghost",onClick:()=>F({isOpen:!1}),children:"Cancel"}),o.jsx(Ke.Button,{variant:"destructive",onClick:He,children:"Delete"})]}),children:o.jsx("p",{className:"text-sm text-muted-foreground",children:"Are you sure you want to delete this event? This action cannot be undone."})})]})]})})});Zn.displayName="EzSchedulerInner";exports.Clock=_n;exports.EzScheduler=Jn;exports.Modal=Kn;exports.SchedulerService=Yn;exports.addDays=dt;exports.addMinutes=Je;exports.addMonths=Kt;exports.constructFrom=Le;exports.eachDayOfInterval=jn;exports.enUS=Pn;exports.endOfMonth=Ut;exports.endOfWeek=$t;exports.format=de;exports.getDefaultOptions=ut;exports.getISOWeek=Jt;exports.getTimezoneOffsetInMilliseconds=Bt;exports.getWeek=St;exports.getWeekYear=Zt;exports.isProtectedDayOfYearToken=Fn;exports.isProtectedWeekYearToken=Wn;exports.isSameDay=fe;exports.isSameMonth=Bn;exports.isValid=Rn;exports.longFormatters=zn;exports.millisecondsInHour=fr;exports.millisecondsInMinute=Xt;exports.millisecondsInSecond=mr;exports.startOfDay=Re;exports.startOfISOWeek=vt;exports.startOfMonth=Yt;exports.startOfWeek=nt;exports.subMonths=Un;exports.toDate=oe;exports.useEzScheduler=$n;exports.useKeyboardNavigation=Cn;exports.useMediaQuery=Vt;exports.warnOrThrowProtectedError=Hn;
|