net.akehurst.language-agl-processor
Version:
2,635 lines • 83.7 kB
JavaScript
import {
initMetadataForInterface1egvbzx539z91 as initMetadataForInterface,
isInterface3d6p8outrmvmk as isInterface,
THROW_CCE2g6jy02ryeudk as THROW_CCE,
IllegalStateExceptionkoljg5n0nrlr as IllegalStateException,
toString1pkumu07cwy4m as toString,
Unit_instance1fbcbse1fwigr as Unit_instance,
VOID3gxj6tk5isa35 as VOID,
toString30pk9tzaqopn as toString_0,
get_COROUTINE_SUSPENDED3ujt3p13qm4iy as get_COROUTINE_SUSPENDED,
initMetadataForClassbxx6q50dy2s7 as initMetadataForClass,
initMetadataForObject1cxne3s9w65el as initMetadataForObject,
hashCodeq5arwsb9dgti as hashCode,
equals2au1ep9vhcato as equals,
CancellationException3b36o9qz53rgr as CancellationException,
Result__exceptionOrNull_impl_p6xea9ty3elzpd9eo3 as Result__exceptionOrNull_impl_p6xea9,
_Result___get_value__impl__bjfvqg2ei4op8d4d2m as _Result___get_value__impl__bjfvqg,
AbstractCoroutineContextKey9xr9r6wlj5bm as AbstractCoroutineContextKey,
Key_instance17k9ki7fvysxq as Key_instance,
AbstractCoroutineContextElement2rpehg0hv5szw as AbstractCoroutineContextElement,
getxe4seun860fg as get,
protoOf180f3jzyo7rfj as protoOf,
ContinuationInterceptor2624y0vaqwxwf as ContinuationInterceptor,
RuntimeException1r3t0zl97011n as RuntimeException,
addSuppressedu5jwjfvsc039 as addSuppressed,
ArrayDeque2dzc9uld4xi7n as ArrayDeque,
add2suhfggl4zvkk as add,
subtract2orl8z9upxd9l as subtract,
captureStack1fzi4aczwc4hg as captureStack,
Error3ofk6owajcepa as Error_0,
StringBuildermazzzhj6kkai as StringBuilder,
throwUninitializedPropertyAccessExceptionyynx7gkm73wd as throwUninitializedPropertyAccessException,
Element2gr7ezmxqaln7 as Element,
anyToString3ho3k49fc56mj as anyToString,
ensureNotNull1e947j3ixpazm as ensureNotNull,
fromInt2ii0rejb1w62w as fromInt,
Exceptiondt2hlxn7j7vw as Exception,
IllegalArgumentException2asla15b5jaob as IllegalArgumentException,
Companion_instance2oawqq9qiaris as Companion_instance,
_Result___init__impl__xyqfz83hut4nr3dfvi3 as _Result___init__impl__xyqfz8,
createFailure8paxfkfa5dc7 as createFailure,
convertToInty04h231mmjoh as convertToInt,
toLongOrNullutqivezb0wx1 as toLongOrNull,
intercepted2ogpsikxxj4u0 as intercepted,
Unitkvevlwgzwiuc as Unit,
suspendOrReturn49pspzlx5djv as suspendOrReturn,
dividelr0uqtdj497z as divide,
modulooi4g1kq3dmtt as modulo,
getKClassFromExpression348iqjl4fnx2f as getKClassFromExpression,
UnsupportedOperationException2tkumpmhredt3 as UnsupportedOperationException,
LinkedHashSet2tkztfx86kyx2 as LinkedHashSet,
} from './kotlin-kotlin-stdlib.mjs';
import {
atomic$int$11d5swdyn6j0pu as atomic$int$1,
atomic$ref$130aurmcwdfdf1 as atomic$ref$1,
atomic$boolean$1iggki4z65a2h as atomic$boolean$1,
atomic$long$129k9zwo6n9ogd as atomic$long$1,
atomicfu$AtomicRefArray$ofNulls2kz3j9ehigwa3 as atomicfu$AtomicRefArray$ofNulls,
} from './kotlinx-atomicfu.mjs';
//region block: imports
var imul = Math.imul;
//endregion
//region block: pre-declaration
class CancellableContinuation {}
class SchedulerTask {}
class DispatchedTask extends SchedulerTask {
constructor(resumeMode) {
super();
this.hs_1 = resumeMode;
}
gt(takenState, cause) {
}
rt(state) {
return (state == null ? true : !(state == null)) ? state : THROW_CCE();
}
cu(state) {
var tmp0_safe_receiver = state instanceof CompletedExceptionally ? state : null;
return tmp0_safe_receiver == null ? null : tmp0_safe_receiver.at_1;
}
eu() {
// Inline function 'kotlinx.coroutines.assert' call
try {
var tmp = this.et();
var delegate = tmp instanceof DispatchedContinuation ? tmp : THROW_CCE();
var continuation = delegate.tr_1;
// Inline function 'kotlinx.coroutines.withContinuationContext' call
delegate.vr_1;
var context = continuation.sb();
var state = this.ft();
var exception = this.cu(state);
var job = exception == null && get_isCancellableMode(this.hs_1) ? context.fc(Key_instance_2) : null;
if (!(job == null) && !job.qt()) {
var cause = job.nt();
this.gt(state, cause);
// Inline function 'kotlinx.coroutines.resumeWithStackTrace' call
// Inline function 'kotlin.Companion.failure' call
var exception_0 = recoverStackTrace(cause, continuation);
var tmp$ret$1 = _Result___init__impl__xyqfz8(createFailure(exception_0));
continuation.ub(tmp$ret$1);
} else {
if (!(exception == null)) {
// Inline function 'kotlin.coroutines.resumeWithException' call
// Inline function 'kotlin.Companion.failure' call
var tmp$ret$3 = _Result___init__impl__xyqfz8(createFailure(exception));
continuation.ub(tmp$ret$3);
} else {
// Inline function 'kotlin.coroutines.resume' call
// Inline function 'kotlin.Companion.success' call
var value = this.rt(state);
var tmp$ret$5 = _Result___init__impl__xyqfz8(value);
continuation.ub(tmp$ret$5);
}
}
} catch ($p) {
if ($p instanceof DispatchException) {
var e = $p;
handleCoroutineException(this.et().sb(), e.ev_1);
} else {
if ($p instanceof Error) {
var e_0 = $p;
this.fu(e_0);
} else {
throw $p;
}
}
}
}
fu(exception) {
var reason = CoroutinesInternalError.zv('Fatal exception in coroutines machinery for ' + toString(this) + '. ' + "Please read KDoc to 'handleFatalException' method and report this incident to maintainers", exception);
handleCoroutineException(this.et().sb(), reason);
}
}
class Waiter {}
class CancellableContinuationImpl extends DispatchedTask {
constructor(delegate, resumeMode) {
super(resumeMode);
this.zr_1 = delegate;
// Inline function 'kotlinx.coroutines.assert' call
this.as_1 = this.zr_1.sb();
var tmp = this;
// Inline function 'kotlinx.coroutines.decisionAndIndex' call
var tmp$ret$1 = (0 << 29) + 536870911 | 0;
tmp.bs_1 = atomic$int$1(tmp$ret$1);
this.cs_1 = atomic$ref$1(Active_instance);
this.ds_1 = atomic$ref$1(null);
}
et() {
return this.zr_1;
}
sb() {
return this.as_1;
}
fs() {
return this.cs_1.kotlinx$atomicfu$value;
}
es() {
// Inline function 'kotlinx.coroutines.assert' call
// Inline function 'kotlinx.coroutines.assert' call
var state = this.cs_1.kotlinx$atomicfu$value;
// Inline function 'kotlinx.coroutines.assert' call
var tmp;
if (state instanceof CompletedContinuation) {
tmp = !(state.vs_1 == null);
} else {
tmp = false;
}
if (tmp) {
this.dt();
return false;
}
var tmp_0 = this.bs_1;
// Inline function 'kotlinx.coroutines.decisionAndIndex' call
tmp_0.kotlinx$atomicfu$value = (0 << 29) + 536870911 | 0;
this.cs_1.kotlinx$atomicfu$value = Active_instance;
return true;
}
ft() {
return this.fs();
}
gt(takenState, cause) {
var this_0 = this.cs_1;
while (true) {
var state = this_0.kotlinx$atomicfu$value;
if (!(state == null) ? isInterface(state, NotCompleted) : false) {
// Inline function 'kotlin.error' call
var message = 'Not completed';
throw IllegalStateException.t4(toString(message));
} else {
if (state instanceof CompletedExceptionally)
return Unit_instance;
else {
if (state instanceof CompletedContinuation) {
// Inline function 'kotlin.check' call
if (!!state.ys()) {
var message_0 = 'Must be called at most once';
throw IllegalStateException.t4(toString(message_0));
}
var update = state.zs(VOID, VOID, VOID, VOID, cause);
if (this.cs_1.atomicfu$compareAndSet(state, update)) {
state.ht(this, cause);
return Unit_instance;
}
} else {
if (this.cs_1.atomicfu$compareAndSet(state, new CompletedContinuation(state, VOID, VOID, VOID, cause))) {
return Unit_instance;
}
}
}
}
}
return Unit_instance;
}
it(cause) {
// Inline function 'kotlinx.atomicfu.loop' call
var this_0 = this.cs_1;
while (true) {
var tmp0 = this_0.kotlinx$atomicfu$value;
$l$block: {
if (!(!(tmp0 == null) ? isInterface(tmp0, NotCompleted) : false))
return false;
var tmp;
if (isInterface(tmp0, CancelHandler)) {
tmp = true;
} else {
tmp = tmp0 instanceof Segment;
}
var update = new CancelledContinuation(this, cause, tmp);
if (!this.cs_1.atomicfu$compareAndSet(tmp0, update)) {
break $l$block;
}
if (isInterface(tmp0, CancelHandler)) {
this.xs(tmp0, cause);
} else {
if (tmp0 instanceof Segment) {
callSegmentOnCancellation(this, tmp0, cause);
}
}
detachChildIfNonReusable(this);
dispatchResume(this, this.hs_1);
return true;
}
}
}
jt(cause) {
if (cancelLater(this, cause))
return Unit_instance;
this.it(cause);
detachChildIfNonReusable(this);
}
xs(handler, cause) {
// Inline function 'kotlinx.coroutines.CancellableContinuationImpl.callCancelHandlerSafely' call
try {
handler.kt(cause);
} catch ($p) {
if ($p instanceof Error) {
var ex = $p;
handleCoroutineException(this.sb(), CompletionHandlerException.rs('Exception in invokeOnCancellation handler for ' + this.toString(), ex));
} else {
throw $p;
}
}
return Unit_instance;
}
lt(onCancellation, cause, value) {
try {
onCancellation(cause, value, this.sb());
} catch ($p) {
if ($p instanceof Error) {
var ex = $p;
handleCoroutineException(this.sb(), CompletionHandlerException.rs('Exception in resume onCancellation handler for ' + this.toString(), ex));
} else {
throw $p;
}
}
}
mt(parent) {
return parent.nt();
}
ot() {
var isReusable_0 = isReusable(this);
if (trySuspend(this)) {
if (_get_parentHandle__f8dcex(this) == null) {
installParentHandle(this);
}
if (isReusable_0) {
this.pt();
}
return get_COROUTINE_SUSPENDED();
}
if (isReusable_0) {
this.pt();
}
var state = this.fs();
if (state instanceof CompletedExceptionally)
throw recoverStackTrace(state.at_1, this);
if (get_isCancellableMode(this.hs_1)) {
var job = this.sb().fc(Key_instance_2);
if (!(job == null) && !job.qt()) {
var cause = job.nt();
this.gt(state, cause);
throw recoverStackTrace(cause, this);
}
}
return this.rt(state);
}
pt() {
var tmp = this.zr_1;
var tmp0_safe_receiver = tmp instanceof DispatchedContinuation ? tmp : null;
var tmp1_elvis_lhs = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.st(this);
var tmp_0;
if (tmp1_elvis_lhs == null) {
return Unit_instance;
} else {
tmp_0 = tmp1_elvis_lhs;
}
var cancellationCause = tmp_0;
this.dt();
this.it(cancellationCause);
}
ub(result) {
return this.tt(toState(result, this), this.hs_1);
}
ut(value, onCancellation) {
var tmp = this.hs_1;
var tmp_0;
if (onCancellation == null) {
tmp_0 = null;
} else {
// Inline function 'kotlin.let' call
tmp_0 = CancellableContinuationImpl$resume$lambda(onCancellation);
}
return this.vt(value, tmp, tmp_0);
}
qr(value, onCancellation) {
return this.vt(value, this.hs_1, onCancellation);
}
wt(segment, index) {
var tmp0 = this.bs_1;
$l$block: {
// Inline function 'kotlinx.atomicfu.update' call
while (true) {
var cur = tmp0.kotlinx$atomicfu$value;
// Inline function 'kotlinx.coroutines.index' call
// Inline function 'kotlin.check' call
if (!((cur & 536870911) === 536870911)) {
var message = 'invokeOnCancellation should be called at most once';
throw IllegalStateException.t4(toString(message));
}
// Inline function 'kotlinx.coroutines.decision' call
// Inline function 'kotlinx.coroutines.decisionAndIndex' call
var upd = (cur >> 29 << 29) + index | 0;
if (tmp0.atomicfu$compareAndSet(cur, upd)) {
break $l$block;
}
}
}
invokeOnCancellationImpl(this, segment);
}
vt(proposedUpdate, resumeMode, onCancellation) {
// Inline function 'kotlinx.atomicfu.loop' call
var this_0 = this.cs_1;
while (true) {
var tmp0 = this_0.kotlinx$atomicfu$value;
$l$block: {
if (!(tmp0 == null) ? isInterface(tmp0, NotCompleted) : false) {
var update = resumedState(this, tmp0, proposedUpdate, resumeMode, onCancellation, null);
if (!this.cs_1.atomicfu$compareAndSet(tmp0, update)) {
break $l$block;
}
detachChildIfNonReusable(this);
dispatchResume(this, resumeMode);
return Unit_instance;
} else {
if (tmp0 instanceof CancelledContinuation) {
if (tmp0.au()) {
if (onCancellation == null)
null;
else {
// Inline function 'kotlin.let' call
this.lt(onCancellation, tmp0.at_1, proposedUpdate);
}
return Unit_instance;
}
}
}
alreadyResumedError(this, proposedUpdate);
}
}
}
tt(proposedUpdate, resumeMode, onCancellation, $super) {
onCancellation = onCancellation === VOID ? null : onCancellation;
var tmp;
if ($super === VOID) {
this.vt(proposedUpdate, resumeMode, onCancellation);
tmp = Unit_instance;
} else {
tmp = $super.vt.call(this, proposedUpdate, resumeMode, onCancellation);
}
return tmp;
}
dt() {
var tmp0_elvis_lhs = _get_parentHandle__f8dcex(this);
var tmp;
if (tmp0_elvis_lhs == null) {
return Unit_instance;
} else {
tmp = tmp0_elvis_lhs;
}
var handle = tmp;
handle.bu();
this.ds_1.kotlinx$atomicfu$value = NonDisposableHandle_instance;
}
or(value, idempotent, onCancellation) {
return tryResumeImpl(this, value, idempotent, onCancellation);
}
pr(token) {
// Inline function 'kotlinx.coroutines.assert' call
dispatchResume(this, this.hs_1);
}
rt(state) {
var tmp;
if (state instanceof CompletedContinuation) {
var tmp_0 = state.ss_1;
tmp = (tmp_0 == null ? true : !(tmp_0 == null)) ? tmp_0 : THROW_CCE();
} else {
tmp = (state == null ? true : !(state == null)) ? state : THROW_CCE();
}
return tmp;
}
cu(state) {
var tmp0_safe_receiver = super.cu(state);
var tmp;
if (tmp0_safe_receiver == null) {
tmp = null;
} else {
// Inline function 'kotlin.let' call
tmp = recoverStackTrace(tmp0_safe_receiver, this.zr_1);
}
return tmp;
}
toString() {
return this.du() + '(' + toDebugString(this.zr_1) + '){' + _get_stateDebugRepresentation__bf18u4(this) + '}@' + get_hexAddress(this);
}
du() {
return 'CancellableContinuation';
}
}
class NotCompleted {}
class CancelHandler {}
class Active {
toString() {
return 'Active';
}
}
class CompletedContinuation {
constructor(result, cancelHandler, onCancellation, idempotentResume, cancelCause) {
cancelHandler = cancelHandler === VOID ? null : cancelHandler;
onCancellation = onCancellation === VOID ? null : onCancellation;
idempotentResume = idempotentResume === VOID ? null : idempotentResume;
cancelCause = cancelCause === VOID ? null : cancelCause;
this.ss_1 = result;
this.ts_1 = cancelHandler;
this.us_1 = onCancellation;
this.vs_1 = idempotentResume;
this.ws_1 = cancelCause;
}
ys() {
return !(this.ws_1 == null);
}
ht(cont, cause) {
var tmp0_safe_receiver = this.ts_1;
if (tmp0_safe_receiver == null)
null;
else {
// Inline function 'kotlin.let' call
cont.xs(tmp0_safe_receiver, cause);
}
var tmp1_safe_receiver = this.us_1;
if (tmp1_safe_receiver == null)
null;
else {
// Inline function 'kotlin.let' call
cont.lt(tmp1_safe_receiver, cause, this.ss_1);
}
}
gu(result, cancelHandler, onCancellation, idempotentResume, cancelCause) {
return new CompletedContinuation(result, cancelHandler, onCancellation, idempotentResume, cancelCause);
}
zs(result, cancelHandler, onCancellation, idempotentResume, cancelCause, $super) {
result = result === VOID ? this.ss_1 : result;
cancelHandler = cancelHandler === VOID ? this.ts_1 : cancelHandler;
onCancellation = onCancellation === VOID ? this.us_1 : onCancellation;
idempotentResume = idempotentResume === VOID ? this.vs_1 : idempotentResume;
cancelCause = cancelCause === VOID ? this.ws_1 : cancelCause;
return $super === VOID ? this.gu(result, cancelHandler, onCancellation, idempotentResume, cancelCause) : $super.gu.call(this, result, cancelHandler, onCancellation, idempotentResume, cancelCause);
}
toString() {
return 'CompletedContinuation(result=' + toString_0(this.ss_1) + ', cancelHandler=' + toString_0(this.ts_1) + ', onCancellation=' + toString_0(this.us_1) + ', idempotentResume=' + toString_0(this.vs_1) + ', cancelCause=' + toString_0(this.ws_1) + ')';
}
hashCode() {
var result = this.ss_1 == null ? 0 : hashCode(this.ss_1);
result = imul(result, 31) + (this.ts_1 == null ? 0 : hashCode(this.ts_1)) | 0;
result = imul(result, 31) + (this.us_1 == null ? 0 : hashCode(this.us_1)) | 0;
result = imul(result, 31) + (this.vs_1 == null ? 0 : hashCode(this.vs_1)) | 0;
result = imul(result, 31) + (this.ws_1 == null ? 0 : hashCode(this.ws_1)) | 0;
return result;
}
equals(other) {
if (this === other)
return true;
if (!(other instanceof CompletedContinuation))
return false;
var tmp0_other_with_cast = other instanceof CompletedContinuation ? other : THROW_CCE();
if (!equals(this.ss_1, tmp0_other_with_cast.ss_1))
return false;
if (!equals(this.ts_1, tmp0_other_with_cast.ts_1))
return false;
if (!equals(this.us_1, tmp0_other_with_cast.us_1))
return false;
if (!equals(this.vs_1, tmp0_other_with_cast.vs_1))
return false;
if (!equals(this.ws_1, tmp0_other_with_cast.ws_1))
return false;
return true;
}
}
class LockFreeLinkedListNode {
constructor() {
this.tu_1 = this;
this.uu_1 = this;
this.vu_1 = false;
}
wu(node, permissionsBitmask) {
var prev = this.uu_1;
var tmp;
if (prev instanceof ListClosed) {
tmp = ((prev.wy_1 & permissionsBitmask) === 0 && prev.wu(node, permissionsBitmask));
} else {
node.tu_1 = this;
node.uu_1 = prev;
prev.tu_1 = node;
this.uu_1 = node;
tmp = true;
}
return tmp;
}
xu() {
if (this.vu_1)
return false;
var prev = this.uu_1;
var next = this.tu_1;
prev.tu_1 = next;
next.uu_1 = prev;
this.vu_1 = true;
return true;
}
yu(node) {
if (!(this.tu_1 === this))
return false;
this.wu(node, -2147483648);
return true;
}
}
class Incomplete {}
class JobNode extends LockFreeLinkedListNode {
ru() {
var tmp = this.qu_1;
if (!(tmp == null))
return tmp;
else {
throwUninitializedPropertyAccessException('job');
}
}
su() {
return null;
}
bu() {
return this.ru().iw(this);
}
toString() {
return get_classSimpleName(this) + '@' + get_hexAddress(this) + '[job@' + get_hexAddress(this.ru()) + ']';
}
}
class ChildContinuation extends JobNode {
constructor(child) {
super();
this.lu_1 = child;
}
mu() {
return true;
}
kt(cause) {
this.lu_1.jt(this.lu_1.mt(this.ru()));
}
}
class CompletedExceptionally {
constructor(cause, handled) {
handled = handled === VOID ? false : handled;
this.at_1 = cause;
this.bt_1 = atomic$boolean$1(handled);
}
ct() {
return this.bt_1.atomicfu$compareAndSet(false, true);
}
toString() {
return get_classSimpleName(this) + '[' + this.at_1.toString() + ']';
}
}
class CancelledContinuation extends CompletedExceptionally {
constructor(continuation, cause, handled) {
super(cause == null ? CancellationException.oc('Continuation ' + toString(continuation) + ' was cancelled normally') : cause, handled);
this.zt_1 = atomic$boolean$1(false);
}
au() {
return this.zt_1.atomicfu$compareAndSet(false, true);
}
}
class Key extends AbstractCoroutineContextKey {
constructor() {
Key_instance_0 = null;
var tmp = Key_instance;
super(tmp, CoroutineDispatcher$Key$_init_$lambda_akl8b5);
Key_instance_0 = this;
}
}
class CoroutineDispatcher extends AbstractCoroutineContextElement {
constructor() {
Key_getInstance();
super(Key_instance);
}
av(context) {
return true;
}
gc(continuation) {
return new DispatchedContinuation(this, continuation);
}
hc(continuation) {
var dispatched = continuation instanceof DispatchedContinuation ? continuation : THROW_CCE();
dispatched.cv();
}
toString() {
return get_classSimpleName(this) + '@' + get_hexAddress(this);
}
}
class Key_0 {}
class EventLoop extends CoroutineDispatcher {
constructor() {
super();
this.iv_1 = 0n;
this.jv_1 = false;
this.kv_1 = null;
}
lv() {
var tmp0_elvis_lhs = this.kv_1;
var tmp;
if (tmp0_elvis_lhs == null) {
return false;
} else {
tmp = tmp0_elvis_lhs;
}
var queue = tmp;
var tmp1_elvis_lhs = queue.sh();
var tmp_0;
if (tmp1_elvis_lhs == null) {
return false;
} else {
tmp_0 = tmp1_elvis_lhs;
}
var task = tmp_0;
task.eu();
return true;
}
mv(task) {
var tmp0_elvis_lhs = this.kv_1;
var tmp;
if (tmp0_elvis_lhs == null) {
// Inline function 'kotlin.also' call
var this_0 = ArrayDeque.oh();
this.kv_1 = this_0;
tmp = this_0;
} else {
tmp = tmp0_elvis_lhs;
}
var queue = tmp;
queue.qh(task);
}
nv() {
return this.iv_1 >= delta(this, true);
}
ov() {
var tmp0_safe_receiver = this.kv_1;
var tmp1_elvis_lhs = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.l1();
return tmp1_elvis_lhs == null ? true : tmp1_elvis_lhs;
}
pv(unconfined) {
this.iv_1 = add(this.iv_1, delta(this, unconfined));
if (!unconfined)
this.jv_1 = true;
}
qv(unconfined) {
this.iv_1 = subtract(this.iv_1, delta(this, unconfined));
if (this.iv_1 > 0n)
return Unit_instance;
// Inline function 'kotlinx.coroutines.assert' call
if (this.jv_1) {
this.rv();
}
}
rv() {
}
}
class ThreadLocalEventLoop {
constructor() {
ThreadLocalEventLoop_instance = this;
this.sv_1 = commonThreadLocal(new Symbol('ThreadLocalEventLoop'));
}
tv() {
var tmp0_elvis_lhs = this.sv_1.vv();
var tmp;
if (tmp0_elvis_lhs == null) {
// Inline function 'kotlin.also' call
var this_0 = createEventLoop();
ThreadLocalEventLoop_getInstance().sv_1.wv(this_0);
tmp = this_0;
} else {
tmp = tmp0_elvis_lhs;
}
return tmp;
}
}
class CompletionHandlerException extends RuntimeException {
static rs(message, cause) {
var $this = this.vc(message, cause);
captureStack($this, $this.qs_1);
return $this;
}
}
class CoroutinesInternalError extends Error_0 {
static zv(message, cause) {
var $this = this.xc(message, cause);
captureStack($this, $this.yv_1);
return $this;
}
}
class Key_1 {}
class NonDisposableHandle {
bu() {
}
toString() {
return 'NonDisposableHandle';
}
}
class Empty {
constructor(isActive) {
this.dw_1 = isActive;
}
su() {
return null;
}
toString() {
return 'Empty{' + (this.dw_1 ? 'Active' : 'New') + '}';
}
}
class LockFreeLinkedListHead extends LockFreeLinkedListNode {}
class NodeList extends LockFreeLinkedListHead {
su() {
return this;
}
hw(state) {
// Inline function 'kotlin.text.buildString' call
// Inline function 'kotlin.apply' call
var this_0 = StringBuilder.s();
this_0.ya('List{');
this_0.ya(state);
this_0.ya('}[');
var first = true;
// Inline function 'kotlinx.coroutines.internal.LockFreeLinkedListHead.forEach' call
var cur = this.tu_1;
while (!equals(cur, this)) {
var node = cur;
if (node instanceof JobNode) {
if (first) {
first = false;
} else
this_0.ya(', ');
this_0.xa(node);
}
cur = cur.tu_1;
}
this_0.ya(']');
return this_0.toString();
}
toString() {
return get_DEBUG() ? this.hw('Active') : super.toString();
}
}
class SynchronizedObject {}
class Finishing extends SynchronizedObject {
kw() {
return this.jw_1.kotlinx$atomicfu$value;
}
}
class JobSupport {
fs() {
return this.bw_1.kotlinx$atomicfu$value;
}
cw(invokeImmediately, node) {
node.qu_1 = this;
var tmp$ret$0;
$l$block_1: {
// Inline function 'kotlinx.coroutines.JobSupport.tryPutNodeIntoList' call
// Inline function 'kotlinx.coroutines.JobSupport.loopOnState' call
while (true) {
var state = this.fs();
if (state instanceof Empty) {
if (state.dw_1) {
if (this.bw_1.atomicfu$compareAndSet(state, node)) {
tmp$ret$0 = true;
break $l$block_1;
}
} else {
promoteEmptyToNodeList(this, state);
}
} else {
if (!(state == null) ? isInterface(state, Incomplete) : false) {
var list = state.su();
if (list == null) {
promoteSingleToNodeList(this, state instanceof JobNode ? state : THROW_CCE());
} else {
var tmp;
if (node.mu()) {
var tmp0_safe_receiver = state instanceof Finishing ? state : null;
var rootCause = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.kw();
var tmp_0;
if (rootCause == null) {
tmp_0 = list.wu(node, 5);
} else {
if (invokeImmediately) {
node.kt(rootCause);
}
return NonDisposableHandle_instance;
}
tmp = tmp_0;
} else {
tmp = list.wu(node, 1);
}
if (tmp) {
tmp$ret$0 = true;
break $l$block_1;
}
}
} else {
tmp$ret$0 = false;
break $l$block_1;
}
}
}
}
var added = tmp$ret$0;
if (added)
return node;
else if (invokeImmediately) {
var tmp_1 = this.fs();
var tmp0_safe_receiver_0 = tmp_1 instanceof CompletedExceptionally ? tmp_1 : null;
node.kt(tmp0_safe_receiver_0 == null ? null : tmp0_safe_receiver_0.at_1);
}
return NonDisposableHandle_instance;
}
iw(node) {
// Inline function 'kotlinx.coroutines.JobSupport.loopOnState' call
while (true) {
var state = this.fs();
if (state instanceof JobNode) {
if (!(state === node))
return Unit_instance;
if (this.bw_1.atomicfu$compareAndSet(state, get_EMPTY_ACTIVE()))
return Unit_instance;
} else {
if (!(state == null) ? isInterface(state, Incomplete) : false) {
if (!(state.su() == null)) {
node.xu();
}
return Unit_instance;
} else {
return Unit_instance;
}
}
}
}
}
class InactiveNodeList {
constructor(list) {
this.lw_1 = list;
}
su() {
return this.lw_1;
}
toString() {
return get_DEBUG() ? this.lw_1.hw('New') : anyToString(this);
}
}
class ConcurrentLinkedListNode {
constructor(prev) {
this.ow_1 = atomic$ref$1(null);
this.pw_1 = atomic$ref$1(prev);
}
uw() {
// Inline function 'kotlinx.coroutines.internal.ConcurrentLinkedListNode.nextOrIfClosed' call
// Inline function 'kotlin.let' call
var it = access$_get_nextOrClosed__ywzond(this);
var tmp;
if (it === access$_get_CLOSED_$tConcurrentLinkedListKt_wmtpdy()) {
return null;
} else {
tmp = (it == null ? true : it instanceof ConcurrentLinkedListNode) ? it : THROW_CCE();
}
return tmp;
}
vw(value) {
return this.ow_1.atomicfu$compareAndSet(null, value);
}
qw() {
return this.uw() == null;
}
ww() {
return this.pw_1.kotlinx$atomicfu$value;
}
xw() {
// Inline function 'kotlinx.atomicfu.AtomicRef.lazySet' call
this.pw_1.kotlinx$atomicfu$value = null;
}
v5() {
// Inline function 'kotlinx.coroutines.assert' call
if (this.qw())
return Unit_instance;
$l$loop_0: while (true) {
var prev = _get_aliveSegmentLeft__mr4ndu(this);
var next = _get_aliveSegmentRight__7ulr0b(this);
var tmp0 = next.pw_1;
$l$block: {
// Inline function 'kotlinx.atomicfu.update' call
while (true) {
var cur = tmp0.kotlinx$atomicfu$value;
var upd = cur === null ? null : prev;
if (tmp0.atomicfu$compareAndSet(cur, upd)) {
break $l$block;
}
}
}
if (!(prev === null))
prev.ow_1.kotlinx$atomicfu$value = next;
if (next.nw() && !next.qw())
continue $l$loop_0;
if (!(prev === null) && prev.nw())
continue $l$loop_0;
return Unit_instance;
}
}
}
class Segment extends ConcurrentLinkedListNode {
constructor(id, prev, pointers) {
super(prev);
this.ls_1 = id;
this.ms_1 = atomic$int$1(pointers << 16);
}
nw() {
return this.ms_1.kotlinx$atomicfu$value === this.mw() && !this.qw();
}
rw() {
var tmp0 = this.ms_1;
var tmp$ret$1;
$l$block_0: {
// Inline function 'kotlinx.coroutines.internal.addConditionally' call
while (true) {
var cur = tmp0.kotlinx$atomicfu$value;
if (!(!(cur === this.mw()) || this.qw())) {
tmp$ret$1 = false;
break $l$block_0;
}
if (tmp0.atomicfu$compareAndSet(cur, cur + 65536 | 0)) {
tmp$ret$1 = true;
break $l$block_0;
}
}
}
return tmp$ret$1;
}
sw() {
return this.ms_1.atomicfu$addAndGet(-65536) === this.mw() && !this.qw();
}
tw() {
if (this.ms_1.atomicfu$incrementAndGet() === this.mw()) {
this.v5();
}
}
}
class ExceptionSuccessfullyProcessed extends Exception {}
class DispatchedContinuation extends DispatchedTask {
constructor(dispatcher, continuation) {
super(-1);
this.sr_1 = dispatcher;
this.tr_1 = continuation;
this.ur_1 = get_UNDEFINED();
this.vr_1 = threadContextElements(this.sb());
this.wr_1 = atomic$ref$1(null);
}
gs() {
return !(this.wr_1.kotlinx$atomicfu$value == null);
}
cx() {
// Inline function 'kotlinx.atomicfu.loop' call
var this_0 = this.wr_1;
while (true) {
if (!(this_0.kotlinx$atomicfu$value === get_REUSABLE_CLAIMED()))
return Unit_instance;
}
}
cv() {
this.cx();
var tmp0_safe_receiver = _get_reusableCancellableContinuation__9qex09(this);
if (tmp0_safe_receiver == null)
null;
else {
tmp0_safe_receiver.dt();
}
}
xr() {
// Inline function 'kotlinx.atomicfu.loop' call
var this_0 = this.wr_1;
while (true) {
var state = this_0.kotlinx$atomicfu$value;
if (state === null) {
this.wr_1.kotlinx$atomicfu$value = get_REUSABLE_CLAIMED();
return null;
} else {
if (state instanceof CancellableContinuationImpl) {
if (this.wr_1.atomicfu$compareAndSet(state, get_REUSABLE_CLAIMED())) {
return state instanceof CancellableContinuationImpl ? state : THROW_CCE();
}
} else {
if (state !== get_REUSABLE_CLAIMED()) {
if (!(state instanceof Error)) {
// Inline function 'kotlin.error' call
var message = 'Inconsistent state ' + toString_0(state);
throw IllegalStateException.t4(toString(message));
}
}
}
}
}
}
st(continuation) {
// Inline function 'kotlinx.atomicfu.loop' call
var this_0 = this.wr_1;
while (true) {
var state = this_0.kotlinx$atomicfu$value;
if (state === get_REUSABLE_CLAIMED()) {
if (this.wr_1.atomicfu$compareAndSet(get_REUSABLE_CLAIMED(), continuation))
return null;
} else {
if (state instanceof Error) {
// Inline function 'kotlin.require' call
// Inline function 'kotlin.require' call
if (!this.wr_1.atomicfu$compareAndSet(state, null)) {
var message = 'Failed requirement.';
throw IllegalArgumentException.f1(toString(message));
}
return state;
} else {
// Inline function 'kotlin.error' call
var message_0 = 'Inconsistent state ' + toString_0(state);
throw IllegalStateException.t4(toString(message_0));
}
}
}
}
is(cause) {
// Inline function 'kotlinx.atomicfu.loop' call
var this_0 = this.wr_1;
while (true) {
var state = this_0.kotlinx$atomicfu$value;
if (equals(state, get_REUSABLE_CLAIMED())) {
if (this.wr_1.atomicfu$compareAndSet(get_REUSABLE_CLAIMED(), cause))
return true;
} else {
if (state instanceof Error)
return true;
else {
if (this.wr_1.atomicfu$compareAndSet(state, null))
return false;
}
}
}
}
ft() {
var state = this.ur_1;
// Inline function 'kotlinx.coroutines.assert' call
this.ur_1 = get_UNDEFINED();
return state;
}
et() {
return this;
}
ub(result) {
var state = toState_0(result);
if (safeIsDispatchNeeded(this.sr_1, this.sb())) {
this.ur_1 = state;
this.hs_1 = 0;
safeDispatch(this.sr_1, this.sb(), this);
} else {
$l$block: {
// Inline function 'kotlinx.coroutines.internal.executeUnconfined' call
// Inline function 'kotlinx.coroutines.assert' call
var eventLoop = ThreadLocalEventLoop_getInstance().tv();
if (false && eventLoop.ov()) {
break $l$block;
}
var tmp;
if (eventLoop.nv()) {
this.ur_1 = state;
this.hs_1 = 0;
eventLoop.mv(this);
tmp = true;
} else {
// Inline function 'kotlinx.coroutines.runUnconfinedEventLoop' call
eventLoop.pv(true);
try {
this.sb();
// Inline function 'kotlinx.coroutines.withCoroutineContext' call
this.vr_1;
this.tr_1.ub(result);
$l$loop: while (eventLoop.lv()) {
}
} catch ($p) {
if ($p instanceof Error) {
var e = $p;
this.fu(e);
} else {
throw $p;
}
}
finally {
eventLoop.qv(true);
}
tmp = false;
}
}
}
}
toString() {
return 'DispatchedContinuation[' + this.sr_1.toString() + ', ' + toDebugString(this.tr_1) + ']';
}
sb() {
return this.tr_1.sb();
}
}
class DispatchException extends Exception {
static dx(cause, dispatcher, context) {
var $this = this.sc('Coroutine dispatcher ' + dispatcher.toString() + ' threw an exception, context = ' + toString(context), cause);
captureStack($this, $this.fv_1);
$this.ev_1 = cause;
delete $this.cause;
return $this;
}
m() {
return this.ev_1;
}
get cause() {
return this.m();
}
}
class Symbol {
constructor(symbol) {
this.ex_1 = symbol;
}
toString() {
return '<' + this.ex_1 + '>';
}
}
class SelectInstance {}
class CancellableContinuationWithOwner {
constructor($outer, cont, owner) {
this.sx_1 = $outer;
this.qx_1 = cont;
this.rx_1 = owner;
}
ey(value, idempotent, onCancellation) {
// Inline function 'kotlinx.coroutines.assert' call
var token = this.qx_1.or(value, idempotent, MutexImpl$CancellableContinuationWithOwner$tryResume$lambda(this.sx_1, this));
if (!(token == null)) {
// Inline function 'kotlinx.coroutines.assert' call
this.sx_1.ox_1.kotlinx$atomicfu$value = this.rx_1;
}
return token;
}
or(value, idempotent, onCancellation) {
return this.ey(value instanceof Unit ? value : THROW_CCE(), idempotent, onCancellation);
}
fy(value, onCancellation) {
// Inline function 'kotlinx.coroutines.assert' call
this.sx_1.ox_1.kotlinx$atomicfu$value = this.rx_1;
this.qx_1.ut(Unit_instance, MutexImpl$CancellableContinuationWithOwner$resume$lambda(this.sx_1, this));
}
qr(value, onCancellation) {
return this.fy(value instanceof Unit ? value : THROW_CCE(), onCancellation);
}
pr(token) {
this.qx_1.pr(token);
}
wt(segment, index) {
this.qx_1.wt(segment, index);
}
gy(result) {
this.qx_1.ub(result);
}
ub(result) {
return this.gy(result);
}
sb() {
return this.qx_1.sb();
}
}
class SemaphoreAndMutexImpl {
constructor(permits, acquiredPermits) {
this.wx_1 = permits;
this.yx_1 = atomic$long$1(0n);
this.ay_1 = atomic$long$1(0n);
// Inline function 'kotlin.require' call
if (!(this.wx_1 > 0)) {
var message = 'Semaphore should have at least 1 permit, but had ' + this.wx_1;
throw IllegalArgumentException.f1(toString(message));
}
// Inline function 'kotlin.require' call
if (!(0 <= acquiredPermits ? acquiredPermits <= this.wx_1 : false)) {
var message_0 = 'The number of acquired permits should be in 0..' + this.wx_1;
throw IllegalArgumentException.f1(toString(message_0));
}
var s = new SemaphoreSegment(0n, null, 2);
this.xx_1 = atomic$ref$1(s);
this.zx_1 = atomic$ref$1(s);
this.by_1 = atomic$int$1(this.wx_1 - acquiredPermits | 0);
var tmp = this;
tmp.cy_1 = SemaphoreAndMutexImpl$onCancellationRelease$lambda(this);
}
hy() {
// Inline function 'kotlin.math.max' call
var a = this.by_1.kotlinx$atomicfu$value;
return Math.max(a, 0);
}
dy() {
$l$loop: while (true) {
var p = this.by_1.kotlinx$atomicfu$value;
if (p > this.wx_1) {
coerceAvailablePermitsAtMaximum(this);
continue $l$loop;
}
if (p <= 0)
return false;
if (this.by_1.atomicfu$compareAndSet(p, p - 1 | 0))
return true;
}
}
acquireCont(waiter) {
var tmp$ret$1;
$l$block_0: {
// Inline function 'kotlinx.coroutines.sync.SemaphoreAndMutexImpl.acquire' call
while (true) {
var p = decPermits(this);
if (p > 0) {
waiter.qr(Unit_instance, this.cy_1);
tmp$ret$1 = Unit_instance;
break $l$block_0;
}
if (addAcquireToQueue(this, isInterface(waiter, Waiter) ? waiter : THROW_CCE())) {
tmp$ret$1 = Unit_instance;
break $l$block_0;
}
}
tmp$ret$1 = Unit_instance;
}
return tmp$ret$1;
}
jy() {
while (true) {
var p = this.by_1.atomicfu$getAndIncrement();
if (p >= this.wx_1) {
coerceAvailablePermitsAtMaximum(this);
// Inline function 'kotlin.error' call
var message = 'The number of released permits cannot be greater than ' + this.wx_1;
throw IllegalStateException.t4(toString(message));
}
if (p >= 0)
return Unit_instance;
if (tryResumeNextFromQueue(this))
return Unit_instance;
}
}
}
class MutexImpl extends SemaphoreAndMutexImpl {
constructor(locked) {
super(1, locked ? 1 : 0);
this.ox_1 = atomic$ref$1(locked ? null : get_NO_OWNER());
var tmp = this;
tmp.px_1 = MutexImpl$onSelectCancellationUnlockConstructor$lambda(this);
}
ux() {
return this.hy() === 0;
}
iy(owner, $completion) {
return suspendOrReturn(/*#__NOINLINE__*/_generator_lock__qllepv.bind(VOID, this, owner), $completion);
}
vx(owner) {
var tmp;
switch (tryLockImpl(this, owner)) {
case 0:
tmp = true;
break;
case 1:
tmp = false;
break;
case 2:
var message = 'This mutex is already locked by the specified owner: ' + toString_0(owner);
throw IllegalStateException.t4(toString(message));
default:
var message_0 = 'unexpected';
throw IllegalStateException.t4(toString(message_0));
}
return tmp;
}
tx(owner) {
$l$loop_0: while (true) {
// Inline function 'kotlin.check' call
if (!this.ux()) {
var message = 'This mutex is not locked';
throw IllegalStateException.t4(toString(message));
}
var curOwner = this.ox_1.kotlinx$atomicfu$value;
if (curOwner === get_NO_OWNER())
continue $l$loop_0;
// Inline function 'kotlin.check' call
if (!(curOwner === owner || owner == null)) {
var message_0 = 'This mutex is locked by ' + toString_0(curOwner) + ', but ' + toString_0(owner) + ' is expected';
throw IllegalStateException.t4(toString(message_0));
}
if (!this.ox_1.atomicfu$compareAndSet(curOwner, get_NO_OWNER()))
continue $l$loop_0;
this.jy();
return Unit_instance;
}
}
toString() {
return 'Mutex@' + get_hexAddress(this) + '[isLocked=' + this.ux() + ',owner=' + toString_0(this.ox_1.kotlinx$atomicfu$value) + ']';
}
}
class SemaphoreSegment extends Segment {
constructor(id, prev, pointers) {
super(id, prev, pointers);
this.oy_1 = atomicfu$AtomicRefArray$ofNulls(get_SEGMENT_SIZE());
}
mw() {
return get_SEGMENT_SIZE();
}
ns(index, cause, context) {
// Inline function 'kotlinx.coroutines.sync.SemaphoreSegment.set' call
var value = get_CANCELLED();
this.oy_1.atomicfu$get(index).kotlinx$atomicfu$value = value;
this.tw();
}
toString() {
return 'SemaphoreSegment[id=' + this.ls_1.toString() + ', hashCode=' + hashCode(this) + ']';
}
}
class UnconfinedEventLoop extends EventLoop {
bv(context, block) {
unsupported();
}
}
class DiagnosticCoroutineContextException extends RuntimeException {
static bx(context) {
var $this = this.w9(toString(context));
captureStack($this, $this.ax_1);
return $this;
}
}
class ListClosed extends LockFreeLinkedListNode {}
class CommonThreadLocal {
constructor() {
this.uv_1 = null;
}
vv() {
var tmp = this.uv_1;
return (tmp == null ? true : !(tmp == null)) ? tmp : THROW_CCE();
}
wv(value) {
this.uv_1 = value;
}
}
//endregion
function getOrCreateCancellableContinuation(delegate) {
if (!(delegate instanceof DispatchedContinuation)) {
return new CancellableContinuationImpl(delegate, 1);
}
var tmp0_safe_receiver = delegate.xr();
var tmp;
if (tmp0_safe_receiver == null) {
tmp = null;
} else {
// Inline function 'kotlin.takeIf' call
var tmp_0;
if (tmp0_safe_receiver.es()) {
tmp_0 = tmp0_safe_receiver;
} else {
tmp_0 = null;
}
tmp = tmp_0;
}
var tmp1_elvis_lhs = tmp;
var tmp_1;
if (tmp1_elvis_lhs == null) {
return new CancellableContinuationImpl(delegate, 2);
} else {
tmp_1 = tmp1_elvis_lhs;
}
return tmp_1;
}
function get_RESUME_TOKEN() {
_init_properties_CancellableContinuationImpl_kt__6rrtdd();
return RESUME_TOKEN;
}
var RESUME_TOKEN;
function _get_parentHandle__f8dcex($this) {
return $this.ds_1.kotlinx$atomicfu$value;
}
function _get_stateDebugRepresentation__bf18u4($this) {
var tmp0_subject = $this.fs();
var tmp;
if (!(tmp0_subject == null) ? isInterface(tmp0_subject, NotCompleted) : false) {
tmp = 'Active';
} else {
if (tmp0_subject instanceof CancelledContinuation) {
tmp = 'Cancelled';
} else {
tmp = 'Completed';
}
}
return tmp;
}
function isReusable($this) {
var tmp;
if (get_isReusableMode($this.hs_1)) {
var tmp_0 = $this.zr_1;
tmp = (tmp_0 instanceof DispatchedContinuation ? tmp_0 : THROW_CCE()).gs();
} else {
tmp = false;
}
return tmp;
}
function cancelLater($this, cause) {
if (!isReusable($this))
return false;
var tmp = $this.zr_1;
var dispatched = tmp instanceof DispatchedContinuation ? tmp : THROW_CCE();
return dispatched.is(cause);
}
function callSegmentOnCancellation($this, segment, cause) {
// Inline function 'kotlinx.coroutines.index' call
var index = $this.bs_1.kotlinx$atomicfu$value & 536870911;
// Inline function 'kotlin.check' call
if (!!(index === 536870911)) {
var message = 'The index for Segment.onCancellation(..) is broken';
throw IllegalStateException.t4(toString(message));
}
// Inline function 'kotlinx.coroutines.CancellableContinuationImpl.callCancelHandlerSafely' call
try {
segment.ns(index, cause, $this.sb());
} catch ($p) {
if ($p instanceof Error) {
var ex = $p;
handleCoroutineException($this.sb(), CompletionHandlerException.rs('Exception in invokeOnCancellation handler for ' + $this.toString(), ex));
} else {
throw $p;
}
}
}
function trySuspend($this) {
// Inline function 'kotlinx.atomicfu.loop' call
var this_0 = $this.bs_1;
while (true) {
var cur = this_0.kotlinx$atomicfu$value;
// Inline function 'kotlinx.coroutines.decision' call
switch (cur >> 29) {
case 0:
// Inline function 'kotlinx.coroutines.index' call
// Inline function 'kotlinx.coroutines.decisionAndIndex' call
var tmp$ret$2 = (1 << 29) + (cur & 536870911) | 0;
if ($this.bs_1.atomicfu$compareAndSet(cur, tmp$ret$2))
return true;
break;
case 2:
return false;
default:
// Inline function 'kotlin.error' call
var message = 'Already suspended';
throw IllegalStateException.t4(toString(message));
}
}
}
function tryResume($this) {
// Inline function 'kotlinx.atomicfu.loop' call
var this_0 = $this.bs_1;
while (true) {
var cur = this_0.kotlinx$atomicfu$value;
// Inline function 'kotlinx.coroutines.decision' call
switch (cur >> 29) {
case 0:
// Inline function 'kotlinx.coroutines.index' call
// Inline function 'kotlinx.coroutines.decisionAndIndex' call
var tmp$ret$2 = (2 << 29) + (cur & 536870911) | 0;
if ($this.bs_1.atomicfu$compareAndSet(cur, tmp$ret$2))
return true;
break;
case 1:
return false;
default:
// Inline function 'kotlin.error' call
var message = 'Already resumed';
throw IllegalStateException.t4(toString(message));
}
}
}
function installParentHandle($this) {
var tmp0_elvis_lhs = $this.sb().fc(Key_instance_2);
var tmp;
if (tmp0_elvis_lhs == null) {
return null;
} else {
tmp = tmp0_elvis_lhs;
}
var parent = tmp;
var handle = invokeOnCompletion(parent, VOID, new ChildContinuation($this));
$this.ds_1.atomicfu$compareAndSet(null, handle);
return handle;
}
function invokeOnCancellationImpl($this, handler) {
// Inline function 'kotlinx.coroutines.assert' call
// Inline function 'kotlinx.atomicfu.loop' call
var this_0 = $this.cs_1;
while (true) {
var state = this_0.kotlinx$atomicfu$value;
if (state instanceof Active) {
if ($this.cs_1.atomicfu$compareAndSet(state, handler))
return Unit_instance;
} else {
var tmp;
if (!(state == null) ? isInterface(state, CancelHandler) : false) {
tmp = true;
} else {
tmp = state instanceof Segment;
}
if (tmp) {
multipleHandlersError($this, handler, state);
} else {
if (state instanceof CompletedExceptionally) {
if (!state.ct()) {
multipleHandlersError($this, handler, state);
}
if (state instanceof CancelledContinuation) {
var tmp1_safe_receiver = state instanceof CompletedExceptionally ? state : null;
var cause = tmp1_safe_receiver == null ? null : tmp1_safe_receiver.at_1;
if (isInterface(handler, CancelHandler)) {
$this.xs(handler, cause);
} else {
var segment = handler instanceof Segment ? handler : THROW_CCE();
callSegmentOnCancellation($this, segment, cause);
}
}
return Unit_instance;
} else {
if (state instanceof CompletedContinuation) {
if (!(state.ts_1 == null)) {
multipleHandlersError($this, handler, state);
}
if (handler instanceof Segment)
return Unit_instance;
if (!isInterface(handler, CancelHandler))
THROW_CCE();
if (state.ys()) {
$this.xs(handler, state.ws_1);
return Unit_instance;
}
var update = state.zs(VOID, handler);
if ($this.cs_1.atomicfu$compareAndSet(state, update))
return Unit_instance;
} else {
if (handler instanceof Segment)
return Unit_instance;
if (!isInterface(handler, CancelHandler))
THROW_CCE();
var update_0 = new CompletedContinuation(state, handler);
if ($this.cs_1.atomicfu$compareAndSet(state, update_0))
return Unit_instance;
}
}
}
}
}
}
function multipleHandlersError($this, handler, state) {
// Inline function 'kotlin.error' call
var message = "It's prohibited to register multiple handlers, tried to register " + toString(handler) + ', already has ' + toString_0(state);
throw IllegalStateException.t4(toString(message));
}
function dispatchResume($this, mode) {
if (tryResume($this))
return Unit_instance;
dispatch($this, mode);
}
function resumedState($this, state, proposedUpdate, resumeMode, onCancellation, idempotent) {
var tmp;
if (proposedUpdate instanceof CompletedExceptionally) {
// Inline function 'kotlinx.coroutines.assert' call
// Inline function 'kotlinx.coroutines.assert' call
tmp = proposedUpdate;
} else {
if (!get_isCancellableMode(resumeMode) && idempotent == null) {
tmp = proposedUpdate;
} else {
var tmp_0;
var tmp_1;
if (!(onCancellation == null)) {
tmp_1 = true;
} else {
tmp_1 = isInterface(state, CancelHandler);
}
if (tmp_1) {
tmp_0 = true;
} else {
tmp_0 = !(idempotent == null);
}
if (tmp_0) {
tmp = new CompletedContinuation(proposedUpdate, isInterface(state, CancelHandler) ? state : null, onCancellation, idempotent);
} else {
tmp = proposedUpdate;
}
}
}
return tmp;
}
function tryResumeImpl($this, proposedUpdate, idempotent, onCancellation) {
// Inline function 'kotlinx.atomicfu.loop' call
var this_0 = $this.cs_1;
while (true) {
var tmp0 = this_0.kotlinx$atomicfu$value;
$l$block: {
if (!(tmp0 == null) ? isInterface(tmp0, NotCompleted) : false) {
var update = resumedState($this, tmp0, proposedUpdate, $this.hs_1, onCancellation, idempotent);
if (!$this.cs_1.atomicfu$compareAndSet(tmp0, update)) {
break $l$block;
}
detachChildIfNonReusable($this);
return get_RESUME_TOKEN();
} else {
if (tmp0 instanceof CompletedContinuation) {
var tmp;
if (!(idempotent == null) && tmp0.vs_1 === idempotent) {
// Inline function 'kotlinx.coroutines.assert' call
tmp = get_RESUME_TOKEN();
} else {
tmp = null;
}
return tmp;
} else {
return null;
}
}
}
}
}
function alreadyResumedError($this, proposedUpdate) {
// Inline function 'kotlin.error' call
var message = 'Already resumed, but proposed with update ' + toString_0(proposedUpdate);
throw IllegalStateException.t4(toString(message));
}
function detachChildIfNonReusable($this) {
if (!isReusable($this)) {
$this.dt();
}
}
function CancellableContinuationImpl$resume$lambda($onCancellation) {
return (cause, _unused_var__etf5q3, _unused_var__etf5q3_0) => {
$onCancellation(cause);
return Unit_instance;
};
}
var Active_instance;
function Active_getInstance() {
return Active_instance;
}
var properties_initialized_CancellableContinuationImpl_kt_xtzb03;
function _init_properties_CancellableContinuationImpl_kt__6rrtdd() {
if (!properties_initialized_CancellableContinuationImpl_kt_xtzb03) {
properties_initialized_CancellableContinuationImpl_kt_xtzb03 = true;
RESUME_TOKEN = new Symbol('RESUME_TOKEN');
}
}
function toState(_this__u8e3s4, caller) {
// Inline function 'kotlin.getOrElse' call
var exception = Result__exceptionOrNull_impl_p6xea9(_this__u8e3s4);
var tmp;
if (exception == null) {
var tmp_0 = _Result___get_value__impl__bjfvqg(_this__u8e3s4);
tmp = (tmp_0 == null ? true : !(tmp_0 == null)) ? tmp_0 : THROW_CCE();
} else {
tmp = new CompletedExceptionally(recoverStackTrace(exception, caller));
}
return tmp;
}
function toState_0(_this__u8e3s4) {
// Inline function 'kotlin.getOrElse' call
var exception = Result__exceptionOrNull_impl_p6xea9(_this__u8e3s4);
var tmp;
if (exception == null) {
var tmp_0 = _Result___get_value__impl__bjfvqg(_this__u8e3s4);
tmp = (tmp_0 == null ? true : !(tmp_0 == null)) ? tmp_0 : THROW_CCE();
} else {
tmp = new CompletedExceptionally(exception);
}
return tmp;
}
function CoroutineDispatcher$Key$_init_$lambda_akl8b5(it) {
return it instanceof CoroutineDispatcher ? it : null;
}
var Key_instance_0;
function Key_getInstance() {
if (Key_instance_0 === VOID)
new Key();
return Key_instance_0;
}
function handleCoroutineException(context, exception) {
var tmp;
if (exception instanceof DispatchException) {
tmp = exception.ev_1;
} else {
tmp = exception;
}
var reportException = tmp;
try {
var tmp0_safe_receiver = context.fc(Key_instance_1);
if (tmp0_safe_receiver == null)
null;
else {
// Inline function 'kotlin.let' call
tmp0_safe_receiver.gv(context, reportException);
return Unit_instance;
}
} catch ($p) {
if ($p instanceof Error) {
var t = $p;
handleUncaughtCoroutineException(context, handlerException(reportException, t));
return Unit_instance;
} else {
throw $p;
}
}
handleUncaughtCoroutineException(context, reportException);
}
var Key_instance_1;
function Key_getInstance_0() {
return Key_instance_1;
}
function handlerException(originalException, thrownException) {
if (originalException === thrownException)
return originalException;
// Inline function 'kotlin.apply' call
var this_0 = RuntimeException.vc('Exception while trying to handle coroutine exception', thrownException);
addSuppressed(this_0, originalException);
return this_0;
}
function delta($this, unconfined) {
return unconfined ? 4294967296n : 1n;
}
var ThreadLocalEventLoop_instance;
function ThreadLocalEventLoop_getInstance() {
if (ThreadLocalEventLoop_instance === VOID)
new ThreadLocalEventLoop();
return ThreadLocalEventLoop_instance;
}
var Key_instance_2;
function Key_getInstance_1() {
return Key_instance_2;
}
var NonDisposableHandle_instance;
function NonDisposableHandle_getInstance() {
return NonDisposableHandle_instance;
}
function invokeOnCompletion(_this__u8e3s4, invokeImmediately, handler) {
invokeImmediately = invokeImmediately === VOID ? true : invokeImmediately;
var tmp;
if (_this__u8e3s4 instanceof JobSupport) {
tmp = _this__u8e3s4.cw(invokeImmediately, handler);
} else {
var tmp_0 = handler.mu();
tmp = _this__u8e3s4.aw(tmp_0, invokeImmediately, JobNode$invoke$ref(handler));
}
return tmp;
}
function JobNode$invoke$ref(p0) {
var l = (_this__u8e3s4) => {
p0.kt(_this__u8e3s4);
return Unit_instance;
};
l.callableName = 'invoke';
return l;
}
var COMPLETING_ALREADY;
var COMPLETING_WAITING_CHILDREN;
var COMPLETING_RETRY;
var TOO_LATE_TO_CANCEL;
var SEALED;
var EMPTY_NEW;
function get_EMPTY_ACTIVE() {
_init_properties_JobSupport_kt__68f172();
return EMPTY_ACTIVE;
}
var EMPTY_ACTIVE;
function promoteEmptyToNodeList($this, state) {
var list = new NodeList();
var update = state.dw_1 ? list : new InactiveNodeList(list);
$this.bw_1.atomicfu$compareAndSet(state, update);
}
function promoteSingleToNodeList($this, state) {
state.yu(new NodeList());
// Inline function 'kotlinx.coroutines.internal.LockFreeLinkedListNode.nextNode' call
var list = state.tu_1;
$this.bw_1.atomicfu$compareAndSet(state, list);
}
var properties_initialized_JobSupport_kt_5iq8a4;
function _init_properties_JobSupport_kt__68f172() {
if (!properties_initialized_JobSupport_kt_5iq8a4) {
properties_initialized_JobSupport_kt_5iq8a4 = true;
COMPLETING_ALREADY = new Symbol('COMPLETING_ALREADY');
COMPLETING_WAITING_CHILDREN = new Symbol('COMPLETING_WAITING_CHILDREN');
COMPLETING_RETRY = new Symbol('COMPLETING_RETRY');
TOO_LATE_TO_CANCEL = new Symbol('TOO_LATE_TO_CANCEL');
SEALED = new Symbol('SEALED');
EMPTY_NEW = new Empty(false);
EMPTY_ACTIVE = new Empty(true);
}
}
function get_CLOSED() {
_init_properties_ConcurrentLinkedList_kt__5gcgzy();
return CLOSED;
}
var CLOSED;
function _SegmentOrClosed___init__impl__jnexvb(value) {
return value;
}
function _get_value__a43j40($this) {
return $this;
}
function _SegmentOrClosed___get_isClosed__impl__qmxmlo($this) {
return _get_value__a43j40($this) === get_CLOSED();
}
function _SegmentOrClosed___get_segment__impl__jvcr9l($this) {
var tmp;
if (_get_value__a43j40($this) === get_CLOSED()) {
var message = 'Does not contain segment';
throw IllegalStateException.t4(toString(message));
} else {
var tmp_0 = _get_value__a43j40($this);
tmp = tmp_0 instanceof Segment ? tmp_0 : THROW_CCE();
}
return tmp;
}
function _get_nextOrClosed__w0gmuv($this) {
return $this.ow_1.kotlinx$atomicfu$value;
}
function _get_aliveSegmentLeft__mr4ndu($this) {
var cur = $this.ww();
while (!(cur === null) && cur.nw())
cur = cur.pw_1.kotlinx$atomicfu$value;
return cur;
}
function _get_aliveSegmentRight__7ulr0b($this) {
// Inline function 'kotlinx.coroutines.assert' call
var cur = ensureNotNull($this.uw());
while (cur.nw()) {
var tmp0_elvis_lhs = cur.uw();
var tmp;
if (tmp0_elvis_lhs == null) {
return cur;
} else {
tmp = tmp0_elvis_lhs;
}
cur = tmp;
}
return cur;
}
function access$_get_nextOrClosed__ywzond($this) {
return _get_nextOrClosed__w0gmuv($this);
}
function findSegmentInternal(_this__u8e3s4, id, createNewSegment) {
_init_properties_ConcurrentLinkedList_kt__5gcgzy();
var cur = _this__u8e3s4;
$l$loop: while (cur.ls_1 < id || cur.nw()) {
// Inline function 'kotlinx.coroutines.internal.ConcurrentLinkedListNode.nextOrIfClosed' call
var this_0 = cur;
// Inline function 'kotlin.let' call
var it = access$_get_nextOrClosed__ywzond(this_0);
var tmp;
if (it === access$_get_CLOSED_$tConcurrentLinkedListKt_wmtpdy()) {
return _SegmentOrClosed___init__impl__jnexvb(get_CLOSED());
} else {
tmp = (it == null ? true : it instanceof ConcurrentLinkedListNode) ? it : THROW_CCE();
}
var next = tmp;
if (!(next == null)) {
cur = next;
continue $l$loop;
}
// Inline function 'kotlin.Long.plus' call
var this_1 = cur.ls_1;
var newTail = createNewSegment(add(this_1, fromInt(1)), cur);
if (cur.vw(newTail)) {
if (cur.nw()) {
cur.v5();
}
cur = newTail;
}
}
return _SegmentOrClosed___init__impl__jnexvb(cur);
}
function access$_get_CLOSED_$tConcurrentLinkedListKt_wmtpdy() {
return get_CLOSED();
}
var properties_initialized_ConcurrentLinkedList_kt_kwt434;
function _init_properties_ConcurrentLinkedList_kt__5gcgzy() {
if (!properties_initialized_ConcurrentLinkedList_kt_kwt434) {
properties_initialized_ConcurrentLinkedList_kt_kwt434 = true;
CLOSED = new Symbol('CLOSED');
}
}
function handleUncaughtCoroutineException(context, exception) {
var _iterator__ex2g4s = get_platformExceptionHandlers().g1();
while (_iterator__ex2g4s.f()) {
var handler = _iterator__ex2g4s.e();
try {
handler.gv(context, exception);
} catch ($p) {
if ($p instanceof ExceptionSuccessfullyProcessed) {
var _unused_var__etf5q3 = $p;
return Unit_instance;
} else {
if ($p instanceof Error) {
var t = $p;
propagateExceptionFinalResort(handlerException(exception, t));
} else {
throw $p;
}
}
}
}
try {
addSuppressed(exception, DiagnosticCoroutineContextException.bx(context));
} catch ($p) {
if ($p instanceof Error) {
var e = $p;
} else {
throw $p;
}
}
propagateExceptionFinalResort(exception);
}
function get_UNDEFINED() {
_init_properties_DispatchedContinuation_kt__tnmqc0();
return UNDEFINED;
}
var UNDEFINED;
function get_REUSABLE_CLAIMED() {
_init_properties_DispatchedContinuation_kt__tnmqc0();
return REUSABLE_CLAIMED;
}
var REUSABLE_CLAIMED;
function _get_reusableCancellableContinuation__9qex09($this) {
var tmp = $this.wr_1.kotlinx$atomicfu$value;
return tmp instanceof CancellableContinuationImpl ? tmp : null;
}
function safeDispatch(_this__u8e3s4, context, runnable) {
_init_properties_DispatchedContinuation_kt__tnmqc0();
try {
_this__u8e3s4.bv(context, runnable);
} catch ($p) {
if ($p instanceof Error) {
var e = $p;
throw DispatchException.dx(e, _this__u8e3s4, context);
} else {
throw $p;
}
}
}
function safeIsDispatchNeeded(_this__u8e3s4, context) {
_init_properties_DispatchedContinuation_kt__tnmqc0();
try {
return _this__u8e3s4.av(context);
} catch ($p) {
if ($p instanceof Error) {
var e = $p;
throw DispatchException.dx(e, _this__u8e3s4, context);
} else {
throw $p;
}
}
}
var properties_initialized_DispatchedContinuation_kt_2siadq;
function _init_properties_DispatchedContinuation_kt__tnmqc0() {
if (!properties_initialized_DispatchedContinuation_kt_2siadq) {
properties_initialized_DispatchedContinuation_kt_2siadq = true;
UNDEFINED = new Symbol('UNDEFINED');
REUSABLE_CLAIMED = new Symbol('REUSABLE_CLAIMED');
}
}
function get_isReusableMode(_this__u8e3s4) {
return _this__u8e3s4 === 2;
}
function get_isCancellableMode(_this__u8e3s4) {
return _this__u8e3s4 === 1 || _this__u8e3s4 === 2;
}
function dispatch(_this__u8e3s4, mode) {
// Inline function 'kotlinx.coroutines.assert' call
var delegate = _this__u8e3s4.et();
var undispatched = mode === 4;
var tmp;
var tmp_0;
if (!undispatched) {
tmp_0 = delegate instanceof DispatchedContinuation;
} else {
tmp_0 = false;
}
if (tmp_0) {
tmp = get_isCancellableMode(mode) === get_isCancellableMode(_this__u8e3s4.hs_1);
} else {
tmp = false;
}
if (tmp) {
var dispatcher = delegate.sr_1;
var context = delegate.sb();
if (safeIsDispatchNeeded(dispatcher, context)) {
safeDispatch(dispatcher, context, _this__u8e3s4);
} else {
resumeUnconfined(_this__u8e3s4);
}
} else {
resume(_this__u8e3s4, delegate, undispatched);
}
}
function resumeUnconfined(_this__u8e3s4) {
var eventLoop = ThreadLocalEventLoop_getInstance().tv();
if (eventLoop.nv()) {
eventLoop.mv(_this__u8e3s4);
} else {
// Inline function 'kotlinx.coroutines.runUnconfinedEventLoop' call
eventLoop.pv(true);
try {
resume(_this__u8e3s4, _this__u8e3s4.et(), true);
$l$loop: while (eventLoop.lv()) {
}
} catch ($p) {
if ($p instanceof Error) {
var e = $p;
_this__u8e3s4.fu(e);
} else {
throw $p;
}
}
finally {
eventLoop.qv(true);
}
}
}
function resume(_this__u8e3s4, delegate, undispatched) {
var state = _this__u8e3s4.ft();
var exception = _this__u8e3s4.cu(state);
var tmp;
if (!(exception == null)) {
// Inline function 'kotlin.Companion.failure' call
tmp = _Result___init__impl__xyqfz8(createFailure(exception));
} else {
// Inline function 'kotlin.Companion.success' call
var value = _this__u8e3s4.rt(state);
tmp = _Result___init__impl__xyqfz8(value);
}
var result = tmp;
if (undispatched) {
// Inline function 'kotlinx.coroutines.internal.DispatchedContinuation.resumeUndispatchedWith' call
var this_0 = delegate instanceof DispatchedContinuation ? delegate : THROW_CCE();
this_0.tr_1;
// Inline function 'kotlinx.coroutines.withContinuationContext' call
this_0.vr_1;
this_0.tr_1.ub(result);
} else {
delegate.ub(result);
}
}
function systemProp(propertyName, defaultValue, minValue, maxValue) {
minValue = minValue === VOID ? 1 : minValue;
maxValue = maxValue === VOID ? 2147483647 : maxValue;
return convertToInt(systemProp_0(propertyName, fromInt(defaultValue), fromInt(minValue), fromInt(maxValue)));
}
function systemProp_0(propertyName, defaultValue, minValue, maxValue) {
minValue = minValue === VOID ? 1n : minValue;
maxValue = maxValue === VOID ? 9223372036854775807n : maxValue;
var tmp0_elvis_lhs = systemProp_1(propertyName);
var tmp;
if (tmp0_elvis_lhs == null) {
return defaultValue;
} else {
tmp = tmp0_elvis_lhs;
}
var value = tmp;
var tmp1_elvis_lhs = toLongOrNull(value);
var tmp_0;
if (tmp1_elvis_lhs == null) {
var message = "System property '" + propertyName + "' has unrecognized value '" + value + "'";
throw IllegalStateException.t4(toString(message));
} else {
tmp_0 = tmp1_elvis_lhs;
}
var parsed = tmp_0;
if (!(minValue <= parsed ? parsed <= maxValue : false)) {
// Inline function 'kotlin.error' call
var message_0 = "System property '" + propertyName + "' should be in range " + minValue.toString() + '..' + maxValue.toString() + ", but is '" + parsed.toString() + "'";
throw IllegalStateException.t4(toString(message_0));
}
return parsed;
}
function get_NO_OWNER() {
_init_properties_Mutex_kt__jod56b();
return NO_OWNER;
}
var NO_OWNER;
var ON_LOCK_ALREADY_LOCKED_BY_OWNER;
function Mutex(locked) {
locked = locked === VOID ? false : locked;
_init_properties_Mutex_kt__jod56b();
return new MutexImpl(locked);
}
function MutexImpl$CancellableContinuationWithOwner$tryResume$lambda(this$0, this$1) {
return (_unused_var__etf5q3, _unused_var__etf5q3_0, _unused_var__etf5q3_1) => {
// Inline function 'kotlinx.coroutines.assert' call
this$0.ox_1.kotlinx$atomicfu$value = this$1.rx_1;
this$0.tx(this$1.rx_1);
return Unit_instance;
};
}
function MutexImpl$CancellableContinuationWithOwner$resume$lambda(this$0, this$1) {
return (it) => {
this$0.tx(this$1.rx_1);
return Unit_instance;
};
}
function holdsLockImpl($this, owner) {
$l$loop: while (true) {
if (!$this.ux())
return 0;
var curOwner = $this.ox_1.kotlinx$atomicfu$value;
if (curOwner === get_NO_OWNER())
continue $l$loop;
return curOwner === owner ? 1 : 2;
}
}
function *_generator_lock__qllepv($this, owner, $completion) {
if ($this.vx(owner))
return Unit_instance;
var tmp = lockSuspend($this, owner, $completion);
if (tmp === get_COROUTINE_SUSPENDED())
tmp = yield tmp;
return Unit_instance;
}
function lockSuspend($this, owner, $completion) {
var cancellable = getOrCreateCancellableContinuation(intercepted($completion));
try {
var contWithOwner = new CancellableContinuationWithOwner($this, cancellable, owner);
$this.acquireCont(contWithOwner);
} catch ($p) {
if ($p instanceof Error) {
var e = $p;
cancellable.pt();
throw e;
} else {
throw $p;
}
}
return cancellable.ot();
}
function tryLockImpl($this, owner) {
$l$loop: while (true) {
if ($this.dy()) {
// Inline function 'kotlinx.coroutines.assert' call
$this.ox_1.kotlinx$atomicfu$value = owner;
return 0;
} else {
if (owner == null)
return 1;
switch (holdsLockImpl($this, owner)) {
case 1:
return 2;
case 2:
return 1;
case 0:
continue $l$loop;
}
}
}
}
function MutexImpl$onSelectCancellationUnlockConstructor$lambda$lambda(this$0, $owner) {
return (_unused_var__etf5q3, _unused_var__etf5q3_0, _unused_var__etf5q3_1) => {
this$0.tx($owner);
return Unit_instance;
};
}
function MutexImpl$onSelectCancellationUnlockConstructor$lambda(this$0) {
return (_unused_var__etf5q3, owner, _unused_var__etf5q3_0) => MutexImpl$onSelectCancellationUnlockConstructor$lambda$lambda(this$0, owner);
}
var properties_initialized_Mutex_kt_yv4p3j;
function _init_properties_Mutex_kt__jod56b() {
if (!properties_initialized_Mutex_kt_yv4p3j) {
properties_initialized_Mutex_kt_yv4p3j = true;
NO_OWNER = new Symbol('NO_OWNER');
ON_LOCK_ALREADY_LOCKED_BY_OWNER = new Symbol('ALREADY_LOCKED_BY_OWNER');
}
}
function get_MAX_SPIN_CYCLES() {
_init_properties_Semaphore_kt__t514r6();
return MAX_SPIN_CYCLES;
}
var MAX_SPIN_CYCLES;
function get_PERMIT() {
_init_properties_Semaphore_kt__t514r6();
return PERMIT;
}
var PERMIT;
function get_TAKEN() {
_init_properties_Semaphore_kt__t514r6();
return TAKEN;
}
var TAKEN;
function get_BROKEN() {
_init_properties_Semaphore_kt__t514r6();
return BROKEN;
}
var BROKEN;
function get_CANCELLED() {
_init_properties_Semaphore_kt__t514r6();
return CANCELLED;
}
var CANCELLED;
function get_SEGMENT_SIZE() {
_init_properties_Semaphore_kt__t514r6();
return SEGMENT_SIZE;
}
var SEGMENT_SIZE;
function decPermits($this) {
$l$loop: while (true) {
var p = $this.by_1.atomicfu$getAndDecrement();
if (p > $this.wx_1)
continue $l$loop;
return p;
}
}
function coerceAvailablePermitsAtMaximum($this) {
$l$loop_0: while (true) {
var cur = $this.by_1.kotlinx$atomicfu$value;
if (cur <= $this.wx_1)
break $l$loop_0;
if ($this.by_1.atomicfu$compareAndSet(cur, $this.wx_1))
break $l$loop_0;
}
}
function addAcquireToQueue($this, waiter) {
var curTail = $this.zx_1.kotlinx$atomicfu$value;
var enqIdx = $this.ay_1.atomicfu$getAndIncrement$long();
var createNewSegment = createSegment$ref();
var tmp0 = $this.zx_1;
// Inline function 'kotlin.Long.div' call
var other = get_SEGMENT_SIZE();
var tmp2 = divide(enqIdx, fromInt(other));
var tmp$ret$3;
$l$block_2: {
// Inline function 'kotlinx.coroutines.internal.findSegmentAndMoveForward' call
while (true) {
var s = findSegmentInternal(curTail, tmp2, createNewSegment);
var tmp;
if (_SegmentOrClosed___get_isClosed__impl__qmxmlo(s)) {
tmp = true;
} else {
var tmp2_0 = _SegmentOrClosed___get_segment__impl__jvcr9l(s);
var tmp$ret$1;
$l$block_1: {
// Inline function 'kotlinx.coroutines.internal.moveForward' call
while (true) {
var cur = tmp0.kotlinx$atomicfu$value;
if (cur.ls_1 >= tmp2_0.ls_1) {
tmp$ret$1 = true;
break $l$block_1;
}
if (!tmp2_0.rw()) {
tmp$ret$1 = false;
break $l$block_1;
}
if (tmp0.atomicfu$compareAndSet(cur, tmp2_0)) {
if (cur.sw()) {
cur.v5();
}
tmp$ret$1 = true;
break $l$block_1;
}
if (tmp2_0.sw()) {
tmp2_0.v5();
}
}
tmp$ret$1 = Unit_instance;
}
tmp = tmp$ret$1;
}
if (tmp) {
tmp$ret$3 = s;
break $l$block_2;
}
}
}
var segment = _SegmentOrClosed___get_segment__impl__jvcr9l(tmp$ret$3);
// Inline function 'kotlin.Long.rem' call
var other_0 = get_SEGMENT_SIZE();
var tmp$ret$4 = modulo(enqIdx, fromInt(other_0));
var i = convertToInt(tmp$ret$4);
// Inline function 'kotlinx.coroutines.sync.SemaphoreSegment.cas' call
if (segment.oy_1.atomicfu$get(i).atomicfu$compareAndSet(null, waiter)) {
waiter.wt(segment, i);
return true;
}
var tmp4 = get_PERMIT();
// Inline function 'kotlinx.coroutines.sync.SemaphoreSegment.cas' call
var value = get_TAKEN();
if (segment.oy_1.atomicfu$get(i).atomicfu$compareAndSet(tmp4, value)) {
if (isInterface(waiter, CancellableContinuation)) {
if (!isInterface(waiter, CancellableContinuation))
THROW_CCE();
waiter.qr(Unit_instance, $this.cy_1);
} else {
if (isInterface(waiter, SelectInstance)) {
waiter.gx(Unit_instance);
} else {
// Inline function 'kotlin.error' call
var message = 'unexpected: ' + toString(waiter);
throw IllegalStateException.t4(toString(message));
}
}
return true;
}
// Inline function 'kotlinx.coroutines.assert' call
return false;
}
function tryResumeNextFromQueue($this) {
var curHead = $this.xx_1.kotlinx$atomicfu$value;
var deqIdx = $this.yx_1.atomicfu$getAndIncrement$long();
// Inline function 'kotlin.Long.div' call
var other = get_SEGMENT_SIZE();
var id = divide(deqIdx, fromInt(other));
var createNewSegment = createSegment$ref_0();
var tmp0 = $this.xx_1;
var tmp$ret$3;
$l$block_2: {
// Inline function 'kotlinx.coroutines.internal.findSegmentAndMoveForward' call
while (true) {
var s = findSegmentInternal(curHead, id, createNewSegment);
var tmp;
if (_SegmentOrClosed___get_isClosed__impl__qmxmlo(s)) {
tmp = true;
} else {
var tmp2 = _SegmentOrClosed___get_segment__impl__jvcr9l(s);
var tmp$ret$1;
$l$block_1: {
// Inline function 'kotlinx.coroutines.internal.moveForward' call
while (true) {
var cur = tmp0.kotlinx$atomicfu$value;
if (cur.ls_1 >= tmp2.ls_1) {
tmp$ret$1 = true;
break $l$block_1;
}
if (!tmp2.rw()) {
tmp$ret$1 = false;
break $l$block_1;
}
if (tmp0.atomicfu$compareAndSet(cur, tmp2)) {
if (cur.sw()) {
cur.v5();
}
tmp$ret$1 = true;
break $l$block_1;
}
if (tmp2.sw()) {
tmp2.v5();
}
}
tmp$ret$1 = Unit_instance;
}
tmp = tmp$ret$1;
}
if (tmp) {
tmp$ret$3 = s;
break $l$block_2;
}
}
}
var segment = _SegmentOrClosed___get_segment__impl__jvcr9l(tmp$ret$3);
segment.xw();
if (segment.ls_1 > id)
return false;
// Inline function 'kotlin.Long.rem' call
var other_0 = get_SEGMENT_SIZE();
var tmp$ret$4 = modulo(deqIdx, fromInt(other_0));
var i = convertToInt(tmp$ret$4);
// Inline function 'kotlinx.coroutines.sync.SemaphoreSegment.getAndSet' call
var value = get_PERMIT();
var cellState = segment.oy_1.atomicfu$get(i).atomicfu$getAndSet(value);
if (cellState === null) {
// Inline function 'kotlin.repeat' call
var times = get_MAX_SPIN_CYCLES();
var inductionVariable = 0;
if (inductionVariable < times)
do {
var index = inductionVariable;
inductionVariable = inductionVariable + 1 | 0;
// Inline function 'kotlinx.coroutines.sync.SemaphoreSegment.get' call
if (segment.oy_1.atomicfu$get(i).kotlinx$atomicfu$value === get_TAKEN())
return true;
}
while (inductionVariable < times);
var tmp4 = get_PERMIT();
// Inline function 'kotlinx.coroutines.sync.SemaphoreSegment.cas' call
var value_0 = get_BROKEN();
return !segment.oy_1.atomicfu$get(i).atomicfu$compareAndSet(tmp4, value_0);
} else if (cellState === get_CANCELLED())
return false;
else
return tryResumeAcquire($this, cellState);
}
function tryResumeAcquire($this, _this__u8e3s4) {
var tmp;
if (isInterface(_this__u8e3s4, CancellableContinuation)) {
if (!isInterface(_this__u8e3s4, CancellableContinuation))
THROW_CCE();
var token = _this__u8e3s4.or(Unit_instance, null, $this.cy_1);
var tmp_0;
if (!(token == null)) {
_this__u8e3s4.pr(token);
tmp_0 = true;
} else {
tmp_0 = false;
}
tmp = tmp_0;
} else {
if (isInterface(_this__u8e3s4, SelectInstance)) {
tmp = _this__u8e3s4.fx($this, Unit_instance);
} else {
var message = 'unexpected: ' + toString(_this__u8e3s4);
throw IllegalStateException.t4(toString(message));
}
}
return tmp;
}
function SemaphoreAndMutexImpl$onCancellationRelease$lambda(this$0) {
return (_unused_var__etf5q3, _unused_var__etf5q3_0, _unused_var__etf5q3_1) => {
this$0.jy();
return Unit_instance;
};
}
function createSegment$ref() {
var l = (p0, p1) => createSegment(p0, p1);
l.callableName = 'createSegment';
return l;
}
function createSegment$ref_0() {
var l = (p0, p1) => createSegment(p0, p1);
l.callableName = 'createSegment';
return l;
}
function createSegment(id, prev) {
_init_properties_Semaphore_kt__t514r6();
return new SemaphoreSegment(id, prev, 0);
}
var properties_initialized_Semaphore_kt_uqcwok;
function _init_properties_Semaphore_kt__t514r6() {
if (!properties_initialized_Semaphore_kt_uqcwok) {
properties_initialized_Semaphore_kt_uqcwok = true;
MAX_SPIN_CYCLES = systemProp('kotlinx.coroutines.semaphore.maxSpinCycles', 100);
PERMIT = new Symbol('PERMIT');
TAKEN = new Symbol('TAKEN');
BROKEN = new Symbol('BROKEN');
CANCELLED = new Symbol('CANCELLED');
SEGMENT_SIZE = systemProp('kotlinx.coroutines.semaphore.segmentSize', 16);
}
}
var counter;
function get_DEBUG() {
return DEBUG;
}
var DEBUG;
function get_classSimpleName(_this__u8e3s4) {
var tmp0_elvis_lhs = getKClassFromExpression(_this__u8e3s4).md();
return tmp0_elvis_lhs == null ? 'Unknown' : tmp0_elvis_lhs;
}
function get_hexAddress(_this__u8e3s4) {
// Inline function 'kotlin.js.asDynamic' call
var result = _this__u8e3s4.__debug_counter;
if (!(typeof result === 'number')) {
counter = counter + 1 | 0;
result = counter;
// Inline function 'kotlin.js.asDynamic' call
_this__u8e3s4.__debug_counter = result;
}
return ((!(result == null) ? typeof result === 'number' : false) ? result : THROW_CCE()).toString();
}
function propagateExceptionFinalResort(exception) {
console.error(exception.toString());
}
function createEventLoop() {
return new UnconfinedEventLoop();
}
function unsupported() {
throw UnsupportedOperationException.g9('runBlocking event loop is not supported');
}
function toDebugString(_this__u8e3s4) {
return toString(_this__u8e3s4);
}
function get_platformExceptionHandlers_() {
_init_properties_CoroutineExceptionHandlerImpl_kt__37d7wf();
return platformExceptionHandlers_;
}
var platformExceptionHandlers_;
function get_platformExceptionHandlers() {
_init_properties_CoroutineExceptionHandlerImpl_kt__37d7wf();
return get_platformExceptionHandlers_();
}
var properties_initialized_CoroutineExceptionHandlerImpl_kt_qhrgvx;
function _init_properties_CoroutineExceptionHandlerImpl_kt__37d7wf() {
if (!properties_initialized_CoroutineExceptionHandlerImpl_kt_qhrgvx) {
properties_initialized_CoroutineExceptionHandlerImpl_kt_qhrgvx = true;
// Inline function 'kotlin.collections.mutableSetOf' call
platformExceptionHandlers_ = LinkedHashSet.j1();
}
}
function recoverStackTrace(exception, continuation) {
return exception;
}
function systemProp_1(propertyName) {
return null;
}
function threadContextElements(context) {
return 0;
}
function commonThreadLocal(name) {
return new CommonThreadLocal();
}
//region block: post-declaration
initMetadataForInterface(CancellableContinuation, 'CancellableContinuation');
initMetadataForClass(SchedulerTask, 'SchedulerTask');
initMetadataForClass(DispatchedTask, 'DispatchedTask');
initMetadataForInterface(Waiter, 'Waiter');
initMetadataForClass(CancellableContinuationImpl, 'CancellableContinuationImpl', VOID, VOID, [DispatchedTask, CancellableContinuation, Waiter]);
initMetadataForInterface(NotCompleted, 'NotCompleted');
initMetadataForInterface(CancelHandler, 'CancelHandler', VOID, VOID, [NotCompleted]);
initMetadataForObject(Active, 'Active', VOID, VOID, [NotCompleted]);
initMetadataForClass(CompletedContinuation, 'CompletedContinuation');
initMetadataForClass(LockFreeLinkedListNode, 'LockFreeLinkedListNode', LockFreeLinkedListNode);
initMetadataForInterface(Incomplete, 'Incomplete');
initMetadataForClass(JobNode, 'JobNode', VOID, VOID, [LockFreeLinkedListNode, Incomplete]);
initMetadataForClass(ChildContinuation, 'ChildContinuation');
initMetadataForClass(CompletedExceptionally, 'CompletedExceptionally');
initMetadataForClass(CancelledContinuation, 'CancelledContinuation');
initMetadataForObject(Key, 'Key');
protoOf(CoroutineDispatcher).fc = get;
initMetadataForClass(CoroutineDispatcher, 'CoroutineDispatcher', VOID, VOID, [AbstractCoroutineContextElement, ContinuationInterceptor]);
initMetadataForObject(Key_0, 'Key');
initMetadataForClass(EventLoop, 'EventLoop');
initMetadataForObject(ThreadLocalEventLoop, 'ThreadLocalEventLoop');
initMetadataForClass(CompletionHandlerException, 'CompletionHandlerException');
initMetadataForClass(CoroutinesInternalError, 'CoroutinesInternalError');
initMetadataForObject(Key_1, 'Key');
initMetadataForObject(NonDisposableHandle, 'NonDisposableHandle');
initMetadataForClass(Empty, 'Empty', VOID, VOID, [Incomplete]);
initMetadataForClass(LockFreeLinkedListHead, 'LockFreeLinkedListHead', LockFreeLinkedListHead);
initMetadataForClass(NodeList, 'NodeList', NodeList, VOID, [LockFreeLinkedListHead, Incomplete]);
initMetadataForClass(SynchronizedObject, 'SynchronizedObject');
initMetadataForClass(Finishing, 'Finishing', VOID, VOID, [SynchronizedObject, Incomplete]);
initMetadataForClass(JobSupport, 'JobSupport', VOID, VOID, [Element], [0]);
initMetadataForClass(InactiveNodeList, 'InactiveNodeList', VOID, VOID, [Incomplete]);
initMetadataForClass(ConcurrentLinkedListNode, 'ConcurrentLinkedListNode');
initMetadataForClass(Segment, 'Segment', VOID, VOID, [ConcurrentLinkedListNode, NotCompleted]);
initMetadataForObject(ExceptionSuccessfullyProcessed, 'ExceptionSuccessfullyProcessed');
initMetadataForClass(DispatchedContinuation, 'DispatchedContinuation');
initMetadataForClass(DispatchException, 'DispatchException');
initMetadataForClass(Symbol, 'Symbol');
initMetadataForInterface(SelectInstance, 'SelectInstance');
initMetadataForClass(CancellableContinuationWithOwner, 'CancellableContinuationWithOwner', VOID, VOID, [CancellableContinuation, Waiter]);
initMetadataForClass(SemaphoreAndMutexImpl, 'SemaphoreAndMutexImpl', VOID, VOID, VOID, [0]);
initMetadataForClass(MutexImpl, 'MutexImpl', VOID, VOID, VOID, [1, 0]);
initMetadataForClass(SemaphoreSegment, 'SemaphoreSegment');
initMetadataForClass(UnconfinedEventLoop, 'UnconfinedEventLoop', UnconfinedEventLoop);
initMetadataForClass(DiagnosticCoroutineContextException, 'DiagnosticCoroutineContextException');
initMetadataForClass(ListClosed, 'ListClosed');
initMetadataForClass(CommonThreadLocal, 'CommonThreadLocal', CommonThreadLocal);
//endregion
//region block: init
Active_instance = new Active();
Key_instance_1 = new Key_0();
Key_instance_2 = new Key_1();
NonDisposableHandle_instance = new NonDisposableHandle();
counter = 0;
DEBUG = false;
//endregion
//region block: exports
export {
Mutex as Mutex16li1l0asjv17,
};
//endregion
//# sourceMappingURL=kotlinx-coroutines-core.mjs.map