define(["exports", "core/LinterRule", "../l10n"], function (exports, _LinterRule, _l10n) {
  "use strict";

  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  exports.rule = undefined;

  var _LinterRule2 = _interopRequireDefault(_LinterRule);

  function _interopRequireDefault(obj) {
    return obj && obj.__esModule ? obj : {
      default: obj
    };
  }

  var _extends = Object.assign || function (target) {
    for (var i = 1; i < arguments.length; i++) {
      var source = arguments[i];

      for (var key in source) {
        if (Object.prototype.hasOwnProperty.call(source, key)) {
          target[key] = source[key];
        }
      }
    }

    return target;
  };

  var name = "privsec-section";
  var meta = {
    en: {
      description: "Document must a 'Privacy and/or Security' Considerations section.",
      howToFix: "Add a privacy and/or security considerations section.",
      help: "See the [Self-Review Questionnaire](https://w3ctag.github.io/security-questionnaire/)."
    }
  };

  // Fall back to english, if language is missing
  var lang = _l10n.lang in meta ? _l10n.lang : "en";

  function hasPriSecConsiderations(doc) {
    return Array.from(doc.querySelectorAll("h2, h3, h4, h5, h6")).some(function (_ref) {
      var text = _ref.textContent;

      var saysPrivOrSec = /(privacy|security)/im.test(text);
      var saysConsiderations = /(considerations)/im.test(text);
      return saysPrivOrSec && saysConsiderations || saysPrivOrSec;
    });
  }

  function lintingFunction(conf, doc) {
    var results = [];
    if (conf.isRecTrack && !hasPriSecConsiderations(doc)) {
      results.push(_extends({ name: name, occurrences: 1 }, meta[lang]));
    }
    return results;
  }

  var rule = exports.rule = new _LinterRule2.default(name, lintingFunction);
});
//# sourceMappingURL=privsec-section.js.map