// src/components/StudentRanking/StudentRanking.tsx
import { TrendUp, TrendDown } from "phosphor-react";

// src/utils/utils.ts
import { clsx } from "clsx";
import { twMerge } from "tailwind-merge";
function cn(...inputs) {
  return twMerge(clsx(inputs));
}

// src/components/Text/Text.tsx
import { jsx } from "react/jsx-runtime";
var Text = ({
  children,
  size = "md",
  weight = "normal",
  color = "text-text-950",
  as,
  className = "",
  ...props
}) => {
  let sizeClasses;
  let weightClasses;
  const sizeClassMap = {
    "2xs": "text-2xs",
    xs: "text-xs",
    sm: "text-sm",
    md: "text-md",
    lg: "text-lg",
    xl: "text-xl",
    "2xl": "text-2xl",
    "3xl": "text-3xl",
    "4xl": "text-4xl",
    "5xl": "text-5xl",
    "6xl": "text-6xl"
  };
  sizeClasses = sizeClassMap[size] ?? sizeClassMap.md;
  const weightClassMap = {
    hairline: "font-hairline",
    light: "font-light",
    normal: "font-normal",
    medium: "font-medium",
    semibold: "font-semibold",
    bold: "font-bold",
    extrabold: "font-extrabold",
    black: "font-black"
  };
  weightClasses = weightClassMap[weight] ?? weightClassMap.normal;
  const baseClasses = "font-primary";
  const Component = as ?? "p";
  return /* @__PURE__ */ jsx(
    Component,
    {
      className: cn(baseClasses, sizeClasses, weightClasses, color, className),
      ...props,
      children
    }
  );
};
var Text_default = Text;

// src/components/shared/RankingShared.tsx
import { Trophy, Warning } from "phosphor-react";
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
var CARD_BACKGROUND_CLASSES = {
  highlight: {
    1: "bg-success-200",
    2: "bg-success-100",
    3: "bg-success-background"
  },
  attention: {
    1: "bg-error-200",
    2: "bg-error-100",
    3: "bg-error-background"
  }
};
var BADGE_BACKGROUND_CLASSES = {
  highlight: "bg-indicator-positive",
  attention: "bg-indicator-negative"
};
var PERCENTAGE_BADGE_CLASSES = {
  highlight: "bg-success-700",
  attention: "bg-indicator-negative"
};
var HEADER_BADGE_CLASSES = BADGE_BACKGROUND_CLASSES;
var getPositionBackgroundClass = (variant, position) => {
  const positionKey = Math.max(1, Math.min(position, 3));
  return CARD_BACKGROUND_CLASSES[variant][positionKey];
};
function BaseRankingCard({
  title,
  variant,
  items,
  renderItem,
  headerIcon,
  className,
  ...props
}) {
  const DefaultIcon = variant === "highlight" ? Trophy : Warning;
  return /* @__PURE__ */ jsxs(
    "div",
    {
      className: cn(
        "flex flex-col flex-1 min-h-[254px] p-5 gap-4 bg-background border border-border-50 rounded-xl",
        className
      ),
      ...props,
      children: [
        /* @__PURE__ */ jsxs("div", { className: "flex flex-row justify-between items-center h-6 gap-4", children: [
          /* @__PURE__ */ jsx2(
            Text_default,
            {
              as: "h3",
              size: "lg",
              weight: "bold",
              className: "text-text-950 tracking-[0.2px]",
              children: title
            }
          ),
          /* @__PURE__ */ jsx2(
            "span",
            {
              className: cn(
                "w-6 h-6 rounded-full flex items-center justify-center",
                HEADER_BADGE_CLASSES[variant]
              ),
              children: headerIcon ?? /* @__PURE__ */ jsx2(
                DefaultIcon,
                {
                  size: 14,
                  weight: "fill",
                  className: variant === "highlight" ? "text-text-950" : "text-text"
                }
              )
            }
          )
        ] }),
        /* @__PURE__ */ jsx2("div", { className: "flex flex-col gap-2", children: items.map((item, index) => renderItem(item, variant, index)) })
      ]
    }
  );
}
function RankingLayout({
  children,
  className,
  ...props
}) {
  return /* @__PURE__ */ jsx2(
    "div",
    {
      className: cn("grid grid-cols-1 sm:grid-cols-2 w-full gap-4", className),
      ...props,
      children
    }
  );
}

// src/components/StudentRanking/StudentRanking.tsx
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
var StudentCard = ({
  student,
  variant
}) => {
  const TrendIcon = variant === "highlight" ? TrendUp : TrendDown;
  const backgroundClass = getPositionBackgroundClass(variant, student.position);
  return /* @__PURE__ */ jsxs2(
    "div",
    {
      className: cn(
        "flex flex-row items-center w-full p-4 gap-2 rounded-xl",
        backgroundClass
      ),
      children: [
        /* @__PURE__ */ jsx3(
          Text_default,
          {
            size: "xs",
            weight: "bold",
            "aria-label": `Posi\xE7\xE3o ${student.position}`,
            className: cn(
              "w-5 h-5 rounded-full flex items-center justify-center text-text",
              BADGE_BACKGROUND_CLASSES[variant]
            ),
            children: student.position
          }
        ),
        /* @__PURE__ */ jsx3(
          Text_default,
          {
            size: "sm",
            weight: "bold",
            className: "flex-1 min-w-0 text-text-950 tracking-[0.2px] truncate",
            children: student.name
          }
        ),
        /* @__PURE__ */ jsxs2(
          Text_default,
          {
            size: "xs",
            weight: "bold",
            "aria-label": `Desempenho ${student.percentage}%`,
            className: cn(
              "flex flex-row items-center h-[22px] px-2 gap-1 rounded text-text",
              PERCENTAGE_BADGE_CLASSES[variant]
            ),
            children: [
              /* @__PURE__ */ jsx3(TrendIcon, { size: 16, weight: "bold", "aria-hidden": "true" }),
              student.percentage,
              "%"
            ]
          }
        )
      ]
    }
  );
};
var RankingCard = ({
  title,
  variant,
  students,
  className,
  ...props
}) => /* @__PURE__ */ jsx3(
  BaseRankingCard,
  {
    title,
    variant,
    items: students,
    renderItem: (student, v, index) => /* @__PURE__ */ jsx3(
      StudentCard,
      {
        student,
        variant: v
      },
      `${v}-${index}-${student.position}`
    ),
    className,
    ...props
  }
);
var StudentRanking = ({
  highlightTitle = "Estudantes em destaque",
  attentionTitle = "Estudantes precisando de aten\xE7\xE3o",
  highlightStudents,
  attentionStudents,
  className,
  ...props
}) => {
  return /* @__PURE__ */ jsxs2(RankingLayout, { className, ...props, children: [
    /* @__PURE__ */ jsx3(
      RankingCard,
      {
        title: highlightTitle,
        variant: "highlight",
        students: highlightStudents
      }
    ),
    /* @__PURE__ */ jsx3(
      RankingCard,
      {
        title: attentionTitle,
        variant: "attention",
        students: attentionStudents
      }
    )
  ] });
};
var StudentRanking_default = StudentRanking;
export {
  RankingCard,
  StudentRanking,
  StudentRanking_default as default
};
//# sourceMappingURL=index.mjs.map