"use client";
import { jsx, jsxs } from "react/jsx-runtime";
const DEFAULT_COLOR = "#6366f1";
function HoursSparkline({
  values,
  color = DEFAULT_COLOR,
  width = 54,
  height = 14,
  ariaLabel,
  className
}) {
  const nonEmpty = values.length > 0;
  const max = nonEmpty ? Math.max(...values, 0) : 0;
  const allZero = !nonEmpty || max === 0;
  if (allZero) {
    return /* @__PURE__ */ jsx(
      "svg",
      {
        role: "img",
        "aria-label": ariaLabel,
        width,
        height,
        viewBox: `0 0 ${width} ${height}`,
        className,
        children: /* @__PURE__ */ jsx(
          "line",
          {
            x1: 0,
            x2: width,
            y1: height / 2,
            y2: height / 2,
            className: "stroke-border",
            strokeWidth: 1
          }
        )
      }
    );
  }
  const stepX = values.length === 1 ? 0 : width / (values.length - 1);
  const points = values.map((value, idx) => {
    const x = values.length === 1 ? width / 2 : idx * stepX;
    const y = height - value / max * (height - 2) - 1;
    return { x, y };
  });
  const linePath = points.map((p, idx) => idx === 0 ? `M${p.x},${p.y}` : `L${p.x},${p.y}`).join(" ");
  const areaPath = `${linePath} L${points[points.length - 1].x},${height} L${points[0].x},${height} Z`;
  return /* @__PURE__ */ jsxs(
    "svg",
    {
      role: "img",
      "aria-label": ariaLabel,
      width,
      height,
      viewBox: `0 0 ${width} ${height}`,
      className,
      children: [
        /* @__PURE__ */ jsx("path", { d: areaPath, fill: color, opacity: 0.15 }),
        /* @__PURE__ */ jsx("path", { d: linePath, fill: "none", stroke: color, strokeWidth: 1.25, strokeLinecap: "round", strokeLinejoin: "round" })
      ]
    }
  );
}
export {
  HoursSparkline
};
//# sourceMappingURL=HoursSparkline.js.map
