import { isBrowser, getOwnerGlobalObject } from '../../lib/globalObject.js';
import { isFirefox } from '../client.js';
// 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
export var fixFirefoxModifiedClickOnLabel = function (ref) {
    return function (e) {
        var input = ref.current;
        if (!input) {
            return;
        }
        var globalObject = getOwnerGlobalObject(input);
        if (!input.disabled && isBrowser(globalObject) && 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.MouseEvent) {
                input.dispatchEvent(new globalObject.MouseEvent('change', e.nativeEvent));
            }
            input.type = type;
        }
    };
};
//# sourceMappingURL=fixFirefoxModifiedClickOnLabel.js.map