import { useState as o, useEffect as f } from "react";
const h = (a, e = "") => {
  const [r, n] = o(!1), [c, i] = o(void 0), [m, t] = o(e);
  return f(() => {
    t(e);
  }, [e]), { loading: r, searchValue: m, handleInput: async (u) => {
    const { value: s } = u.target;
    if (c && clearTimeout(c), t(s), s !== e || !s) {
      const d = setTimeout(() => {
        a(s), n(!1);
      }, 1e3);
      i(d);
    } else
      n(!1);
    n(!0);
  }, removeSearchInput: () => {
    a(), t("");
  }, setSearchValue: t };
};
export {
  h as useHandleTextInputWithTimer
};
