import { j as w } from "../../../../../_virtual/jsx-runtime.js";
import { b as B } from "../../../../sdk/dist/shared/chunk-5DZIQGY2.js";
import "../../../../sdk/dist/shared/chunk-VDX2J22H.js";
import "@sinclair/typebox";
import "../../../../sdk/dist/shared/chunk-URRCKLAS.js";
import "../../../../sdk/dist/shared/chunk-2NLDX5FG.js";
import "../../../../sdk/dist/shared/chunk-XED6ARVN.js";
import "../../../../sdk/dist/shared/chunk-3QOAHMV4.js";
import "../../../../sdk/dist/shared/chunk-EVDZ2KND.js";
import "../../../../sdk/dist/shared/chunk-3P36LG6T.js";
import "../../../../sdk/dist/shared/chunk-ARYG4XMX.js";
import "../../../../sdk/dist/shared/chunk-QGFQA7OZ.js";
import "../../../../sdk/dist/shared/chunk-5X5SX5N7.js";
import "../../../../sdk/dist/shared/chunk-6R76KIHZ.js";
import "../../../../sdk/dist/shared/chunk-K5ADUHF4.js";
import "../../../../sdk/dist/shared/chunk-Y3X4F4YJ.js";
import "../../../../sdk/dist/shared/chunk-LT4CW2F7.js";
import "../../../../sdk/dist/shared/chunk-ILIWVWHC.js";
import "../../../../sdk/dist/shared/chunk-SAJY7H6N.js";
import "../../../../sdk/dist/shared/chunk-STDCM2KD.js";
import "../../../../sdk/dist/shared/chunk-TH5SONR6.js";
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 { a as u } from "../../../../sdk/dist/shared/chunk-MPBYGS6W.js";
import { tx as P } from "../../../../style-system/dist/twind.js";
import { get as I, set as $ } from "lodash-es";
import { useCallback as d, useMemo as l } from "react";
import { usePreviewMode as j } from "../../../../../use-editor.js";
import { useDraftHelpers as D, useBrick as F } from "../../../../../use-page-data.js";
import { useBrickManifest as N } from "../../shared/hooks/use-brick-manifest.js";
import { getNavItemsFromManifest as y } from "./json-form/form-utils.js";
import C from "./json-form/FormNavigator.js";
const G = (o) => o === "settings" || !o;
function go({
  brick: o,
  label: c,
  group: g,
  categoryFilter: p = G
}) {
  const { updateBrickProps: n } = D(), r = N(o.type), i = j(), s = F(o.id), a = d(
    (t) => (typeof t.metadata?.["ui:responsive"] > "u" || t.metadata?.["ui:responsive"] === !0 || t.metadata?.["ui:responsive"] === i) && (typeof t["ui:responsive"] > "u" || t["ui:responsive"] === !0 || t["ui:responsive"] === i) && p(t.metadata?.category),
    [i, p]
  ), v = l(() => y(r.props, a), [a, r.props]), b = l(() => {
    const t = B[o.type].props;
    return i === "mobile" ? u({}, t, o.props, o.mobileProps ?? {}) : u({}, t, o.props ?? {});
  }, [o, i]), x = d(
    (t, e) => {
      if (!e) {
        console.warn("propertyChangedPath is missing in onChange");
        return;
      }
      if (r.isGlobalBrick) {
        console.log("Updating global brick, mutating site attributes instead of brick props");
        return;
      }
      const M = I(r.props.properties, e), f = i === "mobile" && M?.metadata?.category !== "content", m = structuredClone(
        f ? s?.mobileProps ?? {} : s?.props ?? {}
      );
      $(m, e, t[e]), console.debug("Props update for brick %s: %o", o.id, m), n(o.id, m, f);
    },
    [o.id, r, i, n, s]
  );
  return /* @__PURE__ */ w.jsx(
    C,
    {
      title: `${r.name} ${c ?? "settings"}`,
      initialGroup: g,
      navItems: v,
      formSchema: r.props,
      className: P("flex-grow"),
      formData: b,
      onChange: x,
      brickId: o.id
    },
    `brick-nav-${o.id}-${i}`
  );
}
export {
  go as default
};
//# sourceMappingURL=BrickSettingsView.js.map
