import { j as e } from "../../../../../_virtual/jsx-runtime.js";
import { useMemo as g } from "react";
import { a as b, c as N } from "../../../../sdk/dist/shared/chunk-PW5HRVMD.js";
import "@sinclair/typebox";
import "../../../../sdk/dist/shared/chunk-UDQWYGSO.js";
import "../../../../sdk/dist/shared/chunk-AZHH3XJJ.js";
import "../../../../sdk/dist/shared/chunk-6PGAWO4H.js";
import "../../../../sdk/dist/shared/chunk-F4JNKU7J.js";
import "../../../../sdk/dist/shared/chunk-7UBMXMNJ.js";
import "../../../../sdk/dist/shared/chunk-JRCVYDCD.js";
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 { ScrollablePanelTab as o } from "./ScrollablePanelTab.js";
import { tx as c, css as S } from "../../../../style-system/dist/twind.js";
import p from "./AttributesSettingsView.js";
import { PanelBlockTitle as r } from "./PanelBlockTitle.js";
import { usePageAttributes as x, useSiteAttributes as h } from "../../../../../use-page-data.js";
import { useAttributesTab as v, useEditorHelpers as y, useDebugMode as A, useAttributesGroup as D } from "../../../../../use-editor.js";
import { useDatasources as O } from "../hooks/use-datasource.js";
import { useDatarecords as P } from "../hooks/use-datarecord.js";
import { Root as w, List as T, Trigger 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/tabs.js";
function $() {
  const s = v(), t = s === "page" ? b : N, i = y(), l = x(), a = h(), f = A(), d = D(), m = g(() => ({
    ...t,
    properties: Object.fromEntries(
      Object.entries(t.properties).filter(([J, j]) => !j["ui:hidden"])
    )
  }), [t]);
  return /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col h-full", children: [
    /* @__PURE__ */ e.jsx(r, { children: "Settings" }),
    /* @__PURE__ */ e.jsxs(
      w,
      {
        value: s,
        onValueChange: (u) => i.setAttributesTab(u),
        className: "flex-grow flex flex-col h-dvh",
        children: [
          /* @__PURE__ */ e.jsxs(T, { size: "1", className: "sticky top-0 z-50 bg-gray-100", children: [
            /* @__PURE__ */ e.jsx(n, { value: "site", className: c("!flex-1"), children: "Site" }),
            /* @__PURE__ */ e.jsx(n, { value: "page", className: c("!flex-1"), children: "Page" }),
            f && /* @__PURE__ */ e.jsx(n, { value: "debug", className: c("!flex-1"), children: "Debug" })
          ] }),
          /* @__PURE__ */ e.jsx(o, { tab: "page", children: /* @__PURE__ */ e.jsx(
            p,
            {
              type: "page",
              attributes: l,
              attributesSchema: m,
              title: "Page settings",
              group: d
            }
          ) }),
          /* @__PURE__ */ e.jsx(o, { tab: "site", children: /* @__PURE__ */ e.jsx(
            p,
            {
              type: "site",
              attributes: a,
              attributesSchema: m,
              title: "Site settings",
              group: d
            }
          ) }),
          /* @__PURE__ */ e.jsx(o, { tab: "debug", children: /* @__PURE__ */ e.jsx(q, {}) })
        ]
      }
    )
  ] });
}
function q() {
  const s = c(
    S({
      display: "block",
      fontFamily: "monospace",
      fontSize: "0.7rem",
      lineHeight: "1.3",
      wordWrap: "break-word",
      whiteSpace: "pre-wrap"
    })
  ), t = h(), i = x(), l = O(), a = P();
  return /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col h-[calc(100dvh-70px)] overflow-y-auto scrollbar-thin", children: [
    /* @__PURE__ */ e.jsx(r, { children: "Page Attributes" }),
    /* @__PURE__ */ e.jsx("div", { className: "flex-1 ", children: /* @__PURE__ */ e.jsx("pre", { className: "p-1", children: /* @__PURE__ */ e.jsx("code", { className: s, children: JSON.stringify(i, null, 2) }) }) }),
    /* @__PURE__ */ e.jsx(r, { children: "Site Attributes" }),
    /* @__PURE__ */ e.jsx("div", { className: "flex-1 ", children: /* @__PURE__ */ e.jsx("pre", { className: "p-1", children: /* @__PURE__ */ e.jsx("code", { className: s, children: JSON.stringify(t, null, 2) }) }) }),
    /* @__PURE__ */ e.jsxs(r, { children: [
      "Datasources (",
      l.length,
      ")"
    ] }),
    /* @__PURE__ */ e.jsx("div", { className: "flex-1 ", children: /* @__PURE__ */ e.jsx("pre", { className: "p-1", children: /* @__PURE__ */ e.jsx("code", { className: s, children: JSON.stringify(l, null, 2) }) }) }),
    /* @__PURE__ */ e.jsxs(r, { children: [
      "Datarecords (",
      a.length,
      ")"
    ] }),
    /* @__PURE__ */ e.jsx("div", { className: "flex-1 ", children: /* @__PURE__ */ e.jsx("pre", { className: "p-1", children: /* @__PURE__ */ e.jsx("code", { className: s, children: JSON.stringify(a, null, 2) }) }) }),
    /* @__PURE__ */ e.jsxs(r, { children: [
      "Site queries (",
      t.queries?.length ?? 0,
      ")"
    ] }),
    /* @__PURE__ */ e.jsx("div", { className: "flex-1 ", children: /* @__PURE__ */ e.jsx("pre", { className: "p-1", children: /* @__PURE__ */ e.jsx("code", { className: s, children: JSON.stringify(t.queries, null, 2) }) }) }),
    /* @__PURE__ */ e.jsxs(r, { children: [
      "Page queries (",
      i.queries?.length ?? 0,
      ")"
    ] }),
    /* @__PURE__ */ e.jsx("div", { className: "flex-1 ", children: /* @__PURE__ */ e.jsx("pre", { className: "p-1", children: /* @__PURE__ */ e.jsx("code", { className: s, children: JSON.stringify(i.queries, null, 2) }) }) })
  ] });
}
export {
  $ as default
};
//# sourceMappingURL=PanelAttributes.js.map
