"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const constants = require("../constants.js");
var isElementHidden = function(node) {
  if (node.nodeType !== Node.ELEMENT_NODE) {
    return false;
  }
  var computedStyle = window.getComputedStyle(node, null);
  if (!computedStyle || !computedStyle.getPropertyValue) {
    return false;
  }
  return computedStyle.getPropertyValue("display") === "none" || computedStyle.getPropertyValue("visibility") === "hidden";
};
var getParentNode = function(node) {
  return node.parentNode && node.parentNode.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? node.parentNode.host : node.parentNode;
};
var isTopNode = function(node) {
  return node === document || node && node.nodeType === Node.DOCUMENT_NODE;
};
var isVisibleUncached = function(node, checkParent) {
  return !node || isTopNode(node) || !isElementHidden(node) && checkParent(getParentNode(node));
};
var isVisibleCached = function(visibilityCache, node) {
  var cached = visibilityCache.get(node);
  if (cached !== void 0) {
    return cached;
  }
  var result = isVisibleUncached(node, isVisibleCached.bind(void 0, visibilityCache));
  visibilityCache.set(node, result);
  return result;
};
var isAutoFocusAllowedUncached = function(node, checkParent) {
  return node && !isTopNode(node) ? isAutoFocusAllowed(node) ? checkParent(getParentNode(node)) : false : true;
};
var isAutoFocusAllowedCached = function(cache, node) {
  var cached = cache.get(node);
  if (cached !== void 0) {
    return cached;
  }
  var result = isAutoFocusAllowedUncached(node, isAutoFocusAllowedCached.bind(void 0, cache));
  cache.set(node, result);
  return result;
};
var getDataset = function(node) {
  return node.dataset;
};
var isHTMLButtonElement = function(node) {
  return node.tagName === "BUTTON";
};
var isHTMLInputElement = function(node) {
  return node.tagName === "INPUT";
};
var isRadioElement = function(node) {
  return isHTMLInputElement(node) && node.type === "radio";
};
var notHiddenInput = function(node) {
  return !((isHTMLInputElement(node) || isHTMLButtonElement(node)) && (node.type === "hidden" || node.disabled));
};
var isAutoFocusAllowed = function(node) {
  var attribute = node.getAttribute(constants.FOCUS_NO_AUTOFOCUS);
  return ![true, "true", ""].includes(attribute);
};
var isGuard = function(node) {
  var _a;
  return Boolean(node && ((_a = getDataset(node)) === null || _a === void 0 ? void 0 : _a.focusGuard));
};
var isNotAGuard = function(node) {
  return !isGuard(node);
};
var isDefined = function(x) {
  return Boolean(x);
};
exports.getDataset = getDataset;
exports.isAutoFocusAllowed = isAutoFocusAllowed;
exports.isAutoFocusAllowedCached = isAutoFocusAllowedCached;
exports.isDefined = isDefined;
exports.isGuard = isGuard;
exports.isHTMLButtonElement = isHTMLButtonElement;
exports.isHTMLInputElement = isHTMLInputElement;
exports.isNotAGuard = isNotAGuard;
exports.isRadioElement = isRadioElement;
exports.isVisibleCached = isVisibleCached;
exports.notHiddenInput = notHiddenInput;
//# sourceMappingURL=is.js.map
