import { jsx as c } from "@emotion/react/jsx-runtime";
import { useState as f, createContext as F } from "react";
import { voidFunction as p } from "@m4l/core";
const v = {
  activeFilters: !1,
  setActiveFilters: p
}, m = F(v);
function x({
  children: o,
  initialActiveFilters: l
}) {
  const [e, i] = f({
    activeFilters: l
  }), n = (t, s) => {
    const r = e.filters ? new Map(e.filters) : /* @__PURE__ */ new Map();
    s !== "" ? r.set(t.key, { value: s, customFilter: t.customFilter }) : r.delete(t.key), i({
      ...e,
      filters: r
    });
  }, a = (t) => {
    i(t ? { activeFilters: !0, filters: /* @__PURE__ */ new Map() } : { activeFilters: !1 });
  };
  return /* @__PURE__ */ c(
    m.Provider,
    {
      value: {
        ...e,
        onChangeFilter: n,
        setActiveFilters: a
      },
      children: o
    }
  );
}
export {
  m as FilterContext,
  x as FilterProvider
};
