import { j as b } from "../../../../../_virtual/jsx-runtime.js";
import A from "./json-form/FormNavigator.js";
import { b as x } from "../../../../sdk/dist/shared/chunk-QGYZ7CG5.js";
import "../../../../sdk/dist/shared/chunk-AFVJZPLS.js";
import "@sinclair/typebox";
import "../../../../sdk/dist/shared/chunk-A3GF4PYW.js";
import "../../../../sdk/dist/shared/chunk-W33JMRRN.js";
import { useMemo as M, useCallback as N } from "react";
import { merge as P, set as f } from "lodash-es";
import { getNavItemsFromManifest as j } from "./json-form/form-utils.js";
import { usePreviewMode as w, useEditorHelpers as I } from "../../../../../use-editor.js";
import { useDraft as g } from "../../../../../use-page-data.js";
function J({
  attributes: r,
  attributesSchema: o,
  title: l,
  group: m,
  type: n
}) {
  const u = w(), a = I(), s = g(), c = j(o, (e) => (typeof e.metadata?.["ui:responsive"] > "u" || e.metadata?.["ui:responsive"] === !0 || e.metadata?.["ui:responsive"] === u) && (typeof e["ui:responsive"] > "u" || e["ui:responsive"] === !0 || e["ui:responsive"] === u)), v = M(() => {
    const e = x(o);
    return P({}, e, r ?? {});
  }, [r, o]), d = N(
    (e, t) => {
      if (console.log("attributes -> propertyChanged", t), n === "page")
        if (e[t] === null)
          s.deletePageAttribute(t);
        else {
          const i = {};
          f(i, t, e[t]), s.updatePageAttributes(i);
        }
      else if (e[t] === null)
        s.deleteSiteAttribute(t);
      else {
        const i = {};
        f(i, t, e[t]), s.updateSiteAttributes(i);
      }
    },
    [r]
  ), p = (e) => {
    e || a.setAttributesGroup(void 0);
  };
  return /* @__PURE__ */ b.jsx(
    A,
    {
      onNavigate: p,
      brickId: "none",
      title: l,
      initialGroup: m,
      navItems: c,
      formSchema: o,
      className: "h-full",
      formData: v,
      onChange: d
    },
    `${n}-attributes-form-${m || "all"}`
  );
}
export {
  J as default
};
//# sourceMappingURL=AttributesSettingsView.js.map
