import i from "../../../../../_virtual/interact.min.js";
import { useRef as l, useEffect as c } from "react";
import { a as d } from "../../../../sdk/dist/shared/chunk-WXKRIUTA.js";
import { useDraftHelpers as m } from "../../../../../use-page-data.js";
function y(o) {
  const r = l(null), a = m();
  c(() => {
    const e = document.getElementById(o.id);
    return d(e, "Section element not found"), r.current = i(`#${o.id}`), r.current.resizable({
      edges: {
        top: !1,
        left: !1,
        bottom: ".section-resizable-handle",
        right: !1
      },
      inertia: !0,
      autoScroll: !1,
      listeners: {
        start: (t) => {
          t.stopPropagation();
        },
        move: (t) => {
          t.stopPropagation();
          const n = (e.dataset.h ? parseFloat(e.dataset.h) : e.offsetHeight) + t.delta.y;
          requestAnimationFrame(() => {
            Object.assign(e.style, {
              minHeight: `${n}px`,
              // maxHeight: `${newHeight}px`,
              flex: "none"
            });
          }), Object.assign(e.dataset, { h: n });
        },
        end: (t) => {
          const s = `${parseFloat(e.dataset.h).toFixed(0)}px`;
          e.style.removeProperty("minHeight"), e.style.removeProperty("height"), e.style.removeProperty("maxHeight"), e.style.removeProperty("flex"), e.dataset.h = "", console.log("Resized section", o.id, "to height", s), a.updateSectionProps(o.id, {
            minHeight: s
          });
        }
      }
    }).on("resizeend", function() {
      window.addEventListener("click", (t) => t.stopImmediatePropagation(), {
        capture: !0,
        once: !0
      });
    }), () => {
      r.current?.unset(), r.current = null;
    };
  }, []);
}
export {
  y as useResizableSection
};
//# sourceMappingURL=use-resizable-section.js.map
