import { j as w } from "../../../../../_virtual/jsx-runtime.js";
import { b as B } from "../../../../sdk/dist/shared/chunk-PSCN3VVA.js";
import "../../../../sdk/dist/shared/chunk-R6ATC4TC.js";
import "@sinclair/typebox";
import "../../../../sdk/dist/shared/chunk-CFF6Q7O7.js";
import "../../../../sdk/dist/shared/chunk-IKC3FK7L.js";
import "../../../../sdk/dist/shared/chunk-E6XEI7IK.js";
import "../../../../sdk/dist/shared/chunk-SQ5T4AT5.js";
import "../../../../sdk/dist/shared/chunk-G5CJU6RD.js";
import "../../../../sdk/dist/shared/chunk-PSTFJ5IJ.js";
import "../../../../sdk/dist/shared/chunk-NJGXC7D6.js";
import "../../../../sdk/dist/shared/chunk-SXHDQ64Z.js";
import "../../../../sdk/dist/shared/chunk-QX6OGRRT.js";
import "../../../../sdk/dist/shared/chunk-FLOMNC6J.js";
import "../../../../sdk/dist/shared/chunk-PLSV746R.js";
import "../../../../sdk/dist/shared/chunk-WBZW5LVH.js";
import "../../../../sdk/dist/shared/chunk-WYVJE6J5.js";
import "../../../../sdk/dist/shared/chunk-I3VL6SRH.js";
import "../../../../sdk/dist/shared/chunk-B3EATRFX.js";
import "../../../../sdk/dist/shared/chunk-IKHZD2JH.js";
import "../../../../sdk/dist/shared/chunk-PXI7AHWS.js";
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 { a as u } from "../../../../sdk/dist/shared/chunk-OIY3EPHO.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
