import { o as Re } from "./rolldown-runtime.js";
import { i as Le, n as Pe, t as Ve } from "./vendor/react.js";
import { _ as ae, a as ie, c as I, g as q, h as P, l as We, m as J, t as v, v as oe, y as le } from "./format.js";
import { a as X, i as Ue, n as K, r as Ye, t as Q } from "./isSameMonth.js";
import { n as V, t as Fe } from "./subWeeks.js";
import { t as ce } from "./createLucideIcon.js";
import { t as de } from "./calendar.js";
import { t as ue } from "./chevron-left.js";
import { t as me } from "./chevron-right.js";
import { t as Ge } from "./clock.js";
import { t as Ze } from "./copy.js";
import { t as Be } from "./pencil.js";
import { t as qe } from "./Avatar.js";
import { t as Ke } from "./trash-2.js";
import { t as _ } from "./Button.js";
import { t as fe } from "./dist.js";
import { t as N } from "./utils.js";
import { t as Je } from "./create-safe-context.js";
function G(e, t) {
  const n = q(e, t?.in).getDay();
  return n === 0 || n === 6;
}
function Xe(e, t) {
  const { start: n, end: a } = Ye(t?.in, e);
  let i = +n > +a;
  const o = i ? +n : +a, s = i ? a : n;
  s.setHours(0, 0, 0, 0);
  let l = t?.step ?? 1;
  if (!l) return [];
  l < 0 && (l = -l, i = !i);
  const c = [];
  for (; +s <= o; )
    c.push(ae(n, s)), s.setDate(s.getDate() + l), s.setHours(0, 0, 0, 0);
  return i ? c.reverse() : c;
}
function Qe(e, t) {
  const n = () => ae(t?.in, NaN), a = t?.additionalDigits ?? 2, i = rt(e);
  let o;
  if (i.date) {
    const m = nt(i.date, a);
    o = st(m.restDateString, m.year);
  }
  if (!o || isNaN(+o)) return n();
  const s = +o;
  let l = 0, c;
  if (i.time && (l = at(i.time), isNaN(l)))
    return n();
  if (i.timezone) {
    if (c = it(i.timezone), isNaN(c)) return n();
  } else {
    const m = new Date(s + l), u = q(0, t?.in);
    return u.setFullYear(m.getUTCFullYear(), m.getUTCMonth(), m.getUTCDate()), u.setHours(m.getUTCHours(), m.getUTCMinutes(), m.getUTCSeconds(), m.getUTCMilliseconds()), u;
  }
  return q(s + l + c, t?.in);
}
var F = {
  dateTimeDelimiter: /[T ]/,
  timeZoneDelimiter: /[Z ]/i,
  timezone: /([Z+-].*)$/
}, He = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/, et = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/, tt = /^([+-])(\d{2})(?::?(\d{2}))?$/;
function rt(e) {
  const t = {}, n = e.split(F.dateTimeDelimiter);
  let a;
  if (n.length > 2) return t;
  if (/:/.test(n[0]) ? a = n[0] : (t.date = n[0], a = n[1], F.timeZoneDelimiter.test(t.date) && (t.date = e.split(F.timeZoneDelimiter)[0], a = e.substr(t.date.length, e.length))), a) {
    const i = F.timezone.exec(a);
    i ? (t.time = a.replace(i[1], ""), t.timezone = i[1]) : t.time = a;
  }
  return t;
}
function nt(e, t) {
  const n = new RegExp("^(?:(\\d{4}|[+-]\\d{" + (4 + t) + "})|(\\d{2}|[+-]\\d{" + (2 + t) + "})$)"), a = e.match(n);
  if (!a) return {
    year: NaN,
    restDateString: ""
  };
  const i = a[1] ? parseInt(a[1]) : null, o = a[2] ? parseInt(a[2]) : null;
  return {
    year: o === null ? i : o * 100,
    restDateString: e.slice((a[1] || a[2]).length)
  };
}
function st(e, t) {
  if (t === null) return /* @__PURE__ */ new Date(NaN);
  const n = e.match(He);
  if (!n) return /* @__PURE__ */ new Date(NaN);
  const a = !!n[4], i = R(n[1]), o = R(n[2]) - 1, s = R(n[3]), l = R(n[4]), c = R(n[5]) - 1;
  if (a)
    return ut(t, l, c) ? ot(t, l, c) : /* @__PURE__ */ new Date(NaN);
  {
    const m = /* @__PURE__ */ new Date(0);
    return !ct(t, o, s) || !dt(t, i) ? /* @__PURE__ */ new Date(NaN) : (m.setUTCFullYear(t, o, Math.max(i, s)), m);
  }
}
function R(e) {
  return e ? parseInt(e) : 1;
}
function at(e) {
  const t = e.match(et);
  if (!t) return NaN;
  const n = B(t[1]), a = B(t[2]), i = B(t[3]);
  return mt(n, a, i) ? n * oe + a * le + i * 1e3 : NaN;
}
function B(e) {
  return e && parseFloat(e.replace(",", ".")) || 0;
}
function it(e) {
  if (e === "Z") return 0;
  const t = e.match(tt);
  if (!t) return 0;
  const n = t[1] === "+" ? -1 : 1, a = parseInt(t[2]), i = t[3] && parseInt(t[3]) || 0;
  return ft(a, i) ? n * (a * oe + i * le) : NaN;
}
function ot(e, t, n) {
  const a = /* @__PURE__ */ new Date(0);
  a.setUTCFullYear(e, 0, 4);
  const i = a.getUTCDay() || 7, o = (t - 1) * 7 + n + 1 - i;
  return a.setUTCDate(a.getUTCDate() + o), a;
}
var lt = [
  31,
  null,
  31,
  30,
  31,
  30,
  31,
  31,
  30,
  31,
  30,
  31
];
function pe(e) {
  return e % 400 === 0 || e % 4 === 0 && e % 100 !== 0;
}
function ct(e, t, n) {
  return t >= 0 && t <= 11 && n >= 1 && n <= (lt[t] || (pe(e) ? 29 : 28));
}
function dt(e, t) {
  return t >= 1 && t <= (pe(e) ? 366 : 365);
}
function ut(e, t, n) {
  return t >= 1 && t <= 53 && n >= 0 && n <= 6;
}
function mt(e, t, n) {
  return e === 24 ? t === 0 && n === 0 : n >= 0 && n < 60 && t >= 0 && t < 60 && e >= 0 && e < 25;
}
function ft(e, t) {
  return t >= 0 && t <= 59;
}
function xe(e, t, n) {
  return X(e, -t, n);
}
var pt = [["path", {
  d: "M10.268 21a2 2 0 0 0 3.464 0",
  key: "vwvbt9"
}], ["path", {
  d: "M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",
  key: "11g9vi"
}]], xt = ce("bell", pt), ht = [["path", {
  d: "M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",
  key: "1r0f0z"
}], ["circle", {
  cx: "12",
  cy: "10",
  r: "3",
  key: "ilqhr7"
}]], bt = ce("map-pin", ht), r = Ve();
function H({ top: e, now: t, showLabel: n = !0 }) {
  return /* @__PURE__ */ (0, r.jsxs)("div", {
    "data-slot": "current-time-marker",
    className: "pointer-events-none absolute inset-x-0 z-10 flex items-center",
    style: { top: `${e}px` },
    children: [
      n && /* @__PURE__ */ (0, r.jsx)("span", {
        className: "absolute -left-[72px] w-[68px] text-end text-[10px] font-semibold text-primary",
        children: v(t, "h:mm a")
      }),
      /* @__PURE__ */ (0, r.jsxs)("div", {
        className: "relative flex items-center justify-center",
        children: [/* @__PURE__ */ (0, r.jsx)("div", { className: "size-2 rounded-full bg-primary" }), /* @__PURE__ */ (0, r.jsx)("div", { className: "absolute size-2 animate-ping rounded-full bg-primary opacity-40 motion-reduce:animate-none" })]
      }),
      /* @__PURE__ */ (0, r.jsx)("div", { className: "h-0.5 flex-1 bg-primary" })
    ]
  });
}
H.displayName = "CurrentTimeMarker";
function Z(e) {
  return `${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`;
}
function M(e) {
  return typeof e == "string" ? Qe(e) : e;
}
function z(e) {
  const t = M(e);
  return t.getHours() + t.getMinutes() / 60;
}
function E(e, t) {
  if (!t) return 1;
  const n = M(e);
  return (M(t).getTime() - n.getTime()) / (1e3 * 60 * 60);
}
function gt(e) {
  return e === 0 || e === 24 ? "12 AM" : e === 12 ? "12 PM" : e > 12 ? `${e - 12} PM` : `${e} AM`;
}
function he(e, t) {
  const n = K(e), a = Ue(e), i = Xe({
    start: J(n, { weekStartsOn: t }),
    end: ie(a, { weekStartsOn: t })
  }), o = [];
  for (let s = 0; s < i.length; s += 7) o.push(i.slice(s, s + 7));
  return o;
}
var vt = [
  "Mon",
  "Tue",
  "Wed",
  "Thu",
  "Fri",
  "Sat",
  "Sun"
], yt = [
  "Sun",
  "Mon",
  "Tue",
  "Wed",
  "Thu",
  "Fri",
  "Sat"
], be = [
  "M",
  "T",
  "W",
  "T",
  "F",
  "S",
  "S"
], ge = [
  "S",
  "M",
  "T",
  "W",
  "T",
  "F",
  "S"
], Nt = [
  "Monday",
  "Tuesday",
  "Wednesday",
  "Thursday",
  "Friday",
  "Saturday",
  "Sunday"
], jt = [
  "Sunday",
  "Monday",
  "Tuesday",
  "Wednesday",
  "Thursday",
  "Friday",
  "Saturday"
], ve = {
  ArrowLeft: -1,
  ArrowRight: 1,
  ArrowUp: -7,
  ArrowDown: 7
}, W = "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1", ye = 'before:absolute before:inset-0 before:min-h-[44px] before:min-w-[44px] before:-translate-x-[calc((44px-100%)/2)] before:-translate-y-[calc((44px-100%)/2)] before:content-[""]', wt = 'before:absolute before:inset-x-0 before:top-1/2 before:-translate-y-1/2 before:min-h-[44px] before:content-[""]';
var Ne = {
  brand: "bg-primary/10 text-primary",
  gray: "bg-muted text-muted-foreground",
  error: "bg-destructive/10 text-destructive",
  warning: "bg-warning/10 text-warning",
  success: "bg-success/10 text-success",
  pink: "bg-pink-100 text-pink-800 dark:bg-pink-900/30 dark:text-pink-200",
  purple: "bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-200",
  blue: "bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-200",
  orange: "bg-orange-100 text-orange-800 dark:bg-orange-900/30 dark:text-orange-200"
}, Mt = {
  brand: "bg-primary",
  gray: "bg-muted-foreground",
  error: "bg-destructive",
  warning: "bg-warning",
  success: "bg-success",
  pink: "bg-pink-500 dark:bg-pink-400",
  purple: "bg-purple-500 dark:bg-purple-400",
  blue: "bg-blue-500 dark:bg-blue-400",
  orange: "bg-orange-500 dark:bg-orange-400"
}, kt = fe(["rounded-lg p-2 text-xs cursor-pointer transition-[opacity,transform,box-shadow] duration-200 ease-out hover:opacity-90 hover:-translate-y-px hover:shadow-md active:translate-y-0 active:shadow-sm overflow-hidden motion-reduce:transition-none motion-reduce:hover:translate-y-0", W].join(" "), {
  variants: { color: Ne },
  defaultVariants: { color: "brand" }
});
function je({ event: e, top: t, height: n, onClick: a, className: i, style: o }) {
  const s = M(e.start), l = e.end ? M(e.end) : null;
  return /* @__PURE__ */ (0, r.jsxs)("button", {
    type: "button",
    "data-slot": "event-block",
    "aria-label": `${e.title}, ${v(s, "h:mm a")}${l ? ` to ${v(l, "h:mm a")}` : ""}`,
    onClick: (c) => {
      c.stopPropagation(), a?.(e);
    },
    className: N(kt({ color: e.color }), "absolute text-start", i),
    style: {
      top: `${t}px`,
      height: `${Math.max(n, 24)}px`,
      ...o
    },
    children: [/* @__PURE__ */ (0, r.jsx)("div", {
      className: "font-medium",
      children: e.title
    }), n >= 40 && /* @__PURE__ */ (0, r.jsxs)("div", {
      className: "mt-0.5 text-[11px] opacity-70",
      children: [v(s, "h:mm a"), l && ` – ${v(l, "h:mm a")}`]
    })]
  });
}
je.displayName = "EventBlock";
function Ct(e) {
  if (e.length === 0) return [];
  const t = [...e].sort((s, l) => {
    const c = z(s.start), m = z(l.start);
    return c !== m ? c - m : E(l.start, l.end) - E(s.start, s.end);
  }), n = [];
  let a = [t[0]], i = z(t[0].start) + E(t[0].start, t[0].end);
  for (let s = 1; s < t.length; s++) {
    const l = z(t[s].start);
    if (l < i) {
      a.push(t[s]);
      const c = l + E(t[s].start, t[s].end);
      i = Math.max(i, c);
    } else
      n.push(a), a = [t[s]], i = l + E(t[s].start, t[s].end);
  }
  n.push(a);
  const o = [];
  for (const s of n) {
    const l = [], c = /* @__PURE__ */ new Map();
    for (const u of s) {
      const g = z(u.start);
      let y = !1;
      for (let d = 0; d < l.length; d++) if (g >= l[d].end) {
        l[d].end = g + E(u.start, u.end), c.set(u.id, d), y = !0;
        break;
      }
      y || (c.set(u.id, l.length), l.push({ end: g + E(u.start, u.end) }));
    }
    const m = l.length;
    for (const u of s) o.push({
      event: u,
      column: c.get(u.id) ?? 0,
      totalColumns: m
    });
  }
  return o;
}
var x = /* @__PURE__ */ Re(Le(), 1);
var _t = 8;
function ee({ startHour: e, endHour: t, children: n, className: a }) {
  const i = x.useMemo(() => Array.from({ length: t - e }, (s, l) => e + l), [e, t]), o = x.useRef(null);
  return x.useEffect(() => {
    const s = (/* @__PURE__ */ new Date()).getHours();
    if (o.current && s >= e && s < t) {
      const l = (s - e) * 96 - 96;
      o.current.scrollTop = Math.max(0, l);
    }
  }, [e, t]), /* @__PURE__ */ (0, r.jsx)("div", {
    ref: o,
    "data-slot": "time-grid",
    role: "region",
    "aria-label": "Time grid",
    tabIndex: 0,
    className: N("relative overflow-y-auto focus:outline-none", a),
    style: { maxHeight: `${_t * 96}px` },
    children: /* @__PURE__ */ (0, r.jsxs)("div", {
      className: "relative",
      style: { height: `${i.length * 96}px` },
      children: [
        i.map((s) => /* @__PURE__ */ (0, r.jsx)("div", {
          className: "absolute left-0 w-[72px] pr-2 text-right",
          style: { top: `${(s - e) * 96}px` },
          children: /* @__PURE__ */ (0, r.jsx)("span", {
            className: "relative -top-2 text-[10px] text-muted-foreground",
            children: gt(s)
          })
        }, s)),
        i.map((s) => /* @__PURE__ */ (0, r.jsxs)(x.Fragment, { children: [/* @__PURE__ */ (0, r.jsx)("div", {
          className: "absolute left-[72px] right-0 border-b border-border/50",
          style: { top: `${(s - e) * 96}px` }
        }), /* @__PURE__ */ (0, r.jsx)("div", {
          className: "absolute left-[72px] right-0 border-b border-dashed border-border/30",
          style: { top: `${(s - e) * 96 + 96 / 2}px` }
        })] }, `grid-${s}`)),
        /* @__PURE__ */ (0, r.jsx)("div", {
          className: "absolute left-[72px] right-0 top-0 bottom-0",
          children: n
        })
      ]
    })
  });
}
ee.displayName = "TimeGrid";
function te({ date: e, events: t, dayEvents: n, startHour: a, endHour: i, onEventClick: o, className: s }) {
  const l = n ?? t.filter((m) => I(M(m.start), e)), c = x.useMemo(() => Ct(l), [l]);
  return /* @__PURE__ */ (0, r.jsx)("div", {
    "data-slot": "day-column",
    className: N("relative h-full border-l border-border/50", G(e) && "bg-surface-1", s),
    children: c.map(({ event: m, column: u, totalColumns: g }) => {
      const y = z(m.start), d = E(m.start, m.end);
      return y >= i || y + d <= a ? null : /* @__PURE__ */ (0, r.jsx)(je, {
        event: m,
        top: Math.max(0, (y - a) * 96),
        height: Math.min(d * 96, (i - Math.max(y, a)) * 96),
        onClick: o,
        className: "mx-0.5",
        style: {
          width: `${100 / g}%`,
          left: `${u / g * 100}%`
        }
      }, m.id);
    })
  });
}
te.displayName = "DayColumn";
var ne = [
  "primary",
  "indigo",
  "purple",
  "success",
  "warning",
  "slate"
];
function Tt(e) {
  let t = 0, n = 0, a = 0;
  for (const o of e) o.status === "yes" ? t++ : o.status === "no" ? a++ : n++;
  const i = [];
  return t > 0 && i.push(`${t} yes`), n > 0 && i.push(`${n} awaiting`), a > 0 && i.push(`${a} no`), i.join(" · ");
}
function we({ onEventCopy: e, onEventDelete: t, onEventEdit: n, className: a }) {
  const { events: i, selectedEventId: o } = T(), s = x.useMemo(() => i.find((d) => d.id === o) ?? null, [i, o]);
  if (!s) return null;
  const l = M(s.start), c = s.end ? M(s.end) : null, m = 5, u = s.attendees ?? [], g = u.slice(0, m), y = u.length - m;
  return /* @__PURE__ */ (0, r.jsxs)("section", {
    "data-slot": "event-detail-panel",
    "aria-label": "Event details",
    className: N("flex flex-col gap-4 p-4", "animate-in fade-in slide-in-from-bottom-2 duration-200 motion-reduce:animate-none", a),
    children: [
      /* @__PURE__ */ (0, r.jsxs)("div", {
        className: "flex items-start justify-between gap-2",
        children: [/* @__PURE__ */ (0, r.jsx)("h3", {
          className: "text-base font-bold text-foreground",
          children: s.title
        }), /* @__PURE__ */ (0, r.jsxs)("div", {
          className: "flex shrink-0 items-center gap-1",
          children: [
            e && /* @__PURE__ */ (0, r.jsx)(_, {
              appearance: "outline",
              variant: "secondary",
              size: "icon-sm",
              "aria-label": "Copy event",
              onClick: () => e(s),
              children: /* @__PURE__ */ (0, r.jsx)(Ze, { className: "size-3.5" })
            }),
            t && /* @__PURE__ */ (0, r.jsx)(_, {
              appearance: "outline",
              variant: "destructive",
              size: "icon-sm",
              "aria-label": "Delete event",
              onClick: () => t(s),
              children: /* @__PURE__ */ (0, r.jsx)(Ke, { className: "size-3.5" })
            }),
            n && /* @__PURE__ */ (0, r.jsx)(_, {
              appearance: "outline",
              variant: "secondary",
              size: "icon-sm",
              "aria-label": "Edit event",
              onClick: () => n(s),
              children: /* @__PURE__ */ (0, r.jsx)(Be, { className: "size-3.5" })
            })
          ]
        })]
      }),
      /* @__PURE__ */ (0, r.jsxs)("div", {
        className: "flex flex-col gap-3",
        children: [
          /* @__PURE__ */ (0, r.jsxs)("div", {
            className: "flex items-center gap-2.5 text-sm text-muted-foreground",
            children: [/* @__PURE__ */ (0, r.jsx)(de, { className: "size-4 shrink-0" }), /* @__PURE__ */ (0, r.jsx)("span", { children: v(l, "EEEE, MMMM d, yyyy") })]
          }),
          /* @__PURE__ */ (0, r.jsxs)("div", {
            className: "flex items-center gap-2.5 text-sm text-muted-foreground",
            children: [/* @__PURE__ */ (0, r.jsx)(Ge, { className: "size-4 shrink-0" }), /* @__PURE__ */ (0, r.jsxs)("span", { children: [v(l, "h:mm a"), c && ` – ${v(c, "h:mm a")}`] })]
          }),
          s.location && /* @__PURE__ */ (0, r.jsxs)("div", {
            className: "flex items-center gap-2.5 text-sm text-muted-foreground",
            children: [/* @__PURE__ */ (0, r.jsx)(bt, { className: "size-4 shrink-0" }), /* @__PURE__ */ (0, r.jsx)("span", { children: s.location })]
          }),
          s.reminder && /* @__PURE__ */ (0, r.jsxs)("div", {
            className: "flex items-center gap-2.5 text-sm text-muted-foreground",
            children: [/* @__PURE__ */ (0, r.jsx)(xt, { className: "size-4 shrink-0" }), /* @__PURE__ */ (0, r.jsx)("span", { children: s.reminder })]
          })
        ]
      }),
      u.length > 0 && /* @__PURE__ */ (0, r.jsxs)("div", {
        className: "flex flex-col gap-2",
        children: [
          /* @__PURE__ */ (0, r.jsx)("span", {
            className: "text-xs font-medium text-muted-foreground",
            children: "Attendees"
          }),
          /* @__PURE__ */ (0, r.jsx)("div", {
            className: "flex items-center",
            children: /* @__PURE__ */ (0, r.jsxs)("div", {
              className: "flex -space-x-2",
              children: [g.map((d, h) => /* @__PURE__ */ (0, r.jsx)(qe, {
                size: "sm",
                src: d.avatar,
                fallback: d.name,
                softColor: ne[h % ne.length],
                className: "border-2 border-background"
              }, `${d.name}-${h}`)), y > 0 && /* @__PURE__ */ (0, r.jsxs)("div", {
                role: "img",
                "aria-label": `${y} more attendees`,
                className: "flex size-8 items-center justify-center rounded-full border-2 border-background bg-muted text-xs font-semibold text-muted-foreground",
                children: ["+", y]
              })]
            })
          }),
          /* @__PURE__ */ (0, r.jsx)("span", {
            className: "text-xs text-muted-foreground",
            children: Tt(u)
          })
        ]
      }),
      s.description && /* @__PURE__ */ (0, r.jsxs)("div", {
        className: "flex flex-col gap-1.5 border-t border-border pt-4",
        children: [/* @__PURE__ */ (0, r.jsx)("span", {
          className: "text-xs font-medium text-muted-foreground",
          children: "About this event"
        }), /* @__PURE__ */ (0, r.jsx)("p", {
          className: "text-sm leading-relaxed text-foreground",
          children: s.description
        })]
      })
    ]
  }, s.id);
}
we.displayName = "EventDetailPanel";
var St = fe([
  "relative rounded-sm px-1.5 py-0.5 text-xs font-medium truncate cursor-pointer transition-opacity duration-200 hover:opacity-80 motion-reduce:transition-none",
  wt,
  W
].join(" "), {
  variants: { color: Ne },
  defaultVariants: { color: "brand" }
});
function re({ event: e, onClick: t, className: n, style: a }) {
  const i = v(M(e.start), "h:mm a");
  return /* @__PURE__ */ (0, r.jsx)("button", {
    type: "button",
    "data-slot": "event-pill",
    "aria-label": `${e.title}, ${i}`,
    onClick: (o) => {
      o.stopPropagation(), t?.(e);
    },
    className: N(St({ color: e.color }), "text-start", n),
    style: a,
    children: e.title
  });
}
re.displayName = "EventPill";
function Me({ className: e }) {
  const { events: t, selectedDate: n, weekStartsOn: a, onDateSelect: i } = T(), [o, s] = x.useState(K(n));
  x.useEffect(() => {
    const f = K(n);
    s((p) => p.getTime() === f.getTime() ? p : f);
  }, [n]);
  const l = x.useMemo(() => he(o, a), [o, a]), c = a === 0 ? ge : be, m = a === 0 ? jt : Nt, u = x.useRef(null), g = x.useMemo(() => t.filter((f) => I(M(f.start), n)), [t, n]), y = 3, d = g.slice(0, y), h = g.length - y;
  return /* @__PURE__ */ (0, r.jsxs)("div", {
    "data-slot": "mini-month-calendar",
    className: N("p-4", e),
    children: [
      /* @__PURE__ */ (0, r.jsxs)("div", {
        className: "mb-3 flex items-center justify-between",
        children: [/* @__PURE__ */ (0, r.jsx)("span", {
          className: "text-sm font-semibold text-foreground",
          children: v(o, "MMMM yyyy")
        }), /* @__PURE__ */ (0, r.jsxs)("div", {
          className: "flex items-center gap-1",
          children: [/* @__PURE__ */ (0, r.jsx)(_, {
            appearance: "ghost",
            variant: "secondary",
            size: "icon-xs",
            "aria-label": "Previous month",
            onClick: () => s(xe(o, 1)),
            children: /* @__PURE__ */ (0, r.jsx)(ue, { className: "size-3.5" })
          }), /* @__PURE__ */ (0, r.jsx)(_, {
            appearance: "ghost",
            variant: "secondary",
            size: "icon-xs",
            "aria-label": "Next month",
            onClick: () => s(X(o, 1)),
            children: /* @__PURE__ */ (0, r.jsx)(me, { className: "size-3.5" })
          })]
        })]
      }),
      /* @__PURE__ */ (0, r.jsxs)("div", {
        ref: u,
        role: "grid",
        "aria-label": "Mini month calendar",
        children: [/* @__PURE__ */ (0, r.jsx)("div", {
          role: "row",
          className: "mb-1 grid grid-cols-7",
          children: c.map((f, p) => /* @__PURE__ */ (0, r.jsx)("div", {
            role: "columnheader",
            "aria-label": m[p],
            className: "flex items-center justify-center py-1 text-[10px] font-medium text-muted-foreground",
            children: f
          }, `${f}-${p}`))
        }), l.map((f, p) => /* @__PURE__ */ (0, r.jsx)("div", {
          role: "row",
          className: "grid grid-cols-7",
          children: f.map((b) => {
            const k = Q(b, o), w = I(b, n), S = V(b);
            return /* @__PURE__ */ (0, r.jsx)("div", {
              role: "gridcell",
              "aria-selected": w || void 0,
              children: /* @__PURE__ */ (0, r.jsx)("button", {
                type: "button",
                onClick: () => i(b),
                "aria-label": v(b, "MMMM d, yyyy"),
                "aria-current": S ? "date" : void 0,
                "data-date": b.toISOString(),
                tabIndex: I(b, n) ? 0 : -1,
                onKeyDown: ($) => {
                  const C = ve[$.key];
                  if (C !== void 0) {
                    $.preventDefault();
                    const j = P(b, C), D = u.current?.querySelector(`[data-date="${j.toISOString()}"]`);
                    D ? D.focus() : i(j);
                  }
                },
                className: N("relative flex size-7 items-center justify-center text-xs transition-colors duration-200 motion-reduce:transition-none", ye, W, w && "rounded-sm bg-primary text-primary-foreground shadow-sm", !w && S && "rounded-sm bg-primary/10 text-primary font-semibold ring-1 ring-primary/30", !w && !S && k && "text-foreground hover:bg-accent", !k && "text-muted-foreground/50"),
                children: v(b, "d")
              })
            }, b.toISOString());
          })
        }, p))]
      }),
      g.length > 0 && /* @__PURE__ */ (0, r.jsxs)("div", {
        className: "mt-4 flex flex-col gap-1 border-t border-border pt-3",
        children: [
          /* @__PURE__ */ (0, r.jsx)("span", {
            className: "mb-1 text-xs font-medium text-muted-foreground",
            children: v(n, "EEEE, MMM d")
          }),
          d.map((f, p) => /* @__PURE__ */ (0, r.jsx)(re, {
            event: f,
            className: "animate-in fade-in slide-in-from-bottom-1 duration-200 fill-mode-backwards motion-reduce:animate-none",
            style: { animationDelay: `${p * 50}ms` }
          }, f.id)),
          h > 0 && /* @__PURE__ */ (0, r.jsxs)("span", {
            className: "text-xs text-muted-foreground",
            children: [
              "+",
              h,
              " more"
            ]
          })
        ]
      })
    ]
  });
}
Me.displayName = "MiniMonthCalendar";
function ke(e, t, n) {
  const [a, i] = x.useState(() => /* @__PURE__ */ new Date());
  x.useEffect(() => {
    if (!n) return;
    const s = setInterval(() => i(/* @__PURE__ */ new Date()), 6e4);
    return () => clearInterval(s);
  }, [n]);
  const o = a.getHours() + a.getMinutes() / 60;
  return {
    now: a,
    top: (o - e) * 96,
    visible: n && o >= e && o < t
  };
}
function Ce({ startHour: e = 0, endHour: t = 24, onEventClick: n, onEventCopy: a, onEventDelete: i, onEventEdit: o }) {
  const { events: s, selectedDate: l, selectEvent: c } = T(), { now: m, top: u, visible: g } = ke(e, t, V(l)), y = (d) => {
    c(d.id), n?.(d);
  };
  return /* @__PURE__ */ (0, r.jsxs)("div", {
    "data-slot": "day-view",
    role: "region",
    "aria-label": "Day calendar",
    className: "flex flex-col @[768px]:flex-row",
    children: [/* @__PURE__ */ (0, r.jsx)("div", {
      className: "min-w-0 flex-1",
      children: /* @__PURE__ */ (0, r.jsxs)(ee, {
        startHour: e,
        endHour: t,
        children: [/* @__PURE__ */ (0, r.jsx)(te, {
          date: l,
          events: s,
          startHour: e,
          endHour: t,
          onEventClick: y
        }), g && /* @__PURE__ */ (0, r.jsx)(H, {
          top: u,
          now: m
        })]
      })
    }), /* @__PURE__ */ (0, r.jsxs)("section", {
      "aria-label": "Day sidebar",
      className: "flex shrink-0 flex-col overflow-y-auto border-t border-border @[768px]:w-96 @[768px]:border-l @[768px]:border-t-0",
      children: [/* @__PURE__ */ (0, r.jsx)(Me, {}), /* @__PURE__ */ (0, r.jsx)(we, {
        onEventCopy: a,
        onEventDelete: i,
        onEventEdit: o
      })]
    })]
  });
}
Ce.displayName = "DayView";
var Dt = [];
function _e({ onEventClick: e, onMoreEventsClick: t, maxEventsPerCell: n = 2 }) {
  const { events: a, selectedDate: i, weekStartsOn: o, onDateSelect: s } = T(), l = x.useMemo(() => he(i, o), [i, o]), c = o === 0 ? yt : vt, m = o === 0 ? ge : be, u = x.useMemo(() => {
    const d = /* @__PURE__ */ new Map();
    for (const h of a) {
      const f = Z(M(h.start)), p = d.get(f);
      p ? p.push(h) : d.set(f, [h]);
    }
    return d;
  }, [a]), g = (d) => u.get(Z(d)) ?? Dt, y = x.useRef(null);
  return /* @__PURE__ */ (0, r.jsxs)("div", {
    ref: y,
    role: "grid",
    "aria-label": "Calendar",
    "data-slot": "month-view",
    className: "flex flex-col",
    children: [/* @__PURE__ */ (0, r.jsx)("div", {
      role: "row",
      className: "grid grid-cols-7",
      children: c.map((d, h) => /* @__PURE__ */ (0, r.jsxs)("div", {
        role: "columnheader",
        className: N("border-b border-border px-3 py-2 text-center text-xs font-medium text-muted-foreground", (o === 1 && h >= 5 || o === 0 && (h === 0 || h === 6)) && "bg-surface-1"),
        children: [/* @__PURE__ */ (0, r.jsx)("span", {
          className: "hidden @[640px]:inline",
          children: d
        }), /* @__PURE__ */ (0, r.jsx)("span", {
          className: "@[640px]:hidden",
          children: m[h]
        })]
      }, d))
    }), l.map((d, h) => /* @__PURE__ */ (0, r.jsx)("div", {
      role: "row",
      className: "grid grid-cols-7 border-b border-border last:border-b-0",
      children: d.map((f) => {
        const p = g(f), b = Q(f, i), k = I(f, i), w = V(f), S = G(f), $ = p.slice(0, n), C = p.length - n;
        return /* @__PURE__ */ (0, r.jsxs)("div", {
          role: "gridcell",
          "aria-selected": k || void 0,
          tabIndex: -1,
          className: N("min-h-28 border-e border-border p-2 last:border-e-0", S && "bg-surface-1", !b && "bg-secondary"),
          children: [
            /* @__PURE__ */ (0, r.jsx)("div", {
              className: "mb-1",
              children: /* @__PURE__ */ (0, r.jsx)("button", {
                type: "button",
                onClick: () => s(f),
                "aria-label": `Select ${v(f, "MMMM d, yyyy")}`,
                "aria-current": w ? "date" : void 0,
                "data-date": f.toISOString(),
                tabIndex: I(f, i) ? 0 : -1,
                onKeyDown: (j) => {
                  const D = ve[j.key];
                  if (D !== void 0) {
                    j.preventDefault();
                    const U = P(f, D), Y = y.current?.querySelector(`[data-date="${U.toISOString()}"]`);
                    Y ? Y.focus() : s(U);
                  }
                },
                className: N("relative flex size-9 items-center justify-center rounded-sm text-sm font-medium transition-colors duration-200 motion-reduce:transition-none", ye, W, w && "bg-primary text-primary-foreground shadow-[0_0_0_2px_hsl(var(--primary)/0.2)]", k && !w && "bg-primary/10 text-primary", !w && !k && b && "text-foreground hover:bg-accent", !b && "text-muted-foreground"),
                children: v(f, "d")
              })
            }),
            /* @__PURE__ */ (0, r.jsxs)("div", {
              className: "hidden @[640px]:flex flex-col gap-0.5",
              children: [$.map((j) => /* @__PURE__ */ (0, r.jsx)(re, {
                event: j,
                onClick: e,
                className: N(!b && "opacity-60")
              }, j.id)), C > 0 && /* @__PURE__ */ (0, r.jsxs)("button", {
                type: "button",
                "aria-label": `${C} more events on ${v(f, "MMMM d")}`,
                onClick: (j) => {
                  j.stopPropagation(), t?.(f, p);
                },
                className: N("relative min-h-[44px] text-start text-xs font-medium text-primary transition-colors hover:text-primary/80", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1"),
                children: [C, " more.."]
              })]
            }),
            p.length > 0 && /* @__PURE__ */ (0, r.jsx)("button", {
              type: "button",
              "aria-label": `${p.length} event${p.length > 1 ? "s" : ""}`,
              onClick: (j) => {
                j.stopPropagation(), p.length === 1 ? e?.(p[0]) : t?.(f, p);
              },
              className: N("flex min-h-[44px] min-w-[44px] items-center @[640px]:hidden", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1"),
              children: /* @__PURE__ */ (0, r.jsx)("span", {
                className: "flex flex-wrap gap-1",
                children: p.slice(0, 4).map((j) => /* @__PURE__ */ (0, r.jsx)("span", { className: N("size-1.5 rounded-full", Mt[j.color ?? "brand"], !b && "opacity-60") }, j.id))
              })
            })
          ]
        }, f.toISOString());
      })
    }, h))]
  });
}
_e.displayName = "MonthView";
var Et = [];
function Te({ startHour: e = 0, endHour: t = 24, onEventClick: n }) {
  const { events: a, selectedDate: i, weekStartsOn: o } = T(), s = J(i, { weekStartsOn: o }), l = Array.from({ length: 7 }, (d, h) => P(s, h)), c = x.useMemo(() => {
    const d = /* @__PURE__ */ new Map();
    for (const h of a) {
      const f = Z(M(h.start)), p = d.get(f);
      p ? p.push(h) : d.set(f, [h]);
    }
    return d;
  }, [a]), m = (d) => c.get(Z(d)) ?? Et, { now: u, top: g, visible: y } = ke(e, t, l.some((d) => V(d)));
  return /* @__PURE__ */ (0, r.jsxs)("div", {
    "data-slot": "week-view",
    role: "region",
    "aria-label": "Week calendar",
    children: [/* @__PURE__ */ (0, r.jsxs)("div", {
      className: "grid [grid-template-columns:72px_repeat(5,1fr)] @[768px]:[grid-template-columns:72px_repeat(7,1fr)]",
      children: [/* @__PURE__ */ (0, r.jsx)("div", { className: "border-b border-border" }), l.map((d) => {
        const h = V(d);
        return /* @__PURE__ */ (0, r.jsxs)("div", {
          className: N("flex flex-col items-center gap-0.5 border-b border-l border-border px-2 py-2", G(d) && "hidden @[768px]:flex bg-surface-1"),
          children: [/* @__PURE__ */ (0, r.jsx)("span", {
            className: "text-xs font-medium text-muted-foreground",
            children: v(d, "EEE")
          }), /* @__PURE__ */ (0, r.jsx)("span", {
            className: N("flex size-7 items-center justify-center text-sm font-semibold", h && "rounded-sm bg-primary text-primary-foreground shadow-[0_0_0_2px_hsl(var(--primary)/0.2)]", !h && "text-foreground"),
            children: v(d, "d")
          })]
        }, d.toISOString());
      })]
    }), /* @__PURE__ */ (0, r.jsxs)(ee, {
      startHour: e,
      endHour: t,
      children: [/* @__PURE__ */ (0, r.jsx)("div", {
        className: "grid h-full [grid-template-columns:repeat(5,1fr)] @[768px]:[grid-template-columns:repeat(7,1fr)]",
        children: l.map((d) => {
          const h = G(d);
          return /* @__PURE__ */ (0, r.jsx)(te, {
            date: d,
            events: a,
            dayEvents: m(d),
            startHour: e,
            endHour: t,
            onEventClick: n,
            className: N(h && "hidden @[768px]:block")
          }, d.toISOString());
        })
      }), y && /* @__PURE__ */ (0, r.jsx)(H, {
        top: g,
        now: u
      })]
    })]
  });
}
Te.displayName = "WeekView";
function Se({ view: e, onEventClick: t, onMoreEventsClick: n, onEventCopy: a, onEventDelete: i, onEventEdit: o, startHour: s = 0, endHour: l = 24, maxEventsPerCell: c = 2 }) {
  const m = T(), u = e ?? m.view, { idPrefix: g } = m;
  return /* @__PURE__ */ (0, r.jsxs)("div", {
    "data-slot": "calendar-content",
    id: `${g}-tabpanel-${u}`,
    role: "tabpanel",
    "aria-labelledby": `${g}-tab-${u}`,
    children: [
      u === "month" && /* @__PURE__ */ (0, r.jsx)(_e, {
        onEventClick: t,
        onMoreEventsClick: n,
        maxEventsPerCell: c
      }),
      u === "week" && /* @__PURE__ */ (0, r.jsx)(Te, {
        startHour: s,
        endHour: l,
        onEventClick: t
      }),
      u === "day" && /* @__PURE__ */ (0, r.jsx)(Ce, {
        startHour: s,
        endHour: l,
        onEventClick: t,
        onEventCopy: a,
        onEventDelete: i,
        onEventEdit: o
      })
    ]
  });
}
Se.displayName = "CalendarContent";
function De({ children: e, className: t }) {
  return /* @__PURE__ */ (0, r.jsx)("div", {
    "data-slot": "calendar-header",
    role: "toolbar",
    "aria-label": "Calendar controls",
    className: N("flex items-center gap-3 border-b border-border px-4 py-3", t),
    children: e
  });
}
De.displayName = "CalendarHeader";
function Ee({ className: e }) {
  const { navigatePrev: t, navigateNext: n, goToToday: a, view: i } = T(), o = i === "month" ? "month" : i === "week" ? "week" : "day", s = `Previous ${o}`, l = `Next ${o}`;
  return /* @__PURE__ */ (0, r.jsxs)("div", {
    "data-slot": "calendar-navigation",
    className: N("flex items-center gap-1", e),
    children: [
      /* @__PURE__ */ (0, r.jsx)(_, {
        appearance: "outline",
        variant: "secondary",
        size: "icon-sm",
        onClick: t,
        "aria-label": s,
        children: /* @__PURE__ */ (0, r.jsx)(ue, { className: "size-4" })
      }),
      /* @__PURE__ */ (0, r.jsx)(_, {
        appearance: "outline",
        variant: "secondary",
        size: "icon-sm",
        "aria-label": "Calendar picker",
        children: /* @__PURE__ */ (0, r.jsx)(de, { className: "size-4" })
      }),
      /* @__PURE__ */ (0, r.jsx)(_, {
        appearance: "outline",
        variant: "secondary",
        size: "icon-sm",
        onClick: n,
        "aria-label": l,
        children: /* @__PURE__ */ (0, r.jsx)(me, { className: "size-4" })
      }),
      /* @__PURE__ */ (0, r.jsx)(_, {
        appearance: "outline",
        variant: "secondary",
        size: "xs",
        onClick: a,
        "aria-label": "Go to today",
        children: "Today"
      })
    ]
  });
}
Ee.displayName = "CalendarNavigation";
function $e({ className: e }) {
  const { view: t, selectedDate: n, weekStartsOn: a } = T(), i = x.useMemo(() => {
    switch (t) {
      case "month":
        return v(n, "MMMM yyyy");
      case "week": {
        const o = J(n, { weekStartsOn: a }), s = ie(n, { weekStartsOn: a });
        return Q(o, s) ? `${v(o, "MMMM d")} – ${v(s, "d, yyyy")}` : `${v(o, "MMM d")} – ${v(s, "MMM d, yyyy")}`;
      }
      case "day":
        return v(n, "EEEE, MMMM d, yyyy");
    }
  }, [
    t,
    n,
    a
  ]);
  return /* @__PURE__ */ (0, r.jsx)("h2", {
    "data-slot": "calendar-title",
    className: N("text-base font-semibold text-foreground", e),
    children: i
  });
}
$e.displayName = "CalendarTitle";
var A = [
  {
    value: "month",
    label: "Month"
  },
  {
    value: "week",
    label: "Week"
  },
  {
    value: "day",
    label: "Day"
  }
];
function Oe({ view: e, onViewChange: t, className: n }) {
  const a = T(), i = e ?? a.view, o = t ?? a.onViewChange, { idPrefix: s } = a, l = (c, m) => {
    let u = null;
    if (c.key === "ArrowRight" || c.key === "ArrowDown" ? u = (m + 1) % A.length : c.key === "ArrowLeft" || c.key === "ArrowUp" ? u = (m - 1 + A.length) % A.length : c.key === "Home" ? u = 0 : c.key === "End" && (u = A.length - 1), u !== null) {
      c.preventDefault();
      const g = A[u];
      o(g.value), c.target.closest('[role="tablist"]')?.querySelectorAll('[role="tab"]')?.[u]?.focus();
    }
  };
  return /* @__PURE__ */ (0, r.jsx)("div", {
    "data-slot": "calendar-view-switcher",
    role: "tablist",
    "aria-label": "Calendar view",
    className: N("flex overflow-hidden rounded-lg border border-border", n),
    children: A.map((c, m) => {
      const u = i === c.value;
      return /* @__PURE__ */ (0, r.jsx)("button", {
        type: "button",
        role: "tab",
        id: `${s}-tab-${c.value}`,
        "aria-selected": u,
        "aria-controls": `${s}-tabpanel-${c.value}`,
        tabIndex: u ? 0 : -1,
        onClick: () => o(c.value),
        onKeyDown: (g) => l(g, m),
        className: N("min-h-[44px] px-3 py-1.5 text-xs font-medium transition-colors duration-200 motion-reduce:transition-none", "border-e border-border last:border-e-0", W, u ? "bg-muted font-semibold text-foreground" : "text-muted-foreground hover:bg-muted/50"),
        children: c.label
      }, c.value);
    })
  });
}
Oe.displayName = "CalendarViewSwitcher";
var [$t, T] = Je("Calendar");
function Ae({ events: e = [], selectedDate: t, onDateSelect: n, view: a, onViewChange: i, weekStartsOn: o = 1, className: s, children: l, onEventClick: c }) {
  const [m, u] = x.useState("month"), [g, y] = x.useState(/* @__PURE__ */ new Date()), [d, h] = x.useState(null), f = a ?? m, p = t ?? g, b = x.useCallback((O) => {
    y(O), n?.(O);
  }, [n]), k = x.useCallback((O) => {
    u(O), i?.(O);
  }, [i]), w = x.useId(), S = x.useCallback((O) => {
    h(O);
  }, []), $ = x.useCallback(() => {
    h(null);
  }, []), C = x.useCallback(() => {
    switch (f) {
      case "month":
        b(X(p, 1));
        break;
      case "week":
        b(We(p, 1));
        break;
      case "day":
        b(P(p, 1));
        break;
    }
  }, [
    f,
    p,
    b
  ]), j = x.useCallback(() => {
    switch (f) {
      case "month":
        b(xe(p, 1));
        break;
      case "week":
        b(Fe(p, 1));
        break;
      case "day":
        b(P(p, -1));
        break;
    }
  }, [
    f,
    p,
    b
  ]), D = x.useCallback(() => {
    b(/* @__PURE__ */ new Date());
  }, [b]), U = x.useMemo(() => ({
    events: e,
    selectedDate: p,
    view: f,
    weekStartsOn: o,
    idPrefix: w,
    selectedEventId: d,
    selectEvent: S,
    clearSelectedEvent: $,
    onDateSelect: b,
    onViewChange: k,
    navigateNext: C,
    navigatePrev: j,
    goToToday: D
  }), [
    e,
    p,
    f,
    o,
    w,
    d,
    S,
    $,
    b,
    k,
    C,
    j,
    D
  ]), Y = x.useMemo(() => {
    switch (f) {
      case "month":
        return v(p, "MMMM yyyy");
      case "week":
        return `Week of ${v(p, "MMMM d, yyyy")}`;
      case "day":
        return v(p, "EEEE, MMMM d, yyyy");
    }
  }, [f, p]), Ie = x.Children.count(l) > 0;
  return /* @__PURE__ */ (0, r.jsx)($t.Provider, {
    value: U,
    children: /* @__PURE__ */ (0, r.jsxs)("div", {
      "data-slot": "calendar",
      role: "region",
      "aria-label": "Calendar",
      className: N("@container w-full", s),
      children: [/* @__PURE__ */ (0, r.jsx)("div", {
        className: "sr-only",
        "aria-live": "polite",
        role: "status",
        children: Y
      }), Ie ? l : /* @__PURE__ */ (0, r.jsx)(Ot, { onEventClick: c })]
    })
  });
}
Ae.displayName = "Calendar";
function Ot({ onEventClick: e }) {
  return /* @__PURE__ */ (0, r.jsxs)(r.Fragment, { children: [/* @__PURE__ */ (0, r.jsxs)(De, { children: [
    /* @__PURE__ */ (0, r.jsx)($e, {}),
    /* @__PURE__ */ (0, r.jsx)(Oe, {}),
    /* @__PURE__ */ (0, r.jsx)(Ee, {})
  ] }), /* @__PURE__ */ (0, r.jsx)(Se, { onEventClick: e })] });
}
var At = Pe(), L = {};
function se(e, t) {
  if (e !== null)
    switch (t) {
      case "number":
        return Number(e);
      case "boolean":
        return e !== "false" && e !== "0";
      case "json":
        try {
          return JSON.parse(e);
        } catch {
          return e;
        }
      default:
        return e;
    }
}
var ze = class extends HTMLElement {
  _root = null;
  _childrenContainer = null;
  _props = {};
  _initialized = !1;
  connectedCallback() {
    setTimeout(() => this._initialize(), 0);
  }
  _initialize() {
    if (this._initialized) return;
    this._initialized = !0;
    const e = [];
    for (const n of Array.from(this.childNodes))
      n.nodeType === Node.TEXT_NODE && !n.textContent?.trim() || e.push(n);
    const t = document.createElement("div");
    for (t.style.display = "contents", this._childrenContainer = document.createElement("div"), this._childrenContainer.style.display = "contents", e.forEach((n) => this._childrenContainer.appendChild(n)); this.firstChild; ) this.removeChild(this.firstChild);
    this.appendChild(t), this._root = (0, At.createRoot)(t), this._render();
  }
  disconnectedCallback() {
    this._root?.unmount(), this._root = null;
  }
  attributeChangedCallback(e, t, n) {
    this._render();
  }
  static get observedAttributes() {
    return Object.keys(L).map((e) => e.replace(/([A-Z])/g, "-$1").toLowerCase());
  }
  _setProp(e, t) {
    const n = L[e] || "string";
    this._props[e] = this._parseValue(t, n), this._render();
  }
  _parseValue(e, t) {
    if (t === "boolean" && typeof e == "boolean" || t === "number" && typeof e == "number" || t === "string" && typeof e == "string") return e;
    if (typeof e == "string") switch (t) {
      case "boolean":
        return e !== "false" && e !== "0" && e !== "";
      case "number":
        return Number(e);
      case "json":
        try {
          return JSON.parse(e);
        } catch {
          return e;
        }
      default:
        return e;
    }
    return e;
  }
  _getProp(e) {
    if (e in this._props) return this._props[e];
    const t = e.replace(/([A-Z])/g, "-$1").toLowerCase(), n = L[e] || "string";
    return se(this.getAttribute(t), n);
  }
  _render() {
    if (!this._root || !this._childrenContainer) return;
    const e = {};
    for (const [n, a] of Object.entries(L)) if (n in this._props) e[n] = this._props[n];
    else {
      const i = n.replace(/([A-Z])/g, "-$1").toLowerCase();
      e[n] = se(this.getAttribute(i), a);
    }
    const t = x.createElement(Ae, {
      ...e,
      _hostElement: this
    }, x.createElement("span", {
      ref: (n) => {
        n && this._childrenContainer && n.replaceWith(this._childrenContainer);
      },
      style: { display: "contents" }
    }));
    this._root.render(t);
  }
};
for (const e of Object.keys(L)) Object.defineProperty(ze.prototype, e, {
  get() {
    return this._getProp(e);
  },
  set(t) {
    this._setProp(e, t);
  },
  enumerable: !0,
  configurable: !0
});
typeof customElements < "u" && !customElements.get("hf-calendar") && customElements.define("hf-calendar", ze);
export {
  ze as CalendarWC,
  ze as default
};

//# sourceMappingURL=hf-calendar.js.map