"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const canUseDOM = require("./canUseDOM.js");
exports.optionsSupported = false;
exports.onceSupported = false;
try {
  var options = {
    get passive() {
      return exports.optionsSupported = true;
    },
    get once() {
      return exports.onceSupported = exports.optionsSupported = true;
    }
  };
  if (canUseDOM.default) {
    window.addEventListener("test", options, options);
    window.removeEventListener("test", options, true);
  }
} catch (e) {
}
function addEventListener(node, eventName, handler, options) {
  if (options && typeof options !== "boolean" && !exports.onceSupported) {
    var once = options.once, capture = options.capture;
    var wrappedHandler = handler;
    if (!exports.onceSupported && once) {
      wrappedHandler = handler.__once || function onceHandler(event) {
        this.removeEventListener(eventName, onceHandler, capture);
        handler.call(this, event);
      };
      handler.__once = wrappedHandler;
    }
    node.addEventListener(eventName, wrappedHandler, exports.optionsSupported ? options : capture);
  }
  node.addEventListener(eventName, handler, options);
}
exports.default = addEventListener;
