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

var _client = require("../client");

// Checkbox not checked in Firefox if key of modifier was active
// shift+click, ctrl+click on Win and cmd+click on Mac
// https://bugzilla.mozilla.org/show_bug.cgi?id=559506
var fixFirefoxModifiedClickOnLabel = exports.fixFirefoxModifiedClickOnLabel =
function fixFirefoxModifiedClickOnLabel(ref) {return function (e) {
    var input = ref.current;
    if (input && !input.disabled && (0, _globalObject.isBrowser)(_globalObject.globalObject) && _client.isFirefox && (e.shiftKey || e.ctrlKey || e.metaKey)) {
      // Currently only valid for Radio and Checkbox
      input.checked = !input.checked;
      var type = input.type;
      input.type = 'text';
      e.persist();
      if (_globalObject.globalObject.MouseEvent) {
        input.dispatchEvent(new _globalObject.globalObject.MouseEvent('change', e.nativeEvent));
      }
      input.type = type;
    }
  };};