"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.findDangerousCSSRules = void 0;
const NATIVE_TAGS = ['iframe', 'img', 'input', 'textarea', 'select', 'option', 'a', 'button', 'form', 'table', 'thead', 'tbody', 'tr', 'th', 'td'];
const findDangerousCSSRules = () => {
  const {
    styleSheets
  } = document;
  let value = [];
  const checkRules = function (rules) {
    let fileName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'inline';
    const dangerousRules = Array.from(rules).filter(rule => {
      return rule.selectorText && NATIVE_TAGS.some(selector => new RegExp("\\b".concat(selector, "\\b")).test(rule.selectorText));
    }).map(rule => ({
      selector: rule.selectorText,
      fileName
    }));
    value = [...value, ...dangerousRules];
    for (const rule of rules) {
      if (rule.cssRules) checkRules(rule.cssRules, fileName);
    }
  };
  for (const styleSheet of styleSheets) {
    const rules = styleSheet.cssRules || styleSheet.rules;
    if (rules) checkRules(rules, styleSheet.href);
  }
  return value;
};
exports.findDangerousCSSRules = findDangerousCSSRules;
//# sourceMappingURL=findDangerousCSSRules.js.map