import { j as t } from "../../../../../../_virtual/jsx-runtime.js";
import { createContext as p, useContext as c } from "react";
import "../../../../../../node_modules/.pnpm/@formkit_auto-animate@0.8.2/node_modules/@formkit/auto-animate/index.js";
import "../../../../../../node_modules/.pnpm/react-hot-toast@2.5.2_react-dom@18.3.0-canary-3d9b20132-20240124_react@18.3.0-canary-3d_c02c1e17bf76c343fd22d1f22394ecf5/node_modules/react-hot-toast/dist/index.js";
import { tx as N } from "../../../../../style-system/dist/twind.js";
import { VscSymbolArray as h, VscSymbolBoolean as f, VscSymbolString as y } from "../../../../../../node_modules/.pnpm/react-icons@5.3.0_react@18.3.0-canary-3d9b20132-20240124/node_modules/react-icons/vsc/index.js";
import { CiCalendarDate as m } from "../../../../../../node_modules/.pnpm/react-icons@5.3.0_react@18.3.0-canary-3d9b20132-20240124/node_modules/react-icons/ci/index.js";
import { HiMiniHashtag as b, HiMiniAtSymbol as S } from "../../../../../../node_modules/.pnpm/react-icons@5.3.0_react@18.3.0-canary-3d9b20132-20240124/node_modules/react-icons/hi2/index.js";
import { GoRelFilePath as g, GoNumber as v } from "../../../../../../node_modules/.pnpm/react-icons@5.3.0_react@18.3.0-canary-3d9b20132-20240124/node_modules/react-icons/go/index.js";
import { Text as n } from "../../../../../../node_modules/.pnpm/@radix-ui_themes@3.1.4_@types_react-dom@18.3.6_@types_react@18.3.3__@types_react@18.3.3_46b1dabc193c5ff5696ee783983c694e/node_modules/@radix-ui/themes/dist/esm/components/text.js";
const i = p(0), u = p({
  onFieldSelect: () => {
  }
}), x = {
  string: /* @__PURE__ */ t.jsx(y, { className: "text-upstart-600" }),
  number: /* @__PURE__ */ t.jsx(v, { className: "text-upstart-600" }),
  boolean: /* @__PURE__ */ t.jsx(f, { className: "text-upstart-600" }),
  array: /* @__PURE__ */ t.jsx(h, { className: "text-upstart-600" }),
  "date-time": /* @__PURE__ */ t.jsx(m, { className: "text-upstart-600" }),
  date: /* @__PURE__ */ t.jsx(m, { className: "text-upstart-600" }),
  email: /* @__PURE__ */ t.jsx(S, { className: "text-upstart-600" }),
  slug: /* @__PURE__ */ t.jsx(g, { className: "text-upstart-600" }),
  nanoid: /* @__PURE__ */ t.jsx(b, { className: "text-upstart-600" })
};
function j({ schema: e, prefix: s }) {
  const a = c(i), { onFieldSelect: l } = c(u);
  return /* @__PURE__ */ t.jsx(i.Provider, { value: a + 1, children: /* @__PURE__ */ t.jsx("ul", { id: `${e.name}_level-${a}`, className: "mb-1", children: e.type === "object" ? /* @__PURE__ */ t.jsx(C, { schema: e, prefix: s }) : /* @__PURE__ */ t.jsxs("li", { className: "flex items-center gap-0.5 w-full shrink-0 flex-nowrap", children: [
    /* @__PURE__ */ t.jsx(n, { size: "3", children: x[e.format] || x[e.type] || /* @__PURE__ */ t.jsx("span", { className: "text-gray-500", children: "?" }) }),
    /* @__PURE__ */ t.jsx(
      n,
      {
        size: "2",
        onClick: () => l(`${s}.${e.name}`),
        className: "hover:bg-upstart-50 cursor-pointer px-1 py-0.5 rounded text-nowrap",
        children: e.title
      }
    ),
    /* @__PURE__ */ t.jsxs(n, { color: "gray", size: "1", className: "text-nowrap", children: [
      "— ",
      s,
      ".",
      e.name
    ] })
  ] }) }) });
}
function C({
  schema: { name: e, required: s, properties: a },
  prefix: l
}) {
  return a ? /* @__PURE__ */ t.jsxs("ul", { className: "list-disc", children: [
    /* @__PURE__ */ t.jsx("li", { className: N({ hidden: !e }), children: /* @__PURE__ */ t.jsx("span", { children: e }) }),
    Object.entries(a).sort(([r], [o]) => r.localeCompare(o)).map(([r, o], d) => /* @__PURE__ */ t.jsx(
      j,
      {
        schema: { ...o, name: r, optional: s && !s.includes(r) },
        prefix: l
      },
      `${r}-${d}`
    ))
  ] }) : null;
}
function A({
  schema: e,
  prefix: s,
  onFieldSelect: a
}) {
  return /* @__PURE__ */ t.jsx(u.Provider, { value: { onFieldSelect: a }, children: /* @__PURE__ */ t.jsx(i.Provider, { value: 0, children: /* @__PURE__ */ t.jsx(j, { schema: e.items, prefix: s }) }) });
}
export {
  A as JSONSchemaView
};
//# sourceMappingURL=SchemaView.js.map
