import { jsx as p } from "react/jsx-runtime";
import { useState as c, useCallback as m } from "react";
import h from "../../Command.js";
import { COMMAND_VARIANT as C } from "../../constants/index.js";
import { detailedGroups as r } from "../constants/index.js";
const D = () => {
  const [d, a] = c(!1), [u, s] = c(r), l = m(async (e = "") => {
    a(!0);
    try {
      if (await new Promise((o) => setTimeout(o, 800)), e.trim()) {
        const o = r.map((t) => ({
          ...t,
          items: t.items.filter(
            (n) => {
              var i;
              return n.label.toLowerCase().includes(e.toLowerCase()) || ((i = n.value) == null ? void 0 : i.toLowerCase().includes(e.toLowerCase()));
            }
          )
        })).filter((t) => t.items.length > 0);
        s(o);
      } else
        s(r);
    } catch (o) {
      console.error("API fetch error:", o), s([]);
    } finally {
      a(!1);
    }
  }, []), f = m(
    (e) => {
      l(e);
    },
    [l]
  );
  return /* @__PURE__ */ p(
    h,
    {
      variant: C.SIMPLE,
      onDebouncedValueChange: f,
      groups: u,
      isLoading: d,
      showLoadingOnType: !0,
      placeholder: "Type to search products...",
      shouldFilter: !1
    }
  );
};
export {
  D as default
};
//# sourceMappingURL=LoadingCommand.js.map
