"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.updateAnchorHref = exports.isAuxClick = exports.getAnchorAttributesFromEvent = void 0;
/**
 * Returns true for genuine middle-clicks (button === 1).
 * Filters out Windows right-clicks, which fire onAuxClick with button === 2
 * in addition to onContextMenu, to prevent double-counting.
 */
var isAuxClick = exports.isAuxClick = function isAuxClick(e) {
  return e.button === 1;
};

/**
 * Extracts `href` and `target` from the anchor element that is the event's `currentTarget`.
 *
 * Smart Link click handlers are attached to multiple card renderers (InlineCard, BlockCard,
 * EmbedCard, FlexibleCard). When the handler needs to manually open a link — for example,
 * when native anchor navigation has been prevented — it uses this helper to read the
 * anchor's resolved URL and intended target from the event rather than re-deriving them.
 *
 * Returns `{ href: undefined, target: '_self' }` when `currentTarget` is not an anchor
 * element (e.g. a button or wrapper div), so callers can safely fall back to a default target.
 *
 * @param event - A React mouse or keyboard event whose `currentTarget` may be an anchor.
 * @returns The resolved absolute `href` and `target` attribute of the anchor, or safe
 *   defaults if `currentTarget` is not an anchor.
 */
var getAnchorAttributesFromEvent = exports.getAnchorAttributesFromEvent = function getAnchorAttributesFromEvent(event) {
  var currentTarget = event.currentTarget;
  if (!(currentTarget instanceof HTMLAnchorElement)) {
    return {
      href: undefined,
      target: '_self'
    };
  }
  return {
    href: currentTarget.href,
    target: currentTarget.target || '_self'
  };
};
var updateAnchorHref = exports.updateAnchorHref = function updateAnchorHref(event, href) {
  if (!(event.currentTarget instanceof HTMLAnchorElement)) {
    return;
  }
  event.currentTarget.href = href;
};