"use client";
import * as React from 'react';
import { clsx } from 'clsx';
import { twMerge } from 'tailwind-merge';
import { jsx } from 'react/jsx-runtime';

function cn(...inputs) {
  return twMerge(clsx(inputs));
}
var RATINGS = ["again", "hard", "good", "easy"];
var DEFAULT_LABELS = {
  again: "Again",
  hard: "Hard",
  good: "Good",
  easy: "Easy"
};
var RATING_HINT = {
  again: "Couldn't recall \u2014 show this card again soon.",
  hard: "Recalled with effort \u2014 review sooner than usual.",
  good: "Recalled correctly \u2014 keep the standard interval.",
  easy: "Recalled instantly \u2014 push the next review further out."
};
var RATING_CLASSES = {
  again: "border-destructive/40 bg-destructive/10 text-destructive hover:bg-destructive/15 focus-visible:ring-destructive/40",
  hard: "border-secondary bg-secondary text-secondary-foreground hover:bg-secondary/80",
  good: "border-primary/40 bg-primary/10 text-foreground hover:bg-primary/15 focus-visible:ring-primary/40",
  easy: "border-accent bg-accent/10 text-accent-foreground hover:bg-accent/20 focus-visible:ring-accent/40"
};
function SpacedRepetition({
  cardId,
  onRate,
  labels,
  className,
  ...rest
}) {
  const onRateRef = React.useRef(onRate);
  onRateRef.current = onRate;
  return /* @__PURE__ */ jsx(
    "div",
    {
      ...rest,
      "data-hex-spaced-repetition": true,
      "data-card-id": cardId,
      role: "group",
      "aria-label": "Confidence rating",
      className: cn("inline-flex flex-wrap items-center gap-2", className),
      children: RATINGS.map((rating) => {
        const label = labels?.[rating] ?? DEFAULT_LABELS[rating];
        return /* @__PURE__ */ jsx(
          "button",
          {
            type: "button",
            "data-hex-spaced-repetition-button": true,
            "data-rating": rating,
            "aria-label": `${label}: ${RATING_HINT[rating]}`,
            onClick: () => onRateRef.current(rating, cardId),
            className: cn(
              "inline-flex h-9 items-center justify-center rounded-md border px-3 text-sm font-medium transition-all duration-[var(--duration-normal,200ms)] ease-out active:scale-[0.98]",
              "focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",
              RATING_CLASSES[rating]
            ),
            children: label
          },
          rating
        );
      })
    }
  );
}

export { SpacedRepetition };
//# sourceMappingURL=spaced-repetition.js.map
//# sourceMappingURL=spaced-repetition.js.map