(self["webpackChunk_deephaven_ipywidgets"] = self["webpackChunk_deephaven_ipywidgets"] || []).push([["vendors-node_modules_deephaven_log_dist_index_js"],{

/***/ "./node_modules/@deephaven/log/dist/DefaultLogger.js":
/*!***********************************************************!*\
  !*** ./node_modules/@deephaven/log/dist/DefaultLogger.js ***!
  \***********************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var _Logger_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Logger.js */ "./node_modules/@deephaven/log/dist/Logger.js");
/* harmony import */ var _LoggerLevel_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./LoggerLevel.js */ "./node_modules/@deephaven/log/dist/LoggerLevel.js");
/* provided dependency */ var process = __webpack_require__(/*! process/browser */ "./node_modules/process/browser.js");


/**
 * Get the default log level to use.
 * production mode defaults to INFO.
 * development mode defaults to DEBUG2 (most verbose).
 * test mode defaults to SILENT.
 * Override by setting environment variable `process.env.DEEPHAVEN_LOG_LEVEL`
 * @returns {number} The default log level to use
 */

function getDefaultLevel() {
  var _envValue;

  var envValue = '';

  try {
    envValue = process.env.DEEPHAVEN_LOG_LEVEL;
  } catch (_unused) {// no-op. Environment without process defined
  }

  if (envValue && _LoggerLevel_js__WEBPACK_IMPORTED_MODULE_1__["default"][envValue]) {
    return _LoggerLevel_js__WEBPACK_IMPORTED_MODULE_1__["default"][envValue];
  }

  var envLevel = parseInt((_envValue = envValue) !== null && _envValue !== void 0 ? _envValue : '', 10);

  if (!Number.isNaN(envLevel)) {
    return envLevel;
  }

  try {
    if (false) {}

    if (true) {
      return _LoggerLevel_js__WEBPACK_IMPORTED_MODULE_1__.DEBUG2;
    }
  } catch (_unused2) {// no-op. Environment without process defined
  }

  return _LoggerLevel_js__WEBPACK_IMPORTED_MODULE_1__.INFO;
}

class DefaultLogger extends _Logger_js__WEBPACK_IMPORTED_MODULE_0__["default"] {
  constructor() {
    var level = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getDefaultLevel();
    super(null, level);
    this.modules = {};
  }

  module(name) {
    if (!this.modules[name]) {
      this.modules[name] = new _Logger_js__WEBPACK_IMPORTED_MODULE_0__["default"](name, this.level);
    }

    return this.modules[name];
  }

  setLogLevel(level) {
    super.setLogLevel(level);

    if (!this.modules) {
      return;
    }

    var keys = Object.keys(this.modules);

    for (var i = 0; i < keys.length; i += 1) {
      this.modules[keys[i]].setLogLevel(level);
    }
  }

}

/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (DefaultLogger);
//# sourceMappingURL=DefaultLogger.js.map

/***/ }),

/***/ "./node_modules/@deephaven/log/dist/Log.js":
/*!*************************************************!*\
  !*** ./node_modules/@deephaven/log/dist/Log.js ***!
  \*************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var _DefaultLogger_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./DefaultLogger.js */ "./node_modules/@deephaven/log/dist/DefaultLogger.js");

var Log = new _DefaultLogger_js__WEBPACK_IMPORTED_MODULE_0__["default"]();
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Log);
//# sourceMappingURL=Log.js.map

/***/ }),

/***/ "./node_modules/@deephaven/log/dist/LogHistory.js":
/*!********************************************************!*\
  !*** ./node_modules/@deephaven/log/dist/LogHistory.js ***!
  \********************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var _LogProxy_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./LogProxy.js */ "./node_modules/@deephaven/log/dist/LogProxy.js");
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }



class LogHistory {
  /**
   * Formats log arguments on separate lines
   * Attempts to stringify objects
   * @param messages - The messages/params sent to the log call
   */
  static formatMessages(messages) {
    var formatted = messages.map(m => {
      if (typeof m === 'string') {
        return m;
      } // Some objects don't stringify nicely, so give some info about the object


      var jsonString = '';

      try {
        jsonString = JSON.stringify(m);
      } catch (e) {
        jsonString = m.toString();
      }

      return jsonString === '{}' ? m.toString() : jsonString;
    });
    return formatted.join('\t');
  }
  /**
   * Formats stack traces to a string with each frame on its own line and indented 1 level
   * @param stack - Stack trace generated in the console
   * @param type - Log type (e.g. log, warn, error)
   */


  static formatStack() {
    var stack = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
    var type = arguments.length > 1 ? arguments[1] : undefined;

    if (stack === '') {
      return '';
    } // Some browsers will add a top frame which is just 'Error', some won't
    // We will always add at least 2 frames. 1 creating the error and 1 calling addHistory
    // On error (logger.error) we add a 3rd frame which is overriding console.error
    // For uncaught errors the 3rd frame is not added


    var stringStack = stack.split('\n').map(line => line.trim());

    switch (type) {
      case _LogProxy_js__WEBPACK_IMPORTED_MODULE_0__.LOG_PROXY_TYPE.ERROR:
        stringStack = stringStack.splice(stack[0] === 'Error' ? 4 : 3);
        break;

      case _LogProxy_js__WEBPACK_IMPORTED_MODULE_0__.LOG_PROXY_TYPE.UNCAUGHT_ERROR:
        stringStack = stringStack.splice(stack[0] === 'Error' ? 3 : 2);
        break;

      default:
        break;
    }

    return stringStack ? "\t".concat(stringStack.join('\n\t')) : '';
  }

  constructor(proxy) {
    _defineProperty(this, "history", void 0);

    _defineProperty(this, "offset", void 0);

    _defineProperty(this, "limit", void 0);

    _defineProperty(this, "isEnabled", void 0);

    _defineProperty(this, "proxy", void 0);

    this.history = [];
    this.offset = 0;
    this.limit = 10000;
    this.isEnabled = false;
    this.proxy = proxy;
    this.addHistory = this.addHistory.bind(this);
  }

  enable() {
    if (this.isEnabled) {
      return;
    }

    this.proxy.addEventListener(_LogProxy_js__WEBPACK_IMPORTED_MODULE_0__.LOG_PROXY_TYPE.DEBUG, this.addHistory);
    this.proxy.addEventListener(_LogProxy_js__WEBPACK_IMPORTED_MODULE_0__.LOG_PROXY_TYPE.LOG, this.addHistory);
    this.proxy.addEventListener(_LogProxy_js__WEBPACK_IMPORTED_MODULE_0__.LOG_PROXY_TYPE.WARN, this.addHistory);
    this.proxy.addEventListener(_LogProxy_js__WEBPACK_IMPORTED_MODULE_0__.LOG_PROXY_TYPE.ERROR, this.addHistory);
    this.proxy.addEventListener(_LogProxy_js__WEBPACK_IMPORTED_MODULE_0__.LOG_PROXY_TYPE.UNCAUGHT_ERROR, this.addHistory);
    this.isEnabled = true;
  }

  disable() {
    if (!this.isEnabled) {
      return;
    }

    this.proxy.removeEventListener(_LogProxy_js__WEBPACK_IMPORTED_MODULE_0__.LOG_PROXY_TYPE.DEBUG, this.addHistory);
    this.proxy.removeEventListener(_LogProxy_js__WEBPACK_IMPORTED_MODULE_0__.LOG_PROXY_TYPE.LOG, this.addHistory);
    this.proxy.removeEventListener(_LogProxy_js__WEBPACK_IMPORTED_MODULE_0__.LOG_PROXY_TYPE.WARN, this.addHistory);
    this.proxy.removeEventListener(_LogProxy_js__WEBPACK_IMPORTED_MODULE_0__.LOG_PROXY_TYPE.ERROR, this.addHistory);
    this.proxy.removeEventListener(_LogProxy_js__WEBPACK_IMPORTED_MODULE_0__.LOG_PROXY_TYPE.UNCAUGHT_ERROR, this.addHistory);
    this.isEnabled = false;
  }
  /**
   * Adds a call to a console method to the history.
   * @param type - The level of the message to add
   * @param messages - The parameters passed to the console method
   */


  addHistory(_ref) {
    var {
      type,
      detail
    } = _ref;
    var logItem = {
      type: type,
      messages: detail,
      time: new Date()
    };

    switch (type) {
      // Some browsers will add a top frame which is just 'Error', some won't
      // We will always add at least 2 frames. 1 creating the error and 1 calling addHistory
      // On error (logger.error) we add a 3rd frame which is overriding console.error
      // For uncaught errors the 3rd frame is not added
      case _LogProxy_js__WEBPACK_IMPORTED_MODULE_0__.LOG_PROXY_TYPE.ERROR:
      case _LogProxy_js__WEBPACK_IMPORTED_MODULE_0__.LOG_PROXY_TYPE.UNCAUGHT_ERROR:
        logItem.stack = Error().stack;
        break;

      default:
        break;
    }

    this.history[this.offset % this.limit] = logItem;
    this.offset += 1;
  }
  /**
   * Gets LogHistory object
   */


  getHistory() {
    if (this.offset > this.limit) {
      // Wrapped past the limit, get oldest -> end and concat start -> newest
      var startIdx = this.offset % this.limit;
      this.history = this.history.slice(startIdx).concat(this.history.slice(0, startIdx));
      this.offset = this.limit;
    }

    return this.history;
  }
  /**
   * Gets the history formatted as a string so it can easily be exported to a txt file
   */


  getFormattedHistory() {
    var historyString = this.getHistory().map(item => // eslint-disable-next-line prefer-template
    "".concat(item.time.toISOString(), " ").concat(item.type, "\t") + "".concat(LogHistory.formatMessages(item.messages)) + (item.stack ? "\n".concat(LogHistory.formatStack(item.stack, item.type)) : ''));
    return historyString.join('\n');
  }

}

/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (LogHistory);
//# sourceMappingURL=LogHistory.js.map

/***/ }),

/***/ "./node_modules/@deephaven/log/dist/LogProxy.js":
/*!******************************************************!*\
  !*** ./node_modules/@deephaven/log/dist/LogProxy.js ***!
  \******************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "LOG_PROXY_TYPE": () => (/* binding */ LOG_PROXY_TYPE),
/* harmony export */   "LogProxy": () => (/* binding */ LogProxy),
/* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var event_target_shim__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! event-target-shim */ "./node_modules/event-target-shim/index.mjs");
/* harmony import */ var _Log_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Log.js */ "./node_modules/@deephaven/log/dist/Log.js");
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

/* eslint-disable no-console */


var LOG_PROXY_TYPE; // We need to cast our CustomEvent so it's happy with event-target-shim

(function (LOG_PROXY_TYPE) {
  LOG_PROXY_TYPE["DEBUG"] = "D";
  LOG_PROXY_TYPE["LOG"] = "L";
  LOG_PROXY_TYPE["WARN"] = "W";
  LOG_PROXY_TYPE["ERROR"] = "E";
  LOG_PROXY_TYPE["UNCAUGHT_ERROR"] = "U";
})(LOG_PROXY_TYPE || (LOG_PROXY_TYPE = {}));

function makeEvent(type, detail) {
  return new CustomEvent(type, {
    detail
  });
}

class LogProxy {
  constructor() {
    _defineProperty(this, "isEnabled", false);

    _defineProperty(this, "debug", void 0);

    _defineProperty(this, "log", void 0);

    _defineProperty(this, "warn", void 0);

    _defineProperty(this, "error", void 0);

    _defineProperty(this, "eventTarget", void 0);

    _defineProperty(this, "handleUncaughtError", event => {
      var messages = [];

      if (event.error) {
        messages.push(event.error);
      }

      if (event.message) {
        messages.push(event.message);
      }

      this.eventTarget.dispatchEvent(makeEvent(LOG_PROXY_TYPE.UNCAUGHT_ERROR, messages));
    });

    this.debug = console.debug;
    this.log = console.log;
    this.warn = console.warn;
    this.error = console.error;
    this.eventTarget = new event_target_shim__WEBPACK_IMPORTED_MODULE_1__.EventTarget();
  }

  enable() {
    var _this = this;

    if (this.isEnabled) {
      return;
    }

    console.debug = function () {
      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
        args[_key] = arguments[_key];
      }

      _this.eventTarget.dispatchEvent(makeEvent(LOG_PROXY_TYPE.DEBUG, args));

      _this.debug.apply(console, args);
    };

    console.log = function () {
      for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
        args[_key2] = arguments[_key2];
      }

      _this.eventTarget.dispatchEvent(makeEvent(LOG_PROXY_TYPE.LOG, args));

      _this.log.apply(console, args);
    };

    console.warn = function () {
      for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
        args[_key3] = arguments[_key3];
      }

      _this.eventTarget.dispatchEvent(makeEvent(LOG_PROXY_TYPE.WARN, args));

      _this.warn.apply(console, args);
    };

    console.error = function () {
      for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
        args[_key4] = arguments[_key4];
      }

      _this.eventTarget.dispatchEvent(makeEvent(LOG_PROXY_TYPE.ERROR, args));

      _this.error.apply(console, args);
    };

    window.addEventListener('error', this.handleUncaughtError); // This forces logger to update its reference to the overriding functions instead of the original

    _Log_js__WEBPACK_IMPORTED_MODULE_0__["default"].setLogLevel(_Log_js__WEBPACK_IMPORTED_MODULE_0__["default"].level);
    this.isEnabled = true;
  }

  disable() {
    if (!this.isEnabled) {
      return;
    }

    console.debug = this.debug;
    console.log = this.log;
    console.warn = this.warn;
    console.error = this.error;
    window.removeEventListener('error', this.handleUncaughtError);
    _Log_js__WEBPACK_IMPORTED_MODULE_0__["default"].setLogLevel(_Log_js__WEBPACK_IMPORTED_MODULE_0__["default"].level);
    this.isEnabled = false;
  }

  addEventListener(type, listener) {
    // The cast as EventListener is a dumb TypeScript issue
    this.eventTarget.addEventListener(type, listener);
  }

  removeEventListener(type, listener) {
    this.eventTarget.removeEventListener(type, listener);
  }

}
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (LogProxy);
//# sourceMappingURL=LogProxy.js.map

/***/ }),

/***/ "./node_modules/@deephaven/log/dist/Logger.js":
/*!****************************************************!*\
  !*** ./node_modules/@deephaven/log/dist/Logger.js ***!
  \****************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var _LoggerLevel_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./LoggerLevel.js */ "./node_modules/@deephaven/log/dist/LoggerLevel.js");
/* eslint no-console: "off" */


var silent = () => {};

class Logger {
  constructor(name, level) {
    this.name = name;
    this.prefix = name ? "[".concat(name, "]") : "";
    this.setLogLevel(level);
  }

  setLogLevel(level) {
    this.level = level;
    this.error = _LoggerLevel_js__WEBPACK_IMPORTED_MODULE_0__.ERROR <= level ? console.error.bind(console, this.prefix) : silent;
    this.warn = _LoggerLevel_js__WEBPACK_IMPORTED_MODULE_0__.WARN <= level ? console.warn.bind(console, this.prefix) : silent;
    this.log = _LoggerLevel_js__WEBPACK_IMPORTED_MODULE_0__.INFO <= level ? console.log.bind(console, this.prefix) : silent;
    this.info = this.log;
    this.debug = _LoggerLevel_js__WEBPACK_IMPORTED_MODULE_0__.DEBUG <= level ? console.debug.bind(console, this.prefix) : silent;
    this.debug2 = _LoggerLevel_js__WEBPACK_IMPORTED_MODULE_0__.DEBUG2 <= level ? console.debug.bind(console, this.prefix) : silent;
  }

}

/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Logger);
//# sourceMappingURL=Logger.js.map

/***/ }),

/***/ "./node_modules/@deephaven/log/dist/LoggerLevel.js":
/*!*********************************************************!*\
  !*** ./node_modules/@deephaven/log/dist/LoggerLevel.js ***!
  \*********************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "DEBUG": () => (/* binding */ DEBUG),
/* harmony export */   "DEBUG2": () => (/* binding */ DEBUG2),
/* harmony export */   "ERROR": () => (/* binding */ ERROR),
/* harmony export */   "INFO": () => (/* binding */ INFO),
/* harmony export */   "SILENT": () => (/* binding */ SILENT),
/* harmony export */   "WARN": () => (/* binding */ WARN),
/* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
var SILENT = -1;
var ERROR = 0;
var WARN = 1;
var INFO = 2;
var DEBUG = 3;
var DEBUG2 = 4;
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Object.freeze({
  SILENT,
  ERROR,
  WARN,
  INFO,
  DEBUG,
  DEBUG2
}));
//# sourceMappingURL=LoggerLevel.js.map

/***/ }),

/***/ "./node_modules/@deephaven/log/dist/index.js":
/*!***************************************************!*\
  !*** ./node_modules/@deephaven/log/dist/index.js ***!
  \***************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Log": () => (/* reexport safe */ _Log_js__WEBPACK_IMPORTED_MODULE_1__["default"]),
/* harmony export */   "LogHistory": () => (/* reexport safe */ _LogHistory_js__WEBPACK_IMPORTED_MODULE_2__["default"]),
/* harmony export */   "LogProxy": () => (/* reexport safe */ _LogProxy_js__WEBPACK_IMPORTED_MODULE_3__["default"]),
/* harmony export */   "Logger": () => (/* reexport safe */ _Logger_js__WEBPACK_IMPORTED_MODULE_0__["default"]),
/* harmony export */   "LoggerLevel": () => (/* reexport safe */ _LoggerLevel_js__WEBPACK_IMPORTED_MODULE_4__["default"]),
/* harmony export */   "default": () => (/* reexport safe */ _Log_js__WEBPACK_IMPORTED_MODULE_1__["default"])
/* harmony export */ });
/* harmony import */ var _Logger_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Logger.js */ "./node_modules/@deephaven/log/dist/Logger.js");
/* harmony import */ var _Log_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Log.js */ "./node_modules/@deephaven/log/dist/Log.js");
/* harmony import */ var _LogHistory_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./LogHistory.js */ "./node_modules/@deephaven/log/dist/LogHistory.js");
/* harmony import */ var _LogProxy_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./LogProxy.js */ "./node_modules/@deephaven/log/dist/LogProxy.js");
/* harmony import */ var _LoggerLevel_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./LoggerLevel.js */ "./node_modules/@deephaven/log/dist/LoggerLevel.js");






//# sourceMappingURL=index.js.map

/***/ }),

/***/ "./node_modules/event-target-shim/index.mjs":
/*!**************************************************!*\
  !*** ./node_modules/event-target-shim/index.mjs ***!
  \**************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Event": () => (/* binding */ Event),
/* harmony export */   "EventTarget": () => (/* binding */ EventTarget),
/* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__),
/* harmony export */   "defineCustomEventTarget": () => (/* binding */ defineCustomEventTarget),
/* harmony export */   "defineEventAttribute": () => (/* binding */ defineEventAttribute),
/* harmony export */   "getEventAttributeValue": () => (/* binding */ getEventAttributeValue),
/* harmony export */   "setErrorHandler": () => (/* binding */ setErrorHandler),
/* harmony export */   "setEventAttributeValue": () => (/* binding */ setEventAttributeValue),
/* harmony export */   "setWarningHandler": () => (/* binding */ setWarningHandler)
/* harmony export */ });
/* provided dependency */ var process = __webpack_require__(/*! process/browser */ "./node_modules/process/browser.js");
/**
 * Assert a condition.
 * @param condition The condition that it should satisfy.
 * @param message The error message.
 * @param args The arguments for replacing placeholders in the message.
 */
function assertType(condition, message, ...args) {
    if (!condition) {
        throw new TypeError(format(message, args));
    }
}
/**
 * Convert a text and arguments to one string.
 * @param message The formating text
 * @param args The arguments.
 */
function format(message, args) {
    let i = 0;
    return message.replace(/%[os]/gu, () => anyToString(args[i++]));
}
/**
 * Convert a value to a string representation.
 * @param x The value to get the string representation.
 */
function anyToString(x) {
    if (typeof x !== "object" || x === null) {
        return String(x);
    }
    return Object.prototype.toString.call(x);
}

let currentErrorHandler;
/**
 * Set the error handler.
 * @param value The error handler to set.
 */
function setErrorHandler(value) {
    assertType(typeof value === "function" || value === undefined, "The error handler must be a function or undefined, but got %o.", value);
    currentErrorHandler = value;
}
/**
 * Print a error message.
 * @param maybeError The error object.
 */
function reportError(maybeError) {
    try {
        const error = maybeError instanceof Error
            ? maybeError
            : new Error(anyToString(maybeError));
        // Call the user-defined error handler if exists.
        if (currentErrorHandler) {
            currentErrorHandler(error);
            return;
        }
        // Dispatch an `error` event if this is on a browser.
        if (typeof dispatchEvent === "function" &&
            typeof ErrorEvent === "function") {
            dispatchEvent(new ErrorEvent("error", { error, message: error.message }));
        }
        // Emit an `uncaughtException` event if this is on Node.js.
        //istanbul ignore else
        else if (typeof process !== "undefined" &&
            typeof process.emit === "function") {
            process.emit("uncaughtException", error);
            return;
        }
        // Otherwise, print the error.
        console.error(error);
    }
    catch (_a) {
        // ignore.
    }
}

/**
 * The global object.
 */
//istanbul ignore next
const Global = typeof window !== "undefined"
    ? window
    : typeof self !== "undefined"
        ? self
        : typeof __webpack_require__.g !== "undefined"
            ? __webpack_require__.g
            : typeof globalThis !== "undefined"
                ? globalThis
                : undefined;

let currentWarnHandler;
/**
 * Set the warning handler.
 * @param value The warning handler to set.
 */
function setWarningHandler(value) {
    assertType(typeof value === "function" || value === undefined, "The warning handler must be a function or undefined, but got %o.", value);
    currentWarnHandler = value;
}
/**
 * The warning information.
 */
class Warning {
    constructor(code, message) {
        this.code = code;
        this.message = message;
    }
    /**
     * Report this warning.
     * @param args The arguments of the warning.
     */
    warn(...args) {
        var _a;
        try {
            // Call the user-defined warning handler if exists.
            if (currentWarnHandler) {
                currentWarnHandler({ ...this, args });
                return;
            }
            // Otherwise, print the warning.
            const stack = ((_a = new Error().stack) !== null && _a !== void 0 ? _a : "").replace(/^(?:.+?\n){2}/gu, "\n");
            console.warn(this.message, ...args, stack);
        }
        catch (_b) {
            // Ignore.
        }
    }
}

const InitEventWasCalledWhileDispatching = new Warning("W01", "Unable to initialize event under dispatching.");
const FalsyWasAssignedToCancelBubble = new Warning("W02", "Assigning any falsy value to 'cancelBubble' property has no effect.");
const TruthyWasAssignedToReturnValue = new Warning("W03", "Assigning any truthy value to 'returnValue' property has no effect.");
const NonCancelableEventWasCanceled = new Warning("W04", "Unable to preventDefault on non-cancelable events.");
const CanceledInPassiveListener = new Warning("W05", "Unable to preventDefault inside passive event listener invocation.");
const EventListenerWasDuplicated = new Warning("W06", "An event listener wasn't added because it has been added already: %o, %o");
const OptionWasIgnored = new Warning("W07", "The %o option value was abandoned because the event listener wasn't added as duplicated.");
const InvalidEventListener = new Warning("W08", "The 'callback' argument must be a function or an object that has 'handleEvent' method: %o");
const InvalidAttributeHandler = new Warning("W09", "Event attribute handler must be a function: %o");

/*eslint-disable class-methods-use-this */
/**
 * An implementation of `Event` interface, that wraps a given event object.
 * `EventTarget` shim can control the internal state of this `Event` objects.
 * @see https://dom.spec.whatwg.org/#event
 */
class Event {
    /**
     * @see https://dom.spec.whatwg.org/#dom-event-none
     */
    static get NONE() {
        return NONE;
    }
    /**
     * @see https://dom.spec.whatwg.org/#dom-event-capturing_phase
     */
    static get CAPTURING_PHASE() {
        return CAPTURING_PHASE;
    }
    /**
     * @see https://dom.spec.whatwg.org/#dom-event-at_target
     */
    static get AT_TARGET() {
        return AT_TARGET;
    }
    /**
     * @see https://dom.spec.whatwg.org/#dom-event-bubbling_phase
     */
    static get BUBBLING_PHASE() {
        return BUBBLING_PHASE;
    }
    /**
     * Initialize this event instance.
     * @param type The type of this event.
     * @param eventInitDict Options to initialize.
     * @see https://dom.spec.whatwg.org/#dom-event-event
     */
    constructor(type, eventInitDict) {
        Object.defineProperty(this, "isTrusted", {
            value: false,
            enumerable: true,
        });
        const opts = eventInitDict !== null && eventInitDict !== void 0 ? eventInitDict : {};
        internalDataMap.set(this, {
            type: String(type),
            bubbles: Boolean(opts.bubbles),
            cancelable: Boolean(opts.cancelable),
            composed: Boolean(opts.composed),
            target: null,
            currentTarget: null,
            stopPropagationFlag: false,
            stopImmediatePropagationFlag: false,
            canceledFlag: false,
            inPassiveListenerFlag: false,
            dispatchFlag: false,
            timeStamp: Date.now(),
        });
    }
    /**
     * The type of this event.
     * @see https://dom.spec.whatwg.org/#dom-event-type
     */
    get type() {
        return $(this).type;
    }
    /**
     * The event target of the current dispatching.
     * @see https://dom.spec.whatwg.org/#dom-event-target
     */
    get target() {
        return $(this).target;
    }
    /**
     * The event target of the current dispatching.
     * @deprecated Use the `target` property instead.
     * @see https://dom.spec.whatwg.org/#dom-event-srcelement
     */
    get srcElement() {
        return $(this).target;
    }
    /**
     * The event target of the current dispatching.
     * @see https://dom.spec.whatwg.org/#dom-event-currenttarget
     */
    get currentTarget() {
        return $(this).currentTarget;
    }
    /**
     * The event target of the current dispatching.
     * This doesn't support node tree.
     * @see https://dom.spec.whatwg.org/#dom-event-composedpath
     */
    composedPath() {
        const currentTarget = $(this).currentTarget;
        if (currentTarget) {
            return [currentTarget];
        }
        return [];
    }
    /**
     * @see https://dom.spec.whatwg.org/#dom-event-none
     */
    get NONE() {
        return NONE;
    }
    /**
     * @see https://dom.spec.whatwg.org/#dom-event-capturing_phase
     */
    get CAPTURING_PHASE() {
        return CAPTURING_PHASE;
    }
    /**
     * @see https://dom.spec.whatwg.org/#dom-event-at_target
     */
    get AT_TARGET() {
        return AT_TARGET;
    }
    /**
     * @see https://dom.spec.whatwg.org/#dom-event-bubbling_phase
     */
    get BUBBLING_PHASE() {
        return BUBBLING_PHASE;
    }
    /**
     * The current event phase.
     * @see https://dom.spec.whatwg.org/#dom-event-eventphase
     */
    get eventPhase() {
        return $(this).dispatchFlag ? 2 : 0;
    }
    /**
     * Stop event bubbling.
     * Because this shim doesn't support node tree, this merely changes the `cancelBubble` property value.
     * @see https://dom.spec.whatwg.org/#dom-event-stoppropagation
     */
    stopPropagation() {
        $(this).stopPropagationFlag = true;
    }
    /**
     * `true` if event bubbling was stopped.
     * @deprecated
     * @see https://dom.spec.whatwg.org/#dom-event-cancelbubble
     */
    get cancelBubble() {
        return $(this).stopPropagationFlag;
    }
    /**
     * Stop event bubbling if `true` is set.
     * @deprecated Use the `stopPropagation()` method instead.
     * @see https://dom.spec.whatwg.org/#dom-event-cancelbubble
     */
    set cancelBubble(value) {
        if (value) {
            $(this).stopPropagationFlag = true;
        }
        else {
            FalsyWasAssignedToCancelBubble.warn();
        }
    }
    /**
     * Stop event bubbling and subsequent event listener callings.
     * @see https://dom.spec.whatwg.org/#dom-event-stopimmediatepropagation
     */
    stopImmediatePropagation() {
        const data = $(this);
        data.stopPropagationFlag = data.stopImmediatePropagationFlag = true;
    }
    /**
     * `true` if this event will bubble.
     * @see https://dom.spec.whatwg.org/#dom-event-bubbles
     */
    get bubbles() {
        return $(this).bubbles;
    }
    /**
     * `true` if this event can be canceled by the `preventDefault()` method.
     * @see https://dom.spec.whatwg.org/#dom-event-cancelable
     */
    get cancelable() {
        return $(this).cancelable;
    }
    /**
     * `true` if the default behavior will act.
     * @deprecated Use the `defaultPrevented` proeprty instead.
     * @see https://dom.spec.whatwg.org/#dom-event-returnvalue
     */
    get returnValue() {
        return !$(this).canceledFlag;
    }
    /**
     * Cancel the default behavior if `false` is set.
     * @deprecated Use the `preventDefault()` method instead.
     * @see https://dom.spec.whatwg.org/#dom-event-returnvalue
     */
    set returnValue(value) {
        if (!value) {
            setCancelFlag($(this));
        }
        else {
            TruthyWasAssignedToReturnValue.warn();
        }
    }
    /**
     * Cancel the default behavior.
     * @see https://dom.spec.whatwg.org/#dom-event-preventdefault
     */
    preventDefault() {
        setCancelFlag($(this));
    }
    /**
     * `true` if the default behavior was canceled.
     * @see https://dom.spec.whatwg.org/#dom-event-defaultprevented
     */
    get defaultPrevented() {
        return $(this).canceledFlag;
    }
    /**
     * @see https://dom.spec.whatwg.org/#dom-event-composed
     */
    get composed() {
        return $(this).composed;
    }
    /**
     * @see https://dom.spec.whatwg.org/#dom-event-istrusted
     */
    //istanbul ignore next
    get isTrusted() {
        return false;
    }
    /**
     * @see https://dom.spec.whatwg.org/#dom-event-timestamp
     */
    get timeStamp() {
        return $(this).timeStamp;
    }
    /**
     * @deprecated Don't use this method. The constructor did initialization.
     */
    initEvent(type, bubbles = false, cancelable = false) {
        const data = $(this);
        if (data.dispatchFlag) {
            InitEventWasCalledWhileDispatching.warn();
            return;
        }
        internalDataMap.set(this, {
            ...data,
            type: String(type),
            bubbles: Boolean(bubbles),
            cancelable: Boolean(cancelable),
            target: null,
            currentTarget: null,
            stopPropagationFlag: false,
            stopImmediatePropagationFlag: false,
            canceledFlag: false,
        });
    }
}
//------------------------------------------------------------------------------
// Helpers
//------------------------------------------------------------------------------
const NONE = 0;
const CAPTURING_PHASE = 1;
const AT_TARGET = 2;
const BUBBLING_PHASE = 3;
/**
 * Private data for event wrappers.
 */
const internalDataMap = new WeakMap();
/**
 * Get private data.
 * @param event The event object to get private data.
 * @param name The variable name to report.
 * @returns The private data of the event.
 */
function $(event, name = "this") {
    const retv = internalDataMap.get(event);
    assertType(retv != null, "'%s' must be an object that Event constructor created, but got another one: %o", name, event);
    return retv;
}
/**
 * https://dom.spec.whatwg.org/#set-the-canceled-flag
 * @param data private data.
 */
function setCancelFlag(data) {
    if (data.inPassiveListenerFlag) {
        CanceledInPassiveListener.warn();
        return;
    }
    if (!data.cancelable) {
        NonCancelableEventWasCanceled.warn();
        return;
    }
    data.canceledFlag = true;
}
// Set enumerable
Object.defineProperty(Event, "NONE", { enumerable: true });
Object.defineProperty(Event, "CAPTURING_PHASE", { enumerable: true });
Object.defineProperty(Event, "AT_TARGET", { enumerable: true });
Object.defineProperty(Event, "BUBBLING_PHASE", { enumerable: true });
const keys = Object.getOwnPropertyNames(Event.prototype);
for (let i = 0; i < keys.length; ++i) {
    if (keys[i] === "constructor") {
        continue;
    }
    Object.defineProperty(Event.prototype, keys[i], { enumerable: true });
}
// Ensure `event instanceof window.Event` is `true`.
if (typeof Global !== "undefined" && typeof Global.Event !== "undefined") {
    Object.setPrototypeOf(Event.prototype, Global.Event.prototype);
}

/**
 * Create a new InvalidStateError instance.
 * @param message The error message.
 */
function createInvalidStateError(message) {
    if (Global.DOMException) {
        return new Global.DOMException(message, "InvalidStateError");
    }
    if (DOMException == null) {
        DOMException = class DOMException extends Error {
            constructor(msg) {
                super(msg);
                if (Error.captureStackTrace) {
                    Error.captureStackTrace(this, DOMException);
                }
            }
            // eslint-disable-next-line class-methods-use-this
            get code() {
                return 11;
            }
            // eslint-disable-next-line class-methods-use-this
            get name() {
                return "InvalidStateError";
            }
        };
        Object.defineProperties(DOMException.prototype, {
            code: { enumerable: true },
            name: { enumerable: true },
        });
        defineErrorCodeProperties(DOMException);
        defineErrorCodeProperties(DOMException.prototype);
    }
    return new DOMException(message);
}
//------------------------------------------------------------------------------
// Helpers
//------------------------------------------------------------------------------
let DOMException;
const ErrorCodeMap = {
    INDEX_SIZE_ERR: 1,
    DOMSTRING_SIZE_ERR: 2,
    HIERARCHY_REQUEST_ERR: 3,
    WRONG_DOCUMENT_ERR: 4,
    INVALID_CHARACTER_ERR: 5,
    NO_DATA_ALLOWED_ERR: 6,
    NO_MODIFICATION_ALLOWED_ERR: 7,
    NOT_FOUND_ERR: 8,
    NOT_SUPPORTED_ERR: 9,
    INUSE_ATTRIBUTE_ERR: 10,
    INVALID_STATE_ERR: 11,
    SYNTAX_ERR: 12,
    INVALID_MODIFICATION_ERR: 13,
    NAMESPACE_ERR: 14,
    INVALID_ACCESS_ERR: 15,
    VALIDATION_ERR: 16,
    TYPE_MISMATCH_ERR: 17,
    SECURITY_ERR: 18,
    NETWORK_ERR: 19,
    ABORT_ERR: 20,
    URL_MISMATCH_ERR: 21,
    QUOTA_EXCEEDED_ERR: 22,
    TIMEOUT_ERR: 23,
    INVALID_NODE_TYPE_ERR: 24,
    DATA_CLONE_ERR: 25,
};
function defineErrorCodeProperties(obj) {
    const keys = Object.keys(ErrorCodeMap);
    for (let i = 0; i < keys.length; ++i) {
        const key = keys[i];
        const value = ErrorCodeMap[key];
        Object.defineProperty(obj, key, {
            get() {
                return value;
            },
            configurable: true,
            enumerable: true,
        });
    }
}

/**
 * An implementation of `Event` interface, that wraps a given event object.
 * This class controls the internal state of `Event`.
 * @see https://dom.spec.whatwg.org/#interface-event
 */
class EventWrapper extends Event {
    /**
     * Wrap a given event object to control states.
     * @param event The event-like object to wrap.
     */
    static wrap(event) {
        return new (getWrapperClassOf(event))(event);
    }
    constructor(event) {
        super(event.type, {
            bubbles: event.bubbles,
            cancelable: event.cancelable,
            composed: event.composed,
        });
        if (event.cancelBubble) {
            super.stopPropagation();
        }
        if (event.defaultPrevented) {
            super.preventDefault();
        }
        internalDataMap$1.set(this, { original: event });
        // Define accessors
        const keys = Object.keys(event);
        for (let i = 0; i < keys.length; ++i) {
            const key = keys[i];
            if (!(key in this)) {
                Object.defineProperty(this, key, defineRedirectDescriptor(event, key));
            }
        }
    }
    stopPropagation() {
        super.stopPropagation();
        const { original } = $$1(this);
        if ("stopPropagation" in original) {
            original.stopPropagation();
        }
    }
    get cancelBubble() {
        return super.cancelBubble;
    }
    set cancelBubble(value) {
        super.cancelBubble = value;
        const { original } = $$1(this);
        if ("cancelBubble" in original) {
            original.cancelBubble = value;
        }
    }
    stopImmediatePropagation() {
        super.stopImmediatePropagation();
        const { original } = $$1(this);
        if ("stopImmediatePropagation" in original) {
            original.stopImmediatePropagation();
        }
    }
    get returnValue() {
        return super.returnValue;
    }
    set returnValue(value) {
        super.returnValue = value;
        const { original } = $$1(this);
        if ("returnValue" in original) {
            original.returnValue = value;
        }
    }
    preventDefault() {
        super.preventDefault();
        const { original } = $$1(this);
        if ("preventDefault" in original) {
            original.preventDefault();
        }
    }
    get timeStamp() {
        const { original } = $$1(this);
        if ("timeStamp" in original) {
            return original.timeStamp;
        }
        return super.timeStamp;
    }
}
/**
 * Private data for event wrappers.
 */
const internalDataMap$1 = new WeakMap();
/**
 * Get private data.
 * @param event The event object to get private data.
 * @returns The private data of the event.
 */
function $$1(event) {
    const retv = internalDataMap$1.get(event);
    assertType(retv != null, "'this' is expected an Event object, but got", event);
    return retv;
}
/**
 * Cache for wrapper classes.
 * @type {WeakMap<Object, Function>}
 * @private
 */
const wrapperClassCache = new WeakMap();
// Make association for wrappers.
wrapperClassCache.set(Object.prototype, EventWrapper);
if (typeof Global !== "undefined" && typeof Global.Event !== "undefined") {
    wrapperClassCache.set(Global.Event.prototype, EventWrapper);
}
/**
 * Get the wrapper class of a given prototype.
 * @param originalEvent The event object to wrap.
 */
function getWrapperClassOf(originalEvent) {
    const prototype = Object.getPrototypeOf(originalEvent);
    if (prototype == null) {
        return EventWrapper;
    }
    let wrapper = wrapperClassCache.get(prototype);
    if (wrapper == null) {
        wrapper = defineWrapper(getWrapperClassOf(prototype), prototype);
        wrapperClassCache.set(prototype, wrapper);
    }
    return wrapper;
}
/**
 * Define new wrapper class.
 * @param BaseEventWrapper The base wrapper class.
 * @param originalPrototype The prototype of the original event.
 */
function defineWrapper(BaseEventWrapper, originalPrototype) {
    class CustomEventWrapper extends BaseEventWrapper {
    }
    const keys = Object.keys(originalPrototype);
    for (let i = 0; i < keys.length; ++i) {
        Object.defineProperty(CustomEventWrapper.prototype, keys[i], defineRedirectDescriptor(originalPrototype, keys[i]));
    }
    return CustomEventWrapper;
}
/**
 * Get the property descriptor to redirect a given property.
 */
function defineRedirectDescriptor(obj, key) {
    const d = Object.getOwnPropertyDescriptor(obj, key);
    return {
        get() {
            const original = $$1(this).original;
            const value = original[key];
            if (typeof value === "function") {
                return value.bind(original);
            }
            return value;
        },
        set(value) {
            const original = $$1(this).original;
            original[key] = value;
        },
        configurable: d.configurable,
        enumerable: d.enumerable,
    };
}

/**
 * Create a new listener.
 * @param callback The callback function.
 * @param capture The capture flag.
 * @param passive The passive flag.
 * @param once The once flag.
 * @param signal The abort signal.
 * @param signalListener The abort event listener for the abort signal.
 */
function createListener(callback, capture, passive, once, signal, signalListener) {
    return {
        callback,
        flags: (capture ? 1 /* Capture */ : 0) |
            (passive ? 2 /* Passive */ : 0) |
            (once ? 4 /* Once */ : 0),
        signal,
        signalListener,
    };
}
/**
 * Set the `removed` flag to the given listener.
 * @param listener The listener to check.
 */
function setRemoved(listener) {
    listener.flags |= 8 /* Removed */;
}
/**
 * Check if the given listener has the `capture` flag or not.
 * @param listener The listener to check.
 */
function isCapture(listener) {
    return (listener.flags & 1 /* Capture */) === 1 /* Capture */;
}
/**
 * Check if the given listener has the `passive` flag or not.
 * @param listener The listener to check.
 */
function isPassive(listener) {
    return (listener.flags & 2 /* Passive */) === 2 /* Passive */;
}
/**
 * Check if the given listener has the `once` flag or not.
 * @param listener The listener to check.
 */
function isOnce(listener) {
    return (listener.flags & 4 /* Once */) === 4 /* Once */;
}
/**
 * Check if the given listener has the `removed` flag or not.
 * @param listener The listener to check.
 */
function isRemoved(listener) {
    return (listener.flags & 8 /* Removed */) === 8 /* Removed */;
}
/**
 * Call an event listener.
 * @param listener The listener to call.
 * @param target The event target object for `thisArg`.
 * @param event The event object for the first argument.
 * @param attribute `true` if this callback is an event attribute handler.
 */
function invokeCallback({ callback }, target, event) {
    try {
        if (typeof callback === "function") {
            callback.call(target, event);
        }
        else if (typeof callback.handleEvent === "function") {
            callback.handleEvent(event);
        }
    }
    catch (thrownError) {
        reportError(thrownError);
    }
}

/**
 * Find the index of given listener.
 * This returns `-1` if not found.
 * @param list The listener list.
 * @param callback The callback function to find.
 * @param capture The capture flag to find.
 */
function findIndexOfListener({ listeners }, callback, capture) {
    for (let i = 0; i < listeners.length; ++i) {
        if (listeners[i].callback === callback &&
            isCapture(listeners[i]) === capture) {
            return i;
        }
    }
    return -1;
}
/**
 * Add the given listener.
 * Does copy-on-write if needed.
 * @param list The listener list.
 * @param callback The callback function.
 * @param capture The capture flag.
 * @param passive The passive flag.
 * @param once The once flag.
 * @param signal The abort signal.
 */
function addListener(list, callback, capture, passive, once, signal) {
    let signalListener;
    if (signal) {
        signalListener = removeListener.bind(null, list, callback, capture);
        signal.addEventListener("abort", signalListener);
    }
    const listener = createListener(callback, capture, passive, once, signal, signalListener);
    if (list.cow) {
        list.cow = false;
        list.listeners = [...list.listeners, listener];
    }
    else {
        list.listeners.push(listener);
    }
    return listener;
}
/**
 * Remove a listener.
 * @param list The listener list.
 * @param callback The callback function to find.
 * @param capture The capture flag to find.
 * @returns `true` if it mutated the list directly.
 */
function removeListener(list, callback, capture) {
    const index = findIndexOfListener(list, callback, capture);
    if (index !== -1) {
        return removeListenerAt(list, index);
    }
    return false;
}
/**
 * Remove a listener.
 * @param list The listener list.
 * @param index The index of the target listener.
 * @param disableCow Disable copy-on-write if true.
 * @returns `true` if it mutated the `listeners` array directly.
 */
function removeListenerAt(list, index, disableCow = false) {
    const listener = list.listeners[index];
    // Set the removed flag.
    setRemoved(listener);
    // Dispose the abort signal listener if exists.
    if (listener.signal) {
        listener.signal.removeEventListener("abort", listener.signalListener);
    }
    // Remove it from the array.
    if (list.cow && !disableCow) {
        list.cow = false;
        list.listeners = list.listeners.filter((_, i) => i !== index);
        return false;
    }
    list.listeners.splice(index, 1);
    return true;
}

/**
 * Create a new `ListenerListMap` object.
 */
function createListenerListMap() {
    return Object.create(null);
}
/**
 * Get the listener list of the given type.
 * If the listener list has not been initialized, initialize and return it.
 * @param listenerMap The listener list map.
 * @param type The event type to get.
 */
function ensureListenerList(listenerMap, type) {
    var _a;
    return ((_a = listenerMap[type]) !== null && _a !== void 0 ? _a : (listenerMap[type] = {
        attrCallback: undefined,
        attrListener: undefined,
        cow: false,
        listeners: [],
    }));
}

/**
 * An implementation of the `EventTarget` interface.
 * @see https://dom.spec.whatwg.org/#eventtarget
 */
class EventTarget {
    /**
     * Initialize this instance.
     */
    constructor() {
        internalDataMap$2.set(this, createListenerListMap());
    }
    // Implementation
    addEventListener(type0, callback0, options0) {
        const listenerMap = $$2(this);
        const { callback, capture, once, passive, signal, type, } = normalizeAddOptions(type0, callback0, options0);
        if (callback == null || (signal === null || signal === void 0 ? void 0 : signal.aborted)) {
            return;
        }
        const list = ensureListenerList(listenerMap, type);
        // Find existing listener.
        const i = findIndexOfListener(list, callback, capture);
        if (i !== -1) {
            warnDuplicate(list.listeners[i], passive, once, signal);
            return;
        }
        // Add the new listener.
        addListener(list, callback, capture, passive, once, signal);
    }
    // Implementation
    removeEventListener(type0, callback0, options0) {
        const listenerMap = $$2(this);
        const { callback, capture, type } = normalizeOptions(type0, callback0, options0);
        const list = listenerMap[type];
        if (callback != null && list) {
            removeListener(list, callback, capture);
        }
    }
    // Implementation
    dispatchEvent(e) {
        const list = $$2(this)[String(e.type)];
        if (list == null) {
            return true;
        }
        const event = e instanceof Event ? e : EventWrapper.wrap(e);
        const eventData = $(event, "event");
        if (eventData.dispatchFlag) {
            throw createInvalidStateError("This event has been in dispatching.");
        }
        eventData.dispatchFlag = true;
        eventData.target = eventData.currentTarget = this;
        if (!eventData.stopPropagationFlag) {
            const { cow, listeners } = list;
            // Set copy-on-write flag.
            list.cow = true;
            // Call listeners.
            for (let i = 0; i < listeners.length; ++i) {
                const listener = listeners[i];
                // Skip if removed.
                if (isRemoved(listener)) {
                    continue;
                }
                // Remove this listener if has the `once` flag.
                if (isOnce(listener) && removeListenerAt(list, i, !cow)) {
                    // Because this listener was removed, the next index is the
                    // same as the current value.
                    i -= 1;
                }
                // Call this listener with the `passive` flag.
                eventData.inPassiveListenerFlag = isPassive(listener);
                invokeCallback(listener, this, event);
                eventData.inPassiveListenerFlag = false;
                // Stop if the `event.stopImmediatePropagation()` method was called.
                if (eventData.stopImmediatePropagationFlag) {
                    break;
                }
            }
            // Restore copy-on-write flag.
            if (!cow) {
                list.cow = false;
            }
        }
        eventData.target = null;
        eventData.currentTarget = null;
        eventData.stopImmediatePropagationFlag = false;
        eventData.stopPropagationFlag = false;
        eventData.dispatchFlag = false;
        return !eventData.canceledFlag;
    }
}
/**
 * Internal data.
 */
const internalDataMap$2 = new WeakMap();
/**
 * Get private data.
 * @param target The event target object to get private data.
 * @param name The variable name to report.
 * @returns The private data of the event.
 */
function $$2(target, name = "this") {
    const retv = internalDataMap$2.get(target);
    assertType(retv != null, "'%s' must be an object that EventTarget constructor created, but got another one: %o", name, target);
    return retv;
}
/**
 * Normalize options.
 * @param options The options to normalize.
 */
function normalizeAddOptions(type, callback, options) {
    var _a;
    assertCallback(callback);
    if (typeof options === "object" && options !== null) {
        return {
            type: String(type),
            callback: callback !== null && callback !== void 0 ? callback : undefined,
            capture: Boolean(options.capture),
            passive: Boolean(options.passive),
            once: Boolean(options.once),
            signal: (_a = options.signal) !== null && _a !== void 0 ? _a : undefined,
        };
    }
    return {
        type: String(type),
        callback: callback !== null && callback !== void 0 ? callback : undefined,
        capture: Boolean(options),
        passive: false,
        once: false,
        signal: undefined,
    };
}
/**
 * Normalize options.
 * @param options The options to normalize.
 */
function normalizeOptions(type, callback, options) {
    assertCallback(callback);
    if (typeof options === "object" && options !== null) {
        return {
            type: String(type),
            callback: callback !== null && callback !== void 0 ? callback : undefined,
            capture: Boolean(options.capture),
        };
    }
    return {
        type: String(type),
        callback: callback !== null && callback !== void 0 ? callback : undefined,
        capture: Boolean(options),
    };
}
/**
 * Assert the type of 'callback' argument.
 * @param callback The callback to check.
 */
function assertCallback(callback) {
    if (typeof callback === "function" ||
        (typeof callback === "object" &&
            callback !== null &&
            typeof callback.handleEvent === "function")) {
        return;
    }
    if (callback == null || typeof callback === "object") {
        InvalidEventListener.warn(callback);
        return;
    }
    throw new TypeError(format(InvalidEventListener.message, [callback]));
}
/**
 * Print warning for duplicated.
 * @param listener The current listener that is duplicated.
 * @param passive The passive flag of the new duplicated listener.
 * @param once The once flag of the new duplicated listener.
 * @param signal The signal object of the new duplicated listener.
 */
function warnDuplicate(listener, passive, once, signal) {
    EventListenerWasDuplicated.warn(isCapture(listener) ? "capture" : "bubble", listener.callback);
    if (isPassive(listener) !== passive) {
        OptionWasIgnored.warn("passive");
    }
    if (isOnce(listener) !== once) {
        OptionWasIgnored.warn("once");
    }
    if (listener.signal !== signal) {
        OptionWasIgnored.warn("signal");
    }
}
// Set enumerable
const keys$1 = Object.getOwnPropertyNames(EventTarget.prototype);
for (let i = 0; i < keys$1.length; ++i) {
    if (keys$1[i] === "constructor") {
        continue;
    }
    Object.defineProperty(EventTarget.prototype, keys$1[i], { enumerable: true });
}
// Ensure `eventTarget instanceof window.EventTarget` is `true`.
if (typeof Global !== "undefined" &&
    typeof Global.EventTarget !== "undefined") {
    Object.setPrototypeOf(EventTarget.prototype, Global.EventTarget.prototype);
}

/**
 * Get the current value of a given event attribute.
 * @param target The `EventTarget` object to get.
 * @param type The event type.
 */
function getEventAttributeValue(target, type) {
    var _a, _b;
    const listMap = $$2(target, "target");
    return (_b = (_a = listMap[type]) === null || _a === void 0 ? void 0 : _a.attrCallback) !== null && _b !== void 0 ? _b : null;
}
/**
 * Set an event listener to a given event attribute.
 * @param target The `EventTarget` object to set.
 * @param type The event type.
 * @param callback The event listener.
 */
function setEventAttributeValue(target, type, callback) {
    if (callback != null && typeof callback !== "function") {
        InvalidAttributeHandler.warn(callback);
    }
    if (typeof callback === "function" ||
        (typeof callback === "object" && callback !== null)) {
        upsertEventAttributeListener(target, type, callback);
    }
    else {
        removeEventAttributeListener(target, type);
    }
}
//------------------------------------------------------------------------------
// Helpers
//------------------------------------------------------------------------------
/**
 * Update or insert the given event attribute handler.
 * @param target The `EventTarget` object to set.
 * @param type The event type.
 * @param callback The event listener.
 */
function upsertEventAttributeListener(target, type, callback) {
    const list = ensureListenerList($$2(target, "target"), String(type));
    list.attrCallback = callback;
    if (list.attrListener == null) {
        list.attrListener = addListener(list, defineEventAttributeCallback(list), false, false, false, undefined);
    }
}
/**
 * Remove the given event attribute handler.
 * @param target The `EventTarget` object to remove.
 * @param type The event type.
 * @param callback The event listener.
 */
function removeEventAttributeListener(target, type) {
    const listMap = $$2(target, "target");
    const list = listMap[String(type)];
    if (list && list.attrListener) {
        removeListener(list, list.attrListener.callback, false);
        list.attrCallback = list.attrListener = undefined;
    }
}
/**
 * Define the callback function for the given listener list object.
 * It calls `attrCallback` property if the property value is a function.
 * @param list The `ListenerList` object.
 */
function defineEventAttributeCallback(list) {
    return function (event) {
        const callback = list.attrCallback;
        if (typeof callback === "function") {
            callback.call(this, event);
        }
    };
}

/**
 * Define an `EventTarget` class that has event attibutes.
 * @param types The types to define event attributes.
 * @deprecated Use `getEventAttributeValue`/`setEventAttributeValue` pair on your derived class instead because of static analysis friendly.
 */
function defineCustomEventTarget(...types) {
    class CustomEventTarget extends EventTarget {
    }
    for (let i = 0; i < types.length; ++i) {
        defineEventAttribute(CustomEventTarget.prototype, types[i]);
    }
    return CustomEventTarget;
}
/**
 * Define an event attribute.
 * @param target The `EventTarget` object to define an event attribute.
 * @param type The event type to define.
 * @param _eventClass Unused, but to infer `Event` class type.
 * @deprecated Use `getEventAttributeValue`/`setEventAttributeValue` pair on your derived class instead because of static analysis friendly.
 */
function defineEventAttribute(target, type, _eventClass) {
    Object.defineProperty(target, `on${type}`, {
        get() {
            return getEventAttributeValue(this, type);
        },
        set(value) {
            setEventAttributeValue(this, type, value);
        },
        configurable: true,
        enumerable: true,
    });
}

/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (EventTarget);

//# sourceMappingURL=index.mjs.map


/***/ }),

/***/ "./node_modules/process/browser.js":
/*!*****************************************!*\
  !*** ./node_modules/process/browser.js ***!
  \*****************************************/
/***/ ((module) => {

// shim for using process in browser
var process = module.exports = {};

// cached from whatever global is present so that test runners that stub it
// don't break things.  But we need to wrap it in a try catch in case it is
// wrapped in strict mode code which doesn't define any globals.  It's inside a
// function because try/catches deoptimize in certain engines.

var cachedSetTimeout;
var cachedClearTimeout;

function defaultSetTimout() {
    throw new Error('setTimeout has not been defined');
}
function defaultClearTimeout () {
    throw new Error('clearTimeout has not been defined');
}
(function () {
    try {
        if (typeof setTimeout === 'function') {
            cachedSetTimeout = setTimeout;
        } else {
            cachedSetTimeout = defaultSetTimout;
        }
    } catch (e) {
        cachedSetTimeout = defaultSetTimout;
    }
    try {
        if (typeof clearTimeout === 'function') {
            cachedClearTimeout = clearTimeout;
        } else {
            cachedClearTimeout = defaultClearTimeout;
        }
    } catch (e) {
        cachedClearTimeout = defaultClearTimeout;
    }
} ())
function runTimeout(fun) {
    if (cachedSetTimeout === setTimeout) {
        //normal enviroments in sane situations
        return setTimeout(fun, 0);
    }
    // if setTimeout wasn't available but was latter defined
    if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
        cachedSetTimeout = setTimeout;
        return setTimeout(fun, 0);
    }
    try {
        // when when somebody has screwed with setTimeout but no I.E. maddness
        return cachedSetTimeout(fun, 0);
    } catch(e){
        try {
            // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
            return cachedSetTimeout.call(null, fun, 0);
        } catch(e){
            // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
            return cachedSetTimeout.call(this, fun, 0);
        }
    }


}
function runClearTimeout(marker) {
    if (cachedClearTimeout === clearTimeout) {
        //normal enviroments in sane situations
        return clearTimeout(marker);
    }
    // if clearTimeout wasn't available but was latter defined
    if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
        cachedClearTimeout = clearTimeout;
        return clearTimeout(marker);
    }
    try {
        // when when somebody has screwed with setTimeout but no I.E. maddness
        return cachedClearTimeout(marker);
    } catch (e){
        try {
            // When we are in I.E. but the script has been evaled so I.E. doesn't  trust the global object when called normally
            return cachedClearTimeout.call(null, marker);
        } catch (e){
            // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
            // Some versions of I.E. have different rules for clearTimeout vs setTimeout
            return cachedClearTimeout.call(this, marker);
        }
    }



}
var queue = [];
var draining = false;
var currentQueue;
var queueIndex = -1;

function cleanUpNextTick() {
    if (!draining || !currentQueue) {
        return;
    }
    draining = false;
    if (currentQueue.length) {
        queue = currentQueue.concat(queue);
    } else {
        queueIndex = -1;
    }
    if (queue.length) {
        drainQueue();
    }
}

function drainQueue() {
    if (draining) {
        return;
    }
    var timeout = runTimeout(cleanUpNextTick);
    draining = true;

    var len = queue.length;
    while(len) {
        currentQueue = queue;
        queue = [];
        while (++queueIndex < len) {
            if (currentQueue) {
                currentQueue[queueIndex].run();
            }
        }
        queueIndex = -1;
        len = queue.length;
    }
    currentQueue = null;
    draining = false;
    runClearTimeout(timeout);
}

process.nextTick = function (fun) {
    var args = new Array(arguments.length - 1);
    if (arguments.length > 1) {
        for (var i = 1; i < arguments.length; i++) {
            args[i - 1] = arguments[i];
        }
    }
    queue.push(new Item(fun, args));
    if (queue.length === 1 && !draining) {
        runTimeout(drainQueue);
    }
};

// v8 likes predictible objects
function Item(fun, array) {
    this.fun = fun;
    this.array = array;
}
Item.prototype.run = function () {
    this.fun.apply(null, this.array);
};
process.title = 'browser';
process.browser = true;
process.env = {};
process.argv = [];
process.version = ''; // empty string to avoid regexp issues
process.versions = {};

function noop() {}

process.on = noop;
process.addListener = noop;
process.once = noop;
process.off = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;
process.prependListener = noop;
process.prependOnceListener = noop;

process.listeners = function (name) { return [] }

process.binding = function (name) {
    throw new Error('process.binding is not supported');
};

process.cwd = function () { return '/' };
process.chdir = function (dir) {
    throw new Error('process.chdir is not supported');
};
process.umask = function() { return 0; };


/***/ })

}]);
//# sourceMappingURL=vendors-node_modules_deephaven_log_dist_index_js.093c7e74202c92137c2c.js.map