import { clsx } from 'clsx';
import { twMerge } from 'tailwind-merge';
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';

// src/lib/utils.ts
function cn(...inputs) {
  return twMerge(clsx(inputs));
}
function Citation({ title, url, page, index, className, children }) {
  const baseClasses = cn(
    "inline-flex items-center gap-1.5 rounded-md border border-foreground/15 bg-card px-2 py-0.5 text-xs",
    "transition-all duration-[var(--duration-normal,200ms)] ease-out",
    className
  );
  const body = /* @__PURE__ */ jsxs(Fragment, { children: [
    typeof index === "number" ? /* @__PURE__ */ jsxs("span", { className: "font-mono text-[10px] font-semibold text-muted-foreground", children: [
      "[",
      index,
      "]"
    ] }) : /* @__PURE__ */ jsx(DocGlyph, {}),
    /* @__PURE__ */ jsx("span", { className: "truncate text-foreground", children: title }),
    typeof page === "number" ? /* @__PURE__ */ jsxs("span", { className: "text-muted-foreground", children: [
      "p.",
      page
    ] }) : null,
    children
  ] });
  if (url) {
    return /* @__PURE__ */ jsx(
      "a",
      {
        href: url,
        target: "_blank",
        rel: "noreferrer noopener",
        className: cn(
          baseClasses,
          "hover:border-foreground/30 hover:bg-secondary/40 hover:shadow-sm",
          "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"
        ),
        children: body
      }
    );
  }
  return /* @__PURE__ */ jsx("span", { className: baseClasses, children: body });
}
function DocGlyph() {
  return /* @__PURE__ */ jsxs(
    "svg",
    {
      "aria-hidden": true,
      viewBox: "0 0 16 16",
      width: "11",
      height: "11",
      fill: "none",
      stroke: "currentColor",
      strokeWidth: "1.5",
      strokeLinecap: "round",
      strokeLinejoin: "round",
      className: "shrink-0 text-muted-foreground",
      children: [
        /* @__PURE__ */ jsx("path", { d: "M9 1.5H4.5A1.5 1.5 0 0 0 3 3v10a1.5 1.5 0 0 0 1.5 1.5h7A1.5 1.5 0 0 0 13 13V5.5L9 1.5z" }),
        /* @__PURE__ */ jsx("path", { d: "M9 1.5V5.5h4" })
      ]
    }
  );
}

export { Citation };
//# sourceMappingURL=citation.js.map
//# sourceMappingURL=citation.js.map