"use strict";exports.__esModule = true;exports.fixClickFocusIE = void 0;var _globalObject = require("@skbkontur/global-object");

var _tabbableHelpers = require("../dom/tabbableHelpers");
var _client = require("../client");
var _isInstanceOf = require("../isInstanceOf");

var fixClickFocusIE = exports.fixClickFocusIE = function fixClickFocusIE(e) {
  if (_client.isIE11 || _client.isEdge) {
    // workaround for the IE/Edge focus bug
    // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/14306303/
    if (_globalObject.globalObject.document && _globalObject.globalObject.document.activeElement !== e.target) {
      if ((0, _isInstanceOf.isInstanceOf)(e.target, _globalObject.globalObject.HTMLElement)) {
        var closestFocusable = (0, _tabbableHelpers.getClosestFocusableElement)(e.target);
        if (closestFocusable) {
          closestFocusable.focus();
        }
      }
    }
  }
};