"use client";
import { jsx as I } from "react/jsx-runtime";
import { BuilderConfiguration as m } from "../../config/builder.config.js";
import { addBlocks as v, addBlock as C } from "../../store/builder-slice.js";
import { BlockType as o } from "../../types/block.js";
import { createBlock as s, classNames as O } from "../../utils/index.js";
import { isDropableBlock as u } from "../../utils/guard.js";
import { useAppDispatch as T } from "../../hooks/use-app-dispatch.js";
import { useRef as h } from "react";
import { useDrop as R } from "../../../../../node_modules/.pnpm/react-dnd@16.0.1_@types_node@22.13.4_@types_react@19.0.10_react@19.0.0/node_modules/react-dnd/dist/hooks/useDrop/useDrop.js";
const G = ({
  blockId: p = "root",
  className: g,
  children: b,
  onBlockAdded: t
}) => {
  const d = m.getBlockTypes(), i = T(), c = m.getBlock(o.CONTAINER), [{ isOver: D }, N] = R({
    accept: d,
    drop: (r, y) => {
      if (y.didDrop() || !u(r))
        return;
      if (r.type !== o.CONTAINER) {
        const f = s({
          type: o.CONTAINER,
          parentId: p,
          settings: c.settings,
          advancedSettings: c.advancedSettings
        }), e = [f], l = s({
          ...r,
          parentId: f.id
        });
        e.push(l), i(
          v({
            blocks: e,
            selectedBlockId: l.id
          })
        ), t == null || t(e[0]);
        return;
      }
      const n = s({
        ...r,
        parentId: p
      });
      i(C({ block: n })), t == null || t(n);
    },
    collect: (r) => ({
      isOver: r.isOver({ shallow: !0 }) && r.canDrop() && u(r.getItem())
    })
  }), a = h(null);
  return N(a), /* @__PURE__ */ I(
    "div",
    {
      className: O(
        "flex w-full justify-center rounded-sm border border-dashed py-6",
        D ? "border-slate-800" : "border-slate-300",
        g
      ),
      ref: a,
      children: b
    }
  );
};
export {
  G as default
};
//# sourceMappingURL=block-dropzone.js.map
