(function (_, kotlin_kotlin, kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core) {
  'use strict';
  //region block: imports
  var constructor = (class IteratorYieldResult {
    static [Symbol.hasInstance](instance) {
        return instance && (typeof instance === 'object') && (instance.done === false)
    }
    }.prototype).constructor;
  var CoroutineImpl = kotlin_kotlin.$_$.td;
  var await_0 = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.m;
  var get_COROUTINE_SUSPENDED = kotlin_kotlin.$_$.ed;
  var protoOf = kotlin_kotlin.$_$.dg;
  var classMeta = kotlin_kotlin.$_$.oe;
  var setMetadataFor = kotlin_kotlin.$_$.eg;
  var Unit_getInstance = kotlin_kotlin.$_$.i6;
  var toString = kotlin_kotlin.$_$.ig;
  var IllegalStateException_init_$Create$ = kotlin_kotlin.$_$.m2;
  var THROW_CCE = kotlin_kotlin.$_$.rm;
  var VOID = kotlin_kotlin.$_$.g;
  var toSet = kotlin_kotlin.$_$.wc;
  var iterator = kotlin_kotlin.$_$.yh;
  var SequenceScope = kotlin_kotlin.$_$.ph;
  var SuspendFunction1 = kotlin_kotlin.$_$.vd;
  var interfaceMeta = kotlin_kotlin.$_$.ef;
  var Annotation = kotlin_kotlin.$_$.tl;
  //endregion
  //region block: pre-declaration
  setMetadataFor($hasNextCOROUTINE$0, '$hasNextCOROUTINE$0', classMeta, CoroutineImpl);
  setMetadataFor(SuspendableIterator, 'SuspendableIterator', interfaceMeta, VOID, VOID, VOID, VOID, VOID, [0]);
  setMetadataFor(AsyncIteratorAdapter, 'AsyncIteratorAdapter', classMeta, VOID, [SuspendableIterator], VOID, VOID, VOID, [0]);
  setMetadataFor(iteratorFor$slambda, 'iteratorFor$slambda', classMeta, CoroutineImpl, [CoroutineImpl], VOID, VOID, VOID, [1]);
  setMetadataFor(JsPlainObject, 'JsPlainObject', classMeta, VOID, [Annotation]);
  setMetadataFor(JsoDsl, 'JsoDsl', classMeta, VOID, [Annotation]);
  //endregion
  function tupleOf(first, second) {
    // Inline function 'kotlin.js.unsafeCast' call
    // Inline function 'kotlin.arrayOf' call
    // Inline function 'kotlin.js.unsafeCast' call
    // Inline function 'kotlin.js.asDynamic' call
    // Inline function 'kotlin.js.asDynamic' call
    return [first, second];
  }
  function iteratorFor(source) {
    // Inline function 'js.iterable.AsyncIterator.iterator' call
    var this_0 = source[Symbol.asyncIterator]();
    return iteratorFor_0(this_0);
  }
  function iteratorFor_0(source) {
    return new AsyncIteratorAdapter(source);
  }
  function _get_source__4cuw5s($this) {
    return $this.source_1;
  }
  function _set_lastResult__x6ezz8($this, _set____db54di) {
    $this.lastResult_1 = _set____db54di;
  }
  function _get_lastResult__i46eu0($this) {
    return $this.lastResult_1;
  }
  function $hasNextCOROUTINE$0(_this__u8e3s4, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this._this__u8e3s4__1 = _this__u8e3s4;
  }
  protoOf($hasNextCOROUTINE$0).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(3);
            this.tmp0_elvis_lhs0__1 = this._this__u8e3s4__1.lastResult_1;
            if (this.tmp0_elvis_lhs0__1 == null) {
              var tmp_0 = this;
              tmp_0.this2__1 = this._this__u8e3s4__1.source_1.next();
              this.set_state_rjd8d0_k$(1);
              var this_0 = this.this2__1;
              suspendResult = await_0(this_0, this);
              if (suspendResult === get_COROUTINE_SUSPENDED()) {
                return suspendResult;
              }
              continue $sm;
            } else {
              this.WHEN_RESULT1__1 = this.tmp0_elvis_lhs0__1;
              this.set_state_rjd8d0_k$(2);
              continue $sm;
            }

          case 1:
            this.WHEN_RESULT1__1 = suspendResult;
            this.set_state_rjd8d0_k$(2);
            continue $sm;
          case 2:
            var result = this.WHEN_RESULT1__1;
            this._this__u8e3s4__1.lastResult_1 = result;
            return result instanceof constructor;
          case 3:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 3) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  function AsyncIteratorAdapter(source) {
    this.source_1 = source;
    this.lastResult_1 = null;
  }
  protoOf(AsyncIteratorAdapter).hasNext_nhy1w3_k$ = function ($completion) {
    var tmp = new $hasNextCOROUTINE$0(this, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(AsyncIteratorAdapter).next_20eer_k$ = function () {
    var tmp$ret$1;
    $l$block: {
      // Inline function 'kotlin.checkNotNull' call
      var value = this.lastResult_1;
      // Inline function 'kotlin.contracts.contract' call
      if (value == null) {
        // Inline function 'js.iterable.AsyncIteratorAdapter.next.<anonymous>' call
        var message = '`hasNext` must be called before `next`';
        throw IllegalStateException_init_$Create$(toString(message));
      } else {
        tmp$ret$1 = value;
        break $l$block;
      }
    }
    var result = tmp$ret$1;
    this.lastResult_1 = null;
    if (!(result instanceof constructor))
      THROW_CCE();
    return result.value;
  };
  function iteratorFor_1(source) {
    // Inline function 'js.iterable.JsIterator.iterator' call
    var this_0 = source[Symbol.iterator]();
    return iteratorFor_2(this_0);
  }
  function toSet_0(_this__u8e3s4) {
    return toSet(toArray(_this__u8e3s4));
  }
  function toArray(_this__u8e3s4) {
    return Array.from(_this__u8e3s4);
  }
  function iteratorFor_2(source) {
    return iterator(iteratorFor$slambda_0(source, null));
  }
  function iteratorFor$slambda($source, resultContinuation) {
    this.$source_1 = $source;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(iteratorFor$slambda).invoke_5icac5_k$ = function ($this$iterator, $completion) {
    var tmp = this.create_f6q6qh_k$($this$iterator, $completion);
    tmp.set_result_xj64lm_k$(Unit_getInstance());
    tmp.set_exception_px07aa_k$(null);
    return tmp.doResume_5yljmg_k$();
  };
  protoOf(iteratorFor$slambda).invoke_qns8j1_k$ = function (p1, $completion) {
    return this.invoke_5icac5_k$(p1 instanceof SequenceScope ? p1 : THROW_CCE(), $completion);
  };
  protoOf(iteratorFor$slambda).doResume_5yljmg_k$ = function () {
    var suspendResult = this.get_result_iyg5d2_k$();
    $sm: do
      try {
        var tmp = this.get_state_iypx7s_k$();
        switch (tmp) {
          case 0:
            this.set_exceptionState_fex74n_k$(5);
            this.set_state_rjd8d0_k$(1);
            continue $sm;
          case 1:
            var tmp_0 = this;
            var tmp_1 = this.$source_1.next();
            tmp_0.tmp0_elvis_lhs0__1 = tmp_1 instanceof constructor ? tmp_1 : null;
            if (this.tmp0_elvis_lhs0__1 == null) {
              this.set_state_rjd8d0_k$(4);
              var tmp_2 = this;
              continue $sm;
            } else {
              this.WHEN_RESULT1__1 = this.tmp0_elvis_lhs0__1;
              this.set_state_rjd8d0_k$(2);
              continue $sm;
            }

          case 2:
            this.result2__1 = this.WHEN_RESULT1__1;
            this.set_state_rjd8d0_k$(3);
            suspendResult = this.$this$iterator_1.yield_3xhcex_k$(this.result2__1.value, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 3:
            this.set_state_rjd8d0_k$(1);
            continue $sm;
          case 4:
            return Unit_getInstance();
          case 5:
            throw this.get_exception_x0n6w6_k$();
        }
      } catch ($p) {
        var e = $p;
        if (this.get_exceptionState_wflpxn_k$() === 5) {
          throw e;
        } else {
          this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
          this.set_exception_px07aa_k$(e);
        }
      }
     while (true);
  };
  protoOf(iteratorFor$slambda).create_f6q6qh_k$ = function ($this$iterator, completion) {
    var i = new iteratorFor$slambda(this.$source_1, completion);
    i.$this$iterator_1 = $this$iterator;
    return i;
  };
  protoOf(iteratorFor$slambda).create_wyq9v6_k$ = function (value, completion) {
    return this.create_f6q6qh_k$(value instanceof SequenceScope ? value : THROW_CCE(), completion);
  };
  function iteratorFor$slambda_0($source, resultContinuation) {
    var i = new iteratorFor$slambda($source, resultContinuation);
    var l = function ($this$iterator, $completion) {
      return i.invoke_5icac5_k$($this$iterator, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function SuspendableIterator() {
  }
  function JsPlainObject() {
  }
  protoOf(JsPlainObject).equals = function (other) {
    if (!(other instanceof JsPlainObject))
      return false;
    other instanceof JsPlainObject || THROW_CCE();
    return true;
  };
  protoOf(JsPlainObject).hashCode = function () {
    return 0;
  };
  protoOf(JsPlainObject).toString = function () {
    return '@js.objects.JsPlainObject()';
  };
  function JsoDsl() {
  }
  protoOf(JsoDsl).equals = function (other) {
    if (!(other instanceof JsoDsl))
      return false;
    other instanceof JsoDsl || THROW_CCE();
    return true;
  };
  protoOf(JsoDsl).hashCode = function () {
    return 0;
  };
  protoOf(JsoDsl).toString = function () {
    return '@js.objects.JsoDsl()';
  };
  function jso(block) {
    // Inline function 'kotlin.apply' call
    // Inline function 'js.objects.jso' call
    var this_0 = {};
    // Inline function 'kotlin.contracts.contract' call
    block(this_0);
    return this_0;
  }
  function jso_0() {
    return {};
  }
  function catch_0(_this__u8e3s4, onRejected) {
    return _this__u8e3s4.catch(onRejected);
  }
  function await_1(_this__u8e3s4, $completion) {
    // Inline function 'kotlin.js.unsafeCast' call
    // Inline function 'kotlin.js.asDynamic' call
    return await_0(_this__u8e3s4, $completion);
  }
  function toUint8Array(_this__u8e3s4) {
    // Inline function 'js.typedarrays.asInt8Array' call
    // Inline function 'kotlin.js.unsafeCast' call
    // Inline function 'kotlin.js.asDynamic' call
    var array = _this__u8e3s4;
    return new Uint8Array(array.buffer, array.byteOffset, array.length);
  }
  function asInt8Array(_this__u8e3s4) {
    // Inline function 'kotlin.js.unsafeCast' call
    // Inline function 'kotlin.js.asDynamic' call
    return _this__u8e3s4;
  }
  //region block: exports
  _.$_$ = _.$_$ || {};
  _.$_$.a = iteratorFor_1;
  _.$_$.b = toSet_0;
  //endregion
  return _;
}(module.exports, require('./kotlin-kotlin-stdlib.js'), require('./kotlinx-coroutines-core.js')));
