import { jsx as m } from "../../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import { useCallback as a, useMemo as v, useEffect as f } from "../../../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import { AnalyticsContext as l } from "./AnalyticsContext.js";
import { setupAnalytics as y } from "../setupAnalytics.js";
import { usePushAnalyticEvent as A } from "../../../../hooks/useAnalytics/usePushAnalyticEvent.js";
const C = ({ children: i, componentName: s, analyticsEnabled: t }) => {
  const e = A(), r = a(
    (u) => {
      const { name: p, properties: c } = u;
      e({
        event: p,
        properties: c || {}
      });
    },
    [e]
  ), { userEvents: n, subscribe: o } = v(() => y({ analyticsEnabled: t, componentName: s }), [t, s]);
  return f(() => o(r), [o, r]), /* @__PURE__ */ m(l.Provider, { value: n, children: i });
};
export {
  C as AnalyticsProvider
};
