@earth-app/shovel
Version:
Kotlin Multiplatform Web Scraping Framework
1,363 lines (1,333 loc) • 111 kB
JavaScript
(function (factory) {
if (typeof define === 'function' && define.amd)
define(['exports', './kotlin-kotlin-stdlib.js', './kotlinx-coroutines-core.js', './kotlinx-io-kotlinx-io-core.js', './kotlinx-atomicfu.js', './kotlinx-io-kotlinx-io-bytestring.js'], factory);
else if (typeof exports === 'object')
factory(module.exports, require('./kotlin-kotlin-stdlib.js'), require('./kotlinx-coroutines-core.js'), require('./kotlinx-io-kotlinx-io-core.js'), require('./kotlinx-atomicfu.js'), require('./kotlinx-io-kotlinx-io-bytestring.js'));
else {
if (typeof globalThis['kotlin-kotlin-stdlib'] === 'undefined') {
throw new Error("Error loading module 'ktor-ktor-io'. Its dependency 'kotlin-kotlin-stdlib' was not found. Please, check whether 'kotlin-kotlin-stdlib' is loaded prior to 'ktor-ktor-io'.");
}
if (typeof globalThis['kotlinx-coroutines-core'] === 'undefined') {
throw new Error("Error loading module 'ktor-ktor-io'. Its dependency 'kotlinx-coroutines-core' was not found. Please, check whether 'kotlinx-coroutines-core' is loaded prior to 'ktor-ktor-io'.");
}
if (typeof globalThis['kotlinx-io-kotlinx-io-core'] === 'undefined') {
throw new Error("Error loading module 'ktor-ktor-io'. Its dependency 'kotlinx-io-kotlinx-io-core' was not found. Please, check whether 'kotlinx-io-kotlinx-io-core' is loaded prior to 'ktor-ktor-io'.");
}
if (typeof globalThis['kotlinx-atomicfu'] === 'undefined') {
throw new Error("Error loading module 'ktor-ktor-io'. Its dependency 'kotlinx-atomicfu' was not found. Please, check whether 'kotlinx-atomicfu' is loaded prior to 'ktor-ktor-io'.");
}
if (typeof globalThis['kotlinx-io-kotlinx-io-bytestring'] === 'undefined') {
throw new Error("Error loading module 'ktor-ktor-io'. Its dependency 'kotlinx-io-kotlinx-io-bytestring' was not found. Please, check whether 'kotlinx-io-kotlinx-io-bytestring' is loaded prior to 'ktor-ktor-io'.");
}
globalThis['ktor-ktor-io'] = factory(typeof globalThis['ktor-ktor-io'] === 'undefined' ? {} : globalThis['ktor-ktor-io'], globalThis['kotlin-kotlin-stdlib'], globalThis['kotlinx-coroutines-core'], globalThis['kotlinx-io-kotlinx-io-core'], globalThis['kotlinx-atomicfu'], globalThis['kotlinx-io-kotlinx-io-bytestring']);
}
}(function (_, kotlin_kotlin, kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core, kotlin_org_jetbrains_kotlinx_kotlinx_io_core, kotlin_org_jetbrains_kotlinx_atomicfu, kotlin_org_jetbrains_kotlinx_kotlinx_io_bytestring) {
'use strict';
//region block: imports
var Companion_instance = kotlin_kotlin.$_$.z2;
var Unit_instance = kotlin_kotlin.$_$.a3;
var _Result___init__impl__xyqfz8 = kotlin_kotlin.$_$.p2;
var protoOf = kotlin_kotlin.$_$.y7;
var initMetadataForCompanion = kotlin_kotlin.$_$.i7;
var THROW_CCE = kotlin_kotlin.$_$.hb;
var initMetadataForObject = kotlin_kotlin.$_$.n7;
var toString = kotlin_kotlin.$_$.wb;
var hashCode = kotlin_kotlin.$_$.g7;
var equals = kotlin_kotlin.$_$.a7;
var initMetadataForClass = kotlin_kotlin.$_$.h7;
var createFailure = kotlin_kotlin.$_$.nb;
var Result = kotlin_kotlin.$_$.fb;
var initMetadataForInterface = kotlin_kotlin.$_$.l7;
var toString_0 = kotlin_kotlin.$_$.ma;
var newThrowable = kotlin_kotlin.$_$.t7;
var stackTraceToString = kotlin_kotlin.$_$.ub;
var VOID = kotlin_kotlin.$_$.h;
var isInterface = kotlin_kotlin.$_$.r7;
var CoroutineImpl = kotlin_kotlin.$_$.m6;
var toLong = kotlin_kotlin.$_$.a8;
var numberToLong = kotlin_kotlin.$_$.w7;
var intercepted = kotlin_kotlin.$_$.z5;
var CancellableContinuationImpl = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.l;
var noWhenBranchMatchedException = kotlin_kotlin.$_$.sb;
var returnIfSuspended = kotlin_kotlin.$_$.m;
var get_COROUTINE_SUSPENDED = kotlin_kotlin.$_$.w5;
var Long = kotlin_kotlin.$_$.cb;
var initMetadataForCoroutine = kotlin_kotlin.$_$.j7;
var Buffer = kotlin_org_jetbrains_kotlinx_kotlinx_io_core.$_$.f;
var atomic$ref$1 = kotlin_org_jetbrains_kotlinx_atomicfu.$_$.d;
var IllegalStateException = kotlin_kotlin.$_$.ab;
var IllegalStateException_init_$Init$ = kotlin_kotlin.$_$.s1;
var captureStack = kotlin_kotlin.$_$.s6;
var IOException_init_$Create$ = kotlin_org_jetbrains_kotlinx_kotlinx_io_core.$_$.c;
var decodeToString = kotlin_org_jetbrains_kotlinx_kotlinx_io_bytestring.$_$.d;
var replace = kotlin_kotlin.$_$.u9;
var indexOf = kotlin_org_jetbrains_kotlinx_kotlinx_io_core.$_$.i;
var toString_1 = kotlin_kotlin.$_$.c8;
var IllegalArgumentException_init_$Create$ = kotlin_kotlin.$_$.o1;
var EOFException_init_$Create$ = kotlin_org_jetbrains_kotlinx_kotlinx_io_core.$_$.a;
var readString = kotlin_org_jetbrains_kotlinx_kotlinx_io_core.$_$.o;
var closeFinally = kotlin_kotlin.$_$.mb;
var readByteString = kotlin_org_jetbrains_kotlinx_kotlinx_io_core.$_$.l;
var EmptyCoroutineContext_getInstance = kotlin_kotlin.$_$.w2;
var CoroutineScope = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.s;
var launch = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.b1;
var startCoroutineCancellable = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.k;
var Continuation = kotlin_kotlin.$_$.g6;
var initMetadataForFunctionReference = kotlin_kotlin.$_$.k7;
var get_job = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.a1;
var Job = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.t;
var cancel = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.z;
var initMetadataForLambda = kotlin_kotlin.$_$.m7;
var CancellationException_init_$Create$ = kotlin_kotlin.$_$.y;
var CancellationException = kotlin_kotlin.$_$.v5;
var CopyableThrowable = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.p;
var readString_0 = kotlin_org_jetbrains_kotlinx_kotlinx_io_core.$_$.m;
var IOException = kotlin_org_jetbrains_kotlinx_kotlinx_io_core.$_$.g;
var IOException_init_$Init$ = kotlin_org_jetbrains_kotlinx_kotlinx_io_core.$_$.d;
var ArrayList_init_$Create$ = kotlin_kotlin.$_$.p;
var listOf = kotlin_kotlin.$_$.t4;
var IOException_init_$Create$_0 = kotlin_org_jetbrains_kotlinx_kotlinx_io_core.$_$.e;
var StringBuilder_init_$Create$ = kotlin_kotlin.$_$.c1;
var IllegalStateException_init_$Create$ = kotlin_kotlin.$_$.r1;
var charSequenceLength = kotlin_kotlin.$_$.w6;
var readByteArray = kotlin_org_jetbrains_kotlinx_kotlinx_io_core.$_$.j;
var encodeToByteArray = kotlin_kotlin.$_$.y8;
var readString_1 = kotlin_org_jetbrains_kotlinx_kotlinx_io_core.$_$.n;
var writeString = kotlin_org_jetbrains_kotlinx_kotlinx_io_core.$_$.p;
var AutoCloseable = kotlin_kotlin.$_$.ra;
var _Char___init__impl__6a9atx = kotlin_kotlin.$_$.h2;
var replace_0 = kotlin_kotlin.$_$.v9;
var getStringHashCode = kotlin_kotlin.$_$.f7;
var IOException_init_$Init$_0 = kotlin_org_jetbrains_kotlinx_kotlinx_io_core.$_$.b;
var readByteArray_0 = kotlin_org_jetbrains_kotlinx_kotlinx_io_core.$_$.k;
var charSequenceSubSequence = kotlin_kotlin.$_$.x6;
var isCharSequence = kotlin_kotlin.$_$.p7;
var trim = kotlin_kotlin.$_$.pa;
var toByte = kotlin_kotlin.$_$.z7;
var decodeToString_0 = kotlin_kotlin.$_$.w8;
var setOf = kotlin_kotlin.$_$.d5;
var charSequenceGet = kotlin_kotlin.$_$.v6;
var Char__toInt_impl_vasixd = kotlin_kotlin.$_$.n2;
//endregion
//region block: pre-declaration
initMetadataForCompanion(Companion);
initMetadataForObject(Empty, 'Empty');
initMetadataForClass(Closed, 'Closed');
function resume() {
return this.s19().x8(Companion_getInstance().p19_1);
}
function resume_0(throwable) {
var tmp = this.s19();
var tmp_0;
if (throwable == null) {
tmp_0 = null;
} else {
// Inline function 'kotlin.let' call
// Inline function 'kotlin.Companion.failure' call
var tmp$ret$2 = _Result___init__impl__xyqfz8(createFailure(throwable));
tmp_0 = new Result(tmp$ret$2);
}
var tmp1_elvis_lhs = tmp_0;
return tmp.x8(tmp1_elvis_lhs == null ? Companion_getInstance().p19_1 : tmp1_elvis_lhs.ol_1);
}
initMetadataForInterface(Task, 'Task');
initMetadataForClass(Read, 'Read', VOID, VOID, [Task]);
initMetadataForClass(Write, 'Write', VOID, VOID, [Task]);
initMetadataForCoroutine($awaitContentCOROUTINE$0, CoroutineImpl);
initMetadataForCoroutine($flushCOROUTINE$1, CoroutineImpl);
initMetadataForCoroutine($flushAndCloseCOROUTINE$2, CoroutineImpl);
function awaitContent$default(min, $completion, $super) {
min = min === VOID ? 1 : min;
return $super === VOID ? this.e1c(min, $completion) : $super.e1c.call(this, min, $completion);
}
initMetadataForInterface(ByteReadChannel_1, 'ByteReadChannel', VOID, VOID, VOID, [1]);
initMetadataForClass(ByteChannel, 'ByteChannel', ByteChannel, VOID, [ByteReadChannel_1], [1, 0]);
initMetadataForClass(ConcurrentIOException, 'ConcurrentIOException', VOID, IllegalStateException);
initMetadataForCoroutine($findNextCOROUTINE$3, CoroutineImpl);
initMetadataForCoroutine($advanceToNextPotentialMatchCOROUTINE$4, CoroutineImpl);
initMetadataForCoroutine($checkFullMatchCOROUTINE$5, CoroutineImpl);
initMetadataForClass(ByteChannelScanner, 'ByteChannelScanner', VOID, VOID, VOID, [1, 0]);
initMetadataForClass(ByteReadChannel$Companion$Empty$1, VOID, VOID, VOID, [ByteReadChannel_1], [1]);
initMetadataForCompanion(Companion_0);
initMetadataForCoroutine($readRemainingCOROUTINE$6, CoroutineImpl);
initMetadataForCoroutine($readPacketCOROUTINE$7, CoroutineImpl);
initMetadataForCoroutine($discardCOROUTINE$8, CoroutineImpl);
initMetadataForCoroutine($readAvailableCOROUTINE$10, CoroutineImpl);
initMetadataForCoroutine($toByteArrayCOROUTINE$12, CoroutineImpl);
initMetadataForCoroutine($copyToCOROUTINE$13, CoroutineImpl);
initMetadataForCoroutine($readBufferCOROUTINE$14, CoroutineImpl);
initMetadataForCoroutine($readUTF8LineToCOROUTINE$15, CoroutineImpl);
initMetadataForCoroutine($skipIfFoundCOROUTINE$16, CoroutineImpl);
initMetadataForCoroutine($peekCOROUTINE$17, CoroutineImpl);
initMetadataForCoroutine($flushIfNeededCOROUTINE$18, CoroutineImpl);
initMetadataForClass(WriterJob, 'WriterJob');
initMetadataForClass(WriterScope, 'WriterScope', VOID, VOID, [CoroutineScope]);
initMetadataForClass(NO_CALLBACK$1, VOID, VOID, VOID, [Continuation]);
initMetadataForFunctionReference(ByteWriteChannel$flushAndClose$ref, VOID, VOID, [0]);
initMetadataForLambda(writer$slambda, CoroutineImpl, VOID, [1]);
initMetadataForCoroutine($writePacketCOROUTINE$19, CoroutineImpl);
initMetadataForClass(CloseToken, 'CloseToken');
initMetadataForCoroutine($awaitContentCOROUTINE$20, CoroutineImpl);
initMetadataForClass(CountedByteReadChannel, 'CountedByteReadChannel', VOID, VOID, [ByteReadChannel_1], [1]);
initMetadataForClass(ClosedByteChannelException, 'ClosedByteChannelException', ClosedByteChannelException, IOException);
initMetadataForClass(ClosedReadChannelException, 'ClosedReadChannelException', ClosedReadChannelException, ClosedByteChannelException);
initMetadataForClass(ClosedWriteChannelException, 'ClosedWriteChannelException', ClosedWriteChannelException, ClosedByteChannelException);
initMetadataForCompanion(Companion_1);
initMetadataForClass(LineEndingMode, 'LineEndingMode');
initMetadataForClass(SourceByteReadChannel, 'SourceByteReadChannel', VOID, VOID, [ByteReadChannel_1], [1]);
initMetadataForClass(MalformedInputException, 'MalformedInputException', VOID, IOException);
initMetadataForClass(TooLongLineException, 'TooLongLineException', VOID, MalformedInputException);
function close() {
this.tp();
}
initMetadataForInterface(ObjectPool, 'ObjectPool', VOID, VOID, [AutoCloseable]);
initMetadataForClass(DefaultPool, 'DefaultPool', VOID, VOID, [ObjectPool]);
initMetadataForClass(ByteArrayPool$1, VOID, VOID, DefaultPool);
initMetadataForClass(NoPoolImpl, 'NoPoolImpl', VOID, VOID, [ObjectPool]);
initMetadataForCompanion(Companion_2);
initMetadataForClass(Charset, 'Charset');
initMetadataForObject(Charsets, 'Charsets');
initMetadataForClass(CharsetDecoder, 'CharsetDecoder');
initMetadataForClass(CharsetEncoder, 'CharsetEncoder');
initMetadataForClass(CharsetImpl, 'CharsetImpl', VOID, Charset);
initMetadataForClass(CharsetEncoderImpl, 'CharsetEncoderImpl', VOID, CharsetEncoder);
initMetadataForClass(CharsetDecoderImpl, 'CharsetDecoderImpl', VOID, CharsetDecoder);
initMetadataForClass(toKtor$1);
initMetadataForClass(TextDecoderFallback, 'TextDecoderFallback');
//endregion
function Companion() {
Companion_instance_0 = this;
this.o19_1 = new Closed(null);
var tmp = this;
// Inline function 'kotlin.Companion.success' call
tmp.p19_1 = _Result___init__impl__xyqfz8(Unit_instance);
}
var Companion_instance_0;
function Companion_getInstance() {
if (Companion_instance_0 == null)
new Companion();
return Companion_instance_0;
}
function Empty() {
}
protoOf(Empty).toString = function () {
return 'Empty';
};
protoOf(Empty).hashCode = function () {
return -231472095;
};
protoOf(Empty).equals = function (other) {
if (this === other)
return true;
if (!(other instanceof Empty))
return false;
other instanceof Empty || THROW_CCE();
return true;
};
var Empty_instance;
function Empty_getInstance() {
return Empty_instance;
}
function Closed(cause) {
this.q19_1 = cause;
}
protoOf(Closed).toString = function () {
return 'Closed(cause=' + toString(this.q19_1) + ')';
};
protoOf(Closed).hashCode = function () {
return this.q19_1 == null ? 0 : hashCode(this.q19_1);
};
protoOf(Closed).equals = function (other) {
if (this === other)
return true;
if (!(other instanceof Closed))
return false;
var tmp0_other_with_cast = other instanceof Closed ? other : THROW_CCE();
if (!equals(this.q19_1, tmp0_other_with_cast.q19_1))
return false;
return true;
};
function Task() {
}
function Read(continuation) {
this.w19_1 = continuation;
this.x19_1 = null;
if (get_DEVELOPMENT_MODE()) {
var tmp = this;
// Inline function 'kotlin.also' call
var this_0 = newThrowable('ReadTask 0x' + toString_0(hashCode(this.w19_1), 16));
stackTraceToString(this_0);
tmp.x19_1 = this_0;
}
}
protoOf(Read).s19 = function () {
return this.w19_1;
};
protoOf(Read).r19 = function () {
return this.x19_1;
};
protoOf(Read).t19 = function () {
return 'read';
};
function Write(continuation) {
this.y19_1 = continuation;
this.z19_1 = null;
if (get_DEVELOPMENT_MODE()) {
var tmp = this;
// Inline function 'kotlin.also' call
var this_0 = newThrowable('WriteTask 0x' + toString_0(hashCode(this.y19_1), 16));
stackTraceToString(this_0);
tmp.z19_1 = this_0;
}
}
protoOf(Write).s19 = function () {
return this.y19_1;
};
protoOf(Write).r19 = function () {
return this.z19_1;
};
protoOf(Write).t19 = function () {
return 'write';
};
function moveFlushToReadBuffer($this) {
// Inline function 'io.ktor.utils.io.locks.synchronized' call
$this.d1a_1;
$this.b1a_1.t17($this.f1a_1);
$this.c1a_1 = 0;
// Inline function 'io.ktor.utils.io.ByteChannel.resumeSlot' call
var current = $this.e1a_1.kotlinx$atomicfu$value;
var tmp;
if (current instanceof Write) {
tmp = $this.e1a_1.atomicfu$compareAndSet(current, Empty_instance);
} else {
tmp = false;
}
if (tmp) {
current.u19();
}
}
function closeSlot($this, cause) {
var closeContinuation = !(cause == null) ? new Closed(cause) : Companion_getInstance().o19_1;
var continuation = $this.e1a_1.atomicfu$getAndSet(closeContinuation);
if (isInterface(continuation, Task)) {
continuation.v19(cause);
}
}
function ClosedReadChannelException$_init_$ref_ix0089() {
var l = function (p0) {
return new ClosedReadChannelException(p0);
};
l.callableName = '<init>';
return l;
}
function ClosedWriteChannelException$_init_$ref_ef15ty() {
var l = function (p0) {
return new ClosedWriteChannelException(p0);
};
l.callableName = '<init>';
return l;
}
function $awaitContentCOROUTINE$0(_this__u8e3s4, min, resultContinuation) {
CoroutineImpl.call(this, resultContinuation);
this.q1a_1 = _this__u8e3s4;
this.r1a_1 = min;
}
protoOf($awaitContentCOROUTINE$0).u8 = function () {
var suspendResult = this.o8_1;
$sm: do
try {
var tmp = this.m8_1;
switch (tmp) {
case 0:
this.n8_1 = 4;
rethrowCloseCauseIfNeeded_1(this.q1a_1);
if (this.q1a_1.f1a_1.j().a1(toLong(this.r1a_1)) >= 0)
return true;
var tmp_0 = this;
tmp_0.s1a_1 = this.q1a_1;
this.t1a_1 = this.s1a_1;
this.m8_1 = 1;
continue $sm;
case 1:
if (!(numberToLong(this.q1a_1.c1a_1).r2(this.q1a_1.f1a_1.j()).a1(toLong(this.r1a_1)) < 0 && this.q1a_1.h1a_1.kotlinx$atomicfu$value == null)) {
this.m8_1 = 3;
continue $sm;
}
this.m8_1 = 2;
var cancellable = new CancellableContinuationImpl(intercepted(this), 1);
cancellable.vq();
var tmp0 = this.t1a_1;
var tmp1 = new Read(cancellable);
l$ret$1: do {
var previous = tmp0.e1a_1.kotlinx$atomicfu$value;
if (!(previous instanceof Closed)) {
if (!tmp0.e1a_1.atomicfu$compareAndSet(previous, tmp1)) {
tmp1.u19();
break l$ret$1;
}
}
if (previous instanceof Read) {
previous.v19(new ConcurrentIOException(tmp1.t19(), previous.r19()));
} else {
if (isInterface(previous, Task)) {
previous.u19();
} else {
if (previous instanceof Closed) {
tmp1.v19(previous.q19_1);
break l$ret$1;
} else {
if (!equals(previous, Empty_instance)) {
noWhenBranchMatchedException();
}
}
}
}
if (!(numberToLong(this.q1a_1.c1a_1).r2(this.q1a_1.f1a_1.j()).a1(toLong(this.r1a_1)) < 0 && this.q1a_1.h1a_1.kotlinx$atomicfu$value == null)) {
var current = tmp0.e1a_1.kotlinx$atomicfu$value;
var tmp_1;
if (current instanceof Read) {
tmp_1 = tmp0.e1a_1.atomicfu$compareAndSet(current, Empty_instance);
} else {
tmp_1 = false;
}
if (tmp_1) {
current.u19();
}
}
}
while (false);
suspendResult = returnIfSuspended(cancellable.dr(), this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 2:
this.m8_1 = 1;
continue $sm;
case 3:
if (this.q1a_1.f1a_1.j().a1(new Long(1048576, 0)) < 0) {
moveFlushToReadBuffer(this.q1a_1);
}
return this.q1a_1.f1a_1.j().a1(toLong(this.r1a_1)) >= 0;
case 4:
throw this.p8_1;
}
} catch ($p) {
var e = $p;
if (this.n8_1 === 4) {
throw e;
} else {
this.m8_1 = this.n8_1;
this.p8_1 = e;
}
}
while (true);
};
function $flushCOROUTINE$1(_this__u8e3s4, resultContinuation) {
CoroutineImpl.call(this, resultContinuation);
this.c1b_1 = _this__u8e3s4;
}
protoOf($flushCOROUTINE$1).u8 = function () {
var suspendResult = this.o8_1;
$sm: do
try {
var tmp = this.m8_1;
switch (tmp) {
case 0:
this.n8_1 = 4;
rethrowCloseCauseIfNeeded_1(this.c1b_1);
this.c1b_1.f1b();
if (this.c1b_1.c1a_1 < 1048576)
return Unit_instance;
var tmp_0 = this;
tmp_0.d1b_1 = this.c1b_1;
this.e1b_1 = this.d1b_1;
this.m8_1 = 1;
continue $sm;
case 1:
if (!(this.c1b_1.c1a_1 >= 1048576 && this.c1b_1.h1a_1.kotlinx$atomicfu$value == null)) {
this.m8_1 = 3;
continue $sm;
}
this.m8_1 = 2;
var cancellable = new CancellableContinuationImpl(intercepted(this), 1);
cancellable.vq();
var tmp0 = this.e1b_1;
var tmp1 = new Write(cancellable);
l$ret$1: do {
var previous = tmp0.e1a_1.kotlinx$atomicfu$value;
if (!(previous instanceof Closed)) {
if (!tmp0.e1a_1.atomicfu$compareAndSet(previous, tmp1)) {
tmp1.u19();
break l$ret$1;
}
}
if (previous instanceof Write) {
previous.v19(new ConcurrentIOException(tmp1.t19(), previous.r19()));
} else {
if (isInterface(previous, Task)) {
previous.u19();
} else {
if (previous instanceof Closed) {
tmp1.v19(previous.q19_1);
break l$ret$1;
} else {
if (!equals(previous, Empty_instance)) {
noWhenBranchMatchedException();
}
}
}
}
if (!(this.c1b_1.c1a_1 >= 1048576 && this.c1b_1.h1a_1.kotlinx$atomicfu$value == null)) {
var current = tmp0.e1a_1.kotlinx$atomicfu$value;
var tmp_1;
if (current instanceof Write) {
tmp_1 = tmp0.e1a_1.atomicfu$compareAndSet(current, Empty_instance);
} else {
tmp_1 = false;
}
if (tmp_1) {
current.u19();
}
}
}
while (false);
suspendResult = returnIfSuspended(cancellable.dr(), this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 2:
this.m8_1 = 1;
continue $sm;
case 3:
return Unit_instance;
case 4:
throw this.p8_1;
}
} catch ($p) {
var e = $p;
if (this.n8_1 === 4) {
throw e;
} else {
this.m8_1 = this.n8_1;
this.p8_1 = e;
}
}
while (true);
};
function $flushAndCloseCOROUTINE$2(_this__u8e3s4, resultContinuation) {
CoroutineImpl.call(this, resultContinuation);
this.o1b_1 = _this__u8e3s4;
}
protoOf($flushAndCloseCOROUTINE$2).u8 = function () {
var suspendResult = this.o8_1;
$sm: do
try {
var tmp = this.m8_1;
switch (tmp) {
case 0:
this.n8_1 = 4;
var tmp_0 = this;
tmp_0.p1b_1 = this.o1b_1;
this.q1b_1 = this.p1b_1;
this.n8_1 = 2;
var tmp_1 = this;
tmp_1.s1b_1 = Companion_instance;
var tmp_2 = this;
tmp_2.t1b_1 = this.q1b_1;
this.u1b_1 = this.t1b_1;
this.m8_1 = 1;
suspendResult = this.u1b_1.v1b(this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 1:
var tmp_3 = this;
this.s1b_1;
tmp_3.r1b_1 = _Result___init__impl__xyqfz8(Unit_instance);
this.n8_1 = 4;
this.m8_1 = 3;
continue $sm;
case 2:
this.n8_1 = 4;
var tmp_4 = this.p8_1;
if (tmp_4 instanceof Error) {
var e = this.p8_1;
var tmp_5 = this;
tmp_5.r1b_1 = _Result___init__impl__xyqfz8(createFailure(e));
this.m8_1 = 3;
continue $sm;
} else {
throw this.p8_1;
}
case 3:
this.n8_1 = 4;
if (!this.o1b_1.h1a_1.atomicfu$compareAndSet(null, get_CLOSED()))
return Unit_instance;
closeSlot(this.o1b_1, null);
return Unit_instance;
case 4:
throw this.p8_1;
}
} catch ($p) {
var e_0 = $p;
if (this.n8_1 === 4) {
throw e_0;
} else {
this.m8_1 = this.n8_1;
this.p8_1 = e_0;
}
}
while (true);
};
function ByteChannel(autoFlush) {
autoFlush = autoFlush === VOID ? false : autoFlush;
this.a1a_1 = autoFlush;
this.b1a_1 = new Buffer();
this.c1a_1 = 0;
this.d1a_1 = new Object();
this.e1a_1 = atomic$ref$1(Empty_instance);
this.f1a_1 = new Buffer();
this.g1a_1 = new Buffer();
this.h1a_1 = atomic$ref$1(null);
}
protoOf(ByteChannel).w1b = function () {
var tmp0_safe_receiver = this.h1a_1.kotlinx$atomicfu$value;
if (tmp0_safe_receiver == null)
null;
else {
tmp0_safe_receiver.y1b(ClosedReadChannelException$_init_$ref_ix0089());
}
if (this.f1a_1.q16()) {
moveFlushToReadBuffer(this);
}
return this.f1a_1;
};
protoOf(ByteChannel).z1b = function () {
if (this.a1c()) {
var tmp0_safe_receiver = this.h1a_1.kotlinx$atomicfu$value;
var tmp;
if (tmp0_safe_receiver == null) {
tmp = null;
} else {
tmp = tmp0_safe_receiver.y1b(ClosedWriteChannelException$_init_$ref_ef15ty());
}
if (tmp == null)
throw new ClosedWriteChannelException();
}
return this.g1a_1;
};
protoOf(ByteChannel).b1c = function () {
var tmp0_safe_receiver = this.h1a_1.kotlinx$atomicfu$value;
return tmp0_safe_receiver == null ? null : tmp0_safe_receiver.c1c();
};
protoOf(ByteChannel).a1c = function () {
return !(this.h1a_1.kotlinx$atomicfu$value == null);
};
protoOf(ByteChannel).d1c = function () {
return !(this.b1c() == null) || (this.a1c() && this.c1a_1 === 0 && this.f1a_1.q16());
};
protoOf(ByteChannel).e1c = function (min, $completion) {
var tmp = new $awaitContentCOROUTINE$0(this, min, $completion);
tmp.o8_1 = Unit_instance;
tmp.p8_1 = null;
return tmp.u8();
};
protoOf(ByteChannel).v1b = function ($completion) {
var tmp = new $flushCOROUTINE$1(this, $completion);
tmp.o8_1 = Unit_instance;
tmp.p8_1 = null;
return tmp.u8();
};
protoOf(ByteChannel).f1b = function () {
if (this.g1a_1.q16())
return Unit_instance;
// Inline function 'io.ktor.utils.io.locks.synchronized' call
this.d1a_1;
var count = this.g1a_1.j().z();
this.b1a_1.i18(this.g1a_1);
this.c1a_1 = this.c1a_1 + count | 0;
// Inline function 'io.ktor.utils.io.ByteChannel.resumeSlot' call
var current = this.e1a_1.kotlinx$atomicfu$value;
var tmp;
if (current instanceof Read) {
tmp = this.e1a_1.atomicfu$compareAndSet(current, Empty_instance);
} else {
tmp = false;
}
if (tmp) {
current.u19();
}
};
protoOf(ByteChannel).x3 = function () {
this.f1b();
if (!this.h1a_1.atomicfu$compareAndSet(null, get_CLOSED()))
return Unit_instance;
closeSlot(this, null);
};
protoOf(ByteChannel).g1c = function ($completion) {
var tmp = new $flushAndCloseCOROUTINE$2(this, $completion);
tmp.o8_1 = Unit_instance;
tmp.p8_1 = null;
return tmp.u8();
};
protoOf(ByteChannel).h1c = function (cause) {
if (!(this.h1a_1.kotlinx$atomicfu$value == null))
return Unit_instance;
var closedToken = new CloseToken(cause);
this.h1a_1.atomicfu$compareAndSet(null, closedToken);
var wrappedCause = closedToken.c1c();
closeSlot(this, wrappedCause);
};
protoOf(ByteChannel).toString = function () {
return 'ByteChannel[' + hashCode(this) + ']';
};
function ConcurrentIOException(taskName, cause) {
cause = cause === VOID ? null : cause;
IllegalStateException_init_$Init$('Concurrent ' + taskName + ' attempts', cause, this);
captureStack(this, ConcurrentIOException);
}
function ByteReadChannel(content, offset, length) {
offset = offset === VOID ? 0 : offset;
length = length === VOID ? content.length : length;
// Inline function 'kotlin.also' call
var this_0 = new Buffer();
this_0.z17(content, offset, offset + length | 0);
var source = this_0;
return ByteReadChannel_0(source);
}
function ByteReadChannel_0(source) {
return new SourceByteReadChannel(source);
}
function buildPartialMatchTable($this) {
var table = new Int32Array($this.j1c_1.j());
var j = 0;
var inductionVariable = 1;
var last = $this.j1c_1.j();
if (inductionVariable < last)
do {
var i = inductionVariable;
inductionVariable = inductionVariable + 1 | 0;
while (j > 0 && !($this.j1c_1.o(i) === $this.j1c_1.o(j))) {
j = table[j - 1 | 0];
}
if ($this.j1c_1.o(i) === $this.j1c_1.o(j)) {
j = j + 1 | 0;
}
table[i] = j;
}
while (inductionVariable < last);
return table;
}
function advanceToNextPotentialMatch($this, $completion) {
var tmp = new $advanceToNextPotentialMatchCOROUTINE$4($this, $completion);
tmp.o8_1 = Unit_instance;
tmp.p8_1 = null;
return tmp.u8();
}
function checkFullMatch($this, $completion) {
var tmp = new $checkFullMatchCOROUTINE$5($this, $completion);
tmp.o8_1 = Unit_instance;
tmp.p8_1 = null;
return tmp.u8();
}
function checkBounds($this, extra) {
if ($this.p1c_1.r2(extra).a1($this.l1c_1) > 0) {
throw IOException_init_$Create$('Limit of ' + $this.l1c_1.toString() + ' bytes exceeded ' + ('while searching for "' + toSingleLineString($this, $this.j1c_1) + '"'));
}
}
function toSingleLineString($this, _this__u8e3s4) {
return replace(decodeToString(_this__u8e3s4), '\n', '\\n');
}
function $findNextCOROUTINE$3(_this__u8e3s4, ignoreMissing, resultContinuation) {
CoroutineImpl.call(this, resultContinuation);
this.x1d_1 = _this__u8e3s4;
this.y1d_1 = ignoreMissing;
}
protoOf($findNextCOROUTINE$3).u8 = function () {
var suspendResult = this.o8_1;
$sm: do
try {
var tmp = this.m8_1;
switch (tmp) {
case 0:
this.n8_1 = 9;
this.x1d_1.p1c_1 = new Long(0, 0);
this.m8_1 = 1;
continue $sm;
case 1:
if (!this.x1d_1.m1c_1.q16()) {
this.z1d_1 = true;
this.m8_1 = 3;
continue $sm;
} else {
this.m8_1 = 2;
suspendResult = this.x1d_1.i1c_1.f1c(VOID, this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
}
case 2:
this.z1d_1 = suspendResult;
this.m8_1 = 3;
continue $sm;
case 3:
if (!this.z1d_1) {
this.m8_1 = 7;
continue $sm;
}
this.m8_1 = 4;
suspendResult = advanceToNextPotentialMatch(this.x1d_1, this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 4:
this.m8_1 = 5;
suspendResult = checkFullMatch(this.x1d_1, this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 5:
if (suspendResult) {
return this.x1d_1.p1c_1;
} else {
this.m8_1 = 6;
continue $sm;
}
case 6:
this.m8_1 = 1;
continue $sm;
case 7:
if (!this.y1d_1) {
throw IOException_init_$Create$('Expected "' + toSingleLineString(this.x1d_1, this.x1d_1.j1c_1) + '" but encountered end of input');
}
this.x1d_1.p1c_1 = this.x1d_1.p1c_1.r2(this.x1d_1.o1c_1.t17(this.x1d_1.k1c_1.z1b()));
this.m8_1 = 8;
suspendResult = this.x1d_1.k1c_1.v1b(this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 8:
return this.x1d_1.p1c_1;
case 9:
throw this.p8_1;
}
} catch ($p) {
var e = $p;
if (this.n8_1 === 9) {
throw e;
} else {
this.m8_1 = this.n8_1;
this.p8_1 = e;
}
}
while (true);
};
function $advanceToNextPotentialMatchCOROUTINE$4(_this__u8e3s4, resultContinuation) {
CoroutineImpl.call(this, resultContinuation);
this.z1c_1 = _this__u8e3s4;
}
protoOf($advanceToNextPotentialMatchCOROUTINE$4).u8 = function () {
var suspendResult = this.o8_1;
$sm: do
try {
var tmp = this.m8_1;
switch (tmp) {
case 0:
this.n8_1 = 8;
this.m8_1 = 1;
continue $sm;
case 1:
if (!this.z1c_1.m1c_1.q16()) {
this.a1d_1 = true;
this.m8_1 = 3;
continue $sm;
} else {
this.m8_1 = 2;
suspendResult = this.z1c_1.i1c_1.f1c(VOID, this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
}
case 2:
this.a1d_1 = suspendResult;
this.m8_1 = 3;
continue $sm;
case 3:
if (!this.a1d_1) {
this.m8_1 = 7;
continue $sm;
}
this.b1d_1 = indexOf(this.z1c_1.m1c_1, this.z1c_1.j1c_1.o(0));
if (this.b1d_1.equals(new Long(-1, -1))) {
var tmp_0 = this.z1c_1.m1c_1;
checkBounds(this.z1c_1, (tmp_0 instanceof Buffer ? tmp_0 : THROW_CCE()).j());
this.z1c_1.p1c_1 = this.z1c_1.p1c_1.r2(this.z1c_1.m1c_1.t17(this.z1c_1.k1c_1.z1b()));
this.m8_1 = 5;
suspendResult = flushIfNeeded(this.z1c_1.k1c_1, this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
} else {
checkBounds(this.z1c_1, this.b1d_1);
var tmp_1 = this.z1c_1;
var tmp_2 = this.z1c_1.p1c_1;
var tmp_3 = this.z1c_1.k1c_1.z1b();
tmp_1.p1c_1 = tmp_2.r2(this.z1c_1.m1c_1.q17(tmp_3 instanceof Buffer ? tmp_3 : THROW_CCE(), this.b1d_1));
this.m8_1 = 4;
suspendResult = flushIfNeeded(this.z1c_1.k1c_1, this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
}
case 4:
return Unit_instance;
case 5:
this.m8_1 = 6;
continue $sm;
case 6:
this.m8_1 = 1;
continue $sm;
case 7:
return Unit_instance;
case 8:
throw this.p8_1;
}
} catch ($p) {
var e = $p;
if (this.n8_1 === 8) {
throw e;
} else {
this.m8_1 = this.n8_1;
this.p8_1 = e;
}
}
while (true);
};
function $checkFullMatchCOROUTINE$5(_this__u8e3s4, resultContinuation) {
CoroutineImpl.call(this, resultContinuation);
this.k1d_1 = _this__u8e3s4;
}
protoOf($checkFullMatchCOROUTINE$5).u8 = function () {
var suspendResult = this.o8_1;
$sm: do
try {
var tmp = this.m8_1;
switch (tmp) {
case 0:
this.n8_1 = 8;
this.m8_1 = 1;
continue $sm;
case 1:
if (!this.k1d_1.m1c_1.q16()) {
this.l1d_1 = true;
this.m8_1 = 3;
continue $sm;
} else {
this.m8_1 = 2;
suspendResult = this.k1d_1.i1c_1.f1c(VOID, this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
}
case 2:
this.l1d_1 = suspendResult;
this.m8_1 = 3;
continue $sm;
case 3:
if (!this.l1d_1) {
this.m8_1 = 7;
continue $sm;
}
this.m1d_1 = this.k1d_1.m1c_1.t16();
if (this.k1d_1.q1c_1 > 0 && !(this.m1d_1 === this.k1d_1.j1c_1.o(this.k1d_1.q1c_1))) {
this.n1d_1 = this.k1d_1.q1c_1;
while (this.k1d_1.q1c_1 > 0 && !(this.m1d_1 === this.k1d_1.j1c_1.o(this.k1d_1.q1c_1))) {
this.k1d_1.q1c_1 = this.k1d_1.n1c_1[this.k1d_1.q1c_1 - 1 | 0];
}
this.o1d_1 = toLong(this.n1d_1 - this.k1d_1.q1c_1 | 0);
checkBounds(this.k1d_1, this.o1d_1);
var tmp_0 = this.k1d_1;
var tmp_1 = this.k1d_1.p1c_1;
var tmp_2 = this.k1d_1.k1c_1.z1b();
tmp_0.p1c_1 = tmp_1.r2(this.k1d_1.o1c_1.q17(tmp_2 instanceof Buffer ? tmp_2 : THROW_CCE(), this.o1d_1));
if (this.k1d_1.q1c_1 === 0 && !(this.m1d_1 === this.k1d_1.j1c_1.o(this.k1d_1.q1c_1))) {
this.m8_1 = 6;
suspendResult = writeByte(this.k1d_1.k1c_1, this.m1d_1, this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
} else {
this.m8_1 = 4;
continue $sm;
}
} else {
this.m8_1 = 5;
continue $sm;
}
case 4:
this.m8_1 = 5;
continue $sm;
case 5:
this.k1d_1.q1c_1 = this.k1d_1.q1c_1 + 1 | 0;
if (this.k1d_1.q1c_1 === this.k1d_1.j1c_1.j()) {
return true;
}
this.k1d_1.o1c_1.j18(this.m1d_1);
this.m8_1 = 1;
continue $sm;
case 6:
var _unary__edvuaz = this.k1d_1.p1c_1;
this.k1d_1.p1c_1 = _unary__edvuaz.w2();
return false;
case 7:
return false;
case 8:
throw this.p8_1;
}
} catch ($p) {
var e = $p;
if (this.n8_1 === 8) {
throw e;
} else {
this.m8_1 = this.n8_1;
this.p8_1 = e;
}
}
while (true);
};
function ByteChannelScanner(channel, matchString, writeChannel, limit) {
limit = limit === VOID ? new Long(-1, 2147483647) : limit;
this.i1c_1 = channel;
this.j1c_1 = matchString;
this.k1c_1 = writeChannel;
this.l1c_1 = limit;
// Inline function 'kotlin.require' call
if (!(this.j1c_1.j() > 0)) {
var message = 'Empty match string not permitted for scanning';
throw IllegalArgumentException_init_$Create$(toString_1(message));
}
this.m1c_1 = this.i1c_1.w1b();
this.n1c_1 = buildPartialMatchTable(this);
this.o1c_1 = new Buffer();
this.p1c_1 = new Long(0, 0);
this.q1c_1 = 0;
}
protoOf(ByteChannelScanner).a1e = function (ignoreMissing, $completion) {
var tmp = new $findNextCOROUTINE$3(this, ignoreMissing, $completion);
tmp.o8_1 = Unit_instance;
tmp.p8_1 = null;
return tmp.u8();
};
function ByteReadChannel$Companion$Empty$1() {
this.b1e_1 = null;
this.c1e_1 = new Buffer();
}
protoOf(ByteReadChannel$Companion$Empty$1).b1c = function () {
return this.b1e_1;
};
protoOf(ByteReadChannel$Companion$Empty$1).d1c = function () {
return true;
};
protoOf(ByteReadChannel$Companion$Empty$1).w1b = function () {
return this.c1e_1;
};
protoOf(ByteReadChannel$Companion$Empty$1).e1c = function (min, $completion) {
return false;
};
protoOf(ByteReadChannel$Companion$Empty$1).h1c = function (cause) {
};
function Companion_0() {
Companion_instance_1 = this;
var tmp = this;
tmp.d1e_1 = new ByteReadChannel$Companion$Empty$1();
}
var Companion_instance_1;
function Companion_getInstance_0() {
if (Companion_instance_1 == null)
new Companion_0();
return Companion_instance_1;
}
function ByteReadChannel_1() {
}
function cancel_0(_this__u8e3s4) {
_this__u8e3s4.h1c(IOException_init_$Create$('Channel was cancelled'));
}
function readRemaining(_this__u8e3s4, $completion) {
var tmp = new $readRemainingCOROUTINE$6(_this__u8e3s4, $completion);
tmp.o8_1 = Unit_instance;
tmp.p8_1 = null;
return tmp.u8();
}
function get_availableForRead(_this__u8e3s4) {
return _this__u8e3s4.w1b().p16().j().z();
}
function readPacket(_this__u8e3s4, packet, $completion) {
var tmp = new $readPacketCOROUTINE$7(_this__u8e3s4, packet, $completion);
tmp.o8_1 = Unit_instance;
tmp.p8_1 = null;
return tmp.u8();
}
function discard(_this__u8e3s4, max, $completion) {
max = max === VOID ? new Long(-1, 2147483647) : max;
var tmp = new $discardCOROUTINE$8(_this__u8e3s4, max, $completion);
tmp.o8_1 = Unit_instance;
tmp.p8_1 = null;
return tmp.u8();
}
function readAvailable(_this__u8e3s4, buffer, offset, length, $completion) {
offset = offset === VOID ? 0 : offset;
length = length === VOID ? buffer.length - offset | 0 : length;
var tmp = new $readAvailableCOROUTINE$10(_this__u8e3s4, buffer, offset, length, $completion);
tmp.o8_1 = Unit_instance;
tmp.p8_1 = null;
return tmp.u8();
}
function toByteArray(_this__u8e3s4, $completion) {
var tmp = new $toByteArrayCOROUTINE$12(_this__u8e3s4, $completion);
tmp.o8_1 = Unit_instance;
tmp.p8_1 = null;
return tmp.u8();
}
function copyTo(_this__u8e3s4, channel, limit, $completion) {
var tmp = new $copyToCOROUTINE$13(_this__u8e3s4, channel, limit, $completion);
tmp.o8_1 = Unit_instance;
tmp.p8_1 = null;
return tmp.u8();
}
function rethrowCloseCauseIfNeeded(_this__u8e3s4) {
var tmp0_safe_receiver = _this__u8e3s4.b1c();
if (tmp0_safe_receiver == null)
null;
else {
// Inline function 'kotlin.let' call
throw tmp0_safe_receiver;
}
}
function readBuffer(_this__u8e3s4, $completion) {
var tmp = new $readBufferCOROUTINE$14(_this__u8e3s4, $completion);
tmp.o8_1 = Unit_instance;
tmp.p8_1 = null;
return tmp.u8();
}
function readUTF8LineTo(_this__u8e3s4, out, max, lineEnding, $completion) {
max = max === VOID ? 2147483647 : max;
lineEnding = lineEnding === VOID ? Companion_getInstance_1().i1h_1 : lineEnding;
var tmp = new $readUTF8LineToCOROUTINE$15(_this__u8e3s4, out, max, lineEnding, $completion);
tmp.o8_1 = Unit_instance;
tmp.p8_1 = null;
return tmp.u8();
}
function rethrowCloseCauseIfNeeded_0(_this__u8e3s4) {
var tmp0_safe_receiver = _this__u8e3s4.b1c();
if (tmp0_safe_receiver == null)
null;
else {
// Inline function 'kotlin.let' call
throw tmp0_safe_receiver;
}
}
function rethrowCloseCauseIfNeeded_1(_this__u8e3s4) {
var tmp0_safe_receiver = _this__u8e3s4.b1c();
if (tmp0_safe_receiver == null)
null;
else {
// Inline function 'kotlin.let' call
throw tmp0_safe_receiver;
}
}
function skipIfFound(_this__u8e3s4, byteString, $completion) {
var tmp = new $skipIfFoundCOROUTINE$16(_this__u8e3s4, byteString, $completion);
tmp.o8_1 = Unit_instance;
tmp.p8_1 = null;
return tmp.u8();
}
function readUntil(_this__u8e3s4, matchString, writeChannel, limit, ignoreMissing, $completion) {
limit = limit === VOID ? new Long(-1, 2147483647) : limit;
ignoreMissing = ignoreMissing === VOID ? false : ignoreMissing;
return (new ByteChannelScanner(_this__u8e3s4, matchString, writeChannel, limit)).a1e(ignoreMissing, $completion);
}
function peek(_this__u8e3s4, count, $completion) {
var tmp = new $peekCOROUTINE$17(_this__u8e3s4, count, $completion);
tmp.o8_1 = Unit_instance;
tmp.p8_1 = null;
return tmp.u8();
}
function readUTF8LineTo$checkLineEndingAllowed($lineEnding, lineEndingToCheck) {
if (!LineEndingMode__contains_impl_q5pr68($lineEnding, lineEndingToCheck)) {
throw IOException_init_$Create$('Unexpected line ending ' + LineEndingMode__toString_impl_j4h76r(lineEndingToCheck) + ', while expected ' + LineEndingMode__toString_impl_j4h76r($lineEnding));
}
}
function $readRemainingCOROUTINE$6(_this__u8e3s4, resultContinuation) {
CoroutineImpl.call(this, resultContinuation);
this.m1e_1 = _this__u8e3s4;
}
protoOf($readRemainingCOROUTINE$6).u8 = function () {
var suspendResult = this.o8_1;
$sm: do
try {
var tmp = this.m8_1;
switch (tmp) {
case 0:
this.n8_1 = 4;
this.n1e_1 = BytePacketBuilder();
this.m8_1 = 1;
continue $sm;
case 1:
if (!!this.m1e_1.d1c()) {
this.m8_1 = 3;
continue $sm;
}
this.n1e_1.i18(this.m1e_1.w1b());
this.m8_1 = 2;
suspendResult = this.m1e_1.f1c(VOID, this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 2:
this.m8_1 = 1;
continue $sm;
case 3:
rethrowCloseCauseIfNeeded(this.m1e_1);
return this.n1e_1.p16();
case 4:
throw this.p8_1;
}
} catch ($p) {
var e = $p;
if (this.n8_1 === 4) {
throw e;
} else {
this.m8_1 = this.n8_1;
this.p8_1 = e;
}
}
while (true);
};
function $readPacketCOROUTINE$7(_this__u8e3s4, packet, resultContinuation) {
CoroutineImpl.call(this, resultContinuation);
this.w1e_1 = _this__u8e3s4;
this.x1e_1 = packet;
}
protoOf($readPacketCOROUTINE$7).u8 = function () {
var suspendResult = this.o8_1;
$sm: do
try {
var tmp = this.m8_1;
switch (tmp) {
case 0:
this.n8_1 = 6;
this.y1e_1 = new Buffer();
this.m8_1 = 1;
continue $sm;
case 1:
if (!(this.y1e_1.j().a1(toLong(this.x1e_1)) < 0)) {
this.m8_1 = 5;
continue $sm;
}
if (this.w1e_1.w1b().q16()) {
this.m8_1 = 2;
suspendResult = this.w1e_1.f1c(VOID, this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
} else {
this.m8_1 = 3;
continue $sm;
}
case 2:
this.m8_1 = 3;
continue $sm;
case 3:
if (this.w1e_1.d1c()) {
this.m8_1 = 5;
continue $sm;
} else {
this.m8_1 = 4;
continue $sm;
}
case 4:
if (get_remaining(this.w1e_1.w1b()).a1(numberToLong(this.x1e_1).s2(this.y1e_1.j())) > 0) {
this.w1e_1.w1b().s17(this.y1e_1, numberToLong(this.x1e_1).s2(this.y1e_1.j()));
} else {
this.w1e_1.w1b().t17(this.y1e_1);
}
this.m8_1 = 1;
continue $sm;
case 5:
if (this.y1e_1.j().a1(toLong(this.x1e_1)) < 0) {
throw EOFException_init_$Create$('Not enough data available, required ' + this.x1e_1 + ' bytes but only ' + this.y1e_1.j().toString() + ' available');
}
return this.y1e_1;
case 6:
throw this.p8_1;
}
} catch ($p) {
var e = $p;
if (this.n8_1 === 6) {
throw e;
} else {
this.m8_1 = this.n8_1;
this.p8_1 = e;
}
}
while (true);
};
function $discardCOROUTINE$8(_this__u8e3s4, max, resultContinuation) {
CoroutineImpl.call(this, resultContinuation);
this.h1f_1 = _this__u8e3s4;
this.i1f_1 = max;
}
protoOf($discardCOROUTINE$8).u8 = function () {
var suspendResult = this.o8_1;
$sm: do
try {
var tmp = this.m8_1;
switch (tmp) {
case 0:
this.n8_1 = 5;
this.j1f_1 = this.i1f_1;
this.m8_1 = 1;
continue $sm;
case 1:
if (!(this.j1f_1.a1(new Long(0, 0)) > 0 && !this.h1f_1.d1c())) {
this.m8_1 = 4;
continue $sm;
}
if (get_availableForRead(this.h1f_1) === 0) {
this.m8_1 = 2;
suspendResult = this.h1f_1.f1c(VOID, this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
} else {
this.m8_1 = 3;
continue $sm;
}
case 2:
this.m8_1 = 3;
continue $sm;
case 3:
var tmp0 = this.j1f_1;
var b = get_remaining(this.h1f_1.w1b());
var count = tmp0.a1(b) <= 0 ? tmp0 : b;
discard_0(this.h1f_1.w1b(), count);
this.j1f_1 = this.j1f_1.s2(count);
this.m8_1 = 1;
continue $sm;
case 4:
return this.i1f_1.s