"use client";
import { jsxs as a, jsx as r } from "react/jsx-runtime";
import { BuilderConfiguration as c } from "../../../config/builder.config.js";
import u from "./block-navigation-item.js";
import { Accordion as l } from "../../shared/accordion.js";
import { ScrollArea as p } from "../../shared/scroll-area.js";
import { BiSearch as h } from "../../../../../../node_modules/.pnpm/react-icons@5.5.0_react@19.0.0/node_modules/react-icons/bi/index.js";
import { useState as f, useMemo as g } from "react";
import { objectKeys as m, classNames as x } from "../../../utils/index.js";
const S = () => {
  const [o, d] = f(""), i = g(() => c.getBlocks().filter((e) => e.label.toLowerCase().includes(o.toLowerCase())).reduce(
    (e, s) => {
      const t = s.group ?? "Others";
      return e[t] || (e[t] = []), e[t].push(s), e;
    },
    {}
  ), [o]);
  return /* @__PURE__ */ a("div", { children: [
    /* @__PURE__ */ r("div", { className: "mt-4 h-14 w-full bg-white px-4", children: /* @__PURE__ */ a("div", { className: "group flex items-center  overflow-hidden rounded-sm  ring-1 ring-slate-300 focus-within:ring-2 focus-within:ring-slate-600", children: [
      /* @__PURE__ */ r("div", { className: "ms-2.5 flex w-7 items-center justify-center", children: /* @__PURE__ */ r(h, { className: " text-slate-500 group-focus-within:text-slate-700", size: 18 }) }),
      /* @__PURE__ */ r(
        "input",
        {
          value: o,
          onChange: (e) => {
            d(e.target.value);
          },
          type: "text",
          className: "focus:outline-hidden w-full rounded-sm border-0 px-1 py-2 text-sm placeholder:text-sm placeholder:text-slate-500 focus:ring-0",
          placeholder: "Search..."
        }
      )
    ] }) }),
    m(i).length === 0 && /* @__PURE__ */ r("div", { className: "py-2 text-center text-sm text-slate-600", children: "No blocks found" }),
    /* @__PURE__ */ r(p, { className: "h-[calc(100vh-145px)]", children: /* @__PURE__ */ r(l, { defaultValue: Object.keys(i), type: "multiple", children: m(i).sort((e, s) => {
      const t = c.getGroupOrder(e), n = c.getGroupOrder(s);
      return t !== -1 && n !== -1 ? t - n : t !== -1 ? -1 : n !== -1 ? 1 : 0;
    }).map((e, s) => /* @__PURE__ */ a(l.Item, { value: e, children: [
      /* @__PURE__ */ r(
        l.Trigger,
        {
          className: x("px-4", {
            "pt-1": s === 0
          }),
          children: e
        }
      ),
      /* @__PURE__ */ r(l.Content, { className: "px-4", children: /* @__PURE__ */ r("div", { className: "grid grid-cols-2 gap-3 py-2", children: i[e].map((t) => /* @__PURE__ */ r(u, { block: t }, t.type)) }) })
    ] }, e)) }) })
  ] });
};
export {
  S as BlockNavigation
};
//# sourceMappingURL=block-navigation.js.map
