import { j as jsxRuntimeExports } from "../../../../../_virtual/jsx-runtime.js";
import { useMemo } from "react";
import { a as h, c as f } from "../../../../sdk/dist/shared/chunk-AI4GHU7R.js";
import "@sinclair/typebox";
import "../../../../sdk/dist/shared/chunk-SY6DZLTC.js";
import "../../../../sdk/dist/shared/chunk-7A2JNQX3.js";
import "../../../../sdk/dist/shared/chunk-3YVJ2ELD.js";
import "../../../../sdk/dist/shared/chunk-AFVJZPLS.js";
import "../../../../sdk/dist/shared/chunk-A3GF4PYW.js";
import "../../../../sdk/dist/shared/chunk-W33JMRRN.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@19.1.1_react@19.1.1__react@19.1.1/node_modules/react-hot-toast/dist/index.js";
import { ScrollablePanelTab } from "./ScrollablePanelTab.js";
import { tx as D, css as E } from "../../../../style-system/dist/twind.js";
import AttributesSettingsView from "./AttributesSettingsView.js";
import { PanelBlockTitle } from "./PanelBlockTitle.js";
import { usePageAttributes, useSiteAttributes } from "../../../../../use-page-data.js";
import { useAttributesTab, useEditorHelpers, useDebugMode, useAttributesGroup } from "../../../../../use-editor.js";
import { useDatasources } from "../hooks/use-datasource.js";
import { useDatarecords } from "../hooks/use-datarecord.js";
import { Root as m, List as b, Trigger as P } from "../../../../../node_modules/.pnpm/@radix-ui_themes@3.2.1_@types_react-dom@19.1.9_@types_react@19.1.13__@types_react@19.1._832fa1fef691e6e9510ada03948dc85c/node_modules/@radix-ui/themes/dist/esm/components/tabs.js";
function SettingsForm() {
  const currentTab = useAttributesTab();
  const attrSchema = currentTab === "page" ? h : f;
  const editorHelpers = useEditorHelpers();
  const pageAttributes = usePageAttributes();
  const siteAttributes = useSiteAttributes();
  const debugMode = useDebugMode();
  const attributesGroup = useAttributesGroup();
  const filteredAttrSchema = useMemo(() => {
    const filteredSchema = {
      ...attrSchema,
      properties: Object.fromEntries(
        Object.entries(attrSchema.properties).filter(([key, value]) => {
          return !value["ui:hidden"];
        })
      )
    };
    return filteredSchema;
  }, [attrSchema]);
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col h-full", children: [
    /* @__PURE__ */ jsxRuntimeExports.jsx(PanelBlockTitle, { children: "Settings" }),
    /* @__PURE__ */ jsxRuntimeExports.jsxs(
      m,
      {
        value: currentTab,
        onValueChange: (tab) => editorHelpers.setAttributesTab(tab),
        className: "flex-grow flex flex-col h-dvh",
        children: [
          /* @__PURE__ */ jsxRuntimeExports.jsxs(b, { size: "1", className: "sticky top-0 z-50 bg-gray-100", children: [
            /* @__PURE__ */ jsxRuntimeExports.jsx(P, { value: "site", className: D("!flex-1"), children: "Site" }),
            /* @__PURE__ */ jsxRuntimeExports.jsx(P, { value: "page", className: D("!flex-1"), children: "Page" }),
            debugMode && /* @__PURE__ */ jsxRuntimeExports.jsx(P, { value: "debug", className: D("!flex-1"), children: "Debug" })
          ] }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(ScrollablePanelTab, { tab: "page", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
            AttributesSettingsView,
            {
              type: "page",
              attributes: pageAttributes,
              attributesSchema: filteredAttrSchema,
              title: "Page settings",
              group: attributesGroup
            }
          ) }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(ScrollablePanelTab, { tab: "site", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
            AttributesSettingsView,
            {
              type: "site",
              attributes: siteAttributes,
              attributesSchema: filteredAttrSchema,
              title: "Site settings",
              group: attributesGroup
            }
          ) }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(ScrollablePanelTab, { tab: "debug", children: /* @__PURE__ */ jsxRuntimeExports.jsx(DebugTab, {}) })
        ]
      }
    )
  ] });
}
function DebugTab() {
  const codeClassName = D(
    E({
      display: "block",
      fontFamily: "monospace",
      fontSize: "0.7rem",
      lineHeight: "1.3",
      wordWrap: "break-word",
      whiteSpace: "pre-wrap"
    })
  );
  const siteAttributes = useSiteAttributes();
  const pageAttributes = usePageAttributes();
  const datasources = useDatasources();
  const datarecords = useDatarecords();
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col h-[calc(100dvh-70px)] overflow-y-auto scrollbar-thin", children: [
    /* @__PURE__ */ jsxRuntimeExports.jsx(PanelBlockTitle, { children: "Page Attributes" }),
    /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 ", children: /* @__PURE__ */ jsxRuntimeExports.jsx("pre", { className: "p-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx("code", { className: codeClassName, children: JSON.stringify(pageAttributes, null, 2) }) }) }),
    /* @__PURE__ */ jsxRuntimeExports.jsx(PanelBlockTitle, { children: "Site Attributes" }),
    /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 ", children: /* @__PURE__ */ jsxRuntimeExports.jsx("pre", { className: "p-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx("code", { className: codeClassName, children: JSON.stringify(siteAttributes, null, 2) }) }) }),
    /* @__PURE__ */ jsxRuntimeExports.jsxs(PanelBlockTitle, { children: [
      "Datasources (",
      datasources.length,
      ")"
    ] }),
    /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 ", children: /* @__PURE__ */ jsxRuntimeExports.jsx("pre", { className: "p-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx("code", { className: codeClassName, children: JSON.stringify(datasources, null, 2) }) }) }),
    /* @__PURE__ */ jsxRuntimeExports.jsxs(PanelBlockTitle, { children: [
      "Datarecords (",
      datarecords.length,
      ")"
    ] }),
    /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 ", children: /* @__PURE__ */ jsxRuntimeExports.jsx("pre", { className: "p-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx("code", { className: codeClassName, children: JSON.stringify(datarecords, null, 2) }) }) }),
    /* @__PURE__ */ jsxRuntimeExports.jsxs(PanelBlockTitle, { children: [
      "Site queries (",
      siteAttributes.queries?.length ?? 0,
      ")"
    ] }),
    /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 ", children: /* @__PURE__ */ jsxRuntimeExports.jsx("pre", { className: "p-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx("code", { className: codeClassName, children: JSON.stringify(siteAttributes.queries, null, 2) }) }) }),
    /* @__PURE__ */ jsxRuntimeExports.jsxs(PanelBlockTitle, { children: [
      "Page queries (",
      pageAttributes.queries?.length ?? 0,
      ")"
    ] }),
    /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 ", children: /* @__PURE__ */ jsxRuntimeExports.jsx("pre", { className: "p-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx("code", { className: codeClassName, children: JSON.stringify(pageAttributes.queries, null, 2) }) }) })
  ] });
}
export {
  SettingsForm as default
};
//# sourceMappingURL=PanelAttributes.js.map
