"use client";
import { useEffect as u } from "react";
import { useAppSelector as t } from "../state/hooks.js";
import { selectEventEmitter as S, selectSyncId as v, selectSyncMethod as d } from "../state/selectors/rootPropsSelectors.js";
import { eventCenter as h, TOOLTIP_SYNC_EVENT as E } from "../util/Events.js";
import { setSyncInteraction as T } from "../state/tooltipSlice.js";
import { selectTooltipDataKey as I } from "../state/selectors/selectors.js";
import { selectSynchronisedTooltipState as K } from "./syncSelectors.js";
function x(f, p, c, e, m, l) {
  var s = t((i) => I(i, f, p)), r = t(S), o = t(v), y = t(d), n = t(K), a = n?.active;
  u(() => {
    if (!a && o != null && r != null) {
      var i = T({
        active: l,
        coordinate: c,
        dataKey: s,
        index: m,
        label: typeof e == "number" ? String(e) : e
      });
      h.emit(E, o, i, r);
    }
  }, [a, c, s, m, e, r, o, y, l]);
}
export {
  x as useTooltipChartSynchronisation
};
