@aldabil/react-scheduler
Version:
React scheduler component based on Material-UI & date-fns
1,628 lines • 82.5 kB
JavaScript
import { jsxs as E, jsx as r, Fragment as Z } from "react/jsx-runtime";
import { createContext as st, useContext as lt, useMemo as j, useState as P, Fragment as K, useRef as qe, useEffect as ee, useCallback as U, forwardRef as dt } from "react";
import { isWithinInterval as oe, endOfDay as Q, startOfDay as J, format as R, isSameDay as ce, differenceInDays as ct, addSeconds as Pt, subMinutes as Wt, addMinutes as ae, differenceInMilliseconds as Ht, addDays as X, addMilliseconds as zt, isToday as ue, differenceInMinutes as ke, set as ye, isBefore as we, isAfter as ut, startOfWeek as ze, eachMinuteOfInterval as ht, endOfWeek as Lt, getMonth as Vt, setMonth as Xe, getDaysInMonth as Bt, isSameMonth as ft, differenceInCalendarWeeks as Gt, closestTo as jt, startOfMonth as gt, setHours as Ye, endOfMonth as Ut, eachWeekOfInterval as Zt, eachDayOfInterval as qt, isEqual as Qe } from "date-fns";
import { useTheme as Y, ListItem as Xt, ListItemAvatar as pt, Avatar as Le, ListItemText as mt, Typography as N, Tabs as Yt, Tab as Qt, Box as be, styled as ie, alpha as xe, Paper as yt, Grow as Jt, IconButton as he, Slide as Kt, Button as q, Popover as _e, List as en, ListItemButton as tn, ButtonBase as nn, useMediaQuery as _t, MenuList as rn, MenuItem as Ae, TextField as on, FormControl as an, InputLabel as sn, Select as ln, Checkbox as dn, Chip as cn, CircularProgress as vt, FormHelperText as un, Dialog as hn, DialogTitle as fn, DialogContent as gn, Grid2 as Je, DialogActions as pn } from "@mui/material";
import { enUS as mn } from "date-fns/locale";
import { styled as yn } from "@mui/material/styles";
import _n from "@mui/icons-material/DeleteRounded";
import vn from "@mui/icons-material/EditRounded";
import bn from "@mui/icons-material/EventNoteRounded";
import wn from "@mui/icons-material/ClearRounded";
import xn from "@mui/icons-material/SupervisorAccountRounded";
import Ke from "@mui/icons-material/ArrowRightRounded";
import et from "@mui/icons-material/ArrowLeftRounded";
import { LocalizationProvider as Dn } from "@mui/x-date-pickers/LocalizationProvider";
import { AdapterDateFns as Tn } from "@mui/x-date-pickers/AdapterDateFnsV3";
import tt from "@mui/icons-material/NavigateBeforeRounded";
import $e from "@mui/icons-material/NavigateNextRounded";
import { DateCalendar as Ve } from "@mui/x-date-pickers";
import Cn from "@mui/icons-material/MoreVert";
import kn from "@mui/icons-material/ViewAgenda";
import { DatePicker as En } from "@mui/x-date-pickers/DatePicker";
import { DateTimePicker as Mn } from "@mui/x-date-pickers/DateTimePicker";
import Sn from "@mui/icons-material/ExpandMore";
const In = (e) => {
if (e.month)
return "month";
if (e.week)
return "week";
if (e.day)
return "day";
throw new Error("No views were selected");
}, Fn = (e) => {
const t = [];
return e.month && t.push("month"), e.week && t.push("week"), e.day && t.push("day"), t;
}, Oe = (e, t, n) => {
var s;
const o = ((s = e.config) == null ? void 0 : s.multiple) && !Array.isArray((n == null ? void 0 : n[e.name]) || e.default), i = o ? t ? [t] : [] : t, a = o ? i.length : i;
return { value: i, validity: a };
}, ve = (e, t, n, o) => {
var h;
const i = n.idField, a = o.find((d) => d.name === i), s = !!((h = a == null ? void 0 : a.config) != null && h.multiple), l = [];
for (const d of e) {
const g = s && !Array.isArray(d[i]) ? [d[i]] : d[i];
(s || Array.isArray(g) ? g.includes(t[i]) : g === t[i]) && l.push({
...d,
color: d.color || t[n.colorField || ""]
});
}
return l;
}, Rn = (e, t) => e.filter(
(n) => n.event_id !== t.event_id && (oe(ae(t.start, 1), {
start: n.start,
end: n.end
}) || oe(ae(t.end, -1), {
start: n.start,
end: n.end
}) || oe(ae(n.start, 1), {
start: t.start,
end: t.end
}) || oe(ae(n.end, -1), {
start: t.start,
end: t.end
}))
), bt = (e, t) => Math.ceil(e) / t, wt = (e, t) => Math.max(e / t, 60), se = (e, t) => ct(Q(Pt(t, -1)), J(e)), $n = (e) => new Date(
e.getUTCFullYear(),
e.getUTCMonth(),
e.getUTCDate(),
e.getUTCHours(),
e.getUTCMinutes()
), xt = (e, t, n) => {
var i;
const o = Ht(e.end, e.start);
return e.recurring ? (i = e.recurring) == null ? void 0 : i.between(t, X(t, 1), !0).map((a, s) => {
const l = $n(a);
return {
...e,
recurrenceId: s,
start: l,
end: zt(l, o)
};
}).map((a) => Ce(a, n)) : [Ce(e, n)];
}, Dt = (e, t, n) => {
const o = [];
for (let i = 0; i < e.length; i++)
for (const a of xt(e[i], t, n))
!a.allDay && ce(t, a.start) && !se(a.start, a.end) && o.push(a);
return Nn(o);
}, De = (e, t) => {
const n = e.filter(
(o) => oe(t, {
start: J(o.start),
end: Q(Wt(o.end, 1))
})
);
return Ee(n);
}, Nn = (e) => e.sort((t, n) => {
const o = t.end.getTime() - t.start.getTime();
return n.end.getTime() - n.start.getTime() - o;
}), Ee = (e) => e.sort((t, n) => t.allDay || se(t.start, t.end) > 0 ? -1 : t.start.getTime() - n.start.getTime()), Te = (e, t, n, o) => {
var l;
const i = Array.isArray(t), a = [], s = {};
for (let h = 0; h < e.length; h++) {
const d = Ce(e[h], n);
let m = d.allDay || se(d.start, d.end) > 0;
if (m && (i ? m = t.some(
(g) => oe(g, {
start: J(d.start),
end: Q(d.end)
})
) : m = oe(t, {
start: J(d.start),
end: Q(d.end)
}), m))
if (a.push(d), i)
for (const g of t) {
const y = R(g, "yyyy-MM-dd");
oe(g, { start: J(d.start), end: Q(d.end) }) && (s[y] = (s[y] || []).concat(d));
}
else {
const g = R(d.start, "yyyy-MM-dd");
s[g] = (s[g] || []).concat(d);
}
}
return i && o ? ((l = Object.values(s).sort((h, d) => d.length - h.length)) == null ? void 0 : l[0]) || [] : a;
}, Ce = (e, t) => ({
...e,
start: fe(e.start, t),
end: fe(e.end, t),
convertedTz: !0
}), fe = (e, t) => new Date(
new Intl.DateTimeFormat("en-US", {
dateStyle: "short",
timeStyle: "medium",
timeZone: t
}).format(e)
), Pe = (e, t) => {
if (!t)
return e;
const n = -e.getTimezoneOffset(), o = An(t), i = n - o;
return new Date(e.getTime() + i * 60 * 1e3);
}, le = ({
dateLeft: e,
dateRight: t,
timeZone: n
}) => ce(e, fe(t || /* @__PURE__ */ new Date(), n)), me = (e) => e === "12" ? "hh:mm a" : "HH:mm";
function An(e) {
const t = /* @__PURE__ */ new Date(), n = new Date(t.toLocaleString("en-US", { timeZone: e })), o = new Date(t.toLocaleString("en-US", { timeZone: "UTC" }));
return Math.round((n.getTime() - o.getTime()) / (60 * 1e3));
}
const On = {
weekDays: [0, 1, 2, 3, 4, 5, 6],
weekStartOn: 6,
startHour: 9,
endHour: 17,
navigation: !0,
disableGoToDay: !1
}, Pn = {
weekDays: [0, 1, 2, 3, 4, 5, 6],
weekStartOn: 6,
startHour: 9,
endHour: 17,
step: 60,
navigation: !0,
disableGoToDay: !1
}, Wn = {
startHour: 9,
endHour: 17,
step: 60,
navigation: !0
}, Hn = {
idField: "assignee",
textField: "text",
subTextField: "subtext",
avatarField: "avatar",
colorField: "color"
}, zn = (e = {}) => {
const { navigation: t, form: n, event: o, ...i } = e;
return {
navigation: Object.assign(
{
month: "Month",
week: "Week",
day: "Day",
agenda: "Agenda",
today: "Today"
},
t
),
form: Object.assign(
{
addTitle: "Add Event",
editTitle: "Edit Event",
confirm: "Confirm",
delete: "Delete",
cancel: "Cancel"
},
n
),
event: Object.assign(
{
title: "Title",
start: "Start",
end: "End",
allDay: "All Day"
},
o
),
...Object.assign(
{ moreEvents: "More...", loading: "Loading...", noDataToDisplay: "No data to display" },
i
)
};
}, Ln = (e) => {
const { month: t, week: n, day: o } = e;
return {
month: t !== null ? Object.assign(On, t) : null,
week: n !== null ? Object.assign(Pn, n) : null,
day: o !== null ? Object.assign(Wn, o) : null
};
}, Tt = (e) => {
const {
translations: t,
resourceFields: n,
view: o,
agenda: i,
selectedDate: a,
resourceViewMode: s,
direction: l,
dialogMaxWidth: h,
hourFormat: d,
...m
} = e, g = Ln(e), y = o || "week", v = g[y] ? y : In(g);
return {
...g,
translations: zn(t),
resourceFields: Object.assign(Hn, n),
view: v,
selectedDate: fe(a || /* @__PURE__ */ new Date(), e.timeZone),
height: 600,
navigation: !0,
disableViewNavigator: !1,
events: [],
fields: [],
loading: void 0,
customEditor: void 0,
onConfirm: void 0,
onDelete: void 0,
viewerExtraComponent: void 0,
resources: [],
resourceHeaderComponent: void 0,
resourceViewMode: s || "default",
direction: l || "ltr",
dialogMaxWidth: h || "md",
locale: mn,
deletable: !0,
editable: !0,
hourFormat: d || "12",
draggable: !0,
agenda: i,
enableAgenda: typeof i > "u" || i,
...m
};
}, Ct = {
...Tt({}),
setProps: () => {
},
dialog: !1,
selectedRange: void 0,
selectedEvent: void 0,
selectedResource: void 0,
handleState: () => {
},
getViews: () => [],
toggleAgenda: () => {
},
triggerDialog: () => {
},
triggerLoading: () => {
},
handleGotoDay: () => {
},
confirmEvent: () => {
},
setCurrentDragged: () => {
},
onDrop: () => {
}
}, kt = st(Ct), $ = () => lt(kt), We = ({ resource: e }) => {
const { resourceHeaderComponent: t, resourceFields: n, direction: o, resourceViewMode: i } = $(), a = Y(), s = e[n.textField], l = e[n.subTextField || ""], h = e[n.avatarField || ""], d = e[n.colorField || ""];
return t instanceof Function ? t(e) : /* @__PURE__ */ E(
Xt,
{
sx: {
padding: "2px 10px",
textAlign: o === "rtl" ? "right" : "left",
...i === "tabs" ? {} : i === "vertical" ? {
display: "block",
textAlign: "center",
position: "sticky",
top: 4
} : {
borderColor: a.palette.grey[300],
borderStyle: "solid",
borderWidth: 1
}
},
component: "div",
children: [
/* @__PURE__ */ r(pt, { children: /* @__PURE__ */ r(Le, { sx: { background: d, margin: "auto" }, alt: s, src: h }) }),
/* @__PURE__ */ r(
mt,
{
primary: /* @__PURE__ */ r(N, { variant: "body2", noWrap: i !== "vertical", children: s }),
secondary: /* @__PURE__ */ r(
N,
{
variant: "caption",
color: "textSecondary",
noWrap: i !== "vertical",
children: l
}
)
}
)
]
}
);
};
function Vn(e) {
const { children: t, value: n, index: o } = e;
return n === o ? /* @__PURE__ */ r(Z, { children: t }) : /* @__PURE__ */ r(Z, {});
}
function Bn(e) {
return {
id: `scrollable-auto-tab-${e}`,
"aria-controls": `scrollable-auto-tabpanel-${e}`
};
}
const Gn = yn("div")(({ theme: e }) => ({
flexGrow: 1,
width: "100%",
backgroundColor: e.palette.background.paper,
alignSelf: "center",
"& .tabs": {
borderColor: e.palette.grey[300],
borderStyle: "solid",
borderWidth: 1,
"& button.MuiTab-root": {
borderColor: e.palette.grey[300],
borderRightStyle: "solid",
borderWidth: 1
}
},
"& .primary": {
background: e.palette.primary.main
},
"& .secondary": {
background: e.palette.secondary.main
},
"& .error": {
background: e.palette.error.main
},
"& .info": {
background: e.palette.info.dark
},
"& .text_primary": {
color: e.palette.primary.main
},
"& .text_secondary": {
color: e.palette.secondary.main
},
"& .text_error": {
color: e.palette.error.main
},
"& .text_info": {
color: e.palette.info.dark
}
})), jn = ({
tabs: e,
variant: t = "scrollable",
tab: n,
setTab: o,
indicator: i = "primary",
style: a
}) => /* @__PURE__ */ E(Gn, { style: a, children: [
/* @__PURE__ */ r(
Yt,
{
value: n,
variant: t,
scrollButtons: !0,
className: "tabs",
classes: { indicator: i },
children: e.map((s, l) => /* @__PURE__ */ r(
Qt,
{
label: s.label,
sx: { flex: 1, flexBasis: 200, flexShrink: 0 },
value: s.id,
...Bn(s.id),
onClick: () => o(s.id),
onDragEnter: () => o(s.id)
},
s.id || l
))
}
),
e.map(
(s, l) => s.component && /* @__PURE__ */ r(Vn, { value: n, index: s.id, children: s.component }, l)
)
] }), Be = ({ renderChildren: e }) => {
const { resources: t, resourceFields: n, resourceViewMode: o } = $(), i = Y();
return o === "tabs" ? /* @__PURE__ */ r(Un, { renderChildren: e }) : o === "vertical" ? /* @__PURE__ */ r(Z, { children: t.map((a, s) => /* @__PURE__ */ E(be, { sx: { display: "flex" }, children: [
/* @__PURE__ */ r(
be,
{
sx: {
borderColor: i.palette.grey[300],
borderStyle: "solid",
borderWidth: "1px 1px 0 1px",
paddingTop: 1,
flexBasis: 140
},
children: /* @__PURE__ */ r(We, { resource: a })
}
),
/* @__PURE__ */ r(
be,
{
sx: { width: "100%", overflowX: "auto" },
children: e(a)
}
)
] }, `${a[n.idField]}_${s}`)) }) : /* @__PURE__ */ r(Z, { children: t.map((a, s) => /* @__PURE__ */ E("div", { children: [
/* @__PURE__ */ r(We, { resource: a }),
e(a)
] }, `${a[n.idField]}_${s}`)) });
}, Un = ({ renderChildren: e }) => {
const { resources: t, resourceFields: n, selectedResource: o, handleState: i, onResourceChange: a } = $(), s = t.map((d) => ({
id: d[n.idField],
label: /* @__PURE__ */ r(We, { resource: d }),
component: /* @__PURE__ */ r(Z, { children: e(d) })
})), l = (d) => {
if (i(d, "selectedResource"), typeof a == "function") {
const m = t.find((g) => g[n.idField] === d);
m && a(m);
}
}, h = j(() => {
const d = t[0][n.idField];
return !o || t.findIndex((g) => g[n.idField] === o) < 0 ? d : o;
}, [t, o, n.idField]);
return /* @__PURE__ */ r(jn, { tabs: s, tab: h, setTab: l, style: { display: "grid" } });
}, Zn = ie("div")(({ theme: e, dialog: t }) => ({
position: "relative",
"& .rs__table_loading": {
position: "absolute",
left: 0,
right: 0,
top: 0,
bottom: 0,
zIndex: 999999,
"& .rs__table_loading_internal": {
background: t ? "" : xe(e.palette.background.paper, 0.4),
height: "100%",
"& > span": {
display: "flex",
alignItems: "center",
justifyContent: "center",
height: "100%",
flexDirection: "column",
"& >span": {
marginBottom: 15
}
}
}
}
})), qn = ie("div")(({ resource_count: e }) => ({
position: "relative",
display: "flex",
flexDirection: e > 1 ? "row" : "column",
width: "100%",
boxSizing: "content-box",
"& > div": {
flexShrink: 0,
flexGrow: 1
}
})), Xn = ie(yt)(({ sticky: e = "0" }) => ({
display: "flex",
justifyContent: "space-between",
alignItems: "center",
position: e === "1" ? "sticky" : "relative",
top: e === "1" ? 0 : void 0,
zIndex: e === "1" ? 999 : void 0,
boxShadow: "none",
padding: "2px 0",
"& > .rs__view_navigator": {
display: "flex",
alignItems: "center"
}
})), Me = ie("div")(({ theme: e }) => ({
borderStyle: "solid",
borderColor: e.palette.grey[300],
borderWidth: "1px 1px 0 0",
"& > .rs__agenda_row": {
display: "flex",
"& >.rs__agenda__cell": {
padding: 4,
width: "100%",
maxWidth: 60,
"& > .MuiTypography-root": {
position: "sticky",
top: 0,
"&.rs__hover__op": {
cursor: "pointer",
"&:hover": {
opacity: 0.7,
textDecoration: "underline"
}
}
}
},
"& .rs__cell": {
borderStyle: "solid",
borderColor: e.palette.grey[300],
borderWidth: "0 0 1px 1px"
},
"& > .rs__agenda_items": {
flexGrow: 1
}
}
})), ge = ie("div")(({ days: e, sticky: t = "0", stickyNavigation: n, indent: o = "1", theme: i }) => ({
display: "grid",
gridTemplateColumns: +o > 0 ? `10% repeat(${e}, 1fr)` : `repeat(${e}, 1fr)`,
overflowX: "auto",
overflowY: "hidden",
position: t === "1" ? "sticky" : "relative",
top: t === "1" ? n ? 36 : 0 : void 0,
zIndex: t === "1" ? 99 : void 0,
[i.breakpoints.down("sm")]: {
gridTemplateColumns: +o > 0 ? `30px repeat(${e}, 1fr)` : ""
},
borderStyle: "solid",
borderColor: i.palette.grey[300],
borderWidth: "0 0 0 1px",
"&:first-of-type": {
borderWidth: "1px 0 0 1px"
},
"&:last-of-type": {
borderWidth: "0 0 1px 1px"
},
"& .rs__cell": {
background: i.palette.background.paper,
position: "relative",
borderStyle: "solid",
borderColor: i.palette.grey[300],
borderWidth: "0 1px 1px 0",
"&.rs__header": {
"& > :first-of-type": {
padding: "2px 5px"
}
},
"&.rs__header__center": {
padding: "6px 0px"
},
"&.rs__time": {
display: "flex",
alignItems: "center",
justifyContent: "center",
position: "sticky",
left: 0,
zIndex: 99,
[i.breakpoints.down("sm")]: {
writingMode: "vertical-rl"
}
},
"& > button": {
width: "100%",
height: "100%",
borderRadius: 0,
cursor: "pointer",
"&:hover": {
background: xe(i.palette.primary.main, 0.1)
}
},
"& .rs__event__item": {
position: "absolute",
zIndex: 1
},
"& .rs__multi_day": {
position: "absolute",
zIndex: 1,
textOverflow: "ellipsis"
},
"& .rs__block_col": {
display: "block",
position: "relative"
},
"& .rs__hover__op": {
cursor: "pointer",
"&:hover": {
opacity: 0.7,
textDecoration: "underline"
}
},
"&:not(.rs__time)": {
minWidth: 65
}
}
})), nt = ie(yt)(({ disabled: e }) => ({
width: "99.5%",
height: "100%",
display: "block",
cursor: e ? "not-allowed" : "pointer",
overflow: "hidden",
"& .MuiButtonBase-root": {
width: "100%",
height: "100%",
display: "block",
textAlign: "left",
"& > div": {
height: "100%"
// padding: "2px 4px",
}
}
})), Yn = ie("div")(({ theme: e }) => ({
maxWidth: "100%",
width: 400,
"& > div": {
padding: "5px 10px",
"& .rs__popper_actions": {
display: "flex",
alignItems: "center",
justifyContent: "space-between",
"& .MuiIconButton-root": {
color: e.palette.primary.contrastText
}
}
}
})), Qn = ie("div")(({ theme: e }) => ({
display: "inherit",
"& .MuiIconButton-root": {
color: e.palette.primary.contrastText
},
"& .MuiButton-root": {
"&.delete": {
color: e.palette.error.main
},
"&.cancel": {
color: e.palette.action.disabled
}
}
})), Jn = ie("div")(({ theme: e }) => ({
position: "absolute",
zIndex: 9,
width: "100%",
display: "flex",
"& > div:first-of-type": {
height: 12,
width: 12,
borderRadius: "50%",
background: e.palette.error.light,
marginLeft: -6,
marginTop: -5
},
"& > div:last-of-type": {
borderTop: `solid 2px ${e.palette.error.light}`,
width: "100%"
}
})), Et = (e) => {
const { editable: t, deletable: n, draggable: o } = $(), i = j(() => typeof e.editable < "u" ? e.editable : t, [t, e.editable]), a = j(() => typeof e.deletable < "u" ? e.deletable : n, [n, e.deletable]), s = j(() => {
if (i)
return typeof e.draggable < "u" ? e.draggable : o;
}, [o, e.draggable, i]);
return {
canEdit: i,
canDelete: a,
canDrag: s
};
}, Kn = ({ event: e, onDelete: t, onEdit: n }) => {
const { translations: o, direction: i } = $(), [a, s] = P(!1), l = () => {
if (!a)
return s(!0);
t();
}, { canEdit: h, canDelete: d } = Et(e);
return /* @__PURE__ */ E(Qn, { children: [
/* @__PURE__ */ r(Jt, { in: !a, exit: !1, timeout: 400, unmountOnExit: !0, children: /* @__PURE__ */ E("div", { children: [
h && /* @__PURE__ */ r(he, { size: "small", onClick: n, children: /* @__PURE__ */ r(vn, {}) }),
d && /* @__PURE__ */ r(he, { size: "small", onClick: l, children: /* @__PURE__ */ r(_n, {}) })
] }) }),
/* @__PURE__ */ r(
Kt,
{
in: a,
direction: i === "rtl" ? "right" : "left",
unmountOnExit: !0,
timeout: 400,
exit: !1,
children: /* @__PURE__ */ E("div", { children: [
/* @__PURE__ */ r(q, { className: "delete", size: "small", onClick: l, children: o.form.delete.toUpperCase() }),
/* @__PURE__ */ r(q, { className: "cancel", size: "small", onClick: () => s(!1), children: o.form.cancel.toUpperCase() })
] })
}
)
] });
}, Mt = ({ anchorEl: e, event: t, onTriggerViewer: n }) => {
const {
triggerDialog: o,
onDelete: i,
events: a,
handleState: s,
triggerLoading: l,
customViewer: h,
viewerExtraComponent: d,
fields: m,
resources: g,
resourceFields: y,
locale: v,
viewerTitleComponent: f,
viewerSubtitleComponent: u,
hourFormat: w,
translations: c,
onEventEdit: b
} = $(), C = Y(), k = se(t.start, t.end) <= 0 && t.allDay, x = me(w), T = y.idField, D = g.filter(
(p) => Array.isArray(t[T]) ? t[T].includes(p[T]) : p[T] === t[T]
), M = async () => {
try {
l(!0);
let p = t.event_id;
if (i) {
const _ = await i(p);
_ ? p = _ : p = "";
}
if (p) {
n();
const _ = a.filter((S) => S.event_id !== p);
s(_, "events");
}
} catch (p) {
console.error(p);
} finally {
l(!1);
}
};
return /* @__PURE__ */ r(
_e,
{
open: !!e,
anchorEl: e,
onClose: () => {
n();
},
anchorOrigin: {
vertical: "center",
horizontal: "center"
},
transformOrigin: {
vertical: "top",
horizontal: "center"
},
onClick: (p) => {
p.stopPropagation();
},
children: typeof h == "function" ? h(t, () => n()) : /* @__PURE__ */ E(Yn, { children: [
/* @__PURE__ */ E(
be,
{
sx: {
bgcolor: t.color || C.palette.primary.main,
color: C.palette.primary.contrastText
},
children: [
/* @__PURE__ */ E("div", { className: "rs__popper_actions", children: [
/* @__PURE__ */ r("div", { children: /* @__PURE__ */ r(
he,
{
size: "small",
onClick: () => {
n();
},
children: /* @__PURE__ */ r(wn, { color: "disabled" })
}
) }),
/* @__PURE__ */ r(
Kn,
{
event: t,
onDelete: M,
onEdit: () => {
n(), o(!0, t), b && typeof b == "function" && b(t);
}
}
)
] }),
f instanceof Function ? f(t) : /* @__PURE__ */ r(N, { style: { padding: "5px 0" }, noWrap: !0, children: t.title })
]
}
),
/* @__PURE__ */ E("div", { style: { padding: "5px 10px" }, children: [
/* @__PURE__ */ E(
N,
{
style: { display: "flex", alignItems: "center", gap: 8 },
color: "textSecondary",
variant: "caption",
noWrap: !0,
children: [
/* @__PURE__ */ r(bn, {}),
k ? c.event.allDay : `${R(t.start, `dd MMMM yyyy ${x}`, {
locale: v
})} - ${R(t.end, `dd MMMM yyyy ${x}`, {
locale: v
})}`
]
}
),
u instanceof Function ? u(t) : /* @__PURE__ */ r(N, { variant: "body2", style: { padding: "5px 0" }, children: t.subtitle }),
D.length > 0 && /* @__PURE__ */ E(
N,
{
style: { display: "flex", alignItems: "center", gap: 8 },
color: "textSecondary",
variant: "caption",
noWrap: !0,
children: [
/* @__PURE__ */ r(xn, {}),
D.map((p) => p[y.textField]).join(", ")
]
}
),
d instanceof Function ? d(m, t) : d
] })
] })
}
);
}, Ge = ({ day: e, events: t }) => {
const [n, o] = P(null), [i, a] = P(), [s, l] = P(!1), { locale: h, hourFormat: d, eventRenderer: m, onEventClick: g, timeZone: y, disableViewer: v } = $(), f = Y(), u = me(d), w = (c) => {
!(c != null && c.currentTarget) && s && l(!1), o((c == null ? void 0 : c.currentTarget) || null);
};
return /* @__PURE__ */ E(K, { children: [
/* @__PURE__ */ r(en, { children: t.map((c) => {
const C = le({
dateLeft: c.start,
dateRight: e,
timeZone: y
}) ? u : `MMM d, ${u}`, k = R(c.start, C, {
locale: h
}), T = le({ dateLeft: c.end, dateRight: e, timeZone: y }) ? u : `MMM d, ${u}`, D = R(c.end, T, {
locale: h
});
return typeof m == "function" ? m({ event: c, onClick: w }) : /* @__PURE__ */ E(
tn,
{
focusRipple: !0,
disableRipple: v,
tabIndex: v ? -1 : 0,
disabled: c.disabled,
onClick: (M) => {
M.preventDefault(), M.stopPropagation(), v || w(M), a(c), typeof g == "function" && g(c);
},
children: [
/* @__PURE__ */ r(pt, { children: /* @__PURE__ */ r(
Le,
{
sx: {
bgcolor: c.disabled ? "#d0d0d0" : c.color || f.palette.primary.main,
color: c.disabled ? "#808080" : c.textColor || f.palette.primary.contrastText
},
children: c.agendaAvatar || " "
}
) }),
/* @__PURE__ */ r(mt, { primary: c.title, secondary: `${k} - ${D}` })
]
},
`${c.start.getTime()}_${c.end.getTime()}_${c.event_id}`
);
}) }),
i && /* @__PURE__ */ r(
Mt,
{
anchorEl: n,
event: i,
onTriggerViewer: w
}
)
] });
}, je = () => {
const { height: e, translations: t } = $();
return /* @__PURE__ */ r(
Me,
{
sx: {
borderWidth: 1,
padding: 1,
height: e / 2,
display: "flex",
alignItems: "center",
justifyContent: "center"
},
children: /* @__PURE__ */ r("div", { className: "rs__cell rs__agenda_items", children: /* @__PURE__ */ r(N, { children: t.noDataToDisplay }) })
}
);
}, er = ({ daysList: e, events: t }) => {
const { week: n, handleGotoDay: o, locale: i, timeZone: a, translations: s, alwaysShowAgendaDays: l } = $(), { disableGoToDay: h, headRenderer: d } = n, m = j(() => e.some((g) => De(t, g).length > 0), [e, t]);
return !l && !m ? /* @__PURE__ */ r(je, {}) : /* @__PURE__ */ r(Me, { children: e.map((g, y) => {
const v = le({ dateLeft: g, timeZone: a }), f = De(t, g);
return !l && !f.length ? null : /* @__PURE__ */ E("div", { className: `rs__agenda_row ${ue(g) ? "rs__today_cell" : ""}`, children: [
/* @__PURE__ */ r("div", { className: "rs__cell rs__agenda__cell", children: typeof d == "function" ? /* @__PURE__ */ r("div", { children: d(g) }) : /* @__PURE__ */ r(
N,
{
sx: { fontWeight: v ? "bold" : "inherit" },
color: v ? "primary" : "inherit",
variant: "body2",
className: h ? "" : "rs__hover__op",
onClick: (u) => {
u.stopPropagation(), h || o(g);
},
children: R(g, "dd E", { locale: i })
}
) }),
/* @__PURE__ */ r("div", { className: "rs__cell rs__agenda_items", children: f.length > 0 ? /* @__PURE__ */ r(Ge, { day: g, events: f }) : /* @__PURE__ */ r(N, { sx: { padding: 1 }, children: s.noDataToDisplay }) })
] }, y);
}) });
}, He = 1, de = 28, rt = 27, tr = 23, St = () => {
const e = qe(null), t = qe(null);
return ee(() => {
const n = e.current, o = t.current, i = (a) => {
const s = a.currentTarget;
o == null || o.scroll({ left: s.scrollLeft }), n == null || n.scroll({ left: s.scrollLeft });
};
return n == null || n.addEventListener("scroll", i), o == null || o.addEventListener("scroll", i), () => {
n == null || n.removeEventListener("scroll", i), o == null || o.removeEventListener("scroll", i);
};
}), { headersRef: e, bodyRef: t };
}, It = ({ date: e, onClick: t, locale: n }) => {
const { timeZone: o } = $(), i = le({ dateLeft: e, timeZone: o });
return /* @__PURE__ */ E("div", { children: [
/* @__PURE__ */ r(
N,
{
style: {
fontWeight: i ? "bold" : "inherit"
},
color: i ? "primary" : "inherit",
className: t ? "rs__hover__op" : "",
onClick: (a) => {
a.stopPropagation(), t && t(e);
},
children: R(e, "dd", { locale: n })
}
),
/* @__PURE__ */ r(
N,
{
color: i ? "primary" : "inherit",
style: {
fontWeight: i ? "bold" : "inherit",
fontSize: 11
},
children: R(e, "eee", { locale: n })
}
)
] });
}, Ft = st({
renderedSlots: {},
setRenderedSlot: () => {
}
}), Rt = () => lt(Ft), nr = (e) => {
const { setCurrentDragged: t } = $(), n = Y();
return {
draggable: !0,
onDragStart: (o) => {
o.stopPropagation(), t(e), o.currentTarget.style.backgroundColor = n.palette.error.main;
},
onDragEnd: (o) => {
t(), o.currentTarget.style.backgroundColor = e.color || n.palette.primary.main;
},
onDragOver: (o) => {
o.stopPropagation(), o.preventDefault();
},
onDragEnter: (o) => {
o.stopPropagation(), o.preventDefault();
}
};
}, Se = ({ event: e, multiday: t, hasPrev: n, hasNext: o, showdate: i = !0 }) => {
const { direction: a, locale: s, hourFormat: l, eventRenderer: h, onEventClick: d, view: m, disableViewer: g } = $(), y = nr(e), [v, f] = P(null), [u, w] = P(!1), c = Y(), b = me(l), C = a === "rtl" ? et : Ke, k = a === "rtl" ? Ke : et, x = se(e.start, e.end) <= 0 && e.allDay, { canDrag: T } = Et(e), D = U(
(p) => {
!(p != null && p.currentTarget) && u && w(!1), f((p == null ? void 0 : p.currentTarget) || null);
},
[u]
), M = j(() => {
if (typeof h == "function" && !t && m !== "month") {
const _ = h({ event: e, onClick: D, ...y });
if (_)
return /* @__PURE__ */ r(nt, { children: _ }, `${e.start.getTime()}_${e.end.getTime()}_${e.event_id}`);
}
let p = /* @__PURE__ */ E("div", { style: { padding: "2px 6px" }, children: [
/* @__PURE__ */ r(N, { variant: "subtitle2", style: { fontSize: 12 }, noWrap: !0, children: e.title }),
e.subtitle && /* @__PURE__ */ r(N, { variant: "body2", style: { fontSize: 11 }, noWrap: !0, children: e.subtitle }),
i && /* @__PURE__ */ r(N, { style: { fontSize: 11 }, noWrap: !0, children: `${R(e.start, b, {
locale: s
})} - ${R(e.end, b, { locale: s })}` })
] });
return t && (p = /* @__PURE__ */ E(
"div",
{
style: {
padding: 2,
display: "flex",
alignItems: "center",
justifyContent: "space-between"
},
children: [
/* @__PURE__ */ r(N, { sx: { fontSize: 11 }, noWrap: !0, children: n ? /* @__PURE__ */ r(k, { fontSize: "small", sx: { display: "flex" } }) : i && !x && R(e.start, b, { locale: s }) }),
/* @__PURE__ */ r(N, { variant: "subtitle2", align: "center", sx: { fontSize: 12 }, noWrap: !0, children: e.title }),
/* @__PURE__ */ r(N, { sx: { fontSize: 11 }, noWrap: !0, children: o ? /* @__PURE__ */ r(C, { fontSize: "small", sx: { display: "flex" } }) : i && !x && R(e.end, b, { locale: s }) })
]
}
)), /* @__PURE__ */ r(
nt,
{
disabled: e.disabled,
sx: {
bgcolor: e.disabled ? "#d0d0d0" : e.color || c.palette.primary.main,
color: e.disabled ? "#808080" : e.textColor || c.palette.primary.contrastText,
...e.sx || {}
},
children: /* @__PURE__ */ r(
nn,
{
onClick: (_) => {
_.preventDefault(), _.stopPropagation(), g || D(_), typeof d == "function" && d(e);
},
focusRipple: !0,
tabIndex: g ? -1 : 0,
disableRipple: g,
disabled: e.disabled,
children: /* @__PURE__ */ r("div", { ...y, draggable: T, children: p })
}
)
},
`${e.start.getTime()}_${e.end.getTime()}_${e.event_id}`
);
}, [
h,
t,
m,
e,
i,
b,
s,
c.palette.primary.main,
c.palette.primary.contrastText,
g,
y,
T,
D,
n,
k,
x,
o,
C,
d
]);
return /* @__PURE__ */ E(K, { children: [
M,
/* @__PURE__ */ r(Mt, { anchorEl: v, event: e, onTriggerViewer: D })
] });
};
function Ne({ startHour: e, step: t, minuteHeight: n, timeZone: o }) {
const i = fe(/* @__PURE__ */ new Date(), o), a = ke(i, ye(i, { hours: e, minutes: 0 })), s = a * n, h = a / t + He;
return s + h;
}
const rr = (e) => {
const [t, n] = P(Ne(e)), { startHour: o, step: i, minuteHeight: a, timeZone: s } = e;
return ee(() => {
const l = { startHour: o, step: i, minuteHeight: a, timeZone: s };
n(Ne(l));
const h = setInterval(() => n(Ne(l)), 60 * 1e3);
return () => clearInterval(h);
}, [o, i, a, s]), t < 0 ? null : /* @__PURE__ */ E(Jn, { style: { top: t, zIndex: e.zIndex }, children: [
/* @__PURE__ */ r("div", {}),
/* @__PURE__ */ r("div", {})
] });
}, $t = ({
todayEvents: e,
today: t,
startHour: n,
endHour: o,
step: i,
minuteHeight: a,
direction: s,
timeZone: l
}) => {
const h = [];
return /* @__PURE__ */ E(K, { children: [
le({ dateLeft: t, timeZone: l }) && /* @__PURE__ */ r(
rr,
{
startHour: n,
step: i,
minuteHeight: a,
timeZone: l,
zIndex: 2 * e.length + 1
}
),
e.map((d, m) => {
const g = (o * 60 - n * 60) * a, y = ke(d.end, d.start) * a, v = Math.min(y, g) - He, f = n * 60, u = d.start.getHours() * 60 + d.start.getMinutes(), w = Math.max(u - f, 0), c = w * a, C = v / 60 * He, k = w / i, x = c + k, T = Rn(e, d), D = T.filter((M) => h.includes(M.event_id));
return h.push(d.event_id), /* @__PURE__ */ r(
"div",
{
className: "rs__event__item",
style: {
height: v + C,
top: x,
width: D.length > 0 ? `calc(100% - ${100 - 98 / (D.length + 1)}%)` : "98%",
// Leave some space to click cell
zIndex: e.length + m,
[s === "rtl" ? "right" : "left"]: D.length > 0 ? `${100 / (T.length + 1) * D.length}%` : ""
},
children: /* @__PURE__ */ r(Se, { event: d })
},
`${d.event_id}/${d.recurrenceId || ""}`
);
})
] });
}, or = ({ start: e, end: t, resourceKey: n, resourceVal: o }) => {
const {
triggerDialog: i,
onCellClick: a,
onDrop: s,
currentDragged: l,
setCurrentDragged: h,
editable: d,
timeZone: m
} = $(), g = Y();
return {
tabIndex: d ? 0 : -1,
disableRipple: !d,
onClick: () => {
d && i(!0, {
start: e,
end: t,
[n]: o
}), a && typeof a == "function" && a(e, t, n, o);
},
onDragOver: (y) => {
y.preventDefault(), l && (y.currentTarget.style.backgroundColor = xe(g.palette.secondary.main, 0.3));
},
onDragEnter: (y) => {
l && (y.currentTarget.style.backgroundColor = xe(g.palette.secondary.main, 0.3));
},
onDragLeave: (y) => {
l && (y.currentTarget.style.backgroundColor = "");
},
onDrop: (y) => {
if (l && l.event_id) {
y.preventDefault(), y.currentTarget.style.backgroundColor = "";
const v = Pe(e, m);
s(y, l.event_id.toString(), v, n, o), h();
}
},
[n]: o
};
}, Ue = ({
day: e,
start: t,
end: n,
resourceKey: o,
resourceVal: i,
cellRenderer: a,
height: s,
children: l
}) => {
const h = or({ start: t, end: n, resourceKey: o, resourceVal: i });
return a ? a({
day: e,
start: t,
end: n,
height: s,
...h
}) : /* @__PURE__ */ r(
q,
{
fullWidth: !0,
"aria-label": `${t.toLocaleString("en", {
dateStyle: "full",
timeStyle: "long"
})} - ${n.toLocaleString("en", { dateStyle: "full", timeStyle: "long" })}`,
...h,
children: l
}
);
}, ir = ({
daysList: e,
hours: t,
cellHeight: n,
minutesHeight: o,
resourcedEvents: i,
resource: a
}) => {
const {
week: s,
events: l,
handleGotoDay: h,
resources: d,
resourceFields: m,
resourceViewMode: g,
direction: y,
locale: v,
hourFormat: f,
timeZone: u,
stickyNavigation: w
} = $(), { startHour: c, endHour: b, step: C, cellRenderer: k, disableGoToDay: x, headRenderer: T, hourRenderer: D } = s, { renderedSlots: M } = Rt(), { headersRef: p, bodyRef: _ } = St(), S = de, F = J(e[0]), W = Q(e[e.length - 1]), H = me(f), V = j(() => {
const A = d.length && g === "default", I = Te(
A ? l : i,
e,
u,
!0
);
return S * I.length + 45;
}, [
S,
e,
l,
g,
i,
d.length,
u
]), z = (A, I, B) => {
const te = ce(F, I);
return Te(A, e, u).filter((O) => we(O.start, F) ? te : ce(O.start, I)).sort((O, re) => re.end.getTime() - O.end.getTime()).map((O) => {
var Ze;
const re = we(J(O.start), F), L = ut(Q(O.end), W), Fe = se(re ? F : O.start, L ? W : O.end) + 1, Nt = R(I, "yyyy-MM-dd"), At = B ? B[m.idField] : "all", Re = (Ze = M == null ? void 0 : M[At]) == null ? void 0 : Ze[Nt], Ot = (Re == null ? void 0 : Re[O.event_id]) || 0;
return /* @__PURE__ */ r(
"div",
{
className: "rs__multi_day",
style: {
top: Ot * S + 45,
width: `${99.9 * Fe}%`,
overflowX: "hidden"
},
children: /* @__PURE__ */ r(Se, { event: O, hasPrev: re, hasNext: L, multiday: !0 })
},
O.event_id
);
});
};
return /* @__PURE__ */ E(Z, { children: [
/* @__PURE__ */ E(
ge,
{
days: e.length,
ref: p,
sticky: "1",
stickyNavigation: w,
children: [
/* @__PURE__ */ r("span", { className: "rs__cell rs__time" }),
e.map((A, I) => /* @__PURE__ */ E(
"span",
{
className: `rs__cell rs__header ${ue(A) ? "rs__today_cell" : ""}`,
style: { height: V },
children: [
typeof T == "function" ? /* @__PURE__ */ r("div", { children: T(A) }) : /* @__PURE__ */ r(
It,
{
date: A,
onClick: x ? void 0 : h,
locale: v
}
),
z(i, A, a)
]
},
I
))
]
}
),
/* @__PURE__ */ r(ge, { days: e.length, ref: _, children: t.map((A, I) => /* @__PURE__ */ E(K, { children: [
/* @__PURE__ */ r("span", { style: { height: n }, className: "rs__cell rs__header rs__time", children: typeof D == "function" ? /* @__PURE__ */ r("div", { children: D(R(A, H, { locale: v })) }) : /* @__PURE__ */ r(N, { variant: "caption", children: R(A, H, { locale: v }) }) }),
e.map((B, te) => {
const G = /* @__PURE__ */ new Date(`${R(B, "yyyy/MM/dd")} ${R(A, H)}`), ne = ae(G, C), O = m.idField;
return /* @__PURE__ */ E("span", { className: `rs__cell ${ue(B) ? "rs__today_cell" : ""}`, children: [
I === 0 && /* @__PURE__ */ r(
$t,
{
todayEvents: Dt(i, B, u),
today: B,
minuteHeight: o,
startHour: c,
endHour: b,
step: C,
direction: y,
timeZone: u
}
),
/* @__PURE__ */ r(
Ue,
{
start: G,
end: ne,
day: B,
height: n,
resourceKey: O,
resourceVal: a ? a[O] : null,
cellRenderer: k
}
)
] }, te);
})
] }, I)) })
] });
}, ar = () => {
const {
week: e,
selectedDate: t,
height: n,
events: o,
getRemoteEvents: i,
triggerLoading: a,
handleState: s,
resources: l,
resourceFields: h,
fields: d,
agenda: m
} = $(), { weekStartOn: g, weekDays: y, startHour: v, endHour: f, step: u } = e, w = ze(t, { weekStartsOn: g }), c = y.map((S) => X(w, S)), b = J(c[0]), C = Q(c[c.length - 1]), k = ye(t, { hours: v, minutes: 0, seconds: 0 }), x = ye(t, { hours: f, minutes: -u, seconds: 0 }), T = ht(
{
start: k,
end: x
},
{ step: u }
), D = wt(n, T.length), M = bt(D, u), p = U(async () => {
try {
a(!0);
const S = await i({
start: b,
end: C,
view: "week"
});
Array.isArray(S) && s(S, "events");
} catch (S) {
throw S;
} finally {
a(!1);
}
}, [i]);
ee(() => {
i instanceof Function && p();
}, [p, i]);
const _ = (S) => {
let F = o;
return S && (F = ve(o, S, h, d)), m ? /* @__PURE__ */ r(er, { daysList: c, events: F }) : /* @__PURE__ */ r(
ir,
{
resourcedEvents: F,
resource: S,
hours: T,
cellHeight: D,
minutesHeight: M,
daysList: c
}
);
};
return l.length ? /* @__PURE__ */ r(Be, { renderChildren: _ }) : _();
}, Ie = ({ children: e }) => {
const { locale: t } = $();
return /* @__PURE__ */ r(Dn, { dateAdapter: Tn, adapterLocale: t, children: e });
}, pe = ({ type: e, onClick: t, ...n }) => {
const { direction: o } = $();
let i = $e;
return e === "prev" ? i = o === "rtl" ? $e : tt : e === "next" && (i = o === "rtl" ? tt : $e), /* @__PURE__ */ r(
he,
{
style: { padding: 2 },
onClick: t,
onDragOver: (a) => {
a.preventDefault(), t && t();
},
...n,
children: /* @__PURE__ */ r(i, {})
}
);
}, sr = ({ selectedDate: e, onChange: t, weekProps: n }) => {
const { locale: o, navigationPickerProps: i } = $(), [a, s] = P(null), { weekStartOn: l } = n, h = ze(e, { weekStartsOn: l }), d = Lt(e, { weekStartsOn: l }), m = (u) => {
s(u.currentTarget);
}, g = () => {
s(null);
}, y = (u) => {
t(u || /* @__PURE__ */ new Date()), g();
}, v = () => {
const u = X(h, -1);
t(u);
}, f = () => {
const u = X(d, 1);
t(u);
};
return /* @__PURE__ */ E(Z, { children: [
/* @__PURE__ */ r(pe, { type: "prev", onClick: v, "aria-label": "previous week" }),
/* @__PURE__ */ r(q, { style: { padding: 4 }, onClick: m, "aria-label": "selected week", children: `${R(h, "dd", { locale: o })} - ${R(d, "dd MMM yyyy", {
locale: o
})}` }),
/* @__PURE__ */ r(
_e,
{
open: !!a,
anchorEl: a,
onClose: g,
anchorOrigin: {
vertical: "bottom",
horizontal: "left"
},
children: /* @__PURE__ */ r(Ie, { children: /* @__PURE__ */ r(
Ve,
{
...i,
openTo: "day",
views: ["month", "day"],
value: e,
onChange: y
}
) })
}
),
/* @__PURE__ */ r(pe, { type: "next", onClick: f, "aria-label": "next week" })
] });
}, lr = ({ selectedDate: e, onChange: t }) => {
const { locale: n, navigationPickerProps: o } = $(), [i, a] = P(null), s = (g) => {
a(g.currentTarget);
}, l = () => {
a(null);
}, h = (g) => {
t(g || /* @__PURE__ */ new Date()), l();
}, d = () => {
const g = X(e, -1);
t(g);
}, m = () => {
const g = X(e, 1);
t(g);
};
return /* @__PURE__ */ E(Z, { children: [
/* @__PURE__ */ r(pe, { type: "prev", onClick: d, "aria-label": "previous day" }),
/* @__PURE__ */ r(q, { style: { padding: 4 }, onClick: s, "aria-label": "selected date", children: R(e, "dd MMMM yyyy", { locale: n }) }),
/* @__PURE__ */ r(
_e,
{
open: !!i,
anchorEl: i,
onClose: l,
anchorOrigin: {
vertical: "bottom",
horizontal: "left"
},
children: /* @__PURE__ */ r(Ie, { children: /* @__PURE__ */ r(
Ve,
{
...o,
openTo: "day",
views: ["month", "day"],
value: e,
onChange: h
}
) })
}
),
/* @__PURE__ */ r(pe, { type: "next", onClick: m, "aria-label": "next day" })
] });
}, dr = ({ selectedDate: e, onChange: t }) => {
const { locale: n, navigationPickerProps: o } = $(), i = Vt(e), [a, s] = P(null), l = (y) => {
s(y.currentTarget);
}, h = () => {
s(null);
}, d = (y) => {
t(y || /* @__PURE__ */ new Date()), h();
}, m = () => {
const y = i - 1;
t(Xe(e, y));
}, g = () => {
const y = i + 1;
t(Xe(e, y));
};
return /* @__PURE__ */ E(Z, { children: [
/* @__PURE__ */ r(pe, { type: "prev", onClick: m, "aria-label": "previous month" }),
/* @__PURE__ */ r(q, { style: { padding: 4 }, onClick: l, "aria-label": "selected month", children: R(e, "MMMM yyyy", { locale: n }) }),
/* @__PURE__ */ r(
_e,
{
open: !!a,
anchorEl: a,
onClose: h,
anchorOrigin: {
vertical: "bottom",
horizontal: "left"
},
children: /* @__PURE__ */ r(Ie, { children: /* @__PURE__ */ r(
Ve,
{
...o,
openTo: "month",
views: ["year", "month"],
value: e,
onChange: d
}
) })
}
),
/* @__PURE__ */ r(pe, { type: "next", onClick: g, "aria-label": "next month" })
] });
}, cr = () => {
const {
selectedDate: e,
view: t,
week: n,
handleState: o,
getViews: i,
translations: a,
navigation: s,
day: l,
month: h,
disableViewNavigator: d,
onSelectedDateChange: m,
onViewChange: g,
stickyNavigation: y,
timeZone: v,
agenda: f,
toggleAgenda: u,
enableAgenda: w
} = $(), [c, b] = P(null), C = Y(), k = _t(C.breakpoints.up("sm")), x = i(), T = (_) => {
b(_ || null);
}, D = (_) => {
o(_, "selectedDate"), m && typeof m == "function" && m(_);
}, M = (_) => {
o(_, "view"), g && typeof g == "function" && g(_, f);
}, p = () => {
switch (t) {
case "month":
return (h == null ? void 0 : h.navigation) && /* @__PURE__ */ r(dr, { selectedDate: e, onChange: D });
case "week":
return (n == null ? void 0 : n.navigation) && /* @__PURE__ */ r(
sr,
{
selectedDate: e,
onChange: D,
weekProps: n
}
);
case "day":
return (l == null ? void 0 : l.navigation) && /* @__PURE__ */ r(lr, { selectedDate: e, onChange: D });
default:
return "";
}
};
return !s && d ? null : /* @__PURE__ */ E(Xn, { sticky: y ? "1" : "0", children: [
/* @__PURE__ */ r("div", { "data-testid": "date-navigator", children: s && p() }),
/* @__PURE__ */ E(
"div",
{
className: "rs__view_navigator",
"data-testid": "view-navigator",
style: {
visibility: d ? "hidden" : "visible"
},
children: [
/* @__PURE__ */ r(
q,
{
onClick: () => D(fe(/* @__PURE__ */ new Date(), v)),
"aria-label": a.navigation.today,
children: a.navigation.today
}
),
w && (k ? /* @__PURE__ */ r(
q,
{
color: f ? "primary" : "inherit",
onClick: u,
"aria-label": a.navigation.agenda,
children: a.navigation.agenda
}
) : /* @__PURE__ */ r(
he,
{
color: f ? "primary" : "default",
style: { padding: 5 },
onClick: u,
children: /* @__PURE__ */ r(kn, {})
}
)),
x.length > 1 && (k ? x.map((_) => /* @__PURE__ */ r(
q,
{
color: _ === t ? "primary" : "inherit",
onClick: () => M(_),
onDragOver: (S) => {
S.preventDefault(), M(_);
},
children: a.navigation[_]
},
_
)) : /* @__PURE__ */ E(K, { children: [
/* @__PURE__ */ r(
he,
{
style: { padding: 5 },
onClick: (_) => {
T(_.currentTarget);
},
children: /* @__PURE__ */ r(Cn, {})
}
),
/* @__PURE__ */ r(
_e,
{
open: !!c,
anchorEl: c,
onClose: () => {
T();
},
anchorOrigin: {
vertical: "center",
horizontal: "center"
},
transformOrigin: {
vertical: "top",
horizontal: "center"
},
chil