import { j as jsxRuntimeExports } from "../../../../../_virtual/jsx-runtime.js";
import { a as S$1 } from "../../../../sdk/dist/shared/chunk-GOMXZC4B.js";
import "@sinclair/typebox";
import "../../../../sdk/dist/shared/chunk-PSCN3VVA.js";
import "../../../../sdk/dist/shared/chunk-R6ATC4TC.js";
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 "lodash-es";
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 { useDebugMode, useEditorHelpers } from "../../../../../use-editor.js";
import { forwardRef } from "react";
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 { useSections, useDraftHelpers } from "../../../../../use-page-data.js";
import { Root as h, Trigger as S, Content as v, Group as N, Label as y, Item as R, Separator as W } 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/context-menu.js";
import { Portal as r } 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/portal.js";
const EditableSectionContextMenu = forwardRef(
  ({ section, children }, ref) => {
    const debugMode = useDebugMode();
    const sections = useSections();
    const draftHelpers = useDraftHelpers();
    const { setSelectedSectionId, setPanel, setSelectedBrickId } = useEditorHelpers();
    const maxOrder = sections.reduce((max, sec) => Math.max(max, sec.order), -1);
    const minOrder = sections.reduce((min, sec) => Math.min(min, sec.order), Infinity);
    const isLastSection = section.order === maxOrder;
    const isFirstSection = section.order === minOrder;
    return /* @__PURE__ */ jsxRuntimeExports.jsxs(
      h,
      {
        modal: false,
        onOpenChange: (menuOpen) => {
        },
        children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(S, { disabled: debugMode, ref, children }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(r, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(v, { className: "nodrag", size: "2", children: [
            /* @__PURE__ */ jsxRuntimeExports.jsxs(N, { children: [
              /* @__PURE__ */ jsxRuntimeExports.jsxs(y, { children: [
                section.label ?? "Unnamed",
                " (section)"
              ] }),
              /* @__PURE__ */ jsxRuntimeExports.jsx(
                R,
                {
                  onClick: () => {
                    setSelectedSectionId(section.id);
                    setPanel("inspector");
                  },
                  children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-start gap-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "Settings" }) })
                }
              ),
              /* @__PURE__ */ jsxRuntimeExports.jsx(W, {}),
              !isFirstSection && /* @__PURE__ */ jsxRuntimeExports.jsx(R, { onClick: () => draftHelpers.moveSectionUp(section.id), children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-start gap-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "Reorder up" }) }) }),
              !isLastSection && /* @__PURE__ */ jsxRuntimeExports.jsx(R, { onClick: () => draftHelpers.moveSectionDown(section.id), children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-start gap-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "Reorder down" }) }) })
            ] }),
            /* @__PURE__ */ jsxRuntimeExports.jsx(W, {}),
            /* @__PURE__ */ jsxRuntimeExports.jsxs(N, { children: [
              /* @__PURE__ */ jsxRuntimeExports.jsx(
                R,
                {
                  onClick: (e) => {
                    e.stopPropagation();
                    const newId = `s_${S$1()}`;
                    draftHelpers.createEmptySection(newId, section.id);
                    setSelectedSectionId(newId);
                    setPanel("inspector");
                  },
                  children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-start gap-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "Create new section below" }) })
                }
              ),
              /* @__PURE__ */ jsxRuntimeExports.jsx(
                R,
                {
                  onClick: (e) => {
                    e.stopPropagation();
                    draftHelpers.duplicateSection(section.id);
                  },
                  children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-start gap-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "Duplicate" }) })
                }
              )
            ] }),
            /* @__PURE__ */ jsxRuntimeExports.jsx(W, {}),
            /* @__PURE__ */ jsxRuntimeExports.jsx(
              R,
              {
                color: "red",
                onClick: (e) => {
                  e.stopPropagation();
                  draftHelpers.deleteSection(section.id);
                  setSelectedSectionId();
                  setSelectedBrickId();
                  setPanel();
                },
                children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-start gap-2.5", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "Delete section" }) })
              }
            )
          ] }) })
        ]
      }
    );
  }
);
export {
  EditableSectionContextMenu as default
};
//# sourceMappingURL=EditableSectionContextMenu.js.map
