(function (_, kotlin_kotlin, kotlin_io_ktor_ktor_io, kotlin_io_ktor_ktor_http, kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core) {
  'use strict';
  //region block: imports
  var VOID = kotlin_kotlin.$_$.c;
  var captureStack = kotlin_kotlin.$_$.zb;
  var protoOf = kotlin_kotlin.$_$.od;
  var initMetadataForClass = kotlin_kotlin.$_$.pc;
  var Exception = kotlin_kotlin.$_$.oi;
  var Exception_init_$Init$ = kotlin_kotlin.$_$.p2;
  var Unit_instance = kotlin_kotlin.$_$.b1;
  var Charsets_getInstance = kotlin_io_ktor_ktor_io.$_$.a;
  var initMetadataForInterface = kotlin_kotlin.$_$.tc;
  var parseAndSortHeader = kotlin_io_ktor_ktor_http.$_$.r1;
  var forName = kotlin_io_ktor_ktor_io.$_$.q;
  var isSupported = kotlin_io_ktor_ktor_io.$_$.r;
  var equals = kotlin_kotlin.$_$.ic;
  var FunctionAdapter = kotlin_kotlin.$_$.vb;
  var isInterface = kotlin_kotlin.$_$.ed;
  var FlowCollector = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.c1;
  var hashCode = kotlin_kotlin.$_$.oc;
  var CoroutineImpl = kotlin_kotlin.$_$.xa;
  var get_COROUTINE_SUSPENDED = kotlin_kotlin.$_$.fa;
  var initMetadataForLambda = kotlin_kotlin.$_$.uc;
  var initMetadataForCoroutine = kotlin_kotlin.$_$.rc;
  var Flow = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.d1;
  var asFlow = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.e1;
  var firstOrNull = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.j;
  var NullBody_instance = kotlin_io_ktor_ktor_http.$_$.a;
  //endregion
  //region block: pre-declaration
  initMetadataForClass(ContentConvertException, 'ContentConvertException', VOID, Exception);
  initMetadataForClass(JsonConvertException, 'JsonConvertException', VOID, ContentConvertException);
  function register$default(contentType, converter, configuration, $super) {
    var tmp;
    if (configuration === VOID) {
      tmp = Configuration$register$lambda;
    } else {
      tmp = configuration;
    }
    configuration = tmp;
    var tmp_0;
    if ($super === VOID) {
      this.g4y(contentType, converter, configuration);
      tmp_0 = Unit_instance;
    } else {
      tmp_0 = $super.g4y.call(this, contentType, converter, configuration);
    }
    return tmp_0;
  }
  initMetadataForInterface(Configuration, 'Configuration');
  initMetadataForClass(sam$kotlinx_coroutines_flow_FlowCollector$0, 'sam$kotlinx_coroutines_flow_FlowCollector$0', VOID, VOID, [FlowCollector, FunctionAdapter], [1]);
  initMetadataForLambda(deserialize$o$collect$slambda, CoroutineImpl, VOID, [1]);
  initMetadataForCoroutine($collectCOROUTINE$, CoroutineImpl);
  initMetadataForClass(deserialize$$inlined$map$1, VOID, VOID, VOID, [Flow], [1]);
  initMetadataForLambda(deserialize$slambda, CoroutineImpl, VOID, [1]);
  initMetadataForCoroutine($deserializeCOROUTINE$, CoroutineImpl);
  //endregion
  function JsonConvertException(message, cause) {
    cause = cause === VOID ? null : cause;
    ContentConvertException.call(this, message, cause);
    captureStack(this, JsonConvertException);
  }
  function ContentConvertException(message, cause) {
    cause = cause === VOID ? null : cause;
    Exception_init_$Init$(message, cause, this);
    captureStack(this, ContentConvertException);
  }
  function deserialize(_this__u8e3s4, body, typeInfo, charset, $completion) {
    var tmp = new $deserializeCOROUTINE$(_this__u8e3s4, body, typeInfo, charset, $completion);
    tmp.g9_1 = Unit_instance;
    tmp.h9_1 = null;
    return tmp.m9();
  }
  function suitableCharset(_this__u8e3s4, defaultCharset) {
    defaultCharset = defaultCharset === VOID ? Charsets_getInstance().x3x_1 : defaultCharset;
    var tmp0_elvis_lhs = suitableCharsetOrNull(_this__u8e3s4, defaultCharset);
    return tmp0_elvis_lhs == null ? defaultCharset : tmp0_elvis_lhs;
  }
  function Configuration$register$lambda(_this__u8e3s4) {
    return Unit_instance;
  }
  function Configuration() {
  }
  function suitableCharsetOrNull(_this__u8e3s4, defaultCharset) {
    defaultCharset = defaultCharset === VOID ? Charsets_getInstance().x3x_1 : defaultCharset;
    var _iterator__ex2g4s = parseAndSortHeader(_this__u8e3s4.wd('Accept-Charset')).t();
    while (_iterator__ex2g4s.u()) {
      var charset = _iterator__ex2g4s.v().lh();
      if (charset === '*')
        return defaultCharset;
      else if (isSupported(Charsets_getInstance(), charset))
        return forName(Charsets_getInstance(), charset);
    }
    return null;
  }
  function sam$kotlinx_coroutines_flow_FlowCollector$0(function_0) {
    this.i4y_1 = function_0;
  }
  protoOf(sam$kotlinx_coroutines_flow_FlowCollector$0).k3c = function (value, $completion) {
    return this.i4y_1(value, $completion);
  };
  protoOf(sam$kotlinx_coroutines_flow_FlowCollector$0).o3 = function () {
    return this.i4y_1;
  };
  protoOf(sam$kotlinx_coroutines_flow_FlowCollector$0).equals = function (other) {
    var tmp;
    if (!(other == null) ? isInterface(other, FlowCollector) : false) {
      var tmp_0;
      if (!(other == null) ? isInterface(other, FunctionAdapter) : false) {
        tmp_0 = equals(this.o3(), other.o3());
      } else {
        tmp_0 = false;
      }
      tmp = tmp_0;
    } else {
      tmp = false;
    }
    return tmp;
  };
  protoOf(sam$kotlinx_coroutines_flow_FlowCollector$0).hashCode = function () {
    return hashCode(this.o3());
  };
  function deserialize$o$collect$slambda($$this$unsafeFlow, $charset, $typeInfo, $body, resultContinuation) {
    this.r4y_1 = $$this$unsafeFlow;
    this.s4y_1 = $charset;
    this.t4y_1 = $typeInfo;
    this.u4y_1 = $body;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(deserialize$o$collect$slambda).i3h = function (value, $completion) {
    var tmp = this.j3h(value, $completion);
    tmp.g9_1 = Unit_instance;
    tmp.h9_1 = null;
    return tmp.m9();
  };
  protoOf(deserialize$o$collect$slambda).z9 = function (p1, $completion) {
    return this.i3h(p1, $completion);
  };
  protoOf(deserialize$o$collect$slambda).m9 = function () {
    var suspendResult = this.g9_1;
    $sm: do
      try {
        var tmp = this.e9_1;
        switch (tmp) {
          case 0:
            this.f9_1 = 3;
            var tmp0 = this.r4y_1;
            var tmp2 = this.v4y_1;
            this.w4y_1 = tmp0;
            this.e9_1 = 1;
            suspendResult = tmp2.x4y(this.s4y_1, this.t4y_1, this.u4y_1, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            var ARGUMENT = suspendResult;
            this.e9_1 = 2;
            suspendResult = this.w4y_1.k3c(ARGUMENT, this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 2:
            return Unit_instance;
          case 3:
            throw this.h9_1;
        }
      } catch ($p) {
        var e = $p;
        if (this.f9_1 === 3) {
          throw e;
        } else {
          this.e9_1 = this.f9_1;
          this.h9_1 = e;
        }
      }
     while (true);
  };
  protoOf(deserialize$o$collect$slambda).j3h = function (value, completion) {
    var i = new deserialize$o$collect$slambda(this.r4y_1, this.s4y_1, this.t4y_1, this.u4y_1, completion);
    i.v4y_1 = value;
    return i;
  };
  function deserialize$o$collect$slambda_0($$this$unsafeFlow, $charset, $typeInfo, $body, resultContinuation) {
    var i = new deserialize$o$collect$slambda($$this$unsafeFlow, $charset, $typeInfo, $body, resultContinuation);
    var l = function (value, $completion) {
      return i.i3h(value, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function $collectCOROUTINE$(_this__u8e3s4, collector, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this.g4z_1 = _this__u8e3s4;
    this.h4z_1 = collector;
  }
  protoOf($collectCOROUTINE$).m9 = function () {
    var suspendResult = this.g9_1;
    $sm: do
      try {
        var tmp = this.e9_1;
        switch (tmp) {
          case 0:
            this.f9_1 = 2;
            var $this$unsafeFlow = this.h4z_1;
            this.e9_1 = 1;
            var tmp_0 = deserialize$o$collect$slambda_0($this$unsafeFlow, this.g4z_1.j4z_1, this.g4z_1.k4z_1, this.g4z_1.l4z_1, null);
            suspendResult = this.g4z_1.i4z_1.v3b(new sam$kotlinx_coroutines_flow_FlowCollector$0(tmp_0), this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            return Unit_instance;
          case 2:
            throw this.h9_1;
        }
      } catch ($p) {
        var e = $p;
        if (this.f9_1 === 2) {
          throw e;
        } else {
          this.e9_1 = this.f9_1;
          this.h9_1 = e;
        }
      }
     while (true);
  };
  function deserialize$$inlined$map$1($this, $charset, $typeInfo, $body) {
    this.i4z_1 = $this;
    this.j4z_1 = $charset;
    this.k4z_1 = $typeInfo;
    this.l4z_1 = $body;
  }
  protoOf(deserialize$$inlined$map$1).l3c = function (collector, $completion) {
    var tmp = new $collectCOROUTINE$(this, collector, $completion);
    tmp.g9_1 = Unit_instance;
    tmp.h9_1 = null;
    return tmp.m9();
  };
  protoOf(deserialize$$inlined$map$1).v3b = function (collector, $completion) {
    return this.l3c(collector, $completion);
  };
  function deserialize$slambda($body, resultContinuation) {
    this.u4z_1 = $body;
    CoroutineImpl.call(this, resultContinuation);
  }
  protoOf(deserialize$slambda).w4z = function (it, $completion) {
    var tmp = this.j3h(it, $completion);
    tmp.g9_1 = Unit_instance;
    tmp.h9_1 = null;
    return tmp.m9();
  };
  protoOf(deserialize$slambda).z9 = function (p1, $completion) {
    return this.w4z(p1, $completion);
  };
  protoOf(deserialize$slambda).m9 = function () {
    var suspendResult = this.g9_1;
    $sm: do
      try {
        var tmp = this.e9_1;
        if (tmp === 0) {
          this.f9_1 = 1;
          return !(this.v4z_1 == null) || this.u4z_1.x3o();
        } else if (tmp === 1) {
          throw this.h9_1;
        }
      } catch ($p) {
        var e = $p;
        throw e;
      }
     while (true);
  };
  protoOf(deserialize$slambda).j3h = function (it, completion) {
    var i = new deserialize$slambda(this.u4z_1, completion);
    i.v4z_1 = it;
    return i;
  };
  function deserialize$slambda_0($body, resultContinuation) {
    var i = new deserialize$slambda($body, resultContinuation);
    var l = function (it, $completion) {
      return i.w4z(it, $completion);
    };
    l.$arity = 1;
    return l;
  }
  function $deserializeCOROUTINE$(_this__u8e3s4, body, typeInfo, charset, resultContinuation) {
    CoroutineImpl.call(this, resultContinuation);
    this.c4y_1 = _this__u8e3s4;
    this.d4y_1 = body;
    this.e4y_1 = typeInfo;
    this.f4y_1 = charset;
  }
  protoOf($deserializeCOROUTINE$).m9 = function () {
    var suspendResult = this.g9_1;
    $sm: do
      try {
        var tmp = this.e9_1;
        switch (tmp) {
          case 0:
            this.f9_1 = 2;
            this.e9_1 = 1;
            var this_0 = asFlow(this.c4y_1);
            var tmp_0 = new deserialize$$inlined$map$1(this_0, this.f4y_1, this.e4y_1, this.d4y_1);
            suspendResult = firstOrNull(tmp_0, deserialize$slambda_0(this.d4y_1, null), this);
            if (suspendResult === get_COROUTINE_SUSPENDED()) {
              return suspendResult;
            }

            continue $sm;
          case 1:
            var result = suspendResult;
            var tmp_1;
            if (!(result == null)) {
              tmp_1 = result;
            } else {
              if (!this.d4y_1.x3o()) {
                tmp_1 = this.d4y_1;
              } else {
                var tmp0_safe_receiver = this.e4y_1.n45_1;
                if ((tmp0_safe_receiver == null ? null : tmp0_safe_receiver.l()) === true) {
                  tmp_1 = NullBody_instance;
                } else {
                  throw new ContentConvertException('No suitable converter found for ' + this.e4y_1.toString());
                }
              }
            }

            return tmp_1;
          case 2:
            throw this.h9_1;
        }
      } catch ($p) {
        var e = $p;
        if (this.f9_1 === 2) {
          throw e;
        } else {
          this.e9_1 = this.f9_1;
          this.h9_1 = e;
        }
      }
     while (true);
  };
  //region block: exports
  _.$_$ = _.$_$ || {};
  _.$_$.a = deserialize;
  _.$_$.b = register$default;
  _.$_$.c = Configuration;
  _.$_$.d = JsonConvertException;
  _.$_$.e = suitableCharset;
  //endregion
  return _;
}(module.exports, require('./kotlin-kotlin-stdlib.js'), require('./ktor-ktor-io.js'), require('./ktor-ktor-http.js'), require('./kotlinx-coroutines-core.js')));

//# sourceMappingURL=ktor-ktor-serialization.js.map
