import React, { forwardRef } from "react";
import { usePeriodContext } from "../hooks/usePeriodContext.js";
import { useRowContext } from "../hooks/useRowContext.js";
import ClickablePeriod from "./ClickablePeriod.js";
import NonClickablePeriod from "./NonClickablePeriod.js";
export const Period = forwardRef(({ icon }, ref) => {
    const { periods } = useRowContext();
    const { periodId, restProps } = usePeriodContext();
    const period = periods.find((p) => p.id === periodId);
    if (!period) {
        return null;
    }
    const { start, endInclusive, width, horizontalPosition, status = "neutral", onSelectPeriod, cropped, direction, children, isActive, statusLabel, } = period;
    return onSelectPeriod || children ? (React.createElement(ClickablePeriod, { periodRef: ref, start: start, end: endInclusive, status: status, onSelectPeriod: onSelectPeriod, cropped: cropped || "", direction: direction, width: width, left: horizontalPosition, icon: icon, isActive: isActive, statusLabel: statusLabel, restProps: restProps }, children)) : (React.createElement(NonClickablePeriod, { periodRef: ref, start: start, end: endInclusive, status: status, cropped: cropped || "", direction: direction, width: width, left: horizontalPosition, icon: icon, statusLabel: statusLabel, restProps: restProps }));
});
Period.componentType = "period";
export default Period;
//# sourceMappingURL=index.js.map