import { useCallback as i } from "react";
const m = () => typeof document > "u" ? {} : document.cookie.split(";").map((t) => t.trim()).filter(Boolean).reduce(
  (t, n) => {
    const s = n.indexOf("="), r = s >= 0 ? n.slice(0, s) : n, o = s >= 0 ? n.slice(s + 1) : "";
    return t[decodeURIComponent(r)] = decodeURIComponent(o), t;
  },
  {}
), f = () => {
  const t = i((o, c, e = {}) => {
    if (typeof document > "u")
      return;
    const a = [`${encodeURIComponent(o)}=${encodeURIComponent(c)}`, `path=${e.path ?? "/"}`];
    if (e.domain && a.push(`domain=${e.domain}`), e.expires) {
      const u = e.expires instanceof Date ? e.expires.toUTCString() : e.expires;
      a.push(`expires=${u}`);
    }
    typeof e.maxAge == "number" && a.push(`max-age=${e.maxAge}`), e.sameSite && a.push(`samesite=${e.sameSite}`), e.secure && a.push("secure"), document.cookie = a.join("; ");
  }, []), n = i(
    (o, c = {}) => {
      t(o, "", {
        ...c,
        expires: /* @__PURE__ */ new Date(0),
        maxAge: 0
      });
    },
    [t]
  ), s = i((o) => Object.hasOwn(m(), o), []), r = i((o) => m()[o], []);
  return { setCookie: t, deleteCookie: n, hasCookie: s, getCookie: r };
};
export {
  f as default
};
//# sourceMappingURL=useCookies.js.map
