import { j as e } from "../../../../../_virtual/jsx-runtime.js";
import { a as h } from "../../../../sdk/dist/shared/chunk-NLEWXPVM.js";
import "@sinclair/typebox";
import "../../../../sdk/dist/shared/chunk-AQPN5SE2.js";
import "../../../../sdk/dist/shared/chunk-DQXDGV67.js";
import "../../../../sdk/dist/shared/chunk-7DMUDZ4H.js";
import "../../../../sdk/dist/shared/chunk-LSPN22SI.js";
import "../../../../sdk/dist/shared/chunk-ETYYRWLK.js";
import "../../../../sdk/dist/shared/chunk-4TH3C76A.js";
import "../../../../sdk/dist/shared/chunk-FKNNTHWX.js";
import "../../../../sdk/dist/shared/chunk-JS4K5JRM.js";
import "../../../../sdk/dist/shared/chunk-WU6Q4WYD.js";
import "../../../../sdk/dist/shared/chunk-QISTDGPP.js";
import "../../../../sdk/dist/shared/chunk-LFQZRGHS.js";
import "../../../../sdk/dist/shared/chunk-SLRU4CT6.js";
import "../../../../sdk/dist/shared/chunk-TTTXV7TJ.js";
import "../../../../sdk/dist/shared/chunk-UHF6IEKV.js";
import "../../../../sdk/dist/shared/chunk-LGP6GWIY.js";
import "../../../../sdk/dist/shared/chunk-X43MB5WD.js";
import "../../../../sdk/dist/shared/chunk-NNI225RG.js";
import "../../../../sdk/dist/shared/chunk-ZQGNYK5I.js";
import "../../../../sdk/dist/shared/chunk-KHFNN4P3.js";
import "../../../../sdk/dist/shared/chunk-BZGNY7LB.js";
import "../../../../sdk/dist/shared/chunk-IIFTGWFZ.js";
import "lodash-es";
import "../../../../sdk/dist/shared/chunk-UU2MSQXY.js";
import "../../../../sdk/dist/shared/chunk-T3LIA4YB.js";
import "../../../../sdk/dist/shared/chunk-YBGPPF7T.js";
import "../../../../sdk/dist/shared/chunk-UMHXXXVP.js";
import "../../../../sdk/dist/shared/chunk-5N6MBJJ4.js";
import { useEditorHelpers as P, useSelectedSectionId as I } from "../../../../../use-editor.js";
import { HiOutlineCog6Tooth as H } from "../../../../../node_modules/.pnpm/react-icons@5.3.0_react@18.3.0-canary-3d9b20132-20240124/node_modules/react-icons/hi2/index.js";
import { useState as T, useCallback as D } 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@18.3.0-canary-3d9b20132-20240124_react@18.3.0-canary-3d_c02c1e17bf76c343fd22d1f22394ecf5/node_modules/react-hot-toast/dist/index.js";
import { TbArrowAutofitHeight as z, TbBorderCorners as B, TbCirclePlus as E, TbDots as O } from "../../../../../node_modules/.pnpm/react-icons@5.3.0_react@18.3.0-canary-3d9b20132-20240124/node_modules/react-icons/tb/index.js";
import { tx as i } from "../../../../style-system/dist/twind.js";
import { useDraftHelpers as R, useSections as $ } from "../../../../../use-page-data.js";
import { Tooltip as u } from "../../../../../node_modules/.pnpm/@radix-ui_themes@3.1.4_@types_react-dom@18.3.6_@types_react@18.3.3__@types_react@18.3.3_46b1dabc193c5ff5696ee783983c694e/node_modules/@radix-ui/themes/dist/esm/components/tooltip.js";
import { Root as U, Trigger as _, Content as A, Group as f, Label as F, Item as l, Separator as j } from "../../../../../node_modules/.pnpm/@radix-ui_themes@3.1.4_@types_react-dom@18.3.6_@types_react@18.3.3__@types_react@18.3.3_46b1dabc193c5ff5696ee783983c694e/node_modules/@radix-ui/themes/dist/esm/components/dropdown-menu.js";
function Ie({ section: t }) {
  const [b, g] = T(!1), s = R(), { setSelectedSectionId: a, setPanel: c, hidePanel: y, setSelectedBrickId: w } = P(), d = $(), p = I(), v = d.reduce((o, r) => Math.max(o, r.order), -1), S = d.reduce((o, r) => Math.min(o, r.order), 1 / 0), m = t.order === v, C = t.order === S, N = typeof t.props.variant < "u", x = t.props.variant !== "navbar" && t.props.variant !== "footer", k = D(
    (o) => {
      o.stopPropagation(), p !== t.id ? (a(t.id), c("inspector")) : (y(), a());
    },
    [p]
  ), n = i(
    "select-none hover:opacity-90",
    "text-base px-1.5 h-7  ",
    "text-black/80 hover:bg-upstart-300/20 font-bold flex items-center gap-1",
    "active:(outline-none ring-0) focus:(outline-none ring-0)"
  );
  return /* @__PURE__ */ e.jsxs(
    "div",
    {
      role: "toolbar",
      className: i(
        "font-sans",
        // bottom-[3px]
        m ? "bottom-3" : "bottom-0",
        b ? "opacity-100" : "opacity-0",
        `section-options-buttons translate-y-1/2 shadow
            absolute z-[99999] left-1/2 -translate-x-1/2 min-w-fit border border-gray-200`,
        "gap-0 rounded-md [&>*:first-child]:rounded-l-md [&>*:last-child]:rounded-r-md ",
        "bg-white/90 backdrop-blur-md transition-opacity duration-500 group-hover/section:opacity-100 flex"
      ),
      children: [
        /* @__PURE__ */ e.jsxs(
          "div",
          {
            className: i(n, "inline-flex flex-nowrap items-center gap-1 !px-2.5 pointer-events-none"),
            "data-trigger-section-inspector": !0,
            children: [
              /* @__PURE__ */ e.jsx("div", { className: "text-xs font-light text-nowrap", children: "Section" }),
              /* @__PURE__ */ e.jsx("div", { className: "text-xs font-semibold text-nowrap max-w-[120px] truncate", children: t.label ?? "Unnamed" })
            ]
          }
        ),
        /* @__PURE__ */ e.jsx(
          "button",
          {
            type: "button",
            id: `${t.id}-resize-handle`,
            className: i(n),
            onClick: k,
            children: /* @__PURE__ */ e.jsx(H, { className: "w-5 h-5" })
          }
        ),
        x && /* @__PURE__ */ e.jsx(
          "button",
          {
            type: "button",
            id: `${t.id}-resize-handle`,
            className: i("!cursor-ns-resize", n, "section-resizable-handle"),
            children: /* @__PURE__ */ e.jsx(z, { className: "w-5 h-5" })
          }
        ),
        x && t.props.minHeight !== "full" && /* @__PURE__ */ e.jsx(u, { content: "Fill entire screen height", delayDuration: 400, children: /* @__PURE__ */ e.jsx(
          "button",
          {
            type: "button",
            onClick: () => {
              s.updateSectionProps(t.id, {
                minHeight: "full"
              });
              const o = document.getElementById(t.id);
              o && (o.style.removeProperty("minHeight"), o.style.removeProperty("maxHeight"), o.style.removeProperty("height")), setTimeout(() => {
                window.scrollTo(0, document.body.scrollHeight), document.getElementById(t.id)?.scrollIntoView({ behavior: "smooth" });
              }, 100);
            },
            className: i(n, "cursor-pointer"),
            children: /* @__PURE__ */ e.jsx(B, { className: "w-5 h-5" })
          }
        ) }),
        /* @__PURE__ */ e.jsx(u, { content: "Create new section below", delayDuration: 400, children: /* @__PURE__ */ e.jsx(
          "button",
          {
            type: "button",
            onClick: (o) => {
              o.stopPropagation();
              const r = `s_${h()}`;
              s.createEmptySection(r, t.id), a(r), c("inspector");
            },
            className: i(n, "cursor-pointer"),
            children: /* @__PURE__ */ e.jsx(E, { className: "w-5 h-5" })
          }
        ) }),
        /* @__PURE__ */ e.jsxs(U, { modal: !1, onOpenChange: g, children: [
          /* @__PURE__ */ e.jsx(
            _,
            {
              onClick: (o) => {
                o.stopPropagation();
              },
              children: /* @__PURE__ */ e.jsx("button", { type: "button", className: i(n), children: /* @__PURE__ */ e.jsx(O, { className: "w-5 h-5" }) })
            }
          ),
          /* @__PURE__ */ e.jsxs(A, { sideOffset: 5, size: "2", side: "bottom", align: "end", children: [
            /* @__PURE__ */ e.jsxs(f, { children: [
              /* @__PURE__ */ e.jsxs(F, { children: [
                t.label ?? "Unnamed",
                " (section)"
              ] }),
              !C && /* @__PURE__ */ e.jsx(l, { onClick: () => s.moveSectionUp(t.id), children: /* @__PURE__ */ e.jsx("div", { className: "flex items-center justify-start gap-2", children: /* @__PURE__ */ e.jsx("span", { children: "Reorder up" }) }) }),
              !m && /* @__PURE__ */ e.jsx(l, { onClick: () => s.moveSectionDown(t.id), children: /* @__PURE__ */ e.jsx("div", { className: "flex items-center justify-start gap-2", children: /* @__PURE__ */ e.jsx("span", { children: "Reorder down" }) }) })
            ] }),
            /* @__PURE__ */ e.jsx(j, {}),
            /* @__PURE__ */ e.jsxs(f, { children: [
              /* @__PURE__ */ e.jsx(
                l,
                {
                  onClick: (o) => {
                    o.stopPropagation();
                    const r = `s_${h()}`;
                    s.createEmptySection(r, t.id), a(r), c("inspector");
                  },
                  children: /* @__PURE__ */ e.jsx("div", { className: "flex items-center justify-start gap-2", children: /* @__PURE__ */ e.jsx("span", { children: "Create new section below" }) })
                }
              ),
              N === !1 && /* @__PURE__ */ e.jsx(
                l,
                {
                  onClick: (o) => {
                    o.stopPropagation(), s.duplicateSection(t.id);
                  },
                  children: /* @__PURE__ */ e.jsx("div", { className: "flex items-center justify-start gap-2", children: /* @__PURE__ */ e.jsx("span", { children: "Duplicate" }) })
                }
              )
            ] }),
            /* @__PURE__ */ e.jsx(j, {}),
            /* @__PURE__ */ e.jsx(
              l,
              {
                color: "red",
                onClick: (o) => {
                  o.stopPropagation(), s.deleteSection(t.id), a(), w(), c();
                },
                children: /* @__PURE__ */ e.jsx("div", { className: "flex items-center justify-start gap-2.5", children: /* @__PURE__ */ e.jsx("span", { children: "Delete section" }) })
              }
            )
          ] })
        ] })
      ]
    }
  );
}
export {
  Ie as default
};
//# sourceMappingURL=EditableSectionButtons.js.map
