"use client";
import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
import { clsx } from 'clsx';
import { twMerge } from 'tailwind-merge';
import { jsxs, jsx } from 'react/jsx-runtime';

function cn(...inputs) {
  return twMerge(clsx(inputs));
}
function Reasoning({
  children,
  defaultOpen = false,
  durationMs,
  label,
  className
}) {
  const headerLabel = label ?? (typeof durationMs === "number" ? formatThoughtFor(durationMs) : "Thinking");
  return /* @__PURE__ */ jsxs(
    CollapsiblePrimitive.Root,
    {
      defaultOpen,
      className: cn("overflow-hidden rounded-md border-l-2 border-foreground/15 bg-muted/20", className),
      children: [
        /* @__PURE__ */ jsxs(
          CollapsiblePrimitive.Trigger,
          {
            className: cn(
              "group flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-muted-foreground",
              "transition-all duration-[var(--duration-normal,200ms)] ease-out",
              "hover:text-foreground",
              "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"
            ),
            children: [
              /* @__PURE__ */ jsx(SparkleGlyph, {}),
              /* @__PURE__ */ jsx("span", { className: "font-medium italic", children: headerLabel }),
              /* @__PURE__ */ jsx(Chevron, {})
            ]
          }
        ),
        /* @__PURE__ */ jsx(CollapsiblePrimitive.Content, { className: "overflow-hidden border-t border-foreground/[0.06] px-3 py-2 text-sm text-muted-foreground", children })
      ]
    }
  );
}
function formatThoughtFor(ms) {
  if (ms < 1e3) return `Thought for ${ms}ms`;
  const seconds = ms / 1e3;
  const formatted = seconds >= 10 ? Math.round(seconds).toString() : seconds.toFixed(1);
  return `Thought for ${formatted}s`;
}
function SparkleGlyph() {
  return /* @__PURE__ */ jsx(
    "svg",
    {
      "aria-hidden": true,
      viewBox: "0 0 16 16",
      width: "12",
      height: "12",
      fill: "none",
      stroke: "currentColor",
      strokeWidth: "1.5",
      strokeLinecap: "round",
      strokeLinejoin: "round",
      className: "shrink-0",
      children: /* @__PURE__ */ jsx("path", { d: "M8 1.5l1.5 4 4 1.5-4 1.5L8 12.5 6.5 8.5l-4-1.5 4-1.5L8 1.5z" })
    }
  );
}
function Chevron() {
  return /* @__PURE__ */ jsx(
    "svg",
    {
      "aria-hidden": true,
      viewBox: "0 0 16 16",
      width: "12",
      height: "12",
      fill: "none",
      stroke: "currentColor",
      strokeWidth: "1.5",
      strokeLinecap: "round",
      strokeLinejoin: "round",
      className: "ml-auto shrink-0 transition-transform duration-200 group-data-[state=open]:rotate-180",
      children: /* @__PURE__ */ jsx("path", { d: "M4 6l4 4 4-4" })
    }
  );
}

export { Reasoning };
//# sourceMappingURL=reasoning.js.map
//# sourceMappingURL=reasoning.js.map