(function (_, kotlin_kotlin, kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core) {
  'use strict';
  //region block: imports
  var VOID = kotlin_kotlin.$_$.f;
  var Unit_instance = kotlin_kotlin.$_$.m5;
  var intercepted = kotlin_kotlin.$_$.ja;
  var get_MODE_CANCELLABLE = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.c2;
  var CancellableContinuationImpl = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.t1;
  var resume = kotlin_kotlin.$_$.xa;
  var resumeWithException = kotlin_kotlin.$_$.wa;
  //endregion
  //region block: pre-declaration
  //endregion
  function addEventListener(_this__u8e3s4, type, handler, options) {
    options = options === VOID ? undefined : options;
    _this__u8e3s4.addEventListener(type, handler, options);
  }
  function removeEventListener(_this__u8e3s4, type, handler, options) {
    options = options === VOID ? undefined : options;
    _this__u8e3s4.removeEventListener(type, handler, options);
  }
  function addEventListener_0(_this__u8e3s4, type, handler, options) {
    options = options === VOID ? undefined : options;
    _this__u8e3s4.addEventListener(type, handler, options);
  }
  function removeEventListener_0(_this__u8e3s4, type, handler, options) {
    options = options === VOID ? undefined : options;
    _this__u8e3s4.removeEventListener(type, handler, options);
  }
  function toAbortSignal(_this__u8e3s4) {
    var controller = new AbortController();
    _this__u8e3s4.cu(toAbortSignal$lambda(controller));
    return controller.signal;
  }
  function toAbortSignal$lambda($controller) {
    return function (it) {
      $controller.abort();
      return Unit_instance;
    };
  }
  function fetch_0(input, $completion) {
    return fetch_1(new Request(input), $completion);
  }
  function fetch_1(input, $completion) {
    // Inline function 'kotlinx.coroutines.suspendCancellableCoroutine.<anonymous>' call
    var cancellable = new CancellableContinuationImpl(intercepted($completion), get_MODE_CANCELLABLE());
    cancellable.bu();
    // Inline function 'web.http.fetch.<anonymous>' call
    // Inline function 'js.objects.jso' call
    // Inline function 'kotlin.apply' call
    // Inline function 'js.objects.jso' call
    var this_0 = {};
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'web.http.fetch.<anonymous>.<anonymous>' call
    this_0.signal = toAbortSignal(cancellable);
    var request = new Request(input, this_0);
    // Inline function 'js.promise.catch' call
    var tmp = fetch(request);
    var this_1 = tmp.then(resume$ref(cancellable));
    var onRejected = resumeWithException$ref(cancellable);
    this_1.catch(onRejected);
    return cancellable.du();
  }
  function resume$ref($boundThis) {
    var l = function (p0) {
      resume($boundThis, p0);
      return Unit_instance;
    };
    l.callableName = 'resume';
    return l;
  }
  function resumeWithException$ref($boundThis) {
    var l = function (p0) {
      resumeWithException($boundThis, p0);
      return Unit_instance;
    };
    l.callableName = 'resumeWithException';
    return l;
  }
  //region block: exports
  _.$_$ = _.$_$ || {};
  _.$_$.a = fetch_0;
  _.$_$.b = addEventListener;
  _.$_$.c = addEventListener_0;
  _.$_$.d = removeEventListener;
  _.$_$.e = removeEventListener_0;
  //endregion
  return _;
}(module.exports, require('./kotlin-kotlin-stdlib.js'), require('./kotlinx-coroutines-core.js')));

//# sourceMappingURL=kotlin-web.js.map
