import { jsxs as i, jsx as t } from "react/jsx-runtime";
import { isValidElement as W } from "react";
import E from "@iconify-icons/tabler/cloud-download";
import { Icon as s } from "@iconify/react";
import { Verified as F } from "@mui/icons-material";
import { useTheme as O, Card as V, Stack as f, Typography as S, Box as I, CircularProgress as q } from "@mui/material";
import z from "../Avatar/index.js";
import G from "../Button/index.js";
import "../Theme/theme.js";
import "../Theme/theme-provider.js";
import c from "./components/icon-text.js";
import B from "./components/tooltip-icon.js";
import { strippedString as T, formatDownloadCount as J } from "./utils.js";
function so({ ...M }) {
  const {
    title: r,
    description: e = "",
    cover: A = "",
    avatar: D,
    author: L,
    download: h,
    did: x,
    official: n,
    buttonText: P = "Install",
    buttonDisabled: m,
    buttonLoading: d,
    button: u,
    onButtonClick: y = () => {
    },
    onMainClick: g,
    className: K,
    ref: Q,
    icons: R,
    status: k,
    ...b
  } = M, p = O(), v = (o, H = () => !1) => (w, ...N) => {
    const C = o instanceof Function;
    (H() || C) && (w.preventDefault(), w.stopPropagation(), C && o(...N));
  }, _ = g && v(g), j = v(y, () => !!(u || m || d)), l = W(r) ? { children: r } : { title: T(r), dangerouslySetInnerHTML: { __html: r } }, a = W(e) ? { children: e } : { title: T(e), dangerouslySetInnerHTML: { __html: e } };
  return /* @__PURE__ */ i(
    V,
    {
      variant: "outlined",
      onClick: _,
      ...b,
      sx: { p: { xs: 2, md: 3 }, borderRadius: 1, ...b.sx },
      children: [
        /* @__PURE__ */ i(
          f,
          {
            direction: "row",
            sx: {
              flex: 1,
              gap: 1,
              alignItems: "center",
              overflow: "hidden",
              "& > *": { flexShrink: 0 }
            },
            children: [
              /* @__PURE__ */ t(z, { src: A, did: x, size: 48, variant: "rounded", style: { borderRadius: "8px", overflow: "hidden" } }),
              /* @__PURE__ */ t(
                S,
                {
                  className: "blocklet-title",
                  ...l,
                  sx: [
                    {
                      fontWeight: "fontWeightMedium",
                      fontSize: 16,
                      textOverflow: "ellipsis",
                      whiteSpace: "nowrap",
                      overflow: "hidden",
                      cursor: "default",
                      pl: 0.5,
                      "&&": { flexShrink: 1 }
                    },
                    ...Array.isArray(l.sx) ? l.sx : [l.sx]
                  ]
                }
              ),
              /* @__PURE__ */ i(
                I,
                {
                  sx: {
                    flex: 1,
                    display: "flex",
                    alignItems: "center",
                    justifyContent: "flex-start",
                    gap: 1
                  },
                  children: [
                    n && /* @__PURE__ */ t(B, { title: n.tooltip, children: /* @__PURE__ */ t(F, { sx: { color: n.color || "#D97706", fontSize: n.size || 18 } }) }),
                    R?.map((o) => /* @__PURE__ */ t(B, { title: o.title, children: typeof o.icon == "string" ? /* @__PURE__ */ t(s, { icon: o.icon, style: { color: o.color } }) : o.icon }, o.key))
                  ]
                }
              ),
              y && /* @__PURE__ */ i(
                G,
                {
                  variant: "outlined",
                  size: "small",
                  disabled: m || d,
                  style: {
                    color: p.palette.text.primary,
                    borderColor: p.palette.grey[300],
                    borderRadius: 8,
                    fontSize: 13,
                    fontWeight: p.typography.fontWeightMedium
                  },
                  onClick: j,
                  children: [
                    d && /* @__PURE__ */ t(q, { size: 15, style: { marginRight: 3, color: "inherit" } }),
                    P
                  ]
                }
              ),
              u
            ]
          }
        ),
        /* @__PURE__ */ t(
          f,
          {
            sx: {
              py: 2
            },
            children: /* @__PURE__ */ t(
              S,
              {
                className: "blocklet-description",
                variant: "body2",
                ...a,
                sx: [
                  {
                    color: "text.secondary",
                    display: "-webkit-box",
                    lineClamp: 2,
                    WebkitLineClamp: 2,
                    WebkitBoxOrient: "vertical",
                    overflow: "hidden",
                    cursor: "default",
                    height: 40
                  },
                  ...Array.isArray(a.sx) ? a.sx : [a.sx]
                ]
              }
            )
          }
        ),
        /* @__PURE__ */ i(
          f,
          {
            direction: "row",
            sx: {
              alignItems: "center",
              gap: 2,
              color: "text.secondary"
            },
            children: [
              /* @__PURE__ */ t(c, { icon: /* @__PURE__ */ t(z, { src: D, did: x, size: 20, variant: "circle" }), maxWidth: 200, children: L }),
              /* @__PURE__ */ t(c, { icon: /* @__PURE__ */ t(s, { icon: E }), title: h, children: J(h) }),
              k?.filter((o) => o.align !== "right").map((o) => /* @__PURE__ */ t(
                c,
                {
                  icon: typeof o.icon == "string" ? /* @__PURE__ */ t(s, { icon: o.icon }) : o.icon,
                  title: o.title,
                  maxWidth: o.maxWidth,
                  children: o.text
                },
                o.key
              )),
              /* @__PURE__ */ t(I, { sx: { flex: 1 } }),
              k?.filter((o) => o.align === "right").map((o) => /* @__PURE__ */ t(
                c,
                {
                  icon: typeof o.icon == "string" ? /* @__PURE__ */ t(s, { icon: o.icon }) : o.icon,
                  title: o.title,
                  maxWidth: o.maxWidth,
                  sx: { color: o.color },
                  children: o.text
                },
                o.key
              ))
            ]
          }
        )
      ]
    }
  );
}
export {
  so as default
};
