import { jsx as p } from "react/jsx-runtime";
import { useLocation as f } from "react-router-dom";
import { useMount as s, useDeepCompareEffect as u } from "ahooks";
import r from "react-ga4";
import { default as A } from "react-ga4";
import { googleAnalyticsMeasurementId as n } from "./env.js";
n && r.initialize(n);
const h = (i) => {
  const a = (o, t = document.title) => {
    n && r.send({ hitType: "pageview", page: o, title: t });
  }, c = (o, t, e, m) => {
    n && r.event({ category: o, action: t, label: e, value: m, transport: "beacon" });
  };
  return window.trackPage = a, window.trackEvent = c, function(t) {
    const e = f();
    return s(() => {
      a(e.pathname);
    }), u(() => {
      a(e.pathname);
    }, [e.pathname]), /* @__PURE__ */ p(i, { ...t });
  };
};
export {
  A as ReactGA,
  h as default
};
