import { jsx as e } from "@emotion/react/jsx-runtime";
import { forwardRef as N, useMemo as C } from "react";
import { SkeletonDateRangePickerStyled as _, DateRangePickerStyled as v } from "./slots/DateRangePickerSlots.js";
import { useDateRangePicker as I } from "./hooks/useDateRangePicker/useDateRangePicker.js";
import { DATE_RANGE_PICKER_CLASSES as i } from "./constants.js";
import { clsx as h } from "clsx";
import { TEST_PROP_ID as m } from "../../../../test/constants_no_mock.js";
import { DateRangePicker as O } from "rsuite";
import { DateTimeCreatedOutlined as T } from "@m4l/icons";
import { Icon as y } from "@m4l/base";
const z = N((a, c) => {
  const {
    value: t,
    onChange: n,
    disabled: l,
    className: d,
    readOnly: f,
    dataTestId: s,
    format: p
  } = a, {
    ownerState: u,
    dateFormat: D,
    currentSize: o,
    isSkeleton: P
  } = I(a), R = (r) => {
    if (r == null)
      n?.({ start: null, end: null });
    else {
      const [k, E] = r;
      n?.({ start: k, end: E });
    }
  }, S = C(() => () => /* @__PURE__ */ e(y, { size: o, src: /* @__PURE__ */ e(T, {}) }), [o]), g = t ? [t.start, t.end] : [null, null];
  return P ? /* @__PURE__ */ e(
    _,
    {
      className: i.skeleton,
      variant: "rounded",
      ownerState: { size: o },
      ...process.env.NODE_ENV !== "production" ? { [m]: s } : {}
    }
  ) : /* @__PURE__ */ e(
    v,
    {
      className: h(d, i.root),
      ownerState: u,
      ref: c,
      ...process.env.NODE_ENV !== "production" ? { [m]: s } : {},
      children: /* @__PURE__ */ e(
        O,
        {
          value: g,
          onChange: R,
          disabled: l,
          readOnly: f,
          format: p || D,
          caretAs: S
        }
      )
    }
  );
});
z.displayName = "DateRangePicker";
export {
  z as DateRangePicker
};
