import { jsx as E } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import { memo as u } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/compat/dist/compat.module.js";
import { propsProperty as y, property as o } from "./utils.js";
import { CalendarGridRenderToken as w } from "../../types.js";
import { memoComparator as N } from "../../../../../utils/preact/memoComparator/main.js";
import { fixedForwardRef as O } from "../../../../../utils/preact/fixedForwardRef.js";
import { getClassName as p } from "../../../../../utils/preact/className.js";
import { EMPTY_OBJECT as i } from "../../../../../utils/value/constants.js";
const T = "adyen-pe-calendar__cell adyen-pe-calendar__cell--date", l = "adyen-pe-calendar__date", P = (t = i, n) => {
  const r = y.unwrapped(
    {
      childClassName: o.mutable(l),
      childProps: {
        children: o.restricted(),
        className: ""
      },
      className: o.mutable(T),
      props: {
        ...t,
        children: o.restricted(),
        className: ""
      }
    },
    !0
  );
  return n?.(w.DATE, r), r;
}, G = O(
  ({ grid: t, prepare: n, datetime: r, flags: e, index: m, label: _, onlyCellsWithin: C }, h) => {
    const s = e.WITHIN_BLOCK, a = {
      "data-cursor-position": m,
      "data-within-month": s,
      tabIndex: -1
    };
    if (s) {
      const c = e.WITHIN_RANGE;
      a["data-today"] = e.CURRENT, e.CURRENT && (a["data-testid"] = "calendar-current-day"), a["data-first-week-day"] = e.LINE_START, a["data-last-week-day"] = e.LINE_END, a["data-weekend"] = e.WEEKEND, a["data-first-month-day"] = e.BLOCK_START, a["data-last-month-day"] = e.BLOCK_END, a["data-within-range"] = c, c && (a["data-range-end"] = e.RANGE_END, a["data-range-start"] = e.RANGE_START, a["data-selection-end"] = e.SELECTION_END, a["data-selection-start"] = e.SELECTION_START, a["data-within-selection"] = e.WITHIN_SELECTION, a["aria-selected"] = `${!!(e.SELECTION_END || e.SELECTION_START || e.WITHIN_SELECTION)}`), m === +t.cursor && (a.ref = h);
    }
    const d = P(a, n), { children: x, className: I, ...A } = d.props || i, L = p(d.className, T, I);
    return /* @__PURE__ */ E("td", { ...A, ...a, className: L, children: (!C || s) && (() => {
      const {
        children: c,
        className: R,
        ...S
      } = d.childProps || i, D = p(d.childClassName, l, R);
      return /* @__PURE__ */ E("time", { ...S, className: D, dateTime: r, children: _ });
    })() });
  }
), f = u(
  G,
  N({
    block: N.exclude,
    flags: (t) => +t
  })
);
export {
  f as default
};
