import { jsxs as m, jsx as e } from "react/jsx-runtime";
import t from "../../components/RatingPreview/ratingPreview.module.css";
import { Typography as l } from "../Typography/Typography.es.js";
import { Icon as c } from "../Icon/Icon.es.js";
import { EIconName as n } from "../Icon/constants.es.js";
const d = (s) => {
  const a = Math.round(s * 2) / 2, r = [];
  for (let o = 0; o < Math.floor(a); o++)
    r.push(/* @__PURE__ */ e(c, { name: n.STAR_FILL, className: t.starIcon }, `full-${o}`));
  return a % 1 === 0.5 && r.push(/* @__PURE__ */ e(c, { name: n.STAR_HALF, className: t.starIcon }, "half")), r;
}, v = ({ rating: s, text: a }) => {
  if (!(s != null && s.stars) && !a) return null;
  const r = !!(s != null && s.stars) && !!a;
  return /* @__PURE__ */ m("div", { className: t.ratingPreview, children: [
    s !== void 0 && s.stars !== void 0 && /* @__PURE__ */ m(l, { as: "p", defaultVariant: "labelMd", children: [
      s.stars,
      " ",
      d(s.stars)
    ] }),
    r && /* @__PURE__ */ e(l, { as: "p", defaultVariant: "labelSm", children: "|" }),
    a && /* @__PURE__ */ e(l, { as: "p", defaultVariant: "labelSm", emphasis: !0, children: a })
  ] });
};
export {
  v as RatingPreview
};
