import { jsxs, jsx } from 'react/jsx-runtime';
import { useState } from 'react';
import { AddComponentsPopover } from './add-component-popover.mjs';
import { Button } from '../../../button.mjs';
import { PlusCircle } from 'lucide-react';
import { cn } from '../../../../lib/utils.mjs';

function DividerControl({
  className,
  addPosition,
  parentLayerId
}) {
  const [popoverOpen, setPopoverOpen] = useState(false);
  return /* @__PURE__ */ jsxs("div", { className: cn("relative py-0", className), children: [
    /* @__PURE__ */ jsx("div", { className: "absolute inset-0 flex items-center", "aria-hidden": "true", children: /* @__PURE__ */ jsx("div", { className: "w-full border-t border-primary border-dashed" }) }),
    /* @__PURE__ */ jsx(
      AddComponentsPopover,
      {
        onOpenChange: setPopoverOpen,
        addPosition,
        parentLayerId,
        children: /* @__PURE__ */ jsxs(
          Button,
          {
            variant: "outline",
            className: "group flex items-center rounded-full bg-secondary h-min p-2 text-sm font-semibold text-secondar-foreground shadow-sm ring-1 ring-inset ring-secondary transition-all duration-200 ease-in-out gap-0",
            children: [
              /* @__PURE__ */ jsx(PlusCircle, { className: "h-5 w-5 text-secondary-foreground" }),
              /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Add component" }),
              /* @__PURE__ */ jsx("span", { className: cn("overflow-hidden max-w-0 group-hover:max-w-xs transition-all duration-200 ease-in-out group-hover:pl-2", popoverOpen ? "max-w-xs pl-2" : "max-w-0"), children: "Add component" })
            ]
          }
        )
      }
    )
  ] });
}

export { DividerControl };
