import { jsx as l } from "react/jsx-runtime";
import { c } from "../../../index-UgeK3A8s.js";
import { memo as m, useMemo as j } from "react";
import { cn as p } from "../../../lib/utils.js";
const x = /("(?:[^"\\]|\\.)*")\s*(?=:)|("(?:[^"\\]|\\.)*")|\b(true)\b|\b(false)\b|\b(null)\b|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g;
function v(s) {
  const e = [];
  let a = 0;
  for (const o of s.matchAll(x)) {
    const t = o.index;
    t > a && e.push(s.slice(a, t));
    const [n, r, u, h, f, d, i] = o;
    r ? e.push({ type: "key", text: r, offset: t }) : u ? e.push({ type: "str", text: u, offset: t }) : h ? e.push({ type: "true", text: h, offset: t }) : f ? e.push({ type: "false", text: f, offset: t }) : d ? e.push({ type: "null", text: d, offset: t }) : i && e.push({ type: "num", text: i, offset: t }), a = t + n.length;
  }
  return a < s.length && e.push(s.slice(a)), e;
}
const g = c(
  "w-full overflow-x-auto text-[13px] text-foreground/90",
  {
    variants: {
      theme: {
        default: [
          "[--jh-key:#8a6c14] dark:[--jh-key:#b8a965]",
          "[--jh-str:#a8453a] dark:[--jh-str:#c98a7d]",
          "[--jh-num:#0f766e] dark:[--jh-num:#4c9a91]",
          "[--jh-true:#2f6e4e] dark:[--jh-true:#4d9375]",
          "[--jh-false:#a8453a] dark:[--jh-false:#c98a7d]",
          "[--jh-null:#71717a] dark:[--jh-null:#a1a1aa]"
        ],
        branded: [
          "[--jh-key:var(--chart-2)]",
          "[--jh-str:var(--chart-1)]",
          "[--jh-num:var(--warning)]",
          "[--jh-true:var(--success)]",
          "[--jh-false:var(--destructive)]",
          "[--jh-null:var(--color-muted-foreground)]"
        ],
        monochrome: [
          "[--jh-key:var(--color-foreground)]",
          "[--jh-str:var(--color-muted-foreground)]",
          "[--jh-num:var(--color-muted-foreground)]",
          "[--jh-true:var(--color-muted-foreground)]",
          "[--jh-false:var(--color-muted-foreground)]",
          "[--jh-null:var(--color-muted-foreground)]"
        ]
      }
    },
    defaultVariants: { theme: "default" }
  }
), k = {
  key: "text-[var(--jh-key)]",
  str: "text-[var(--jh-str)]",
  num: "text-[var(--jh-num)]",
  true: "text-[var(--jh-true)]",
  false: "text-[var(--jh-false)]",
  null: "text-[var(--jh-null)]"
}, E = m(function({
  code: e,
  theme: a,
  className: o,
  ...t
}) {
  const n = j(() => v(e), [e]);
  return /* @__PURE__ */ l(
    "div",
    {
      className: p(g({ theme: a }), o),
      "data-slot": "json-highlight",
      ...t,
      children: /* @__PURE__ */ l("pre", { className: "wrap-break-word max-w-full whitespace-pre-wrap p-3 font-mono leading-relaxed", children: /* @__PURE__ */ l("code", { children: n.map((r) => typeof r == "string" ? r : /* @__PURE__ */ l("span", { className: k[r.type], children: r.text }, r.offset)) }) })
    }
  );
});
export {
  E as JsonHighlight,
  g as jsonHighlightVariants
};
