function _instanceof(left, right) {
    "@swc/helpers - instanceof";
    if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
        return !!right[Symbol.hasInstance](left);
    } else {
        return left instanceof right;
    }
}
import { merge } from "d3-array";
import clickLegend from "./click.legend.js";
import { legendLabel } from "../drawSteps/drawLegend.js";
import { configPrep } from "../../utils/index.js";
/**
    @module mouseMoveLegend
    Tooltip logic for a specified data point.
    @param config Optional configuration methods for the Tooltip class.
    @private
*/ export default function(d, i, x, event) {
    var _this = this;
    var position = event.touches ? [
        event.touches[0].clientX,
        event.touches[0].clientY
    ] : [
        event.clientX,
        event.clientY
    ];
    var dataLength = merge(this._legendClass.data().map(function(d, i) {
        var id = _this._id(d, i);
        if (!_instanceof(id, Array)) id = [
            id
        ];
        return id;
    })).length;
    if (d && this._tooltip(d, i)) {
        var id = this._id(d, i);
        if (_instanceof(id, Array)) id = id[0];
        var t = this._translate;
        var defaultClick = clickLegend.bind(this).toString();
        // does the legend have any user-defined click events?
        var hasUserClick = Object.keys(this._on).some(function(e) {
            return(// all valid click event keys,
            [
                "click",
                "click.legend"
            ].includes(e) && // truthy values (no nulls),
            _this._on[e] && // and it is not our default click.legend function
            _this._on[e].toString() !== defaultClick);
        });
        // does the legend still have our default "click.legend" event?
        // (if the user only sets "click", both functions will fire)
        var hasDefaultClick = this._on["click.legend"] && this._on["click.legend"].toString() === defaultClick;
        // can the viz show deeper data?
        var hasDeeperLevel = this._drawDepth < this._groupBy.length - 1;
        // only show the hand cursor when the shape has a click event
        this._select.style("cursor", hasUserClick || hasDefaultClick && hasDeeperLevel ? "pointer" : "auto");
        var invertedBehavior = this._legendFilterInvert.bind(this)();
        var solo = this._solo.includes(id);
        var hidden = this._hidden.includes(id);
        this._tooltipClass.data([
            x || d
        ]).footer(hasDefaultClick ? invertedBehavior ? this._solo.length && !solo || hidden ? t("Click to Highlight") : this._solo.length === 1 && solo || this._hidden.length === dataLength - 1 ? t("Click to Show All") : "".concat(t("Click to Highlight"), "<br />").concat(t("Shift+Click to Hide")) : this._solo.length && !solo || hidden ? "".concat(t("Click to Show"), "<br />").concat(t("Shift+Click to Highlight")) : this._solo.length === 1 && solo || this._hidden.length === dataLength - 1 ? t("Click to Show All") : "".concat(t("Click to Hide"), "<br />").concat(t("Shift+Click to Highlight")) : false).title(this._legendConfig.label ? this._legendClass.label() : legendLabel.bind(this)).position(position).config(configPrep.bind(this)(this._tooltipConfig)).config(configPrep.bind(this)(this._legendTooltip)).render();
    }
}
