"use client";
import { j as o } from "./index.esm38.js";
import { forwardRef as g, useMemo as q, useCallback as y } from "react";
import z from "./index.esm40.js";
import { formatDateRu as F } from "./index.esm35.js";
import i from "./index.esm51.js";
import { ArticlePreviewContent as G } from "./index.esm52.js";
const H = g(
  ({
    title: m,
    publishedAt: c,
    formattedDate: d,
    description: x,
    viewsCount: f,
    readingTimeMinutes: j,
    author: N,
    imageUrl: n,
    view: l = "card",
    imageAlt: b = "",
    href: t,
    tags: A,
    className: P,
    contentClassName: R,
    showPlaceholder: E,
    testId: I,
    onClick: a,
    onKeyDown: r,
    ...$
  }, u) => {
    const B = q(
      () => d ?? F(c),
      [d, c]
    ), L = y((s) => {
      !t && a && (s.key === "Enter" || s.key === " ") && (s.preventDefault(), a(s)), r == null || r(s);
    }, [t, a, r]), e = !!(t || a), M = z(
      i.root,
      i[`root--${l}`],
      e && i["root--interactive"],
      P
    ), v = /* @__PURE__ */ o.jsx(
      G,
      {
        title: m,
        description: x,
        viewsCount: f,
        readingTimeMinutes: j,
        author: N,
        ...n != null ? { imageUrl: n, imageAlt: b || m } : {},
        formattedDate: B,
        view: l,
        tags: A,
        href: t,
        showPlaceholder: E,
        className: R
      }
    ), p = {
      className: M,
      "data-atme-ui": !0,
      "data-testid": I,
      ...e && { "data-interactive": !0 },
      ...$
    };
    return t ? /* @__PURE__ */ o.jsxs("div", { ref: u, ...p, children: [
      /* @__PURE__ */ o.jsx(
        "a",
        {
          href: t,
          className: i.cardLink,
          "aria-label": `Перейти к статье: ${m}`,
          onClick: a
        }
      ),
      v
    ] }) : /* @__PURE__ */ o.jsx(
      "div",
      {
        ref: u,
        ...p,
        onClick: a,
        onKeyDown: e ? L : r,
        role: e ? "button" : void 0,
        tabIndex: e ? 0 : void 0,
        children: v
      }
    );
  }
);
H.displayName = "ArticlePreview";
export {
  H as ArticlePreview
};
//# sourceMappingURL=index.esm30.js.map
